1 #include "PicoDriveAppS60.h"
\r
2 #include <picodrives60.rsg>
\r
5 EXPORT_C CApaApplication* NewApplication()
\r
7 return (new CPicoDrive);
\r
10 CPicoDrive::CPicoDrive()
\r
15 CPicoDrive::~CPicoDrive()
\r
20 CApaDocument* CPicoDrive::CreateDocumentL()
\r
22 return new (ELeave) CPicoDriveDoc(*this);
\r
24 TUid CPicoDrive::AppDllUid() const
\r
26 return TUid::Uid(0x101F9B49);
\r
30 CPicoDriveDoc::CPicoDriveDoc(CEikApplication& aApp):CAknDocument(aApp)
\r
34 CPicoDriveDoc::~CPicoDriveDoc()
\r
38 CEikAppUi* CPicoDriveDoc::CreateAppUiL()
\r
40 return new (ELeave) CPicoDriveUi;
\r
44 void CPicoDriveUi::HandleForegroundEventL(TBool aForeground)
\r
48 BringUpEmulatorL();
\r
52 CPicoDriveUi::CPicoDriveUi()
\r
56 CPicoDriveUi::~CPicoDriveUi()
\r
59 RemoveFromViewStack(*iView,iView);
\r
60 DeregisterViewAndRemoveStack(*iView);
\r
64 iThreadWatch.LogonCancel(iWatcher->iStatus);
\r
69 iThreadWatch.Close();
\r
73 void CPicoDriveUi::ConstructL()
\r
76 iView = new(ELeave)CPicoView;
\r
77 iView->SetMopParent(this);
\r
78 iView->ConstructL();
\r
79 RegisterViewAndAddStackL(*iView);
\r
80 AddToViewStackL(*iView,iView);
\r
81 SetDefaultViewL(*iView);
\r
82 TBuf<128> startFile;
\r
83 startFile = iEikonEnv->EikAppUi()->Application()->AppFullName();
\r
85 parser.Set(startFile,NULL,NULL);
\r
87 startFile = parser.DriveAndPath();
\r
89 startFile.Append( _L("PicoDrive.EXE"));
\r
91 startFile.Append( _L("PicoDrive.DLL"));
\r
93 CApaCommandLine* cmdLine=CApaCommandLine::NewLC(startFile);
\r
94 RApaLsSession lsSession;
\r
95 lsSession.Connect();
\r
96 CleanupClosePushL(lsSession);
\r
97 lsSession.StartApp(*cmdLine,iThreadId);
\r
98 CleanupStack::PopAndDestroy();//close lsSession
\r
99 CleanupStack::PopAndDestroy(cmdLine);
\r
100 User::After(500000);// Let the application start
\r
101 TApaTaskList taskList(iEikonEnv->WsSession());
\r
102 TApaTask myTask=taskList.FindApp(TUid::Uid(0x101F9B49));
\r
103 myTask.SendToBackground();
\r
104 TApaTask exeTask=taskList.FindByPos(0);
\r
105 iExeWgId=exeTask.WgId();
\r
106 if(iThreadWatch.Open(iThreadId)==KErrNone)
\r
108 iWatcher = new (ELeave)CPicoWatcher;
\r
109 iWatcher->iAppUi=this;
\r
110 iThreadWatch.Logon(iWatcher->iStatus);
\r
115 CPicoWatcher::CPicoWatcher():CActive(EPriorityStandard)
\r
117 CActiveScheduler::Add(this);
\r
118 iStatus=KRequestPending;
\r
122 CPicoWatcher::~CPicoWatcher()
\r
125 void CPicoWatcher::DoCancel()
\r
129 void CPicoWatcher::RunL()
\r
131 iAppUi->HandleCommandL(EEikCmdExit);
\r
134 void CPicoDriveUi::BringUpEmulatorL()
\r
137 if(thread.Open(iThreadId)==KErrNone)
\r
140 TApaTask apaTask(iEikonEnv->WsSession());
\r
141 apaTask.SetWgId(iExeWgId);
\r
142 apaTask.BringToForeground();
\r
152 void CPicoDriveUi::HandleCommandL(TInt aCommand)
\r
160 if(thread.Open(iThreadId)==KErrNone)
\r
162 thread.Terminate(0);
\r
172 GLDEF_C TInt E32Dll(TDllReason)
\r