📄 mmidc_storage.c
字号:
SCI_FREE(photo_info_ptr->photo_detail[i].name_ptr);
photo_info_ptr->photo_detail[i].name_ptr = PNULL;
}
}
//set global variable
SCI_MEMSET(&s_mmidc_photo_info, 0, sizeof(MMIDC_PHOTO_INFO_T));
if (MMI_GetUdiskStatus())
{
FindPhoto(FS_UDISK, photo_info_ptr);
}
if (MMI_GetSDStatus())
{
FindPhoto(FS_MMC, photo_info_ptr);
}
if(photo_info_ptr->total_num>0)
{
// 对所有读取的图片进行排序操作
qsort(
photo_info_ptr->photo_detail,
photo_info_ptr->total_num,
sizeof(MMIDC_PHOTO_DETAIL_T),
SortByTime);
}
}
/*****************************************************************************/
// Description : sort function by file time
// Global resource dependence :
// Author: lin.lin
// Note:
/*****************************************************************************/
LOCAL int SortByTime(const void *arg1, const void *arg2)
{
uint32 time1 = 0,time2 = 0;
MMI_TM_T tm1,tm2;
MMIDC_PHOTO_DETAIL_T *photo_arg1 = (MMIDC_PHOTO_DETAIL_T*)arg1;
MMIDC_PHOTO_DETAIL_T *photo_arg2 = (MMIDC_PHOTO_DETAIL_T*)arg2;
SCI_ASSERT(PNULL != photo_arg1);
SCI_ASSERT(PNULL != photo_arg2);
//get the strut time
tm1 = MMI_FatData2Tm(photo_arg1->time);
tm2 = MMI_FatData2Tm(photo_arg2->time);
//translate to seconds
time1 = MMI_Tm2Second(tm1.tm_sec,tm1.tm_min,tm1.tm_hour,tm1.tm_mday,tm1.tm_mon,tm1.tm_year);
time2 = MMI_Tm2Second(tm2.tm_sec,tm2.tm_min,tm2.tm_hour,tm2.tm_mday,tm2.tm_mon,tm2.tm_year);
if(time1 == time2)
{
return 0;
}
else if(time1 > time2)
{
return 1;
}
else
{
return -1;
}
}
/*****************************************************************************/
// Description : init the photo detail according the find photo file
// Global resource dependence :
// Author: Great.Tian
// Note:
/*****************************************************************************/
LOCAL BOOLEAN InitPhotoDetail(
MMIDC_PHOTO_DETAIL_T* detail_ptr,
FILE_DEV_E_T e_file_dev,
FFS_FIND_DATA_T* fd_ptr
)
{
uint16 name_len = 0;
uint16 *name_ptr = PNULL;
DC_ASSERT_LOW(detail_ptr != PNULL && fd_ptr != PNULL);
//check file attribute
if ((fd_ptr->attr & ATTR_DIR) != 0)
{
SCI_TRACE_LOW("mmidc_storage.c:InitPhotoDetail, find ATTR_DIR");
return FALSE;
}
//check file name, if longer than (MMIDC_MAX_PHOTO_NAME_LEN + 2 * MMIDC_DEFAULT_SUBFIX_LEN), I will ignore it
name_len = 2 * DCGetWcharlength((uint16 *)fd_ptr->name);
if (name_len > MMIDC_MAX_PHOTO_NAME_LEN) //@cr73752
{
return FALSE;
}
//save file device
detail_ptr->location = e_file_dev;
//save file name
name_ptr = SCI_ALLOC(MMIDC_MAX_PHOTO_NAME_LEN + 2);
SCI_MEMSET(name_ptr, 0, MMIDC_MAX_PHOTO_NAME_LEN + 2);
detail_ptr->name_len = name_len - 2 * MMIDC_DEFAULT_SUBFIX_LEN; //delete the ".jpg" subfix
SCI_MEMCPY(name_ptr, fd_ptr->name, detail_ptr->name_len);
detail_ptr->name_ptr = name_ptr;
// save file time when created
detail_ptr->time = fd_ptr->create_time;
SCI_TRACE_LOW("mmidc_storage.c:InitPhotoDetail: detail_ptr->time = %d!", detail_ptr->time);
// set memory size
detail_ptr->memory_size = fd_ptr->length;
//set width and heigh
detail_ptr->width = 0;
detail_ptr->height = 0;
return TRUE;
}
/*****************************************************************************/
// Description : get wchar length
// Global resource dependence :
// Author: Bruce.Chi
// Note:
///*****************************************************************************/
LOCAL uint32 DCGetWcharlength(
uint16* pwchar
)
{
uint16 i=0;
uint8 *str=NULL;
str=(uint8*)pwchar;
while (!((*str == '\0') && (*(str+1) == '\0')))
{
i++;
str++;
str++;
}
return(i);
}
/*****************************************************************************/
// Description : load album to window
// Global resource dependence :
// Author:bruce.chi
// Note: it is placed in inversed order
/*****************************************************************************/
PUBLIC BOOLEAN LoadAlbum(MMI_CTRL_ID_T list_ctrl_id )
{
MMIDC_PHOTO_INFO_T *photo_info_ptr = &s_mmidc_photo_info;
MMIDC_PHOTO_DETAIL_T photo_detail = {0};
uint32 photo_num = 0;
int i = 0;
photo_num = photo_info_ptr->total_num;
if (0 == photo_num)
{
return FALSE;
}
GUILISTBOX_SetMaxItem(list_ctrl_id, photo_num);
GUILISTBOX_SetNeedDisplayInfo(list_ctrl_id, TRUE);
for (i = photo_num - 1; i >= 0; i--)
{
photo_detail = photo_info_ptr->photo_detail[i];
DC_AddItemToListbox(list_ctrl_id, (uint8 *)photo_detail.name_ptr, photo_detail.name_len, photo_detail.location);
}
return TRUE;
}
/*****************************************************************************/
// Description : add get index in s_mmidc_photo_info.detail[] according to the list index
// Global resource dependence :
// Author:bruce.chi
// Note: it is placed in inversed order
/*****************************************************************************/
PUBLIC uint32 DCSaveList_GetPhotoIndex(uint32 list_index)
{
DC_ASSERT_LOW(list_index < MMIDC_MAX_PHOTO_NUM);
return (s_mmidc_photo_info.total_num - 1 - list_index);
}
/*****************************************************************************/
// Description : add item to listbox
// Global resource dependence :
// Author:bruce.chi
// Note: make sure it is ucs2
/*****************************************************************************/
LOCAL BOOLEAN DC_AddItemToListbox(
MMI_CTRL_ID_T list_ctrl_id,
uint8 *str,
uint8 str_len,
FILE_DEV_E_T device
)
{
GUI_LISTBOX_ITEM_T item = {0};
DC_ASSERT_LOW(PNULL != str);
SCI_MEMSET(&item, 0, sizeof(item));
item.str_len = MIN(str_len, LISTBOX_STRING_MAX_NUM);
MMI_MEMCPY(item.str, LISTBOX_STRING_MAX_NUM, str, str_len, item.str_len);
// Check WallPaper
if (IsDCWallpaper((uint16 *)str, (uint16)str_len, device))
{
item.left_icon_id = IMAGE_SELECT_TICK_ON_PIC;
}
else
{
item.left_icon_id = IMAGE_MULTIMEDIA_CAMERA_PIC_ICON;
}
item.is_ucs2 = TRUE;
item.softkey_id[0] = STXT_OK;
item.softkey_id[1] = TXT_NULL;
item.softkey_id[2] = STXT_RETURN;
GUILISTBOX_AppendItem(list_ctrl_id, &item);
return TRUE;
}
/*****************************************************************************/
// Description : is this photo set as wall paper
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC BOOLEAN IsDCWallpaper(
uint16 *name,
uint16 name_len,
FILE_DEV_E_T device
)
{
uint16 ucs2_name_arr[(MMIDC_MAX_PHOTO_NAME_LEN + MMIDC_DEFAULT_SUBFIX_LEN * 2 + 4) / 2] = {0};
uint16 ucs2_name_len = 0;
//add subfix
SCI_MEMCPY(ucs2_name_arr, name, name_len);
ucs2_name_len = MMISTR_AddSubfix((uint8 *)ucs2_name_arr, name_len, TRUE, (uint8 *)MMIDC_DEFAULT_SUBFIX, MMIDC_DEFAULT_SUBFIX_LEN);
//it is ucs2
return (MMIMULTIM_CheckDCName(ucs2_name_arr, ucs2_name_len, device));
}
/*****************************************************************************/
// Description : Allocate memory to store one jpg
// Global resource dependence : none
// Author:bruce.chi
// Note:
/*****************************************************************************/
PUBLIC uint8 *MMIDC_AllocJpegMemory(
uint32 buf_length
)
{
uint8* buff1_ptr= PNULL;
uint8* buff2_ptr= PNULL;
SCI_TRACE_LOW("mmidc_storage.c MMIDC_AllocJpegMemory");
if (buf_length > MMIDC_MAX_PHOTO_SIZE)
{
return PNULL;
}
#ifndef MMI_NOR_VERSION
return BL_Malloc(BLOCK_MEM_POOL_2);
#else
FreeYUVExtBuffer();
buff1_ptr = BL_Malloc(BLOCK_MEM_POOL_3);
SCI_ASSERT(buff1_ptr!=PNULL);
buff2_ptr = BL_Malloc(BLOCK_MEM_POOL_4);
SCI_ASSERT(buff2_ptr!=PNULL);
return buff1_ptr;
#endif
}
/*****************************************************************************/
// Description : free the memory allocated by MMIDC_AllocJpegMemory
// Global resource dependence : none
// Author:bruce.chi
// Note:
/*****************************************************************************/
PUBLIC BOOLEAN FreeJpegMemory(void *buf_ptr)
{
SCI_TRACE_LOW("mmidc_storage.c FreeJpegMemory");
#ifndef MMI_NOR_VERSION
BL_Free(BLOCK_MEM_POOL_2);
#else
BL_Free(BLOCK_MEM_POOL_3);
BL_Free(BLOCK_MEM_POOL_4);
#endif
return TRUE;
}
/*****************************************************************************/
// Description : Reset DC
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
BOOLEAN MMIDC_ResetDCGlobe(void)
{
int32 i = 0;
uint16 ucs2_path_name[32] = {0};
MMIDC_PHOTO_INFO_T* photo_info_ptr = &s_mmidc_photo_info;
//this funciton will be call by MMIUDISK_FormatUdisk() when udisk is formatted, so I have to free the allcated name buffer
for (i = 0; i < photo_info_ptr->total_num; i++)
{
if (photo_info_ptr->photo_detail[i].name_ptr != PNULL)
{
SCI_FREE(photo_info_ptr->photo_detail[i].name_ptr);
}
}
SCI_MEMSET(&s_mmidc_photo_info, 0, sizeof(s_mmidc_photo_info));
GUI_GB2UCS(ucs2_path_name, (uint8 *)MMIDC_DEFAULT_DIR, strlen(MMIDC_DEFAULT_DIR));
if (MMI_GetUdiskStatus())
{
FILE_CdRootPath(FS_UDISK);
FFS_CreateDir(FS_UDISK, (const wchar*)ucs2_path_name);
}
if(MMI_GetSDStatus())
{
FILE_CdRootPath(FS_MMC);
FFS_CreateDir(FS_MMC, (const wchar*)ucs2_path_name);
}
return TRUE;
}
/*****************************************************************************/
// Description : open album window for mms
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC BOOLEAN MMIDC_OpenAlbumWinForMMS(int max_size, MMI_WIN_ID_T win_id)
{
MMIDC_ALBUM_OPEN_FROM open_album_status = {0};
if (DCSaveInfo_GetPotoTotalNum() >0)
{
if (MMK_IsOpenWin(MMIDC_ALBUM_WIN_ID))
{
MMK_CloseWin(MMIDC_ALBUM_WIN_ID);
MMK_CloseWin(MMIDC_BROWSER_WIN_ID);
MMK_CloseWin(MMIDC_PICOPTION_WIN_ID);
}
//open album window
open_album_status.is_from_mms = TRUE;
open_album_status.max_siz = max_size;
open_album_status.win_id = win_id;
MMIDC_OpenAlbumWin(open_album_status);
return TRUE;
}
else
{
PUBWIN_OpenPromptAlertWin(PUBWIN_SOFTKEY_ONE,TXT_MMIMULTIM_NOPICTURE,IMAGE_PROMPT_ICON_ALERT,MMI_3SECONDS,PNULL);
return FALSE;
}
}
#endif //_MMIDC_STORAGE_C_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -