author | alwin <alwin> | 2004-02-22 21:40:20 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-22 21:40:20 (UTC) |
commit | caa64a311d665e4d5c75cc9d45e0b3cd8ef2fdf1 (patch) (unidiff) | |
tree | ef464310a07582a7179a4d136b555b806f43fe1a | |
parent | 936fc191ac5756a4de2e8b2a83c8bc910f918b95 (diff) | |
download | opie-caa64a311d665e4d5c75cc9d45e0b3cd8ef2fdf1.zip opie-caa64a311d665e4d5c75cc9d45e0b3cd8ef2fdf1.tar.gz opie-caa64a311d665e4d5c75cc9d45e0b3cd8ef2fdf1.tar.bz2 |
when inserting a new media without .opiestorage.cf a dialog comes
setting up this file.
-rw-r--r-- | core/launcher/documentlist.cpp | 7 | ||||
-rw-r--r-- | core/launcher/mediadlg.cpp | 31 | ||||
-rw-r--r-- | core/launcher/mediadlg.h | 29 | ||||
-rw-r--r-- | core/launcher/server.pro | 12 |
4 files changed, 74 insertions, 5 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 9736e65..39dc7c9 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -1,689 +1,690 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "documentlist.h" | 20 | #include "documentlist.h" |
21 | #include "serverinterface.h" | 21 | #include "serverinterface.h" |
22 | #include "mediadlg.h" | ||
22 | 23 | ||
23 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
24 | 25 | ||
25 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
26 | #include <qtopia/mimetype.h> | 27 | #include <qtopia/mimetype.h> |
27 | #include <qtopia/resource.h> | 28 | #include <qtopia/resource.h> |
28 | #include <qtopia/private/categories.h> | 29 | #include <qtopia/private/categories.h> |
29 | #include <qtopia/qpeapplication.h> | 30 | #include <qtopia/qpeapplication.h> |
30 | #include <qtopia/applnk.h> | 31 | #include <qtopia/applnk.h> |
31 | #include <qtopia/storage.h> | 32 | #include <qtopia/storage.h> |
32 | #ifdef Q_WS_QWS | 33 | #ifdef Q_WS_QWS |
33 | #include <qtopia/qcopenvelope_qws.h> | 34 | #include <qtopia/qcopenvelope_qws.h> |
34 | #endif | 35 | #endif |
35 | 36 | ||
36 | #include <qtimer.h> | 37 | #include <qtimer.h> |
37 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
38 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
39 | #include <qfile.h> | 40 | #include <qfile.h> |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <qpainter.h> | 42 | #include <qpainter.h> |
42 | #include <qimage.h> | 43 | #include <qimage.h> |
43 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
44 | #include <qlistview.h> | 45 | #include <qlistview.h> |
45 | #include <qlist.h> | 46 | #include <qlist.h> |
46 | #include <qpixmap.h> | 47 | #include <qpixmap.h> |
47 | 48 | ||
48 | 49 | ||
49 | AppLnkSet *DocumentList::appLnkSet = 0; | 50 | AppLnkSet *DocumentList::appLnkSet = 0; |
50 | 51 | ||
51 | static const int MAX_SEARCH_DEPTH = 10; | 52 | static const int MAX_SEARCH_DEPTH = 10; |
52 | 53 | ||
53 | 54 | ||
54 | class DocumentListPrivate : public QObject { | 55 | class DocumentListPrivate : public QObject { |
55 | Q_OBJECT | 56 | Q_OBJECT |
56 | public: | 57 | public: |
57 | DocumentListPrivate( ServerInterface *gui ); | 58 | DocumentListPrivate( ServerInterface *gui ); |
58 | ~DocumentListPrivate(); | 59 | ~DocumentListPrivate(); |
59 | 60 | ||
60 | void initialize(); | 61 | void initialize(); |
61 | 62 | ||
62 | const QString nextFile(); | 63 | const QString nextFile(); |
63 | const DocLnk *iterate(); | 64 | const DocLnk *iterate(); |
64 | bool store( DocLnk* dl ); | 65 | bool store( DocLnk* dl ); |
65 | void estimatedPercentScanned(); | 66 | void estimatedPercentScanned(); |
66 | void appendDocpath(FileSystem*); | 67 | void appendDocpath(FileSystem*); |
67 | 68 | ||
68 | 69 | ||
69 | DocLnkSet dls; | 70 | DocLnkSet dls; |
70 | QDict<void> reference; | 71 | QDict<void> reference; |
71 | QDictIterator<void> *dit; | 72 | QDictIterator<void> *dit; |
72 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; | 73 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; |
73 | 74 | ||
74 | QStringList docPaths; | 75 | QStringList docPaths; |
75 | unsigned int docPathsSearched; | 76 | unsigned int docPathsSearched; |
76 | 77 | ||
77 | int searchDepth; | 78 | int searchDepth; |
78 | QDir *listDirs[MAX_SEARCH_DEPTH]; | 79 | QDir *listDirs[MAX_SEARCH_DEPTH]; |
79 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; | 80 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; |
80 | unsigned int listPositions[MAX_SEARCH_DEPTH]; | 81 | unsigned int listPositions[MAX_SEARCH_DEPTH]; |
81 | 82 | ||
82 | StorageInfo *storage; | 83 | StorageInfo *storage; |
83 | 84 | ||
84 | int tid; | 85 | int tid; |
85 | 86 | ||
86 | ServerInterface *serverGui; | 87 | ServerInterface *serverGui; |
87 | 88 | ||
88 | bool needToSendAllDocLinks; | 89 | bool needToSendAllDocLinks; |
89 | bool sendAppLnks; | 90 | bool sendAppLnks; |
90 | bool sendDocLnks; | 91 | bool sendDocLnks; |
91 | bool scanDocs; | 92 | bool scanDocs; |
92 | }; | 93 | }; |
93 | 94 | ||
94 | 95 | ||
95 | /* | 96 | /* |
96 | * scandocs will be read from Config | 97 | * scandocs will be read from Config |
97 | */ | 98 | */ |
98 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, | 99 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, |
99 | QObject *parent, const char *name ) | 100 | QObject *parent, const char *name ) |
100 | : QObject( parent, name ) | 101 | : QObject( parent, name ) |
101 | { | 102 | { |
102 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); | 103 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); |
103 | d = new DocumentListPrivate( serverGui ); | 104 | d = new DocumentListPrivate( serverGui ); |
104 | d->needToSendAllDocLinks = false; | 105 | d->needToSendAllDocLinks = false; |
105 | 106 | ||
106 | Config cfg( "Launcher" ); | 107 | Config cfg( "Launcher" ); |
107 | cfg.setGroup( "DocTab" ); | 108 | cfg.setGroup( "DocTab" ); |
108 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); | 109 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); |
109 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); | 110 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); |
110 | 111 | ||
111 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); | 112 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); |
112 | } | 113 | } |
113 | 114 | ||
114 | void DocumentList::startInitialScan() | 115 | void DocumentList::startInitialScan() |
115 | { | 116 | { |
116 | reloadAppLnks(); | 117 | reloadAppLnks(); |
117 | reloadDocLnks(); | 118 | reloadDocLnks(); |
118 | } | 119 | } |
119 | 120 | ||
120 | DocumentList::~DocumentList() | 121 | DocumentList::~DocumentList() |
121 | { | 122 | { |
122 | delete appLnkSet; | 123 | delete appLnkSet; |
123 | delete d; | 124 | delete d; |
124 | } | 125 | } |
125 | 126 | ||
126 | 127 | ||
127 | void DocumentList::add( const DocLnk& doc ) | 128 | void DocumentList::add( const DocLnk& doc ) |
128 | { | 129 | { |
129 | if ( d->serverGui && QFile::exists( doc.file() ) ) | 130 | if ( d->serverGui && QFile::exists( doc.file() ) ) |
130 | d->serverGui->documentAdded( doc ); | 131 | d->serverGui->documentAdded( doc ); |
131 | } | 132 | } |
132 | 133 | ||
133 | 134 | ||
134 | void DocumentList::start() | 135 | void DocumentList::start() |
135 | { | 136 | { |
136 | resume(); | 137 | resume(); |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | void DocumentList::pause() | 141 | void DocumentList::pause() |
141 | { | 142 | { |
142 | //qDebug("pause %i", d->tid); | 143 | //qDebug("pause %i", d->tid); |
143 | killTimer( d->tid ); | 144 | killTimer( d->tid ); |
144 | d->tid = 0; | 145 | d->tid = 0; |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | void DocumentList::resume() | 149 | void DocumentList::resume() |
149 | { | 150 | { |
150 | if ( d->tid == 0 ) { | 151 | if ( d->tid == 0 ) { |
151 | d->tid = startTimer( 20 ); | 152 | d->tid = startTimer( 20 ); |
152 | //qDebug("resumed %i", d->tid); | 153 | //qDebug("resumed %i", d->tid); |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | /* | 157 | /* |
157 | void DocumentList::resend() | 158 | void DocumentList::resend() |
158 | { | 159 | { |
159 | // Re-emits all the added items to the list (firstly letting everyone know to | 160 | // Re-emits all the added items to the list (firstly letting everyone know to |
160 | // clear what they have as it is being sent again) | 161 | // clear what they have as it is being sent again) |
161 | pause(); | 162 | pause(); |
162 | emit allRemoved(); | 163 | emit allRemoved(); |
163 | QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); | 164 | QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); |
164 | } | 165 | } |
165 | 166 | ||
166 | 167 | ||
167 | void DocumentList::resendWorker() | 168 | void DocumentList::resendWorker() |
168 | { | 169 | { |
169 | const QList<DocLnk> &list = d->dls.children(); | 170 | const QList<DocLnk> &list = d->dls.children(); |
170 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) | 171 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) |
171 | add( *(*it) ); | 172 | add( *(*it) ); |
172 | resume(); | 173 | resume(); |
173 | } | 174 | } |
174 | */ | 175 | */ |
175 | 176 | ||
176 | void DocumentList::rescan() | 177 | void DocumentList::rescan() |
177 | { | 178 | { |
178 | //qDebug("rescan"); | 179 | //qDebug("rescan"); |
179 | pause(); | 180 | pause(); |
180 | d->initialize(); | 181 | d->initialize(); |
181 | resume(); | 182 | resume(); |
182 | } | 183 | } |
183 | 184 | ||
184 | 185 | ||
185 | void DocumentList::timerEvent( QTimerEvent *te ) | 186 | void DocumentList::timerEvent( QTimerEvent *te ) |
186 | { | 187 | { |
187 | if ( te->timerId() == d->tid ) { | 188 | if ( te->timerId() == d->tid ) { |
188 | // Do 3 at a time | 189 | // Do 3 at a time |
189 | for (int i = 0; i < 3; i++ ) { | 190 | for (int i = 0; i < 3; i++ ) { |
190 | const DocLnk *lnk = d->iterate(); | 191 | const DocLnk *lnk = d->iterate(); |
191 | if ( lnk ) { | 192 | if ( lnk ) { |
192 | add( *lnk ); | 193 | add( *lnk ); |
193 | } else { | 194 | } else { |
194 | // stop when done | 195 | // stop when done |
195 | pause(); | 196 | pause(); |
196 | if ( d->serverGui ) | 197 | if ( d->serverGui ) |
197 | d->serverGui->documentScanningProgress( 100 ); | 198 | d->serverGui->documentScanningProgress( 100 ); |
198 | if ( d->needToSendAllDocLinks ) | 199 | if ( d->needToSendAllDocLinks ) |
199 | sendAllDocLinks(); | 200 | sendAllDocLinks(); |
200 | break; | 201 | break; |
201 | } | 202 | } |
202 | } | 203 | } |
203 | } | 204 | } |
204 | } | 205 | } |
205 | 206 | ||
206 | 207 | ||
207 | void DocumentList::reloadAppLnks() | 208 | void DocumentList::reloadAppLnks() |
208 | { | 209 | { |
209 | if ( d->sendAppLnks && d->serverGui ) { | 210 | if ( d->sendAppLnks && d->serverGui ) { |
210 | d->serverGui->applicationScanningProgress( 0 ); | 211 | d->serverGui->applicationScanningProgress( 0 ); |
211 | d->serverGui->allApplicationsRemoved(); | 212 | d->serverGui->allApplicationsRemoved(); |
212 | } | 213 | } |
213 | 214 | ||
214 | delete appLnkSet; | 215 | delete appLnkSet; |
215 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); | 216 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); |
216 | 217 | ||
217 | if ( d->sendAppLnks && d->serverGui ) { | 218 | if ( d->sendAppLnks && d->serverGui ) { |
218 | static QStringList prevTypeList; | 219 | static QStringList prevTypeList; |
219 | QStringList types = appLnkSet->types(); | 220 | QStringList types = appLnkSet->types(); |
220 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | 221 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { |
221 | if ( !(*ittypes).isEmpty() ) { | 222 | if ( !(*ittypes).isEmpty() ) { |
222 | if ( !prevTypeList.contains(*ittypes) ) { | 223 | if ( !prevTypeList.contains(*ittypes) ) { |
223 | QString name = appLnkSet->typeName(*ittypes); | 224 | QString name = appLnkSet->typeName(*ittypes); |
224 | QPixmap pm = appLnkSet->typePixmap(*ittypes); | 225 | QPixmap pm = appLnkSet->typePixmap(*ittypes); |
225 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); | 226 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); |
226 | 227 | ||
227 | if (pm.isNull()) { | 228 | if (pm.isNull()) { |
228 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 229 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
229 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 230 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
230 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | 231 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); |
231 | } | 232 | } |
232 | 233 | ||
233 | //qDebug("adding type %s", (*ittypes).latin1()); | 234 | //qDebug("adding type %s", (*ittypes).latin1()); |
234 | 235 | ||
235 | // ### our current launcher expects docs tab to be last | 236 | // ### our current launcher expects docs tab to be last |
236 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | 237 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); |
237 | } | 238 | } |
238 | prevTypeList.remove(*ittypes); | 239 | prevTypeList.remove(*ittypes); |
239 | } | 240 | } |
240 | } | 241 | } |
241 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | 242 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { |
242 | //qDebug("removing type %s", (*ittypes).latin1()); | 243 | //qDebug("removing type %s", (*ittypes).latin1()); |
243 | d->serverGui->typeRemoved(*ittypes); | 244 | d->serverGui->typeRemoved(*ittypes); |
244 | } | 245 | } |
245 | prevTypeList = types; | 246 | prevTypeList = types; |
246 | } | 247 | } |
247 | 248 | ||
248 | QListIterator<AppLnk> itapp( appLnkSet->children() ); | 249 | QListIterator<AppLnk> itapp( appLnkSet->children() ); |
249 | AppLnk* l; | 250 | AppLnk* l; |
250 | while ( (l=itapp.current()) ) { | 251 | while ( (l=itapp.current()) ) { |
251 | ++itapp; | 252 | ++itapp; |
252 | if ( d->sendAppLnks && d->serverGui ) | 253 | if ( d->sendAppLnks && d->serverGui ) |
253 | d->serverGui->applicationAdded( l->type(), *l ); | 254 | d->serverGui->applicationAdded( l->type(), *l ); |
254 | } | 255 | } |
255 | 256 | ||
256 | if ( d->sendAppLnks && d->serverGui ) | 257 | if ( d->sendAppLnks && d->serverGui ) |
257 | d->serverGui->applicationScanningProgress( 100 ); | 258 | d->serverGui->applicationScanningProgress( 100 ); |
258 | } | 259 | } |
259 | 260 | ||
260 | void DocumentList::reloadDocLnks() | 261 | void DocumentList::reloadDocLnks() |
261 | { | 262 | { |
262 | if ( !d->scanDocs ) | 263 | if ( !d->scanDocs ) |
263 | return; | 264 | return; |
264 | 265 | ||
265 | if ( d->sendDocLnks && d->serverGui ) { | 266 | if ( d->sendDocLnks && d->serverGui ) { |
266 | d->serverGui->documentScanningProgress( 0 ); | 267 | d->serverGui->documentScanningProgress( 0 ); |
267 | d->serverGui->allDocumentsRemoved(); | 268 | d->serverGui->allDocumentsRemoved(); |
268 | } | 269 | } |
269 | 270 | ||
270 | rescan(); | 271 | rescan(); |
271 | } | 272 | } |
272 | 273 | ||
273 | void DocumentList::linkChanged( QString arg ) | 274 | void DocumentList::linkChanged( QString arg ) |
274 | { | 275 | { |
275 | //qDebug( "linkchanged( %s )", arg.latin1() ); | 276 | //qDebug( "linkchanged( %s )", arg.latin1() ); |
276 | 277 | ||
277 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { | 278 | if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { |
278 | reloadAppLnks(); | 279 | reloadAppLnks(); |
279 | } else { | 280 | } else { |
280 | 281 | ||
281 | const QList<DocLnk> &list = d->dls.children(); | 282 | const QList<DocLnk> &list = d->dls.children(); |
282 | QListIterator<DocLnk> it( list ); | 283 | QListIterator<DocLnk> it( list ); |
283 | while ( it.current() ) { | 284 | while ( it.current() ) { |
284 | DocLnk *doc = it.current(); | 285 | DocLnk *doc = it.current(); |
285 | ++it; | 286 | ++it; |
286 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) | 287 | if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) |
287 | || ( doc->fileKnown() && doc->file() == arg ) ) { | 288 | || ( doc->fileKnown() && doc->file() == arg ) ) { |
288 | //qDebug( "found old link" ); | 289 | //qDebug( "found old link" ); |
289 | DocLnk* dl = new DocLnk( arg ); | 290 | DocLnk* dl = new DocLnk( arg ); |
290 | // add new one if it exists and matches the mimetype | 291 | // add new one if it exists and matches the mimetype |
291 | if ( d->store( dl ) ) { | 292 | if ( d->store( dl ) ) { |
292 | // Existing link has been changed, send old link ref and a ref | 293 | // Existing link has been changed, send old link ref and a ref |
293 | // to the new link | 294 | // to the new link |
294 | //qDebug( "change case" ); | 295 | //qDebug( "change case" ); |
295 | if ( d->serverGui ) | 296 | if ( d->serverGui ) |
296 | d->serverGui->documentChanged( *doc, *dl ); | 297 | d->serverGui->documentChanged( *doc, *dl ); |
297 | 298 | ||
298 | } else { | 299 | } else { |
299 | // Link has been removed or doesn't match the mimetypes any more | 300 | // Link has been removed or doesn't match the mimetypes any more |
300 | // so we aren't interested in it, so take it away from the list | 301 | // so we aren't interested in it, so take it away from the list |
301 | //qDebug( "removal case" ); | 302 | //qDebug( "removal case" ); |
302 | if ( d->serverGui ) | 303 | if ( d->serverGui ) |
303 | d->serverGui->documentRemoved( *doc ); | 304 | d->serverGui->documentRemoved( *doc ); |
304 | 305 | ||
305 | } | 306 | } |
306 | d->dls.remove( doc ); // remove old link from docLnkSet | 307 | d->dls.remove( doc ); // remove old link from docLnkSet |
307 | delete doc; | 308 | delete doc; |
308 | return; | 309 | return; |
309 | } | 310 | } |
310 | } | 311 | } |
311 | // Didn't find existing link, must be new | 312 | // Didn't find existing link, must be new |
312 | DocLnk* dl = new DocLnk( arg ); | 313 | DocLnk* dl = new DocLnk( arg ); |
313 | if ( d->store( dl ) ) { | 314 | if ( d->store( dl ) ) { |
314 | // Add if it's a link we are interested in | 315 | // Add if it's a link we are interested in |
315 | //qDebug( "add case" ); | 316 | //qDebug( "add case" ); |
316 | add( *dl ); | 317 | add( *dl ); |
317 | } | 318 | } |
318 | 319 | ||
319 | } | 320 | } |
320 | } | 321 | } |
321 | 322 | ||
322 | void DocumentList::restoreDone() | 323 | void DocumentList::restoreDone() |
323 | { | 324 | { |
324 | reloadAppLnks(); | 325 | reloadAppLnks(); |
325 | reloadDocLnks(); | 326 | reloadDocLnks(); |
326 | } | 327 | } |
327 | 328 | ||
328 | void DocumentList::storageChanged() | 329 | void DocumentList::storageChanged() |
329 | { | 330 | { |
330 | // ### can implement better | 331 | // ### can implement better |
331 | reloadAppLnks(); | 332 | reloadAppLnks(); |
332 | reloadDocLnks(); | 333 | reloadDocLnks(); |
333 | // ### Optimization opportunity | 334 | // ### Optimization opportunity |
334 | // Could be a bit more intelligent and somehow work out which | 335 | // Could be a bit more intelligent and somehow work out which |
335 | // mtab entry has changed and then only scan that and add and remove | 336 | // mtab entry has changed and then only scan that and add and remove |
336 | // links appropriately. | 337 | // links appropriately. |
337 | // rescan(); | 338 | // rescan(); |
338 | } | 339 | } |
339 | 340 | ||
340 | void DocumentList::sendAllDocLinks() | 341 | void DocumentList::sendAllDocLinks() |
341 | { | 342 | { |
342 | if ( d->tid != 0 ) { | 343 | if ( d->tid != 0 ) { |
343 | // We are in the middle of scanning, set a flag so | 344 | // We are in the middle of scanning, set a flag so |
344 | // we do this when we finish our scanning | 345 | // we do this when we finish our scanning |
345 | d->needToSendAllDocLinks = true; | 346 | d->needToSendAllDocLinks = true; |
346 | return; | 347 | return; |
347 | } | 348 | } |
348 | 349 | ||
349 | QString contents; | 350 | QString contents; |
350 | Categories cats; | 351 | Categories cats; |
351 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { | 352 | for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { |
352 | DocLnk *doc = it.current(); | 353 | DocLnk *doc = it.current(); |
353 | QFileInfo fi( doc->file() ); | 354 | QFileInfo fi( doc->file() ); |
354 | if ( !fi.exists() ) | 355 | if ( !fi.exists() ) |
355 | continue; | 356 | continue; |
356 | 357 | ||
357 | bool fake = !doc->linkFileKnown(); | 358 | bool fake = !doc->linkFileKnown(); |
358 | if ( !fake ) { | 359 | if ( !fake ) { |
359 | QFile f( doc->linkFile() ); | 360 | QFile f( doc->linkFile() ); |
360 | if ( f.open( IO_ReadOnly ) ) { | 361 | if ( f.open( IO_ReadOnly ) ) { |
361 | QTextStream ts( &f ); | 362 | QTextStream ts( &f ); |
362 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 363 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
363 | contents += ts.read(); | 364 | contents += ts.read(); |
364 | f.close(); | 365 | f.close(); |
365 | } else | 366 | } else |
366 | fake = TRUE; | 367 | fake = TRUE; |
367 | } | 368 | } |
368 | if (fake) { | 369 | if (fake) { |
369 | contents += "[Desktop Entry]\n"; // No tr | 370 | contents += "[Desktop Entry]\n"; // No tr |
370 | contents += "Categories = " + // No tr | 371 | contents += "Categories = " + // No tr |
371 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 372 | cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
372 | contents += "Name = "+doc->name()+"\n"; // No tr | 373 | contents += "Name = "+doc->name()+"\n"; // No tr |
373 | contents += "Type = "+doc->type()+"\n"; // No tr | 374 | contents += "Type = "+doc->type()+"\n"; // No tr |
374 | } | 375 | } |
375 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 376 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
376 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 377 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
377 | } | 378 | } |
378 | 379 | ||
379 | //qDebug( "sending length %d", contents.length() ); | 380 | //qDebug( "sending length %d", contents.length() ); |
380 | #ifndef QT_NO_COP | 381 | #ifndef QT_NO_COP |
381 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 382 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
382 | e << contents; | 383 | e << contents; |
383 | #endif | 384 | #endif |
384 | //qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); | 385 | //qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); |
385 | 386 | ||
386 | d->needToSendAllDocLinks = false; | 387 | d->needToSendAllDocLinks = false; |
387 | } | 388 | } |
388 | 389 | ||
389 | 390 | ||
390 | 391 | ||
391 | 392 | ||
392 | 393 | ||
393 | 394 | ||
394 | 395 | ||
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | 399 | ||
399 | 400 | ||
400 | 401 | ||
401 | 402 | ||
402 | 403 | ||
403 | 404 | ||
404 | 405 | ||
405 | 406 | ||
406 | 407 | ||
407 | 408 | ||
408 | 409 | ||
409 | 410 | ||
410 | 411 | ||
411 | 412 | ||
412 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) | 413 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) |
413 | { | 414 | { |
414 | storage = new StorageInfo( this ); | 415 | storage = new StorageInfo( this ); |
415 | serverGui = gui; | 416 | serverGui = gui; |
416 | if ( serverGui ) { | 417 | if ( serverGui ) { |
417 | sendAppLnks = serverGui->requiresApplications(); | 418 | sendAppLnks = serverGui->requiresApplications(); |
418 | sendDocLnks = serverGui->requiresDocuments(); | 419 | sendDocLnks = serverGui->requiresDocuments(); |
419 | } else { | 420 | } else { |
420 | sendAppLnks = false; | 421 | sendAppLnks = false; |
421 | sendDocLnks = false; | 422 | sendDocLnks = false; |
422 | } | 423 | } |
423 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { | 424 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { |
424 | listDirs[i] = 0; | 425 | listDirs[i] = 0; |
425 | lists[i] = 0; | 426 | lists[i] = 0; |
426 | listPositions[i] = 0; | 427 | listPositions[i] = 0; |
427 | } | 428 | } |
428 | initialize(); | 429 | initialize(); |
429 | tid = 0; | 430 | tid = 0; |
430 | } | 431 | } |
431 | 432 | ||
432 | void DocumentListPrivate::appendDocpath(FileSystem*fs) | 433 | void DocumentListPrivate::appendDocpath(FileSystem*fs) |
433 | { | 434 | { |
434 | QDir defPath(fs->path()+"/Documents"); | 435 | QDir defPath(fs->path()+"/Documents"); |
435 | QFileInfo f(fs->path()+"/.opiestorage.cf"); | 436 | QFileInfo f(fs->path()+"/.opiestorage.cf"); |
436 | if (!f.exists()) { | 437 | if (!f.exists()) { |
437 | if (defPath.exists()) { | 438 | Mediadlg dlg(fs); |
438 | docPaths+=defPath.path(); | 439 | if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { |
440 | return; | ||
439 | } | 441 | } |
440 | return; | ||
441 | } | 442 | } |
442 | Config conf(f.filePath(), Config::File ); | 443 | Config conf(f.filePath(), Config::File ); |
443 | conf.setGroup("subdirs"); | 444 | conf.setGroup("subdirs"); |
444 | bool read_all = conf.readBoolEntry("wholemedia",true); | 445 | bool read_all = conf.readBoolEntry("wholemedia",true); |
445 | if (read_all) { | 446 | if (read_all) { |
446 | docPaths+=fs->path(); | 447 | docPaths+=fs->path(); |
447 | return; | 448 | return; |
448 | } | 449 | } |
449 | QStringList subDirs = conf.readListEntry("subdirs",':'); | 450 | QStringList subDirs = conf.readListEntry("subdirs",':'); |
450 | if (subDirs.isEmpty()) { | 451 | if (subDirs.isEmpty()) { |
451 | if (defPath.exists()) { | 452 | if (defPath.exists()) { |
452 | docPaths+=defPath.path(); | 453 | docPaths+=defPath.path(); |
453 | } | 454 | } |
454 | return; | 455 | return; |
455 | } | 456 | } |
456 | for (unsigned c = 0; c < subDirs.count();++c) { | 457 | for (unsigned c = 0; c < subDirs.count();++c) { |
457 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); | 458 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); |
458 | if (docDir.exists()) { | 459 | if (docDir.exists()) { |
459 | docPaths+=docDir.path(); | 460 | docPaths+=docDir.path(); |
460 | } | 461 | } |
461 | } | 462 | } |
462 | } | 463 | } |
463 | 464 | ||
464 | void DocumentListPrivate::initialize() | 465 | void DocumentListPrivate::initialize() |
465 | { | 466 | { |
466 | // Reset | 467 | // Reset |
467 | dls.clear(); | 468 | dls.clear(); |
468 | docPaths.clear(); | 469 | docPaths.clear(); |
469 | reference.clear(); | 470 | reference.clear(); |
470 | 471 | ||
471 | QDir docDir( QPEApplication::documentDir() ); | 472 | QDir docDir( QPEApplication::documentDir() ); |
472 | if ( docDir.exists() ) | 473 | if ( docDir.exists() ) |
473 | docPaths += QPEApplication::documentDir(); | 474 | docPaths += QPEApplication::documentDir(); |
474 | int i = 1; | 475 | int i = 1; |
475 | const QList<FileSystem> &fs = storage->fileSystems(); | 476 | const QList<FileSystem> &fs = storage->fileSystems(); |
476 | QListIterator<FileSystem> it( fs ); | 477 | QListIterator<FileSystem> it( fs ); |
477 | for ( ; it.current(); ++it ) { | 478 | for ( ; it.current(); ++it ) { |
478 | if ( (*it)->isRemovable() ) { | 479 | if ( (*it)->isRemovable() ) { |
479 | appendDocpath((*it)); | 480 | appendDocpath((*it)); |
480 | ++i; | 481 | ++i; |
481 | } | 482 | } |
482 | } | 483 | } |
483 | 484 | ||
484 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { | 485 | for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { |
485 | if ( listDirs[i] ) { | 486 | if ( listDirs[i] ) { |
486 | delete listDirs[i]; | 487 | delete listDirs[i]; |
487 | listDirs[i] = 0; | 488 | listDirs[i] = 0; |
488 | } | 489 | } |
489 | lists[i] = 0; | 490 | lists[i] = 0; |
490 | listPositions[i] = 0; | 491 | listPositions[i] = 0; |
491 | } | 492 | } |
492 | 493 | ||
493 | docPathsSearched = 0; | 494 | docPathsSearched = 0; |
494 | searchDepth = -1; | 495 | searchDepth = -1; |
495 | state = Find; | 496 | state = Find; |
496 | dit = 0; | 497 | dit = 0; |
497 | } | 498 | } |
498 | 499 | ||
499 | 500 | ||
500 | DocumentListPrivate::~DocumentListPrivate() | 501 | DocumentListPrivate::~DocumentListPrivate() |
501 | { | 502 | { |
502 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) | 503 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) |
503 | if ( listDirs[i] ) | 504 | if ( listDirs[i] ) |
504 | delete listDirs[i]; | 505 | delete listDirs[i]; |
505 | delete dit; | 506 | delete dit; |
506 | } | 507 | } |
507 | 508 | ||
508 | 509 | ||
509 | void DocumentListPrivate::estimatedPercentScanned() | 510 | void DocumentListPrivate::estimatedPercentScanned() |
510 | { | 511 | { |
511 | double overallProgress = 0.0; | 512 | double overallProgress = 0.0; |
512 | double levelWeight = 75.0; | 513 | double levelWeight = 75.0; |
513 | 514 | ||
514 | int topCount = docPaths.count(); | 515 | int topCount = docPaths.count(); |
515 | if ( topCount > 1 ) { | 516 | if ( topCount > 1 ) { |
516 | levelWeight = levelWeight / topCount; | 517 | levelWeight = levelWeight / topCount; |
517 | overallProgress += (docPathsSearched - 1) * levelWeight; | 518 | overallProgress += (docPathsSearched - 1) * levelWeight; |
518 | } | 519 | } |
519 | 520 | ||
520 | for ( int d = 0; d <= searchDepth; d++ ) { | 521 | for ( int d = 0; d <= searchDepth; d++ ) { |
521 | if ( listDirs[d] ) { | 522 | if ( listDirs[d] ) { |
522 | int items = lists[d]->count(); | 523 | int items = lists[d]->count(); |
523 | if ( items > 1 ) { | 524 | if ( items > 1 ) { |
524 | levelWeight = levelWeight / items; | 525 | levelWeight = levelWeight / items; |
525 | // Take in to account "." and ".." | 526 | // Take in to account "." and ".." |
526 | overallProgress += (listPositions[d] - 3) * levelWeight; | 527 | overallProgress += (listPositions[d] - 3) * levelWeight; |
527 | } | 528 | } |
528 | } else { | 529 | } else { |
529 | break; | 530 | break; |
530 | } | 531 | } |
531 | } | 532 | } |
532 | 533 | ||
533 | // qDebug( "overallProgress: %f", overallProgress ); | 534 | // qDebug( "overallProgress: %f", overallProgress ); |
534 | 535 | ||
535 | if ( serverGui ) | 536 | if ( serverGui ) |
536 | serverGui->documentScanningProgress( (int)overallProgress ); | 537 | serverGui->documentScanningProgress( (int)overallProgress ); |
537 | } | 538 | } |
538 | 539 | ||
539 | 540 | ||
540 | const QString DocumentListPrivate::nextFile() | 541 | const QString DocumentListPrivate::nextFile() |
541 | { | 542 | { |
542 | while ( TRUE ) { | 543 | while ( TRUE ) { |
543 | while ( searchDepth < 0 ) { | 544 | while ( searchDepth < 0 ) { |
544 | // go to next base path | 545 | // go to next base path |
545 | if ( docPathsSearched >= docPaths.count() ) { | 546 | if ( docPathsSearched >= docPaths.count() ) { |
546 | // end of base paths | 547 | // end of base paths |
547 | return QString::null; | 548 | return QString::null; |
548 | } else { | 549 | } else { |
549 | QDir dir( docPaths[docPathsSearched] ); | 550 | QDir dir( docPaths[docPathsSearched] ); |
550 | // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); | 551 | // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); |
551 | docPathsSearched++; | 552 | docPathsSearched++; |
552 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 553 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
553 | listDirs[0] = new QDir( dir ); | 554 | listDirs[0] = new QDir( dir ); |
554 | lists[0] = listDirs[0]->entryInfoList(); | 555 | lists[0] = listDirs[0]->entryInfoList(); |
555 | listPositions[0] = 0; | 556 | listPositions[0] = 0; |
556 | searchDepth = 0; | 557 | searchDepth = 0; |
557 | } | 558 | } |
558 | } | 559 | } |
559 | } | 560 | } |
560 | 561 | ||
561 | const QFileInfoList *fil = lists[searchDepth]; | 562 | const QFileInfoList *fil = lists[searchDepth]; |
562 | QFileInfoList *fl = (QFileInfoList *)fil; | 563 | QFileInfoList *fl = (QFileInfoList *)fil; |
563 | unsigned int pos = listPositions[searchDepth]; | 564 | unsigned int pos = listPositions[searchDepth]; |
564 | 565 | ||
565 | if ( pos >= fl->count() ) { | 566 | if ( pos >= fl->count() ) { |
566 | // go up a depth | 567 | // go up a depth |
567 | delete listDirs[searchDepth]; | 568 | delete listDirs[searchDepth]; |
568 | listDirs[searchDepth] = 0; | 569 | listDirs[searchDepth] = 0; |
569 | lists[searchDepth] = 0; | 570 | lists[searchDepth] = 0; |
570 | listPositions[searchDepth] = 0; | 571 | listPositions[searchDepth] = 0; |
571 | searchDepth--; | 572 | searchDepth--; |
572 | } else { | 573 | } else { |
573 | const QFileInfo *fi = fl->at(pos); | 574 | const QFileInfo *fi = fl->at(pos); |
574 | listPositions[searchDepth]++; | 575 | listPositions[searchDepth]++; |
575 | QString bn = fi->fileName(); | 576 | QString bn = fi->fileName(); |
576 | if ( bn[0] != '.' ) { | 577 | if ( bn[0] != '.' ) { |
577 | if ( fi->isDir() ) { | 578 | if ( fi->isDir() ) { |
578 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { | 579 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { |
579 | // go down a depth | 580 | // go down a depth |
580 | QDir dir( fi->filePath() ); | 581 | QDir dir( fi->filePath() ); |
581 | // qDebug("now going in to path: %s", bn.latin1() ); | 582 | // qDebug("now going in to path: %s", bn.latin1() ); |
582 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 583 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
583 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { | 584 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { |
584 | searchDepth++; | 585 | searchDepth++; |
585 | listDirs[searchDepth] = new QDir( dir ); | 586 | listDirs[searchDepth] = new QDir( dir ); |
586 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); | 587 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); |
587 | listPositions[searchDepth] = 0; | 588 | listPositions[searchDepth] = 0; |
588 | } | 589 | } |
589 | } | 590 | } |
590 | } | 591 | } |
591 | } else { | 592 | } else { |
592 | estimatedPercentScanned(); | 593 | estimatedPercentScanned(); |
593 | return fl->at(pos)->filePath(); | 594 | return fl->at(pos)->filePath(); |
594 | } | 595 | } |
595 | } | 596 | } |
596 | } | 597 | } |
597 | } | 598 | } |
598 | 599 | ||
599 | return QString::null; | 600 | return QString::null; |
600 | } | 601 | } |
601 | 602 | ||
602 | 603 | ||
603 | bool DocumentListPrivate::store( DocLnk* dl ) | 604 | bool DocumentListPrivate::store( DocLnk* dl ) |
604 | { | 605 | { |
605 | // if ( dl->fileKnown() && !dl->file().isEmpty() ) { | 606 | // if ( dl->fileKnown() && !dl->file().isEmpty() ) { |
606 | if ( dl && dl->fileKnown() ) { | 607 | if ( dl && dl->fileKnown() ) { |
607 | dls.add( dl ); // store | 608 | dls.add( dl ); // store |
608 | return TRUE; | 609 | return TRUE; |
609 | } | 610 | } |
610 | 611 | ||
611 | // don't store - delete | 612 | // don't store - delete |
612 | delete dl; | 613 | delete dl; |
613 | return FALSE; | 614 | return FALSE; |
614 | } | 615 | } |
615 | 616 | ||
616 | 617 | ||
617 | #define MAGIC_NUMBER((void*)2) | 618 | #define MAGIC_NUMBER((void*)2) |
618 | 619 | ||
619 | const DocLnk *DocumentListPrivate::iterate() | 620 | const DocLnk *DocumentListPrivate::iterate() |
620 | { | 621 | { |
621 | if ( state == Find ) { | 622 | if ( state == Find ) { |
622 | //qDebug("state Find"); | 623 | //qDebug("state Find"); |
623 | QString file = nextFile(); | 624 | QString file = nextFile(); |
624 | while ( !file.isNull() ) { | 625 | while ( !file.isNull() ) { |
625 | if ( file.right(8) == ".desktop" ) { // No tr | 626 | if ( file.right(8) == ".desktop" ) { // No tr |
626 | DocLnk* dl = new DocLnk( file ); | 627 | DocLnk* dl = new DocLnk( file ); |
627 | if ( store(dl) ) | 628 | if ( store(dl) ) |
628 | return dl; | 629 | return dl; |
629 | } else { | 630 | } else { |
630 | reference.insert( file, MAGIC_NUMBER ); | 631 | reference.insert( file, MAGIC_NUMBER ); |
631 | } | 632 | } |
632 | file = nextFile(); | 633 | file = nextFile(); |
633 | } | 634 | } |
634 | state = RemoveKnownFiles; | 635 | state = RemoveKnownFiles; |
635 | 636 | ||
636 | if ( serverGui ) | 637 | if ( serverGui ) |
637 | serverGui->documentScanningProgress( 75 ); | 638 | serverGui->documentScanningProgress( 75 ); |
638 | } | 639 | } |
639 | 640 | ||
640 | static int iterationI; | 641 | static int iterationI; |
641 | static int iterationCount; | 642 | static int iterationCount; |
642 | 643 | ||
643 | if ( state == RemoveKnownFiles ) { | 644 | if ( state == RemoveKnownFiles ) { |
644 | //qDebug("state RemoveKnownFiles"); | 645 | //qDebug("state RemoveKnownFiles"); |
645 | const QList<DocLnk> &list = dls.children(); | 646 | const QList<DocLnk> &list = dls.children(); |
646 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { | 647 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { |
647 | reference.remove( (*it)->file() ); | 648 | reference.remove( (*it)->file() ); |
648 | // ### does this need to be deleted? | 649 | // ### does this need to be deleted? |
649 | } | 650 | } |
650 | dit = new QDictIterator<void>(reference); | 651 | dit = new QDictIterator<void>(reference); |
651 | state = MakeUnknownFiles; | 652 | state = MakeUnknownFiles; |
652 | 653 | ||
653 | iterationI = 0; | 654 | iterationI = 0; |
654 | iterationCount = dit->count(); | 655 | iterationCount = dit->count(); |
655 | } | 656 | } |
656 | 657 | ||
657 | if ( state == MakeUnknownFiles ) { | 658 | if ( state == MakeUnknownFiles ) { |
658 | //qDebug("state MakeUnknownFiles"); | 659 | //qDebug("state MakeUnknownFiles"); |
659 | for (void* c; (c=dit->current()); ++(*dit) ) { | 660 | for (void* c; (c=dit->current()); ++(*dit) ) { |
660 | if ( c == MAGIC_NUMBER ) { | 661 | if ( c == MAGIC_NUMBER ) { |
661 | DocLnk* dl = new DocLnk; | 662 | DocLnk* dl = new DocLnk; |
662 | QFileInfo fi( dit->currentKey() ); | 663 | QFileInfo fi( dit->currentKey() ); |
663 | dl->setFile( fi.filePath() ); | 664 | dl->setFile( fi.filePath() ); |
664 | dl->setName( fi.baseName() ); | 665 | dl->setName( fi.baseName() ); |
665 | if ( store(dl) ) { | 666 | if ( store(dl) ) { |
666 | ++*dit; | 667 | ++*dit; |
667 | iterationI++; | 668 | iterationI++; |
668 | if ( serverGui ) | 669 | if ( serverGui ) |
669 | serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); | 670 | serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); |
670 | return dl; | 671 | return dl; |
671 | } | 672 | } |
672 | } | 673 | } |
673 | iterationI++; | 674 | iterationI++; |
674 | } | 675 | } |
675 | 676 | ||
676 | delete dit; | 677 | delete dit; |
677 | dit = 0; | 678 | dit = 0; |
678 | state = Done; | 679 | state = Done; |
679 | } | 680 | } |
680 | 681 | ||
681 | //qDebug("state Done"); | 682 | //qDebug("state Done"); |
682 | return NULL; | 683 | return NULL; |
683 | } | 684 | } |
684 | 685 | ||
685 | 686 | ||
686 | #include "documentlist.moc" | 687 | #include "documentlist.moc" |
687 | 688 | ||
688 | 689 | ||
689 | 690 | ||
diff --git a/core/launcher/mediadlg.cpp b/core/launcher/mediadlg.cpp new file mode 100644 index 0000000..6448863 --- a/dev/null +++ b/core/launcher/mediadlg.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include "mediadlg.h" | ||
2 | #include "mediumwidget.h" | ||
3 | #include <qtopia/storage.h> | ||
4 | #include <qpixmap.h> | ||
5 | #include <qlayout.h> | ||
6 | |||
7 | Mediadlg::Mediadlg(FileSystem*fs,QWidget *parent, const char *name, bool modal, WFlags fl) | ||
8 | : QDialog(parent,name,modal,fl) | ||
9 | { | ||
10 | m_fs = fs; | ||
11 | m_widget = 0; | ||
12 | init(); | ||
13 | } | ||
14 | |||
15 | Mediadlg::~Mediadlg() | ||
16 | { | ||
17 | } | ||
18 | |||
19 | void Mediadlg::init() | ||
20 | { | ||
21 | if (!m_fs) return; | ||
22 | m_lay = new QVBoxLayout( this ); | ||
23 | m_widget = new MediumMountSetting::MediumMountWidget(m_fs->path(),QPixmap(),this); | ||
24 | m_lay->addWidget(m_widget); | ||
25 | } | ||
26 | |||
27 | void Mediadlg::accept() | ||
28 | { | ||
29 | if (m_widget) m_widget->writeConfig(); | ||
30 | QDialog::accept(); | ||
31 | } | ||
diff --git a/core/launcher/mediadlg.h b/core/launcher/mediadlg.h new file mode 100644 index 0000000..f4d552d --- a/dev/null +++ b/core/launcher/mediadlg.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef __MEDIA_DLG_H | ||
2 | #define __MEDIA_DLG_H | ||
3 | |||
4 | #include <qdialog.h> | ||
5 | |||
6 | namespace MediumMountSetting { | ||
7 | class MediumMountWidget; | ||
8 | } | ||
9 | class FileSystem; | ||
10 | class QVBoxLayout; | ||
11 | |||
12 | class Mediadlg:public QDialog | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | Mediadlg(FileSystem*,QWidget *parent = 0, const char *name = 0 , bool modal = TRUE, WFlags fl = 0); | ||
17 | virtual ~Mediadlg(); | ||
18 | protected slots: | ||
19 | virtual void accept(); | ||
20 | |||
21 | protected: | ||
22 | MediumMountSetting::MediumMountWidget*m_widget; | ||
23 | FileSystem*m_fs; | ||
24 | QVBoxLayout *m_lay; | ||
25 | void init(); | ||
26 | }; | ||
27 | |||
28 | #endif | ||
29 | |||
diff --git a/core/launcher/server.pro b/core/launcher/server.pro index f82c741..e341e1a 100644 --- a/core/launcher/server.pro +++ b/core/launcher/server.pro | |||
@@ -1,124 +1,132 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | 2 | ||
3 | CONFIG += qtopia warn_on release | 3 | CONFIG += qtopia warn_on release |
4 | 4 | ||
5 | DESTDIR = $$(OPIEDIR)/bin | 5 | DESTDIR = $$(OPIEDIR)/bin |
6 | 6 | ||
7 | HEADERS += server.h \ | 7 | HEADERS += server.h \ |
8 | serverinterface.h \ | 8 | serverinterface.h \ |
9 | launchertab.h \ | 9 | launchertab.h \ |
10 | documentlist.h \ | 10 | documentlist.h \ |
11 | appicons.h \ | 11 | appicons.h \ |
12 | taskbar.h \ | 12 | taskbar.h \ |
13 | runningappbar.h \ | 13 | runningappbar.h \ |
14 | applauncher.h \ | 14 | applauncher.h \ |
15 | stabmon.h \ | 15 | stabmon.h \ |
16 | inputmethods.h \ | 16 | inputmethods.h \ |
17 | systray.h \ | 17 | systray.h \ |
18 | wait.h \ | 18 | wait.h \ |
19 | shutdownimpl.h \ | 19 | shutdownimpl.h \ |
20 | launcher.h \ | 20 | launcher.h \ |
21 | launcherview.h \ | 21 | launcherview.h \ |
22 | $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ | 22 | $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ |
23 | startmenu.h \ | 23 | startmenu.h \ |
24 | transferserver.h \ | 24 | transferserver.h \ |
25 | qcopbridge.h \ | 25 | qcopbridge.h \ |
26 | packageslave.h \ | 26 | packageslave.h \ |
27 | irserver.h \ | 27 | irserver.h \ |
28 | firstuse.h \ | 28 | firstuse.h \ |
29 | $$(OPIEDIR)/rsync/buf.h \ | 29 | $$(OPIEDIR)/rsync/buf.h \ |
30 | $$(OPIEDIR)/rsync/checksum.h \ | 30 | $$(OPIEDIR)/rsync/checksum.h \ |
31 | $$(OPIEDIR)/rsync/command.h \ | 31 | $$(OPIEDIR)/rsync/command.h \ |
32 | $$(OPIEDIR)/rsync/emit.h \ | 32 | $$(OPIEDIR)/rsync/emit.h \ |
33 | $$(OPIEDIR)/rsync/job.h \ | 33 | $$(OPIEDIR)/rsync/job.h \ |
34 | $$(OPIEDIR)/rsync/netint.h \ | 34 | $$(OPIEDIR)/rsync/netint.h \ |
35 | $$(OPIEDIR)/rsync/protocol.h \ | 35 | $$(OPIEDIR)/rsync/protocol.h \ |
36 | $$(OPIEDIR)/rsync/prototab.h \ | 36 | $$(OPIEDIR)/rsync/prototab.h \ |
37 | $$(OPIEDIR)/rsync/rsync.h \ | 37 | $$(OPIEDIR)/rsync/rsync.h \ |
38 | $$(OPIEDIR)/rsync/search.h \ | 38 | $$(OPIEDIR)/rsync/search.h \ |
39 | $$(OPIEDIR)/rsync/stream.h \ | 39 | $$(OPIEDIR)/rsync/stream.h \ |
40 | $$(OPIEDIR)/rsync/sumset.h \ | 40 | $$(OPIEDIR)/rsync/sumset.h \ |
41 | $$(OPIEDIR)/rsync/trace.h \ | 41 | $$(OPIEDIR)/rsync/trace.h \ |
42 | $$(OPIEDIR)/rsync/types.h \ | 42 | $$(OPIEDIR)/rsync/types.h \ |
43 | $$(OPIEDIR)/rsync/util.h \ | 43 | $$(OPIEDIR)/rsync/util.h \ |
44 | $$(OPIEDIR)/rsync/whole.h \ | 44 | $$(OPIEDIR)/rsync/whole.h \ |
45 | $$(OPIEDIR)/rsync/config_rsync.h \ | 45 | $$(OPIEDIR)/rsync/config_rsync.h \ |
46 | $$(OPIEDIR)/rsync/qrsync.h \ | 46 | $$(OPIEDIR)/rsync/qrsync.h \ |
47 | syncdialog.h \ | 47 | syncdialog.h \ |
48 | serverapp.h \ | 48 | serverapp.h \ |
49 | qprocess.h \ | 49 | qprocess.h \ |
50 | screensaver.h | 50 | screensaver.h \ |
51 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.h \ | ||
52 | mediadlg.h | ||
51 | 53 | ||
52 | SOURCES += server.cpp \ | 54 | SOURCES += server.cpp \ |
53 | serverinterface.cpp \ | 55 | serverinterface.cpp \ |
54 | launchertab.cpp \ | 56 | launchertab.cpp \ |
55 | documentlist.cpp \ | 57 | documentlist.cpp \ |
56 | appicons.cpp \ | 58 | appicons.cpp \ |
57 | taskbar.cpp \ | 59 | taskbar.cpp \ |
58 | runningappbar.cpp \ | 60 | runningappbar.cpp \ |
59 | applauncher.cpp \ | 61 | applauncher.cpp \ |
60 | stabmon.cpp \ | 62 | stabmon.cpp \ |
61 | inputmethods.cpp \ | 63 | inputmethods.cpp \ |
62 | systray.cpp \ | 64 | systray.cpp \ |
63 | wait.cpp \ | 65 | wait.cpp \ |
64 | shutdownimpl.cpp \ | 66 | shutdownimpl.cpp \ |
65 | launcher.cpp \ | 67 | launcher.cpp \ |
66 | launcherview.cpp \ | 68 | launcherview.cpp \ |
67 | $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ | 69 | $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ |
68 | transferserver.cpp \ | 70 | transferserver.cpp \ |
69 | packageslave.cpp \ | 71 | packageslave.cpp \ |
70 | irserver.cpp \ | 72 | irserver.cpp \ |
71 | qcopbridge.cpp \ | 73 | qcopbridge.cpp \ |
72 | startmenu.cpp \ | 74 | startmenu.cpp \ |
73 | main.cpp \ | 75 | main.cpp \ |
74 | firstuse.cpp \ | 76 | firstuse.cpp \ |
75 | $$(OPIEDIR)/rsync/base64.c \ | 77 | $$(OPIEDIR)/rsync/base64.c \ |
76 | $$(OPIEDIR)/rsync/buf.c \ | 78 | $$(OPIEDIR)/rsync/buf.c \ |
77 | $$(OPIEDIR)/rsync/checksum.c \ | 79 | $$(OPIEDIR)/rsync/checksum.c \ |
78 | $$(OPIEDIR)/rsync/command.c \ | 80 | $$(OPIEDIR)/rsync/command.c \ |
79 | $$(OPIEDIR)/rsync/delta.c \ | 81 | $$(OPIEDIR)/rsync/delta.c \ |
80 | $$(OPIEDIR)/rsync/emit.c \ | 82 | $$(OPIEDIR)/rsync/emit.c \ |
81 | $$(OPIEDIR)/rsync/hex.c \ | 83 | $$(OPIEDIR)/rsync/hex.c \ |
82 | $$(OPIEDIR)/rsync/job.c \ | 84 | $$(OPIEDIR)/rsync/job.c \ |
83 | $$(OPIEDIR)/rsync/mdfour.c \ | 85 | $$(OPIEDIR)/rsync/mdfour.c \ |
84 | $$(OPIEDIR)/rsync/mksum.c \ | 86 | $$(OPIEDIR)/rsync/mksum.c \ |
85 | $$(OPIEDIR)/rsync/msg.c \ | 87 | $$(OPIEDIR)/rsync/msg.c \ |
86 | $$(OPIEDIR)/rsync/netint.c \ | 88 | $$(OPIEDIR)/rsync/netint.c \ |
87 | $$(OPIEDIR)/rsync/patch.c \ | 89 | $$(OPIEDIR)/rsync/patch.c \ |
88 | $$(OPIEDIR)/rsync/prototab.c \ | 90 | $$(OPIEDIR)/rsync/prototab.c \ |
89 | $$(OPIEDIR)/rsync/readsums.c \ | 91 | $$(OPIEDIR)/rsync/readsums.c \ |
90 | $$(OPIEDIR)/rsync/scoop.c \ | 92 | $$(OPIEDIR)/rsync/scoop.c \ |
91 | $$(OPIEDIR)/rsync/search.c \ | 93 | $$(OPIEDIR)/rsync/search.c \ |
92 | $$(OPIEDIR)/rsync/stats.c \ | 94 | $$(OPIEDIR)/rsync/stats.c \ |
93 | $$(OPIEDIR)/rsync/stream.c \ | 95 | $$(OPIEDIR)/rsync/stream.c \ |
94 | $$(OPIEDIR)/rsync/sumset.c \ | 96 | $$(OPIEDIR)/rsync/sumset.c \ |
95 | $$(OPIEDIR)/rsync/trace.c \ | 97 | $$(OPIEDIR)/rsync/trace.c \ |
96 | $$(OPIEDIR)/rsync/tube.c \ | 98 | $$(OPIEDIR)/rsync/tube.c \ |
97 | $$(OPIEDIR)/rsync/util.c \ | 99 | $$(OPIEDIR)/rsync/util.c \ |
98 | $$(OPIEDIR)/rsync/version.c \ | 100 | $$(OPIEDIR)/rsync/version.c \ |
99 | $$(OPIEDIR)/rsync/whole.c \ | 101 | $$(OPIEDIR)/rsync/whole.c \ |
100 | $$(OPIEDIR)/rsync/qrsync.cpp \ | 102 | $$(OPIEDIR)/rsync/qrsync.cpp \ |
101 | syncdialog.cpp \ | 103 | syncdialog.cpp \ |
102 | serverapp.cpp \ | 104 | serverapp.cpp \ |
103 | qprocess.cpp \ | 105 | qprocess.cpp \ |
104 | qprocess_unix.cpp \ | 106 | qprocess_unix.cpp \ |
105 | screensaver.cpp | 107 | screensaver.cpp \ |
108 | $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.cc \ | ||
109 | mediadlg.cpp | ||
106 | 110 | ||
107 | 111 | ||
108 | INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate | 112 | INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate |
109 | DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate | 113 | DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate |
110 | 114 | ||
111 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync | 115 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync |
112 | DEPENDPATH+= $(OPIEDIR)/rsync | 116 | DEPENDPATH+= $(OPIEDIR)/rsync |
113 | 117 | ||
118 | INCLUDEPATH += $(OPIEDIR)/noncore/settings/mediummount | ||
119 | DEPENDPATH+= $(OPIEDIR)/noncore/settings/mediummount | ||
120 | |||
121 | |||
114 | TARGET = qpe | 122 | TARGET = qpe |
115 | 123 | ||
116 | #needs OWait and ODevice | 124 | #needs OWait and ODevice |
117 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 125 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
118 | contains( CONFTEST, y ){ | 126 | contains( CONFTEST, y ){ |
119 | LIBS += -lqpe -lopiecore2 -lopieui2 | 127 | LIBS += -lqpe -lopiecore2 -lopieui2 |
120 | }else{ | 128 | }else{ |
121 | LIBS+= -lcrypt -lqpe -lopiecore2 -lopieui2 | 129 | LIBS+= -lcrypt -lqpe -lopiecore2 -lopieui2 |
122 | } | 130 | } |
123 | 131 | ||
124 | include ( $(OPIEDIR)/include.pro ) | 132 | include ( $(OPIEDIR)/include.pro ) |