|
1 /* |
|
2 * Copyright (c) 2008 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: Java Connection Manager |
|
15 * Provides connection management for all Java Connections: |
|
16 - Network Access Point selection |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef CONNECTIONMANAGER_H |
|
22 #define CONNECTIONMANAGER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <javauid.h> |
|
26 |
|
27 using namespace java::util; // Uid |
|
28 static const int KJavaNetworkAccessNotSpecified = -1; // returned when no IAP/SNAP is defined in java storage |
|
29 static const int KAlwaysAskId = -2; // returned in case of AskAlways case |
|
30 static const int KDefaultConnection = -3; // froe default connection case |
|
31 |
|
32 /** |
|
33 * Java Connection Manager |
|
34 * Java The Connection Manager caches and handles Network Access Point selection. |
|
35 * The component is central point for all Java Connection Implementations |
|
36 * requiring Network Access Point selection. |
|
37 * |
|
38 * Network Access Point selection |
|
39 * Java Connection Manager component handles Network Access Point selection |
|
40 * in following priority steps: |
|
41 * 1. Is SNAP ID parameter (nokia_netid) specified in the URI. |
|
42 * 2. Is IAP ID parameter (nokia_apnid) specified in the URI. |
|
43 * 3. Is Session default Network Access Point (SNAP/IAP) set? |
|
44 * 4. Is MIDlet suite default Network Access Point (SNAP/IAP) defined in CenRep? |
|
45 * 5. Prompt User to select SNAP/IAP. If Default Connection is set, |
|
46 * it is used instead and User is not prompted at all. |
|
47 * |
|
48 * User SNAP/IAP selection is set as Session default Network Access Point. |
|
49 * The Session default Network Access Point exists until MIDlet is closed. |
|
50 * |
|
51 * Usage: |
|
52 * |
|
53 * @code |
|
54 * TJavaNetworkAccessPoint access = ConnectionManager::SelectNetworkAccessPointL( appUid ); |
|
55 * if ( access.Type() == ESnap ) |
|
56 * // start connection with access.Id() as SNAP paramater |
|
57 * else if ( access.Type() == EIap ) |
|
58 * // start connection with access.Id() as IAP paramater |
|
59 * else |
|
60 * // start connection without selected Network Access Point |
|
61 * @endcode |
|
62 * |
|
63 * @lib javaconnectionmanager.dll |
|
64 */ |
|
65 class ConnectionManager |
|
66 { |
|
67 |
|
68 /** |
|
69 * Handles and caches the Network Access Point selection for |
|
70 * Java Connection Implementation. |
|
71 * |
|
72 * Start |
|
73 * | |
|
74 * Is Session default Network Access Point set? - Yes --------------------+ |
|
75 * | | |
|
76 * No | |
|
77 * | | |
|
78 * MIDlet suite default Network Access Point defined - Yes ---------------+ |
|
79 * | | |
|
80 * No | |
|
81 * | | |
|
82 * Prompt User to select SNAP/IAP ID | |
|
83 * | | |
|
84 * +-- Cache selection as Session default Network Access Point ---------+ |
|
85 * | |
|
86 * | |
|
87 * Return Network Access Point |
|
88 * |
|
89 * @param aAppUid Java application UID |
|
90 * @return Selected Java Network Access Point |
|
91 */ |
|
92 |
|
93 |
|
94 |
|
95 public: |
|
96 |
|
97 /** |
|
98 * Prompt User to select Network Access Point |
|
99 * If Default Connection is defined in platform, the Default Connection is used instead. |
|
100 * @return Selected Network Access Point |
|
101 */ |
|
102 |
|
103 static bool SelectNetworkAccessPoint(char * , int *); |
|
104 |
|
105 |
|
106 /* prompt the user for |
|
107 * access point |
|
108 */ |
|
109 |
|
110 static void PromptUserL(char *); |
|
111 |
|
112 /* check if get the |
|
113 * device default access point |
|
114 */ |
|
115 |
|
116 static void GetDeviceDefaultAccessPointL(char *); |
|
117 |
|
118 /** |
|
119 * Get the default IAP defined for the java application |
|
120 * from java storage |
|
121 * @param Application Suite UID |
|
122 * @return default IAP |
|
123 */ |
|
124 |
|
125 IMPORT_C static unsigned int getApnIdL(Uid aAppSuiteUid); |
|
126 |
|
127 /** |
|
128 * Sets default IAP defined for the java application |
|
129 * defined by App UID into java storage |
|
130 * @param Application Suite UID |
|
131 * @param default IAP Id |
|
132 */ |
|
133 |
|
134 IMPORT_C static void setApnIdL(Uid aAppSuiteUid, int aApnId); |
|
135 |
|
136 /** |
|
137 * Sets default SNAP defined for the java application |
|
138 * defined by App UID into java storage |
|
139 * @param Application Suite UID |
|
140 * @param default IAP Id |
|
141 */ |
|
142 |
|
143 IMPORT_C static void setDestinationNetworkIdL(Uid aAppSuiteUid, int aApnId); |
|
144 |
|
145 /** |
|
146 * Get the default SNAP defined for the java application |
|
147 * from java storage |
|
148 * @param Application Suite UID |
|
149 * @return default SNAP ID |
|
150 */ |
|
151 |
|
152 IMPORT_C static unsigned int getDestinationNetworkIdL(Uid aAppSuiteUid); |
|
153 |
|
154 /** |
|
155 * Checks if the given IAP id falls in the destination id. |
|
156 * @param aMatchIapId , iap id |
|
157 * @param aDestId, destination id. If this param is -1 then it checks the iap in default SNAP |
|
158 * @return true if given ap is present in the SNAP , false otherwise |
|
159 */ |
|
160 IMPORT_C static bool isIapDefault(TUint32 aMatchIapId, TUint32 aDestId, bool aDefault = true); |
|
161 |
|
162 private: |
|
163 |
|
164 static HBufC8 * PromptUserSelectNetworkAccessPointL(); |
|
165 static HBufC8 * CreateDescriptorL(const int aType, const int id); |
|
166 |
|
167 |
|
168 |
|
169 static unsigned int ParseNetworkAccessPointL(const TDesC8& aDes); |
|
170 |
|
171 |
|
172 }; |
|
173 |
|
174 #endif // CONNECTIONMANAGER_H |