|
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: VideoThumbnailFetcher class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __VIDEOTHUMBNAILDATAFETCHER_H__ |
|
19 #define __VIDEOTHUMBNAILDATAFETCHER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <qobject.h> |
|
23 #include <qicon.h> |
|
24 #include <qlist.h> |
|
25 #include <qhash.h> |
|
26 #include <qmap.h> |
|
27 #include <qpixmap.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 |
|
32 class ThumbnailFetchData |
|
33 { |
|
34 public: |
|
35 QString mFileName; |
|
36 int mPriority; |
|
37 void *mInternal; |
|
38 }; |
|
39 |
|
40 class VideoThumbnailFetcher : public QObject |
|
41 { |
|
42 /** |
|
43 * defined to be able to use signals and slots |
|
44 */ |
|
45 Q_OBJECT |
|
46 |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Default constructor |
|
51 */ |
|
52 VideoThumbnailFetcher(); |
|
53 |
|
54 /** |
|
55 * Desctructor |
|
56 */ |
|
57 ~VideoThumbnailFetcher(); |
|
58 |
|
59 /** |
|
60 * Adds thumbnail fetch to the fetch list. pauseFetching should be called |
|
61 * before adding fetches for performance reasons. After all fetches have |
|
62 * been added, call continueFetching to start the fetch process which passes |
|
63 * the internal data to thumbnail manager. Signal thumbnailReady is emitted |
|
64 * when fetch is complete. |
|
65 * |
|
66 * @param fileName path to the media. |
|
67 * @param internal data identifying the media. |
|
68 * @param priority priority for the fetch. |
|
69 * |
|
70 */ |
|
71 void addFetch(const QString fileName, void *internal, int priority); |
|
72 |
|
73 /** |
|
74 * Empties fetch list. This does not cancel the possible ongoing fetch on |
|
75 * thumbnail manager side. |
|
76 * |
|
77 */ |
|
78 void cancelFetches(); |
|
79 |
|
80 /** |
|
81 * Returns count of the fetches. |
|
82 * |
|
83 */ |
|
84 int fetchCount(); |
|
85 |
|
86 /** |
|
87 * Pauses thumbnail fetching process. This does not pause the possible |
|
88 * ongoing fetch on thumbnail manager side. |
|
89 * |
|
90 */ |
|
91 void pauseFetching(); |
|
92 |
|
93 /** |
|
94 * Continues the fetching process. All fetches added with addFetch are |
|
95 * started without create thumbnail flag. If there's not any of those, |
|
96 * starts creating thumbnails for fetches that have no thumbnail yet. |
|
97 * Signal allThumbnailsFetched is emitted if there's nothing to do. |
|
98 * |
|
99 */ |
|
100 void continueFetching(); |
|
101 |
|
102 /** |
|
103 * Enables or disables the thumbnail creation for videos that do |
|
104 * not have thumbnail already in the database. |
|
105 * |
|
106 * @param enable true enables thumbnail creation, false disables. |
|
107 * |
|
108 */ |
|
109 void enableThumbnailCreation(bool enable); |
|
110 |
|
111 // Test helper methods |
|
112 public: |
|
113 |
|
114 void emitThumbnailReady(QPixmap pixmap, void *internal, int error); |
|
115 |
|
116 void emitAllThumbnailsFetched(); |
|
117 |
|
118 signals: |
|
119 |
|
120 /** |
|
121 * Signaled after signal from thumbnail manager has been processed and |
|
122 * thumbnail fetch process is complete. |
|
123 * |
|
124 * @param tnData thumbnail |
|
125 * @param internal internal data to identify the request |
|
126 * @param error possible error code from thumbnail manager ( 0 == ok ) |
|
127 * |
|
128 */ |
|
129 void thumbnailReady(QPixmap tnData, void *internal, int error); |
|
130 |
|
131 /** |
|
132 * Signaled when all the fetches have been done. |
|
133 * |
|
134 */ |
|
135 void allThumbnailsFetched(); |
|
136 |
|
137 public: |
|
138 |
|
139 struct TnRequest |
|
140 { |
|
141 QString name; |
|
142 void *id; |
|
143 int priority; |
|
144 bool cancelled; |
|
145 |
|
146 TnRequest(QString name, void *id, int priority, bool cancelled) { |
|
147 this->name = name; |
|
148 this->id = id; |
|
149 this->priority = priority; |
|
150 this->cancelled = cancelled; |
|
151 } |
|
152 |
|
153 TnRequest() { |
|
154 name = QString(""); |
|
155 id = 0; |
|
156 priority = -1; |
|
157 cancelled = false; |
|
158 } |
|
159 }; |
|
160 |
|
161 static QMap<int, TnRequest> mRequests; |
|
162 |
|
163 public: // Data |
|
164 |
|
165 static int mConstructorCallCount; |
|
166 static int mDestructorCallCount; |
|
167 static int mAddFetchCallCount; |
|
168 static int mCancelFetchesCallCount; |
|
169 static int mFetchCountCallCount; |
|
170 static int mPauseFetchingCallCount; |
|
171 static int mContinueFetchingCallCount; |
|
172 static int mEnableThumbnailCreationCallCount; |
|
173 |
|
174 static bool mAddFetchFails; |
|
175 static int mThumbnailReadyError; |
|
176 |
|
177 /* |
|
178 static int mxxxCallCount; |
|
179 static int mxxxCallCount; |
|
180 static int mxxxCallCount; |
|
181 static int mxxxCallCount; |
|
182 static int mxxxCallCount; |
|
183 static int mxxxCallCount;*/ |
|
184 }; |
|
185 |
|
186 #endif // __VIDEOTHUMBNAILDATAFETCHER_H__ |