chxavplayerui.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,429 行 · 第 1/3 页
CPP
1,429 行
m_spCloseAppWaitNote->EndL();
if( !bGotIt )
{
CHXAvMessageDialog::DoAlertErrorL(CHXAvCleanString(R_AVP_N_FAILED_TO_CLOSE_OTHER_INSTANCE)());
}
}
return bGotIt;
}
/*
* EnsureUniqueInstanceL
* ------------
* ensure that we close any other app instances
* that might be running
*
*/
void CHXAvPlayerUI::EnsureUniqueInstanceL()
{
m_spCloseAppWaitNote = new (ELeave) CHXAvWaitNote();
m_spCloseAppWaitNote->SetTextL(CHXAvCleanString(R_AVP_N_CLOSING_OTHER_INSTANCE)());
// token name for controlling single instance
_LIT(KUniqueInstanceSemName, "HelixPlayer10009D06");
m_instanceToken.ConstructL(KUniqueInstanceSemName);
if(!EnsureUniqueInstanceHelperL())
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::EnsureUniqueInstanceL(): other instance failed to close"));
HXSYM_LEAVE(KLeaveWithoutAlert);
}
}
////////////////////////////////////////////
//
TBool CHXAvPlayerUI::ProcessCommandParametersL(TApaCommand idCmd,
TFileName& aDocumentName,
const TDesC8& /*aTail*/)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::ProcessCommandParametersL(%d))\n", idCmd));
DPRINTF(SYMP_INFO, ("doc = '%s'\n", dbg::CharPtr(aDocumentName)()));
// this (call to 2-arg override) causes doc name to be given a new name
// return CAknViewAppUi::ProcessCommandParametersL(idCmd, aDocumentName);
// this (default) results in CEikDocument::OpenFileL not being called
// return CAknViewAppUi::ProcessCommandParametersL(idCmd, aDocumentName, aTail);
// ensures that CEikDocument::OpenFileL is called if a command line arg was provided
return EFalse;
}
////////////////////////////////////////////
// get here if:
//
// o click on file in file browser (while our app is running)
// o click on app in file browser (while our app is running)
// o someone calls TApaTask::SwitchOpenFile()
// o our document calls us because it gets the openfile request
//
// all external ways of getting an argument, file, etc. end up
// here
//
// fileArg can be in local path form ('c:\myfolder\file.rm') or
// url form ('rtsp://dfsd/sdf/foo.rm')
//
void CHXAvPlayerUI::OpenFileL(const TDesC& fileArg)
{
DPRINTF(SYMP_INFO,("avPlayerUI::OpenFileL(): '%s'\n", dbg::CharPtr(fileArg)()));
bool bIsUrl = CHXAvUtil::IsValidUrl(fileArg);
if( bIsUrl )
{
// an URL was passed as the argument
ActivatePlayViewL(fileArg);
}
else
{
// local file (most likely case)
HBufC* pFile = CHXAvFile::AllocFileUrlL(fileArg);
AUTO_PUSH_POP_DEL(pFile);
ActivatePlayViewL(*pFile);
}
}
#if(0)
/*
* CAknViewAppUi::HandleForegroundEventL
* ----------------------
*
* Called when app gains/looses foreground (not when app views are switching)
*
*/
void CHXAvPlayerUI::HandleForegroundEventL(TBool bEnterForeground)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleForegroundEventL(): enter = '%s'\n", dbg::Bool(bEnterForeground)));
CAknViewAppUi::HandleForegroundEventL(bEnterForeground);
}
#endif
/*
* CAknViewAppUi::HandleViewDeactivation
* ----------------------
* Switch views. Set the correct back view index for future switches.
* This is called, then DoActivate for new view, then DoDeactivate for old view.
*/
void
CHXAvPlayerUI::HandleViewDeactivation(const TVwsViewId& idOldView, const TVwsViewId& idNewView)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleViewDeactivation()\n"));
bool bIsInterAppViewSwitch = (idOldView.iAppUid != idNewView.iAppUid);
if(!bIsInterAppViewSwitch)
{
// Activating another view in our own app...
HX_ASSERT(idOldView.iAppUid == CHXAvMisc::KAppUID);
TUid idNew = idNewView.iViewUid;
TUid idOld = idOldView.iViewUid;
// special case: if settings view is activating, tell player view not
// to shut down the player so return gets user back to previous player state
if(idOld == TUid::Uid(VID_PlayerView) && idNew == TUid::Uid(VID_SelectSettingsView))
{
CHXAvPlayView* pPlayView = GetPlayView();
pPlayView->SetShutdownOnViewDeactivation(false);
}
CHXAvViewBase * pNewView = static_cast<CHXAvViewBase *>(View(idNew));
CHXAvViewBase * pOldView = static_cast<CHXAvViewBase *>(View(idOld));
HX_ASSERT(pNewView);
HX_ASSERT(pOldView);
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleViewDeactivation(): old = %d; new = %d\n", idOld.iUid, idNew.iUid));
if( idNew == TUid::Uid(m_idxDefaultView) )
{
// Default view is activating; there is no "last view" to go back to...
pNewView->SetBackView(-1);
}
else
{
// Do nothing if returning back to old view that 'launched' the new (now becoming old) view...
bool bReturning = (pOldView->GetBackView() == pNewView->Id().iUid);
// Don't set back view to self...
bool bSame = (pNewView->Id() == pOldView->Id());
if(!bReturning && !bSame)
{
pNewView->SetBackView(pOldView->Id().iUid);
}
}
}
CAknViewAppUi::HandleViewDeactivation(idOldView, idNewView);
}
/*
* DoBackFromCurrentViewL
* ----------------------
* Go back to the previous view from here.
*
*/
void
CHXAvPlayerUI::DoBackFromCurrentViewL()
{
HX_ASSERT(iView);
CHXAvViewBase *pView = static_cast<CHXAvViewBase *>(iView);
TInt idxBackView = pView->GetBackView();
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::DoBackFromCurrentViewL(): back view = %d\n", idxBackView));
if (idxBackView == -1)
{
// If there's no view to go back to, exit...
HX_ASSERT( TUid::Uid(m_idxDefaultView) == iView->Id());
HandleCommandL(EEikCmdExit);
}
else
{
// note: call to base class is intentional
HX_ASSERT( TUid::Uid(m_idxDefaultView) != iView->Id());
ActivateLocalViewL(TUid::Uid(idxBackView));
}
}
////////////////////////////////////////
// TWsEvent beyond EEventUser received...
void CHXAvPlayerUI::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleApplicationSpecificEventL(): type = %d\n", aType));
// handle possible shutdown command coming from TWsEvent that we send
if(aType == KHXPlayerWsEvent)
{
TUint8* pData = aEvent.EventData();
if( pData )
{
TPtr8 msg(pData, TWsEvent::EWsEventDataSize);
DPRINTF(SYMP_INFO, ("HandleApplicationSpecificEventL(): message is '%.*s'\n", msg.Length(), msg.Ptr()));
// make sure it is not from this thread
HBufC8* pMsg = MakeHXPlayerPrivateMessageL(KMessage_CloseApp);
AUTO_PUSH_POP_DEL(pMsg);
// message will compare equal if it is a close app message from another instance
if( 0 != pMsg->Compare(msg) )
{
DPRINTF(SYMP_INFO, ("HandlePossibleShutdownCommandL(): closing instance\n"));
CloseApp();
}
}
}
}
/*
* HandleCommandL
* --------------
* These are commands that are shared (or conceivably can be shared) among
* several of the views
*
*/
void
CHXAvPlayerUI::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EAknCmdExit:
case EEikCmdExit:
case EAknSoftkeyExit:
CloseApp();
break;
case EAknSoftkeyBack:
DoBackFromCurrentViewL();
break;
case EOpenGuide:
DoOpenGuideL();
break;
case EViewSettings:
DoSelectSettingsL();
break;
case EAboutDialog:
DoAboutL();
break;
case EOpenRecentDialog:
DoOpenRecentL();
break;
case EOpenURLDialog:
DoOpenURLL();
break;
case ERestoreDefaultSettings:
DoRestoreDefaultSettingsL();
break;
case EAknCmdHelp:
//HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), AppHelpContextL() );
break;
default:
// we don't expect any other commands (except possibly a click on an empty softkey)
HX_ASSERT(EAknSoftkeyEmpty == aCommand);
break;
}
}
////////////////////////////////////////////////////////////////
// restore config to installation default
void CHXAvPlayerUI::DoRestoreDefaultSettingsL()
{
if(CHXAvMessageDialog::DoQueryL(R_CONF_RESTORE_SETTINGS))
{
// user confirmed...
comptr<CHXLitePrefs> spPrefs = m_spEngineMgr->GetPrefs();
spPrefs->ResetPrefs(); //XXXLCM can fail
if( m_pPrefChangeObserver )
{
m_pPrefChangeObserver->OnPrefsChanged();
}
CHXAvMessageDialog::DoAlertConfirmL(CHXAvCleanString(R_SETTINGS_RESTORED)());
}
}
/*
* DoSelectSettingsL
* -----------------
* Show the select settings view.
*
*/
void CHXAvPlayerUI::DoSelectSettingsL()
{
// prepare select settings view to launch with first item hilighted
CAknView* pView = View(TUid::Uid(CHXAvPlayerUI::VID_SelectSettingsView));
HX_ASSERT(pView);
CHXAvSelectSettingsView* pSelectView = static_cast<CHXAvSelectSettingsView*>(pView);
pSelectView->ResetCurrentIndex();
ActivateLocalViewL(TUid::Uid(VID_SelectSettingsView));
}
////////////////////////////////////////
//
void
CHXAvPlayerUI::DoEditPlaylistL(const TDesC& playlistPath)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::DoEditPlaylistL()\n"));
CHXAvEditPlaylistDialog* pDlg = new (ELeave) CHXAvEditPlaylistDialog();
TInt err = KErrNone;
// save cleanupstack init until LD
{
AUTO_PUSH_POP(pDlg);
pDlg->ConstructL();
// make sure read-only is clear so we can edit (we don't honor this attribute)
CHXAvFile::EnsureClearReadOnlyAttributeL(playlistPath);
err = pDlg->SetPlaylistL(playlistPath);
}
if(KErrNone == err)
{
pDlg->ExecuteLD(R_AVP_EDIT_PLAYLIST_DLG);
}
else
{
HX_DELETE(pDlg); // <-- since dialog will not delete itself
CHXAvMessageDialog::DoAlertErrorL(CHXAvCleanString(R_ERR_UNABLE_TO_EDIT_PLAYLIST)());
}
}
/*
* DoOpenGuideL
* ------------
* Open the guide.
*
*/
void
CHXAvPlayerUI::DoOpenGuideL()
{
const TDesC& guideUrl = GetGuideUrlL(false);
TInt err = KErrGeneral;
if( guideUrl.Length() > 0 )
{
const TInt KWmlBrowserUid = 0x10008D39;
// format web browser message
_LIT(KOpenUrlMessagePrefix, "4 ");
TInt cchTotal = guideUrl.Length() + CHXAvUtil::litSize(KOpenUrlMessagePrefix);
HBufC* pBuf = HBufC::NewL(cchTotal);
AUTO_PUSH_POP_DEL(pBuf);
TPtr ptr = pBuf->Des();
ptr.Copy(KOpenUrlMessagePrefix);
ptr.Append(guideUrl);
// launch app with message argument
TRAP(err, CHXAvMisc::LaunchAppL(KWmlBrowserUid, *pBuf));
}
if(KErrNone != err)
{
//XXXLCM
CHXAvMessageDialog::DoAlertInfoL(_L("unable to launch guide"));
}
}
/*
* CloseApp
* --------
* Called when we receive exit command (from user or via system message)
*
*/
void
CHXAvPlayerUI::CloseApp()
{
// Write out the recent clips and release...
HX_ASSERT(m_recentClips);
if (m_recentClips)
{
m_recentClips->WriteFile(GetRecentClipsFileName());
}
// this prevents mms app from hanging when we exit
if(iDoorObserver)
{
iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty);
}
// Now we can exit...
Exit();
}
////////////////////////////
//HandleWsEventL
void CHXAvPlayerUI::HandleWsEventL(const TWsEvent& event, CCoeControl* pDest)
{
DPRINTF(SYMP_WSEVENTS, ("CHXAvPlayerUI::HandleWsEventL(): type = %ld; dest = 0x%08x\n", event.Type(), pDest));
switch(event.Type())
{
case EEventKeyUp:
{
DPRINTF(SYMP_WSEVENTS, ("CHXAvPlayerUI::HandleWsEventL(): key up event\n"));
TKeyEvent* pKey = event.Key();
if(pKey)
{
CHXAvViewBase *pActiveView = static_cast<CHXAvViewBase *>(iView);
if(pActiveView)
{
//
// special case: for some reason the left-shift up is not received by the CCoeControl
// if you click on a softkey while the shift key is held down before releasing the shift key
//
// XXXLCM we should probably do more to avoid double-event notification
if( pKey->iScanCode == EStdKeyLeftShift)
{
DPRINTF(SYMP_INFO, ("CHXAvPlayerUI::HandleWsEventL(): got shift key up event\n"));
pActiveView->GetWindow()->OfferKeyEventL(*pKey, EEventKeyUp);
}
}
}
}
break;
case EEventFocusGroupChanged:
{
DPRINTF(SYMP_WSEVENTS, ("CHXAvPlayerUI::HandleWsEvent(): focus group change\n"));
TInt wgidFocus = iEikonEnv->WsSession().GetFocusWindowGroup();
TUid uidFocus = CHXAvMisc::GetAppUidFromWgId(wgidFocus);
bool bNeedToStopPlayback = !(uidFocus == CHXAvMisc::KScreenSaverUID ||
uidFocus == CHXAvMisc::KAppUID );
if( bNeedToStopPlayback )
{
DPRINTF(SYMP_WSEVENTS, ("CHXAvPlayerUI::HandleWsEvent(): new app focus is not screen saver or player\n"));
CHXAvViewBase* pActiveView = static_cast<CHXAvViewBase *>(iView);
if( pActiveView )
{
pActiveView->HandleLosePlayFocus();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?