Sonic CD shows Sega logo
[picodrive.git] / platform / s60 / Picodriveapps60.cpp
... / ...
CommitLineData
1#include "PicoDriveAppS60.h"\r
2#include <picodrives60.rsg>\r
3#include <apgcli.h>\r
4#include <eikdll.h>\r
5EXPORT_C CApaApplication* NewApplication()\r
6{\r
7 return (new CPicoDrive);\r
8}\r
9\r
10CPicoDrive::CPicoDrive()\r
11{\r
12}\r
13\r
14\r
15CPicoDrive::~CPicoDrive()\r
16{\r
17}\r
18\r
19\r
20CApaDocument* CPicoDrive::CreateDocumentL()\r
21 {\r
22 return new (ELeave) CPicoDriveDoc(*this);\r
23 }\r
24TUid CPicoDrive::AppDllUid() const\r
25 {\r
26 return TUid::Uid(0x101F9B49);\r
27 }\r
28\r
29\r
30CPicoDriveDoc::CPicoDriveDoc(CEikApplication& aApp):CAknDocument(aApp)\r
31{\r
32}\r
33\r
34CPicoDriveDoc::~CPicoDriveDoc()\r
35 {\r
36 }\r
37\r
38CEikAppUi* CPicoDriveDoc::CreateAppUiL()\r
39 {\r
40 return new (ELeave) CPicoDriveUi;\r
41 }\r
42\r
43\r
44void CPicoDriveUi::HandleForegroundEventL(TBool aForeground)\r
45{\r
46 if(aForeground)\r
47 {\r
48 BringUpEmulatorL(); \r
49 }\r
50}\r
51\r
52CPicoDriveUi::CPicoDriveUi()\r
53{\r
54}\r
55\r
56CPicoDriveUi::~CPicoDriveUi()\r
57 {\r
58 \r
59 RemoveFromViewStack(*iView,iView);\r
60 DeregisterViewAndRemoveStack(*iView);\r
61 delete iView;\r
62 if(iWatcher)\r
63 {\r
64 iThreadWatch.LogonCancel(iWatcher->iStatus);\r
65 iWatcher->Cancel();\r
66 }\r
67 delete iWatcher;\r
68\r
69 iThreadWatch.Close();\r
70 }\r
71\r
72\r
73void CPicoDriveUi::ConstructL()\r
74 {\r
75 BaseConstructL();\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
84 TParse parser;\r
85 parser.Set(startFile,NULL,NULL);\r
86 \r
87 startFile = parser.DriveAndPath(); \r
88#ifndef __WINS__\r
89 startFile.Append( _L("PicoDrive.EXE"));\r
90#else\r
91 startFile.Append( _L("PicoDrive.DLL"));\r
92#endif\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
107 {\r
108 iWatcher = new (ELeave)CPicoWatcher;\r
109 iWatcher->iAppUi=this;\r
110 iThreadWatch.Logon(iWatcher->iStatus); \r
111 }\r
112}\r
113\r
114\r
115CPicoWatcher::CPicoWatcher():CActive(EPriorityStandard)\r
116{\r
117 CActiveScheduler::Add(this);\r
118 iStatus=KRequestPending;\r
119 SetActive();\r
120}\r
121\r
122CPicoWatcher::~CPicoWatcher()\r
123{\r
124}\r
125void CPicoWatcher::DoCancel()\r
126{\r
127}\r
128\r
129void CPicoWatcher::RunL()\r
130{\r
131 iAppUi->HandleCommandL(EEikCmdExit);\r
132}\r
133\r
134void CPicoDriveUi::BringUpEmulatorL()\r
135{\r
136 RThread thread;\r
137 if(thread.Open(iThreadId)==KErrNone)\r
138 {\r
139 thread.Close();\r
140 TApaTask apaTask(iEikonEnv->WsSession());\r
141 apaTask.SetWgId(iExeWgId);\r
142 apaTask.BringToForeground();\r
143 }\r
144 else\r
145 {\r
146 iExeWgId=-1;\r
147 }\r
148}\r
149\r
150\r
151\r
152void CPicoDriveUi::HandleCommandL(TInt aCommand)\r
153{\r
154 \r
155 switch(aCommand)\r
156 {\r
157 case EEikCmdExit:\r
158 {\r
159 RThread thread;\r
160 if(thread.Open(iThreadId)==KErrNone)\r
161 {\r
162 thread.Terminate(0);\r
163 thread.Close();\r
164 }\r
165 Exit();\r
166 } \r
167 break;\r
168 \r
169 }\r
170}\r
171\r
172GLDEF_C TInt E32Dll(TDllReason)\r
173{\r
174 return KErrNone;\r
175}\r
176\r
177\r
178\r