|
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 #include <bacntf.h> |
|
31 |
|
32 // User includes |
|
33 #include "clockdatatypes.h" |
|
34 |
|
35 #ifdef TIMEZONECLIENT_LIBRARY |
|
36 #define TIMEZONECLIENT_EXPORT Q_DECL_EXPORT |
|
37 #else |
|
38 #define TIMEZONECLIENT_EXPORT Q_DECL_IMPORT |
|
39 #endif |
|
40 |
|
41 class CEnvironmentChangeNotifier; |
|
42 class QStandardItemModel; |
|
43 class CTzLocalizer; |
|
44 |
|
45 const int KInitialEvent = ( |
|
46 EChangesLocale | |
|
47 EChangesMidnightCrossover | |
|
48 EChangesThreadDeath | |
|
49 EChangesPowerStatus | |
|
50 EChangesSystemTime | |
|
51 EChangesFreeMemory | |
|
52 EChangesOutOfMemory); |
|
53 |
|
54 class TIMEZONECLIENT_EXPORT TimezoneClient : public QObject, public CBase |
|
55 { |
|
56 Q_OBJECT |
|
57 |
|
58 public: |
|
59 TimezoneClient(QObject* parent = 0); |
|
60 ~TimezoneClient(); |
|
61 |
|
62 public: |
|
63 QList<LocationInfo> getLocations(); |
|
64 bool getUtcDstOffsetL(int &dstOffset, |
|
65 const CTzId &tzId); |
|
66 LocationInfo getCurrentZoneInfoL(); |
|
67 void setAsCurrentLocationL(LocationInfo &location); |
|
68 bool isDSTOnL(int timezoneId); |
|
69 int getStandardOffset(int timezoneId); |
|
70 void getDstRulesL( |
|
71 QDateTime &startTime, QDateTime &endTime,int timezoneId); |
|
72 QList<LocationInfo> getSavedLocations(); |
|
73 void saveLocations(const QList<LocationInfo> &locationList); |
|
74 void getCountries(QMap<QString, int>& countries); |
|
75 void getCitiesForCountry( |
|
76 int id, QMap<QString, int>& cities); |
|
77 void getLocationInfo( |
|
78 int groupId, int cityIndex, LocationInfo& cityInfo); |
|
79 bool dstOn(int tzId); |
|
80 int getCityGroupIdByName(const QString& name); |
|
81 int getCityOffsetByNameAndId(const QString& name, int tzId); |
|
82 void setDateTime(QDateTime dateTime); |
|
83 void setTimeUpdateOn(bool timeUpdate = true); |
|
84 bool timeUpdateOn(); |
|
85 QStandardItemModel *locationSelectorModel(); |
|
86 void createWorldClockModel(); |
|
87 bool checkForDstChange(AlarmInfo& alarmInfo); |
|
88 QList<int> getAllTimeZoneIds(); |
|
89 QList<int> getAllTimeZoneOffsets(); |
|
90 QList<LocationInfo> getCountriesForUTCOffset(int utcOffset); |
|
91 LocationInfo addCity(int timeZoneId, QString &cityName, int cityGroupId); |
|
92 |
|
93 public: |
|
94 static int environmentCallback(TAny* obj); |
|
95 |
|
96 signals: |
|
97 void timechanged(); |
|
98 void listUpdated(); |
|
99 |
|
100 private: |
|
101 int getDstZoneOffset(int tzId); |
|
102 TMonth intToMonth(int month); |
|
103 |
|
104 private slots: |
|
105 void populateCities(); |
|
106 |
|
107 public: |
|
108 CEnvironmentChangeNotifier *mNotifier; |
|
109 |
|
110 private: |
|
111 CTzLocalizer *mTzLocalizer; |
|
112 QMap<QString, int> mAllCountries; |
|
113 QList<LocationInfo> mAllLocations; |
|
114 QStandardItemModel *mWorldClockModel; |
|
115 |
|
116 QList<int> mTimeZoneIds; |
|
117 |
|
118 bool mTimeUpdateOn; |
|
119 int mFetchCount; |
|
120 int mCountryCount; |
|
121 }; |
|
122 |
|
123 #endif // __TIMEZONECLIENT_H__ |
|
124 |
|
125 // End of file |