1 /* |
|
2 * Copyright (c) 2009 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: Implementation of fotaserver component |
|
15 * This is part of fotaapplication. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <fotaConst.h> |
|
21 #include <fotaengine.h> |
|
22 #include "fmsclientserver.h" |
|
23 #include "fmsclient.h" |
|
24 #include "fmsclientdebug.h" |
|
25 |
|
26 #include "fotaserverPrivateCRKeys.h" |
|
27 #include <centralrepository.h> |
|
28 // --------------------------------------------------------------------------- |
|
29 // IsSecureClient() |
|
30 // Checks who is trying to launch FMS |
|
31 // --------------------------------------------------------------------------- |
|
32 TBool IsSecureClient(TBool& aFotaStartUp) |
|
33 { |
|
34 FLOG(_L("IsSecureClient Started")); |
|
35 RThread thread; |
|
36 TUid fotaserver,fotastartup; |
|
37 fotaserver.iUid = KFotaServerUid; |
|
38 fotastartup.iUid = KStarterUid; |
|
39 if ( thread.SecureId() == fotaserver.iUid ) |
|
40 { |
|
41 FLOG(_L("fmsclient fotaserver is using the service")); |
|
42 return ETrue; |
|
43 } |
|
44 else if ( thread.SecureId() == fotastartup.iUid ) |
|
45 { |
|
46 FLOG(_L("fmsclient fotastartupplugin is using the service")); |
|
47 aFotaStartUp = ETrue; |
|
48 return ETrue; |
|
49 } |
|
50 else if (thread.SecureId() == 0x01D278B9 ) //test app |
|
51 { |
|
52 FLOG(_L("fmsclient test app is using the service")); |
|
53 return ETrue; |
|
54 } |
|
55 FLOG(_L("fmsclient not launched")); |
|
56 return EFalse; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // StartServerL() |
|
61 // Starts Fota Downlaod Interrupt Monitory server |
|
62 // --------------------------------------------------------------------------- |
|
63 TInt StartServerL() |
|
64 { |
|
65 FLOG(_L("StartServerLt Started")); |
|
66 TInt res = KErrNone; |
|
67 RProcess server; |
|
68 res=server.Create(KFMSServerName,KNullDesC); |
|
69 FLOG(_L("StartServerL-- create server error as %d"),res); |
|
70 if (res!=KErrNone) |
|
71 { |
|
72 return res; |
|
73 } |
|
74 TRequestStatus stat; |
|
75 server.Rendezvous(stat); |
|
76 if (stat!=KRequestPending) |
|
77 server.Kill(0); // abort startup |
|
78 else |
|
79 server.Resume(); // logon OK - start the server |
|
80 User::WaitForRequest(stat); // wait for start or death |
|
81 res=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
|
82 FLOG(_L("StartServerL-- server.ExitType() returns %d"),res); |
|
83 server.Close(); |
|
84 return res; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // RFMSClient::OpenL() |
|
89 // --------------------------------------------------------------------------- |
|
90 EXPORT_C TInt RFMSClient::OpenL() |
|
91 { |
|
92 FLOG(_L("RFMSClient::OpenL()- Begin")); |
|
93 TInt res = KErrNone; |
|
94 TBool FotaStartUp = EFalse; |
|
95 if( IsSecureClient(FotaStartUp)) |
|
96 { |
|
97 FLOG(_L("RFMSClient::OpenL()- Secured client")); |
|
98 res = CreateSession( KFMSServerName,TVersion(1,0,0),2 ); |
|
99 if ( res != KErrNone ) |
|
100 { |
|
101 FLOG(_L("RFMSClient::OpenL()- session not created")); |
|
102 res = StartServerL(); |
|
103 User::LeaveIfError( res ); |
|
104 res = CreateSession( KFMSServerName,TVersion(1,0,0),2 ); |
|
105 } |
|
106 User::LeaveIfError( res ); |
|
107 FLOG(_L("RFMSClient::OpenL()- session created")); |
|
108 CRepository* centrep2 = NULL; |
|
109 TRAPD( err, centrep2 = CRepository::NewL( KCRUidFotaServer ) ) |
|
110 TInt val = KErrNone; |
|
111 if (err==KErrNone ) |
|
112 { |
|
113 centrep2->Get( KFotaUpdateState, val ); |
|
114 delete centrep2; |
|
115 } |
|
116 |
|
117 centrep2 = NULL; |
|
118 |
|
119 if( FotaStartUp && val == EFotaDownloadInterrupted ) |
|
120 { |
|
121 FLOG(_L("RFMSClient::OpenL()- fotastartup using FMS session")); |
|
122 SendInterruptParamsL(); |
|
123 } |
|
124 } |
|
125 else //not a secured client |
|
126 { |
|
127 FLOG(_L("fmsclient not launched--insecured client")); |
|
128 res = KErrNotFound; |
|
129 } |
|
130 FLOG(_L("RFMSClient::OpenL()- End %d"),res); |
|
131 return res; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // RFMSClient::Close() |
|
136 // --------------------------------------------------------------------------- |
|
137 EXPORT_C void RFMSClient::Close() |
|
138 { |
|
139 FLOG(_L(" RFMSClient::Close")); |
|
140 RSessionBase::Close(); //basecall |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // RFMSClient::NotifyForResumeL() |
|
145 // ---------------------------------------------------------------------------- |
|
146 EXPORT_C void RFMSClient::NotifyForResumeL(const TOmaDLInterruptReason& aReason, |
|
147 const TInt& aBearer, const TDriveNumber& aDrive, const TInt& aSize) |
|
148 { |
|
149 FLOG(_L(" RFMSClient::NotifyForResumeL--Begin")); |
|
150 TInt Size(aSize),Drive((TInt)aDrive),Bearer(aBearer); |
|
151 TInt err = SendReceive( (TInt)aReason, TIpcArgs(Bearer,Drive,Size)); |
|
152 FLOG(_L(" RFMSClient::NotifyForResumeL--End error as %d"),err); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // RFMSClient::SendInterruptParamsL() called only when fotastartup launched |
|
157 // --------------------------------------------------------------------------- |
|
158 void RFMSClient::SendInterruptParamsL() |
|
159 { |
|
160 FLOG(_L(" RFMSClient::SendInterruptParamsL--Begin")); |
|
161 TInt err = Send( EFotaStartUpPlugin ); |
|
162 FLOG(_L(" RFMSClient::SendInterruptParamsL--End as %d"),err); |
|
163 } |
|
164 // --------------------------------------------------------------------------- |
|
165 // RFMSClient::CancelNotifyForResume() |
|
166 // --------------------------------------------------------------------------- |
|
167 EXPORT_C void RFMSClient::CancelNotifyForResume() |
|
168 { |
|
169 FLOG(_L(" RFMSClient::CancelNotifyForResume--Begin")); |
|
170 TInt err = Send( ECancelOutstandingRequest ); |
|
171 FLOG(_L(" RFMSClient::CancelNotifyForResume--End as %d"),err); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // RFMSClient::MonitorForBatteryL() |
|
176 // --------------------------------------------------------------------------- |
|
177 EXPORT_C void RFMSClient::MonitorForBatteryL(TUint aLevel) |
|
178 { |
|
179 FLOG(_L(" RFMSClient::MonitorForBatteryL--Begin, level = %d"), aLevel); |
|
180 TInt err = SendReceive( EMonitorbattery, TIpcArgs (aLevel)); |
|
181 FLOG(_L(" RFMSClient::MonitorForBatterL--End as %d"),err); |
|
182 User::LeaveIfError(err); |
|
183 } |
|
184 // --------------------------------------------------------------------------- |
|
185 // RFMSClient::Cancel() |
|
186 // --------------------------------------------------------------------------- |
|
187 EXPORT_C void RFMSClient::Cancel() |
|
188 { |
|
189 FLOG(_L(" RFMSClient::Cancel--Begin")); |
|
190 TInt err = SendReceive( ECancelOutstandingRequest ); |
|
191 FLOG(_L(" RFMSClient::Cancel--End as %d"),err); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // RFMSClient::ActivePhoneCallSync() |
|
196 // --------------------------------------------------------------------------- |
|
197 EXPORT_C TInt RFMSClient::IsPhoneCallActive(TInt& aCallActive) |
|
198 { |
|
199 FLOG(_L(" RFMSClient::IsPhoneCallActive--Begin")); |
|
200 TPckgBuf<TInt> result(aCallActive); |
|
201 TInt err = SendReceive( EPhoneCallActive,TIpcArgs(&result)); |
|
202 aCallActive=result(); |
|
203 FLOG(_L(" RFMSClient::IsPhoneCallActive--End as %d,%d"),err,aCallActive); |
|
204 return err; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // RFMSClient::MonitorActivePhoneCallEnd() |
|
209 // --------------------------------------------------------------------------- |
|
210 EXPORT_C TInt RFMSClient::MonitorActivePhoneCallEnd(TInt aPkgId,TInt aProfileId) |
|
211 { |
|
212 FLOG(_L(" RFMSClient::MonitorActivePhoneCallEnd--Begin, pkgid:%d, \ |
|
213 / profileid:%d"),aPkgId,aProfileId); |
|
214 TInt err = SendReceive( EMonitorPhoneCallEnd, TIpcArgs(aPkgId,aProfileId)); |
|
215 FLOG(_L(" RFMSClient::MonitorActivePhoneCallEnd--End as %d"),err); |
|
216 return err; |
|
217 } |
|
218 //End of file |
|