|
1 /* |
|
2 * Copyright (c) 2007 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: Handles logic of selecting default connection, |
|
15 * stores selected default connection when necessary. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef C_DEFAULTCONNECTION_H |
|
20 #define C_DEFAULTCONNECTION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <cmdefconnvalues.h> |
|
24 |
|
25 const TCmDefConnType KDefaultMode = ECmDefConnAlwaysAsk; |
|
26 const TUint32 KDefaultConnectionId = 0; |
|
27 |
|
28 class CMPMServer; |
|
29 /** |
|
30 * Class handling default connection |
|
31 * The class handles logic of selecting default connection |
|
32 * based on the registered Default connections, user selection |
|
33 * stored in CommsDat and values queried from user. |
|
34 * |
|
35 * The default connection can be queried from the class by |
|
36 * MPM Server session starting a connection. Following |
|
37 * example describes the behaviour expected from the session. |
|
38 * |
|
39 * @code |
|
40 * TCmDefConnType mode(0); |
|
41 * TUint id(0); |
|
42 * iMyServer.DefaultConnection().GetDefaultConnection( mode, id ); |
|
43 * if( mode == ECmDefConnAlwaysAsk ) |
|
44 * { |
|
45 * //implicit connection start |
|
46 * } |
|
47 * else if (mode == ECmDefConnAskOnce) |
|
48 * { |
|
49 * if( id == 0 ) |
|
50 * { |
|
51 * // Implicit connection start |
|
52 * // |
|
53 * // User selection must be registered by the session |
|
54 * // with call: |
|
55 * MyServer().DefaultConnection(). |
|
56 * SetAskOnceDefaultConnection( aId ); |
|
57 * |
|
58 * // When BM connection is added under the MPM server object |
|
59 * // the parameter aUsingAskOnce must be set to ETrue in call |
|
60 * MyServer().CMAppendBMConnection( connId, snap, iapId, |
|
61 * state, ETrue ); |
|
62 * } |
|
63 * else |
|
64 * { |
|
65 * // Explicit connection start using SNAP or IAP from |
|
66 * // parameters. |
|
67 * // |
|
68 * // When BM connection is added under the MPM server object |
|
69 * // the parameter aUsingAskOnce must be set to ETrue in call |
|
70 * MyServer().CMAppendBMConnection( connId, snap, iapId, |
|
71 * state, ETrue ); |
|
72 * } |
|
73 * } |
|
74 * else // snap or iap |
|
75 * { |
|
76 * // Explicit connection start using SNAP or IAP from |
|
77 * //parameters |
|
78 * } |
|
79 * } |
|
80 * @endcode |
|
81 * |
|
82 * @lib mpmserver.exe |
|
83 * @since S60 v3.2 |
|
84 */ |
|
85 class CMPMDefaultConnection : public CBase |
|
86 { |
|
87 |
|
88 public: |
|
89 |
|
90 /** |
|
91 * Two-phased constructor. |
|
92 * @param aServer Reference to MPM Server |
|
93 */ |
|
94 static CMPMDefaultConnection* NewL( const CMPMServer* aServer ); |
|
95 |
|
96 |
|
97 /** |
|
98 * Destructor. |
|
99 */ |
|
100 virtual ~CMPMDefaultConnection(); |
|
101 |
|
102 /** |
|
103 * Sets IAP to be used as default connection |
|
104 * |
|
105 * @since S60 v3.2 |
|
106 * @param aIapId The IAP to be set as default connection |
|
107 * return KErrNone if succesful, KErrArgument if id was not accepted |
|
108 */ |
|
109 TInt SetDefaultIAP( TInt aIapId ); |
|
110 |
|
111 /** |
|
112 * Clear IAP from being used as default connection, |
|
113 * if one is set |
|
114 * |
|
115 * @since S60 v3.2 |
|
116 */ |
|
117 void ClearDefaultIAP(); |
|
118 |
|
119 /** |
|
120 * Get the current default connection value |
|
121 * |
|
122 * @since S60 v3.2 |
|
123 * @param aMode Points to snap or specific iap. |
|
124 * @param aConnection CommsDat elementId of the IAP or SNAP to be used. |
|
125 * 0 if not defined. |
|
126 * |
|
127 */ |
|
128 void GetDefaultConnectionL( TCmDefConnType& aMode, |
|
129 TUint32& aConnection ); |
|
130 |
|
131 private: |
|
132 |
|
133 /** |
|
134 * Converts int value to TCmDefaultConnection |
|
135 * Leaves with KErrArgument is value no in the range |
|
136 * |
|
137 * @since S60 v3.2 |
|
138 * @param aInt Int value |
|
139 * @return TCmDefConn value |
|
140 */ |
|
141 TCmDefConnType IntToCmDefConnTypeL( const TUint& aInt ); |
|
142 |
|
143 /** |
|
144 * Reads default connection setting from commsdat. |
|
145 * If no entry is found default values are returned. |
|
146 * |
|
147 * @since S60 v3.2 |
|
148 * @param aType Default connection setting type |
|
149 * @param aId Default connection id |
|
150 */ |
|
151 void ReadDefConnSettingL( TCmDefConnType& aType, |
|
152 TUint32& aId ); |
|
153 /** |
|
154 * C++ default constructor. |
|
155 */ |
|
156 CMPMDefaultConnection( const CMPMServer* aServer ); |
|
157 |
|
158 /** |
|
159 * 2nd phase constructor. |
|
160 */ |
|
161 void ConstructL(); |
|
162 |
|
163 |
|
164 private: // data |
|
165 |
|
166 /** |
|
167 * CommsDat element id of IAP registered by Wlan active idle plugin, |
|
168 * 0 if not defined |
|
169 */ |
|
170 TUint32 iDefaultIapId; |
|
171 |
|
172 /** |
|
173 * Pointer to the MPM Server object |
|
174 * Not own |
|
175 */ |
|
176 const CMPMServer* iServer; |
|
177 |
|
178 }; |
|
179 |
|
180 #endif // CMPMDEFAULTCONNECTION |