author | ulf69 <ulf69> | 2004-06-29 05:03:25 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-29 05:03:25 (UTC) |
commit | 0538ac1cc17ad4249d27d686b4bc7e80663f475f (patch) (unidiff) | |
tree | abf571d0e2640bbb7ce14818a376ad980492ea05 /microkde | |
parent | 61ef87224517601f8754dd9da1b521a7b0094558 (diff) | |
download | kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.zip kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.tar.gz kdepimpi-0538ac1cc17ad4249d27d686b4bc7e80663f475f.tar.bz2 |
*** empty log message ***
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index 1410308..130cc7c 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp | |||
@@ -136,49 +136,50 @@ KLibrary::~KLibrary() | |||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | QString KLibrary::name() const | 139 | QString KLibrary::name() const |
140 | { | 140 | { |
141 | return m_libname; | 141 | return m_libname; |
142 | } | 142 | } |
143 | 143 | ||
144 | QString KLibrary::fileName() const | 144 | QString KLibrary::fileName() const |
145 | { | 145 | { |
146 | return m_filename; | 146 | return m_filename; |
147 | } | 147 | } |
148 | 148 | ||
149 | KLibFactory* KLibrary::factory() | 149 | KLibFactory* KLibrary::factory() |
150 | { | 150 | { |
151 | if ( m_factory ) | 151 | if ( m_factory ) |
152 | return m_factory; | 152 | return m_factory; |
153 | 153 | ||
154 | QCString symname; | 154 | QCString symname; |
155 | symname.sprintf("init_%s", name().latin1() ); | 155 | symname.sprintf("init_%s", name().latin1() ); |
156 | 156 | ||
157 | void* sym = symbol( symname ); | 157 | void* sym = symbol( symname ); |
158 | if ( !sym ) | 158 | if ( !sym ) |
159 | { | 159 | { |
160 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer an init_" << name() << " function" << endl; | 160 | qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); |
161 | kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; | ||
161 | return 0; | 162 | return 0; |
162 | } | 163 | } |
163 | 164 | ||
164 | typedef KLibFactory* (*t_func)(); | 165 | typedef KLibFactory* (*t_func)(); |
165 | t_func func = (t_func)sym; | 166 | t_func func = (t_func)sym; |
166 | m_factory = func(); | 167 | m_factory = func(); |
167 | 168 | ||
168 | if( !m_factory ) | 169 | if( !m_factory ) |
169 | { | 170 | { |
170 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; | 171 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; |
171 | return 0; | 172 | return 0; |
172 | } | 173 | } |
173 | 174 | ||
174 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), | 175 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), |
175 | this, SLOT( slotObjectCreated( QObject * ) ) ); | 176 | this, SLOT( slotObjectCreated( QObject * ) ) ); |
176 | 177 | ||
177 | return m_factory; | 178 | return m_factory; |
178 | } | 179 | } |
179 | 180 | ||
180 | void* KLibrary::symbol( const char* symname ) const | 181 | void* KLibrary::symbol( const char* symname ) const |
181 | { | 182 | { |
182 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 183 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
183 | void* sym = m_handle->resolve( symname ); | 184 | void* sym = m_handle->resolve( symname ); |
184 | if ( !sym ) | 185 | if ( !sym ) |
@@ -347,75 +348,91 @@ KLibLoader::~KLibLoader() | |||
347 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); | 348 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); |
348 | for (; it.current(); ++it ) | 349 | for (; it.current(); ++it ) |
349 | { | 350 | { |
350 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name | 351 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name |
351 | << " (" << it.current()->lib << ")" << endl; | 352 | << " (" << it.current()->lib << ")" << endl; |
352 | d->pending_close.append(it.current()); | 353 | d->pending_close.append(it.current()); |
353 | } | 354 | } |
354 | 355 | ||
355 | close_pending(0); | 356 | close_pending(0); |
356 | 357 | ||
357 | delete d; | 358 | delete d; |
358 | } | 359 | } |
359 | 360 | ||
360 | //static | 361 | //static |
361 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) | 362 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) |
362 | { | 363 | { |
363 | QCString libname( name ); | 364 | QCString libname( name ); |
364 | 365 | ||
365 | // only append ".la" if there is no extension | 366 | // only append ".la" if there is no extension |
366 | // this allows to load non-libtool libraries as well | 367 | // this allows to load non-libtool libraries as well |
367 | // (mhk, 20000228) | 368 | // (mhk, 20000228) |
368 | int pos = libname.findRev('/'); | 369 | int pos = libname.findRev('/'); |
369 | if (pos < 0) | 370 | if (pos < 0) |
370 | pos = 0; | 371 | pos = 0; |
371 | if (libname.find('.', pos) < 0) | 372 | /*US |
373 | if (libname.find('.', pos) < 0) { | ||
372 | libname += ".la"; | 374 | libname += ".la"; |
375 | } | ||
376 | */ | ||
377 | //US in the microedition we work only with shared libraries. | ||
378 | if (libname.find('.', pos) < 0) { | ||
379 | libname += ".so"; | ||
380 | } | ||
373 | 381 | ||
374 | // only look up the file if it is not an absolute filename | 382 | // only look up the file if it is not an absolute filename |
375 | // (mhk, 20000228) | 383 | // (mhk, 20000228) |
376 | QString libfile; | 384 | QString libfile; |
377 | if (libname[0] == '/') | 385 | if (libname[0] == '/') |
378 | libfile = libname; | 386 | libfile = libname; |
379 | else | 387 | else |
380 | { | 388 | { |
389 | //US at this point the libname must exist as real filesname. No expansions will be made later | ||
390 | // in findResources. Because of that we prepend the lib prefix here to the name | ||
391 | //US I add also the "lib" prefix. I do not how could this could have worked before without it? | ||
392 | libname.insert(pos, "lib"); | ||
393 | |||
394 | |||
381 | //US libfile = instance->dirs()->findResource( "module", libname ); | 395 | //US libfile = instance->dirs()->findResource( "module", libname ); |
382 | libfile = KGlobal::dirs()->findResource( "module", libname ); | 396 | libfile = KGlobal::dirs()->findResource( "module", libname ); |
383 | if ( libfile.isEmpty() ) | 397 | if ( libfile.isEmpty() ) |
384 | { | 398 | { |
385 | //US libfile = instance->dirs()->findResource( "lib", libname ); | 399 | //US libfile = instance->dirs()->findResource( "lib", libname ); |
386 | libfile = KGlobal::dirs()->findResource( "lib", libname ); | 400 | libfile = KGlobal::dirs()->findResource( "lib", libname ); |
387 | #ifndef NDEBUG | 401 | #ifndef NDEBUG |
388 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules | 402 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules |
389 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; | 403 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; |
390 | #endif | 404 | #endif |
391 | } | 405 | } |
392 | if ( libfile.isEmpty() ) | 406 | if ( libfile.isEmpty() ) |
393 | { | 407 | { |
394 | #ifndef NDEBUG | 408 | #ifndef NDEBUG |
395 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; | 409 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; |
396 | #endif | 410 | #endif |
397 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); | 411 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); |
412 | |||
413 | qDebug("KLibLoader::library could not find library: %s", libname.data()); | ||
414 | |||
398 | } | 415 | } |
399 | else | 416 | else |
400 | self()->d->errorMessage = QString::null; | 417 | self()->d->errorMessage = QString::null; |
401 | } | 418 | } |
402 | return libfile; | 419 | return libfile; |
403 | } | 420 | } |
404 | 421 | ||
405 | 422 | ||
406 | KLibrary* KLibLoader::globalLibrary( const char *name ) | 423 | KLibrary* KLibLoader::globalLibrary( const char *name ) |
407 | { | 424 | { |
408 | KLibrary *tmp; | 425 | KLibrary *tmp; |
409 | /*US | 426 | /*US |
410 | int olt_dlopen_flag = lt_dlopen_flag; | 427 | int olt_dlopen_flag = lt_dlopen_flag; |
411 | 428 | ||
412 | lt_dlopen_flag |= LT_GLOBAL; | 429 | lt_dlopen_flag |= LT_GLOBAL; |
413 | kdDebug(150) << "Loading the next library global with flag " | 430 | kdDebug(150) << "Loading the next library global with flag " |
414 | << lt_dlopen_flag | 431 | << lt_dlopen_flag |
415 | << "." << endl; | 432 | << "." << endl; |
416 | */ | 433 | */ |
417 | tmp = library(name); | 434 | tmp = library(name); |
418 | /*US | 435 | /*US |
419 | lt_dlopen_flag = olt_dlopen_flag; | 436 | lt_dlopen_flag = olt_dlopen_flag; |
420 | */ | 437 | */ |
421 | return tmp; | 438 | return tmp; |
@@ -433,51 +450,48 @@ KLibrary* KLibLoader::library( const char *name ) | |||
433 | wrap->ref_count++; | 450 | wrap->ref_count++; |
434 | return wrap->lib; | 451 | return wrap->lib; |
435 | } | 452 | } |
436 | 453 | ||
437 | /* Test if this library was loaded at some time, but got | 454 | /* Test if this library was loaded at some time, but got |
438 | unloaded meanwhile, whithout being dlclose()'ed. */ | 455 | unloaded meanwhile, whithout being dlclose()'ed. */ |
439 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); | 456 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); |
440 | for (; it.current(); ++it) { | 457 | for (; it.current(); ++it) { |
441 | if (it.current()->name == name) | 458 | if (it.current()->name == name) |
442 | wrap = it.current(); | 459 | wrap = it.current(); |
443 | } | 460 | } |
444 | 461 | ||
445 | if (wrap) { | 462 | if (wrap) { |
446 | d->pending_close.removeRef(wrap); | 463 | d->pending_close.removeRef(wrap); |
447 | if (!wrap->lib) { | 464 | if (!wrap->lib) { |
448 | /* This lib only was in loaded_stack, but not in m_libs. */ | 465 | /* This lib only was in loaded_stack, but not in m_libs. */ |
449 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); | 466 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); |
450 | } | 467 | } |
451 | wrap->ref_count++; | 468 | wrap->ref_count++; |
452 | } else { | 469 | } else { |
453 | QString libfile = findLibrary( name ); | 470 | QString libfile = findLibrary( name ); |
454 | if ( libfile.isEmpty() ) | 471 | if ( libfile.isEmpty() ) |
455 | return 0; | 472 | return 0; |
456 | 473 | ||
457 | const QString & qpeDir = QPEApplication::qpeDir(); | ||
458 | libfile = qpeDir + libfile; | ||
459 | //US QLibrary *lib = new QLibrary( qpeDir + "/plugins/korganizer/libopiekabc.so", QLibrary::Immediately ); | ||
460 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); | 474 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); |
461 | 475 | ||
462 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); | 476 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); |
463 | //US if ( !handle ) | 477 | //US if ( !handle ) |
464 | if ( !qlib ) | 478 | if ( !qlib ) |
465 | { | 479 | { |
466 | //US const char* errmsg = lt_dlerror(); | 480 | //US const char* errmsg = lt_dlerror(); |
467 | char* errmsg; | 481 | char* errmsg; |
468 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); | 482 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); |
469 | qDebug(errmsg); | 483 | qDebug(errmsg); |
470 | 484 | ||
471 | if(errmsg) | 485 | if(errmsg) |
472 | d->errorMessage = QString::fromLatin1(errmsg); | 486 | d->errorMessage = QString::fromLatin1(errmsg); |
473 | else | 487 | else |
474 | d->errorMessage = QString::null; | 488 | d->errorMessage = QString::null; |
475 | kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; | 489 | kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; |
476 | return 0; | 490 | return 0; |
477 | } | 491 | } |
478 | else | 492 | else |
479 | d->errorMessage = QString::null; | 493 | d->errorMessage = QString::null; |
480 | 494 | ||
481 | KLibrary *lib = new KLibrary( name, libfile, qlib ); | 495 | KLibrary *lib = new KLibrary( name, libfile, qlib ); |
482 | wrap = new KLibWrapPrivate(lib, qlib); | 496 | wrap = new KLibWrapPrivate(lib, qlib); |
483 | d->loaded_stack.prepend(wrap); | 497 | d->loaded_stack.prepend(wrap); |