|
1 /** |
|
2 This file is part of CWRT package ** |
|
3 |
|
4 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** |
|
5 |
|
6 This program is free software: you can redistribute it and/or modify |
|
7 it under the terms of the GNU (Lesser) General Public License as |
|
8 published by the Free Software Foundation, version 2.1 of the License. |
|
9 This program is distributed in the hope that it will be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 (Lesser) General Public License for more details. You should have |
|
13 received a copy of the GNU (Lesser) General Public License along |
|
14 with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 */ |
|
16 |
|
17 #ifndef DOWNLOAD_INFO_H |
|
18 #define DOWNLOAD_INFO_H |
|
19 |
|
20 #include "dmpimpl.h" |
|
21 #include "dmcommon.h" |
|
22 #include <QString> |
|
23 #include <QVector> |
|
24 #include <QVariant> |
|
25 |
|
26 // forward declarations |
|
27 class QSettings; |
|
28 class DownloadInfoPrivate; |
|
29 |
|
30 // class declaration |
|
31 class DownloadInfo |
|
32 { |
|
33 DM_DECLARE_PRIVATE(DownloadInfo); // private implementation |
|
34 public: |
|
35 /* |
|
36 InfoKey - key enumerations for the download info |
|
37 */ |
|
38 enum Key |
|
39 { |
|
40 EUrl = 0, // 0 http://xyz.com/a.mp3 |
|
41 EFileName, // 1 a.mp3 |
|
42 ETempPath, // 2 ./com.nokia.browser/ |
|
43 EFinalPath, // 3 /home/downloads/ |
|
44 ETempFullPath, // 4 ./com.nokia.browser/a(1).mp3 |
|
45 ETotalSize, // 5 xxx bytes <int> |
|
46 EDlState, // 6 int |
|
47 EContentType, // 7 audio/mp3 |
|
48 EETag, // 8 ETag |
|
49 EChildIdList, // 9 list of child ids |
|
50 EType, // 10 sequential or parallel |
|
51 EScope, // 11 client side or background download |
|
52 EPriority // 12 priority of the download |
|
53 }; |
|
54 |
|
55 DownloadInfo(const QString& aClientName); |
|
56 ~DownloadInfo(); |
|
57 |
|
58 public: |
|
59 /* |
|
60 Sets a string value. |
|
61 Returns : 0 on success, non zero on error |
|
62 */ |
|
63 int setValue(int aDlId, Key aKeyStr, const QString& aStrValue, int aParentId = INVALID_DL_ID); |
|
64 |
|
65 /* |
|
66 Sets a string value. |
|
67 Returns : 0 on success, non zero on error |
|
68 */ |
|
69 int setValue(int aDlId, Key aKeyStr, long aLongValue, int aParentId = INVALID_DL_ID); |
|
70 |
|
71 /* |
|
72 Sets a string value. |
|
73 Returns : 0 on success, non zero on error |
|
74 */ |
|
75 int setValueForChild(int aDlId, Key aKeyStr, const QString& aStrValue, int aChildId = INVALID_DL_ID); |
|
76 |
|
77 /* |
|
78 Sets an int value. |
|
79 Returns : 0 on success, non zero on error |
|
80 */ |
|
81 int setValueForChild(int aDlId, Key aKeyInt, long aLongValue, int aChildId = INVALID_DL_ID); |
|
82 |
|
83 /* |
|
84 Sets the mediaObject list |
|
85 Returns : 0 on success, non zero on error |
|
86 */ |
|
87 int setValue(int aDlId, Key aKey, const QList<QVariant>& aChildIds); |
|
88 |
|
89 /* |
|
90 Updates(serializes) the info with all set values at once. |
|
91 Returns : 0 on success, non zero on error |
|
92 */ |
|
93 int update(); |
|
94 |
|
95 /* |
|
96 Retrieves the string value |
|
97 Returns : 0 on success, non zero on error |
|
98 */ |
|
99 int getValue(int aDlId, Key aKeyStr, QString& aStrValue, int aParentId = INVALID_DL_ID); |
|
100 |
|
101 /* |
|
102 Retrieves the int value |
|
103 Returns : 0 on success, non zero on error |
|
104 */ |
|
105 int getValue(int aDlId, Key aKeyInt, long& aLongValue, int aParentId = INVALID_DL_ID); |
|
106 |
|
107 /* |
|
108 Retrieves the string value |
|
109 Returns : 0 on success, non zero on error |
|
110 */ |
|
111 int getValueForChild(int aDlId, Key aKeyStr, QString& aStrValue, int aChildId = INVALID_DL_ID); |
|
112 |
|
113 /* |
|
114 Retrieves the int value |
|
115 Returns : 0 on success, non zero on error |
|
116 */ |
|
117 int getValueForChild(int aDlId, Key aKeyInt, long& aLongValue, int aChildId = INVALID_DL_ID); |
|
118 |
|
119 /* |
|
120 Retrieves the mediaObject list |
|
121 Returns : 0 on success, non zero on error |
|
122 */ |
|
123 int getValue(int aParentId, Key aKey, QList<QVariant>& aChildIds); |
|
124 |
|
125 /* |
|
126 Deletes the download info of a particular download represented by aDlId. |
|
127 Returns : 0 on success, non zero on error |
|
128 */ |
|
129 int remove(int aDlId, int aParentId = INVALID_DL_ID); |
|
130 |
|
131 /* |
|
132 Returns all download ids in a vector |
|
133 */ |
|
134 static QVector<int> getAllDownloads(const QString& aClientName); |
|
135 |
|
136 private: |
|
137 |
|
138 /* |
|
139 Helper function to generate a string key combining dlId and the InfoKey |
|
140 */ |
|
141 QString genStrKey(int aDlId, Key aKey); |
|
142 |
|
143 /* |
|
144 Helper function to generate a string key combining parentId, childId and the InfoKey |
|
145 */ |
|
146 QString genStrKey(int aParentId, int aChildId, Key aKey); |
|
147 }; |
|
148 |
|
149 #endif |