|
1 /* |
|
2 * Copyright (c) 2008 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: Class CCatalogsRemoveAccesspointShutdownOperation implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "catalogsremoveaccesspointshutdownoperation.h" |
|
20 |
|
21 #include "catalogsconnectionmethod.h" |
|
22 #include "catalogsaccesspointmanagerimpl.h" |
|
23 #include "catalogshttpsessionmanagerimpl.h" |
|
24 #include "catalogsnetworkmanager.h" |
|
25 |
|
26 // one minute |
|
27 const TTimeIntervalMicroSeconds32 KTimerDelay( 60 * 1000000 ); |
|
28 |
|
29 |
|
30 TInt CCatalogsRemoveAccesspointShutdownOperation::CallbackRemoveAccessPoint( |
|
31 TAny* aData ) |
|
32 { |
|
33 static_cast< CCatalogsRemoveAccesspointShutdownOperation* >( |
|
34 aData )->RemoveAccessPoint(); |
|
35 return KErrNone; |
|
36 } |
|
37 |
|
38 CCatalogsRemoveAccesspointShutdownOperation* |
|
39 CCatalogsRemoveAccesspointShutdownOperation::NewL( |
|
40 const TUid& aFamilyUid, |
|
41 const TUint32 aApnId ) |
|
42 { |
|
43 CCatalogsRemoveAccesspointShutdownOperation* self = new( ELeave ) |
|
44 CCatalogsRemoveAccesspointShutdownOperation( aFamilyUid, aApnId ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 CCatalogsRemoveAccesspointShutdownOperation::CCatalogsRemoveAccesspointShutdownOperation( |
|
50 const TUid& aFamilyUid, |
|
51 const TUint32 aApnId ) |
|
52 : CCatalogsShutdownOperation( aFamilyUid ), |
|
53 iApnId( aApnId ) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 CCatalogsRemoveAccesspointShutdownOperation::~CCatalogsRemoveAccesspointShutdownOperation() |
|
59 { |
|
60 Cancel(); |
|
61 } |
|
62 |
|
63 |
|
64 void CCatalogsRemoveAccesspointShutdownOperation::HandleAccessPointEventL( |
|
65 const TCatalogsConnectionMethod& aAp, |
|
66 const TCatalogsAccessPointEvent& aEvent ) |
|
67 { |
|
68 DLTRACEIN(("")); |
|
69 if ( aEvent == ECatalogsAccessPointReallyClosed && |
|
70 aAp.iApnId == iApnId ) |
|
71 { |
|
72 DLTRACE(("AP closed, delete it")); |
|
73 RemoveAccessPoint(); |
|
74 } |
|
75 } |
|
76 |
|
77 |
|
78 void CCatalogsRemoveAccesspointShutdownOperation::DoExecuteL() |
|
79 { |
|
80 DLTRACEIN(("")); |
|
81 iNetworkManager = &CCatalogsHttpSessionManager::NetworkManagerL(); |
|
82 iNetworkManager->AddObserverL( *this ); |
|
83 |
|
84 iNetworkManager->UpdateConnectionsL(); |
|
85 |
|
86 TCatalogsConnectionMethod method( |
|
87 iApnId, |
|
88 ECatalogsConnectionMethodTypeAccessPoint ); |
|
89 method.iId = iApnId; |
|
90 |
|
91 TBool apIsOpen = iNetworkManager->IsAccessPointOpen( method ); |
|
92 if ( !apIsOpen ) |
|
93 { |
|
94 // Try to delete the accesspoint again |
|
95 RemoveAccessPoint(); |
|
96 } |
|
97 // this is the ultimate failsafe that ensures that we actually stop the |
|
98 // engine at some point even if we don't get any connection closed events. |
|
99 else |
|
100 { |
|
101 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
102 iTimer->Start( |
|
103 KTimerDelay, |
|
104 KTimerDelay, |
|
105 TCallBack( &CallbackRemoveAccessPoint, this ) ); |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 void CCatalogsRemoveAccesspointShutdownOperation::DoCancel() |
|
111 { |
|
112 delete iTimer; |
|
113 iTimer = NULL; |
|
114 |
|
115 if ( iNetworkManager ) |
|
116 { |
|
117 iNetworkManager->RemoveObserver( *this ); |
|
118 iNetworkManager = NULL; |
|
119 } |
|
120 } |
|
121 |
|
122 |
|
123 void CCatalogsRemoveAccesspointShutdownOperation::RemoveAccessPoint() |
|
124 { |
|
125 DLTRACEIN(("")); |
|
126 Cancel(); |
|
127 |
|
128 // If this fails then it fails. We've tried hard enough |
|
129 TRAP_IGNORE( |
|
130 CCatalogsAccessPointManager::RemoveApFromCommsDatabaseL( iApnId ) ); |
|
131 |
|
132 // Notify owner which will delete this object |
|
133 NotifyObserver( KErrNone ); |
|
134 } |
|
135 |
|
136 |
|
137 |