1 /* |
1 /* |
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
36 |
36 |
37 #include <e32property.h> // RProperty |
37 #include <e32property.h> // RProperty |
38 #include <PSVariables.h> // Property values |
38 #include <PSVariables.h> // Property values |
39 |
39 |
40 #ifdef WIMSERVER_SHUTDOWN |
40 #ifdef WIMSERVER_SHUTDOWN |
41 const TInt KServerShutdownDelay = 0x200000; |
41 const TInt KServerShutdownDelay = 0x200000; |
42 #endif |
42 #endif |
43 // Initialize static variables. These variables are static because static |
43 // Initialize static variables. These variables are static because static |
44 // callback functions in CWimCallBack. |
44 // callback functions in CWimCallBack. |
45 CWimServer* CWimServer::iWimServer = NULL; |
45 CWimServer* CWimServer::iWimServer = NULL; |
46 TInt CWimServer::iWimStatus = KErrNone; |
46 TInt CWimServer::iWimStatus = KErrNone; |
58 static void StartServerL() |
58 static void StartServerL() |
59 { |
59 { |
60 _WIMTRACE(_L("WIM | WIMServer | StartServer | Enter")); |
60 _WIMTRACE(_L("WIM | WIMServer | StartServer | Enter")); |
61 User::LeaveIfError( User::RenameThread( KWIMServerName ) ); |
61 User::LeaveIfError( User::RenameThread( KWIMServerName ) ); |
62 _WIMTRACE(_L("WIM | WIMServer | StartServer | Create AS")); |
62 _WIMTRACE(_L("WIM | WIMServer | StartServer | Create AS")); |
63 |
63 |
64 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
64 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
65 CleanupStack::PushL( s ); |
65 CleanupStack::PushL( s ); |
66 |
66 |
67 CActiveScheduler::Install( s ); |
67 CActiveScheduler::Install( s ); |
68 |
68 |
69 _WIMTRACE(_L("WIM | WIMServer | StartServer | Create server")); |
69 _WIMTRACE(_L("WIM | WIMServer | StartServer | Create server")); |
70 |
70 |
71 CWimServer::NewL(); |
71 CWimServer::NewL(); |
72 |
72 |
73 _WIMTRACE(_L("WIM | WIMServer | StartServer | Notify client")); |
73 _WIMTRACE(_L("WIM | WIMServer | StartServer | Notify client")); |
74 // Notify Client that server has starter |
74 // Notify Client that server has starter |
75 RProcess::Rendezvous( KErrNone ); |
75 RProcess::Rendezvous( KErrNone ); |
76 |
76 |
77 _WIMTRACE(_L("WIM | WIMServer | StartServer | Start ActiveScheduler")); |
77 _WIMTRACE(_L("WIM | WIMServer | StartServer | Start ActiveScheduler")); |
78 CActiveScheduler::Start(); |
78 CActiveScheduler::Start(); |
79 |
79 |
80 CleanupStack::PopAndDestroy( s ); |
80 CleanupStack::PopAndDestroy( s ); |
81 } |
81 } |
82 |
82 |
83 |
83 |
84 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
89 // |
89 // |
90 GLDEF_C TInt E32Main() |
90 GLDEF_C TInt E32Main() |
91 { |
91 { |
92 __UHEAP_MARK; |
92 __UHEAP_MARK; |
93 _WIMTRACE(_L("WIM | WIMServer | E32Main | Begin")); |
93 _WIMTRACE(_L("WIM | WIMServer | E32Main | Begin")); |
94 |
94 |
95 CTrapCleanup* cleanup=CTrapCleanup::New(); |
95 CTrapCleanup* cleanup=CTrapCleanup::New(); |
96 TInt r=KErrNoMemory; |
96 TInt r=KErrNoMemory; |
97 |
97 |
98 if ( cleanup ) |
98 if ( cleanup ) |
99 { |
99 { |
100 TRAP( r, StartServerL() ); |
100 TRAP( r, StartServerL() ); |
101 delete cleanup; |
101 delete cleanup; |
102 } |
102 } |
103 _WIMTRACE(_L("WIM | WIMServer | E32Main Memory leak checking line")); |
103 _WIMTRACE(_L("WIM | WIMServer | E32Main Memory leak checking line")); |
104 __UHEAP_MARKEND; |
104 __UHEAP_MARKEND; |
105 _WIMTRACE(_L("WIM | WIMServer | E32Main Memory checking passed")); |
105 _WIMTRACE(_L("WIM | WIMServer | E32Main Memory checking passed")); |
106 return r; |
106 return r; |
107 } |
107 } |
108 |
108 |
109 |
109 |
135 iWimServer = this; |
135 iWimServer = this; |
136 InitializeCallbackFunctions(); // Initialize WIMI callback functions |
136 InitializeCallbackFunctions(); // Initialize WIMI callback functions |
137 iWimSessionRegistry = CWimSessionRegistry::NewL(); |
137 iWimSessionRegistry = CWimSessionRegistry::NewL(); |
138 iWimTrustSettingsStore = CWimTrustSettingsStore::NewL(); |
138 iWimTrustSettingsStore = CWimTrustSettingsStore::NewL(); |
139 iWimTimer = CWimTimer::NewL( this ); |
139 iWimTimer = CWimTimer::NewL( this ); |
140 #ifdef WIMSERVER_SHUTDOWN |
140 #ifdef WIMSERVER_SHUTDOWN |
141 iShutdown.ConstructL(); |
141 iShutdown.ConstructL(); |
142 iShutdown.Start(); |
142 iShutdown.Start(); |
143 #endif |
143 #endif |
144 _WIMTRACE(_L("WIM | WIMServer | CWimServer::ConstructL | End")); |
144 _WIMTRACE(_L("WIM | WIMServer | CWimServer::ConstructL | End")); |
145 } |
145 } |
146 |
146 |
147 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
148 // CWimServer::NewL |
148 // CWimServer::NewL |
177 if ( iWimInitialized ) |
177 if ( iWimInitialized ) |
178 { |
178 { |
179 WIMI_CloseDownReq(); |
179 WIMI_CloseDownReq(); |
180 _WIMTRACE(_L("WIM | WIMServer | CWimServer::~CWimServer | WIMI_CloseDownReq")); |
180 _WIMTRACE(_L("WIM | WIMServer | CWimServer::~CWimServer | WIMI_CloseDownReq")); |
181 } |
181 } |
182 //iWimTrustSettingsStore->CloseD(); |
182 |
183 delete iWimTrustSettingsStore; |
183 delete iWimTrustSettingsStore; |
184 delete iWimSessionRegistry; |
184 delete iWimSessionRegistry; |
185 delete iWimTimer; |
185 delete iWimTimer; |
186 CWimCallBack::DeletegApdu(); |
186 CWimCallBack::DeletegApdu(); |
187 _WIMTRACE(_L("WIM | WIMServer | CWimServer::~CWimServer | delete iWimSessionRegistry")); |
187 _WIMTRACE(_L("WIM | WIMServer | CWimServer::~CWimServer | delete iWimSessionRegistry")); |
270 // ----------------------------------------------------------------------------- |
270 // ----------------------------------------------------------------------------- |
271 // CWimServer::SetWimInitialized |
271 // CWimServer::SetWimInitialized |
272 // Set iWimInitialized flag |
272 // Set iWimInitialized flag |
273 // ----------------------------------------------------------------------------- |
273 // ----------------------------------------------------------------------------- |
274 // |
274 // |
275 void CWimServer::SetWimInitialized( TBool aInitialized, TInt aStatus ) |
275 void CWimServer::SetWimInitialized( TBool aInitialized, TInt aWimStatus ) |
276 { |
276 { |
277 _WIMTRACE2(_L("WIM|WIMServer|CWimServer::SetWimInitialized|Value=%d"), aInitialized); |
277 _WIMTRACE2(_L("WIM|WIMServer|CWimServer::SetWimInitialized|Value=%d"), aInitialized); |
278 iWimInitialized = aInitialized; |
278 iWimInitialized = aInitialized; |
279 |
279 |
280 if ( !aInitialized ) |
280 if ( !aInitialized ) |
281 { |
281 { |
282 iWimStatus = aStatus; |
282 iWimStatus = aWimStatus; |
283 } |
283 } |
284 } |
284 } |
285 |
285 |
286 // ----------------------------------------------------------------------------- |
286 // ----------------------------------------------------------------------------- |
287 // CWimServer::NewSessionL |
287 // CWimServer::NewSessionL |
346 // ----------------------------------------------------------------------------- |
346 // ----------------------------------------------------------------------------- |
347 // |
347 // |
348 void CWimServer::PanicServer( TWimServerPanic aPanic ) |
348 void CWimServer::PanicServer( TWimServerPanic aPanic ) |
349 { |
349 { |
350 _WIMTRACE(_L("WIM | WIMServer | CWimServer::PanicServer | Begin")); |
350 _WIMTRACE(_L("WIM | WIMServer | CWimServer::PanicServer | Begin")); |
351 // Set server state to EWimServerNotRunning |
351 |
352 TInt retVal = RProperty::Set( KUidSystemCategory, |
352 // Set server state to EWimServerNotRunning. |
353 KWimServerUid.iUid, |
353 (void)RProperty::Set( KUidSystemCategory, KWimServerUid.iUid, EWimServerNotRunning ); |
354 EWimServerNotRunning ); |
|
355 retVal = retVal; // To prevent warning |
|
356 |
354 |
357 User::Panic( KWIMServerName, aPanic ); |
355 User::Panic( KWIMServerName, aPanic ); |
358 } |
356 } |
359 |
357 |
360 // ----------------------------------------------------------------------------- |
358 // ----------------------------------------------------------------------------- |
722 if( callStatus != WIMI_Ok ) |
720 if( callStatus != WIMI_Ok ) |
723 { |
721 { |
724 return callStatus; |
722 return callStatus; |
725 } |
723 } |
726 free_WIMI_RefList_t( clicertRefList ); |
724 free_WIMI_RefList_t( clicertRefList ); |
727 |
725 |
728 if ( clicertCount > 0 ) |
726 if ( clicertCount > 0 ) |
729 { |
727 { |
730 usage = WIMI_CU_Client; |
728 usage = WIMI_CU_Client; |
731 } |
729 } |
732 else |
730 else |
733 { |
731 { |
734 TUint8 cacertCount = 0; |
732 TUint8 cacertCount = 0; |
735 WIMI_RefList_t cacertRefList = NULL; |
733 WIMI_RefList_t cacertRefList = NULL; |
736 |
734 |
737 callStatus = WIMI_GetCertificateListByKeyHash( ( TUint8* ) keyIdBuf.Ptr(), |
735 callStatus = WIMI_GetCertificateListByKeyHash( ( TUint8* ) keyIdBuf.Ptr(), |
738 WIMI_CU_CA, |
736 WIMI_CU_CA, |
739 &cacertCount, |
737 &cacertCount, |
740 &cacertRefList ); |
738 &cacertRefList ); |
741 if ( callStatus != WIMI_Ok ) |
739 if ( callStatus != WIMI_Ok ) |
917 iRefreshNotificationReceived = aValue; |
915 iRefreshNotificationReceived = aValue; |
918 } |
916 } |
919 |
917 |
920 // ----------------------------------------------------------------------------- |
918 // ----------------------------------------------------------------------------- |
921 // CWimServer::TimerExpired() |
919 // CWimServer::TimerExpired() |
922 // Interface derived from |
920 // Interface derived from MWimTimerListener |
923 // ----------------------------------------------------------------------------- |
921 // ----------------------------------------------------------------------------- |
924 // |
922 // |
925 void CWimServer::TimerExpired() |
923 void CWimServer::TimerExpired() |
926 { |
924 { |
927 _WIMTRACE(_L("WIM | WIMServer | CWimServer::TimerExpired | Begin")); |
925 _WIMTRACE(_L("WIM | WIMServer | CWimServer::TimerExpired | Begin")); |
928 WIMI_Ref_pt pWimRefTemp = NULL; |
926 WIMI_Ref_pt pWimRefTemp = NULL; |
929 |
927 |
930 pWimRefTemp = WIMI_GetWIMRef( 0 ); |
928 pWimRefTemp = WIMI_GetWIMRef( 0 ); |
931 |
929 |
932 if ( pWimRefTemp ) // Close the WIM |
930 if ( pWimRefTemp ) // Close the WIM |
933 { |
931 { |
934 WIMI_CloseWIM( pWimRefTemp ); |
932 WIMI_CloseWIM( pWimRefTemp ); |
935 free_WIMI_Ref_t( pWimRefTemp ); |
933 free_WIMI_Ref_t( pWimRefTemp ); |
936 } |
934 } |
937 //SetWimInitialized( EFalse ); |
|
938 } |
935 } |
939 |
936 |
940 // ----------------------------------------------------------------------------- |
937 // ----------------------------------------------------------------------------- |
941 // CWimServer::WimTimer() |
938 // CWimServer::WimTimer() |
942 // Return the pointer of Timer |
939 // Return the pointer of Timer |
943 // ----------------------------------------------------------------------------- |
940 // ----------------------------------------------------------------------------- |
944 // |
941 // |
945 CWimTimer* CWimServer::WimTimer() |
942 CWimTimer* CWimServer::WimTimer() |
946 { |
943 { |
947 _WIMTRACE(_L("WIM | WIMServer | CWimServer::WimTimer | Begin")); |
944 _WIMTRACE(_L("WIM | WIMServer | CWimServer::WimTimer | Begin")); |
948 return iWimTimer; |
945 return iWimTimer; |
949 } |
946 } |
950 |
947 |
951 // ----------------------------------------------------------------------------- |
948 // ----------------------------------------------------------------------------- |
952 // CWimServer::CancelWimInitialize() |
949 // CWimServer::CancelWimInitialize() |
953 // Cancel Wim Initialize |
950 // Cancel Wim Initialize |
954 // ----------------------------------------------------------------------------- |
951 // ----------------------------------------------------------------------------- |
955 // |
952 // |
956 void CWimServer::CancelWimInitialize( const RMessage2& aMessage ) |
953 void CWimServer::CancelWimInitialize( const RMessage2& aMessage ) |
957 { |
954 { |
958 if ( !iWimInitialized ) |
955 if ( !iWimInitialized ) |
959 { |
956 { |
960 CWimCallBack::CancelWimInitialize(); |
957 CWimCallBack::CancelWimInitialize(); |
961 } |
958 } |
962 aMessage.Complete( KErrNone ); |
959 aMessage.Complete( KErrNone ); |
963 } |
960 } |
964 |
961 |
965 |
962 |
966 #ifdef WIMSERVER_SHUTDOWN |
963 #ifdef WIMSERVER_SHUTDOWN |
967 |
964 |