|
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 // System includes |
|
19 #include <HbEffect> |
|
20 #include <HbNotificationDialog> |
|
21 |
|
22 // User includes |
|
23 #include "radioutil.h" |
|
24 #include "radiofrequencystrip.h" |
|
25 #include "radiostationcarousel.h" |
|
26 #include "radiofrequencyscanner.h" |
|
27 #include "radiologger.h" |
|
28 |
|
29 // Constants |
|
30 |
|
31 static RadioUtil* theInstance = 0; |
|
32 |
|
33 /*! |
|
34 * |
|
35 */ |
|
36 RadioUtil::RadioUtil() : |
|
37 mScanStatus( Scan::NotScanning ) |
|
38 { |
|
39 } |
|
40 |
|
41 /*! |
|
42 * |
|
43 */ |
|
44 RadioUtil::~RadioUtil() |
|
45 { |
|
46 } |
|
47 |
|
48 /*! |
|
49 * |
|
50 */ |
|
51 bool RadioUtil::addEffects( QEffectList list ) |
|
52 { |
|
53 bool allAvailable = true; |
|
54 QEffectList added; |
|
55 foreach ( EffectInfo info, list ) { |
|
56 if ( HbEffect::add( info.mItem, info.mPath, info.mEvent ) ) { |
|
57 added.append( info ); |
|
58 } else { |
|
59 allAvailable = false; |
|
60 break; |
|
61 } |
|
62 } |
|
63 |
|
64 if ( !allAvailable ) { |
|
65 foreach ( const EffectInfo& info, added ) { |
|
66 HbEffect::remove( info.mItem, info.mPath, info.mEvent ); |
|
67 } |
|
68 } |
|
69 |
|
70 return allAvailable; |
|
71 } |
|
72 |
|
73 |
|
74 /*! |
|
75 * |
|
76 */ |
|
77 RadioFrequencyStrip* RadioUtil::frequencyStrip() |
|
78 { |
|
79 return instance().mFrequencyStrip.data(); |
|
80 } |
|
81 |
|
82 /*! |
|
83 * |
|
84 */ |
|
85 RadioStationCarousel* RadioUtil::carousel() |
|
86 { |
|
87 return instance().mCarousel.data(); |
|
88 } |
|
89 |
|
90 /*! |
|
91 * |
|
92 */ |
|
93 bool RadioUtil::isScannerAlive() |
|
94 { |
|
95 RadioFrequencyScanner* scanner = instance().mScanner.data(); |
|
96 if ( scanner ) { |
|
97 return scanner->isAlive(); |
|
98 } |
|
99 return false; |
|
100 } |
|
101 |
|
102 /*! |
|
103 * |
|
104 */ |
|
105 Scan::Status RadioUtil::scanStatus() |
|
106 { |
|
107 return instance().mScanStatus; |
|
108 } |
|
109 |
|
110 /*! |
|
111 * |
|
112 */ |
|
113 void RadioUtil::setFrequencyStrip( RadioFrequencyStrip* frequencyStrip ) |
|
114 { |
|
115 instance().mFrequencyStrip = frequencyStrip; |
|
116 } |
|
117 |
|
118 /*! |
|
119 * |
|
120 */ |
|
121 void RadioUtil::setCarousel( RadioStationCarousel* carousel ) |
|
122 { |
|
123 instance().mCarousel = carousel; |
|
124 } |
|
125 |
|
126 /*! |
|
127 * |
|
128 */ |
|
129 void RadioUtil::setFrequencyScanner( RadioFrequencyScanner* scanner ) |
|
130 { |
|
131 instance().mScanner = scanner; |
|
132 } |
|
133 |
|
134 /*! |
|
135 * |
|
136 */ |
|
137 void RadioUtil::setScanStatus( Scan::Status status ) |
|
138 { |
|
139 instance().mScanStatus = status; |
|
140 } |
|
141 |
|
142 /*! |
|
143 * |
|
144 */ |
|
145 Scroll::Direction RadioUtil::scrollDirectionFromSkipMode( int skipMode ) |
|
146 { |
|
147 return ( skipMode == StationSkip::Next || skipMode == StationSkip::NextFavorite ) |
|
148 ? Scroll::Left : Scroll::Right; |
|
149 } |
|
150 |
|
151 /*! |
|
152 * |
|
153 */ |
|
154 Scroll::Direction RadioUtil::scrollDirection( int direction ) |
|
155 { |
|
156 return static_cast<Scroll::Direction>( direction ); |
|
157 } |
|
158 |
|
159 /*! |
|
160 * |
|
161 */ |
|
162 TuneReason::Reason RadioUtil::tuneReason( int tuneReason ) |
|
163 { |
|
164 return static_cast<TuneReason::Reason>( tuneReason ); |
|
165 } |
|
166 |
|
167 /*! |
|
168 * |
|
169 */ |
|
170 void RadioUtil::showDiscreetNote( const QString& text ) |
|
171 { |
|
172 RadioUtil& self = instance(); |
|
173 if ( !self.mNotificationDialog ) { |
|
174 self.mNotificationDialog = new HbNotificationDialog(); |
|
175 } |
|
176 self.mNotificationDialog.data()->setAttribute( Qt::WA_DeleteOnClose ); |
|
177 self.mNotificationDialog.data()->setTitle( text ); |
|
178 self.mNotificationDialog.data()->show(); |
|
179 } |
|
180 |
|
181 /*! |
|
182 * |
|
183 */ |
|
184 RadioUtil& RadioUtil::instance() |
|
185 { |
|
186 if ( !::theInstance ) { |
|
187 ::theInstance = new RadioUtil; |
|
188 } |
|
189 return *::theInstance; |
|
190 } |
|
191 |