28 #include <tdeapplication.h>
31 #include <tdemessagebox.h>
32 #include <tdeparts/componentfactory.h>
34 #include "tdecmoduleloader.h"
45 KCMError(
const TQString& msg,
const TQString& details, TQWidget* parent )
48 TQVBoxLayout* topLayout =
new TQVBoxLayout(
this );
49 topLayout->addWidget(
new TQLabel( msg,
this ) );
50 topLayout->addWidget(
new TQLabel( details,
this ) );
59 KLibLoader *loader, ErrorReporting report, TQWidget * parent,
60 const char * name,
const TQStringList & args )
67 TQString initSym(
"init_");
68 initSym += libname.arg(mod.
library());
70 if ( lib->
hasSymbol(TQFile::encodeName(initSym)) )
75 TDECModule *module = KParts::ComponentFactory::createInstanceFromFactory<TDECModule>( factory, TQT_TQOBJECT(parent), name ? name : mod.
handle().latin1(), args );
80 kdDebug(1208) <<
"Unable to load module using ComponentFactory. Falling back to old loader." <<
endl;
84 TQString factory(
"create_%1");
91 func = (
TDECModule* (*)(TQWidget *,
const char *)) create;
92 return func( parent, name ? name : mod.
handle().latin1() );
96 TQString libFileName = lib->
fileName();
98 return reportError( report, i18n(
"<qt>There was an error when loading the module '%1'.<br><br>"
99 "The desktop file (%2) as well as the library (%3) was found but "
100 "yet the module could not be loaded properly. Most likely "
101 "the factory declaration was wrong, or the "
102 "create_* function was missing.</qt>")
106 TQString::null, parent );
111 return reportError( report, i18n(
"The specified library %1 could not be found.")
112 .arg( mod.
library() ), TQString::null, parent );
134 i18n(
"The module %1 could not be found.")
136 i18n(
"<qt><p>The Lisa and lan:/ ioslave modules "
137 "are not installed by default in Kubuntu, because they are obsolete "
138 "and replaced by zeroconf.<br> If you still wish to use them, you "
139 "should install the lisa package from the Universe repository.</p></qt>"),
143 i18n(
"The module %1 could not be found.")
145 i18n(
"<qt><p>The diagnostics is:<br>The desktop file %1 could not be found.</p></qt>").arg(mod.
fileName()),
156 TDECModule *module = load(mod,
"kcm_%1", loader, report, parent, name, args );
162 module = load(mod,
"libkcm_%1", loader, report, parent, name, args );
166 i18n(
"The module %1 could not be loaded.")
167 .arg( mod.
moduleName() ), TQString::null, parent );
185 i18n(
"The module %1 is not a valid configuration module.")
186 .arg( mod.
moduleName() ), i18n(
"<qt><p>The diagnostics is:<br>The desktop file %1 does not specify a library.</qt>").arg(mod.
fileName()), parent );
193 const char *name,
const TQStringList & args)
199 report, TQWidget *parent,
const char *name,
const TQStringList & args)
210 TQString libname(
"libkcm_%1");
220 i18n(
"There was an error loading the module."),i18n(
"<qt><p>The diagnostics is:<br>%1"
221 "<p>Possible reasons:</p><ul><li>An error occurred during your last "
222 "TDE upgrade leaving an orphaned control module<li>You have old third party "
223 "modules lying around.</ul><p>Check these points carefully and try to remove "
224 "the module mentioned in the error message. If this fails, consider contacting "
225 "your distributor or packager.</p></qt>")
243 bool doLoad = module.
service()->property(
"X-TDE-Test-Module", TQVariant::Bool ).toBool();
260 void *test_func = library->
symbol( TQString(TQString(
"test_%1").arg(module.
factoryName())).utf8() );
263 bool (*func)() = (
bool(*)())test_func;
275 kdDebug(1208) <<
"The test function for module '" << module.
fileName() <<
"' could not be found." <<
endl;
279 kdDebug(1208) <<
"The library '" << module.
library() <<
"' could not be found." <<
endl;
285 TQString details, TQWidget * parent )
287 if( details.isNull() )
288 details = i18n(
"<qt><p>The diagnostics is:<br>%1"
289 "<p>Possible reasons:</p><ul><li>An error occurred during your last "
290 "TDE upgrade leaving an orphaned control module<li>You have old third party "
291 "modules lying around.</ul><p>Check these points carefully and try to remove "
292 "the module mentioned in the error message. If this fails, consider contacting "
293 "your distributor or packager.</p></qt>").arg(
KLibLoader::self()->lastErrorMessage());
297 return new KCMError( text, details, parent );