1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include <dial_consts.h>
26 _LIT(KWorldServerName, "!WorldServer");
28 _LIT(KWorldServerImageName, "WorldServer");
34 const TUid KWorldServerUid = { 0x101F5025 };
41 const TInt KWorldServerMajorVN=1;
47 const TInt KWorldServerMinorVN=0;
53 const TInt KWorldServerBuildVN=105;
59 const TInt KMaxZoneName=3;
61 /** Maximum length for TCityName.
65 const TInt KMaxCityName=25;
67 /** Maximum length for TCountryName.
71 const TInt KMaxCountryName=25;
77 const TInt KMaxWorldRomTitle=32;
83 const TInt KMaxWorldLatitudeMinutes=90*60;
89 const TInt KMaxWorldLongitudeMinutes=180*60;
95 const TInt KMaxWorldUniversalTimeOffsetMinutes=17*60;
101 const TInt KISOCountryCodeLength=2;
104 /** A buffer for a city name.
108 typedef TBuf<KMaxCityName> TCityName;
110 /** A buffer for a country name.
114 typedef TBuf<KMaxCountryName> TCountryName;
120 typedef TBuf<KISOCountryCodeLength> TISOCountryCode;
123 /** Defines the distance units which can be used by the world server.
127 enum TWldDistanceUnits
133 /** Nautical miles. */
137 /** City search mode flags. These define whether a search for a city involves the
138 whole of the world database, or just a single country.
139 For example, the RWorldServer::NextCity() function returns either the next
140 city in the country, or the next city in the world, depending on which of these two
141 values is set in the TWorldId.
147 /** The search is within the whole world database. */
149 /** The search is within the current country only. */
153 /** Flags which indicate the reasons why the server cannot delete a
154 city or country. Bitmasks of these flags are returned by the RWorldServer
155 functions IsCityDeletable() and IsCountryDeletable().
159 enum TWldDeleteDeniedFlags
161 /** The specified TWorldId is not found. */
162 EWldDelNotFound=0x01,
163 /** The specified TWorldId is in a read-only file. */
164 EWldDelDerivedFromRom=0x02,
165 /** The specified TWorldId is the home city or country. */
166 EWldDelHomeCityCountry=0x04,
167 /** The specified TWorldId is a capital city. */
168 EWldDelCapitalCity=0x08,
169 /** The specified TWorldId is the default country. */
170 EWldDelDefaultCountry=0x10,
171 /** The specified TWorldId cannot be deleted for all of the above reasons. */
178 @deprecated Interface is deprecated and is available for backward compatibility reasons only
182 inline TInt MinutesLat() const; // North is +ve, South is -ve
183 inline TInt MinutesLong() const; // West is +ve, East is -ve
184 IMPORT_C void SetMinutesL(TInt aLat,TInt aLong); // North and West are +ve, South and East are -ve
185 IMPORT_C void SetMinutesCorrectingErrors(TInt aLat,TInt aLong); // North and West are +ve, South and East are -ve
192 /** City information.
194 This class stores information about a city, including its name, country,
195 area code, daylight savings zone, latitude and longitude, map position and
202 /** The city name. */
204 /** The country name. */
205 TCountryName iCountry;
206 /** The position of the city in pixels on a map on the screen. */
208 /** The city's latitude and longitude. This is used to calculate the distance
209 between cities, and the sunrise and sunset time. */
211 /** The local area code. */
213 /** The UTC offset in minutes. */
214 TInt iUniversalTimeOffset;
215 /** The daylight savings zone. */
216 TDaylightSavingZone iDaylightSavingZone;
220 /** Country information.
222 This class stores information about a country.
228 /** The country's name. */
229 TCountryName iCountry;
230 /** The country's national dialling code. */
232 /** The country's capital city. */
234 /** The national dialling prefix. */
235 TNatPrefCode iNatPref;
236 /** The country's international dialling prefix. */
237 TIntlPrefCode iIntlPref;
244 This class stores the world ID for a city/country. This consists of the city
245 and country names. Unique IDs of this type are used to identify every city
246 in the world database.
248 It also defines a field for setting whether city searches span the
249 whole database, or just the current country.
251 @deprecated Interface is deprecated and is available for backward compatibility reasons only
256 inline const TCityName& City() const;
257 inline const TCountryName& Country() const;
258 inline TWldSelect Select() const;
259 inline void SetSelect(TWldSelect aSelector);
263 TCountryName iCountry;
264 friend class RWorldServer;
267 class RWorldServer : public RSessionBase
268 /** Defines the client side API to the world server.
270 Clients can use this API to connect to the server, add, update and delete
271 cities/countries, retrieve city/country information, navigate and search the
272 world database, set the home city, default country, and the units used in
273 distance comparisons. In addition, clients can use the file handling functions
274 to import and export database data files.
276 @deprecated Interface is deprecated and is available for backward compatibility reasons only
280 IMPORT_C TInt Connect();
281 IMPORT_C TVersion Version() const;
282 IMPORT_C void RomTitle(TDes& aText) const;
283 IMPORT_C TInt NumberCities() const;
284 IMPORT_C TInt NumberCountries() const;
286 IMPORT_C void NotifyOnChange(TRequestStatus& aStatus);
287 IMPORT_C void NotifyOnChangeCancel();
289 IMPORT_C TInt ResetAllData();
290 IMPORT_C TInt DataFileSave();
291 IMPORT_C TInt DataFileRevertToSaved();
293 IMPORT_C TInt DefaultCountry(TWorldId& aCountry) const;
294 IMPORT_C TInt SetDefaultCountry(const TWorldId& aId);
295 IMPORT_C TInt Home(TWorldId& aHome) const;
296 IMPORT_C TInt SetHome(const TWorldId& aId);
298 IMPORT_C TInt AddCity(const TCityData& aCity);
299 IMPORT_C TInt AddCountry(const TCountryData& aCountry,const TCityData& aCapital);
300 IMPORT_C TInt CityData(TCityData& aCity,const TWorldId& aId) const;
301 IMPORT_C TInt CountryData(TCountryData& aCountry,const TWorldId& aId) const;
302 IMPORT_C TInt CalculateDistance(TInt& aDistance,const TWorldId& aLeft,const TWorldId& aRight) const;
303 IMPORT_C TInt CalculateSunlight(TTime& aSunrise,TTime& aSunset,const TWorldId& aId,const TTime& aDate=Time::NullTTime()) const;
304 IMPORT_C TInt DeleteCity(TWorldId& aId);
305 IMPORT_C TInt DeleteCountry(TWorldId& aId);
306 IMPORT_C TInt DistanceUnits(TWldDistanceUnits& aDistanceUnit) const;
307 IMPORT_C TInt SetDistanceUnits(TWldDistanceUnits aUnit);
308 IMPORT_C TInt Find(TWorldId& aId,const TDesC& aCity,const TDesC& aCountry) const;
309 IMPORT_C TInt FindCity(TWorldId& aCity,const TDesC& aPartialCity) const;
310 IMPORT_C TInt FindCountry(TWorldId& aCountry,const TDesC& aPartialCountry) const;
311 IMPORT_C TInt FirstCity(TWorldId& aId) const;
312 IMPORT_C TInt FirstCountry(TWorldId& aId) const;
313 IMPORT_C TInt IsCityDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;
314 IMPORT_C TInt IsCountryDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;
315 IMPORT_C TInt LastCity(TWorldId& aId) const;
316 IMPORT_C TInt LastCountry(TWorldId& aId) const;
317 IMPORT_C TInt NearestCity(const TPoint& aMapCoord,const TWorldId* aCityToBeat=NULL);
318 IMPORT_C TInt NextNearestCity(TWorldId& aId,TInt aMaxNumberToCompare=KMaxTInt);
319 IMPORT_C TInt NextCity(TWorldId& aId) const;
320 IMPORT_C TInt NextCountry(TWorldId& aId) const;
321 IMPORT_C TInt PrevCity(TWorldId& aId) const;
322 IMPORT_C TInt PrevCountry(TWorldId& aId) const;
323 IMPORT_C TInt UpdateCity(TWorldId& aId,const TCityData& aCity);
324 IMPORT_C TInt UpdateCountry(TWorldId& aId,const TCountryData& aCountry);
325 IMPORT_C TInt GetCountryNameByISOCode(const TDesC& aCode, TDes& aCountry) const;
326 IMPORT_C TInt SetCollationLevelForFind(TInt aCollationLevel); // this is a per-client setting
328 IMPORT_C void __DbgFailAlloc(TInt aCount);
329 IMPORT_C void __DbgMarkEnd();
330 IMPORT_C void __DbgMarkHeap();
331 IMPORT_C TInt SetRomDatabaseToUse(const TDesC& aRomDatabaseToUse);
332 IMPORT_C TBool ReadOnlyDataIsInRAM() const;
336 inline TWldSelect TWorldId::Select() const
337 /** Gets the current city search mode. Clients can search for cities by country,
338 or over the whole world database.
340 @return The current city search mode. */
344 inline const TCityName& TWorldId::City() const
345 /** Gets the city name in the current TWorldId.
347 @return A reference to the city name. */
351 inline const TCountryName& TWorldId::Country() const
352 /** Gets the country name in the current TWorldId.
354 @return A reference to the country name. */
358 inline void TWorldId::SetSelect(TWldSelect aSelector)
359 /** Sets the city search mode. Clients can search for cities by country, or over
360 the whole world database.
362 @param aSelector The city search mode. */
368 inline TInt TLatLong::MinutesLat() const
372 inline TInt TLatLong::MinutesLong() const