Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: t32wld.h
Link against: ealwl.lib

Class RWorldServer

RWorldServer

Support

Supported from 5.0

Description

Defines the world server’s client side API.

Clients can use this API to connect to the server, add, update and delete cities/countries, retrieve city/country information, navigate and search the world database, set the home city, default country, and the units used in distance comparisons. In addition, clients can use the file handling functions to import and export database data files.

Derivation

RHandleBaseHandle to an object
RSessionBaseClient-side handle to a session with a server
RWorldServerDefines the world server's client side API

Defined in RWorldServer:
AddCity(), AddCountry(), CalculateDistance(), CalculateSunlight(), CityData(), Connect(), CountryData(), DataFileLocation(), DataFileOpen(), DataFileRevertToSaved(), DataFileSave(), DataFileSaveAs(), DefaultCountry(), DeleteCity(), DeleteCountry(), DistanceUnits(), Find(), FindCity(), FindCountry(), FirstCity(), FirstCountry(), GetCountryNameByISOCode(), Home(), IsCityDeletable(), IsCountryDeletable(), LastCity(), LastCountry(), NearestCity(), NextCity(), NextCountry(), NextNearestCity(), NotifyOnChange(), NotifyOnChangeCancel(), NumberCities(), NumberCountries(), PrevCity(), PrevCountry(), ResetAllData(), RomTitle(), SetDefaultCountry(), SetDistanceUnits(), SetHome(), UpdateCity(), UpdateCountry(), Version()

Inherited from RHandleBase:
Close(), Duplicate(), Handle(), SetHandle()

Inherited from RSessionBase:
Attach(), CreateSession(), EAutoAttach, EExplicitAttach, Send(), SendReceive(), SetRetry(), Share(), TAttachMode


Connecting to the world server


Connect()

TInt Connect();

Description

Connects the client process to the world server.

Note:

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Version()

TVersion Version() const;

Description

Gets the version number of the world server. The version number may be incremented in future releases of the world server. If extra features are added in such releases, the version number may be used by application programs as a basis for assessing the capabilities of the world server. Version-specific functions will be marked as such in the SDK documentation.

Return value

TVersion

The version number.

[Top]


City modifying

Description

To update or delete a city, the session must first obtain the correct TWldID. A TCityData is filled with the data and the server is called to add the information.

Contains the functions used to add, update, and delete city information.


AddCity()

TInt AddCity(const TCityData& aCity);

Description

Adds a new city to the world database.

Cities must be in a valid country, and have a valid DST zone. City names must be unique within a country — though the same city name may be used for cities in different countries.

Parameters

const TCityData& aCity

The new city information.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes. KErrArgument is returned if the city already exists, or if the city data doesn’t specify a city name. It is also returned if the named country does not exist, or if the country name is not specified.


UpdateCity()

TInt UpdateCity(TWorldId& aId,const TCityData& aCity);

Description

Updates the information for a city.

The new information must also be valid — cities must be in a valid country, and have a valid DST zone. City names must be unique within a country — though the same city name may be used for cities in different countries.

Parameters

TWorldId& aId

The ID of the city to be updated.

const TCityData& aCity

The new city information

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes. KErrArgument is returned if the updated city name overwrites an existing city, or if it isn’t specified. It is also returned if the updated country name does not exist, or if the country name is not specified.


IsCityDeletable()

TInt IsCityDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;

Description

Tests whether a given city can be deleted. Capital cities, the home city, and all cities from the read-only file cannot be deleted.

Parameters

TInt& aDeleteDeniedFlags

Bitmask of the TWldDeleteDeniedFlags flags. Gives the reasons why the specified TWorldID cannot be deleted. The value returned is 0 if the country can be deleted.

const TWorldId& aId

The ID of the city which is being queried.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


DeleteCity()

TInt DeleteCity(TWorldId& aId);

Description

Deletes a city from the world database. Capital cities, the home city, and all cities from the read-only file cannot be deleted.

Note:

Parameters

TWorldId& aId

The ID of the city which is to be deleted.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


City navigation

Description

The cities are sorted according to their name by the locale alphabet order.


NumberCities()

TInt NumberCities() const;

Description

Gets the number of cities in the world database.

Return value

TInt

On return, contains the number of cities in the database.


FirstCity()

TInt FirstCity(TWorldId& aId) const;

Description

Gets the ID of the first city in the selected locale.

The locale can either be the current country or the whole world database, and is defined by the Select mode of the TWorldId.

Notes:

Parameters

TWorldId& aId

Specifies the locale for which the search is to be carried out — over the whole database, or in the current country. On return, contains the ID of the first city within the specified locale.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


NextCity()

TInt NextCity(TWorldId& aId) const;

Description

Gets the ID of the next city in the selected locale.

The locale can either be the current country or the whole world database, and is defined by the Select mode of the TWorldId.

Notes:

Parameters

TWorldId& aId

Specifies the locale within which the next city is to be found — over the whole database, or in the current country. On return, contains the ID of the next city in the specified locale.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes. KErrNotFound is returned if this function is called when the current city is the last city.


PrevCity()

TInt PrevCity(TWorldId& aId) const;

Description

Gets the ID of the previous city in the selected locale.

The locale can either be the current country or the whole world database, and is defined by the Select mode of the TWorldId.

Notes:

Parameters

TWorldId& aId

Specifies the locale within which the previous city is to be found — over the whole database, or in the current country. On return, contains the ID of the previous city within the specified locale.

Return value

TInt

KErrNone if successful, KErrNotFound when the current city is the first city, otherwise another of the system-wide error codes.


LastCity()

TInt LastCity(TWorldId& aId) const;

Description

Gets the ID of the last city — in the selected locale.

The locale can either be the current country or the whole world database, and is defined by the Select mode of the TWorldId.

Notes:

Parameters

TWorldId& aId

Specifies the locale within which the last city is to be found — over the whole database, or in the current country. On return, contains the ID of the last city in the specified locale.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


FindCity()

TInt FindCity(TWorldId& aCity,const TDesC& aPartialCity) const;

Description

Locates the ID of the first city that has a name which starts with the search string.

The search string can contain a partial name or the full name. The string may be capitalised, uncapitalised, or a combination of the two. If several cities have names matching the search string, then the first city found is returned — the lowest in the alphabetic order.

Note:

Parameters

TWorldId& aCity

Specifies the locale within which the city is to be found — over the whole database, or in the current country. On return, contains the ID of the first city matching the partial name within the specified locale.

const TDesC& aPartialCity

A descriptor containing the search string for the city.

Return value

TInt

KErrNone if successful, KErrNotFound if no city matches the search string, otherwise another of the system-wide error codes.


Find()

TInt Find(TWorldId& aId,const TDesC& aCity,const TDesC& aCountry) const;

Description

Finds the ID of the city which precisely matches the specified city and country names.

Parameters

TWorldId& aId

On return, contains the ID of the specified city.

const TDesC& aCity

The city name.

const TDesC& aCountry

The country name.

Return value

TInt

KErrNone if successful, KErrNotFound if there is no match between the city and country names and those of a city in the world database, otherwise another of the system-wide error codes..

[Top]


Country modifying

Description

To update or delete a country, the session must first obtain the correctTWldID. To add a country, a TCountryData is filled with the data and the server is called to add the information.

Contains the functions used to add, update, and delete country information.


AddCountry()

TInt AddCountry(const TCountryData& aCountry,const TCityData& aCapital);

Description

Adds a new country, with its capital city, to the world database. Country names must be unique.

Parameters

const TCountryData& aCountry

The country to be added to the database.

const TCityData& aCapital

The country’s capital.

Return value

TInt

KErrNone if successful, KErrArgument if the name of the new country is not specified or if the capital city information indicates that it is not in the country, otherwise another of the system-wide error codes.


UpdateCountry()

TInt UpdateCountry(TWorldId& aId,const TCountryData& aCountry);

Description

Updates the data of an existing country. Updated country names must be unique.

Parameters

TWorldId& aId

The ID of the country to be updated.

const TCountryData& aCountry

The new country data.

Return value

TInt

KErrNone if successful, KErrArgument is returned if the updated country name is not specified or if it is not unique, otherwise another of the system-wide error codes.


IsCountryDeletable()

TInt IsCountryDeletable(TInt& aDeleteDeniedFlags,const TWorldId& aId) const;

Description

Determines whether a given country can be deleted. The home country, default country, and all countries from the read-only file cannot be deleted.

Parameters

TInt& aDeleteDeniedFlags

Bitmask of the TWldDeleteDeniedFlags flags. Gives the reasons why the specified TWorldID cannot be deleted. The value returned is 0 if the country can be deleted.

const TWorldId& aId

The ID of the country which is being queried.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes


DeleteCountry()

TInt DeleteCountry(TWorldId& aId);

Description

Deletes a country from the world database.

The home country, default country, and all countries from the read-only file cannot be deleted.

Notes:

Parameters

TWorldId& aId

The ID of the country to be deleted.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Country navigation

Description

The countries are sorted according to their name by alphabetic order.


NumberCountries()

TInt NumberCountries() const;

Description

Gets the number of countries in the world database.

Return value

TInt

The number of countries in the world database.


FirstCountry()

TInt FirstCountry(TWorldId& aId) const;

Description

Gets the ID of the first country in the world database.

Notes:

Parameters

TWorldId& aId

On return, contains the ID of the first country.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


NextCountry()

TInt NextCountry(TWorldId& aId) const;

Description

Gets the ID of the next country in the world database.

Notes:

Parameters

TWorldId& aId

On return, contains the ID of the next country.

Return value

TInt

KErrNone if successful, KErrNotFound when the current country is the last country, otherwise another of the system-wide error codes


PrevCountry()

TInt PrevCountry(TWorldId& aId) const;

Description

Gets the ID of the previous country in the world database.

Notes:

Parameters

TWorldId& aId

On return, contains the ID of the previous country.

Return value

TInt

KErrNone if successful, KErrNotFound when the current country is the first country, otherwise another of the system-wide error codes.


LastCountry()

TInt LastCountry(TWorldId& aId) const;

Description

Gets the ID of the last country in the world database.

Notes:

Parameters

TWorldId& aId

On return, contains the ID of the last country.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


FindCountry()

TInt FindCountry(TWorldId& aCountry,const TDesC& aPartialCountry) const;

Description

Locates the ID of the first country which starts with the search string.

The search string can contain a partial name or the full name. The string may be capitalised, uncapitalised, or a combination of the two. If several countries have names matching the search string, then the first country found is returned — the lowest in the alphabetic order.

Note:

Parameters

TWorldId& aCountry

On return, contains the ID of the country.

const TDesC& aPartialCountry

A descriptor containing the search string, or partial country name.

Return value

TInt

KErrNone if successful, KErrNotFound if no country matches the search string, otherwise another of the system-wide error codes.

[Top]


File functions

Description

This section describes the functions which can be used to locate, import, export, and delete the effects of data files.

New cities and countries can be added to the world server by importing a data file. Importing data updates any information of existing cities or countries. The import method cannot be used to delete any data that is set already, and can import only those cities or countries that obey referential integrity — e.g. cities must always be added to a country, a country cannot be added without a capital city etc.


DataFileLocation()

TInt DataFileLocation(TFileName& aDataFile) const;

Description

Gets the location of the most recently imported user data file.

Parameters

TFileName& aDataFile

On return, contains the name and path of the most recently imported data file.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


DataFileOpen()

TInt DataFileOpen(const TDesC& aDataFile);

Description

Allows clients to import a specified world database data file.

Parameters

const TDesC& aDataFile

The location of the data file to be imported, including drive, path and file name.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


DataFileRevertToSaved()

TInt DataFileRevertToSaved();

Description

Reverts the world database to its state when the data file was last saved — discarding data which was not saved.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


DataFileSave()

TInt DataFileSave();

Description

Saves the world database data — added by the user — to the current data file.

Notes:

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


DataFileSaveAs()

TInt DataFileSaveAs(const TDesC& aDataFile,TBool aReplace=EFalse);

Description

Saves the world database data — added by the user — to a specified data file.

Parameters

const TDesC& aDataFile

The name, including path, of the data file in which the user added data is to be saved.

TBool aReplace=EFalse

This specifies whether or not the function will allow an existing data file to be over-written. By default the function does not over-write data files.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes. KErrAlreadyExists is returned if the data file exists and aReplace is set to disallow overwriting.


ResetAllData()

TInt ResetAllData();

Description

Resets the database to the state it had when first opened, and notifies the clients.

Note:

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Home location


Home()

TInt Home(TWorldId& aHome) const;

Description

Gets the ID of the home city.

Parameters

TWorldId& aHome

On return, contains the ID of the home city.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


SetHome()

TInt SetHome(const TWorldId& aId);

Description

Sets the home city.

Parameters

const TWorldId& aId

The ID of the city which is to become the home city.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Default country


DefaultCountry()

TInt DefaultCountry(TWorldId& aCountry) const;

Description

Gets the ID of the default country.

Parameters

TWorldId& aCountry

On return, contains the ID of the default country.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


SetDefaultCountry()

TInt SetDefaultCountry(const TWorldId& aId);

Description

Sets the default country.

Parameters

const TWorldId& aId

The ID of the country which is to become the default country.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


City/Country data


CityData()

TInt CityData(TCityData& aCity,const TWorldId& aId) const;

Description

Gets the city data associated with the specified ID.

Parameters

TCityData& aCity

On return, contains the city data.

const TWorldId& aId

The ID of the city.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


CountryData()

TInt CountryData(TCountryData& aCountry,const TWorldId& aId) const;

Description

Gets the country data associated with the specified ID.

Parameters

TCountryData& aCountry

On return, contains the country data.

const TWorldId& aId

The ID of the country.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


GetCountryNameByISOCode()

TInt GetCountryNameByISOCode(const TDesC& aCode, TDes& aCountry) const;

Support

Supported from 6.0

Description

Gets the country name for the given ISO country code.

Note:

Parameters

const TDesC& aCode

The ISO country code.

TDes& aCountry

On return, contains the name of the country.

Return value

TInt

KErrNone if successful or KErrNotFound if there is an attempt to get a country name with an undefined country code. Otherwise another of the system-wide error codes.

[Top]


Distance units


DistanceUnits()

TInt DistanceUnits(TWldDistanceUnits& aDistanceUnit) const;

Description

Gets the distance units used by the session.

Parameters

TWldDistanceUnits& aDistanceUnit

On return, contains the session’s distance units.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


SetDistanceUnits()

TInt SetDistanceUnits(TWldDistanceUnits aUnit);

Description

Sets the distance units used by the session.

Parameters

TWldDistanceUnits aUnit

The new distance units.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Distance, sunlight and city location calculations


CalculateDistance()

TInt CalculateDistance(TInt& aDistance,const TWorldId& aLeft,const TWorldId& aRight) const;

Description

Calculates the distance between two cities — using the currently selected distance units.

Parameters

TInt& aDistance

On return, contains the distance between the two cities.

const TWorldId& aLeft

The ID of the first city.

const TWorldId& aRight

The ID of the second city.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


CalculateSunlight()

TInt CalculateSunlight(TTime& aSunrise,TTime& aSunset,const TWorldId& aId,const TTime& aDate=Time::NullTTime()) const;

Description

Gets a city’s sunset and sunrise time on a specified date.

Parameters

TTime& aSunrise

On return, contains the sunrise time.

TTime& aSunset

On return, contains the sunset time.

const TWorldId& aId

The ID of the city for which the sunset and sunrise times are to be calculated.

const TTime& aDate=Time::NullTTime()

The date for which the sunrise/sunset times are to be calculated.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


NearestCity()

TInt NearestCity(const TPoint& aMapCoord,const TWorldId* aCityToBeat=NULL);

Description

Initialises the parameters for a next city search. To actually start the search, use the NextNearestCity() function.

Parameters

const TPoint& aMapCoord

The map co-ordinate for which the nearest city is to be found (pixels).

const TWorldId* aCityToBeat=NULL

The ID of the reference city. The search spans a specified number of cites, starting from this ID.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


NextNearestCity()

TInt NextNearestCity(TWorldId& aId,TInt aMaxNumberToCompare=KMaxTInt);

Description

Gets the results of a search for the city nearest to a map co-ordinate — the co-ordinate is specified using theNearestCity() function.

The search compares the distance between each city and the map co-ordinate. It starts at the reference city and continues the comparison until it reaches a specified number of cities. By default, the search spansKMaxTInt cities, which is effectively the entire database.

Parameters

TWorldId& aId

On return, contains the ID of the nearest city.

TInt aMaxNumberToCompare=KMaxTInt

The number of cities to compare in the search.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Notifications


NotifyOnChange()

void NotifyOnChange(TRequestStatus& aStatus);

Description

Provides notification of changes to the home city, default country, system time, and database files — asynchronous.

Parameters

TRequestStatus& aStatus

A variable that indicates the completion status of the request.


NotifyOnChangeCancel()

void NotifyOnChangeCancel();

Description

Cancels an outstanding request for notification of changes to the home city, default country, system time, and database files.

[Top]


ROM title


RomTitle()

void RomTitle(TDes& aText) const;

Description

Gets the title of the currently loaded world database, which is defined in the read-only file..

Parameters

TDes& aText

On return, contains the title of the world database.