summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/resources.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/resources.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp179
1 files changed, 158 insertions, 21 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 50fb15a..79d41ea 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -6,5 +6,10 @@
6#include <qdir.h> 6#include <qdir.h>
7#include <qmessagebox.h>
8
7#include <qpe/qlibrary.h> 9#include <qpe/qlibrary.h>
8#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11
9#include <opie2/odebug.h> 12#include <opie2/odebug.h>
13#include <opie2/opluginloader.h>
14
10#include <qtopia/resource.h> 15#include <qtopia/resource.h>
@@ -13,2 +18,3 @@
13#include "resources.h" 18#include "resources.h"
19#include "netnodeinterface.h"
14 20
@@ -28,2 +34,5 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
28 // load available netnodes 34 // load available netnodes
35
36#ifdef MYPLUGIN
37
29 findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); 38 findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR );
@@ -68,2 +77,48 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
68 77
78#else
79
80 Plugins = 0;
81 findAvailableNetNodes();
82
83 // compile provides and needs lists
84 { const char ** NeedsRun;
85 QDictIterator<ANetNode> OuterIt( AllNodeTypes );
86 bool Done;
87
88 for ( ; OuterIt.current(); ++OuterIt ) {
89 // find needs list
90 ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList;
91 ANetNode::NetNodeList & NNL = *(NNLP);
92
93 // must iterate this way to avoid duplication pointers
94 for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes );
95 InnerIt.current(); ++InnerIt ) {
96
97 if( InnerIt.current() == OuterIt.current() )
98 // avoid recursive
99 continue;
100
101 const char ** Provides = InnerIt.current()->provides();
102 NeedsRun = OuterIt.current()->needs();
103
104 for( ; *NeedsRun; NeedsRun ++ ) {
105 const char ** PRun;
106 PRun = Provides;
107 for( ; *PRun; PRun ++ ) {
108 if( strcmp( *PRun, *NeedsRun ) == 0 ) {
109 // inner provides what outer needs
110 NNL.resize( NNL.size() + 1 );
111 NNL[NNL.size()-1] = InnerIt.current();
112 Done = 1; // break from 2 loops
113 break;
114 }
115 }
116 }
117 }
118 OuterIt.current()->setAlternatives( NNLP );
119 }
120 }
121
122#endif
123
69 // define built in Node types to Description map 124 // define built in Node types to Description map
@@ -86,3 +141,11 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
86TheNSResources::~TheNSResources( void ) { 141TheNSResources::~TheNSResources( void ) {
142
143#ifndef MYPLUGINS
144 if( Plugins ) {
145 delete Plugins;
146 delete PluginManager;
147 }
148#endif
87 delete TheSystem; 149 delete TheSystem;
150
88} 151}
@@ -118,2 +181,3 @@ void TheNSResources::busy( bool ) {
118 181
182#ifdef MYPLUGIN
119/** 183/**
@@ -162,23 +226,2 @@ void TheNSResources::findAvailableNetNodes(const QString &path){
162 226
163// used to find unique connection number
164int TheNSResources::assignConnectionNumber( void ) {
165 bool found = 1;
166 for( int trial = 0; ; trial ++ ) {
167 found = 1;
168 for( QDictIterator<NodeCollection> it(ConnectionsMap);
169 it.current();
170 ++it ) {
171 if( it.current()->number() == trial ) {
172 found = 0;
173 break;
174 }
175 }
176
177 if( found ) {
178 Log(("Assign profile number %d\n", trial ));
179 return trial;
180 }
181 }
182}
183
184/** 227/**
@@ -229,2 +272,96 @@ bool TheNSResources::loadNetNode(
229 272
273#else
274
275void TheNSResources::findAvailableNetNodes( void ){
276
277 Plugins = new OPluginLoader( "networksettings2" );
278 Plugins->setAutoDelete( true );
279
280 PluginManager = new OPluginManager( Plugins );
281 PluginManager->load();
282
283 if( Plugins->isInSafeMode() ) {
284 QMessageBox::information(
285 0,
286 tr( "Today Error"),
287 tr( "<qt>The plugin '%1' caused Today to crash."
288 " It could be that the plugin is not properly"
289 " installed.<br>Today tries to continue loading"
290 " plugins.</qt>" )
291 .arg( PluginManager->crashedPlugin().name()));
292 }
293
294 // Get All Plugins
295 OPluginLoader::List allplugins = Plugins->filtered();
296
297 for( OPluginLoader::List::Iterator it = allplugins.begin();
298 it != allplugins.end();
299 ++it ) {
300
301 // check if this plugin supports the proper interface
302 NetNodeInterface * interface =
303 Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 );
304
305 if( ! interface ) {
306 Log(( "Plugin %s from %s does not support proper interface\n",
307 it->name().latin1(), it->path().latin1() ));
308 continue;
309 }
310
311 // add the nodes in this plugin to the dictionary
312 { QList<ANetNode> PNN;
313
314 interface->create_plugin( PNN );
315
316 if( PNN.isEmpty() ) {
317 Log(( "Plugin %s from %s does offer any nodes\n",
318 it->name().latin1(), it->path().latin1() ));
319 delete interface;
320 continue;
321 }
322
323 // merge this node with global node
324 for( QListIterator<ANetNode> it(PNN);
325 it.current();
326 ++it ) {
327 AllNodeTypes.insert( it->current()->name(), it->current() );
328 }
329 }
330
331 // load the translation
332 QTranslator *trans = new QTranslator(qApp);
333 QString fn = QPEApplication::qpeDir()+
334 "/i18n/"+lang+"/"+ it->name() + ".qm";
335
336 if( trans->load( fn ) )
337 qApp->installTranslator( trans );
338 else
339 delete trans;
340 }
341
342}
343
344#endif
345
346// used to find unique connection number
347int TheNSResources::assignConnectionNumber( void ) {
348 bool found = 1;
349 for( int trial = 0; ; trial ++ ) {
350 found = 1;
351 for( QDictIterator<NodeCollection> it(ConnectionsMap);
352 it.current();
353 ++it ) {
354 if( it.current()->number() == trial ) {
355 found = 0;
356 break;
357 }
358 }
359
360 if( found ) {
361 Log(("Assign profile number %d\n", trial ));
362 return trial;
363 }
364 }
365}
366
230QPixmap TheNSResources::getPixmap( const QString & QS ) { 367QPixmap TheNSResources::getPixmap( const QString & QS ) {