author | zecke <zecke> | 2004-10-14 01:26:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-14 01:26:40 (UTC) |
commit | a1aed5edd5ccef77d79ccdd2d74f5c029d037617 (patch) (side-by-side diff) | |
tree | 64f8342d651e968478df58d1a98db978e950b372 | |
parent | b17b6c77af35b610d236321279d3f18eb3060c90 (diff) | |
download | opie-a1aed5edd5ccef77d79ccdd2d74f5c029d037617.zip opie-a1aed5edd5ccef77d79ccdd2d74f5c029d037617.tar.gz opie-a1aed5edd5ccef77d79ccdd2d74f5c029d037617.tar.bz2 |
Old Patch from BRANCH 1.0 to install Translations of the Plugins
-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 56 |
1 files changed, 13 insertions, 43 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index a4a2875..fb7d7c9 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp @@ -46,30 +46,25 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) { connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); //remove tab with no function tabWidget->removePage( tab ); // Load connections. // /usr/local/kde/lib/libinterfaces.la -#ifdef QWS loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); -#else - loader = KLibLoader::self(); - loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); -#endif getAllInterfaces(); Interfaces i; QStringList list = i.getInterfaceList(); QMap<QString, Interface*>::Iterator it; for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { /* * we skipped it in getAllInterfaces now * we need to ignore it as well */ if (m_handledIfaces.contains( *ni) ) @@ -137,37 +132,33 @@ MainWindowImp::~MainWindowImp() Config cfg("NetworkSetup"); cfg.setGroup("General"); cfg.writeEntry("Profiles", profiles.join(" ")); // Delete all interfaces that don't have owners. QMap<Interface*, QListViewItem*>::Iterator iIt; for( iIt = items.begin(); iIt != items.end(); ++iIt ) { if(iIt.key()->getModuleOwner() == NULL) delete iIt.key(); } -#ifdef QWS // Delete Modules and Libraries QMap<Module*, QLibrary*>::Iterator it; for( it = libraries.begin(); it != libraries.end(); ++it ) { delete it.key(); // I wonder why I can't delete the libraries // What fucking shit this is. //delete it.data(); } -#else - // klibloader automaticly deletes the libraries for us... -#endif } /** * Query the kernel for all of the interfaces. */ void MainWindowImp::getAllInterfaces() { int sockfd = socket(PF_INET, SOCK_DGRAM, 0); if(sockfd == -1) return; struct ifreq ifr; @@ -275,106 +266,85 @@ void MainWindowImp::getAllInterfaces() * @param path a directory that is scaned for any plugins that can be loaded * and attempts to load them */ void MainWindowImp::loadModules(const QString &path) { #ifdef DEBUG odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; #endif QDir d(path); if(!d.exists()) return; + QString lang = ::getenv("LANG"); // Don't want sym links d.setFilter( QDir::Files | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { -#ifdef QWS if(fi->fileName().contains(".so")) { -#else - if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) - { -#endif - loadPlugin(path + "/" + fi->fileName()); + /* if loaded install translation */ + if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ + QTranslator *trans = new QTranslator(qApp); + QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; + if( trans->load( fn ) ) + qApp->installTranslator( trans ); + else + delete trans; + } odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; } ++it; } } /** * Attempt to load a function and resolve a function. * @param pluginFileName - the name of the file in which to attempt to load * @param resolveString - function pointer to resolve * @return pointer to the function with name resolveString or NULL */ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) { #ifdef DEBUG odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; #endif -#ifdef QWS QLibrary *lib = new QLibrary(pluginFileName); void *functionPointer = lib->resolve(resolveString); if( !functionPointer ) { #ifdef DEBUG odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; #endif delete lib; - return NULL; + return 0; } // Try to get an object. Module *object = ((Module* (*)()) functionPointer)(); - if(object == NULL) + if(object == 0) { #ifdef DEBUG odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; #endif delete lib; - return NULL; + return 0; } m_handledIfaces += object->handledInterfaceNames(); // Store for deletion later libraries.insert(object, lib); return object; - -#else - QLibrary *lib = loader->library(pluginFileName); - if( !lib || !lib->hasSymbol(resolveString) ) - { - odebug << QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1() << oendl; - return NULL; - } - // Try to get an object. - Module *object = ((Module* (*)()) lib->symbol(resolveString))(); - if(object == NULL) - { -#ifdef DEBUG - odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; -#endif - return NULL; - } -#ifdef DEBUG - odebug << "MainWindowImp::loadPlugin:: Found object, storing." << oendl; -#endif - // Store for deletion later - libraries.insert(object, lib); - return object; -#endif } /** * The Add button was clicked. Bring up the add dialog and if OK is hit * load the plugin and append it to the list */ void MainWindowImp::addClicked() { QMap<Module*, QLibrary*>::Iterator it; QMap<QString, QString> list; QMap<QString, Module*> newInterfaceOwners; |