|
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 #include "downloadevent.h" |
|
18 |
|
19 // private implementation for DownloadEvent |
|
20 class DownloadEventPrivate |
|
21 { |
|
22 DM_DECLARE_PUBLIC(DownloadEvent); |
|
23 public: |
|
24 DownloadEventPrivate(); |
|
25 ~DownloadEventPrivate(); |
|
26 DlEventAttributeMap *m_attrMap; // hold <key, value> pairs |
|
27 DEventType m_type; |
|
28 int m_id; |
|
29 }; |
|
30 |
|
31 DownloadEventPrivate::DownloadEventPrivate() |
|
32 { |
|
33 m_attrMap = 0; |
|
34 m_id = -1; |
|
35 } |
|
36 |
|
37 DownloadEventPrivate::~DownloadEventPrivate() |
|
38 { |
|
39 if(m_attrMap) |
|
40 { |
|
41 delete m_attrMap; |
|
42 m_attrMap = 0; |
|
43 } |
|
44 } |
|
45 |
|
46 DownloadEvent::DownloadEvent(DEventType type, DlEventAttributeMap* attrMap, int id) |
|
47 :QEvent((Type)type) |
|
48 { |
|
49 DM_INITIALIZE(DownloadEvent); |
|
50 priv->m_type = type; |
|
51 priv->m_attrMap = attrMap; |
|
52 priv->m_id = id; |
|
53 } |
|
54 |
|
55 DownloadEvent::~DownloadEvent() |
|
56 { |
|
57 DM_UNINITIALIZE(DownloadEvent); |
|
58 } |
|
59 |
|
60 Q_DECL_EXPORT QVariant DownloadEvent::getAttribute(DownloadEventAttribute attr) |
|
61 { |
|
62 DM_PRIVATE(DownloadEvent); |
|
63 bool exists = (priv->m_attrMap) && (priv->m_attrMap->contains(attr)); |
|
64 if(exists) |
|
65 { |
|
66 return priv->m_attrMap->value(attr); |
|
67 } |
|
68 else |
|
69 { |
|
70 return QVariant(); |
|
71 } |
|
72 } |
|
73 |
|
74 Q_DECL_EXPORT int DownloadEvent::getId() |
|
75 { |
|
76 DM_PRIVATE(DownloadEvent); |
|
77 // returns the download id |
|
78 return priv->m_id; |
|
79 } |
|
80 |
|
81 |
|
82 // private implementation for DownloadManagerEvent |
|
83 class DownloadManagerEventPrivate |
|
84 { |
|
85 DM_DECLARE_PUBLIC(DownloadManagerEvent); |
|
86 public: |
|
87 DownloadManagerEventPrivate(); |
|
88 ~DownloadManagerEventPrivate(); |
|
89 DlManagerEventAttributeMap *m_attrMap; |
|
90 DEventType type; |
|
91 }; |
|
92 |
|
93 DownloadManagerEventPrivate::DownloadManagerEventPrivate() |
|
94 { |
|
95 m_attrMap = 0; |
|
96 } |
|
97 |
|
98 DownloadManagerEventPrivate::~DownloadManagerEventPrivate() |
|
99 { |
|
100 if(m_attrMap) |
|
101 { |
|
102 delete m_attrMap; |
|
103 m_attrMap = 0; |
|
104 } |
|
105 } |
|
106 |
|
107 DownloadManagerEvent::DownloadManagerEvent(DEventType type, DlManagerEventAttributeMap* attrMap) |
|
108 :QEvent((Type)type) |
|
109 { |
|
110 DM_INITIALIZE(DownloadManagerEvent); |
|
111 priv->type = type; |
|
112 priv->m_attrMap = attrMap; |
|
113 } |
|
114 |
|
115 DownloadManagerEvent::~DownloadManagerEvent() |
|
116 { |
|
117 DM_UNINITIALIZE(DownloadManagerEvent); |
|
118 } |
|
119 |
|
120 QVariant DownloadManagerEvent::getAttribute(DownloadManagerEventAttribute attr) |
|
121 { |
|
122 DM_PRIVATE(DownloadManagerEvent); |
|
123 bool exists = priv->m_attrMap->contains(attr); |
|
124 if(exists) |
|
125 { |
|
126 return priv->m_attrMap->value(attr); |
|
127 } |
|
128 else |
|
129 { |
|
130 return QVariant(); |
|
131 } |
|
132 } |
|
133 |
|
134 |
|
135 |