williamr@2
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
4 |
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#ifndef __T32WLD_H__
|
williamr@2
|
17 |
#define __T32WLD_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#include <e32base.h>
|
williamr@2
|
20 |
#include <dial_consts.h>
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
//
|
williamr@2
|
24 |
//
|
williamr@2
|
25 |
// Literal constants
|
williamr@2
|
26 |
_LIT(KWorldServerName, "!WorldServer");
|
williamr@2
|
27 |
|
williamr@2
|
28 |
_LIT(KWorldServerImageName, "WorldServer");
|
williamr@2
|
29 |
//
|
williamr@2
|
30 |
/**
|
williamr@2
|
31 |
@internalComponent
|
williamr@2
|
32 |
@released
|
williamr@2
|
33 |
*/
|
williamr@2
|
34 |
const TUid KWorldServerUid = { 0x101F5025 };
|
williamr@2
|
35 |
//
|
williamr@2
|
36 |
|
williamr@2
|
37 |
/**
|
williamr@2
|
38 |
@internalComponent
|
williamr@2
|
39 |
@released
|
williamr@2
|
40 |
*/
|
williamr@2
|
41 |
const TInt KWorldServerMajorVN=1;
|
williamr@2
|
42 |
|
williamr@2
|
43 |
/**
|
williamr@2
|
44 |
@internalComponent
|
williamr@2
|
45 |
@released
|
williamr@2
|
46 |
*/
|
williamr@2
|
47 |
const TInt KWorldServerMinorVN=0;
|
williamr@2
|
48 |
|
williamr@2
|
49 |
/**
|
williamr@2
|
50 |
@internalComponent
|
williamr@2
|
51 |
@released
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
const TInt KWorldServerBuildVN=105;
|
williamr@2
|
54 |
//
|
williamr@2
|
55 |
/**
|
williamr@2
|
56 |
@internalComponent
|
williamr@2
|
57 |
@released
|
williamr@2
|
58 |
*/
|
williamr@2
|
59 |
const TInt KMaxZoneName=3;
|
williamr@2
|
60 |
|
williamr@2
|
61 |
/** Maximum length for TCityName.
|
williamr@2
|
62 |
@internalComponent
|
williamr@2
|
63 |
@released
|
williamr@2
|
64 |
*/
|
williamr@2
|
65 |
const TInt KMaxCityName=25;
|
williamr@2
|
66 |
|
williamr@2
|
67 |
/** Maximum length for TCountryName.
|
williamr@2
|
68 |
@internalComponent
|
williamr@2
|
69 |
@released
|
williamr@2
|
70 |
*/
|
williamr@2
|
71 |
const TInt KMaxCountryName=25;
|
williamr@2
|
72 |
|
williamr@2
|
73 |
/**
|
williamr@2
|
74 |
@internalComponent
|
williamr@2
|
75 |
@released
|
williamr@2
|
76 |
*/
|
williamr@2
|
77 |
const TInt KMaxWorldRomTitle=32;
|
williamr@2
|
78 |
|
williamr@2
|
79 |
/**
|
williamr@2
|
80 |
@internalComponent
|
williamr@2
|
81 |
@released
|
williamr@2
|
82 |
*/
|
williamr@2
|
83 |
const TInt KMaxWorldLatitudeMinutes=90*60;
|
williamr@2
|
84 |
|
williamr@2
|
85 |
/**
|
williamr@2
|
86 |
@internalComponent
|
williamr@2
|
87 |
@released
|
williamr@2
|
88 |
*/
|
williamr@2
|
89 |
const TInt KMaxWorldLongitudeMinutes=180*60;
|
williamr@2
|
90 |
|
williamr@2
|
91 |
/**
|
williamr@2
|
92 |
@internalComponent
|
williamr@2
|
93 |
@released
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
const TInt KMaxWorldUniversalTimeOffsetMinutes=17*60;
|
williamr@2
|
96 |
|
williamr@2
|
97 |
/**
|
williamr@2
|
98 |
@internalComponent
|
williamr@2
|
99 |
@released
|
williamr@2
|
100 |
*/
|
williamr@2
|
101 |
const TInt KISOCountryCodeLength=2;
|
williamr@2
|
102 |
//
|
williamr@2
|
103 |
|
williamr@2
|
104 |
/** A buffer for a city name.
|
williamr@2
|
105 |
@publishedAll
|
williamr@2
|
106 |
@released
|
williamr@2
|
107 |
*/
|
williamr@2
|
108 |
typedef TBuf<KMaxCityName> TCityName;
|
williamr@2
|
109 |
|
williamr@2
|
110 |
/** A buffer for a country name.
|
williamr@2
|
111 |
@publishedAll
|
williamr@2
|
112 |
@released
|
williamr@2
|
113 |
*/
|
williamr@2
|
114 |
typedef TBuf<KMaxCountryName> TCountryName;
|
williamr@2
|
115 |
|
williamr@2
|
116 |
/**
|
williamr@2
|
117 |
@publishedAll
|
williamr@2
|
118 |
@released
|
williamr@2
|
119 |
*/
|
williamr@2
|
120 |
typedef TBuf<KISOCountryCodeLength> TISOCountryCode;
|
williamr@2
|
121 |
//
|
williamr@2
|
122 |
|
williamr@2
|
123 |
/** Defines the distance units which can be used by the world server.
|
williamr@2
|
124 |
@publishedAll
|
williamr@2
|
125 |
@released
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
enum TWldDistanceUnits
|
williamr@2
|
128 |
{
|
williamr@2
|
129 |
/** Miles. */
|
williamr@2
|
130 |
EWldMiles,
|
williamr@2
|
131 |
/** Kilometres. */
|
williamr@2
|
132 |
EWldKilometers,
|
williamr@2
|
133 |
/** Nautical miles. */
|
williamr@2
|
134 |
EWldNauticalMiles
|
williamr@2
|
135 |
};
|
williamr@2
|
136 |
|
williamr@2
|
137 |
/** City search mode flags. These define whether a search for a city involves the
|
williamr@2
|
138 |
whole of the world database, or just a single country.
|
williamr@2
|
139 |
For example, the RWorldServer::NextCity() function returns either the next
|
williamr@2
|
140 |
city in the country, or the next city in the world, depending on which of these two
|
williamr@2
|
141 |
values is set in the TWorldId.
|
williamr@2
|
142 |
@publishedAll
|
williamr@2
|
143 |
@released
|
williamr@2
|
144 |
*/
|
williamr@2
|
145 |
enum TWldSelect
|
williamr@2
|
146 |
{
|
williamr@2
|
147 |
/** The search is within the whole world database. */
|
williamr@2
|
148 |
EWithinWorld,
|
williamr@2
|
149 |
/** The search is within the current country only. */
|
williamr@2
|
150 |
EWithinCountry
|
williamr@2
|
151 |
};
|
williamr@2
|
152 |
|
williamr@2
|
153 |
/** Flags which indicate the reasons why the server cannot delete a
|
williamr@2
|
154 |
city or country. Bitmasks of these flags are returned by the RWorldServer
|
williamr@2
|
155 |
functions IsCityDeletable() and IsCountryDeletable().
|
williamr@2
|
156 |
@publishedAll
|
williamr@2
|
157 |
@released
|
williamr@2
|
158 |
*/
|
williamr@2
|
159 |
enum TWldDeleteDeniedFlags
|
williamr@2
|
160 |
{
|
williamr@2
|
161 |
/** The specified TWorldId is not found. */
|
williamr@2
|
162 |
EWldDelNotFound=0x01,
|
williamr@2
|
163 |
/** The specified TWorldId is in a read-only file. */
|
williamr@2
|
164 |
EWldDelDerivedFromRom=0x02,
|
williamr@2
|
165 |
/** The specified TWorldId is the home city or country. */
|
williamr@2
|
166 |
EWldDelHomeCityCountry=0x04,
|
williamr@2
|
167 |
/** The specified TWorldId is a capital city. */
|
williamr@2
|
168 |
EWldDelCapitalCity=0x08,
|
williamr@2
|
169 |
/** The specified TWorldId is the default country. */
|
williamr@2
|
170 |
EWldDelDefaultCountry=0x10,
|
williamr@2
|
171 |
/** The specified TWorldId cannot be deleted for all of the above reasons. */
|
williamr@2
|
172 |
EWldDelAll=0xff
|
williamr@2
|
173 |
};
|
williamr@2
|
174 |
//
|
williamr@2
|
175 |
class TLatLong
|
williamr@2
|
176 |
/**
|
williamr@2
|
177 |
@publishedAll
|
williamr@2
|
178 |
@deprecated Interface is deprecated and is available for backward compatibility reasons only
|
williamr@2
|
179 |
*/
|
williamr@2
|
180 |
{
|
williamr@2
|
181 |
public:
|
williamr@2
|
182 |
inline TInt MinutesLat() const; // North is +ve, South is -ve
|
williamr@2
|
183 |
inline TInt MinutesLong() const; // West is +ve, East is -ve
|
williamr@2
|
184 |
IMPORT_C void SetMinutesL(TInt aLat,TInt aLong); // North and West are +ve, South and East are -ve
|
williamr@2
|
185 |
IMPORT_C void SetMinutesCorrectingErrors(TInt aLat,TInt aLong); // North and West are +ve, South and East are -ve
|
williamr@2
|
186 |
private:
|
williamr@2
|
187 |
TInt16 iLat;
|
williamr@2
|
188 |
TInt16 iLong;
|
williamr@2
|
189 |
};
|
williamr@2
|
190 |
//
|
williamr@2
|
191 |
class TCityData
|
williamr@2
|
192 |
/** City information.
|
williamr@2
|
193 |
|
williamr@2
|
194 |
This class stores information about a city, including its name, country,
|
williamr@2
|
195 |
area code, daylight savings zone, latitude and longitude, map position and
|
williamr@2
|
196 |
UTC offset.
|
williamr@2
|
197 |
@publishedAll
|
williamr@2
|
198 |
@released
|
williamr@2
|
199 |
*/
|
williamr@2
|
200 |
{
|
williamr@2
|
201 |
public:
|
williamr@2
|
202 |
/** The city name. */
|
williamr@2
|
203 |
TCityName iCity;
|
williamr@2
|
204 |
/** The country name. */
|
williamr@2
|
205 |
TCountryName iCountry;
|
williamr@2
|
206 |
/** The position of the city in pixels on a map on the screen. */
|
williamr@2
|
207 |
TPoint iMapPos;
|
williamr@2
|
208 |
/** The city's latitude and longitude. This is used to calculate the distance
|
williamr@2
|
209 |
between cities, and the sunrise and sunset time. */
|
williamr@2
|
210 |
TLatLong iLatLong;
|
williamr@2
|
211 |
/** The local area code. */
|
williamr@2
|
212 |
TAreaCode iAreaCode;
|
williamr@2
|
213 |
/** The UTC offset in minutes. */
|
williamr@2
|
214 |
TInt iUniversalTimeOffset;
|
williamr@2
|
215 |
/** The daylight savings zone. */
|
williamr@2
|
216 |
TDaylightSavingZone iDaylightSavingZone;
|
williamr@2
|
217 |
};
|
williamr@2
|
218 |
//
|
williamr@2
|
219 |
class TCountryData
|
williamr@2
|
220 |
/** Country information.
|
williamr@2
|
221 |
|
williamr@2
|
222 |
This class stores information about a country.
|
williamr@2
|
223 |
@publishedAll
|
williamr@2
|
224 |
@released
|
williamr@2
|
225 |
*/
|
williamr@2
|
226 |
{
|
williamr@2
|
227 |
public:
|
williamr@2
|
228 |
/** The country's name. */
|
williamr@2
|
229 |
TCountryName iCountry;
|
williamr@2
|
230 |
/** The country's national dialling code. */
|
williamr@2
|
231 |
TNatCode iNatCode;
|
williamr@2
|
232 |
/** The country's capital city. */
|
williamr@2
|
233 |
TCityName iCapital;
|
williamr@2
|
234 |
/** The national dialling prefix. */
|
williamr@2
|
235 |
TNatPrefCode iNatPref;
|
williamr@2
|
236 |
/** The country's international dialling prefix. */
|
williamr@2
|
237 |
TIntlPrefCode iIntlPref;
|
williamr@2
|
238 |
};
|
williamr@2
|
239 |
//
|
williamr@2
|
240 |
//
|
williamr@2
|
241 |
class TWorldId
|
williamr@2
|
242 |
/** World ID.
|
williamr@2
|
243 |
|
williamr@2
|
244 |
This class stores the world ID for a city/country. This consists of the city
|
williamr@2
|
245 |
and country names. Unique IDs of this type are used to identify every city
|
williamr@2
|
246 |
in the world database.
|
williamr@2
|
247 |
|
williamr@2
|
248 |
It also defines a field for setting whether city searches span the
|
williamr@2
|
249 |
whole database, or just the current country.
|
williamr@2
|
250 |
@publishedAll
|
williamr@2
|
251 |
@deprecated Interface is deprecated and is available for backward compatibility reasons only
|
williamr@2
|
252 |
*/
|
williamr@2
|
253 |
{
|
williamr@2
|
254 |
public:
|
williamr@2
|
255 |
IMPORT_C TWorldId();
|
williamr@2
|
256 |
inline const TCityName& City() const;
|
williamr@2
|
257 |
inline const TCountryName& Country() const;
|
williamr@2
|
258 |
inline TWldSelect Select() const;
|
williamr@2
|
259 |
inline void SetSelect(TWldSelect aSelector);
|
williamr@2
|
260 |
private:
|
williamr@2
|
261 |
TCityName iCity;
|
williamr@2
|
262 |
TWldSelect iSelect;
|
williamr@2
|
263 |
TCountryName iCountry;
|
williamr@2
|
264 |
friend class RWorldServer;
|
williamr@2
|
265 |
};
|
williamr@2
|
266 |
//
|
williamr@2
|
267 |
class RWorldServer : public RSessionBase
|
williamr@2
|
268 |
/** Defines the client side API to the world server.
|
williamr@2
|
269 |
|
williamr@2
|
270 |
Clients can use this API to connect to the server, add, update and delete
|
williamr@2
|
271 |
cities/countries, retrieve city/country information, navigate and search the
|
williamr@2
|
272 |
world database, set the home city, default country, and the units used in
|
williamr@2
|
273 |
distance comparisons. In addition, clients can use the file handling functions
|
williamr@2
|
274 |
to import and export database data files.
|
williamr@2
|
275 |
@publishedAll
|
williamr@2
|
276 |
@deprecated Interface is deprecated and is available for backward compatibility reasons only
|
williamr@2
|
277 |
*/
|
williamr@2
|
278 |
{
|
williamr@2
|
279 |
public:
|
williamr@2
|
280 |
IMPORT_C TInt Connect();
|
williamr@2
|
281 |
IMPORT_C TVersion Version() const;
|
williamr@2
|
282 |
IMPORT_C void RomTitle(TDes& aText) const;
|
williamr@2
|
283 |
IMPORT_C TInt NumberCities() const;
|
williamr@2
|
284 |
IMPORT_C TInt NumberCountries() const;
|
williamr@2
|
285 |
//
|
williamr@2
|
286 |
IMPORT_C void NotifyOnChange(TRequestStatus& aStatus);
|
williamr@2
|
287 |
IMPORT_C void NotifyOnChangeCancel();
|
williamr@2
|
288 |
//
|
williamr@2
|
289 |
IMPORT_C TInt ResetAllData();
|
williamr@2
|
290 |
IMPORT_C TInt DataFileSave();
|
williamr@2
|
291 |
IMPORT_C TInt DataFileRevertToSaved();
|
williamr@2
|
292 |
//
|
williamr@2
|
293 |
IMPORT_C TInt DefaultCountry(TWorldId& aCountry) const;
|
williamr@2
|
294 |
IMPORT_C TInt SetDefaultCountry(const TWorldId& aId);
|
williamr@2
|
295 |
IMPORT_C TInt Home(TWorldId& aHome) const;
|
williamr@2
|
296 |
IMPORT_C TInt SetHome(const TWorldId& aId);
|
williamr@2
|
297 |
//
|
williamr@2
|
298 |
IMPORT_C TInt AddCity(const TCityData& aCity);
|
williamr@2
|
299 |
IMPORT_C TInt AddCountry(const TCountryData& aCountry,const TCityData& aCapital);
|
williamr@2
|
300 |
IMPORT_C TInt CityData(TCityData& aCity,const TWorldId& aId) const;
|
williamr@2
|
301 |
IMPORT_C TInt CountryData(TCountryData& aCountry,const TWorldId& aId) const;
|
williamr@2
|
302 |
IMPORT_C TInt CalculateDistance(TInt& aDistance,const TWorldId& aLeft,const TWorldId& aRight) const;
|
williamr@2
|
303 |
IMPORT_C TInt CalculateSunlight(TTime& aSunrise,TTime& aSunset,const TWorldId& aId,const TTime& aDate=Time::NullTTime()) const;
|
williamr@2
|
304 |
IMPORT_C TInt DeleteCity(TWorldId& aId);
|
williamr@2
|
305 |
IMPORT_C TInt DeleteCountry(TWorldId& aId);
|
williamr@2
|
306 |
IMPORT_C TInt DistanceUnits(TWldDistanceUnits& aDistanceUnit) const;
|
williamr@2
|
307 |
IMPORT_C TInt SetDistanceUnits(TWldDistanceUnits aUnit);
|
williamr@2
|
308 |
IMPORT_C TInt Find(TWorldId& aId,const TDesC& aCity,const TDesC& aCountry) const;
|
williamr@2
|
309 |
IMPORT_C TInt FindCity(TWorldId& aCity,const TDesC& aPartialCity) const;
|
williamr@2
|
310 |
IMPORT_C TInt FindCountry(TWorldId& aCountry,const TDesC& aPartialCountry) const;
|
williamr@2
|
311 |
IMPORT_C TInt FirstCity(TWorldId& aId) const;
|
williamr@2
|
312 |
IMPORT_C TInt FirstCountry(TWorldId& aId) const;
|
williamr@2
|
313 |
IMPORT_C TInt IsCityDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;
|
williamr@2
|
314 |
IMPORT_C TInt IsCountryDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;
|
williamr@2
|
315 |
IMPORT_C TInt LastCity(TWorldId& aId) const;
|
williamr@2
|
316 |
IMPORT_C TInt LastCountry(TWorldId& aId) const;
|
williamr@2
|
317 |
IMPORT_C TInt NearestCity(const TPoint& aMapCoord,const TWorldId* aCityToBeat=NULL);
|
williamr@2
|
318 |
IMPORT_C TInt NextNearestCity(TWorldId& aId,TInt aMaxNumberToCompare=KMaxTInt);
|
williamr@2
|
319 |
IMPORT_C TInt NextCity(TWorldId& aId) const;
|
williamr@2
|
320 |
IMPORT_C TInt NextCountry(TWorldId& aId) const;
|
williamr@2
|
321 |
IMPORT_C TInt PrevCity(TWorldId& aId) const;
|
williamr@2
|
322 |
IMPORT_C TInt PrevCountry(TWorldId& aId) const;
|
williamr@2
|
323 |
IMPORT_C TInt UpdateCity(TWorldId& aId,const TCityData& aCity);
|
williamr@2
|
324 |
IMPORT_C TInt UpdateCountry(TWorldId& aId,const TCountryData& aCountry);
|
williamr@2
|
325 |
IMPORT_C TInt GetCountryNameByISOCode(const TDesC& aCode, TDes& aCountry) const;
|
williamr@2
|
326 |
IMPORT_C TInt SetCollationLevelForFind(TInt aCollationLevel); // this is a per-client setting
|
williamr@2
|
327 |
public:
|
williamr@2
|
328 |
IMPORT_C void __DbgFailAlloc(TInt aCount);
|
williamr@2
|
329 |
IMPORT_C void __DbgMarkEnd();
|
williamr@2
|
330 |
IMPORT_C void __DbgMarkHeap();
|
williamr@2
|
331 |
IMPORT_C TInt SetRomDatabaseToUse(const TDesC& aRomDatabaseToUse);
|
williamr@2
|
332 |
IMPORT_C TBool ReadOnlyDataIsInRAM() const;
|
williamr@2
|
333 |
};
|
williamr@2
|
334 |
//
|
williamr@2
|
335 |
// TWorldId
|
williamr@2
|
336 |
inline TWldSelect TWorldId::Select() const
|
williamr@2
|
337 |
/** Gets the current city search mode. Clients can search for cities by country,
|
williamr@2
|
338 |
or over the whole world database.
|
williamr@2
|
339 |
|
williamr@2
|
340 |
@return The current city search mode. */
|
williamr@2
|
341 |
{
|
williamr@2
|
342 |
return(iSelect);
|
williamr@2
|
343 |
}
|
williamr@2
|
344 |
inline const TCityName& TWorldId::City() const
|
williamr@2
|
345 |
/** Gets the city name in the current TWorldId.
|
williamr@2
|
346 |
|
williamr@2
|
347 |
@return A reference to the city name. */
|
williamr@2
|
348 |
{
|
williamr@2
|
349 |
return(iCity);
|
williamr@2
|
350 |
}
|
williamr@2
|
351 |
inline const TCountryName& TWorldId::Country() const
|
williamr@2
|
352 |
/** Gets the country name in the current TWorldId.
|
williamr@2
|
353 |
|
williamr@2
|
354 |
@return A reference to the country name. */
|
williamr@2
|
355 |
{
|
williamr@2
|
356 |
return(iCountry);
|
williamr@2
|
357 |
}
|
williamr@2
|
358 |
inline void TWorldId::SetSelect(TWldSelect aSelector)
|
williamr@2
|
359 |
/** Sets the city search mode. Clients can search for cities by country, or over
|
williamr@2
|
360 |
the whole world database.
|
williamr@2
|
361 |
|
williamr@2
|
362 |
@param aSelector The city search mode. */
|
williamr@2
|
363 |
{
|
williamr@2
|
364 |
iSelect=aSelector;
|
williamr@2
|
365 |
}
|
williamr@2
|
366 |
//
|
williamr@2
|
367 |
// TLatLong
|
williamr@2
|
368 |
inline TInt TLatLong::MinutesLat() const
|
williamr@2
|
369 |
{
|
williamr@2
|
370 |
return(iLat);
|
williamr@2
|
371 |
}
|
williamr@2
|
372 |
inline TInt TLatLong::MinutesLong() const
|
williamr@2
|
373 |
{
|
williamr@2
|
374 |
return(iLong);
|
williamr@2
|
375 |
}
|
williamr@2
|
376 |
#endif
|