📄 myringer.step4
字号:
STRCPY(szBuf, "Create RingerMgr failed!");
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
}
//lab 4
NumberOfFormats = IRINGERMGR_GetNumberFormats(pMe->m_pIRingerMgr);
IRINGERMGR_GetFormats(pMe->m_pIRingerMgr, pwFormats, NumberOfFormats);
//end of lab 4
STRCPY(szBuf, "Support Format: \n");
for (i = 0; i<NumberOfFormats; i++)
{
DBGPRINTF("Support Format: %d", (int)pwFormats[i]);
STRCAT(szBuf, FormatList[(int)pwFormats[i]]);
}
CleanUp(pMe);
}
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
case RT_PLAY:
{
AEERingerID ringId = GetFirstRingerID(pMe);
STRTOWSTR("Play", pMe->m_szTitle, sizeof(pMe->m_szTitle));
if (ringId != AEE_RINGER_ID_NONE)
{
if(pMe->m_pIRingerMgr == NULL)
{
DBGPRINTF("Create RingerMgr failed!");
STRCPY(szBuf, "Create RingerMgr failed!");
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
}
}
else
{
STRCPY(szBuf, "No Ringer Avail.");
}
}
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
case RT_SETRINGER:
{
AEERingerID ringId = GetFirstRingerID(pMe);
STRTOWSTR("SetRinger", pMe->m_szTitle, sizeof(pMe->m_szTitle));
if (ringId != AEE_RINGER_ID_NONE)
{
if(pMe->m_pIRingerMgr == NULL)
{
DBGPRINTF("Create RingerMgr failed!");
STRCPY(szBuf, "Create RingerMgr failed!");
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
}
}
else
{
STRCPY(szBuf, "No Ringer Avail.");
}
}
CleanUp(pMe);
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
case RT_REMOVE:
{
AEERingerID ringId = GetFirstRingerID(pMe);
STRTOWSTR("Remove", pMe->m_szTitle, sizeof(pMe->m_szTitle));
if (ringId != AEE_RINGER_ID_NONE)
{
if(pMe->m_pIRingerMgr == NULL)
{
DBGPRINTF("Create RingerMgr failed!");
STRCPY(szBuf, "Create RingerMgr failed!");
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
}
}
else
{
STRCPY(szBuf, "No Ringer Avail.");
}
}
CleanUp(pMe);
STRTOWSTR(szBuf, pMe->m_pszText, TEXT_BUFFER_SIZE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
DisplayText(pMe);
return TRUE;
case SOFTMENU_BACK:
// Go back to the mainmenu
ISTATIC_Release (pMe->m_pIStatic);
pMe->m_pIStatic = NULL;
IMENUCTL_SetActive(pMe->m_pISoftMenu, FALSE);
IMENUCTL_SetActive(pMe->m_pIMainMenu, TRUE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
IMENUCTL_Redraw(pMe->m_pIMainMenu);
return TRUE;
default:
return FALSE;
}
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean myringer_InitAppData(myringer* pMe)
{
AECHAR szBuf[15];
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
pMe->m_pIFileMgr = NULL;
pMe->m_pIFile = NULL;
pMe->m_pIStatic = NULL;
pMe->m_pIRingerMgr = NULL;
pMe->m_pISoftMenu = NULL;
pMe->m_pIMainMenu = NULL;
pMe->m_pMemStream = NULL;
pMe->m_pBuff = NULL;
if ((pMe->m_pszText = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL)
return FALSE;
// Create the Main Menu
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MENUCTL, (void * *) (&(pMe->m_pIMainMenu))) != SUCCESS )
{
FREE(pMe->m_pszText);
return FALSE;
}
// Create the Soft Menu Menu
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SOFTKEYCTL, (void * *) (&(pMe->m_pISoftMenu))) != SUCCESS )
{
FREE(pMe->m_pszText);
IMENUCTL_Release(pMe->m_pIMainMenu);
return FALSE;
}
//Add individual entries to the Menu
// Add Back to menu
STR_TO_WSTR("Back", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pISoftMenu, 0, 0, SOFTMENU_BACK, szBuf, 0);
return TRUE;
}
// this function is called when your application is exiting
void myringer_FreeAppData(myringer* pMe)
{
CleanUp(pMe);
if(pMe->m_pISoftMenu != NULL)
{
IMENUCTL_Release(pMe->m_pISoftMenu);
pMe->m_pISoftMenu = NULL;
}
if(pMe->m_pIMainMenu != NULL)
{
IMENUCTL_Release(pMe->m_pIMainMenu);
pMe->m_pIMainMenu = NULL;
}
if (pMe->m_pIStatic != NULL)
{
ISTATIC_Release (pMe->m_pIStatic);
pMe->m_pIStatic = NULL;
}
if (pMe->m_pszText != NULL)
{
FREE(pMe->m_pszText);
pMe->m_pszText = NULL;
}
}
static void DisplayText(myringer* pMe)
{
AEERect rect;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_STATIC, (void **)&(pMe->m_pIStatic)) != SUCCESS)
return;
SETAEERECT(&rect, 2, 2, pMe->DeviceInfo.cxScreen - 4, pMe->DeviceInfo.cyScreen - BOTTOM_TEXT_HEIGHT);
IMENUCTL_SetActive(pMe->m_pIMainMenu,FALSE);
IDISPLAY_ClearScreen(pMe->pIDisplay);
ISTATIC_SetRect(pMe->m_pIStatic, &rect);
if (ISTATIC_SetText(pMe->m_pIStatic, pMe->m_szTitle, pMe->m_pszText, AEE_FONT_BOLD, AEE_FONT_NORMAL) == FALSE)
{
ISTATIC_Release (pMe->m_pIStatic);
pMe->m_pIStatic = NULL;
return;
}
ISTATIC_Redraw(pMe->m_pIStatic);
IMENUCTL_SetActive(pMe->m_pISoftMenu,TRUE);
IDISPLAY_Update(pMe->pIDisplay);
}
static void BuildMainMenu(myringer* pMe)
{
AECHAR szBuf[40];
AEERect rect;
SETAEERECT(&rect, 0, 0, pMe->DeviceInfo.cxScreen, pMe->DeviceInfo.cyScreen);
IMENUCTL_SetRect(pMe->m_pIMainMenu, &rect);
// Set Title
STR_TO_WSTR("Ringer Test", szBuf, sizeof(szBuf));
IMENUCTL_SetTitle(pMe->m_pIMainMenu, NULL, 0, szBuf);
//Add individual entries to the Menu
STR_TO_WSTR("1. Create", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_CREATE, szBuf, 0);
STR_TO_WSTR("2. EnumCategory", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_ENUMCATEGORY, szBuf, 0);
STR_TO_WSTR("3. EnumRinger", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_ENUMRINGER, szBuf, 0);
STR_TO_WSTR("4. RingerFormat", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_RINGERFORMAT, szBuf, 0);
STR_TO_WSTR("5. Play", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_PLAY, szBuf, 0);
STR_TO_WSTR("6. SetRinger", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_SETRINGER, szBuf, 0);
STR_TO_WSTR("7. Remove", szBuf, sizeof(szBuf));
IMENUCTL_AddItem(pMe->m_pIMainMenu, 0, 0, RT_REMOVE, szBuf, 0);
if(pMe->m_pISoftMenu)
IMENUCTL_SetActive(pMe->m_pISoftMenu,FALSE);
IMENUCTL_SetActive(pMe->m_pIMainMenu,TRUE);
}
static void CleanUp(myringer* pMe)
{
if (pMe->m_pIRingerMgr != NULL)
{
// Deregister Notify so that
IRINGERMGR_RegisterNotify (pMe->m_pIRingerMgr, NULL, NULL);
// Stop any songs being played at this time
IRINGERMGR_Stop (pMe->m_pIRingerMgr);
IRINGERMGR_Release (pMe->m_pIRingerMgr);
pMe->m_pIRingerMgr = NULL;
}
if (pMe->m_pIFile != NULL)
{
IFILE_Release(pMe->m_pIFile);
pMe->m_pIFile = NULL;
}
if (pMe->m_pIFileMgr != NULL)
{
IFILEMGR_Release(pMe->m_pIFileMgr);
pMe->m_pIFileMgr = NULL;
}
if (pMe->m_pMemStream != NULL)
{
IMEMASTREAM_Release(pMe->m_pMemStream);
pMe->m_pMemStream = NULL;
}
}
static AEERingerID GetFirstRingerID(myringer* pMe)
{
AEERingerInfo ringerinfo;
AEERingerID ringerId = AEE_RINGER_ID_NONE;
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);
if(pMe->m_pIRingerMgr == NULL)
{
return ringerId;
}
if (SUCCESS != IRINGERMGR_EnumRingerInit(pMe->m_pIRingerMgr))
goto Exit;
while (IRINGERMGR_EnumNextRinger(pMe->m_pIRingerMgr, &ringerinfo))
{
char name[MAX_RINGER_NAME+1];
WSTRTOSTR(ringerinfo.szName, name, MAX_RINGER_NAME);
ringerId = ringerinfo.id;
break;
}
Exit:
CleanUp(pMe);
return ringerId;
}
static boolean CreateRinger(myringer* pMe, const char * ringername, const char * inputfile, AEESoundPlayerFile format)
{
FileInfo fi;
AECHAR rngName[15] ;
boolean bRet = FALSE;
if ( ringername )
{
STRTOWSTR(ringername, rngName, sizeof(rngName) );
}
else
return bRet;
//lab 1
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);
//end of lab 1
if(pMe->m_pIRingerMgr == NULL)
{
return bRet;
}
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR, (void **)(&pMe->m_pIFileMgr));
if (NULL == pMe->m_pIFileMgr)
goto Exit;
if (NULL == (pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, inputfile, _OFM_READ)))
goto Exit;
IFILE_GetInfo(pMe->m_pIFile, &fi);
if (NULL == (pMe->m_pBuff = (byte *) MALLOC(fi.dwSize)))
goto Exit;
if (IFILE_Read(pMe->m_pIFile, (void *)pMe->m_pBuff, fi.dwSize) == 0)
goto Exit;
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MEMASTREAM, (void **)(&pMe->m_pMemStream));
if (NULL == pMe->m_pMemStream)
goto Exit;
IMEMASTREAM_Set(pMe->m_pMemStream, pMe->m_pBuff, fi.dwSize, 0, 0);
//lab 1
if (SUCCESS == IRINGERMGR_Create(pMe->m_pIRingerMgr, (AECHAR*)rngName, format, (IAStream*)pMe->m_pMemStream))
bRet = TRUE;
//end of lab 1
Exit:
CleanUp(pMe);
return bRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -