|
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 #include <QVariant> |
|
18 |
|
19 #include "irlogoprovider.h" |
|
20 #include "imgwrapper.h" |
|
21 #include "irqisdsclient.h" |
|
22 #include "irqisdsdatastructure.h" |
|
23 #include "iruidefines.h" |
|
24 |
|
25 |
|
26 IRLogoProvider::IRLogoProvider(IRQIsdsClient *aIsdsClient) : iIsdsClient(aIsdsClient) |
|
27 { |
|
28 |
|
29 } |
|
30 |
|
31 IRLogoProvider::~IRLogoProvider() |
|
32 { |
|
33 } |
|
34 |
|
35 void IRLogoProvider::getLogo(IRQPreset *aPreset) |
|
36 { |
|
37 imgWrapper wrapper; |
|
38 columnMap map; |
|
39 |
|
40 map.insert(channelId, QString::number(aPreset->presetId)); |
|
41 map.insert(imgUrl, aPreset->imgUrl); |
|
42 QList<QVariant*> *dataSet = wrapper.getImg(&map); |
|
43 if (dataSet) |
|
44 { |
|
45 //logo data has been saved into database |
|
46 if (dataSet->count() > 0) |
|
47 { |
|
48 QVariant *row = dataSet->at(0); |
|
49 QByteArray logo = row[sLogoGet].toByteArray(); |
|
50 if (logo.size() > 0) |
|
51 { |
|
52 emit logoData(logo); |
|
53 } |
|
54 else |
|
55 { |
|
56 //logo data hasn't been saved into database, call isds client to get it |
|
57 iIsdsClient->isdsLogoDownSendRequest(aPreset, 0, KBitmapSize, KBitmapSize); |
|
58 } |
|
59 } |
|
60 else |
|
61 { |
|
62 //logo data hasn't been saved into database, call isds client to get it |
|
63 iIsdsClient->isdsLogoDownSendRequest(aPreset, 0, KBitmapSize, KBitmapSize); |
|
64 } |
|
65 |
|
66 while (!dataSet->isEmpty()) |
|
67 { |
|
68 delete []dataSet->takeFirst(); |
|
69 } |
|
70 delete dataSet; |
|
71 } |
|
72 else |
|
73 { |
|
74 //logo data hasn't been saved into database, call isds client to get it |
|
75 iIsdsClient->isdsLogoDownSendRequest(aPreset, 0, KBitmapSize, KBitmapSize); |
|
76 } |
|
77 } |
|
78 |
|
79 void IRLogoProvider::activate(const QObject *aReceiver, const char *aFunc) |
|
80 { |
|
81 connect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset* )), |
|
82 this, SLOT(presetLogoDownload(IRQPreset* ))); |
|
83 connect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
|
84 this, SLOT(presetLogoDownloadError())); |
|
85 connect(this, SIGNAL(logoData(const QByteArray&)), aReceiver, aFunc); |
|
86 } |
|
87 |
|
88 void IRLogoProvider::deactivate() |
|
89 { |
|
90 disconnect(iIsdsClient, SIGNAL(presetLogoDownloaded(IRQPreset*)), |
|
91 this, SLOT(presetLogoDownload(IRQPreset* ))); |
|
92 disconnect(iIsdsClient, SIGNAL(presetLogoDownloadError()), |
|
93 this, SLOT(presetLogoDownloadError())); |
|
94 disconnect(SIGNAL(logoData(const QByteArray&))); |
|
95 } |
|
96 |
|
97 void IRLogoProvider::presetLogoDownload(IRQPreset* aPreset) |
|
98 { |
|
99 if (NULL == aPreset) |
|
100 { |
|
101 presetLogoDownloadError(); |
|
102 return; |
|
103 } |
|
104 |
|
105 //logo data is available, save it to database |
|
106 imgWrapper wrapper; |
|
107 columnMap rowData; |
|
108 rowData.insert(imgUrl, aPreset->imgUrl); |
|
109 |
|
110 logoMap logo; |
|
111 logo.insert(bLogo, QByteArray()); |
|
112 logo.insert(sLogo, aPreset->logoData); |
|
113 bool ret = wrapper.updateImg(&rowData, aPreset->presetId, &logo); |
|
114 |
|
115 emit logoData(aPreset->logoData); |
|
116 delete aPreset; |
|
117 } |
|
118 |
|
119 void IRLogoProvider::presetLogoDownloadError() |
|
120 { |
|
121 QByteArray data; |
|
122 emit logoData(data); |
|
123 } |