|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <commdb.h> |
|
17 #include <iapprefs.h> |
|
18 #include <wapmessage.h> |
|
19 #include "ConnMan.h" |
|
20 |
|
21 // Comment out the following define to use PPP - crashes program in WINS if |
|
22 // either RAS is not set up or theres no means of connecting to a phone! |
|
23 |
|
24 #define __USE_REAL_PPP_CONNECTION |
|
25 |
|
26 /** |
|
27 * Factory construction method |
|
28 * Use this method to allocate and construct a new CConnectionManager object |
|
29 * @param aLog |
|
30 * in: a interface for run-time logging |
|
31 * @return CConnectionManager* - pointer to newly instantiated object |
|
32 */ |
|
33 CConnectionManager* CConnectionManager::NewL(MWapPushLog& aLog) |
|
34 { |
|
35 CConnectionManager* self = new (ELeave) CConnectionManager(aLog); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(); //self |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 /** |
|
44 * Constructor |
|
45 * @param aLog a interface for run-time logging |
|
46 */ |
|
47 CConnectionManager::CConnectionManager(MWapPushLog& aLog) : |
|
48 CActive(CActive::EPriorityStandard), |
|
49 iLog(aLog), |
|
50 iConnectionExists(EFalse) |
|
51 { |
|
52 } |
|
53 |
|
54 /** |
|
55 * Destructor. Deletes the queue of CO Watchers, and |
|
56 * closes the PPP connection. |
|
57 */ |
|
58 CConnectionManager::~CConnectionManager() |
|
59 { |
|
60 __LOG_DEBUG("CConnectionManager destructor called"); |
|
61 |
|
62 Cancel(); |
|
63 delete iCLUnsecWatcher; |
|
64 delete iCLSecureWatcher; |
|
65 } |
|
66 |
|
67 /** |
|
68 * Secondary constructor for the connection manager. |
|
69 * Creates connectionless watchers (unsecure & secure). |
|
70 */ |
|
71 void CConnectionManager::ConstructL() |
|
72 { |
|
73 __LOG_DEBUG("CConnectionManager::NewL called"); |
|
74 |
|
75 CActiveScheduler::Add(this); |
|
76 |
|
77 // Create and start CL watchers |
|
78 iCLUnsecWatcher = CCLUnsecureWatcher::NewL(iLog,*this); |
|
79 TRAPD(error, iCLSecureWatcher = CCLSecureWatcher::NewL(iLog, *this)); |
|
80 |
|
81 // Secure Watcher should not leave if it is not supported in Wap Stack |
|
82 // as we want push watcher to start. |
|
83 if (error != KErrNotSupported) |
|
84 { |
|
85 User::LeaveIfError(error); |
|
86 } |
|
87 } |
|
88 |
|
89 |
|
90 /** |
|
91 * The Connection Manager is an Active Object. It is managing other AO's. However, |
|
92 * it is not waiting for an event to complete. RunL() should never get called. |
|
93 * |
|
94 */ |
|
95 void CConnectionManager::RunL() |
|
96 { |
|
97 __ASSERT_DEBUG(0, User::Invariant()); |
|
98 User::Panic(_L("WapPush Connection Manager"), KErrNotSupported); |
|
99 } |
|
100 |
|
101 |
|
102 /** |
|
103 * If RunL() leaves, this function gets called to handle the leave. |
|
104 * @param TInt aError |
|
105 * in: errror code for the event which generated the leave |
|
106 * @return TInt error code for the function |
|
107 */ |
|
108 TInt CConnectionManager::RunError(TInt aError) |
|
109 { |
|
110 User::Panic(_L("Untrapped RunError"),aError); |
|
111 return(KErrNone); |
|
112 } |
|
113 |
|
114 |
|
115 /** |
|
116 * Cancel any active aynchronous request this object has made. |
|
117 */ |
|
118 void CConnectionManager::DoCancel() |
|
119 { |
|
120 iCLUnsecWatcher->Cancel(); |
|
121 iCLSecureWatcher->Cancel(); |
|
122 } |
|
123 |
|
124 |
|
125 /** |
|
126 * Request that a new connection-orientated connection is created. |
|
127 * This will be called by the SIA content type handler, passing in |
|
128 * a connection point |
|
129 * @param TPushConnPoint aConnPoint |
|
130 * in: structur containing connection point information |
|
131 */ |
|
132 void CConnectionManager::CMOpenConnectionL(TPushConnPoint& /*aConnPoint*/) |
|
133 { |
|
134 __LOG_DEBUG("CConnectionManager: CMOpenCOConnectionL called") |
|
135 // Do nothing as we do not support CO Push |
|
136 |
|
137 } |
|
138 |
|
139 /** |
|
140 * Signal that the connection-orientated watcher has completed |
|
141 * Remove the watcher from the list. |
|
142 * If there are no more CO watchers, close PPP connection |
|
143 * @param aCOWatcher completed watcher |
|
144 * @param aError completion error code |
|
145 */ |
|
146 void CConnectionManager::CMWatcherComplete(CCOWatcherBase& /*aCOWatcher*/, TInt /*aError*/) |
|
147 { |
|
148 __LOG_DEBUG("ConnMan: CMWatcherComplete"); |
|
149 } |
|
150 |
|
151 |