20 #include <cmconnectionmethod.h> |
20 #include <cmconnectionmethod.h> |
21 #include <cmdestination.h> |
21 #include <cmdestination.h> |
22 #include <cmconnectionmethoddef.h> |
22 #include <cmconnectionmethoddef.h> |
23 #include <cmmanager.h> |
23 #include <cmmanager.h> |
24 #include <centralrepository.h> |
24 #include <centralrepository.h> |
25 #include <commdbconnpref.h> |
25 #include <extendedconnpref.h> |
26 #include <cdblen.h> |
26 #include <cdblen.h> |
|
27 #include <cdbcols.h> // IAP, COMMDB_ID |
27 #include <es_enum.h> |
28 #include <es_enum.h> |
28 #ifdef __SERIES60_NATIVE_BROWSER |
|
29 #include <browseruisdkcrkeys.h> |
|
30 #endif |
|
31 #include "RoapConnection.h" |
29 #include "RoapConnection.h" |
32 #include "RoapDef.h" |
30 #include "RoapDef.h" |
33 #include "RoapLog.h" |
31 #include "RoapLog.h" |
34 |
32 |
35 |
33 |
36 |
|
37 #ifndef __SERIES60_NATIVE_BROWSER |
|
38 const TUid KCRUidBrowser = {0x10008D39}; |
|
39 const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; |
|
40 const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; |
|
41 const TUint32 KBrowserNGDefaultSnapId = 0x00000053; |
|
42 #endif |
|
43 |
|
44 |
|
45 // ================= LOCAL FUNCTIONS ========================================= |
|
46 // --------------------------------------------------------------------------- |
|
47 // IapIdOfDefaultSnapL |
|
48 // for trapping purposes only |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 LOCAL_C TUint32 IapIdOfDefaultSnapL( |
|
52 RCmManager& aCmManager, |
|
53 const TUint32 aDefaultSnap ) |
|
54 { |
|
55 RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) ); |
|
56 CleanupClosePushL( dest ); |
|
57 TUint32 iapIdOfDest( 0 ); |
|
58 |
|
59 if ( dest.ConnectionMethodCount() <= 0 ) |
|
60 { |
|
61 User::Leave( KErrNotFound ); |
|
62 } |
|
63 |
|
64 RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) ); |
|
65 CleanupClosePushL( cMeth ); |
|
66 |
|
67 iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId ); |
|
68 CleanupStack::PopAndDestroy( &cMeth ); |
|
69 CleanupStack::PopAndDestroy( &dest ); |
|
70 return iapIdOfDest; |
|
71 } |
|
72 |
34 |
73 // ================= MEMBER FUNCTIONS ======================= |
35 // ================= MEMBER FUNCTIONS ======================= |
74 |
36 |
75 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
76 // Roap::CRoapConnection::NewL |
38 // Roap::CRoapConnection::NewL |
102 // |
64 // |
103 void Roap::CRoapConnection::ConnectL |
65 void Roap::CRoapConnection::ConnectL |
104 ( TUint32 aIap, TRequestStatus* aStatus ) |
66 ( TUint32 aIap, TRequestStatus* aStatus ) |
105 { |
67 { |
106 LOGLIT( "CRoapConnection::ConnectL" ) |
68 LOGLIT( "CRoapConnection::ConnectL" ) |
107 const TInt KAlwaysAskSelectionMode( 1 ); |
|
108 const TInt KDestinationSelectionMode( 2 ); |
|
109 |
69 |
110 if ( iState == EInit ) |
70 if ( iState == EInit ) |
111 { |
71 { |
112 // Not connected. Attach to existing connection, or create new one if |
72 // Not connected. Attach to existing connection, or create new one if |
113 // allowed. |
73 // allowed. |
118 CleanupClosePushL<RSocketServ>( iSocketServ ); |
78 CleanupClosePushL<RSocketServ>( iSocketServ ); |
119 User::LeaveIfError( iConnection.Open( iSocketServ ) ); |
79 User::LeaveIfError( iConnection.Open( iSocketServ ) ); |
120 CleanupClosePushL<RConnection>( iConnection ); |
80 CleanupClosePushL<RConnection>( iConnection ); |
121 |
81 |
122 TConnectionInfoBuf connInfo; |
82 TConnectionInfoBuf connInfo; |
123 TInt ap = 0; |
83 TUint count(0); |
124 TInt alwaysAsk = 0; |
|
125 TUint count; |
|
126 User::LeaveIfError( iConnection.EnumerateConnections( count ) ); |
84 User::LeaveIfError( iConnection.EnumerateConnections( count ) ); |
127 TUint i; |
85 TUint i(0); |
128 if ( count ) |
86 if ( count ) |
129 { |
87 { |
130 // Select from existing connections. Try to make AP match. |
88 // Select from existing connections. Try to make AP match. |
131 for ( i = count; i; i-- ) |
89 for ( i = count; i; i-- ) |
132 { |
90 { |
150 iStatus = KErrNone; |
108 iStatus = KErrNone; |
151 } |
109 } |
152 else |
110 else |
153 { |
111 { |
154 // No existing connections, create new one. |
112 // No existing connections, create new one. |
155 #ifdef __WINS__ |
113 // Create overrides |
156 // WINS connection creation does not work if preferences are given. |
114 TConnPrefList prefList; |
157 // Defaults are to be used always. |
115 TExtendedConnPref prefs; |
158 iConnection.Start( iStatus ); |
116 |
159 #else |
117 prefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); |
160 // Note: the TCommDbConnPref must NOT be stack variable. |
118 |
161 // It must persist until completion of RConnection::Start(). |
119 //Fetch default connection |
162 iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing ); |
120 TBool hasDefault(ETrue); |
163 //iConnPref.SetDialogPreference( ECommDbDialogPrefWarn ) |
121 TCmDefConnValue defConn; |
164 iConnPref.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma ); |
122 RCmManager cmManager; |
165 // New connection is always created with user-selected AP |
123 cmManager.OpenLC(); |
166 // so 0 is used instead of aIap. |
124 cmManager.ReadDefConnL(defConn); |
167 |
125 if (defConn.iType == ECmDefConnConnectionMethod) |
168 TInt defaultSnap( 0 ); |
126 { |
169 CRepository* repository( NULL ); |
127 prefs.SetIapId(defConn.iId); |
170 repository = CRepository::NewL( KCRUidBrowser ); |
128 } |
171 CleanupStack::PushL( repository ); |
129 else if (defConn.iType == ECmDefConnDestination) |
172 |
130 { |
173 repository->Get( KBrowserDefaultAccessPoint, ap); |
131 prefs.SetSnapId(defConn.iId); |
174 repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); |
|
175 repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); |
|
176 CleanupStack::PopAndDestroy( repository ); |
|
177 repository = NULL; |
|
178 |
|
179 TUint32 iapd32 = 0; |
|
180 TInt err = KErrNone; |
|
181 |
|
182 if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) |
|
183 { |
|
184 alwaysAsk = KAlwaysAskSelectionMode; |
|
185 } |
132 } |
186 else |
133 else |
187 { |
134 { |
188 RCmManager cmManager; |
135 hasDefault = EFalse; |
189 cmManager.OpenLC(); |
136 } |
190 if ( !alwaysAsk ) |
137 // End of fetch default connection |
191 { |
138 if (hasDefault) |
192 TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL( |
139 { |
193 ap, CMManager::ECmIapId ) ); |
140 prefList.AppendL(&prefs); |
194 } |
141 |
195 else if ( alwaysAsk == KDestinationSelectionMode ) |
142 // Start an Outgoing Connection with overrides |
196 { |
143 iConnection.Start(prefList, iStatus); |
197 TRAP( err, iapd32 = IapIdOfDefaultSnapL( |
|
198 cmManager, defaultSnap ) ); |
|
199 } |
|
200 CleanupStack::PopAndDestroy( &cmManager ); |
|
201 } |
|
202 |
|
203 if ( err || alwaysAsk == KAlwaysAskSelectionMode ) |
|
204 { |
|
205 // Always ask |
|
206 LOGLIT( "SetDialogPreference( ECommDbDialogPrefPrompt )" ) |
|
207 iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
|
208 iapd32 = 0; |
|
209 } |
144 } |
210 else |
145 else |
211 { |
146 { |
212 // User defined |
147 // No default found --> trying with query |
213 LOGLIT( "SetDialogPreference( ECommDbDialogPrefDoNotPrompt )" ) |
148 iConnection.Start(iStatus); |
214 iConnPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
149 } |
215 } |
150 CleanupStack::PopAndDestroy(&cmManager); |
216 |
|
217 iConnPref.SetIapId( iapd32 ); |
|
218 iConnection.Start( iConnPref, iStatus ); |
|
219 #endif |
|
220 iState = EConnecting; |
151 iState = EConnecting; |
221 SetActive(); // The only path with a real async request. |
152 SetActive(); // The only path with a real async request. |
222 } |
153 } |
223 CleanupStack::Pop( 2, &iSocketServ ); // closing iConn and iSockServ |
154 CleanupStack::Pop( 2, &iSocketServ ); // closing iConn and iSockServ |
224 // End of atomic part. |
155 // End of atomic part. |