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 #ifndef RADIOSTATIONINFO_P_H_ |
|
19 #define RADIOSTATIONINFO_P_H_ |
|
20 |
|
21 // System includes |
|
22 #include <QSharedData> |
|
23 #include <QTime> |
|
24 |
|
25 // User includes |
|
26 #include "radiostation.h" |
|
27 #include "radiostationif.h" |
|
28 |
|
29 // Class declaration |
|
30 class RadioStationPrivate : public QSharedData |
|
31 , public RadioStationIf |
|
32 { |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Flags to indicate various on/off type information of the radio station |
|
37 */ |
|
38 enum StationInfoFlag |
|
39 { |
|
40 RenamedByUser = 1 << 0, |
|
41 StationSendsRds = 1 << 1, |
|
42 CallSignCheckDone = 1 << 2 |
|
43 }; |
|
44 Q_DECLARE_FLAGS( StationInfo, StationInfoFlag ) |
|
45 |
|
46 explicit RadioStationPrivate( int presetIndex = RadioStation::Invalid, uint frequency = 0 ); |
|
47 explicit RadioStationPrivate( const RadioStationPrivate& other ); |
|
48 |
|
49 virtual ~RadioStationPrivate(); |
|
50 |
|
51 void init( int presetIndex, uint frequency = 0 ); |
|
52 |
|
53 // from base class RadioStationIf |
|
54 |
|
55 int presetIndex() const; |
|
56 void setPresetIndex( int presetIndex ); |
|
57 uint frequency() const; |
|
58 void setFrequency( uint frequency ); |
|
59 QString name() const; |
|
60 void setName( QString name ); |
|
61 bool isRenamedByUser() const; |
|
62 void setRenamedByUser( bool renamed ); |
|
63 int genre() const; |
|
64 void setGenre( int genre ); |
|
65 QString url() const; |
|
66 void setUrl( QString url ); |
|
67 int piCode() const; |
|
68 void setPiCode( int piCode ); |
|
69 bool isFavorite() const; |
|
70 void setFavorite( bool favorite ); |
|
71 bool isLocalStation() const; |
|
72 void setLocalStation( bool localStation ); |
|
73 bool hasStationSentRds() const; |
|
74 void setStationHasSentRds( bool hasSentRds ); |
|
75 |
|
76 // New functions |
|
77 |
|
78 bool isCallSignCheckDone() const; |
|
79 void setCallSignCheckDone( bool checkDone ); |
|
80 |
|
81 public: // data |
|
82 |
|
83 // ======================================================================== |
|
84 // Persistent data. Saved to Central repository |
|
85 // ======================================================================== |
|
86 |
|
87 /** |
|
88 * Station index in the Preset Utility. |
|
89 * Negative values signify an invalid RadioStation that has not and will not be saved. |
|
90 * Initialized to -100 by default to indicate and invalid station. |
|
91 */ |
|
92 int mPresetIndex; |
|
93 |
|
94 /** |
|
95 * Station frequency. The most important bit of information about a radio station. |
|
96 * Is checked to be non-null in the isValid() function |
|
97 */ |
|
98 uint mFrequency; |
|
99 |
|
100 /** |
|
101 * Station name. Contains a name that is set in one of the following ways: |
|
102 * 1) Received through RDS as the stations PS name and station does not use dynamic PS |
|
103 * 2) Entered by the user. In this case the mRenamedByUser flag will be set and the name |
|
104 * cannot be changed until the user removes the renaming. |
|
105 * 3) Callsign calculated from the PI code can be set as the station name if the station |
|
106 * does not send RDS information and the current region is America |
|
107 */ |
|
108 QString mName; |
|
109 |
|
110 /** |
|
111 * Station genre received through RDS |
|
112 */ |
|
113 int mGenre; |
|
114 |
|
115 /** |
|
116 * Station URL. Can be e.g. a web address to the radio stations homepage |
|
117 */ |
|
118 QString mUrl; |
|
119 |
|
120 /** |
|
121 * Stations PI code. Only used in the America region to calculate the Callsign if station |
|
122 * does not use RDS to broadcast PS name |
|
123 */ |
|
124 int mPiCode; |
|
125 |
|
126 /** |
|
127 * Station type. Used by the application mainly to filter out certain stations depending |
|
128 * on the users preference to see all locally audible stations or all favorite stations. |
|
129 * Can have any combination of the following flags: |
|
130 * - Favorite The station is a favorite of the user. |
|
131 * - LocalStation The station was found in the last scan and should be audible in the current location |
|
132 * - Temporary Special flag to mark one RadioStation instance that is used to store |
|
133 * information of a manually tuned frequency that has not been saved by the user. |
|
134 */ |
|
135 RadioStation::Type mType; // Station type, favorite or local station or neither |
|
136 |
|
137 // ======================================================================== |
|
138 // Non-persistent data. Only kept in memory |
|
139 // ======================================================================== |
|
140 |
|
141 /** |
|
142 * Radio station PS name type. Some radio stations use the PS name broadcasting against the |
|
143 * official RDS standard rules to broadcast advertisements. The ads are sent by changing the |
|
144 * PS name in relatively rapid succession. The RDS standard specifies that a station should |
|
145 * only use the PS name to broadcast a static station name. |
|
146 * The FM Radio application attempts to determine if the station uses dynamic PS or not and |
|
147 * stores the information here. Stations with a dynamic PS are treated differently in the UI and the |
|
148 * name is never saved to Central Repository because it would only contain a part of an advertisement. |
|
149 * Can have one of the following values: |
|
150 * - Unknown Dynamic PS check has not been done so it is unknown if the station uses dynamic PS |
|
151 * - Dynamic The check has been done and station has been found to use dynamic PS |
|
152 * - Static The check has been done and the station has been found not to use dynamic PS |
|
153 */ |
|
154 RadioStation::PsType mPsType; |
|
155 |
|
156 /** |
|
157 * Stores the Radio Text received through RDS. Can be either normal Radio Text or Radio Text Plus |
|
158 * where the tags have been parsed. Parsed Radio Text Plus is stored in HTML form, the normal Radio Text |
|
159 * is stored as plain text. |
|
160 */ |
|
161 QString mRadioText; |
|
162 |
|
163 /** |
|
164 * Holder for the ads sent by using dynamic PS. Holds one part of the ad at a time. |
|
165 */ |
|
166 QString mDynamicPsText; |
|
167 |
|
168 /** |
|
169 * Internal book keeping used to determine which member variables have been changed since last save |
|
170 * or reset. Used to decide which signals should be sent by the RadioStationModel when the station is saved. |
|
171 */ |
|
172 RadioStation::Change mChangeFlags; |
|
173 |
|
174 /** |
|
175 * Time of the last PS name change. Used to check if the station changes its PS name too often. |
|
176 * In bad RDS coverage a station using dynamic PS might be incorrectly determined to use static PS. |
|
177 * This is a corrective effort to change that decision if the name changes too often. |
|
178 */ |
|
179 QTime mLastPsNameChangeTime; |
|
180 |
|
181 /** |
|
182 * Flags to indicate various on/off type information of the radio station |
|
183 */ |
|
184 StationInfo mStationInfo; |
|
185 |
|
186 }; |
|
187 |
|
188 Q_DECLARE_OPERATORS_FOR_FLAGS( RadioStationPrivate::StationInfo ) |
|
189 |
|
190 #endif // RADIOSTATIONINFO_P_H_ |
|