clock/clockmw/clocktimezone/inc/timezoneclient.h
changeset 57 bb2d3e476f29
parent 45 b6db4fd4947b
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    25 #include <QList>
    25 #include <QList>
    26 #include <QDateTime>
    26 #include <QDateTime>
    27 #include <QMap>
    27 #include <QMap>
    28 
    28 
    29 #include <tz.h>
    29 #include <tz.h>
    30 #include <bacntf.h>
       
    31 
    30 
    32 // User includes
    31 // User includes
    33 #include "clockdatatypes.h"
    32 #include "clockdatatypes.h"
    34 
    33 
    35 #ifdef  TIMEZONECLIENT_LIBRARY
    34 #ifdef  TIMEZONECLIENT_LIBRARY
    36 #define TIMEZONECLIENT_EXPORT Q_DECL_EXPORT
    35 #define TIMEZONECLIENT_EXPORT Q_DECL_EXPORT
    37 #else
    36 #else
    38 #define TIMEZONECLIENT_EXPORT Q_DECL_IMPORT
    37 #define TIMEZONECLIENT_EXPORT Q_DECL_IMPORT
    39 #endif
    38 #endif
    40 
    39 
    41 class CEnvironmentChangeNotifier;
    40 //class CEnvironmentChangeNotifier;
    42 class QStandardItemModel;
    41 class QStandardItemModel;
    43 class CTzLocalizer;
    42 class CTzLocalizer;
    44 class XQSettingsManager;
    43 class XQSettingsManager;
    45 class XQSettingsKey;
    44 class XQSettingsKey;
       
    45 class EnvironmentChangeNotifier;
    46 
    46 
    47 const int KInitialEvent = (
    47 class TimezoneClient : public QObject
    48 		EChangesLocale |
       
    49 		EChangesMidnightCrossover |
       
    50 		EChangesThreadDeath |
       
    51 		EChangesPowerStatus |
       
    52 		EChangesSystemTime |
       
    53 		EChangesFreeMemory |
       
    54 		EChangesOutOfMemory);
       
    55 
       
    56 class TIMEZONECLIENT_EXPORT TimezoneClient : public QObject, public CBase
       
    57 {
    48 {
    58 	Q_OBJECT
    49 	Q_OBJECT
    59 
    50 
    60 public:
    51 public:
    61 	/*TIMEZONECLIENT_EXPORT*/ static TimezoneClient* getInstance();
    52 	TIMEZONECLIENT_EXPORT static TimezoneClient* getInstance();
    62 	/*TIMEZONECLIENT_EXPORT*/ void deleteInstance();
    53 	TIMEZONECLIENT_EXPORT void deleteInstance();
    63 	/*TIMEZONECLIENT_EXPORT*/ bool isNull();
    54 	TIMEZONECLIENT_EXPORT bool isNull();
    64 
       
    65 private:
       
    66 	TimezoneClient();
       
    67 	~TimezoneClient();
       
    68 
       
    69 private:
       
    70 
       
    71 private:
       
    72 	static TimezoneClient *mTimezoneClient;
       
    73 	static bool mReferenceCount;
       
    74 
       
    75 // TODO: still refatoring
       
    76 public:
       
    77 	/*TIMEZONECLIENT_EXPORT*/ 	QList<LocationInfo> &getLocations();
       
    78 	/*TIMEZONECLIENT_EXPORT*/ LocationInfo getCurrentZoneInfoL();
       
    79 	/*TIMEZONECLIENT_EXPORT*/ void setAsCurrentLocationL(LocationInfo &location);
       
    80 	/*TIMEZONECLIENT_EXPORT*/ bool isDSTOnL(int timezoneId);
       
    81 	/*TIMEZONECLIENT_EXPORT*/ int getStandardOffset(int timezoneId);
       
    82 	QList<LocationInfo> getSavedLocations();
       
    83 	void saveLocations(const QList<LocationInfo> &locationList);
       
    84 	void getCountries(QMap<QString, int>& countries);
       
    85 	bool dstOn(int tzId);
       
    86 	void setDateTime(QDateTime dateTime);
       
    87 	void setTimeUpdateOn(bool timeUpdate = true);
       
    88 	bool timeUpdateOn();
       
    89 	QStandardItemModel *locationSelectorModel();
       
    90 	void createWorldClockModel();
       
    91 	bool checkForDstChange(AlarmInfo& alarmInfo);
       
    92 	QList<int> getAllTimeZoneIds();
       
    93 	QList<int> getAllTimeZoneOffsets();
       
    94 	QList<LocationInfo> getCountriesForUTCOffset(int utcOffset);
       
    95 	LocationInfo addCity(int timeZoneId, QString &cityName, int cityGroupId);
       
    96 
    55 
    97 public:
    56 public:
    98 	static int environmentCallback(TAny* obj);
    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();
    99 
    76 
   100 signals:
    77 signals:
   101 	void timechanged();
    78 	void timechanged();
   102 	void listUpdated();
    79 	void listUpdated();
   103 	void autoTimeUpdateChanged(int value);
    80 	void autoTimeUpdateChanged(int value);
   104 	void cityUpdated();
    81 	void cityUpdated();
       
    82 
       
    83 private:
       
    84 	TimezoneClient();
       
    85 	~TimezoneClient();
   105 	
    86 	
   106 private:
    87 private:
       
    88 	bool dstOn(int tzId);	
       
    89 	QList<int> getAllTimeZoneIds();
   107 	int getDstZoneOffset(int tzId);
    90 	int getDstZoneOffset(int tzId);
   108 	TMonth intToMonth(int month);
    91 	TMonth intToMonth(int month);
   109 	bool getUtcDstOffsetL(int &dstOffset, const CTzId &tzId);
    92 	bool getUtcDstOffsetL(int &dstOffset, const CTzId &tzId);
   110 	void getDstRulesL(
    93 	void getDstRulesL(
   111 			QDateTime &startTime, QDateTime &endTime,int timezoneId);
    94 			QDateTime &startTime, QDateTime &endTime,int timezoneId);
   118 
   101 
   119 private slots:
   102 private slots:
   120 	void populateCities();
   103 	void populateCities();
   121 	void eventMonitor(const XQSettingsKey& key, const QVariant& value);
   104 	void eventMonitor(const XQSettingsKey& key, const QVariant& value);
   122 
   105 
   123 public:
       
   124 	CEnvironmentChangeNotifier *mNotifier;
       
   125 
       
   126 private:
   106 private:
       
   107 	static TimezoneClient *mTimezoneClient;
       
   108 	static bool mReferenceCount;
       
   109 	
       
   110 private:
       
   111 	EnvironmentChangeNotifier *mNotifier;
   127 	CTzLocalizer *mTzLocalizer;
   112 	CTzLocalizer *mTzLocalizer;
   128 	QMap<QString, int> mAllCountries;
   113 	QMap<QString, int> mAllCountries;
   129 	QList<LocationInfo> mAllLocations;
   114 	QList<LocationInfo> mAllLocations;
   130 	QStandardItemModel *mWorldClockModel;
   115 	QPointer<QStandardItemModel> mWorldClockModel;
   131 	XQSettingsManager *mSettingsManager;
   116 	XQSettingsManager *mSettingsManager;
   132 	XQSettingsKey *mAutoTimeUpdateKey;
   117 	XQSettingsKey *mAutoTimeUpdateKey;
   133 
   118 
   134 	QList<int> mTimeZoneIds;
   119 	QList<int> mTimeZoneIds;
   135 
   120 
   136 //	bool mTimeUpdateOn;
       
   137 	int mCountryCount;
   121 	int mCountryCount;
   138 	int mAutoTimeUpdateValue;
   122 	int mAutoTimeUpdateValue;
   139 };
   123 };
   140 
   124 
   141 #endif		// __TIMEZONECLIENT_H__
   125 #endif		// __TIMEZONECLIENT_H__