|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Server applications framework: LaunchApp service |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <apgcli.h> |
|
21 #include <eikenv.h> |
|
22 #include <eikappui.h> |
|
23 #include <eikdoc.h> |
|
24 #include <s32mem.h> // for CBufStore |
|
25 #include <s32std.h> // for CStreamDictionary |
|
26 #include <AiwGenericParam.h> |
|
27 #include "AknLaunchAppServiceImpl.h" |
|
28 |
|
29 const TUid KUidEmbedInputStream = { 0x1000 }; |
|
30 // const TUid KUidEmbedOutputStream = { 0x2000 }; |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 void RAknLaunchAppService::LaunchAppL(CAiwGenericParamList* aParam) |
|
37 { |
|
38 TIpcArgs args; |
|
39 HBufC8* buf = aParam->PackForServerL(args); // packs params 0 and 1. |
|
40 |
|
41 TInt err = SendReceive(EAknLaunchAppServiceCmdLaunchAppWithParams, args); |
|
42 |
|
43 delete buf; |
|
44 |
|
45 User::LeaveIfError(err); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 TUid RAknLaunchAppService::ServiceUid() const |
|
53 { |
|
54 return KAknLaunchAppServiceUid; |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 CAknLaunchAppServiceSession::CAknLaunchAppServiceSession() |
|
63 : iDoc(CEikonEnv::Static()->EikAppUi()->Document()) |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 CAknLaunchAppServiceSession::~CAknLaunchAppServiceSession() |
|
72 { |
|
73 delete iStore; |
|
74 delete iDictionary; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 void CAknLaunchAppServiceSession::CreateL() |
|
82 { |
|
83 CAknAppServiceBase::CreateL(); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CAknLaunchAppServiceSession::ServiceL(const RMessage2& aMessage) |
|
91 { |
|
92 switch (aMessage.Function()) |
|
93 { |
|
94 case EAknLaunchAppServiceCmdLaunchAppWithParams: |
|
95 LaunchAppWithParamsL(aMessage); |
|
96 break; |
|
97 |
|
98 default: |
|
99 CAknAppServiceBase::ServiceL(aMessage); |
|
100 break; |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 void CAknLaunchAppServiceSession::ServiceError(const RMessage2& aMessage,TInt aError) |
|
109 { |
|
110 CAknAppServiceBase::ServiceError(aMessage, aError); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 void CAknLaunchAppServiceSession::LaunchAppWithParamsL(const RMessage2& aMessage) |
|
118 { |
|
119 CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); |
|
120 paramList->UnpackFromClientL(aMessage); |
|
121 |
|
122 TSecureId clientSid = aMessage.SecureId(); |
|
123 TAiwVariant clientAppUid((TUid)clientSid); |
|
124 TAiwGenericParam uid(EGenericParamApplication, clientAppUid); |
|
125 paramList->AppendL(uid); |
|
126 |
|
127 ExternalizeParamsL(paramList); |
|
128 |
|
129 CleanupStack::PopAndDestroy(); // paramList |
|
130 |
|
131 TFileName fileName; |
|
132 |
|
133 iDoc->OpenFileL(ETrue, fileName, CEikonEnv::Static()->FsSession()); |
|
134 |
|
135 aMessage.Complete(KErrNone); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CAknLaunchAppServiceSession::ExternalizeParamsL(CAiwGenericParamList* aParamList) |
|
143 { |
|
144 // Create an in-memory store of parameters. |
|
145 delete iStore; |
|
146 iStore = NULL; |
|
147 iStore = CBufStore::NewL(127); |
|
148 |
|
149 RStoreWriteStream outStream; |
|
150 iStreamId = outStream.CreateLC(*iStore); |
|
151 aParamList->ExternalizeL(outStream); |
|
152 iStore->CommitL(); |
|
153 CleanupStack::PopAndDestroy(); // outStream |
|
154 |
|
155 delete iDictionary; |
|
156 iDictionary = NULL; |
|
157 iDictionary = CStreamDictionary::NewL(); |
|
158 |
|
159 iDictionary->AssignL(KUidEmbedInputStream, iStreamId); |
|
160 outStream.CreateLC(*iStore); |
|
161 iDictionary->ExternalizeL(outStream); |
|
162 iStore->CommitL(); |
|
163 CleanupStack::PopAndDestroy(); // outstream |
|
164 |
|
165 RStoreReadStream readStream; |
|
166 readStream.OpenLC(*iStore, iStreamId); |
|
167 iDoc->RestoreL(*iStore, *iDictionary); |
|
168 CleanupStack::PopAndDestroy(); // readStream |
|
169 } |
|
170 |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 EXPORT_C CAknLaunchAppService* CAknLaunchAppService::NewL( |
|
177 const TUid& aAppUid, MAknServerAppExitObserver* aObserver, CAiwGenericParamList* aParam) |
|
178 { |
|
179 CAknLaunchAppService* self = NewLC(aAppUid, aObserver, aParam); |
|
180 CleanupStack::Pop(self); |
|
181 return self; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------- |
|
185 // |
|
186 // --------------------------------------------------------- |
|
187 // |
|
188 CAknLaunchAppService* CAknLaunchAppService::NewLC( |
|
189 const TUid& aAppUid, MAknServerAppExitObserver* aObserver, CAiwGenericParamList* aParam) |
|
190 { |
|
191 CAknLaunchAppServiceImpl* self = new(ELeave) CAknLaunchAppServiceImpl(); |
|
192 CleanupStack::PushL(self); |
|
193 self->ConstructL(aAppUid, aObserver, aParam); |
|
194 return self; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // |
|
199 // --------------------------------------------------------- |
|
200 // |
|
201 CAknLaunchAppServiceImpl::CAknLaunchAppServiceImpl() |
|
202 { |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 CAknLaunchAppServiceImpl::~CAknLaunchAppServiceImpl() |
|
210 { |
|
211 delete iMonitor; |
|
212 iService.Close(); |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 // --------------------------------------------------------- |
|
218 // |
|
219 void CAknLaunchAppServiceImpl::ConstructL( |
|
220 const TUid& aAppUid, MAknServerAppExitObserver* aObserver, CAiwGenericParamList* aParam) |
|
221 { |
|
222 iService.ConnectChainedAppL(aAppUid); |
|
223 |
|
224 if (aObserver) |
|
225 { |
|
226 iMonitor = CApaServerAppExitMonitor::NewL(iService, *aObserver, CActive::EPriorityStandard); |
|
227 } |
|
228 |
|
229 if (aParam && aParam->Count()) |
|
230 { |
|
231 iService.LaunchAppL(aParam); |
|
232 } |
|
233 } |
|
234 |
|
235 // End of file. |