author | hgs |
Mon, 24 May 2010 21:11:39 +0300 | |
changeset 31 | e8f4211554fb |
parent 19 | 10810c91db26 |
permissions | -rw-r--r-- |
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
31 | 2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
31 | 15 |
* Private implementation of wrapper for Symbian Esock library. |
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
31 | 18 |
// System includes |
19 |
||
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <e32base.h> |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <es_sock.h> |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <in_sock.h> |
31 | 23 |
#include <extendedconnpref.h> |
24 |
||
25 |
// User includes |
|
26 |
||
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include "wlanqtutilsesockwrapper.h" |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "wlanqtutilsesockwrapper_s60_p.h" |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "OstTraceDefinitions.h" |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#ifdef OST_TRACE_COMPILER_IN_USE |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "wlanqtutilsesockwrapper_s60Traces.h" |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
#endif |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
31 | 35 |
/*! |
36 |
\class WlanQtUtilsWlanQtUtilsEsockWrapperPrivate |
|
37 |
\brief Private implementation of wrapper for Symbian Esock library. |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
|
31 | 39 |
Provides functionality to connect and disconnect IAPs. |
40 |
*/ |
|
41 |
||
42 |
// External function prototypes |
|
43 |
||
44 |
// Local constants |
|
45 |
||
46 |
// ======== LOCAL FUNCTIONS ======== |
|
47 |
||
48 |
// ======== MEMBER FUNCTIONS ======== |
|
49 |
||
50 |
/*! |
|
51 |
Constructor. |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
|
31 | 53 |
@param [in] wrapper Wrapper to report progress to. |
54 |
*/ |
|
55 |
||
56 |
WlanQtUtilsEsockWrapperPrivate::WlanQtUtilsEsockWrapperPrivate( |
|
57 |
WlanQtUtilsEsockWrapper *wrapper) : |
|
58 |
CActive(EPriorityStandard), |
|
59 |
iConnectionActive(EFalse), |
|
60 |
q_ptr(wrapper) |
|
61 |
{ |
|
62 |
OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_ENTRY, this); |
|
63 |
||
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
CActiveScheduler::Add(this); |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
|
31 | 66 |
// Establish a session to Socket Server. Errors in Socket Server |
67 |
// connection are fatal so just throw them as exceptions |
|
68 |
qt_symbian_throwIfError(iSocketServer.Connect()); |
|
69 |
||
70 |
OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_EXIT, this); |
|
71 |
} |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
31 | 73 |
/*! |
74 |
Destructor. |
|
75 |
*/ |
|
76 |
||
77 |
WlanQtUtilsEsockWrapperPrivate::~WlanQtUtilsEsockWrapperPrivate() |
|
78 |
{ |
|
79 |
OstTraceFunctionEntry1(DUP1_WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_ENTRY, this); |
|
80 |
||
81 |
// Close any possibly ongoing connection |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
Cancel(); |
31 | 83 |
// Close Socket Server session |
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
iSocketServer.Close(); |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
|
31 | 86 |
OstTraceFunctionExit1(DUP1_WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_EXIT, this); |
87 |
} |
|
88 |
||
89 |
/*! |
|
90 |
Starts connection creation to given IAP. |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
31 | 92 |
@param [in] iapId IAP ID to connect. |
93 |
*/ |
|
94 |
||
95 |
void WlanQtUtilsEsockWrapperPrivate::ConnectIap(int iapId) |
|
96 |
{ |
|
97 |
OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP_ENTRY, this); |
|
98 |
||
99 |
// Cancel a (possibly) ongoing previous request |
|
100 |
Cancel(); |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
|
31 | 102 |
OstTrace1( |
103 |
TRACE_NORMAL, |
|
104 |
WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP, |
|
105 |
"WlanQtUtilsEsockWrapperPrivate::connectIap;iapId=%d", |
|
106 |
iapId ); |
|
107 |
||
108 |
// Open an RConnection object. Errors in RConnection opening are |
|
109 |
// fatal so just throw them as exceptions |
|
110 |
qt_symbian_throwIfError(iConnection.Open(iSocketServer)); |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
31 | 112 |
// Create overrides for connection preferences to force opening of the |
113 |
// given IAP without any user prompts. |
|
114 |
TConnPrefList prefList; |
|
115 |
TExtendedConnPref prefs; |
|
116 |
prefs.SetIapId(iapId); |
|
117 |
prefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); |
|
118 |
QT_TRAP_THROWING(prefList.AppendL(&prefs)); |
|
119 |
||
120 |
// Start a connection with connection preferences |
|
121 |
iConnection.Start(prefList, iStatus); |
|
122 |
||
123 |
iConnectionActive = ETrue; |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
|
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
SetActive(); |
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
|
31 | 127 |
OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP_EXIT, this); |
128 |
} |
|
129 |
||
130 |
/*! |
|
131 |
Disconnects connection, if one is active. |
|
132 |
*/ |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
|
31 | 134 |
void WlanQtUtilsEsockWrapperPrivate::DisconnectIap() |
135 |
{ |
|
136 |
OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_ENTRY, this); |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
|
31 | 138 |
if (iConnectionActive) { |
139 |
OstTrace0( |
|
140 |
TRACE_NORMAL, |
|
141 |
WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_DISCONNECT, |
|
142 |
"WlanQtUtilsEsockWrapperPrivate::disconnectIap Disconnecting connection"); |
|
143 |
||
144 |
iConnectionActive = EFalse; |
|
145 |
iConnection.Close(); |
|
146 |
} else { |
|
147 |
OstTrace0( |
|
148 |
TRACE_NORMAL, |
|
149 |
WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_IGNORED, |
|
150 |
"WlanQtUtilsEsockWrapperPrivate::disconnectIap Ignored since no active connection"); |
|
151 |
} |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
|
31 | 153 |
OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_EXIT, this); |
154 |
} |
|
155 |
||
156 |
/*! |
|
157 |
From CActive: called when async request (RConnection::Start()) |
|
158 |
has been completed. |
|
159 |
*/ |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
|
31 | 161 |
void WlanQtUtilsEsockWrapperPrivate::RunL() |
162 |
{ |
|
163 |
OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL_ENTRY, this); |
|
164 |
||
165 |
OstTrace1( |
|
166 |
TRACE_NORMAL, |
|
167 |
WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL, |
|
168 |
"WlanQtUtilsEsockWrapperPrivate::RunL;iStatus=%d", iStatus.Int()); |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
|
31 | 170 |
bool success; |
171 |
if (iStatus == KErrNone) { |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
success = true; |
31 | 173 |
} else { |
174 |
success = false; |
|
175 |
iConnectionActive = EFalse; |
|
176 |
} |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
|
31 | 178 |
// Report to public wrapper |
179 |
q_ptr->updateConnection(success, iStatus.Int()); |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
|
31 | 181 |
OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL_EXIT, this); |
182 |
} |
|
183 |
||
184 |
/*! |
|
185 |
From CActive: called when active object is cancelled. |
|
186 |
*/ |
|
19
10810c91db26
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
|
31 | 188 |
void WlanQtUtilsEsockWrapperPrivate::DoCancel() |
189 |
{ |
|
190 |
OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_DOCANCEL_ENTRY, this); |
|
191 |
||
192 |
// Disconnect, if needed. |
|
193 |
DisconnectIap(); |
|
194 |
||
195 |
OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_DOCANCEL_EXIT, this); |
|
196 |
} |