1 /* |
|
2 * Copyright (c) 2009-2010 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: |
|
15 * Private implementation of wrapper for Symbian Connection Monitor |
|
16 * library's connection disconnect interface. |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 |
|
21 // User includes |
|
22 |
|
23 #include "wlanqtutilsconmonwrapper.h" |
|
24 #include "wlanqtutilsconmonwrapperdisconnect_s60_p.h" |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "wlanqtutilsconmonwrapperdisconnect_s60Traces.h" |
|
28 #endif |
|
29 |
|
30 /*! |
|
31 \class WlanQtUtilsConMonWrapperDisconnect |
|
32 \brief Private wrapper for Symbian Connection Monitor library. |
|
33 |
|
34 Provides functionality to disconnect connections regardless of how |
|
35 many applications are using the connection. |
|
36 */ |
|
37 |
|
38 // External function prototypes |
|
39 |
|
40 // Local constants |
|
41 |
|
42 // ======== LOCAL FUNCTIONS ======== |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 /*! |
|
47 Constructor. |
|
48 |
|
49 @param [in] wrapper Wrapper to report progress to. |
|
50 */ |
|
51 |
|
52 WlanQtUtilsConMonWrapperDisconnect::WlanQtUtilsConMonWrapperDisconnect( |
|
53 WlanQtUtilsConMonWrapper *wrapper) : |
|
54 q_ptr(wrapper) |
|
55 { |
|
56 OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this); |
|
57 |
|
58 // Errors in Connection Monitor Server connection are fatal so just |
|
59 // throw them as exceptions |
|
60 QT_TRAP_THROWING(iMonitor.ConnectL()); |
|
61 |
|
62 OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this); |
|
63 } |
|
64 |
|
65 /*! |
|
66 Destructor. |
|
67 */ |
|
68 |
|
69 WlanQtUtilsConMonWrapperDisconnect::~WlanQtUtilsConMonWrapperDisconnect() |
|
70 { |
|
71 OstTraceFunctionEntry1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this); |
|
72 |
|
73 iMonitor.Close(); |
|
74 |
|
75 OstTraceFunctionExit1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this); |
|
76 } |
|
77 |
|
78 /*! |
|
79 Disconnects the connection with the given IAP ID. |
|
80 |
|
81 @param [in] wrapper Wrapper to report progress to. |
|
82 */ |
|
83 |
|
84 void WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection(int iapId) |
|
85 { |
|
86 OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_ENTRY, this); |
|
87 |
|
88 OstTrace1( |
|
89 TRACE_NORMAL, |
|
90 WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION, |
|
91 "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection;iapId=%d", iapId); |
|
92 |
|
93 // Loop through connections to find the one with the IAP ID we want |
|
94 TUint count; |
|
95 TRequestStatus status; |
|
96 iMonitor.GetConnectionCount(count, status); |
|
97 User::WaitForRequest(status); |
|
98 if (status.Int() == KErrNone) { |
|
99 for (TInt i = 1; i <= count; i++) { |
|
100 TUint numSubConnections; |
|
101 TUint iap = 0; |
|
102 TUint connectionId = 0; |
|
103 TInt ret = iMonitor.GetConnectionInfo( |
|
104 i, |
|
105 connectionId, |
|
106 numSubConnections); |
|
107 if (ret == KErrNone) { |
|
108 iMonitor.GetUintAttribute(connectionId, 0, KIAPId, iap, status); |
|
109 User::WaitForRequest(status); |
|
110 if (status.Int() == KErrNone) { |
|
111 if (iap == iapId) { |
|
112 OstTrace1( |
|
113 TRACE_NORMAL, |
|
114 WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_STOP, |
|
115 "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Stopping connection;connectionId=%u", |
|
116 connectionId); |
|
117 |
|
118 // Match found, stop connection |
|
119 TInt KErr = iMonitor.SetBoolAttribute( |
|
120 connectionId, |
|
121 0, |
|
122 KConnectionStop, |
|
123 ETrue); |
|
124 |
|
125 OstTrace1( |
|
126 TRACE_NORMAL, |
|
127 WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_RESULT, |
|
128 "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Result;KErr=%d", KErr); |
|
129 } |
|
130 } |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 OstTraceFunctionExit1( WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_EXIT, this); |
|
136 } |
|