summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klibloader.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp
index 130cc7c..c07d50f 100644
--- a/microkde/kdecore/klibloader.cpp
+++ b/microkde/kdecore/klibloader.cpp
@@ -9,49 +9,53 @@
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19//US #include <config.h> 19//US #include <config.h>
20#include <qclipboard.h> 20#include <qclipboard.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qobjectdict.h> 23#include <qobjectdict.h>
24#include <qwidgetlist.h> 24#include <qwidgetlist.h>
25#include <qwidget.h> 25#include <qwidget.h>
26 26
27#include "kapplication.h" 27#include "kapplication.h"
28#include "klibloader.h" 28#include "klibloader.h"
29#include "kstandarddirs.h" 29#include "kstandarddirs.h"
30#include "kdebug.h" 30#include "kdebug.h"
31#include "klocale.h" 31#include "klocale.h"
32 32
33//US #include "ltdl.h" 33/*US
34#ifndef NDEBUG
35#include "ltdl.h"
36#endif
37*/
34 38
35//US do everything through qlibrary 39//US do everything through qlibrary
36#ifndef DESKTOP_VERSION 40#ifndef DESKTOP_VERSION
37#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
38#include <qtopia/qlibrary.h> 42#include <qtopia/qlibrary.h>
39#endif 43#endif
40 44
41/*US 45/*US
42#ifdef Q_WS_X11 46#ifdef Q_WS_X11
43#include <X11/Xlib.h> 47#include <X11/Xlib.h>
44#include <X11/Xatom.h> 48#include <X11/Xatom.h>
45#endif 49#endif
46*/ 50*/
47template class QAsciiDict<KLibrary>; 51template class QAsciiDict<KLibrary>;
48 52
49#include <stdlib.h> //getenv 53#include <stdlib.h> //getenv
50 54
51/*US 55/*US
52#if HAVE_DLFCN_H 56#if HAVE_DLFCN_H
53# include <dlfcn.h> 57# include <dlfcn.h>
54#endif 58#endif
55 59
56#ifdef RTLD_GLOBAL 60#ifdef RTLD_GLOBAL
57# define LT_GLOBAL RTLD_GLOBAL 61# define LT_GLOBAL RTLD_GLOBAL
@@ -132,53 +136,56 @@ KLibrary::~KLibrary()
132 136
133 if ( m_factory ) { 137 if ( m_factory ) {
134 //kdDebug(150) << " ... deleting the factory " << m_factory << endl; 138 //kdDebug(150) << " ... deleting the factory " << m_factory << endl;
135 delete m_factory; 139 delete m_factory;
136 } 140 }
137} 141}
138 142
139QString KLibrary::name() const 143QString KLibrary::name() const
140{ 144{
141 return m_libname; 145 return m_libname;
142} 146}
143 147
144QString KLibrary::fileName() const 148QString KLibrary::fileName() const
145{ 149{
146 return m_filename; 150 return m_filename;
147} 151}
148 152
149KLibFactory* KLibrary::factory() 153KLibFactory* KLibrary::factory()
150{ 154{
151 if ( m_factory ) 155 if ( m_factory )
152 return m_factory; 156 return m_factory;
153 157
154 QCString symname; 158 QCString symname;
155 symname.sprintf("init_%s", name().latin1() ); 159 symname.sprintf("init_%s", name().latin1() );
156 160
157 void* sym = symbol( symname ); 161 void* sym = symbol( symname );
158 if ( !sym ) 162 if ( !sym )
159 { 163 {
160 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); 164 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data());
165#ifndef NDEBUG
166//US qDebug("KLibrary: errorcode: %s", lt_dlerror());
167#endif
161 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; 168 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl;
162 return 0; 169 return 0;
163 } 170 }
164 171
165 typedef KLibFactory* (*t_func)(); 172 typedef KLibFactory* (*t_func)();
166 t_func func = (t_func)sym; 173 t_func func = (t_func)sym;
167 m_factory = func(); 174 m_factory = func();
168 175
169 if( !m_factory ) 176 if( !m_factory )
170 { 177 {
171 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; 178 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl;
172 return 0; 179 return 0;
173 } 180 }
174 181
175 connect( m_factory, SIGNAL( objectCreated( QObject * ) ), 182 connect( m_factory, SIGNAL( objectCreated( QObject * ) ),
176 this, SLOT( slotObjectCreated( QObject * ) ) ); 183 this, SLOT( slotObjectCreated( QObject * ) ) );
177 184
178 return m_factory; 185 return m_factory;
179} 186}
180 187
181void* KLibrary::symbol( const char* symname ) const 188void* KLibrary::symbol( const char* symname ) const
182{ 189{
183//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 190//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
184 void* sym = m_handle->resolve( symname ); 191 void* sym = m_handle->resolve( symname );
@@ -386,52 +393,52 @@ QString KLibLoader::findLibrary( const char * name/*US , const KInstance * insta
386 libfile = libname; 393 libfile = libname;
387 else 394 else
388 { 395 {
389//US at this point the libname must exist as real filesname. No expansions will be made later 396//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 397// 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? 398//US I add also the "lib" prefix. I do not how could this could have worked before without it?
392 libname.insert(pos, "lib"); 399 libname.insert(pos, "lib");
393 400
394 401
395//US libfile = instance->dirs()->findResource( "module", libname ); 402//US libfile = instance->dirs()->findResource( "module", libname );
396 libfile = KGlobal::dirs()->findResource( "module", libname ); 403 libfile = KGlobal::dirs()->findResource( "module", libname );
397 if ( libfile.isEmpty() ) 404 if ( libfile.isEmpty() )
398 { 405 {
399//US libfile = instance->dirs()->findResource( "lib", libname ); 406//US libfile = instance->dirs()->findResource( "lib", libname );
400 libfile = KGlobal::dirs()->findResource( "lib", libname ); 407 libfile = KGlobal::dirs()->findResource( "lib", libname );
401#ifndef NDEBUG 408#ifndef NDEBUG
402 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules 409 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules
403 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; 410 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl;
404#endif 411#endif
405 } 412 }
406 if ( libfile.isEmpty() ) 413 if ( libfile.isEmpty() )
407 { 414 {
408#ifndef NDEBUG 415#ifndef NDEBUG
409 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; 416 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl;
410#endif 417 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 418
413 qDebug("KLibLoader::library could not find library: %s", libname.data()); 419 qDebug("KLibLoader::library could not find library: %s", libname.data());
420#endif
414 421
415 } 422 }
416 else 423 else
417 self()->d->errorMessage = QString::null; 424 self()->d->errorMessage = QString::null;
418 } 425 }
419 return libfile; 426 return libfile;
420} 427}
421 428
422 429
423KLibrary* KLibLoader::globalLibrary( const char *name ) 430KLibrary* KLibLoader::globalLibrary( const char *name )
424{ 431{
425KLibrary *tmp; 432KLibrary *tmp;
426/*US 433/*US
427int olt_dlopen_flag = lt_dlopen_flag; 434int olt_dlopen_flag = lt_dlopen_flag;
428 435
429 lt_dlopen_flag |= LT_GLOBAL; 436 lt_dlopen_flag |= LT_GLOBAL;
430 kdDebug(150) << "Loading the next library global with flag " 437 kdDebug(150) << "Loading the next library global with flag "
431 << lt_dlopen_flag 438 << lt_dlopen_flag
432 << "." << endl; 439 << "." << endl;
433*/ 440*/
434 tmp = library(name); 441 tmp = library(name);
435/*US 442/*US
436 lt_dlopen_flag = olt_dlopen_flag; 443 lt_dlopen_flag = olt_dlopen_flag;
437*/ 444*/