13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "irqisdsclientimpl.h" |
18 #include "irqisdsclientimpl_symbian.h" |
19 |
19 |
|
20 QMutex IRQIsdsClient::mMutex; |
|
21 int IRQIsdsClient::mRef = 0; |
|
22 IRQIsdsClient *IRQIsdsClient::mInstance = NULL; |
|
23 |
20 //Static function |
24 //Static function |
21 //to get an instance of the IRQIsdsClient |
25 //to get an instance of the IRQIsdsClient |
22 //@return IRQIsdsClient * |
26 //@return IRQIsdsClient * |
23 EXPORT_C IRQIsdsClient *IRQIsdsClient::openInstance() |
27 IRQIsdsClient *IRQIsdsClient::openInstance() |
24 { |
28 { |
25 IRQIsdsClient* irqisdsclient = |
29 mMutex.lock(); |
26 reinterpret_cast<IRQIsdsClient*> (Dll::Tls()); |
30 if (NULL == mInstance) |
27 |
|
28 if (NULL == irqisdsclient) |
|
29 { |
31 { |
30 irqisdsclient = new IRQIsdsClient(); |
32 mInstance = new IRQIsdsClient(); |
31 int result = 0; |
|
32 result = Dll::SetTls(irqisdsclient); |
|
33 |
|
34 if( KErrNone != result ) |
|
35 { |
|
36 delete irqisdsclient; |
|
37 return NULL; |
|
38 } |
|
39 |
|
40 irqisdsclient->iSingletonInstances = 1; |
|
41 } |
33 } |
42 else |
34 if (NULL != mInstance) |
43 irqisdsclient->iSingletonInstances++; |
35 { |
44 |
36 mInstance->mRef++; |
45 return irqisdsclient; |
37 } |
|
38 |
|
39 mMutex.unlock(); |
|
40 return mInstance; |
46 } |
41 } |
47 |
42 |
48 // |
43 // |
49 //close the instance. |
44 //close the instance. |
50 //@return void |
45 //@return void |
51 EXPORT_C void IRQIsdsClient::closeInstance() |
46 void IRQIsdsClient::closeInstance() |
52 { |
47 { |
53 iSingletonInstances--; |
48 mMutex.lock(); |
54 |
49 mRef--; |
55 if (0 == iSingletonInstances) |
50 |
|
51 if (0 == mRef) |
56 { |
52 { |
57 Dll::SetTls(NULL); |
53 mInstance = NULL; |
58 delete this; |
54 delete this; |
59 } |
55 } |
60 |
56 |
|
57 mMutex.unlock(); |
61 return; |
58 return; |
62 } |
59 } |
63 |
60 |
64 //Issue a search request to the isds server |
61 //Issue a search request to the isds server |
65 //@param QString, the requested search string |
62 //@param QString, the requested search string |
66 // |
63 // |
67 EXPORT_C void IRQIsdsClient::isdsSearchRequest(const QString& aIsdsSearchString) |
64 void IRQIsdsClient::isdsSearchRequest(const QString& aIsdsSearchString) |
68 { |
65 { |
69 iImpl->isdsSearchRequestImpl(aIsdsSearchString); |
66 d_ptr->isdsSearchRequestImpl(aIsdsSearchString); |
70 } |
67 } |
71 |
68 |
72 //Send the category request by the category type |
69 //Send the category request by the category type |
73 // |
70 // |
74 EXPORT_C void IRQIsdsClient::isdsCategoryRequest( |
71 void IRQIsdsClient::isdsCategoryRequest( |
75 IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType, bool& aCache) |
72 IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType, bool& aCache) |
76 { |
73 { |
77 iImpl->isdsCategoryRequestImpl(aIDType, aCache); |
74 d_ptr->isdsCategoryRequestImpl(aIDType, aCache); |
78 } |
75 } |
79 |
76 |
80 EXPORT_C bool IRQIsdsClient::isdsIsCategoryCached(IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType) |
77 bool IRQIsdsClient::isdsIsCategoryCached(IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType) |
81 { |
78 { |
82 return iImpl->isdsIsCategoryCachedImpl(aIDType); |
79 return d_ptr->isdsIsCategoryCachedImpl(aIDType); |
83 } |
80 } |
84 |
81 |
85 EXPORT_C bool IRQIsdsClient::isdsIsChannelCached(int aIndex) |
82 bool IRQIsdsClient::isdsIsChannelCached(int aIndex) |
86 { |
83 { |
87 return iImpl->isdsIsChannelCachedImpl(aIndex); |
84 return d_ptr->isdsIsChannelCachedImpl(aIndex); |
88 } |
85 } |
89 //Send the channels request by the channel index in the specify category |
86 //Send the channels request by the channel index in the specify category |
90 // |
87 // |
91 EXPORT_C void IRQIsdsClient::isdsChannelRequest(int aIndex, bool& aCache) |
88 void IRQIsdsClient::isdsChannelRequest(int aIndex, bool& aCache) |
92 { |
89 { |
93 |
90 |
94 if( 0 > aIndex ) |
91 if( 0 > aIndex ) |
95 return; |
92 return; |
96 |
93 |
97 /* if the isds has the banner, the index can't be 0 , or it will crash*/ |
94 /* if the isds has the banner, the index can't be 0 , or it will crash*/ |
98 if( isdsIsCategoryBanner() && 0 == aIndex ) |
95 if( isdsIsCategoryBanner() && 0 == aIndex ) |
99 return; |
96 return; |
100 |
97 |
101 iImpl->isdsChannelRequestImpl(aIndex, aCache); |
98 d_ptr->isdsChannelRequestImpl(aIndex, aCache); |
102 } |
99 } |
103 |
100 |
104 //issue a listen request to the isds client |
101 //issue a listen request to the isds client |
105 //@param int,bool, the current index of channel, the history tag |
102 //@param int,bool, the current index of channel, the history tag |
106 // |
103 // |
107 EXPORT_C void IRQIsdsClient::isdsListenRequest(int aCurrentIndex, |
104 void IRQIsdsClient::isdsListenRequest(int aCurrentIndex, |
108 bool aHistoryBool) |
105 bool aHistoryBool) |
109 { |
106 { |
110 if (0 > aCurrentIndex) |
107 if (0 > aCurrentIndex) |
111 return; |
108 return; |
112 |
109 |
113 /* if the isds has the banner, the index can't be 0 , or it will crash*/ |
110 /* if the isds has the banner, the index can't be 0 , or it will crash*/ |
114 if (isdsIsChannelBanner() && 0 == aCurrentIndex) |
111 if (isdsIsChannelBanner() && 0 == aCurrentIndex) |
115 return; |
112 return; |
116 |
113 |
117 iImpl->isdsListenRequestImpl(aCurrentIndex,aHistoryBool); |
114 d_ptr->isdsListenRequestImpl(aCurrentIndex,aHistoryBool); |
118 } |
115 } |
119 |
116 |
120 //to syncronize presets |
117 //to syncronize presets |
121 //@param int,QString, the preset id and the last modified tag for the preset |
118 //@param int,QString, the preset id and the last modified tag for the preset |
122 // |
119 // |
123 EXPORT_C int IRQIsdsClient::isdsSyncPreset(int aPresetId, |
120 int IRQIsdsClient::isdsSyncPreset(int aPresetId, |
124 const QString& aIfModifySince, IRQFavoritesDB *aFavPresets) |
121 const QString& aIfModifySince, IRQFavoritesDB *aFavPresets) |
125 { |
122 { |
126 TInt result = 0; |
123 TInt result = 0; |
127 result = iImpl->isdsSyncPresetImpl(aPresetId, aIfModifySince, aFavPresets); |
124 result = d_ptr->isdsSyncPresetImpl(aPresetId, aIfModifySince, aFavPresets); |
128 return result; |
125 return result; |
129 } |
126 } |
130 |
127 |
131 //Cacel the request sent by the UI. |
128 //Cacel the request sent by the UI. |
132 //@param None |
129 //@param None |
133 // |
130 // |
134 EXPORT_C void IRQIsdsClient::isdsCancelRequest() |
131 void IRQIsdsClient::isdsCancelRequest() |
135 { |
132 { |
136 iImpl->isdsCancelRequestImpl(); |
133 d_ptr->isdsCancelRequestImpl(); |
137 } |
134 } |
138 |
135 |
139 |
136 |
140 |
137 |
141 //to see wether category view has a banner. |
138 //to see wether category view has a banner. |
142 //@param None |
139 //@param None |
143 // |
140 // |
144 EXPORT_C bool IRQIsdsClient::isdsIsCategoryBanner() |
141 bool IRQIsdsClient::isdsIsCategoryBanner() |
145 { |
142 { |
146 return iImpl->isdsIsCategoryBannerImpl(); |
143 return d_ptr->isdsIsCategoryBannerImpl(); |
147 } |
144 } |
148 |
145 |
149 // |
146 // |
150 //to see wether channel view has a banner. |
147 //to see wether channel view has a banner. |
151 //@param None |
148 //@param None |
152 EXPORT_C bool IRQIsdsClient::isdsIsChannelBanner() |
149 bool IRQIsdsClient::isdsIsChannelBanner() |
153 { |
150 { |
154 return iImpl->isdsIsChannelBannerImpl(); |
151 return d_ptr->isdsIsChannelBannerImpl(); |
155 } |
152 } |
156 |
153 |
157 //the api is called from the UI(nowplaying view) to download logo. |
154 //the api is called from the UI(nowplaying view) to download logo. |
158 //@param None |
155 //@param None |
159 // |
156 // |
160 EXPORT_C void IRQIsdsClient::isdsLogoDownSendRequest(IRQPreset* aPreset, |
157 void IRQIsdsClient::isdsLogoDownSendRequest(IRQPreset* aPreset, |
161 int aNPVReq, int aXValue, int aYValue) |
158 int aNPVReq, int aXValue, int aYValue) |
162 { |
159 { |
163 iImpl->isdsLogoDownSendRequestImpl(aPreset, aNPVReq, aXValue, aYValue); |
160 d_ptr->isdsLogoDownSendRequestImpl(aPreset, aNPVReq, aXValue, aYValue); |
164 } |
161 } |
165 |
162 |
166 EXPORT_C bool IRQIsdsClient::isdsIsLogoCached(IRQPreset* aPreset, int aXValue, int aYValue) |
163 bool IRQIsdsClient::isdsIsLogoCached(IRQPreset* aPreset, int aXValue, int aYValue) |
167 { |
164 { |
168 return iImpl->isdsIsLogoCachedImpl(aPreset, aXValue, aYValue); |
165 return d_ptr->isdsIsLogoCachedImpl(aPreset, aXValue, aYValue); |
169 } |
166 } |
170 // |
167 // |
171 //the api is called to cancel the current transaction |
168 //the api is called to cancel the current transaction |
172 //@param None |
169 //@param None |
173 // |
170 // |
174 EXPORT_C void IRQIsdsClient::isdsLogoDownCancelTransaction() |
171 void IRQIsdsClient::isdsLogoDownCancelTransaction() |
175 { |
172 { |
176 iImpl->isdsLogoDownCancelTransactionImpl(); |
173 d_ptr->isdsLogoDownCancelTransactionImpl(); |
177 } |
174 } |
178 |
175 |
179 // |
176 // |
180 //To know the status of downloading logo |
177 //To know the status of downloading logo |
181 EXPORT_C bool IRQIsdsClient::isdsLogoDownIsRunning() const |
178 bool IRQIsdsClient::isdsLogoDownIsRunning() const |
182 { |
179 { |
183 return iImpl->isdsLogoDownIsRunningImpl(); |
180 return d_ptr->isdsLogoDownIsRunningImpl(); |
184 } |
181 } |
185 |
182 |
186 //takes the url as a parameter and returns the logo data which is in cache |
183 //takes the url as a parameter and returns the logo data which is in cache |
187 //this API is called form the search results for to display logo on the view |
184 //this API is called form the search results for to display logo on the view |
188 //@param QString: the url of the img, int: the status for getting |
185 //@param QString: the url of the img, int: the status for getting |
189 // |
186 // |
190 EXPORT_C void IRQIsdsClient::isdsLogoDownCheckCacheLogo(const QString& aURL, |
187 void IRQIsdsClient::isdsLogoDownCheckCacheLogo(const QString& aURL, |
191 int& aStatus) |
188 int& aStatus) |
192 { |
189 { |
193 iImpl->isdsLogoDownCheckCacheLogoImpl(aURL, aStatus); |
190 d_ptr->isdsLogoDownCheckCacheLogoImpl(aURL, aStatus); |
194 } |
191 } |
195 |
192 |
196 //get the cache logo from the logodown engine. The "send" is the point from a logodown engine |
193 //get the cache logo from the logodown engine. The "send" is the point from a logodown engine |
197 //@param None |
194 //@param None |
198 // |
195 // |
199 EXPORT_C TDesC8& IRQIsdsClient::isdsLogoDownSendCacheLogo() |
196 TDesC8& IRQIsdsClient::isdsLogoDownSendCacheLogo() |
200 { |
197 { |
201 return iImpl->isdsLogoDownSendCacheLogoImpl(); |
198 return d_ptr->isdsLogoDownSendCacheLogoImpl(); |
202 } |
199 } |
203 |
200 |
204 EXPORT_C void IRQIsdsClient::isdsPostLog(const QString& aFileName) |
201 void IRQIsdsClient::isdsPostLog(const QString& aFileName) |
205 { |
202 { |
206 iImpl->isdsPostLogImpl(aFileName); |
203 d_ptr->isdsPostLogImpl(aFileName); |
207 } |
204 } |
208 |
205 |
209 EXPORT_C void IRQIsdsClient::isdsGetIRID() |
206 void IRQIsdsClient::isdsGetIRID() |
210 { |
207 { |
211 iImpl->isdsGetIRIDImpl(); |
208 d_ptr->isdsGetIRIDImpl(); |
212 } |
209 } |
213 |
210 |
214 EXPORT_C void IRQIsdsClient::isdsGetBrowseBanner(QString& aBannerUrl, QString& aClickThroughUrl) |
211 void IRQIsdsClient::isdsGetBrowseBanner(QString& aBannerUrl, QString& aClickThroughUrl) |
215 { |
212 { |
216 iImpl->isdsGetBrowseBannerImpl(aBannerUrl, aClickThroughUrl); |
213 d_ptr->isdsGetBrowseBannerImpl(aBannerUrl, aClickThroughUrl); |
217 } |
214 } |
218 |
215 |
219 EXPORT_C void IRQIsdsClient::isdsMultSearch(QString aGenreID, QString aCountryID, QString aLanguageID, QString aSearchText) |
216 void IRQIsdsClient::isdsMultSearch(QString aGenreID, QString aCountryID, QString aLanguageID, QString aSearchText) |
220 { |
217 { |
221 iImpl->isdsMultSearchImpl(aGenreID, aCountryID, aLanguageID, aSearchText); |
218 d_ptr->isdsMultSearchImpl(aGenreID, aCountryID, aLanguageID, aSearchText); |
222 } |
219 } |
223 |
220 |
224 EXPORT_C bool IRQIsdsClient::isdsIsConstructSucceed() const |
221 bool IRQIsdsClient::isdsIsConstructSucceed() const |
225 { |
222 { |
226 return iImpl->isdsIsConstructSucceed(); |
223 return d_ptr->isdsIsConstructSucceed(); |
227 } |
224 } |
228 |
225 |
229 /************************ private functions **************************/ |
226 /************************ private functions **************************/ |
230 //the c++ default destruction function |
227 //the c++ default destruction function |
231 // private |
228 // private |
232 IRQIsdsClient::~IRQIsdsClient() |
229 IRQIsdsClient::~IRQIsdsClient() |
233 { |
230 { |
234 delete iImpl; |
231 delete d_ptr; |
235 } |
232 } |
236 |
233 |
237 |
234 |
238 IRQIsdsClient::IRQIsdsClient() |
235 IRQIsdsClient::IRQIsdsClient() |
239 { |
236 { |
240 iImpl = new IRQIsdsClientImpl(); |
237 d_ptr = new IRQIsdsClientImpl(this); |
241 Q_ASSERT(iImpl); |
238 Q_ASSERT(d_ptr); |
242 |
239 } |
243 connect(iImpl, SIGNAL(categoryItemsChangedImpl(QList<IRQBrowseCategoryItem *> *)), |
|
244 this, SIGNAL(categoryItemsChanged(QList<IRQBrowseCategoryItem *> *))); |
|
245 |
|
246 connect(iImpl, SIGNAL(channelItemsChangedImpl(QList<IRQChannelItem *> *)), |
|
247 this, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *))); |
|
248 |
|
249 connect(iImpl, SIGNAL(operationExceptionImpl(IRQError)), |
|
250 this, SIGNAL(operationException(IRQError))); |
|
251 |
|
252 |
|
253 connect(iImpl, SIGNAL(presetResponseImpl(IRQPreset *)), |
|
254 this, SIGNAL(presetResponse(IRQPreset *))); |
|
255 |
|
256 |
|
257 connect(iImpl, SIGNAL(syncPresetResultImpl(IRQSycPresetStatus, IRQPreset*)), |
|
258 this, SIGNAL(syncPresetResult(IRQSycPresetStatus, IRQPreset*))); |
|
259 |
|
260 |
|
261 connect(iImpl, SIGNAL(presetLogoDownloadedImpl(IRQPreset*)), |
|
262 this, SIGNAL(presetLogoDownloaded(IRQPreset*))); |
|
263 |
|
264 |
|
265 connect(iImpl, SIGNAL(presetLogoDownloadErrorImpl()), |
|
266 this, SIGNAL(presetLogoDownloadError())); |
|
267 |
|
268 |
|
269 connect(iImpl, SIGNAL(iridReceivedImpl(QString)), |
|
270 this, SIGNAL(iridReceived(QString))); |
|
271 |
|
272 } |
|
273 |
|
274 |
240 |
275 |
|