|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <alf/alfappui.h> |
|
20 #include "alfdecoderserverclient.h" |
|
21 #include "alfstreamerconsts.h" |
|
22 #include "alfuids.h" |
|
23 |
|
24 _LIT(KAlfServerThreadName, "alfredserver"); |
|
25 static void RunServerL() |
|
26 { |
|
27 CActiveScheduler* s=new(ELeave) CActiveScheduler; |
|
28 CleanupStack::PushL(s); |
|
29 CActiveScheduler::Install(s); |
|
30 |
|
31 CAlfAppUi* appUiStub = new (ELeave) CAlfAppUi(); |
|
32 CleanupStack::PushL(appUiStub); |
|
33 appUiStub->ConstructL(); |
|
34 |
|
35 CActiveScheduler::Start(); |
|
36 |
|
37 CleanupStack::PopAndDestroy(2); |
|
38 } |
|
39 |
|
40 TInt AlfThreadFucntion(TAny*) |
|
41 { |
|
42 TInt err = User::RenameThread(KAlfServerThreadName); |
|
43 if ( err != KErrNone ) |
|
44 { |
|
45 return err; |
|
46 } |
|
47 |
|
48 // create CCleanup |
|
49 CTrapCleanup * cleanup = CTrapCleanup::New(); |
|
50 if (cleanup) |
|
51 { |
|
52 TRAP(err, RunServerL()); |
|
53 delete cleanup; |
|
54 } |
|
55 |
|
56 return err; |
|
57 } |
|
58 |
|
59 EXPORT_C void AlfServerStarter::StartL(TRequestStatus& aStatus, TBool aCreateProcess) |
|
60 { |
|
61 TName serverName; |
|
62 TUid appUid = TUid::Uid(KAlfAppServerCoreUid3); |
|
63 _LIT(KServerNameFormat, "%08x_%08x_AppServer"); |
|
64 serverName.Format( |
|
65 KServerNameFormat, |
|
66 appUid, |
|
67 appUid.iUid ); |
|
68 TFindServer serverFinder(serverName); |
|
69 TFullName fullName; |
|
70 if (serverFinder.Next(fullName) != KErrNone) |
|
71 { |
|
72 const TUidType serverUid(TUid::Uid(0x1000007a),TUid::Uid(0x100039ce),TUid::Uid(0xdabadaba)); |
|
73 |
|
74 if (aCreateProcess) |
|
75 { |
|
76 RProcess server; |
|
77 User::LeaveIfError(server.Create(_L("z:\\sys\\bin\\alfserver.exe"),_L(""),serverUid)); |
|
78 server.Rendezvous(aStatus); |
|
79 if (aStatus!=KRequestPending) |
|
80 { |
|
81 server.Kill(0); // abort startup |
|
82 } |
|
83 else |
|
84 { |
|
85 server.Resume(); // logon OK - start the server |
|
86 } |
|
87 } |
|
88 else |
|
89 { |
|
90 RThread serverThread; |
|
91 User::LeaveIfError(serverThread.Create( |
|
92 KAlfServerThreadName, |
|
93 AlfThreadFucntion, |
|
94 16384, // magic |
|
95 20000, // uses own heap for now |
|
96 10000000, |
|
97 0, |
|
98 EOwnerThread)); |
|
99 |
|
100 serverThread.Rendezvous(aStatus); |
|
101 serverThread.Resume(); |
|
102 serverThread.Close(); |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 // Someone else already started the server, weird |
|
108 User::Leave(KErrAlreadyExists); |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Connect |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C TInt RAlfBridgerClient::Connect() |
|
117 { |
|
118 return CreateSession(ALFSTREAMER_SERVER_NAME,TVersion(1,1,1)); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // SendSynch |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C TInt RAlfBridgerClient::SendSynch(TInt aOp, const TDesC8& aBuffer) |
|
126 { |
|
127 return SendReceive(aOp, TIpcArgs(&aBuffer)); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // SendSynch |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C TInt RAlfBridgerClient::SendSynch(TInt aOp, const TIpcArgs& aIPCArgs ) |
|
135 { |
|
136 return SendReceive(aOp, aIPCArgs ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // SendAsyncronous |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C void RAlfBridgerClient::SendAsynchronous(TInt aOp, const TIpcArgs& aIPCArgs,TRequestStatus& aStatus ) |
|
144 { |
|
145 SendReceive(aOp, aIPCArgs, aStatus ); |
|
146 } |
|
147 |
|
148 // Open |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C TInt RAlfTfxClient::Open() |
|
152 { |
|
153 return RAlfBridgerClient::Connect(); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // LoadTfxPlugin |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C TInt RAlfTfxClient::LoadTfxPlugin(const TUid& aPluginUid) |
|
161 { |
|
162 return SendReceive(EAlfDecodSLoadPlugin, TIpcArgs(aPluginUid.iUid)); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // UnloadTfxPlugin |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C void RAlfTfxClient::UnloadTfxPlugin(const TUid& aPluginUid) |
|
170 { |
|
171 SendReceive(EAlfDecodSUnloadPlugin, TIpcArgs(aPluginUid.iUid)); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // SendSynchronousData |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 EXPORT_C TInt RAlfTfxClient::SendSynchronousData(const TUid& aPluginUid, const TDesC8& aInBuf, TDes8& aOutBuf) |
|
179 { |
|
180 return SendReceive(EAlfDecodSSendSynch, TIpcArgs(aPluginUid.iUid, &aInBuf, &aOutBuf)); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // SendAsynchronousData |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 EXPORT_C void RAlfTfxClient::SendAsynchronousData(const TUid& aPluginUid, const TDesC8& aInBuf, TDes8& aOutBuf, TRequestStatus& aStatus) |
|
188 { |
|
189 SendReceive(EAlfDecodSSendAsynch, TIpcArgs(aPluginUid.iUid, &aInBuf, &aOutBuf), aStatus); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CancelAsynchronousData |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C void RAlfTfxClient::CancelAsynchronousData(const TUid& aPluginUid,TInt aCommandId) |
|
197 { |
|
198 SendReceive(EAlfDecodSCancelAsynch, TIpcArgs(aPluginUid.iUid, aCommandId)); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // PrepareFrame |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 EXPORT_C void RAlfTfxClient::PrepareFrame(TUint aEstimatedFrameInterval) |
|
206 { |
|
207 Send(EAlfDecodSPrepareFrame, TIpcArgs(aEstimatedFrameInterval)); |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // SendSynch |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 EXPORT_C TInt RAlfBridgerClient::SendBlind(TInt aOp, const TIpcArgs& aIPCArgs ) |
|
215 { |
|
216 return Send(aOp, aIPCArgs); |
|
217 } |
|
218 |
|
219 // end of file |