clock/clockmw/clocktimezone/inc/timezoneclient.h
branchRCL_3
changeset 65 12af337248b1
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 // timezoneclient.h
       
    19 #ifndef __TIMEZONECLIENT_H__
       
    20 #define __TIMEZONECLIENT_H__
       
    21 
       
    22 // System includes
       
    23 #include <qglobal.h>
       
    24 #include <QtGui>
       
    25 #include <QList>
       
    26 #include <QDateTime>
       
    27 #include <QMap>
       
    28 
       
    29 #include <tz.h>
       
    30 
       
    31 // User includes
       
    32 #include "clockdatatypes.h"
       
    33 
       
    34 #ifdef  TIMEZONECLIENT_LIBRARY
       
    35 #define TIMEZONECLIENT_EXPORT Q_DECL_EXPORT
       
    36 #else
       
    37 #define TIMEZONECLIENT_EXPORT Q_DECL_IMPORT
       
    38 #endif
       
    39 
       
    40 //class CEnvironmentChangeNotifier;
       
    41 class QStandardItemModel;
       
    42 class CTzLocalizer;
       
    43 class XQSettingsManager;
       
    44 class XQSettingsKey;
       
    45 class EnvironmentChangeNotifier;
       
    46 
       
    47 class TimezoneClient : public QObject
       
    48 {
       
    49 	Q_OBJECT
       
    50 
       
    51 public:
       
    52 	TIMEZONECLIENT_EXPORT static TimezoneClient* getInstance();
       
    53 	TIMEZONECLIENT_EXPORT void deleteInstance();
       
    54 	TIMEZONECLIENT_EXPORT bool isNull();
       
    55 
       
    56 public:
       
    57 	TIMEZONECLIENT_EXPORT QList<LocationInfo> &getLocations();
       
    58 	TIMEZONECLIENT_EXPORT LocationInfo getCurrentZoneInfoL();
       
    59 	TIMEZONECLIENT_EXPORT void setAsCurrentLocationL(LocationInfo &location);
       
    60 	TIMEZONECLIENT_EXPORT bool isDSTOnL(int timezoneId);
       
    61 	TIMEZONECLIENT_EXPORT int getStandardOffset(int timezoneId);
       
    62 	TIMEZONECLIENT_EXPORT bool timeUpdateOn();
       
    63 	TIMEZONECLIENT_EXPORT void setTimeUpdateOn(bool timeUpdate = true);
       
    64 	TIMEZONECLIENT_EXPORT void setDateTime(QDateTime dateTime);
       
    65 	TIMEZONECLIENT_EXPORT QList<int> getAllTimeZoneOffsets();
       
    66 	TIMEZONECLIENT_EXPORT QList<LocationInfo> getCountriesForUTCOffset(
       
    67 			int utcOffset);
       
    68 	TIMEZONECLIENT_EXPORT LocationInfo addCity(
       
    69 			int timeZoneId, QString &cityName, int cityGroupId);
       
    70 	TIMEZONECLIENT_EXPORT bool checkForDstChange(AlarmInfo& alarmInfo);
       
    71 	TIMEZONECLIENT_EXPORT QList<LocationInfo> getSavedLocations();
       
    72 	TIMEZONECLIENT_EXPORT void saveLocations(
       
    73 			const QList<LocationInfo> &locationList);
       
    74 	
       
    75 	void notifyTimeChange();
       
    76 
       
    77 signals:
       
    78 	void timechanged();
       
    79 	void listUpdated();
       
    80 	void autoTimeUpdateChanged(int value);
       
    81 	void cityUpdated();
       
    82 
       
    83 private:
       
    84 	TimezoneClient();
       
    85 	~TimezoneClient();
       
    86 	
       
    87 private:
       
    88 	bool dstOn(int tzId);	
       
    89 	QList<int> getAllTimeZoneIds();
       
    90 	int getDstZoneOffset(int tzId);
       
    91 	TMonth intToMonth(int month);
       
    92 	bool getUtcDstOffsetL(int &dstOffset, const CTzId &tzId);
       
    93 	void getDstRulesL(
       
    94 			QDateTime &startTime, QDateTime &endTime,int timezoneId);
       
    95 	void getCitiesForCountry(
       
    96 			int id, QMap<QString, int>& cities);
       
    97 	void getLocationInfo(
       
    98 			int groupId, int cityIndex, LocationInfo& cityInfo);
       
    99 	int getCityGroupIdByName(const QString& name);
       
   100 	int getCityOffsetByNameAndId(const QString& name, int tzId);
       
   101 
       
   102 private slots:
       
   103 	void populateCities();
       
   104 	void eventMonitor(const XQSettingsKey& key, const QVariant& value);
       
   105 
       
   106 private:
       
   107 	static TimezoneClient *mTimezoneClient;
       
   108 	static bool mReferenceCount;
       
   109 	
       
   110 private:
       
   111 	EnvironmentChangeNotifier *mNotifier;
       
   112 	CTzLocalizer *mTzLocalizer;
       
   113 	QMap<QString, int> mAllCountries;
       
   114 	QList<LocationInfo> mAllLocations;
       
   115 	QPointer<QStandardItemModel> mWorldClockModel;
       
   116 	XQSettingsManager *mSettingsManager;
       
   117 	XQSettingsKey *mAutoTimeUpdateKey;
       
   118 
       
   119 	QList<int> mTimeZoneIds;
       
   120 
       
   121 	int mCountryCount;
       
   122 	int mAutoTimeUpdateValue;
       
   123 };
       
   124 
       
   125 #endif		// __TIMEZONECLIENT_H__
       
   126 
       
   127 // End of file