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