summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp610
-rw-r--r--core/launcher/documentlist.h3
-rw-r--r--core/launcher/launcher.cpp107
-rw-r--r--core/launcher/launcher.h1
-rw-r--r--core/launcher/launcherview.cpp4
-rw-r--r--core/launcher/server.cpp210
6 files changed, 483 insertions, 452 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index d8e7a83..9781a32 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -79,479 +79,487 @@ public:
79 unsigned int docPathsSearched; 79 unsigned int docPathsSearched;
80 80
81 int searchDepth; 81 int searchDepth;
82 QDir *listDirs[MAX_SEARCH_DEPTH]; 82 QDir *listDirs[MAX_SEARCH_DEPTH];
83 const QFileInfoList *lists[MAX_SEARCH_DEPTH]; 83 const QFileInfoList *lists[MAX_SEARCH_DEPTH];
84 unsigned int listPositions[MAX_SEARCH_DEPTH]; 84 unsigned int listPositions[MAX_SEARCH_DEPTH];
85 85
86 StorageInfo *storage; 86 StorageInfo *storage;
87 87
88 int tid; 88 int tid;
89 89
90 ServerInterface *serverGui; 90 ServerInterface *serverGui;
91 91
92 bool needToSendAllDocLinks; 92 bool needToSendAllDocLinks;
93 bool sendAppLnks; 93 bool sendAppLnks;
94 bool sendDocLnks; 94 bool sendDocLnks;
95 bool scanDocs; 95 bool scanDocs;
96}; 96};
97 97
98 98
99/* 99/*
100 * scandocs will be read from Config 100 * scandocs will be read from Config
101 */ 101 */
102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, 102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
103 QObject *parent, const char *name ) 103 QObject *parent, const char *name )
104 : QObject( parent, name ) 104 : QObject( parent, name )
105{ 105{
106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
107 d = new DocumentListPrivate( serverGui ); 107 d = new DocumentListPrivate( serverGui );
108 d->needToSendAllDocLinks = false; 108 d->needToSendAllDocLinks = false;
109 109
110 Config cfg( "Launcher" ); 110 Config cfg( "Launcher" );
111 cfg.setGroup( "DocTab" ); 111 cfg.setGroup( "DocTab" );
112 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 112 d->scanDocs = cfg.readBoolEntry( "Enable", true );
113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl; 113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl;
114 114
115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); 115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
116} 116}
117 117
118void DocumentList::startInitialScan() 118void DocumentList::startInitialScan()
119{ 119{
120 reloadAppLnks(); 120 reloadAppLnks();
121 reloadDocLnks(); 121 reloadDocLnks();
122} 122}
123 123
124DocumentList::~DocumentList() 124DocumentList::~DocumentList()
125{ 125{
126 delete appLnkSet; 126 delete appLnkSet;
127 delete d; 127 delete d;
128} 128}
129 129
130 130
131void DocumentList::add( const DocLnk& doc ) 131void DocumentList::add( const DocLnk& doc )
132{ 132{
133 if ( d->serverGui && QFile::exists( doc.file() ) ) 133 if ( d->serverGui && QFile::exists( doc.file() ) )
134 d->serverGui->documentAdded( doc ); 134 d->serverGui->documentAdded( doc );
135} 135}
136 136
137 137
138void DocumentList::start() 138void DocumentList::start()
139{ 139{
140 resume(); 140 resume();
141} 141}
142 142
143 143
144void DocumentList::pause() 144void DocumentList::pause()
145{ 145{
146 //odebug << "pause " << d->tid << "" << oendl; 146 //odebug << "pause " << d->tid << "" << oendl;
147 killTimer( d->tid ); 147 killTimer( d->tid );
148 d->tid = 0; 148 d->tid = 0;
149} 149}
150 150
151 151
152void DocumentList::resume() 152void DocumentList::resume()
153{ 153{
154 if ( d->tid == 0 ) { 154 if ( d->tid == 0 ) {
155 d->tid = startTimer( 20 ); 155 d->tid = startTimer( 20 );
156 //odebug << "resumed " << d->tid << "" << oendl; 156 //odebug << "resumed " << d->tid << "" << oendl;
157 } 157 }
158} 158}
159 159
160/* 160/*
161void DocumentList::resend() 161void DocumentList::resend()
162{ 162{
163 // Re-emits all the added items to the list (firstly letting everyone know to 163 // Re-emits all the added items to the list (firstly letting everyone know to
164 // clear what they have as it is being sent again) 164 // clear what they have as it is being sent again)
165 pause(); 165 pause();
166 emit allRemoved(); 166 emit allRemoved();
167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); 167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) );
168} 168}
169 169
170 170
171void DocumentList::resendWorker() 171void DocumentList::resendWorker()
172{ 172{
173 const QList<DocLnk> &list = d->dls.children(); 173 const QList<DocLnk> &list = d->dls.children();
174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) 174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it )
175 add( *(*it) ); 175 add( *(*it) );
176 resume(); 176 resume();
177} 177}
178*/ 178*/
179 179
180void DocumentList::rescan() 180void DocumentList::rescan()
181{ 181{
182 //odebug << "rescan" << oendl; 182 //odebug << "rescan" << oendl;
183 pause(); 183 pause();
184 d->initialize(); 184 d->initialize();
185 resume(); 185 resume();
186} 186}
187 187
188 188
189void DocumentList::timerEvent( QTimerEvent *te ) 189void DocumentList::timerEvent( QTimerEvent *te )
190{ 190{
191 if ( te->timerId() == d->tid ) { 191 if ( te->timerId() == d->tid ) {
192 // Do 3 at a time 192 // Do 3 at a time
193 if ( d->serverGui ) 193 if ( d->serverGui )
194 d->serverGui->aboutToAddBegin(); 194 d->serverGui->aboutToAddBegin();
195 for (int i = 0; i < 3; i++ ) { 195 for (int i = 0; i < 3; i++ ) {
196 const DocLnk *lnk = d->iterate(); 196 const DocLnk *lnk = d->iterate();
197 if ( lnk ) { 197 if ( lnk ) {
198 add( *lnk ); 198 add( *lnk );
199 } else { 199 } else {
200 // stop when done 200 // stop when done
201 pause(); 201 pause();
202 if ( d->serverGui ) 202 if ( d->serverGui )
203 d->serverGui->documentScanningProgress( 100 ); 203 d->serverGui->documentScanningProgress( 100 );
204 if ( d->needToSendAllDocLinks ) 204 if ( d->needToSendAllDocLinks )
205 sendAllDocLinks(); 205 sendAllDocLinks();
206 break; 206 break;
207 } 207 }
208 } 208 }
209 if ( d->serverGui ) 209 if ( d->serverGui )
210 d->serverGui->aboutToAddEnd(); 210 d->serverGui->aboutToAddEnd();
211 } 211 }
212} 212}
213 213
214 214
215void DocumentList::reloadAppLnks() 215void DocumentList::reloadAppLnks()
216{ 216{
217 if ( d->sendAppLnks && d->serverGui ) { 217 if ( d->sendAppLnks && d->serverGui ) {
218 d->serverGui->applicationScanningProgress( 0 ); 218 d->serverGui->applicationScanningProgress( 0 );
219 d->serverGui->allApplicationsRemoved(); 219 d->serverGui->allApplicationsRemoved();
220 } 220 }
221 221
222 delete appLnkSet; 222 delete appLnkSet;
223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
224 224
225 if ( d->sendAppLnks && d->serverGui ) { 225 if ( d->sendAppLnks && d->serverGui ) {
226 static QStringList prevTypeList; 226 static QStringList prevTypeList;
227 QStringList types = appLnkSet->types(); 227 QStringList types = appLnkSet->types();
228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
229 if ( !(*ittypes).isEmpty() ) { 229 if ( !(*ittypes).isEmpty() ) {
230 if ( !prevTypeList.contains(*ittypes) ) { 230 if ( !prevTypeList.contains(*ittypes) ) {
231 QString name = appLnkSet->typeName(*ittypes); 231 QString name = appLnkSet->typeName(*ittypes);
232 QPixmap pm = appLnkSet->typePixmap(*ittypes); 232 QPixmap pm = appLnkSet->typePixmap(*ittypes);
233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
234 234
235 if (pm.isNull()) { 235 if (pm.isNull()) {
236 QImage img( Resource::loadImage( "UnknownDocument" ) ); 236 QImage img( Resource::loadImage( "UnknownDocument" ) );
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
239 } 239 }
240 240
241 //odebug << "adding type " << (*ittypes) << "" << oendl; 241 //odebug << "adding type " << (*ittypes) << "" << oendl;
242 242
243 // ### our current launcher expects docs tab to be last 243 // ### our current launcher expects docs tab to be last
244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
245 } 245 }
246 prevTypeList.remove(*ittypes); 246 prevTypeList.remove(*ittypes);
247 } 247 }
248 } 248 }
249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
250 //odebug << "removing type " << (*ittypes) << "" << oendl; 250 //odebug << "removing type " << (*ittypes) << "" << oendl;
251 d->serverGui->typeRemoved(*ittypes); 251 d->serverGui->typeRemoved(*ittypes);
252 } 252 }
253 prevTypeList = types; 253 prevTypeList = types;
254 } 254 }
255 255
256 QListIterator<AppLnk> itapp( appLnkSet->children() ); 256 QListIterator<AppLnk> itapp( appLnkSet->children() );
257 AppLnk* l; 257 AppLnk* l;
258 while ( (l=itapp.current()) ) { 258 while ( (l=itapp.current()) ) {
259 ++itapp; 259 ++itapp;
260 if ( d->sendAppLnks && d->serverGui ) 260 if ( d->sendAppLnks && d->serverGui )
261 d->serverGui->applicationAdded( l->type(), *l ); 261 d->serverGui->applicationAdded( l->type(), *l );
262 } 262 }
263 263
264 if ( d->sendAppLnks && d->serverGui ) 264 if ( d->sendAppLnks && d->serverGui )
265 d->serverGui->applicationScanningProgress( 100 ); 265 d->serverGui->applicationScanningProgress( 100 );
266} 266}
267 267
268void DocumentList::reloadDocLnks() 268void DocumentList::reloadDocLnks()
269{ 269{
270 if ( !d->scanDocs ) 270 if ( !d->scanDocs )
271 return; 271 return;
272 272
273 if ( d->sendDocLnks && d->serverGui ) { 273 if ( d->sendDocLnks && d->serverGui ) {
274 d->serverGui->documentScanningProgress( 0 ); 274 d->serverGui->documentScanningProgress( 0 );
275 d->serverGui->allDocumentsRemoved(); 275 d->serverGui->allDocumentsRemoved();
276 } 276 }
277 277
278 rescan(); 278 rescan();
279} 279}
280 280
281void DocumentList::reforceDocuments()
282{
283 Config cfg( "Launcher" );
284 cfg.setGroup( "DocTab" );
285 d->scanDocs = cfg.readBoolEntry( "Enable", true );
286 reloadDocLnks();
287}
288
281void DocumentList::linkChanged( QString arg ) 289void DocumentList::linkChanged( QString arg )
282{ 290{
283 //odebug << "linkchanged( " << arg << " )" << oendl; 291 odebug << "linkchanged( " << arg << " )" << oendl;
284 292
285 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 293 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
286 reloadAppLnks(); 294 reloadAppLnks();
287 } else { 295 } else {
288 296
289 const QList<DocLnk> &list = d->dls.children(); 297 const QList<DocLnk> &list = d->dls.children();
290 QListIterator<DocLnk> it( list ); 298 QListIterator<DocLnk> it( list );
291 while ( it.current() ) { 299 while ( it.current() ) {
292 DocLnk *doc = it.current(); 300 DocLnk *doc = it.current();
293 ++it; 301 ++it;
294 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 302 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
295 || ( doc->fileKnown() && doc->file() == arg ) ) { 303 || ( doc->fileKnown() && doc->file() == arg ) ) {
296 //odebug << "found old link" << oendl; 304 //odebug << "found old link" << oendl;
297 DocLnk* dl = new DocLnk( arg ); 305 DocLnk* dl = new DocLnk( arg );
298 // add new one if it exists and matches the mimetype 306 // add new one if it exists and matches the mimetype
299 if ( d->store( dl ) ) { 307 if ( d->store( dl ) ) {
300 // Existing link has been changed, send old link ref and a ref 308 // Existing link has been changed, send old link ref and a ref
301 // to the new link 309 // to the new link
302 //odebug << "change case" << oendl; 310 //odebug << "change case" << oendl;
303 if ( d->serverGui ) 311 if ( d->serverGui )
304 d->serverGui->documentChanged( *doc, *dl ); 312 d->serverGui->documentChanged( *doc, *dl );
305 313
306 } else { 314 } else {
307 // Link has been removed or doesn't match the mimetypes any more 315 // Link has been removed or doesn't match the mimetypes any more
308 // so we aren't interested in it, so take it away from the list 316 // so we aren't interested in it, so take it away from the list
309 //odebug << "removal case" << oendl; 317 //odebug << "removal case" << oendl;
310 if ( d->serverGui ) 318 if ( d->serverGui )
311 d->serverGui->documentRemoved( *doc ); 319 d->serverGui->documentRemoved( *doc );
312 320
313 } 321 }
314 d->dls.remove( doc ); // remove old link from docLnkSet 322 d->dls.remove( doc ); // remove old link from docLnkSet
315 delete doc; 323 delete doc;
316 return; 324 return;
317 } 325 }
318 } 326 }
319 // Didn't find existing link, must be new 327 // Didn't find existing link, must be new
320 DocLnk* dl = new DocLnk( arg ); 328 DocLnk* dl = new DocLnk( arg );
321 if ( d->store( dl ) ) { 329 if ( d->store( dl ) ) {
322 // Add if it's a link we are interested in 330 // Add if it's a link we are interested in
323 //odebug << "add case" << oendl; 331 //odebug << "add case" << oendl;
324 add( *dl ); 332 add( *dl );
325 } 333 }
326 334
327 } 335 }
328} 336}
329 337
330void DocumentList::restoreDone() 338void DocumentList::restoreDone()
331{ 339{
332 reloadAppLnks(); 340 reloadAppLnks();
333 reloadDocLnks(); 341 reloadDocLnks();
334} 342}
335 343
336void DocumentList::DiffAppLnks() 344void DocumentList::DiffAppLnks()
337{ 345{
338 static AppLnkSet *appLnkSet2; 346 static AppLnkSet *appLnkSet2;
339 347
340 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
341 349
342 if ( d->sendAppLnks && d->serverGui ) { 350 if ( d->sendAppLnks && d->serverGui ) {
343 static QStringList prevTypeList = appLnkSet->types(); 351 static QStringList prevTypeList = appLnkSet->types();
344 QStringList types = appLnkSet2->types(); 352 QStringList types = appLnkSet2->types();
345 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
346 if ( !(*ittypes).isEmpty() ) { 354 if ( !(*ittypes).isEmpty() ) {
347 if ( !prevTypeList.contains(*ittypes) ) { 355 if ( !prevTypeList.contains(*ittypes) ) {
348 QString name = appLnkSet2->typeName(*ittypes); 356 QString name = appLnkSet2->typeName(*ittypes);
349 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 357 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
350 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
351 359
352 if (pm.isNull()) { 360 if (pm.isNull()) {
353 QImage img( Resource::loadImage( "UnknownDocument" ) ); 361 QImage img( Resource::loadImage( "UnknownDocument" ) );
354 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
355 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
356 } 364 }
357 365
358 odebug << "adding type " << (*ittypes) << "" << oendl; 366 odebug << "adding type " << (*ittypes) << "" << oendl;
359 367
360 // ### our current launcher expects docs tab to be last 368 // ### our current launcher expects docs tab to be last
361 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
362 } 370 }
363 prevTypeList.remove(*ittypes); 371 prevTypeList.remove(*ittypes);
364 } 372 }
365 } 373 }
366 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
367 odebug << "removing type " << (*ittypes) << "" << oendl; 375 odebug << "removing type " << (*ittypes) << "" << oendl;
368 d->serverGui->typeRemoved(*ittypes); 376 d->serverGui->typeRemoved(*ittypes);
369 } 377 }
370 prevTypeList = types; 378 prevTypeList = types;
371 } 379 }
372 380
373 381
374 QListIterator<AppLnk> it1( appLnkSet->children() ); 382 QListIterator<AppLnk> it1( appLnkSet->children() );
375 QListIterator<AppLnk> it2( appLnkSet2->children() ); 383 QListIterator<AppLnk> it2( appLnkSet2->children() );
376 384
377 AppLnk *i; 385 AppLnk *i;
378 AppLnk *j; 386 AppLnk *j;
379 bool found; 387 bool found;
380 388
381 while ( (j=it2.current()) ) { 389 while ( (j=it2.current()) ) {
382 it1 = appLnkSet->children(); 390 it1 = appLnkSet->children();
383 found = false; 391 found = false;
384 while ( (i=it1.current()) ){ 392 while ( (i=it1.current()) ){
385 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 393 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
386 found = true; 394 found = true;
387 ++it1; 395 ++it1;
388 } 396 }
389 if (!found) { 397 if (!found) {
390 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; 398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
391 d->serverGui->applicationAdded( j->type(), *j ); 399 d->serverGui->applicationAdded( j->type(), *j );
392 } 400 }
393 ++it2; 401 ++it2;
394 } 402 }
395 403
396 it1 = appLnkSet->children(); 404 it1 = appLnkSet->children();
397 while ( (i=it1.current()) ) { 405 while ( (i=it1.current()) ) {
398 it2 = appLnkSet2->children(); 406 it2 = appLnkSet2->children();
399 found = false; 407 found = false;
400 while ( (j=it2.current()) ){ 408 while ( (j=it2.current()) ){
401 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 409 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
402 found = true; 410 found = true;
403 ++it2; 411 ++it2;
404 } 412 }
405 if (!found) { 413 if (!found) {
406 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; 414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
407 d->serverGui->applicationRemoved( i->type(), *i ); 415 d->serverGui->applicationRemoved( i->type(), *i );
408 } 416 }
409 417
410 ++it1; 418 ++it1;
411 } 419 }
412 420
413 delete appLnkSet; 421 delete appLnkSet;
414 appLnkSet = appLnkSet2; 422 appLnkSet = appLnkSet2;
415 423
416} 424}
417void DocumentList::storageChanged() 425void DocumentList::storageChanged()
418{ 426{
419 QTime t; 427 QTime t;
420 // ### can implement better 428 // ### can implement better
421 429
422 t.start(); 430 t.start();
423 DiffAppLnks(); 431 DiffAppLnks();
424// reloadAppLnks(); 432// reloadAppLnks();
425 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; 433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
426 reloadDocLnks(); 434 reloadDocLnks();
427// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
428 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; 436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
429// ### Optimization opportunity 437// ### Optimization opportunity
430 // Could be a bit more intelligent and somehow work out which 438 // Could be a bit more intelligent and somehow work out which
431 // mtab entry has changed and then only scan that and add and remove 439 // mtab entry has changed and then only scan that and add and remove
432 // links appropriately. 440 // links appropriately.
433// rescan(); 441// rescan();
434} 442}
435 443
436void DocumentList::sendAllDocLinks() 444void DocumentList::sendAllDocLinks()
437{ 445{
438 if ( d->tid != 0 ) { 446 if ( d->tid != 0 ) {
439 // We are in the middle of scanning, set a flag so 447 // We are in the middle of scanning, set a flag so
440 // we do this when we finish our scanning 448 // we do this when we finish our scanning
441 d->needToSendAllDocLinks = true; 449 d->needToSendAllDocLinks = true;
442 return; 450 return;
443 } 451 }
444 452
445 QString contents; 453 QString contents;
446 Categories cats; 454 Categories cats;
447 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
448 DocLnk *doc = it.current(); 456 DocLnk *doc = it.current();
449 QFileInfo fi( doc->file() ); 457 QFileInfo fi( doc->file() );
450 if ( !fi.exists() ) 458 if ( !fi.exists() )
451 continue; 459 continue;
452 460
453 bool fake = !doc->linkFileKnown(); 461 bool fake = !doc->linkFileKnown();
454 if ( !fake ) { 462 if ( !fake ) {
455 QFile f( doc->linkFile() ); 463 QFile f( doc->linkFile() );
456 if ( f.open( IO_ReadOnly ) ) { 464 if ( f.open( IO_ReadOnly ) ) {
457 QTextStream ts( &f ); 465 QTextStream ts( &f );
458 ts.setEncoding( QTextStream::UnicodeUTF8 ); 466 ts.setEncoding( QTextStream::UnicodeUTF8 );
459 QString docLnk = ts.read(); 467 QString docLnk = ts.read();
460 // Strip out the (stale) LinkFile entry 468 // Strip out the (stale) LinkFile entry
461 int start = docLnk.find( "\nLinkFile = " ) + 1; 469 int start = docLnk.find( "\nLinkFile = " ) + 1;
462 if ( start > 0 ) { 470 if ( start > 0 ) {
463 int end = docLnk.find( "\n", start + 1 ) + 1; 471 int end = docLnk.find( "\n", start + 1 ) + 1;
464 contents += docLnk.left(start); 472 contents += docLnk.left(start);
465 contents += docLnk.mid(end); 473 contents += docLnk.mid(end);
466 } else { 474 } else {
467 contents += docLnk; 475 contents += docLnk;
468 } 476 }
469 contents += "LinkFile = " + doc->linkFile() + "\n"; 477 contents += "LinkFile = " + doc->linkFile() + "\n";
470 478
471 f.close(); 479 f.close();
472 } else 480 } else
473 fake = TRUE; 481 fake = TRUE;
474 } 482 }
475 if (fake) { 483 if (fake) {
476 contents += "[Desktop Entry]\n"; // No tr 484 contents += "[Desktop Entry]\n"; // No tr
477 contents += "Categories = " + // No tr 485 contents += "Categories = " + // No tr
478 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 486 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
479 contents += "Name = "+doc->name()+"\n"; // No tr 487 contents += "Name = "+doc->name()+"\n"; // No tr
480 contents += "Type = "+doc->type()+"\n"; // No tr 488 contents += "Type = "+doc->type()+"\n"; // No tr
481 } 489 }
482 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 490 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
483 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 491 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
484 } 492 }
485 493
486 //odebug << "sending length " << contents.length() << "" << oendl; 494 //odebug << "sending length " << contents.length() << "" << oendl;
487#ifndef QT_NO_COP 495#ifndef QT_NO_COP
488 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 496 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
489 e << contents; 497 e << contents;
490#endif 498#endif
491 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 499 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
492 500
493 d->needToSendAllDocLinks = false; 501 d->needToSendAllDocLinks = false;
494} 502}
495 503
496 504
497 505
498 506
499 507
500 508
501 509
502 510
503 511
504 512
505 513
506 514
507 515
508 516
509 517
510 518
511 519
512 520
513 521
514 522
515 523
516 524
517 525
518 526
519DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 527DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
520{ 528{
521 storage = new StorageInfo( this ); 529 storage = new StorageInfo( this );
522 serverGui = gui; 530 serverGui = gui;
523 if ( serverGui ) { 531 if ( serverGui ) {
524 sendAppLnks = serverGui->requiresApplications(); 532 sendAppLnks = serverGui->requiresApplications();
525 sendDocLnks = serverGui->requiresDocuments(); 533 sendDocLnks = serverGui->requiresDocuments();
526 } else { 534 } else {
527 sendAppLnks = false; 535 sendAppLnks = false;
528 sendDocLnks = false; 536 sendDocLnks = false;
529 } 537 }
530 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 538 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
531 listDirs[i] = 0; 539 listDirs[i] = 0;
532 lists[i] = 0; 540 lists[i] = 0;
533 listPositions[i] = 0; 541 listPositions[i] = 0;
534 } 542 }
535 initialize(); 543 initialize();
536 tid = 0; 544 tid = 0;
537} 545}
538 546
539void DocumentListPrivate::appendDocpath(FileSystem*fs) 547void DocumentListPrivate::appendDocpath(FileSystem*fs)
540{ 548{
541 QDir defPath(fs->path()+"/Documents"); 549 QDir defPath(fs->path()+"/Documents");
542 QFileInfo f(fs->path()+"/.opiestorage.cf"); 550 QFileInfo f(fs->path()+"/.opiestorage.cf");
543 if (!f.exists()) { 551 if (!f.exists()) {
544 Mediadlg dlg(fs); 552 Mediadlg dlg(fs);
545 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { 553 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) {
546 return; 554 return;
547 } 555 }
548 } 556 }
549 Config conf(f.filePath(), Config::File ); 557 Config conf(f.filePath(), Config::File );
550 conf.setGroup("main"); 558 conf.setGroup("main");
551 if (!conf.readBoolEntry("check",false)) { 559 if (!conf.readBoolEntry("check",false)) {
552 return; 560 return;
553 } 561 }
554 conf.setGroup("subdirs"); 562 conf.setGroup("subdirs");
555 bool read_all = conf.readBoolEntry("wholemedia",true); 563 bool read_all = conf.readBoolEntry("wholemedia",true);
556 if (read_all) { 564 if (read_all) {
557 docPaths+=fs->path(); 565 docPaths+=fs->path();
@@ -560,244 +568,244 @@ void DocumentListPrivate::appendDocpath(FileSystem*fs)
560 QStringList subDirs = conf.readListEntry("subdirs",':'); 568 QStringList subDirs = conf.readListEntry("subdirs",':');
561 if (subDirs.isEmpty()) { 569 if (subDirs.isEmpty()) {
562 if (defPath.exists()) { 570 if (defPath.exists()) {
563 docPaths+=defPath.path(); 571 docPaths+=defPath.path();
564 } 572 }
565 return; 573 return;
566 } 574 }
567 for (unsigned c = 0; c < subDirs.count();++c) { 575 for (unsigned c = 0; c < subDirs.count();++c) {
568 QDir docDir(QString(fs->path()+"/"+subDirs[c])); 576 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
569 if (docDir.exists()) { 577 if (docDir.exists()) {
570 docPaths+=docDir.path(); 578 docPaths+=docDir.path();
571 } 579 }
572 } 580 }
573} 581}
574 582
575void DocumentListPrivate::initialize() 583void DocumentListPrivate::initialize()
576{ 584{
577 // Reset 585 // Reset
578 dls.clear(); 586 dls.clear();
579 docPaths.clear(); 587 docPaths.clear();
580 reference.clear(); 588 reference.clear();
581 589
582 QDir docDir( QPEApplication::documentDir() ); 590 QDir docDir( QPEApplication::documentDir() );
583 if ( docDir.exists() ) 591 if ( docDir.exists() )
584 docPaths += QPEApplication::documentDir(); 592 docPaths += QPEApplication::documentDir();
585 int i = 1; 593 int i = 1;
586 const QList<FileSystem> &fs = storage->fileSystems(); 594 const QList<FileSystem> &fs = storage->fileSystems();
587 QListIterator<FileSystem> it( fs ); 595 QListIterator<FileSystem> it( fs );
588 for ( ; it.current(); ++it ) { 596 for ( ; it.current(); ++it ) {
589 if ( (*it)->isRemovable() ) { 597 if ( (*it)->isRemovable() ) {
590 appendDocpath((*it)); 598 appendDocpath((*it));
591 ++i; 599 ++i;
592 } 600 }
593 } 601 }
594 602
595 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { 603 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) {
596 if ( listDirs[i] ) { 604 if ( listDirs[i] ) {
597 delete listDirs[i]; 605 delete listDirs[i];
598 listDirs[i] = 0; 606 listDirs[i] = 0;
599 } 607 }
600 lists[i] = 0; 608 lists[i] = 0;
601 listPositions[i] = 0; 609 listPositions[i] = 0;
602 } 610 }
603 611
604 docPathsSearched = 0; 612 docPathsSearched = 0;
605 searchDepth = -1; 613 searchDepth = -1;
606 state = Find; 614 state = Find;
607 dit = 0; 615 dit = 0;
608} 616}
609 617
610 618
611DocumentListPrivate::~DocumentListPrivate() 619DocumentListPrivate::~DocumentListPrivate()
612{ 620{
613 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) 621 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ )
614 if ( listDirs[i] ) 622 if ( listDirs[i] )
615 delete listDirs[i]; 623 delete listDirs[i];
616 delete dit; 624 delete dit;
617} 625}
618 626
619 627
620void DocumentListPrivate::estimatedPercentScanned() 628void DocumentListPrivate::estimatedPercentScanned()
621{ 629{
622 double overallProgress = 0.0; 630 double overallProgress = 0.0;
623 double levelWeight = 75.0; 631 double levelWeight = 75.0;
624 632
625 int topCount = docPaths.count(); 633 int topCount = docPaths.count();
626 if ( topCount > 1 ) { 634 if ( topCount > 1 ) {
627 levelWeight = levelWeight / topCount; 635 levelWeight = levelWeight / topCount;
628 overallProgress += (docPathsSearched - 1) * levelWeight; 636 overallProgress += (docPathsSearched - 1) * levelWeight;
629 } 637 }
630 638
631 for ( int d = 0; d <= searchDepth; d++ ) { 639 for ( int d = 0; d <= searchDepth; d++ ) {
632 if ( listDirs[d] ) { 640 if ( listDirs[d] ) {
633 int items = lists[d]->count(); 641 int items = lists[d]->count();
634 if ( items > 1 ) { 642 if ( items > 1 ) {
635 levelWeight = levelWeight / items; 643 levelWeight = levelWeight / items;
636 // Take in to account "." and ".." 644 // Take in to account "." and ".."
637 overallProgress += (listPositions[d] - 3) * levelWeight; 645 overallProgress += (listPositions[d] - 3) * levelWeight;
638 } 646 }
639 } else { 647 } else {
640 break; 648 break;
641 } 649 }
642 } 650 }
643 651
644 // odebug << "overallProgress: " << overallProgress << "" << oendl; 652 // odebug << "overallProgress: " << overallProgress << "" << oendl;
645 653
646 if ( serverGui ) 654 if ( serverGui )
647 serverGui->documentScanningProgress( (int)overallProgress ); 655 serverGui->documentScanningProgress( (int)overallProgress );
648} 656}
649 657
650 658
651const QString DocumentListPrivate::nextFile() 659const QString DocumentListPrivate::nextFile()
652{ 660{
653 while ( TRUE ) { 661 while ( TRUE ) {
654 while ( searchDepth < 0 ) { 662 while ( searchDepth < 0 ) {
655 // go to next base path 663 // go to next base path
656 if ( docPathsSearched >= docPaths.count() ) { 664 if ( docPathsSearched >= docPaths.count() ) {
657 // end of base paths 665 // end of base paths
658 return QString::null; 666 return QString::null;
659 } else { 667 } else {
660 QDir dir( docPaths[docPathsSearched] ); 668 QDir dir( docPaths[docPathsSearched] );
661 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; 669 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
662 docPathsSearched++; 670 docPathsSearched++;
663 if ( !dir.exists( ".Qtopia-ignore" ) ) { 671 if ( !dir.exists( ".Qtopia-ignore" ) ) {
664 listDirs[0] = new QDir( dir ); 672 listDirs[0] = new QDir( dir );
665 lists[0] = listDirs[0]->entryInfoList(); 673 lists[0] = listDirs[0]->entryInfoList();
666 listPositions[0] = 0; 674 listPositions[0] = 0;
667 searchDepth = 0; 675 searchDepth = 0;
668 } 676 }
669 } 677 }
670 } 678 }
671 679
672 const QFileInfoList *fil = lists[searchDepth]; 680 const QFileInfoList *fil = lists[searchDepth];
673 if (!fil) { 681 if (!fil) {
674 return QString::null; 682 return QString::null;
675 } 683 }
676 QFileInfoList *fl = (QFileInfoList *)fil; 684 QFileInfoList *fl = (QFileInfoList *)fil;
677 unsigned int pos = listPositions[searchDepth]; 685 unsigned int pos = listPositions[searchDepth];
678 686
679 if ( pos >= fl->count() ) { 687 if ( pos >= fl->count() ) {
680 // go up a depth 688 // go up a depth
681 delete listDirs[searchDepth]; 689 delete listDirs[searchDepth];
682 listDirs[searchDepth] = 0; 690 listDirs[searchDepth] = 0;
683 lists[searchDepth] = 0; 691 lists[searchDepth] = 0;
684 listPositions[searchDepth] = 0; 692 listPositions[searchDepth] = 0;
685 searchDepth--; 693 searchDepth--;
686 } else { 694 } else {
687 const QFileInfo *fi = fl->at(pos); 695 const QFileInfo *fi = fl->at(pos);
688 listPositions[searchDepth]++; 696 listPositions[searchDepth]++;
689 QString bn = fi->fileName(); 697 QString bn = fi->fileName();
690 if ( bn[0] != '.' ) { 698 if ( bn[0] != '.' ) {
691 if ( fi->isDir() ) { 699 if ( fi->isDir() ) {
692 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 700 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
693 // go down a depth 701 // go down a depth
694 QDir dir( fi->filePath() ); 702 QDir dir( fi->filePath() );
695 // odebug << "now going in to path: " << bn << "" << oendl; 703 // odebug << "now going in to path: " << bn << "" << oendl;
696 if ( !dir.exists( ".Qtopia-ignore" ) ) { 704 if ( !dir.exists( ".Qtopia-ignore" ) ) {
697 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 705 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
698 searchDepth++; 706 searchDepth++;
699 listDirs[searchDepth] = new QDir( dir ); 707 listDirs[searchDepth] = new QDir( dir );
700 lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); 708 lists[searchDepth] = listDirs[searchDepth]->entryInfoList();
701 listPositions[searchDepth] = 0; 709 listPositions[searchDepth] = 0;
702 } 710 }
703 } 711 }
704 } 712 }
705 } else { 713 } else {
706 estimatedPercentScanned(); 714 estimatedPercentScanned();
707 return fl->at(pos)->filePath(); 715 return fl->at(pos)->filePath();
708 } 716 }
709 } 717 }
710 } 718 }
711 } 719 }
712 720
713 return QString::null; 721 return QString::null;
714} 722}
715 723
716 724
717bool DocumentListPrivate::store( DocLnk* dl ) 725bool DocumentListPrivate::store( DocLnk* dl )
718{ 726{
719 // if ( dl->fileKnown() && !dl->file().isEmpty() ) { 727 // if ( dl->fileKnown() && !dl->file().isEmpty() ) {
720 if ( dl && dl->fileKnown() ) { 728 if ( dl && dl->fileKnown() ) {
721 dls.add( dl ); // store 729 dls.add( dl ); // store
722 return TRUE; 730 return TRUE;
723 } 731 }
724 732
725 // don't store - delete 733 // don't store - delete
726 delete dl; 734 delete dl;
727 return FALSE; 735 return FALSE;
728} 736}
729 737
730 738
731 #define MAGIC_NUMBER((void*)2) 739#define MAGIC_NUMBER ((void*)2)
732 740
733const DocLnk *DocumentListPrivate::iterate() 741const DocLnk *DocumentListPrivate::iterate()
734{ 742{
735 if ( state == Find ) { 743 if ( state == Find ) {
736 //odebug << "state Find" << oendl; 744 //odebug << "state Find" << oendl;
737 QString file = nextFile(); 745 QString file = nextFile();
738 while ( !file.isNull() ) { 746 while ( !file.isNull() ) {
739 if ( file.right(8) == ".desktop" ) { // No tr 747 if ( file.right(8) == ".desktop" ) { // No tr
740 DocLnk* dl = new DocLnk( file ); 748 DocLnk* dl = new DocLnk( file );
741 if ( store(dl) ) 749 if ( store(dl) )
742 return dl; 750 return dl;
743 } else { 751 } else {
744 reference.insert( file, MAGIC_NUMBER ); 752 reference.insert( file, MAGIC_NUMBER );
745 } 753 }
746 file = nextFile(); 754 file = nextFile();
747 } 755 }
748 state = RemoveKnownFiles; 756 state = RemoveKnownFiles;
749 757
750 if ( serverGui ) 758 if ( serverGui )
751 serverGui->documentScanningProgress( 75 ); 759 serverGui->documentScanningProgress( 75 );
752 } 760 }
753 761
754 static int iterationI; 762 static int iterationI;
755 static int iterationCount; 763 static int iterationCount;
756 764
757 if ( state == RemoveKnownFiles ) { 765 if ( state == RemoveKnownFiles ) {
758 //odebug << "state RemoveKnownFiles" << oendl; 766 //odebug << "state RemoveKnownFiles" << oendl;
759 const QList<DocLnk> &list = dls.children(); 767 const QList<DocLnk> &list = dls.children();
760 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { 768 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) {
761 reference.remove( (*it)->file() ); 769 reference.remove( (*it)->file() );
762 // ### does this need to be deleted? 770 // ### does this need to be deleted?
763 } 771 }
764 dit = new QDictIterator<void>(reference); 772 dit = new QDictIterator<void>(reference);
765 state = MakeUnknownFiles; 773 state = MakeUnknownFiles;
766 774
767 iterationI = 0; 775 iterationI = 0;
768 iterationCount = dit->count(); 776 iterationCount = dit->count();
769 } 777 }
770 778
771 if ( state == MakeUnknownFiles ) { 779 if ( state == MakeUnknownFiles ) {
772 //odebug << "state MakeUnknownFiles" << oendl; 780 //odebug << "state MakeUnknownFiles" << oendl;
773 for (void* c; (c=dit->current()); ++(*dit) ) { 781 for (void* c; (c=dit->current()); ++(*dit) ) {
774 if ( c == MAGIC_NUMBER ) { 782 if ( c == MAGIC_NUMBER ) {
775 DocLnk* dl = new DocLnk; 783 DocLnk* dl = new DocLnk;
776 QFileInfo fi( dit->currentKey() ); 784 QFileInfo fi( dit->currentKey() );
777 dl->setFile( fi.filePath() ); 785 dl->setFile( fi.filePath() );
778 dl->setName( fi.baseName() ); 786 dl->setName( fi.baseName() );
779 if ( store(dl) ) { 787 if ( store(dl) ) {
780 ++*dit; 788 ++*dit;
781 iterationI++; 789 iterationI++;
782 if ( serverGui ) 790 if ( serverGui )
783 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); 791 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount );
784 return dl; 792 return dl;
785 } 793 }
786 } 794 }
787 iterationI++; 795 iterationI++;
788 } 796 }
789 797
790 delete dit; 798 delete dit;
791 dit = 0; 799 dit = 0;
792 state = Done; 800 state = Done;
793 } 801 }
794 802
795 //odebug << "state Done" << oendl; 803 //odebug << "state Done" << oendl;
796 return NULL; 804 return NULL;
797} 805}
798 806
799 807
800#include "documentlist.moc" 808#include "documentlist.moc"
801 809
802 810
803 811
diff --git a/core/launcher/documentlist.h b/core/launcher/documentlist.h
index 232bb6a..8b69e95 100644
--- a/core/launcher/documentlist.h
+++ b/core/launcher/documentlist.h
@@ -11,58 +11,59 @@
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#ifndef DOCUMENT_LIST_H 20#ifndef DOCUMENT_LIST_H
21#define DOCUMENT_LIST_H 21#define DOCUMENT_LIST_H
22 22
23 23
24#include <qobject.h> 24#include <qobject.h>
25#include <qtopia/applnk.h> 25#include <qtopia/applnk.h>
26 26
27 27
28class DocumentListPrivate; 28class DocumentListPrivate;
29class ServerInterface; 29class ServerInterface;
30 30
31class DocumentList : public QObject { 31class DocumentList : public QObject {
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE, 34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE,
35 QObject *parent = 0, const char *name = 0 ); 35 QObject *parent = 0, const char *name = 0 );
36 ~DocumentList(); 36 ~DocumentList();
37 37
38 void linkChanged( QString link ); 38 void linkChanged( QString link );
39 void restoreDone(); 39 void restoreDone();
40 void storageChanged(); 40 void storageChanged();
41 void sendAllDocLinks(); 41 void sendAllDocLinks();
42 42
43 void reloadAppLnks(); 43 void reloadAppLnks();
44 void reloadDocLnks(); 44 void reloadDocLnks();
45 void reforceDocuments();
45 void DiffAppLnks(); 46 void DiffAppLnks();
46 47
47// Orig DocList stuff 48// Orig DocList stuff
48 void start(); 49 void start();
49 void pause(); 50 void pause();
50 void resume(); 51 void resume();
51 void rescan(); 52 void rescan();
52 53
53 static AppLnkSet *appLnkSet; 54 static AppLnkSet *appLnkSet;
54 55
55/* 56/*
56 void resend(); 57 void resend();
57signals: 58signals:
58 void added( const DocLnk& doc ); 59 void added( const DocLnk& doc );
59 void removed( const DocLnk& doc ); 60 void removed( const DocLnk& doc );
60 void changed( const DocLnk& oldDoc, const DocLnk& newDoc ); 61 void changed( const DocLnk& oldDoc, const DocLnk& newDoc );
61 void allRemoved(); 62 void allRemoved();
62 void doneForNow(); 63 void doneForNow();
63private slots: 64private slots:
64 void resendWorker(); 65 void resendWorker();
65*/ 66*/
66private slots: 67private slots:
67 void startInitialScan(); 68 void startInitialScan();
68protected: 69protected:
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index ccc2114..970b8cb 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -367,107 +367,128 @@ void LauncherTabWidget::setBusy(bool on)
367 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; 367 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
368 } 368 }
369 } 369 }
370 } 370 }
371} 371}
372 372
373void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 373void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
374 for (int i = 0; i < categoryBar->count(); i++ ) { 374 for (int i = 0; i < categoryBar->count(); i++ ) {
375 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 375 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
376 view->setBusyIndicatorType( str ); 376 view->setBusyIndicatorType( str );
377 } 377 }
378} 378}
379 379
380LauncherView *LauncherTabWidget::currentView(void) 380LauncherView *LauncherTabWidget::currentView(void)
381{ 381{
382 return (LauncherView*)stack->visibleWidget(); 382 return (LauncherView*)stack->visibleWidget();
383} 383}
384 384
385 385
386 386
387void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 387void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
388{ 388{
389 QDataStream stream( data, IO_ReadOnly ); 389 QDataStream stream( data, IO_ReadOnly );
390 if ( msg == "setTabView(QString,int)" ) { 390 if ( msg == "setTabView(QString,int)" ) {
391 QString id; 391 QString id;
392 stream >> id; 392 stream >> id;
393 int mode; 393 int mode;
394 stream >> mode; 394 stream >> mode;
395 if ( view(id) ) 395 if ( view(id) )
396 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 396 view(id)->setViewMode( (LauncherView::ViewMode)mode );
397 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 397 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
398 QString id; 398 QString id;
399 stream >> id; 399 stream >> id;
400 int mode; 400 int mode;
401 stream >> mode; 401 stream >> mode;
402 QString pixmapOrColor; 402 QString pixmapOrColor;
403 stream >> pixmapOrColor; 403 stream >> pixmapOrColor;
404 if ( view(id) ) 404 if ( view(id) )
405 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 405 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
406 if ( id == "Documents" ) 406 if ( id == "Documents" )
407 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 407 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
408 } else if ( msg == "setTextColor(QString,QString)" ) { 408 } else if ( msg == "setTextColor(QString,QString)" ) {
409 QString id; 409 QString id;
410 stream >> id; 410 stream >> id;
411 QString color; 411 QString color;
412 stream >> color; 412 stream >> color;
413 if ( view(id) ) 413 if ( view(id) )
414 view(id)->setTextColor( QColor(color) ); 414 view(id)->setTextColor( QColor(color) );
415 if ( id == "Documents" ) 415 if ( id == "Documents" )
416 docLoadingWidget->setTextColor( QColor(color) ); 416 docLoadingWidget->setTextColor( QColor(color) );
417 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 417 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
418 QString id; 418 QString id;
419 stream >> id; 419 stream >> id;
420 QString fam; 420 QString fam;
421 stream >> fam; 421 stream >> fam;
422 int size; 422 int size;
423 stream >> size; 423 stream >> size;
424 int weight; 424 int weight;
425 stream >> weight; 425 stream >> weight;
426 int italic; 426 int italic;
427 stream >> italic; 427 stream >> italic;
428 if ( view(id) ) { 428 if ( view(id) ) {
429 if ( !fam.isEmpty() ) { 429 if ( !fam.isEmpty() ) {
430 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 430 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
431 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 431 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
432 } else { 432 } else {
433 view(id)->clearViewFont(); 433 view(id)->clearViewFont();
434 }
434 } 435 }
435 }
436 }else if ( msg == "setBusyIndicatorType(QString)" ) { 436 }else if ( msg == "setBusyIndicatorType(QString)" ) {
437 QString type; 437 QString type;
438 stream >> type; 438 stream >> type;
439 setBusyIndicatorType( type ); 439 setBusyIndicatorType( type );
440 }else if ( msg == "home()" ) { 440 }else if ( msg == "home()" ) {
441 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 441 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
442 if (categoryBar) 442 if (categoryBar)
443 categoryBar->nextTab(); 443 categoryBar->nextTab();
444 }else 444 }else {
445 static_cast<QWidget*>(parent())->raise(); 445 static_cast<QWidget*>(parent())->raise();
446 }
447 } else if (msg=="doctabEnabled(int)") {
448 int id; stream >> id;
449 odebug << "Doctab enabled " << id << oendl;
450 reCheckDoctab(id);
446 } 451 }
447} 452}
448 453
449 454void LauncherTabWidget::reCheckDoctab(int how)
455{
456 if ((bool)how == docTabEnabled) {
457 /* nothing to do */
458 return;
459 }
460 if (docLoadingWidget) {
461 stack->removeWidget(docLoadingWidget);
462 delete docLoadingWidget;
463 docLoadingWidget = 0;
464 }
465 createDocLoadingWidget();
466 {
467 QCopEnvelope( "QPE/System", "reforceDocuments()" );
468 odebug << "Sending doc rescan" << oendl;
469 }
470}
450 471
451//--------------------------------------------------------------------------- 472//---------------------------------------------------------------------------
452 473
453Launcher::Launcher() 474Launcher::Launcher()
454 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 475 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
455{ 476{
456 tabs = 0; 477 tabs = 0;
457 tb = 0; 478 tb = 0;
458 Config cfg( "Launcher" ); 479 Config cfg( "Launcher" );
459 cfg.setGroup( "DocTab" ); 480 cfg.setGroup( "DocTab" );
460 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 481 docTabEnabled = cfg.readBoolEntry( "Enable", true );
461} 482}
462 483
463void Launcher::createGUI() 484void Launcher::createGUI()
464{ 485{
465 setCaption( tr("Launcher") ); 486 setCaption( tr("Launcher") );
466 487
467 // we have a pretty good idea how big we'll be 488 // we have a pretty good idea how big we'll be
468 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 489 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
469 490
470 tb = new TaskBar; 491 tb = new TaskBar;
471 tabs = new LauncherTabWidget( this ); 492 tabs = new LauncherTabWidget( this );
472 setCentralWidget( tabs ); 493 setCentralWidget( tabs );
473 494
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index db6ac54..b741064 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -60,48 +60,49 @@ public:
60 void setLoadingProgress( int percent ); 60 void setLoadingProgress( int percent );
61 61
62 LauncherTabBar* categoryBar; 62 LauncherTabBar* categoryBar;
63 63
64 void setBusyIndicatorType( const QString& type ); 64 void setBusyIndicatorType( const QString& type );
65 65
66signals: 66signals:
67 void selected(const QString&); 67 void selected(const QString&);
68 void clicked(const AppLnk*); 68 void clicked(const AppLnk*);
69 void rightPressed(AppLnk*); 69 void rightPressed(AppLnk*);
70 70
71protected slots: 71protected slots:
72 void raiseTabWidget(); 72 void raiseTabWidget();
73 void tabProperties(); 73 void tabProperties();
74 void initLayout(); 74 void initLayout();
75 75
76private slots: 76private slots:
77 void launcherMessage( const QCString &, const QByteArray &); 77 void launcherMessage( const QCString &, const QByteArray &);
78 void appMessage( const QCString &, const QByteArray &); 78 void appMessage( const QCString &, const QByteArray &);
79 void setProgressStyle(); 79 void setProgressStyle();
80 80
81protected: 81protected:
82 void paletteChange( const QPalette &p ); 82 void paletteChange( const QPalette &p );
83 void styleChange( QStyle & ); 83 void styleChange( QStyle & );
84 void reCheckDoctab(int how);
84 85
85private: 86private:
86 Launcher *launcher; 87 Launcher *launcher;
87 LauncherView *docview; 88 LauncherView *docview;
88 89
89 QWidgetStack *stack; 90 QWidgetStack *stack;
90 LauncherView *docLoadingWidget; 91 LauncherView *docLoadingWidget;
91 QProgressBar *docLoadingWidgetProgress; 92 QProgressBar *docLoadingWidgetProgress;
92 bool docLoadingWidgetEnabled; 93 bool docLoadingWidgetEnabled;
93 bool docTabEnabled; 94 bool docTabEnabled;
94 int m_DocumentTabId; 95 int m_DocumentTabId;
95}; 96};
96 97
97class Launcher : public QMainWindow, public ServerInterface 98class Launcher : public QMainWindow, public ServerInterface
98{ 99{
99 Q_OBJECT 100 Q_OBJECT
100public: 101public:
101 Launcher(); 102 Launcher();
102 ~Launcher(); 103 ~Launcher();
103 104
104 // implementing ServerInterface 105 // implementing ServerInterface
105 void createGUI(); 106 void createGUI();
106 void destroyGUI(); 107 void destroyGUI();
107 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ); 108 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap );
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index c9efacb..2783423 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -311,51 +311,48 @@ int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
311 switch (sortmeth) { 311 switch (sortmeth) {
312 case Name: 312 case Name:
313 return a->name().lower().compare(b->name().lower()); 313 return a->name().lower().compare(b->name().lower());
314 case Date: { 314 case Date: {
315 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 315 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
316 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 316 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
317 return fa.lastModified().secsTo(fb.lastModified()); 317 return fa.lastModified().secsTo(fb.lastModified());
318 } 318 }
319 case Type: 319 case Type:
320 return a->type().compare(b->type()); 320 return a->type().compare(b->type());
321 } 321 }
322 return 0; 322 return 0;
323} 323}
324 324
325void LauncherIconView::setSortMethod( SortMethod m ) 325void LauncherIconView::setSortMethod( SortMethod m )
326{ 326{
327 if ( sortmeth != m ) { 327 if ( sortmeth != m ) {
328 sortmeth = m; 328 sortmeth = m;
329 sort(); 329 sort();
330 } 330 }
331} 331}
332 332
333void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 333void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
334{ 334{
335 Categories cat;
336 cat.load( categoryFileName() );
337 QString str;
338 if ( catfilter == -2 ) 335 if ( catfilter == -2 )
339 cf = 0; 336 cf = 0;
340 else 337 else
341 cf = catfilter; 338 cf = catfilter;
342 hideOrShowItems(resort); 339 hideOrShowItems(resort);
343} 340}
344 341
345void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 342void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
346{ 343{
347 tf = QRegExp(typefilter,FALSE,TRUE); 344 tf = QRegExp(typefilter,FALSE,TRUE);
348 hideOrShowItems(resort); 345 hideOrShowItems(resort);
349} 346}
350 347
351void LauncherIconView::setItemTextPos( ItemTextPos pos ) 348void LauncherIconView::setItemTextPos( ItemTextPos pos )
352{ 349{
353 calculateGrid( pos ); 350 calculateGrid( pos );
354 QIconView::setItemTextPos( pos ); 351 QIconView::setItemTextPos( pos );
355} 352}
356 353
357void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 354void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
358{ 355{
359 if ( !bgPixmap.isNull() ) { 356 if ( !bgPixmap.isNull() ) {
360 p->drawTiledPixmap( r, bgPixmap, 357 p->drawTiledPixmap( r, bgPixmap,
361 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 358 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
@@ -1062,48 +1059,49 @@ void LauncherView::itemClicked( int btn, QIconViewItem *item )
1062 if ( btn == LeftButton ) { 1059 if ( btn == LeftButton ) {
1063 // Make sure it's the item we execute that gets highlighted 1060 // Make sure it's the item we execute that gets highlighted
1064 icons->setCurrentItem( item ); 1061 icons->setCurrentItem( item );
1065 emit clicked( appLnk ); 1062 emit clicked( appLnk );
1066 } 1063 }
1067 item->setSelected(FALSE); 1064 item->setSelected(FALSE);
1068 } 1065 }
1069} 1066}
1070 1067
1071void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1068void LauncherView::itemPressed( int btn, QIconViewItem *item )
1072{ 1069{
1073 if ( item ) { 1070 if ( item ) {
1074 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1071 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1075 if ( btn == RightButton ) 1072 if ( btn == RightButton )
1076 emit rightPressed( appLnk ); 1073 emit rightPressed( appLnk );
1077 else if ( btn == ShiftButton ) 1074 else if ( btn == ShiftButton )
1078 emit rightPressed( appLnk ); 1075 emit rightPressed( appLnk );
1079 item->setSelected(FALSE); 1076 item->setSelected(FALSE);
1080 } 1077 }
1081} 1078}
1082 1079
1083void LauncherView::removeAllItems() 1080void LauncherView::removeAllItems()
1084{ 1081{
1085 odebug << "LauncherView::removeAllItems()" << oendl; 1082 odebug << "LauncherView::removeAllItems()" << oendl;
1083 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear();
1086 icons->clear(); 1084 icons->clear();
1087} 1085}
1088 1086
1089bool LauncherView::removeLink(const QString& linkfile) 1087bool LauncherView::removeLink(const QString& linkfile)
1090{ 1088{
1091 return icons->removeLink(linkfile); 1089 return icons->removeLink(linkfile);
1092} 1090}
1093 1091
1094void LauncherView::addItem(AppLnk* app, bool resort) 1092void LauncherView::addItem(AppLnk* app, bool resort)
1095{ 1093{
1096 icons->addItem(app,resort); 1094 icons->addItem(app,resort);
1097} 1095}
1098 1096
1099void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) 1097void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
1100{ 1098{
1101 icons->changeItem(old,nlink); 1099 icons->changeItem(old,nlink);
1102} 1100}
1103 1101
1104void LauncherView::setSortEnabled( bool v ) 1102void LauncherView::setSortEnabled( bool v )
1105{ 1103{
1106 icons->setSorting( v ); 1104 icons->setSorting( v );
1107 if ( v ) 1105 if ( v )
1108 sort(); 1106 sort();
1109} 1107}
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 42186d3..15cd686 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -143,49 +143,49 @@ Server::Server() :
143 last_today_show = QDate::currentDate(); 143 last_today_show = QDate::currentDate();
144 144
145#warning FIXME support TempScreenSaverMode 145#warning FIXME support TempScreenSaverMode
146#if 0 146#if 0
147 tsmMonitor = new TempScreenSaverMode(); 147 tsmMonitor = new TempScreenSaverMode();
148 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); 148 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) );
149#endif 149#endif
150 150
151 serverGui = new Launcher; 151 serverGui = new Launcher;
152 serverGui->createGUI(); 152 serverGui->createGUI();
153 153
154 docList = new DocumentList( serverGui ); 154 docList = new DocumentList( serverGui );
155 appLauncher = new AppLauncher(this); 155 appLauncher = new AppLauncher(this);
156 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); 156 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) );
157 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); 157 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) );
158 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); 158 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) );
159 159
160 storage = new StorageInfo( this ); 160 storage = new StorageInfo( this );
161 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); 161 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) );
162 162
163 163
164#ifdef QPE_HAVE_DIRECT_ACCESS 164#ifdef QPE_HAVE_DIRECT_ACCESS
165 QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); 165 QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this );
166 connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), 166 connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )),
167 this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); 167 this, SLOT(desktopMessage( const QCString &, const QByteArray & )) );
168#endif 168#endif
169 169
170 // start services 170 // start services
171 startTransferServer(); 171 startTransferServer();
172 (void) new IrServer( this ); 172 (void) new IrServer( this );
173 173
174 packageHandler = new PackageHandler( this ); 174 packageHandler = new PackageHandler( this );
175 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), 175 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)),
176 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); 176 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool)));
177 177
178 setGeometry( -10, -10, 9, 9 ); 178 setGeometry( -10, -10, 9, 9 );
179 179
180 QCopChannel *channel = new QCopChannel("QPE/System", this); 180 QCopChannel *channel = new QCopChannel("QPE/System", this);
181 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), 181 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)),
182 this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); 182 this, SLOT(systemMsg(const QCString&,const QByteArray&)) );
183 183
184 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); 184 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this );
185 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), 185 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)),
186 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); 186 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) );
187 187
188 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); 188 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) );
189 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); 189 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) );
190 190
191 preloadApps(); 191 preloadApps();
@@ -195,62 +195,62 @@ void Server::show()
195{ 195{
196 ServerApplication::login(TRUE); 196 ServerApplication::login(TRUE);
197 QWidget::show(); 197 QWidget::show();
198} 198}
199 199
200Server::~Server() 200Server::~Server()
201{ 201{
202 serverGui->destroyGUI(); 202 serverGui->destroyGUI();
203 delete docList; 203 delete docList;
204 delete qcopBridge; 204 delete qcopBridge;
205 delete transferServer; 205 delete transferServer;
206 delete serverGui; 206 delete serverGui;
207#if 0 207#if 0
208 delete tsmMonitor; 208 delete tsmMonitor;
209#endif 209#endif
210} 210}
211 211
212 212
213static bool hasVisibleWindow(const QString& clientname, bool partial) 213static bool hasVisibleWindow(const QString& clientname, bool partial)
214{ 214{
215#ifdef QWS 215#ifdef QWS
216 const QList<QWSWindow> &list = qwsServer->clientWindows(); 216 const QList<QWSWindow> &list = qwsServer->clientWindows();
217 QWSWindow* w; 217 QWSWindow* w;
218 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 218 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
219 if ( w->client()->identity() == clientname ) { 219 if ( w->client()->identity() == clientname ) {
220 if ( partial && !w->isFullyObscured() ) 220 if ( partial && !w->isFullyObscured() )
221 return TRUE; 221 return TRUE;
222 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { 222 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) {
223# if QT_VERSION < 0x030000 223# if QT_VERSION < 0x030000
224 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, 224 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect,
225 QSize(qt_screen->width(),qt_screen->height()) ); 225 QSize(qt_screen->width(),qt_screen->height()) );
226# else 226# else
227 QRect mwr = qt_maxWindowRect; 227 QRect mwr = qt_maxWindowRect;
228# endif 228# endif
229 if ( mwr.contains(w->requested().boundingRect()) ) 229 if ( mwr.contains(w->requested().boundingRect()) )
230 return TRUE; 230 return TRUE;
231 } 231 }
232 } 232 }
233 } 233 }
234#endif 234#endif
235 return FALSE; 235 return FALSE;
236} 236}
237 237
238void Server::activate(const ODeviceButton* button, bool held) 238void Server::activate(const ODeviceButton* button, bool held)
239{ 239{
240 Global::terminateBuiltin("calibrate"); // No tr 240 Global::terminateBuiltin("calibrate"); // No tr
241 OQCopMessage om; 241 OQCopMessage om;
242 if ( held ) { 242 if ( held ) {
243 om = button->heldAction(); 243 om = button->heldAction();
244 } else { 244 } else {
245 om = button->pressedAction(); 245 om = button->pressedAction();
246 } 246 }
247 247
248 if ( om.channel() != "ignore" ) 248 if ( om.channel() != "ignore" )
249 om.send(); 249 om.send();
250 250
251 // A button with no action defined, will return a null ServiceRequest. Don't attempt 251 // A button with no action defined, will return a null ServiceRequest. Don't attempt
252 // to send/do anything with this as it will crash 252 // to send/do anything with this as it will crash
253 /* ### FIXME */ 253 /* ### FIXME */
254#if 0 254#if 0
255 if ( !sr.isNull() ) { 255 if ( !sr.isNull() ) {
256 QString app = sr.app(); 256 QString app = sr.app();
@@ -321,48 +321,50 @@ bool Server::setKeyboardLayout( const QString &kb )
321#endif 321#endif
322 322
323void Server::systemMsg(const QCString &msg, const QByteArray &data) 323void Server::systemMsg(const QCString &msg, const QByteArray &data)
324{ 324{
325 QDataStream stream( data, IO_ReadOnly ); 325 QDataStream stream( data, IO_ReadOnly );
326 326
327 if ( msg == "securityChanged()" ) { 327 if ( msg == "securityChanged()" ) {
328 if ( transferServer ) 328 if ( transferServer )
329 transferServer->authorizeConnections(); 329 transferServer->authorizeConnections();
330 330
331 if ( qcopBridge ) 331 if ( qcopBridge )
332 qcopBridge->authorizeConnections(); 332 qcopBridge->authorizeConnections();
333#warning FIXME support TempScreenSaverMode 333#warning FIXME support TempScreenSaverMode
334#if 0 334#if 0
335 } else if ( msg == "setTempScreenSaverMode(int,int)" ) { 335 } else if ( msg == "setTempScreenSaverMode(int,int)" ) {
336 int mode, pid; 336 int mode, pid;
337 stream >> mode >> pid; 337 stream >> mode >> pid;
338 tsmMonitor->setTempMode(mode, pid); 338 tsmMonitor->setTempMode(mode, pid);
339#endif 339#endif
340 } else if ( msg == "linkChanged(QString)" ) { 340 } else if ( msg == "linkChanged(QString)" ) {
341 QString link; 341 QString link;
342 stream >> link; 342 stream >> link;
343 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; 343 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
344 docList->linkChanged(link); 344 docList->linkChanged(link);
345 } else if (msg =="reforceDocuments()") {
346 docList->reforceDocuments();
345 } else if ( msg == "serviceChanged(QString)" ) { 347 } else if ( msg == "serviceChanged(QString)" ) {
346 MimeType::updateApplications(); 348 MimeType::updateApplications();
347 } else if ( msg == "mkdir(QString)" ) { 349 } else if ( msg == "mkdir(QString)" ) {
348 QString dir; 350 QString dir;
349 stream >> dir; 351 stream >> dir;
350 if ( !dir.isEmpty() ) 352 if ( !dir.isEmpty() )
351 mkdir( dir ); 353 mkdir( dir );
352 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 354 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
353 QString baseFile, sigFile; 355 QString baseFile, sigFile;
354 stream >> baseFile >> sigFile; 356 stream >> baseFile >> sigFile;
355 QRsync::generateSignature( baseFile, sigFile ); 357 QRsync::generateSignature( baseFile, sigFile );
356 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 358 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
357 QString baseFile, sigFile, deltaFile; 359 QString baseFile, sigFile, deltaFile;
358 stream >> baseFile >> sigFile >> deltaFile; 360 stream >> baseFile >> sigFile >> deltaFile;
359 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 361 QRsync::generateDiff( baseFile, sigFile, deltaFile );
360 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 362 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
361 QString baseFile, deltaFile; 363 QString baseFile, deltaFile;
362 stream >> baseFile >> deltaFile; 364 stream >> baseFile >> deltaFile;
363 if ( !QFile::exists( baseFile ) ) { 365 if ( !QFile::exists( baseFile ) ) {
364 QFile f( baseFile ); 366 QFile f( baseFile );
365 f.open( IO_WriteOnly ); 367 f.open( IO_WriteOnly );
366 f.close(); 368 f.close();
367 } 369 }
368 QRsync::applyDiff( baseFile, deltaFile ); 370 QRsync::applyDiff( baseFile, deltaFile );
@@ -411,89 +413,89 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
411 QString homeDir = getenv("HOME"); 413 QString homeDir = getenv("HOME");
412 QString homeFs, homeFsPath; 414 QString homeFs, homeFsPath;
413 for ( ; it.current(); ++it ) { 415 for ( ; it.current(); ++it ) {
414 int k4 = (*it)->blockSize()/256; 416 int k4 = (*it)->blockSize()/256;
415 if ( (*it)->isRemovable() ) { 417 if ( (*it)->isRemovable() ) {
416 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 418 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
417 + QString::number( (*it)->availBlocks() * k4/4 ) 419 + QString::number( (*it)->availBlocks() * k4/4 )
418 + "K " + (*it)->options() + ";"; 420 + "K " + (*it)->options() + ";";
419 } else if ( homeDir.contains( (*it)->path() ) && 421 } else if ( homeDir.contains( (*it)->path() ) &&
420 (*it)->path().length() > homeFsPath.length() ) { 422 (*it)->path().length() > homeFsPath.length() ) {
421 homeFsPath = (*it)->path(); 423 homeFsPath = (*it)->path();
422 homeFs = 424 homeFs =
423 (*it)->name() + "=" + homeDir + "/Documents " // No tr 425 (*it)->name() + "=" + homeDir + "/Documents " // No tr
424 + QString::number( (*it)->availBlocks() * k4/4 ) 426 + QString::number( (*it)->availBlocks() * k4/4 )
425 + "K " + (*it)->options() + ";"; 427 + "K " + (*it)->options() + ";";
426 } 428 }
427 } 429 }
428 if ( !homeFs.isEmpty() ) 430 if ( !homeFs.isEmpty() )
429 s += homeFs; 431 s += homeFs;
430#ifndef QT_NO_COP 432#ifndef QT_NO_COP
431 e << s; 433 e << s;
432#endif 434#endif
433 } else if ( msg == "sendInstallLocations()" ) { 435 } else if ( msg == "sendInstallLocations()" ) {
434#ifndef QT_NO_COP 436#ifndef QT_NO_COP
435 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); 437 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" );
436 e << installLocationsString(); 438 e << installLocationsString();
437#endif 439#endif
438 } else if ( msg == "sendSyncDate(QString)" ) { 440 } else if ( msg == "sendSyncDate(QString)" ) {
439 QString app; 441 QString app;
440 stream >> app; 442 stream >> app;
441 Config cfg( "qpe" ); 443 Config cfg( "qpe" );
442 cfg.setGroup("SyncDate"); 444 cfg.setGroup("SyncDate");
443#ifndef QT_NO_COP 445#ifndef QT_NO_COP
444 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 446 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
445 e << app << cfg.readEntry( app ); 447 e << app << cfg.readEntry( app );
446#endif 448#endif
447 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " 449 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response "
448 // << cfg.readEntry( app ).latin1() << oendl; 450 // << cfg.readEntry( app ).latin1() << oendl;
449 } else if ( msg == "setSyncDate(QString,QString)" ) { 451 } else if ( msg == "setSyncDate(QString,QString)" ) {
450 QString app, date; 452 QString app, date;
451 stream >> app >> date; 453 stream >> app >> date;
452 Config cfg( "qpe" ); 454 Config cfg( "qpe" );
453 cfg.setGroup("SyncDate"); 455 cfg.setGroup("SyncDate");
454 cfg.writeEntry( app, date ); 456 cfg.writeEntry( app, date );
455 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; 457 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
456 } else if ( msg == "startSync(QString)" ) { 458 } else if ( msg == "startSync(QString)" ) {
457 QString what; 459 QString what;
458 stream >> what; 460 stream >> what;
459 delete syncDialog; 461 delete syncDialog;
460 syncDialog = new SyncDialog( this, what ); 462 syncDialog = new SyncDialog( this, what );
461 syncDialog->show(); 463 syncDialog->show();
462 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 464 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
463 } else if ( msg == "stopSync()") { 465 } else if ( msg == "stopSync()") {
464 delete syncDialog; 466 delete syncDialog;
465 syncDialog = 0; 467 syncDialog = 0;
466 } else if (msg == "restoreDone(QString)") { 468 } else if (msg == "restoreDone(QString)") {
467 docList->restoreDone(); 469 docList->restoreDone();
468 } else if ( msg == "getAllDocLinks()" ) { 470 } else if ( msg == "getAllDocLinks()" ) {
469 docList->sendAllDocLinks(); 471 docList->sendAllDocLinks();
470 } 472 }
471#ifdef QPE_HAVE_DIRECT_ACCESS 473#ifdef QPE_HAVE_DIRECT_ACCESS
472 else if ( msg == "prepareDirectAccess()" ) { 474 else if ( msg == "prepareDirectAccess()" ) {
473 prepareDirectAccess(); 475 prepareDirectAccess();
474 } else if ( msg == "postDirectAccess()" ) { 476 } else if ( msg == "postDirectAccess()" ) {
475 postDirectAccess(); 477 postDirectAccess();
476 } 478 }
477#endif 479#endif
478#ifdef Q_WS_QWS 480#ifdef Q_WS_QWS
479 481
480 else if ( msg == "setMouseProto(QString)" ) { 482 else if ( msg == "setMouseProto(QString)" ) {
481 QString mice; 483 QString mice;
482 stream >> mice; 484 stream >> mice;
483 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 485 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
484 qwsServer->openMouse(); 486 qwsServer->openMouse();
485 } else if ( msg == "setKeyboard(QString)" ) { 487 } else if ( msg == "setKeyboard(QString)" ) {
486 QString kb; 488 QString kb;
487 stream >> kb; 489 stream >> kb;
488 setenv("QWS_KEYBOARD",kb.latin1(),1); 490 setenv("QWS_KEYBOARD",kb.latin1(),1);
489 qwsServer->openKeyboard(); 491 qwsServer->openKeyboard();
490 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { 492 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) {
491 int delay, period; 493 int delay, period;
492 stream >> delay >> period; 494 stream >> delay >> period;
493 qwsSetKeyboardAutoRepeat( delay, period ); 495 qwsSetKeyboardAutoRepeat( delay, period );
494 Config cfg( "qpe" ); 496 Config cfg( "qpe" );
495 cfg.setGroup("Keyboard"); 497 cfg.setGroup("Keyboard");
496 cfg.writeEntry( "RepeatDelay", delay ); 498 cfg.writeEntry( "RepeatDelay", delay );
497 cfg.writeEntry( "RepeatPeriod", period ); 499 cfg.writeEntry( "RepeatPeriod", period );
498 } else if ( msg == "setKeyboardLayout(QString)" ) { 500 } else if ( msg == "setKeyboardLayout(QString)" ) {
499 QString kb; 501 QString kb;
@@ -536,92 +538,92 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
536 stream >> modifier >> appName >> delay; 538 stream >> modifier >> appName >> delay;
537 Config cfg( "autostart" ); 539 Config cfg( "autostart" );
538 540
539 cfg.setGroup( "AutoStart" ); 541 cfg.setGroup( "AutoStart" );
540 if ( modifier.compare("add") == 0 ){ 542 if ( modifier.compare("add") == 0 ){
541 // only add it appname is entered 543 // only add it appname is entered
542 if (!appName.isEmpty()) { 544 if (!appName.isEmpty()) {
543 cfg.writeEntry("Apps", appName); 545 cfg.writeEntry("Apps", appName);
544 cfg.writeEntry("Delay", delay); 546 cfg.writeEntry("Delay", delay);
545 } 547 }
546 } 548 }
547 } 549 }
548#endif 550#endif
549} 551}
550 552
551QString Server::cardInfoString() 553QString Server::cardInfoString()
552{ 554{
553 storage->update(); 555 storage->update();
554 const QList<FileSystem> &fs = storage->fileSystems(); 556 const QList<FileSystem> &fs = storage->fileSystems();
555 QListIterator<FileSystem> it ( fs ); 557 QListIterator<FileSystem> it ( fs );
556 QString s; 558 QString s;
557 QString homeDir = getenv("HOME"); 559 QString homeDir = getenv("HOME");
558 QString homeFs, homeFsPath; 560 QString homeFs, homeFsPath;
559 for ( ; it.current(); ++it ) { 561 for ( ; it.current(); ++it ) {
560 int k4 = (*it)->blockSize()/256; 562 int k4 = (*it)->blockSize()/256;
561 if ( (*it)->isRemovable() ) { 563 if ( (*it)->isRemovable() ) {
562 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 564 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
563 + QString::number( (*it)->availBlocks() * k4/4 ) 565 + QString::number( (*it)->availBlocks() * k4/4 )
564 + "K " + (*it)->options() + ";"; 566 + "K " + (*it)->options() + ";";
565 } else if ( homeDir.contains( (*it)->path() ) && 567 } else if ( homeDir.contains( (*it)->path() ) &&
566 (*it)->path().length() > homeFsPath.length() ) { 568 (*it)->path().length() > homeFsPath.length() ) {
567 homeFsPath = (*it)->path(); 569 homeFsPath = (*it)->path();
568 homeFs = 570 homeFs =
569 (*it)->name() + "=" + homeDir + "/Documents " // No tr 571 (*it)->name() + "=" + homeDir + "/Documents " // No tr
570 + QString::number( (*it)->availBlocks() * k4/4 ) 572 + QString::number( (*it)->availBlocks() * k4/4 )
571 + "K " + (*it)->options() + ";"; 573 + "K " + (*it)->options() + ";";
572 } 574 }
573 } 575 }
574 if ( !homeFs.isEmpty() ) 576 if ( !homeFs.isEmpty() )
575 s += homeFs; 577 s += homeFs;
576 return s; 578 return s;
577} 579}
578 580
579QString Server::installLocationsString() 581QString Server::installLocationsString()
580{ 582{
581 storage->update(); 583 storage->update();
582 const QList<FileSystem> &fs = storage->fileSystems(); 584 const QList<FileSystem> &fs = storage->fileSystems();
583 QListIterator<FileSystem> it ( fs ); 585 QListIterator<FileSystem> it ( fs );
584 QString s; 586 QString s;
585 QString homeDir = getenv("HOME"); 587 QString homeDir = getenv("HOME");
586 QString homeFs, homeFsPath; 588 QString homeFs, homeFsPath;
587 for ( ; it.current(); ++it ) { 589 for ( ; it.current(); ++it ) {
588 int k4 = (*it)->blockSize()/256; 590 int k4 = (*it)->blockSize()/256;
589 if ( (*it)->isRemovable() ) { 591 if ( (*it)->isRemovable() ) {
590 s += (*it)->name() + "=" + (*it)->path() + " " // No tr 592 s += (*it)->name() + "=" + (*it)->path() + " " // No tr
591 + QString::number( (*it)->availBlocks() * k4/4 ) 593 + QString::number( (*it)->availBlocks() * k4/4 )
592 + "K " + (*it)->options() + ";"; 594 + "K " + (*it)->options() + ";";
593 } else if ( homeDir.contains( (*it)->path() ) && 595 } else if ( homeDir.contains( (*it)->path() ) &&
594 (*it)->path().length() > homeFsPath.length() ) { 596 (*it)->path().length() > homeFsPath.length() ) {
595 homeFsPath = (*it)->path(); 597 homeFsPath = (*it)->path();
596 homeFs = 598 homeFs =
597 (*it)->name() + "=" + homeDir + " " // No tr 599 (*it)->name() + "=" + homeDir + " " // No tr
598 + QString::number( (*it)->availBlocks() * k4/4 ) 600 + QString::number( (*it)->availBlocks() * k4/4 )
599 + "K " + (*it)->options() + ";"; 601 + "K " + (*it)->options() + ";";
600 } 602 }
601 } 603 }
602 if ( !homeFs.isEmpty() ) 604 if ( !homeFs.isEmpty() )
603 s = homeFs + s; 605 s = homeFs + s;
604 return s; 606 return s;
605} 607}
606 608
607void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) 609void Server::receiveTaskBar(const QCString &msg, const QByteArray &data)
608{ 610{
609 QDataStream stream( data, IO_ReadOnly ); 611 QDataStream stream( data, IO_ReadOnly );
610 612
611 if ( msg == "reloadApps()" ) { 613 if ( msg == "reloadApps()" ) {
612 docList->reloadAppLnks(); 614 docList->reloadAppLnks();
613 } else if ( msg == "soundAlarm()" ) { 615 } else if ( msg == "soundAlarm()" ) {
614 ServerApplication::soundAlarm(); 616 ServerApplication::soundAlarm();
615 } else if ( msg == "setLed(int,bool)" ) { 617 } else if ( msg == "setLed(int,bool)" ) {
616 int led, status; 618 int led, status;
617 stream >> led >> status; 619 stream >> led >> status;
618 620
619 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 621 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
620 if ( ll. count ( )) { 622 if ( ll. count ( )) {
621 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 623 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
622 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 624 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
623 625
624 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 626 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
625 } 627 }
626 } 628 }
627} 629}
@@ -803,182 +805,182 @@ void Server::preloadApps()
803 Config cfg("Launcher"); 805 Config cfg("Launcher");
804 cfg.setGroup("Preload"); 806 cfg.setGroup("Preload");
805 QStringList apps = cfg.readListEntry("Apps",','); 807 QStringList apps = cfg.readListEntry("Apps",',');
806 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 808 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
807#ifndef QT_NO_COP 809#ifndef QT_NO_COP
808 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 810 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
809#endif 811#endif
810 } 812 }
811} 813}
812 814
813// This is only called if QPE_HAVE_DIRECT_ACCESS is defined 815// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
814void Server::prepareDirectAccess() 816void Server::prepareDirectAccess()
815{ 817{
816 qDebug( "Server::prepareDirectAccess()" ); 818 qDebug( "Server::prepareDirectAccess()" );
817 // Put up a pretty dialog 819 // Put up a pretty dialog
818 syncDialog = new SyncDialog( this, tr("USB Lock") ); 820 syncDialog = new SyncDialog( this, tr("USB Lock") );
819 syncDialog->show(); 821 syncDialog->show();
820 822
821 // Prevent the PDA from acting as a PDA 823 // Prevent the PDA from acting as a PDA
822 terminateServers(); 824 terminateServers();
823 825
824 // suspend the mtab monitor 826 // suspend the mtab monitor
825#ifndef QT_NO_COP 827#ifndef QT_NO_COP
826 { 828 {
827 QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); 829 QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" );
828 } 830 }
829#endif 831#endif
830 832
831 // send out a flush message 833 // send out a flush message
832 // once flushes are done call runDirectAccess() 834 // once flushes are done call runDirectAccess()
833 // We just count the number of apps and set a timer. 835 // We just count the number of apps and set a timer.
834 // Either the timer expires or the correct number of apps responds. 836 // Either the timer expires or the correct number of apps responds.
835 // Note: quicklauncher isn't in the runningApps list but it responds 837 // Note: quicklauncher isn't in the runningApps list but it responds
836 // to the flush so we start the counter at 1 838 // to the flush so we start the counter at 1
837 pendingFlushes = 1; 839 pendingFlushes = 1;
838 directAccessRun = FALSE; 840 directAccessRun = FALSE;
839 for ( QMap<int,QString>::ConstIterator it = 841 for ( QMap<int,QString>::ConstIterator it =
840 appLauncher->runningApplications().begin(); 842 appLauncher->runningApplications().begin();
841 it != appLauncher->runningApplications().end(); 843 it != appLauncher->runningApplications().end();
842 ++it ) { 844 ++it ) {
843 pendingFlushes++; 845 pendingFlushes++;
844 } 846 }
845#ifndef QT_NO_COP 847#ifndef QT_NO_COP
846 QCopEnvelope e1( "QPE/System", "flush()" ); 848 QCopEnvelope e1( "QPE/System", "flush()" );
847#endif 849#endif
848 QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); 850 QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) );
849#warning FIXME support TempScreenSaverMode 851#warning FIXME support TempScreenSaverMode
850#if 0 852#if 0
851 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); 853 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend);
852#endif 854#endif
853} 855}
854 856
855// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined 857// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
856// It fakes the presence of Qtopia Desktop 858// It fakes the presence of Qtopia Desktop
857void Server::desktopMessage( const QCString &message, const QByteArray &data ) 859void Server::desktopMessage( const QCString &message, const QByteArray &data )
858{ 860{
859 QDataStream stream( data, IO_ReadOnly ); 861 QDataStream stream( data, IO_ReadOnly );
860 if ( message == "flushDone(QString)" ) { 862 if ( message == "flushDone(QString)" ) {
861 QString app; 863 QString app;
862 stream >> app; 864 stream >> app;
863 qDebug( "flushDone from %s", app.latin1() ); 865 qDebug( "flushDone from %s", app.latin1() );
864 if ( --pendingFlushes == 0 ) { 866 if ( --pendingFlushes == 0 ) {
865 qDebug( "pendingFlushes == 0, all the apps responded" ); 867 qDebug( "pendingFlushes == 0, all the apps responded" );
866 runDirectAccess(); 868 runDirectAccess();
867 } 869 }
868 } else if ( message == "installStarted(QString)" ) { 870 } else if ( message == "installStarted(QString)" ) {
869 QString package; 871 QString package;
870 stream >> package; 872 stream >> package;
871 qDebug( "\tInstall Started for package %s", package.latin1() ); 873 qDebug( "\tInstall Started for package %s", package.latin1() );
872 } else if ( message == "installStep(QString)" ) { 874 } else if ( message == "installStep(QString)" ) {
873 QString step; 875 QString step;
874 stream >> step; 876 stream >> step;
875 qDebug( "\tInstall Step %s", step.latin1() ); 877 qDebug( "\tInstall Step %s", step.latin1() );
876 } else if ( message == "installDone(QString)" ) { 878 } else if ( message == "installDone(QString)" ) {
877 QString package; 879 QString package;
878 stream >> package; 880 stream >> package;
879 qDebug( "\tInstall Finished for package %s", package.latin1() ); 881 qDebug( "\tInstall Finished for package %s", package.latin1() );
880 } else if ( message == "installFailed(QString,int,QString)" ) { 882 } else if ( message == "installFailed(QString,int,QString)" ) {
881 QString package, error; 883 QString package, error;
882 int status; 884 int status;
883 stream >> package >> status >> error; 885 stream >> package >> status >> error;
884 qDebug( "\tInstall Failed for package %s with error code %d and error message %s", 886 qDebug( "\tInstall Failed for package %s with error code %d and error message %s",
885 package.latin1(), status, error.latin1() ); 887 package.latin1(), status, error.latin1() );
886 } else if ( message == "removeStarted(QString)" ) { 888 } else if ( message == "removeStarted(QString)" ) {
887 QString package; 889 QString package;
888 stream >> package; 890 stream >> package;
889 qDebug( "\tRemove Started for package %s", package.latin1() ); 891 qDebug( "\tRemove Started for package %s", package.latin1() );
890 } else if ( message == "removeDone(QString)" ) { 892 } else if ( message == "removeDone(QString)" ) {
891 QString package; 893 QString package;
892 stream >> package; 894 stream >> package;
893 qDebug( "\tRemove Finished for package %s", package.latin1() ); 895 qDebug( "\tRemove Finished for package %s", package.latin1() );
894 } else if ( message == "removeFailed(QString)" ) { 896 } else if ( message == "removeFailed(QString)" ) {
895 QString package; 897 QString package;
896 stream >> package; 898 stream >> package;
897 qDebug( "\tRemove Failed for package %s", package.latin1() ); 899 qDebug( "\tRemove Failed for package %s", package.latin1() );
898 } 900 }
899 901
900 if ( qrr && qrr->waitingForMessages ) 902 if ( qrr && qrr->waitingForMessages )
901 qrr->desktopMessage( message, data ); 903 qrr->desktopMessage( message, data );
902} 904}
903 905
904 906
905// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined 907// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
906void Server::runDirectAccess() 908void Server::runDirectAccess()
907{ 909{
908#ifdef QPE_HAVE_DIRECT_ACCESS 910#ifdef QPE_HAVE_DIRECT_ACCESS
909 // The timer must have fired after all the apps responded 911 // The timer must have fired after all the apps responded
910 // with flushDone(). Just ignore it. 912 // with flushDone(). Just ignore it.
911 if ( directAccessRun ) 913 if ( directAccessRun )
912 return; 914 return;
913 915
914 directAccessRun = TRUE; 916 directAccessRun = TRUE;
915 ::readyDirectAccess(cardInfoString(), installLocationsString()); 917 ::readyDirectAccess(cardInfoString(), installLocationsString());
916#endif 918#endif
917} 919}
918 920
919// This is only called if QPE_HAVE_DIRECT_ACCESS is defined 921// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
920void Server::postDirectAccess() 922void Server::postDirectAccess()
921{ 923{
922#ifdef QPE_HAVE_DIRECT_ACCESS 924#ifdef QPE_HAVE_DIRECT_ACCESS
923 qDebug( "Server::postDirectAccess()" ); 925 qDebug( "Server::postDirectAccess()" );
924 926
925 // Categories may have changed 927 // Categories may have changed
926 QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); 928 QCopEnvelope e1( "QPE/System", "categoriesChanged()" );
927 // Apps need to reload their data 929 // Apps need to reload their data
928 QCopEnvelope e2( "QPE/System", "reload()" ); 930 QCopEnvelope e2( "QPE/System", "reload()" );
929 // Reload DocLinks 931 // Reload DocLinks
930 docList->storageChanged(); 932 docList->storageChanged();
931 // Restart the PDA server stuff 933 // Restart the PDA server stuff
932 startTransferServer(); 934 startTransferServer();
933 935
934 // restart the mtab monitor 936 // restart the mtab monitor
935#ifndef QT_NO_COP 937#ifndef QT_NO_COP
936 { 938 {
937 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); 939 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" );
938 } 940 }
939#endif 941#endif
940 942
941 // Process queued requests 943 // Process queued requests
942 const char *queueFile = ::directAccessQueueFile(); 944 const char *queueFile = ::directAccessQueueFile();
943 QFile *file = new QFile( queueFile ); 945 QFile *file = new QFile( queueFile );
944 if ( !file->exists() ) { 946 if ( !file->exists() ) {
945 delete file; 947 delete file;
946 // Get rid of the dialog 948 // Get rid of the dialog
947 if ( syncDialog ) { 949 if ( syncDialog ) {
948 delete syncDialog; 950 delete syncDialog;
949 syncDialog = 0; 951 syncDialog = 0;
950 } 952 }
951#warning FIXME support TempScreenSaverMode 953#warning FIXME support TempScreenSaverMode
952#if 0 954#if 0
953 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 955 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
954#endif 956#endif
955 } else { 957 } else {
956 qrr = new QueuedRequestRunner( file, syncDialog ); 958 qrr = new QueuedRequestRunner( file, syncDialog );
957 connect( qrr, SIGNAL(finished()), 959 connect( qrr, SIGNAL(finished()),
958 this, SLOT(finishedQueuedRequests()) ); 960 this, SLOT(finishedQueuedRequests()) );
959 QTimer::singleShot( 100, qrr, SLOT(process()) ); 961 QTimer::singleShot( 100, qrr, SLOT(process()) );
960 // qrr will remove the sync dialog later 962 // qrr will remove the sync dialog later
961 } 963 }
962#endif 964#endif
963} 965}
964 966
965void Server::finishedQueuedRequests() 967void Server::finishedQueuedRequests()
966{ 968{
967 if ( qrr->readyToDelete ) { 969 if ( qrr->readyToDelete ) {
968 delete qrr; 970 delete qrr;
969 qrr = 0; 971 qrr = 0;
970 // Get rid of the dialog 972 // Get rid of the dialog
971 if ( syncDialog ) { 973 if ( syncDialog ) {
972 delete syncDialog; 974 delete syncDialog;
973 syncDialog = 0; 975 syncDialog = 0;
974 } 976 }
975#warning FIXME support TempScreenSaverMode 977#warning FIXME support TempScreenSaverMode
976#if 0 978#if 0
977 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 979 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
978#endif 980#endif
979 } else { 981 } else {
980 qrr->readyToDelete = TRUE; 982 qrr->readyToDelete = TRUE;
981 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); 983 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) );
982 } 984 }
983} 985}
984 986