summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp4
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp2
-rw-r--r--libopie2/opiesecurity/multiauthcommon.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index 2a6e369..d33eac6 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -1,905 +1,905 @@
1/* 1/*
2 * LGPLv2 or later 2 * LGPLv2 or later
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5 5
6#include "opluginloader.h" 6#include "opluginloader.h"
7#include "oconfig.h" 7#include "oconfig.h"
8#include "odebug.h" 8#include "odebug.h"
9 9
10#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11 11
12#include <qdir.h> 12#include <qdir.h>
13#include <qdict.h> 13#include <qdict.h>
14#include <qtl.h> 14#include <qtl.h>
15#include <qfile.h> 15#include <qfile.h>
16 16
17#include <stdlib.h> 17#include <stdlib.h>
18 18
19 19
20 20
21namespace Opie { 21namespace Opie {
22namespace Core { 22namespace Core {
23namespace Internal { 23namespace Internal {
24struct OPluginLibraryHolder { 24struct OPluginLibraryHolder {
25 static OPluginLibraryHolder *self(); 25 static OPluginLibraryHolder *self();
26 QLibrary *ref( const QString& ); 26 QLibrary *ref( const QString& );
27 void deref( QLibrary* ); 27 void deref( QLibrary* );
28private: 28private:
29 29
30 OPluginLibraryHolder(); 30 OPluginLibraryHolder();
31 ~OPluginLibraryHolder(); 31 ~OPluginLibraryHolder();
32 QDict<QLibrary> m_libs; 32 QDict<QLibrary> m_libs;
33 static OPluginLibraryHolder* m_self; 33 static OPluginLibraryHolder* m_self;
34}; 34};
35 35
36 OPluginLibraryHolder* OPluginLibraryHolder::m_self = 0; 36 OPluginLibraryHolder* OPluginLibraryHolder::m_self = 0;
37 OPluginLibraryHolder* OPluginLibraryHolder::self() { 37 OPluginLibraryHolder* OPluginLibraryHolder::self() {
38 if ( !m_self ) 38 if ( !m_self )
39 m_self = new OPluginLibraryHolder; 39 m_self = new OPluginLibraryHolder;
40 40
41 return m_self; 41 return m_self;
42 } 42 }
43 43
44 OPluginLibraryHolder::OPluginLibraryHolder() {} 44 OPluginLibraryHolder::OPluginLibraryHolder() {}
45 OPluginLibraryHolder::~OPluginLibraryHolder() {} 45 OPluginLibraryHolder::~OPluginLibraryHolder() {}
46 46
47 /* 47 /*
48 * We do simple ref counting... We will add the QLibrary again 48 * We do simple ref counting... We will add the QLibrary again
49 * and again to the dictionary and on deref we will pop and pop it 49 * and again to the dictionary and on deref we will pop and pop it
50 * until there are no more library and we will unload and delete the library 50 * until there are no more library and we will unload and delete the library
51 * luckily dlopen does some ref counting as well so we don't need 51 * luckily dlopen does some ref counting as well so we don't need
52 * to hack QPEApplication 52 * to hack QPEApplication
53 */ 53 */
54 QLibrary* OPluginLibraryHolder::ref(const QString& str) { 54 QLibrary* OPluginLibraryHolder::ref(const QString& str) {
55 QLibrary *lib = m_libs[str]; 55 QLibrary *lib = m_libs[str];
56 56
57 /* if not in the dict try to load it */ 57 /* if not in the dict try to load it */
58 if ( !lib ) { 58 if ( !lib ) {
59 lib = new QLibrary( str, QLibrary::Immediately ); 59 lib = new QLibrary( str, QLibrary::Immediately );
60 if ( !lib->isLoaded() ) { 60 if ( !lib->isLoaded() ) {
61 delete lib; 61 delete lib;
62 return 0l; 62 return 0l;
63 } 63 }
64 } 64 }
65 65
66 /* now refcount one up */ 66 /* now refcount one up */
67 m_libs.insert( str, lib ); 67 m_libs.insert( str, lib );
68 return lib; 68 return lib;
69 } 69 }
70 70
71 /* 71 /*
72 * 'unshadow' the items until we're the last then unload and delete 72 * 'unshadow' the items until we're the last then unload and delete
73 */ 73 */
74 void OPluginLibraryHolder::deref( QLibrary* lib ) { 74 void OPluginLibraryHolder::deref( QLibrary* lib ) {
75 if ( !lib ) 75 if ( !lib )
76 return; 76 return;
77 77
78 QString str = lib->library(); 78 QString str = lib->library();
79 /* no need to check if the lib was inserted or such */ 79 /* no need to check if the lib was inserted or such */
80 (void) m_libs.take( str ); 80 (void) m_libs.take( str );
81 if ( !m_libs[str] ) { 81 if ( !m_libs[str] ) {
82 lib->unload(); 82 lib->unload();
83 delete lib; 83 delete lib;
84 } 84 }
85 } 85 }
86} 86}
87 87
88/** 88/**
89 * We want values with 30,29,28 at the beginning of the list 89 * We want values with 30,29,28 at the beginning of the list
90 */ 90 */
91 91
92bool operator<( const OPluginItem& l, const OPluginItem& r ) { 92bool operator<( const OPluginItem& l, const OPluginItem& r ) {
93 return l.position() > r.position(); 93 return l.position() > r.position();
94} 94}
95 95
96bool operator>( const OPluginItem& l, const OPluginItem& r ) { 96bool operator>( const OPluginItem& l, const OPluginItem& r ) {
97 return l.position() < r.position(); 97 return l.position() < r.position();
98} 98}
99 99
100bool operator<=( const OPluginItem& l, const OPluginItem& r ) { 100bool operator<=( const OPluginItem& l, const OPluginItem& r ) {
101 return l.position() >= r.position(); 101 return l.position() >= r.position();
102} 102}
103 103
104/** 104/**
105 * \brief Creates an Empty OPluginItem 105 * \brief Creates an Empty OPluginItem
106 * 106 *
107 * create an empty pluginitem. Position is set to -1 and the 107 * create an empty pluginitem. Position is set to -1 and the
108 * other things are used with the default ctors 108 * other things are used with the default ctors
109 */ 109 */
110OPluginItem::OPluginItem() 110OPluginItem::OPluginItem()
111 : m_pos( -1 ) { 111 : m_pos( -1 ) {
112} 112}
113 113
114/** 114/**
115 * @todo Create Internal name so we can have the plugin names translated. Or only for the gui? I'm not yet sure 115 * @todo Create Internal name so we can have the plugin names translated. Or only for the gui? I'm not yet sure
116 * \brief Create an OPluginItem 116 * \brief Create an OPluginItem
117 * 117 *
118 * Create a Plugin Item with all information. If you for some reasons 118 * Create a Plugin Item with all information. If you for some reasons
119 * need to create your own OPluginItems make sure that 'name' is always the same 119 * need to create your own OPluginItems make sure that 'name' is always the same
120 * as it if used for positions and exclude list. 120 * as it if used for positions and exclude list.
121 * 121 *
122 * @param name The if available translated Name 122 * @param name The if available translated Name
123 * @param path The path to the plugin must be absolute. 123 * @param path The path to the plugin must be absolute.
124 * @param b If the OPluginItem is enabled or not 124 * @param b If the OPluginItem is enabled or not
125 * @param pos The position of the plugin if used for sorting 125 * @param pos The position of the plugin if used for sorting
126 * 126 *
127 */ 127 */
128OPluginItem::OPluginItem( const QString& name, const QString& path, bool b, int pos ) 128OPluginItem::OPluginItem( const QString& name, const QString& path, bool b, int pos )
129 : m_name( name ), m_path( path ), m_enabled( b ), m_pos( pos ) 129 : m_name( name ), m_path( path ), m_enabled( b ), m_pos( pos )
130{} 130{}
131 131
132/** 132/**
133 * \brief simple d'tor 133 * \brief simple d'tor
134 */ 134 */
135OPluginItem::~OPluginItem() { 135OPluginItem::~OPluginItem() {
136} 136}
137 137
138/** 138/**
139 * \brief Test if this Item is Empty and does not represent a loadable plugin 139 * \brief Test if this Item is Empty and does not represent a loadable plugin
140 * Test if a OPluginItem is empty. A OPluginItem is empty if name and path are empty 140 * Test if a OPluginItem is empty. A OPluginItem is empty if name and path are empty
141 * ,pos equals -1 and the item is disabled 141 * ,pos equals -1 and the item is disabled
142 * 142 *
143 * @see QString::isEmpty() 143 * @see QString::isEmpty()
144 * 144 *
145 */ 145 */
146bool OPluginItem::isEmpty()const { 146bool OPluginItem::isEmpty()const {
147 if ( m_pos != -1 ) return false; 147 if ( m_pos != -1 ) return false;
148 if ( m_enabled ) return false; 148 if ( m_enabled ) return false;
149 if ( !m_name.isEmpty() ) return false; 149 if ( !m_name.isEmpty() ) return false;
150 if ( !m_path.isEmpty() ) return false; 150 if ( !m_path.isEmpty() ) return false;
151 151
152 return true; 152 return true;
153} 153}
154 154
155/** 155/**
156 * \brief test equality 156 * \brief test equality
157 * operator to test equalness of two OPluginItem 157 * operator to test equalness of two OPluginItem
158 */ 158 */
159bool OPluginItem::operator==( const OPluginItem& r )const{ 159bool OPluginItem::operator==( const OPluginItem& r )const{
160 if ( m_pos != r.m_pos ) return false; 160 if ( m_pos != r.m_pos ) return false;
161 if ( m_enabled != r.m_enabled) return false; 161 if ( m_enabled != r.m_enabled) return false;
162 if ( m_name != r.m_name ) return false; 162 if ( m_name != r.m_name ) return false;
163 if ( m_path != r.m_path ) return false; 163 if ( m_path != r.m_path ) return false;
164 return true; 164 return true;
165} 165}
166 166
167/** 167/**
168 * \brief test non equality 168 * \brief test non equality
169 * operator to test non-equalness of two OPluginItem 169 * operator to test non-equalness of two OPluginItem
170 */ 170 */
171bool OPluginItem::operator!=( const OPluginItem& r )const{ 171bool OPluginItem::operator!=( const OPluginItem& r )const{
172 return !( *this == r ); 172 return !( *this == r );
173} 173}
174 174
175/** 175/**
176 * \brief returns the name of the plugin 176 * \brief returns the name of the plugin
177 * return the name of this Plugin 177 * return the name of this Plugin
178 */ 178 */
179QString OPluginItem::name()const { 179QString OPluginItem::name()const {
180 return m_name; 180 return m_name;
181} 181}
182 182
183/** 183/**
184 * \brief return the path of the plugin 184 * \brief return the path of the plugin
185 */ 185 */
186QString OPluginItem::path()const { 186QString OPluginItem::path()const {
187 return m_path; 187 return m_path;
188} 188}
189 189
190/** 190/**
191 * \brief Return if this item is enabled. 191 * \brief Return if this item is enabled.
192 */ 192 */
193bool OPluginItem::isEnabled()const { 193bool OPluginItem::isEnabled()const {
194 return m_enabled; 194 return m_enabled;
195} 195}
196 196
197/** 197/**
198 * \brief return the position of a plugin. 198 * \brief return the position of a plugin.
199 * return the position of the item 199 * return the position of the item
200 * -1 is the default value and means normally that the whole items are unsorted. 200 * -1 is the default value and means normally that the whole items are unsorted.
201 * Higher numbers belong to an upper position. With plugins with the postions 20,19,5,3 201 * Higher numbers belong to an upper position. With plugins with the postions 20,19,5,3
202 * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader 202 * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader
203 * 203 *
204 * @see OGenericPluginLoader::allAvailable 204 * @see OGenericPluginLoader::allAvailable
205 * @see OGenericPluginLoader::filtered 205 * @see OGenericPluginLoader::filtered
206 */ 206 */
207int OPluginItem::position()const{ 207int OPluginItem::position()const{
208 return m_pos; 208 return m_pos;
209} 209}
210 210
211/** 211/**
212 * \brief set the name of a plugin 212 * \brief set the name of a plugin
213 * Set the name of the Plugin Item 213 * Set the name of the Plugin Item
214 * @param name 214 * @param name
215 */ 215 */
216void OPluginItem::setName( const QString& name ) { 216void OPluginItem::setName( const QString& name ) {
217 m_name = name; 217 m_name = name;
218} 218}
219 219
220/** 220/**
221 * \brief set the path of a plugin 221 * \brief set the path of a plugin
222 * Set the path of Plugin Item. The path must be absolute. 222 * Set the path of Plugin Item. The path must be absolute.
223 * @param name The path of the plugin 223 * @param name The path of the plugin
224 */ 224 */
225void OPluginItem::setPath( const QString& name ) { 225void OPluginItem::setPath( const QString& name ) {
226 m_path = name; 226 m_path = name;
227} 227}
228 228
229/** 229/**
230 * \brief enable or disable the to load attribute 230 * \brief enable or disable the to load attribute
231 * Set the Enabled attribute. Such changes won't be saved. If you want to save it 231 * Set the Enabled attribute. Such changes won't be saved. If you want to save it
232 * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig 232 * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig
233 * for a graphical frontend. 233 * for a graphical frontend.
234 * 234 *
235 * @param enabled Enable or Disable the Enabled Attribute 235 * @param enabled Enable or Disable the Enabled Attribute
236 */ 236 */
237void OPluginItem::setEnabled( bool enabled ) { 237void OPluginItem::setEnabled( bool enabled ) {
238 m_enabled = enabled; 238 m_enabled = enabled;
239} 239}
240 240
241/** 241/**
242 * \brief Set the position. 242 * \brief Set the position.
243 * Set the position 243 * Set the position
244 * @param pos The position 244 * @param pos The position
245 * 245 *
246 * @see position() 246 * @see position()
247 */ 247 */
248void OPluginItem::setPosition( int pos ) { 248void OPluginItem::setPosition( int pos ) {
249 m_pos = pos; 249 m_pos = pos;
250} 250}
251 251
252 252
253 253
254/** 254/**
255 * \brief create a PluginLoader 255 * \brief create a PluginLoader
256 * 256 *
257 * Create a PluginLoader autoDelete is set to false 257 * Create a PluginLoader autoDelete is set to false
258 * 258 *
259 * \code 259 * \code
260 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 260 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
261 * Opie::Core::OPluginItem::List lst = loader.filtered(); 261 * Opie::Core::OPluginItem::List lst = loader.filtered();
262 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 262 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
263 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 263 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
264 * } 264 * }
265 * \endcode 265 * \endcode
266 * 266 *
267 * \code 267 * \code
268 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 268 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
269 * Opie::Core::OPluginItem::List lst = loader.filtered(); 269 * Opie::Core::OPluginItem::List lst = loader.filtered();
270 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 270 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
271 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 271 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
272 * } 272 * }
273 * ... 273 * ...
274 * loader.clear(); 274 * loader.clear();
275 * 275 *
276 * \endcode 276 * \endcode
277 * 277 *
278 * @param name The name of the plugin directory. 278 * @param name The name of the plugin directory.
279 * @param isSorted Tell the PluginLoader if your Plugins are sorted 279 * @param isSorted Tell the PluginLoader if your Plugins are sorted
280 */ 280 */
281OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted) 281OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted)
282 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ), 282 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ),
283 m_isSorted( isSorted ) 283 m_isSorted( isSorted )
284{ 284{
285 setPluginDir( QPEApplication::qpeDir() + "plugins/"+name ); 285 setPluginDir( QPEApplication::qpeDir() + "plugins/"+name );
286 readConfig(); 286 readConfig();
287} 287}
288 288
289 289
290/** 290/**
291 * \brief simple d'tor that cleans up depending on autoDelete 291 * \brief simple d'tor that cleans up depending on autoDelete
292 * 292 *
293 * calls clear if autoDelete is true. This will release all interfaces 293 * calls clear if autoDelete is true. This will release all interfaces
294 * and remove the library from this process if the refcount falls to zero 294 * and remove the library from this process if the refcount falls to zero
295 */ 295 */
296OGenericPluginLoader::~OGenericPluginLoader() { 296OGenericPluginLoader::~OGenericPluginLoader() {
297 if ( m_autoDelete ) 297 if ( m_autoDelete )
298 clear(); 298 clear();
299} 299}
300 300
301/** 301/**
302 * \brief Enable or disable autoDelete on destruction 302 * \brief Enable or disable autoDelete on destruction
303 * 303 *
304 * enable autoDelete. This will call clear on the d'tor 304 * enable autoDelete. This will call clear on the d'tor
305 * 305 *
306 * @see ~OGenericPluginLoader 306 * @see ~OGenericPluginLoader
307 * @see clear() 307 * @see clear()
308 */ 308 */
309void OGenericPluginLoader::setAutoDelete( bool t ) { 309void OGenericPluginLoader::setAutoDelete( bool t ) {
310 m_autoDelete = t; 310 m_autoDelete = t;
311} 311}
312 312
313/** 313/**
314 * \brief See if autoDelete is enabled. 314 * \brief See if autoDelete is enabled.
315 */ 315 */
316bool OGenericPluginLoader::autoDelete()const{ 316bool OGenericPluginLoader::autoDelete()const{
317 return m_autoDelete; 317 return m_autoDelete;
318} 318}
319 319
320/** 320/**
321 * \brief unload all loaded Plugins 321 * \brief unload all loaded Plugins
322 * 322 *
323 * This will unload all returned QUnknownInterfaces by load. Unload 323 * This will unload all returned QUnknownInterfaces by load. Unload
324 * will be called. 324 * will be called.
325 */ 325 */
326void OGenericPluginLoader::clear() { 326void OGenericPluginLoader::clear() {
327 QPtrDictIterator<QLibrary> it( m_library ); 327 QPtrDictIterator<QLibrary> it( m_library );
328 for ( ;it.current(); ) 328 for ( ;it.current(); )
329 unload( static_cast<QUnknownInterface*>( it.currentKey() ) ); 329 unload( static_cast<QUnknownInterface*>( it.currentKey() ) );
330} 330}
331 331
332/** 332/**
333 * \brief unload the Plugin and the accompanied Resources. 333 * \brief unload the Plugin and the accompanied Resources.
334 * 334 *
335 * This will take the iface from the internal QPtrDict, Release it, 335 * This will take the iface from the internal QPtrDict, Release it,
336 * and deref the libray used. 336 * and deref the libray used.
337 * The visibility depends on the QPtrDict. 337 * The visibility depends on the QPtrDict.
338 * @see QPtrDict::insert 338 * @see QPtrDict::insert
339 */ 339 */
340void OGenericPluginLoader::unload( QUnknownInterface* iface ) { 340void OGenericPluginLoader::unload( QUnknownInterface* iface ) {
341 if ( !iface ) 341 if ( !iface )
342 return; 342 return;
343 343
344 iface->release(); 344 iface->release();
345 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) ); 345 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) );
346} 346}
347 347
348/** 348/**
349 * \brief The name of the plugins. 349 * \brief The name of the plugins.
350 * 350 *
351 * Return the name/type you specified in the constructor. 351 * Return the name/type you specified in the constructor.
352 * This is at least used by the OPluginManager to find the right config 352 * This is at least used by the OPluginManager to find the right config
353 */ 353 */
354QString OGenericPluginLoader::name()const { 354QString OGenericPluginLoader::name()const {
355 return m_dir; 355 return m_dir;
356} 356}
357 357
358 358
359/** 359/**
360 * \brief See if loading of a plugin segfaulted 360 * \brief See if loading of a plugin segfaulted
361 * This tells you 361 * This tells you
362 * if by previous tries to load, loading crashed your application. 362 * if by previous tries to load, loading crashed your application.
363 * If isInSafeMode you can use the GUI to configure the plugins prior to loading 363 * If isInSafeMode you can use the GUI to configure the plugins prior to loading
364 * 364 *
365 * @return true if prior loading failed 365 * @return true if prior loading failed
366 */ 366 */
367bool OGenericPluginLoader::isInSafeMode()const { 367bool OGenericPluginLoader::isInSafeMode()const {
368 return m_isSafeMode; 368 return m_isSafeMode;
369} 369}
370 370
371 371
372/** 372/**
373 * \brief Return all Plugins found in the plugins dirs. 373 * \brief Return all Plugins found in the plugins dirs.
374 * Return the list of all available plugins. This will go through all plugin 374 * Return the list of all available plugins. This will go through all plugin
375 * directories and search for your type of plugins ( by subdir ) 375 * directories and search for your type of plugins ( by subdir )
376 * 376 *
377 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you 377 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you
378 */ 378 */
379OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { 379OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const {
380 OPluginItem::List lst; 380 OPluginItem::List lst;
381 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 381 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
382 lst += plugins( *it, sorted, false ); 382 lst += plugins( *it, sorted, false );
383 383
384 if ( sorted ) 384 if ( sorted )
385 qHeapSort( lst ); 385 qHeapSort( lst );
386 return lst; 386 return lst;
387} 387}
388 388
389/** 389/**
390 * \brief Return only the enabled plugins 390 * \brief Return only the enabled plugins
391 * Return only activated plugins. 391 * Return only activated plugins.
392 * 392 *
393 * @param sorted If the list should be sorted 393 * @param sorted If the list should be sorted
394 */ 394 */
395OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { 395OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const {
396 OPluginItem::List lst; 396 OPluginItem::List lst;
397 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 397 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
398 lst += plugins( *it, sorted, true ); 398 lst += plugins( *it, sorted, true );
399 399
400 if ( sorted ) 400 if ( sorted )
401 qHeapSort( lst ); 401 qHeapSort( lst );
402 return lst; 402 return lst;
403} 403}
404 404
405 405
406/** 406/**
407 * \brief Load a OPluginItem for the specified interface 407 * \brief Load a OPluginItem for the specified interface
408 * This will open the resource of the OPluginItem::path() and then will query 408 * This will open the resource of the OPluginItem::path() and then will query
409 * if the Interface specified in the uuid is available and then will manage the 409 * if the Interface specified in the uuid is available and then will manage the
410 * resource and Interface. 410 * resource and Interface.
411 * 411 *
412 * @param item The OPluginItem that should be loaded 412 * @param item The OPluginItem that should be loaded
413 * @param uuid The Interface to query for 413 * @param uuid The Interface to query for
414 * 414 *
415 * @return Either 0 in case of failure or the Plugin as QUnknownInterface* 415 * @return Either 0 in case of failure or the Plugin as QUnknownInterface*
416 */ 416 */
417QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { 417QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
418 /* 418 /*
419 * Check if there could be a library 419 * Check if there could be a library
420 */ 420 */
421 QString pa = item.path(); 421 QString pa = item.path();
422 if ( pa.isEmpty() ) 422 if ( pa.isEmpty() )
423 return 0l; 423 return 0l;
424 424
425 /* 425 /*
426 * See if we get a library 426 * See if we get a library
427 * return if we've none 427 * return if we've none
428 */ 428 */
429 setSafeMode( pa, true ); 429 setSafeMode( pa, true );
430 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); 430 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
431 if ( !lib ) { 431 if ( !lib ) {
432 setSafeMode(); 432 setSafeMode();
433 return 0l; 433 return 0l;
434 } 434 }
435 435
436 /** 436 /**
437 * try to load the plugin and just in case initialize the pointer to a pointer again 437 * try to load the plugin and just in case initialize the pointer to a pointer again
438 */ 438 */
439 QUnknownInterface* iface=0; 439 QUnknownInterface* iface=0;
440 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { 440 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) {
441 installTranslators( item.name() ); 441 installTranslators( item.name() );
442 m_library.insert( iface, lib ); 442 m_library.insert( iface, lib );
443 }else 443 }else
444 iface = 0; 444 iface = 0;
445 445
446 setSafeMode(); 446 setSafeMode();
447 447
448 return iface; 448 return iface;
449} 449}
450 450
451/** 451/**
452 * @internal and reads in the safe mode 452 * @internal and reads in the safe mode
453 */ 453 */
454void OGenericPluginLoader::readConfig() { 454void OGenericPluginLoader::readConfig() {
455 455
456 456
457/* read the config for SafeMode */ 457/* read the config for SafeMode */
458 OConfig conf( m_dir + "-odpplugins" ); 458 OConfig conf( m_dir + "-odpplugins" );
459 conf.setGroup( "General" ); 459 conf.setGroup( "General" );
460 m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); 460 m_isSafeMode = conf.readBoolEntry( "SafeMode", false );
461} 461}
462 462
463/** 463/**
464 * @internal Enter or leave SafeMode 464 * @internal Enter or leave SafeMode
465 */ 465 */
466void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { 466void OGenericPluginLoader::setSafeMode(const QString& str, bool b) {
467 OConfig conf( m_dir + "-odpplugins" ); 467 OConfig conf( m_dir + "-odpplugins" );
468 conf.setGroup( "General" ); 468 conf.setGroup( "General" );
469 conf.writeEntry( "SafeMode", b ); 469 conf.writeEntry( "SafeMode", b );
470 conf.writeEntry( "CrashedPlugin", str ); 470 conf.writeEntry( "CrashedPlugin", str );
471} 471}
472 472
473/** 473/**
474 * @internal 474 * @internal
475 * 475 *
476 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype 476 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"plugins/"+mytype
477 * is used as plugin dir 477 * is used as plugin dir
478 */ 478 */
479void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { 479void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) {
480 m_plugDirs = lst; 480 m_plugDirs = lst;
481} 481}
482 482
483/** 483/**
484 * 484 *
485 * @internal 485 * @internal
486 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs 486 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs
487 */ 487 */
488void OGenericPluginLoader::setPluginDir( const QString& str) { 488void OGenericPluginLoader::setPluginDir( const QString& str) {
489 m_plugDirs.clear(); 489 m_plugDirs.clear();
490 m_plugDirs.append( str ); 490 m_plugDirs.append( str );
491} 491}
492 492
493 493
494/** 494/**
495 * @internal 495 * @internal
496 */ 496 */
497bool OGenericPluginLoader::isSorted()const{ 497bool OGenericPluginLoader::isSorted()const{
498 return m_isSorted; 498 return m_isSorted;
499} 499}
500 500
501/* 501/*
502 * make libfoo.so.1.0.0 -> foo on UNIX 502 * make libfoo.so.1.0.0 -> foo on UNIX
503 * make libfoo.dylib -> foo on MAC OS X Unix 503 * make libfoo.dylib -> foo on MAC OS X Unix
504 * windows is obviously missing 504 * windows is obviously missing
505 */ 505 */
506/** 506/**
507 * @internal 507 * @internal
508 */ 508 */
509QString OGenericPluginLoader::unlibify( const QString& str ) { 509QString OGenericPluginLoader::unlibify( const QString& str ) {
510 QString st = str.mid( str.find( "lib" )+3 ); 510 QString st = str.mid( str.find( "lib" )+3 );
511#ifdef Q_OS_MACX 511#ifdef Q_OS_MACX
512 return st.left( st.findRev( ".dylib" ) ); 512 return st.left( st.findRev( ".dylib" ) );
513#else 513#else
514 return st.left( st.findRev( ".so" ) ); 514 return st.left( st.findRev( ".so" ) );
515#endif 515#endif
516} 516}
517 517
518/** 518/**
519 * @internal 519 * @internal
520 * 520 *
521 * \brief method to return available plugins. Internal and for reeimplementations 521 * \brief method to return available plugins. Internal and for reeimplementations
522 * 522 *
523 *Return a List of Plugins for a dir and add positions and remove disabled. 523 *Return a List of Plugins for a dir and add positions and remove disabled.
524 * If a plugin is on the excluded list assign position -2 524 * If a plugin is on the excluded list assign position -2
525 * 525 *
526 * @param _dir The dir to look in 526 * @param _dir The dir to look in
527 * @param sorted Should positions be read? 527 * @param sorted Should positions be read?
528 * @param disabled Remove excluded from the list 528 * @param disabled Remove excluded from the list
529 */ 529 */
530OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { 530OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
531#ifdef Q_OS_MACX 531#ifdef Q_OS_MACX
532 QDir dir( _dir, "lib*.dylib" ); 532 QDir dir( _dir, "lib*.dylib" );
533#else 533#else
534 QDir dir( _dir, "lib*.so" ); 534 QDir dir( _dir, "lib*.so" );
535#endif 535#endif
536 536
537 537
538 OPluginItem::List lst; 538 OPluginItem::List lst;
539 539
540 /* 540 /*
541 * get excluded list and then iterate over them 541 * get excluded list and then iterate over them
542 * Excluded list contains the name 542 * Excluded list contains the name
543 * Position is a list with 'name.pos.name.pos.name.pos' 543 * Position is a list with 'name.pos.name.pos.name.pos'
544 * 544 *
545 * For the look up we will create two QMap<QString,pos> 545 * For the look up we will create two QMap<QString,pos>
546 */ 546 */
547 QMap<QString, int> positionMap; 547 QMap<QString, int> positionMap;
548 QMap<QString, int> excludedMap; 548 QMap<QString, int> excludedMap;
549 549
550 550
551 OConfig cfg( m_dir+"-odpplugins" ); 551 OConfig cfg( m_dir+"-odpplugins" );
552 cfg.setGroup( _dir ); 552 cfg.setGroup( _dir );
553 553
554 554
555 QStringList excludes = cfg.readListEntry( "Excluded", ',' ); 555 QStringList excludes = cfg.readListEntry( "Excluded", ',' );
556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) 556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
557 excludedMap.insert( *it, -2 ); 557 excludedMap.insert( *it, -2 );
558 558
559 if ( sorted ) { 559 if ( sorted ) {
560 QStringList pos = cfg.readListEntry( "Positions", '.' ); 560 QStringList pos = cfg.readListEntry( "Positions", '.' );
561 QStringList::Iterator it = pos.begin(); 561 QStringList::Iterator it = pos.begin();
562 QString tmp; int i; 562 QString tmp; int i;
563 while ( it != pos.end() ) { 563 while ( it != pos.end() ) {
564 tmp = *it++; i = (*it++).toInt(); 564 tmp = *it++; i = (*it++).toInt();
565 positionMap.insert( tmp, i ); 565 positionMap.insert( tmp, i );
566 } 566 }
567 567
568 } 568 }
569 569
570 570
571 571
572 572
573 QStringList list = dir.entryList(); 573 QStringList list = dir.entryList();
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QString str = unlibify( *it ); 575 QString str = unlibify( *it );
576 OPluginItem item( str, _dir + "/" + *it ); 576 OPluginItem item( str, _dir + "/" + *it );
577 577
578 bool ex = excludedMap.contains( str ); 578 bool ex = excludedMap.contains( str );
579 /* 579 /*
580 * if disabled but we should show all mark it as disabled 580 * if disabled but we should show all mark it as disabled
581 * else continue because we don't want to add the item 581 * else continue because we don't want to add the item
582 * else if sorted we assign the right position 582 * else if sorted we assign the right position
583 */ 583 */
584 if ( ex && !disabled) 584 if ( ex && !disabled)
585 item.setEnabled( false ); 585 item.setEnabled( false );
586 else if ( ex && disabled ) 586 else if ( ex && disabled )
587 continue; 587 continue;
588 else if ( sorted ) 588 else if ( sorted )
589 item.setPosition( positionMap[str] ); 589 item.setPosition( positionMap[str] );
590 590
591 591
592 lst.append( item ); 592 lst.append( item );
593 } 593 }
594 594
595 return lst; 595 return lst;
596} 596}
597 597
598/** 598/**
599 * @internal generate a list of languages from $LANG 599 * @internal generate a list of languages from $LANG
600 */ 600 */
601QStringList OGenericPluginLoader::languageList() { 601QStringList OGenericPluginLoader::languageList() {
602 if ( m_languages.isEmpty() ) { 602 if ( m_languages.isEmpty() ) {
603 /* 603 /*
604 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be 604 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
605 * to our list of languages. 605 * to our list of languages.
606 * Also for de_DE@euro we will add de_DE@eurp, de_DE, de 606 * Also for de_DE@euro we will add de_DE@eurp, de_DE, de
607 * to our list of languages 607 * to our list of languages
608 */ 608 */
609 QString str = ::getenv( "LANG" ); 609 QString str = ::getenv( "LANG" );
610 m_languages += str; 610 m_languages += str;
611 int pos = str.find( '@' ); 611 int pos = str.find( '@' );
612 if( pos > 0 ) 612 if( pos > 0 )
613 m_languages += str.left( pos ); 613 m_languages += str.left( pos );
614 614
615 615
616 pos = str.find( '.' ); 616 pos = str.find( '.' );
617 if ( pos > 0 ) 617 if ( pos > 0 )
618 m_languages += str.left( pos ); 618 m_languages += str.left( pos );
619 619
620 int n_pos = str.find( '_' ); 620 int n_pos = str.find( '_' );
621 if ( n_pos > 0 ) 621 if ( n_pos > 0 )
622 m_languages += str.left( n_pos ); 622 m_languages += str.left( n_pos );
623 623
624 } 624 }
625 return m_languages; 625 return m_languages;
626} 626}
627 627
628/** 628/**
629 * @internal 629 * @internal
630 * Tries to install languages using the languageList for the type 630 * Tries to install languages using the languageList for the type
631 */ 631 */
632void OGenericPluginLoader::installTranslators(const QString& type) { 632void OGenericPluginLoader::installTranslators(const QString& type) {
633 QStringList lst = languageList(); 633 QStringList lst = languageList();
634 634
635 /* 635 /*
636 * for each language and maybe later for each language dir... 636 * for each language and maybe later for each language dir...
637 * try to load a Translator 637 * try to load a Translator
638 */ 638 */
639 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 639 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
640 QTranslator* trans = new QTranslator( qApp ); 640 QTranslator* trans = new QTranslator( qApp );
641 QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ; 641 QString tfn = QPEApplication::qpeDir()+"i18n/" + *it + "/lib" + type + ".qm" ;
642 642
643 /* 643 /*
644 * If loaded then install else clean up and don't leak 644 * If loaded then install else clean up and don't leak
645 */ 645 */
646 if ( trans->load( tfn ) ) 646 if ( trans->load( tfn ) )
647 qApp->installTranslator( trans ); 647 qApp->installTranslator( trans );
648 else 648 else
649 delete trans; 649 delete trans;
650 } 650 }
651} 651}
652 652
653/** 653/**
654 * \brief Simple c'tor. 654 * \brief Simple c'tor.
655 * 655 *
656 * Simple C'tor same as the one of the base class. Additional this 656 * Simple C'tor same as the one of the base class. Additional this
657 * class can cast for you if you nee it. 657 * class can cast for you if you nee it.
658 * 658 *
659 * 659 *
660 * @param name The name of your plugin class 660 * @param name The name of your plugin class
661 * @param sorted If plugins are sorted 661 * @param sorted If plugins are sorted
662 * 662 *
663 * @see OGenericPluginLoader 663 * @see OGenericPluginLoader
664 */ 664 */
665OPluginLoader::OPluginLoader( const QString& name, bool sorted ) 665OPluginLoader::OPluginLoader( const QString& name, bool sorted )
666 : OGenericPluginLoader( name, sorted ) 666 : OGenericPluginLoader( name, sorted )
667{ 667{
668} 668}
669 669
670/** 670/**
671 * d'tor 671 * d'tor
672 * @see OGenericPluginLoader::~OGenericPluginLoader 672 * @see OGenericPluginLoader::~OGenericPluginLoader
673 */ 673 */
674OPluginLoader::~OPluginLoader() { 674OPluginLoader::~OPluginLoader() {
675} 675}
676 676
677/** 677/**
678 * \brief C'Tor using a OGenericPluginLoader 678 * \brief C'Tor using a OGenericPluginLoader
679 * The C'tor. Pass your OGenericPluginLoader to manage 679 * The C'tor. Pass your OGenericPluginLoader to manage
680 * OGenericPluginLoader::allAvailable plugins. 680 * OGenericPluginLoader::allAvailable plugins.
681 * 681 *
682 * 682 *
683 * @param loader A Pointer to your OGenericPluginLoader 683 * @param loader A Pointer to your OGenericPluginLoader
684 */ 684 */
685OPluginManager::OPluginManager( OGenericPluginLoader* loader) 685OPluginManager::OPluginManager( OGenericPluginLoader* loader)
686 : m_loader( loader ), m_isSorted( false ) 686 : m_loader( loader ), m_isSorted( false )
687{ 687{
688} 688}
689 689
690/** 690/**
691 * \brief Overloaded c'tor using a List of Plugins and a type name 691 * \brief Overloaded c'tor using a List of Plugins and a type name
692 * Overloaded Constructor to work with a 'Type' of plugins 692 * Overloaded Constructor to work with a 'Type' of plugins
693 * and a correspending list of those. In this case calling load 693 * and a correspending list of those. In this case calling load
694 * is a no operation. 694 * is a no operation.
695 * 695 *
696 * @param name The name of your plugin ('today','inputmethods','applets') 696 * @param name The name of your plugin ('today','inputmethods','applets')
697 * @param lst A List with plugins of your type to manage 697 * @param lst A List with plugins of your type to manage
698 * @param isSorted If the List should be treated sorted 698 * @param isSorted If the List should be treated sorted
699 */ 699 */
700OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted) 700OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted)
701 : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted ) 701 : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted )
702{ 702{
703} 703}
704 704
705/** 705/**
706 * \brief A simple d'tor 706 * \brief A simple d'tor
707 */ 707 */
708OPluginManager::~OPluginManager() { 708OPluginManager::~OPluginManager() {
709} 709}
710 710
711/** 711/**
712 * \brief Return the OPluginItem where loading is likely to have crashed on. 712 * \brief Return the OPluginItem where loading is likely to have crashed on.
713 713
714 * Return the Item that made the OGenericPluginLoader crash 714 * Return the Item that made the OGenericPluginLoader crash
715 * the returned OPluginItem could be empty if no crash occured 715 * the returned OPluginItem could be empty if no crash occured
716 * which should apply most of the time. It could also be empty if the crashed 716 * which should apply most of the time. It could also be empty if the crashed
717 * plugin is not in the current list of available/managed plugins 717 * plugin is not in the current list of available/managed plugins
718 * 718 *
719 * @see OPluginItem::isEmpty 719 * @see OPluginItem::isEmpty
720 * @return OPluginItem that crashed the loader 720 * @return OPluginItem that crashed the loader
721 */ 721 */
722OPluginItem OPluginManager::crashedPlugin()const { 722OPluginItem OPluginManager::crashedPlugin()const {
723 return m_crashed; 723 return m_crashed;
724} 724}
725 725
726/** 726/**
727 * \brief Return a list of plugins that are managed by this OPluginManager 727 * \brief Return a list of plugins that are managed by this OPluginManager
728 * 728 *
729 * Return the list of managed plugins. This could either result 729 * Return the list of managed plugins. This could either result
730 * from passing a OGenericPluginLoader and calling load or by 730 * from passing a OGenericPluginLoader and calling load or by
731 * giving name and a list of plugins. 731 * giving name and a list of plugins.
732 */ 732 */
733OPluginItem::List OPluginManager::managedPlugins()const { 733OPluginItem::List OPluginManager::managedPlugins()const {
734 return m_plugins; 734 return m_plugins;
735} 735}
736 736
737/** 737/**
738 * \brief Set the position of the items 738 * \brief Set the position of the items
739 * 739 *
740 * Replace the OPluginItem with the name and path and this way 740 * Replace the OPluginItem with the name and path and this way
741 * apply the new position. The search is linear and this way O(n/2) 741 * apply the new position. The search is linear and this way O(n/2)
742 * You still need to call save() to make your changes effective. After saving 742 * You still need to call save() to make your changes effective. After saving
743 * a call to OGenericPluginLoader::filtered() returns the newly configured order and items 743 * a call to OGenericPluginLoader::filtered() returns the newly configured order and items
744 * 744 *
745 * @param item The OPluginItem to be replaced internall 745 * @param item The OPluginItem to be replaced internall
746 * 746 *
747 */ 747 */
748void OPluginManager::setPosition( const OPluginItem& item) { 748void OPluginManager::setPosition( const OPluginItem& item) {
749 replace( item ); 749 replace( item );
750} 750}
751 751
752/** 752/**
753 * \brief Enable the item specified as argument 753 * \brief Enable the item specified as argument
754 * 754 *
755 * This will make sure that OPluginItem::setEnabled is called and then will replace 755 * This will make sure that OPluginItem::setEnabled is called and then will replace
756 * the item with one that matches name and path internally. 756 * the item with one that matches name and path internally.
757 * @see setPosition 757 * @see setPosition
758 * 758 *
759 * @param item the Item to enable 759 * @param item the Item to enable
760 */ 760 */
761void OPluginManager::enable( const OPluginItem& item ) { 761void OPluginManager::enable( const OPluginItem& item ) {
762 setEnabled( item, true ); 762 setEnabled( item, true );
763} 763}
764 764
765/** 765/**
766 * \brief disable the Item. 766 * \brief disable the Item.
767 * 767 *
768 * Disable the OPluginItem. Same applies as in 768 * Disable the OPluginItem. Same applies as in
769 * @see setPosition and @see enable 769 * @see setPosition and @see enable
770 * 770 *
771 * @param item Item to disable 771 * @param item Item to disable
772 */ 772 */
773void OPluginManager::disable( const OPluginItem& item) { 773void OPluginManager::disable( const OPluginItem& item) {
774 setEnabled( item, false ); 774 setEnabled( item, false );
775} 775}
776 776
777/** 777/**
778 * \brief Enable or disable the OPluginItem. 778 * \brief Enable or disable the OPluginItem.
779 * Depending on the value of the parameter this will either disable 779 * Depending on the value of the parameter this will either disable
780 * or enable the pluginitem. 780 * or enable the pluginitem.
781 * Beside that same as in @see disable, @see enable, @see setPosition 781 * Beside that same as in @see disable, @see enable, @see setPosition
782 * applies. 782 * applies.
783 * 783 *
784 * @param _item The OPluginItem to enable or to disable. 784 * @param _item The OPluginItem to enable or to disable.
785 * @param b Enable or disable the plugin. 785 * @param b Enable or disable the plugin.
786 * 786 *
787 */ 787 */
788void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) { 788void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
789 OPluginItem item = _item; 789 OPluginItem item = _item;
790 item.setEnabled( b ); 790 item.setEnabled( b );
791 replace( item ); 791 replace( item );
792} 792}
793 793
794/** 794/**
795 * \brief Load necessary information after constructing the object 795 * \brief Load necessary information after constructing the object
796 * If you speified a OGenericPluginLoader you need to call this method 796 * If you speified a OGenericPluginLoader you need to call this method
797 * so that this manager knows what to manage and have a right value for \sa crashedPlugin 797 * so that this manager knows what to manage and have a right value for \sa crashedPlugin
798 * For the name and the list of plugins this does only try to find out the crashed plugin 798 * For the name and the list of plugins this does only try to find out the crashed plugin
799 */ 799 */
800void OPluginManager::load() { 800void OPluginManager::load() {
801 OConfig cfg( configName() ); 801 OConfig cfg( configName() );
802 cfg.setGroup( "General" ); 802 cfg.setGroup( "General" );
803 QString crashedPath = cfg.readEntry( "CrashedPlugin" ); 803 QString crashedPath = cfg.readEntry( "CrashedPlugin" );
804 804
805 /* if we've a loader this applies if we were called from the first part */ 805 /* if we've a loader this applies if we were called from the first part */
806 if ( m_loader ) 806 if ( m_loader )
807 m_plugins = m_loader->allAvailable( m_loader->isSorted() ); 807 m_plugins = m_loader->allAvailable( m_loader->isSorted() );
808 808
809 /* fast and normal route if we did not crash... */ 809 /* fast and normal route if we did not crash... */
810 if ( crashedPath.isEmpty() ) 810 if ( crashedPath.isEmpty() )
811 return; 811 return;
812 812
813 /* lets try to find the plugin path and this way the associated item */ 813 /* lets try to find the plugin path and this way the associated item */
814 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) 814 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it )
815 if ( (*it).path() == crashedPath ) { 815 if ( (*it).path() == crashedPath ) {
816 m_crashed = *it; 816 m_crashed = *it;
817 break; 817 break;
818 } 818 }
819} 819}
820 820
821 821
822/** 822/**
823 * \brief Save the values and this way make it available. 823 * \brief Save the values and this way make it available.
824 * 824 *
825 * Save the current set of data. A call to @see OGenericPluginLoader::filtered 825 * Save the current set of data. A call to @see OGenericPluginLoader::filtered
826 * now would return your saved changes. 826 * now would return your saved changes.
827 */ 827 */
828void OPluginManager::save() { 828void OPluginManager::save() {
829 QMap<QString, QStringList> excluded; // map for path to excluded name 829 QMap<QString, QStringList> excluded; // map for path to excluded name
830 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs 830 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
831 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; 831 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
832 832
833 /* 833 /*
834 * We will create some maps for the groups to include positions a 834 * We will create some maps for the groups to include positions a
835 */ 835 */
836 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { 836 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
837 OPluginItem item = *it; 837 OPluginItem item = *it;
838 QString path = QFileInfo( item.path() ).dirPath(true); 838 QString path = QFileInfo( item.path() ).dirPath(true);
839 if ( sorted ) { 839 if ( sorted ) {
840 positions[path].append( item.name() ); 840 positions[path].append( item.name() );
841 positions[path].append( QString::number( item.position() ) ); 841 positions[path].append( QString::number( item.position() ) );
842 } 842 }
843 843
844 if ( !item.isEnabled() ) 844 if ( !item.isEnabled() )
845 excluded[path].append( item.name() ); 845 excluded[path].append( item.name() );
846 if ( !excluded.contains( path ) ) 846 if ( !excluded.contains( path ) )
847 excluded[path] = QString::null; 847 excluded[path] = QString::null;
848 848
849 } 849 }
850 850
851/* 851/*
852 * The code below wouldn't work because we can't delete groups/keys from the config 852 * The code below wouldn't work because we can't delete groups/keys from the config
853 * ### for ODP make Config right! 853 * ### for ODP make Config right!
854 */ 854 */
855// if ( excluded.isEmpty() && positions.isEmpty() ) return; 855// if ( excluded.isEmpty() && positions.isEmpty() ) return;
856 /* 856 /*
857 * Now safe for each path 857 * Now safe for each path
858 */ 858 */
859 OConfig cfg( configName() ); 859 OConfig cfg( configName() );
860 860
861 /* safe excluded items */ 861 /* safe excluded items */
862 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { 862 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
863 OConfigGroupSaver saver( &cfg, it.key() ); 863 OConfigGroupSaver saver( &cfg, it.key() );
864 cfg.writeEntry("Excluded", it.data(), ',' ); 864 cfg.writeEntry("Excluded", it.data(), ',' );
865 } 865 }
866 866
867 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop 867 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop
868 * ### Write a Test Suite that can profile these runs... 868 * ### Write a Test Suite that can profile these runs...
869 */ 869 */
870 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { 870 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) {
871 OConfigGroupSaver saver( &cfg, it.key() ); 871 OConfigGroupSaver saver( &cfg, it.key() );
872 cfg.writeEntry("Positions", it.data(), '.' ); 872 cfg.writeEntry("Positions", it.data(), '.' );
873 } 873 }
874} 874}
875 875
876/** 876/**
877 * @internal 877 * @internal
878 */ 878 */
879QString OPluginManager::configName()const { 879QString OPluginManager::configName()const {
880 QString str = m_loader ? m_loader->name() : m_cfgName; 880 QString str = m_loader ? m_loader->name() : m_cfgName;
881 return str + "-odpplugins"; 881 return str + "-odpplugins";
882} 882}
883 883
884/** 884/**
885 * @internal.. replace in m_plugins by path... this is linear search O(n/2) 885 * @internal.. replace in m_plugins by path... this is linear search O(n/2)
886 */ 886 */
887void OPluginManager::replace( const OPluginItem& item ) { 887void OPluginManager::replace( const OPluginItem& item ) {
888 OPluginItem _item; 888 OPluginItem _item;
889 889
890 /* for all plugins */ 890 /* for all plugins */
891 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) { 891 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) {
892 _item = *it; 892 _item = *it;
893 /* if path and name are the same we will remove, readd and return */ 893 /* if path and name are the same we will remove, readd and return */
894 if ( _item.path() == item.path() && 894 if ( _item.path() == item.path() &&
895 _item.name() == item.name() ) { 895 _item.name() == item.name() ) {
896 it = m_plugins.remove( it ); 896 it = m_plugins.remove( it );
897 m_plugins.append( item ); 897 m_plugins.append( item );
898 return; 898 return;
899 } 899 }
900 900
901 } 901 }
902} 902}
903 903
904} 904}
905} 905}
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index 32bae0a..7e185a2 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,143 +1,143 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#include "omanufacturerdb.h" 29#include "omanufacturerdb.h"
30 30
31#define OPIE_IMPROVE_GUI_LATENCY 1 31#define OPIE_IMPROVE_GUI_LATENCY 1
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#ifdef OPIE_IMPROVE_GUI_LATENCY 36#ifdef OPIE_IMPROVE_GUI_LATENCY
37#include <qpe/global.h> 37#include <qpe/global.h>
38#endif 38#endif
39 39
40 40
41 41
42/* QT */ 42/* QT */
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qfile.h> 44#include <qfile.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47using namespace Opie::Core; 47using namespace Opie::Core;
48namespace Opie { 48namespace Opie {
49namespace Net { 49namespace Net {
50 50
51OManufacturerDB* OManufacturerDB::_instance = 0; 51OManufacturerDB* OManufacturerDB::_instance = 0;
52 52
53OManufacturerDB* OManufacturerDB::instance() 53OManufacturerDB* OManufacturerDB::instance()
54{ 54{
55 if ( !OManufacturerDB::_instance ) 55 if ( !OManufacturerDB::_instance )
56 { 56 {
57 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 57 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
58 _instance = new OManufacturerDB(); 58 _instance = new OManufacturerDB();
59 } 59 }
60 return _instance; 60 return _instance;
61} 61}
62 62
63 63
64OManufacturerDB::OManufacturerDB() 64OManufacturerDB::OManufacturerDB()
65{ 65{
66 #ifdef OPIE_IMPROVE_GUI_LATENCY 66 #ifdef OPIE_IMPROVE_GUI_LATENCY
67 Global::statusMessage( "Reading Manufacturers..." ); 67 Global::statusMessage( "Reading Manufacturers..." );
68 #endif 68 #endif
69 QString filename( "/etc/manufacturers" ); 69 QString filename( "/etc/manufacturers" );
70 odebug << "OManufacturerDB: trying to read " << filename << oendl; 70 odebug << "OManufacturerDB: trying to read " << filename << oendl;
71 if ( !QFile::exists( filename ) ) 71 if ( !QFile::exists( filename ) )
72 { 72 {
73 filename = QPEApplication::qpeDir()+"/etc/manufacturers"; 73 filename = QPEApplication::qpeDir()+"etc/manufacturers";
74 odebug << "OManufacturerDB: trying to read " << filename << oendl; 74 odebug << "OManufacturerDB: trying to read " << filename << oendl;
75 if ( !QFile::exists( filename ) ) 75 if ( !QFile::exists( filename ) )
76 { 76 {
77 filename = "/usr/share/wellenreiter/manufacturers"; 77 filename = "/usr/share/wellenreiter/manufacturers";
78 odebug << "OManufacturerDB: trying to read " << filename << oendl; 78 odebug << "OManufacturerDB: trying to read " << filename << oendl;
79 } 79 }
80 } 80 }
81 81
82 QFile file( filename ); 82 QFile file( filename );
83 bool hasFile = file.open( IO_ReadOnly ); 83 bool hasFile = file.open( IO_ReadOnly );
84 if (!hasFile) 84 if (!hasFile)
85 { 85 {
86 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 86 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
87 } 87 }
88 else 88 else
89 { 89 {
90 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 90 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
91 QTextStream s( &file ); 91 QTextStream s( &file );
92 QString addr; 92 QString addr;
93 QString manu; 93 QString manu;
94 QString extManu; 94 QString extManu;
95 #ifdef OPIE_IMPROVE_GUI_LATENCY 95 #ifdef OPIE_IMPROVE_GUI_LATENCY
96 int counter = 0; 96 int counter = 0;
97 #endif 97 #endif
98 while (!s.atEnd()) 98 while (!s.atEnd())
99 { 99 {
100 s >> addr; 100 s >> addr;
101 s >> manu; 101 s >> manu;
102 s >> extManu; 102 s >> extManu;
103 103
104 manufacturers.insert( addr, manu ); 104 manufacturers.insert( addr, manu );
105 manufacturersExt.insert( addr, extManu ); 105 manufacturersExt.insert( addr, extManu );
106 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 106 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
107 #ifdef OPIE_IMPROVE_GUI_LATENCY 107 #ifdef OPIE_IMPROVE_GUI_LATENCY
108 counter++; 108 counter++;
109 if ( counter == 50 ) 109 if ( counter == 50 )
110 { 110 {
111 qApp->processEvents(); 111 qApp->processEvents();
112 counter = 0; 112 counter = 0;
113 } 113 }
114 #endif 114 #endif
115 } 115 }
116 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 116 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
117 #ifdef OPIE_IMPROVE_GUI_LATENCY 117 #ifdef OPIE_IMPROVE_GUI_LATENCY
118 Global::statusMessage( "Manufacturers Complete..." ); 118 Global::statusMessage( "Manufacturers Complete..." );
119 #endif 119 #endif
120 } 120 }
121} 121}
122 122
123 123
124OManufacturerDB::~OManufacturerDB() 124OManufacturerDB::~OManufacturerDB()
125{ 125{
126} 126}
127 127
128 128
129const QString& OManufacturerDB::lookup( const QString& macaddr ) const 129const QString& OManufacturerDB::lookup( const QString& macaddr ) const
130{ 130{
131 return manufacturers[macaddr.upper().left(8)]; 131 return manufacturers[macaddr.upper().left(8)];
132} 132}
133 133
134 134
135const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 135const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
136{ 136{
137 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 137 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
138 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 138 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
139} 139}
140 140
141} 141}
142} 142}
143 143
diff --git a/libopie2/opiesecurity/multiauthcommon.cpp b/libopie2/opiesecurity/multiauthcommon.cpp
index 9de62d2..e563193 100644
--- a/libopie2/opiesecurity/multiauthcommon.cpp
+++ b/libopie2/opiesecurity/multiauthcommon.cpp
@@ -1,195 +1,195 @@
1#include "multiauthplugininterface.h" 1#include "multiauthplugininterface.h"
2#include "multiauthcommon.h" 2#include "multiauthcommon.h"
3 3
4/* Opie */ 4/* Opie */
5#include <opie2/odebug.h> 5#include <opie2/odebug.h>
6#include <opie2/oapplication.h> 6#include <opie2/oapplication.h>
7 7
8/* Qt */ 8/* Qt */
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/qlibrary.h> 10#include <qpe/qlibrary.h>
11#include <qpe/qcom.h> 11#include <qpe/qcom.h>
12#include <qtextview.h> 12#include <qtextview.h>
13#include <qdir.h> 13#include <qdir.h>
14 14
15/* UNIX */ 15/* UNIX */
16#include <unistd.h> 16#include <unistd.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18 18
19namespace Opie { 19namespace Opie {
20namespace Security { 20namespace Security {
21 21
22SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c, 22SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c,
23 bool modal, bool fullscreen = FALSE ) 23 bool modal, bool fullscreen = FALSE )
24: QDialog( parent, name, modal, 24: QDialog( parent, name, modal,
25 fullscreen ? 25 fullscreen ?
26 WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ) 26 WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 )
27{ 27{
28 if ( fullscreen ) { 28 if ( fullscreen ) {
29 QRect desk = qApp->desktop()->geometry(); 29 QRect desk = qApp->desktop()->geometry();
30 setGeometry( 0, 0, desk.width(), desk.height() ); 30 setGeometry( 0, 0, desk.width(), desk.height() );
31 } 31 }
32 // set up contents. 32 // set up contents.
33 QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>"); 33 QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>");
34 text += c.toRichText(); 34 text += c.toRichText();
35 tv = new QTextView(this); 35 tv = new QTextView(this);
36 tv->setText(text); 36 tv->setText(text);
37 37
38 tv->viewport()->installEventFilter(this); 38 tv->viewport()->installEventFilter(this);
39} 39}
40 40
41void SecOwnerDlg::resizeEvent( QResizeEvent * ) 41void SecOwnerDlg::resizeEvent( QResizeEvent * )
42{ 42{
43 tv->resize( size() ); 43 tv->resize( size() );
44} 44}
45 45
46bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e) 46bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e)
47{ 47{
48 if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) { 48 if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) {
49 accept(); 49 accept();
50 return TRUE; 50 return TRUE;
51 } 51 }
52 return QWidget::eventFilter(o, e); 52 return QWidget::eventFilter(o, e);
53} 53}
54 54
55void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); } 55void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); }
56 56
57 57
58namespace Internal { 58namespace Internal {
59/// run plugins until we reach nbSuccessMin successes 59/// run plugins until we reach nbSuccessMin successes
60int runPlugins() { 60int runPlugins() {
61 61
62 SecOwnerDlg *oi = 0; 62 SecOwnerDlg *oi = 0;
63 // see if there is contact information. 63 // see if there is contact information.
64 QString vfilename = Global::applicationFileName("addressbook", 64 QString vfilename = Global::applicationFileName("addressbook",
65 "businesscard.vcf"); 65 "businesscard.vcf");
66 if (QFile::exists(vfilename)) { 66 if (QFile::exists(vfilename)) {
67 Contact c; 67 Contact c;
68 c = Contact::readVCard( vfilename )[0]; 68 c = Contact::readVCard( vfilename )[0];
69 69
70 oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE); 70 oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE);
71 } 71 }
72 72
73 Config config("Security"); 73 Config config("Security");
74 config.setGroup("Plugins"); 74 config.setGroup("Plugins");
75 QStringList plugins = config.readListEntry("IncludePlugins", ','); 75 QStringList plugins = config.readListEntry("IncludePlugins", ',');
76 /* if there are no configured plugins, we simply return 0 to 76 /* if there are no configured plugins, we simply return 0 to
77 * let the user in: 77 * let the user in:
78 */ 78 */
79 if (plugins.isEmpty() == true) { 79 if (plugins.isEmpty() == true) {
80 owarn << "No authentication plugin has been configured yet!" << oendl; 80 owarn << "No authentication plugin has been configured yet!" << oendl;
81 odebug << "Letting the user in..." << oendl; 81 odebug << "Letting the user in..." << oendl;
82 if(oi) delete oi; 82 if(oi) delete oi;
83 return 0; 83 return 0;
84 } 84 }
85 config.setGroup("Misc"); 85 config.setGroup("Misc");
86 int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1); 86 int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1);
87 int nbSuccess = 0; 87 int nbSuccess = 0;
88 88
89 /* tries to launch successively each plugin in $OPIEDIR/plugins/security 89 /* tries to launch successively each plugin in $OPIEDIR/plugins/security
90 * directory which file name is in Security.conf / [Misc] / IncludePlugins 90 * directory which file name is in Security.conf / [Misc] / IncludePlugins
91 */ 91 */
92 QString path = QPEApplication::qpeDir() + "/plugins/security"; 92 QString path = QPEApplication::qpeDir() + "plugins/security";
93 QStringList::Iterator libIt; 93 QStringList::Iterator libIt;
94 94
95 for ( libIt = plugins.begin(); libIt != plugins.end(); ++libIt ) { 95 for ( libIt = plugins.begin(); libIt != plugins.end(); ++libIt ) {
96 QInterfacePtr<MultiauthPluginInterface> iface; 96 QInterfacePtr<MultiauthPluginInterface> iface;
97 QLibrary *lib = new QLibrary( path + "/" + *libIt ); 97 QLibrary *lib = new QLibrary( path + "/" + *libIt );
98 98
99 if ( lib->queryInterface( 99 if ( lib->queryInterface(
100 IID_MultiauthPluginInterface, 100 IID_MultiauthPluginInterface,
101 (QUnknownInterface**)&iface ) == QS_OK ) 101 (QUnknownInterface**)&iface ) == QS_OK )
102 { 102 {
103 // the plugin is a true Multiauth plugin 103 // the plugin is a true Multiauth plugin
104 odebug << "Accepted plugin: " << QString( path + "/" + *libIt ) << oendl; 104 odebug << "Accepted plugin: " << QString( path + "/" + *libIt ) << oendl;
105 odebug << "Plugin name: " << iface->plugin()->pluginName() << oendl; 105 odebug << "Plugin name: " << iface->plugin()->pluginName() << oendl;
106 106
107 int resultCode; 107 int resultCode;
108 int tries = 0; 108 int tries = 0;
109 109
110 // perform authentication 110 // perform authentication
111 resultCode = iface->plugin()->authenticate(); 111 resultCode = iface->plugin()->authenticate();
112 112
113 // display the result in command line 113 // display the result in command line
114 QString resultMessage; 114 QString resultMessage;
115 switch (resultCode) 115 switch (resultCode)
116 { 116 {
117 case MultiauthPluginObject::Success: 117 case MultiauthPluginObject::Success:
118 resultMessage = "Success!"; 118 resultMessage = "Success!";
119 nbSuccess++; 119 nbSuccess++;
120 break; 120 break;
121 case MultiauthPluginObject::Failure: 121 case MultiauthPluginObject::Failure:
122 resultMessage = "Failure..."; 122 resultMessage = "Failure...";
123 break; 123 break;
124 case MultiauthPluginObject::Skip: 124 case MultiauthPluginObject::Skip:
125 resultMessage = "Skip"; 125 resultMessage = "Skip";
126 break; 126 break;
127 } 127 }
128 odebug << "Plugin result: " << resultMessage << oendl; 128 odebug << "Plugin result: " << resultMessage << oendl;
129 129
130 // if failure, wait, reperform, wait, reperform... until right 130 // if failure, wait, reperform, wait, reperform... until right
131 while (resultCode == MultiauthPluginObject::Failure) 131 while (resultCode == MultiauthPluginObject::Failure)
132 { 132 {
133 tries++; 133 tries++;
134 owarn << "This plugin has failed " << tries << " times already" << oendl; 134 owarn << "This plugin has failed " << tries << " times already" << oendl;
135 135
136 // displays owner information, if any 136 // displays owner information, if any
137 if (oi) 137 if (oi)
138 { 138 {
139 oi->exec(); 139 oi->exec();
140 odebug << "Contact information displayed" << oendl; 140 odebug << "Contact information displayed" << oendl;
141 } 141 }
142 142
143 /// \todo parametrize the time penalty according to \em mode (exponential, 143 /// \todo parametrize the time penalty according to \em mode (exponential,
144 /// linear or fixed) and \em basetime (time penalty for the first failure) 144 /// linear or fixed) and \em basetime (time penalty for the first failure)
145 sleep(2 * tries); 145 sleep(2 * tries);
146 146
147 if (oi) 147 if (oi)
148 { 148 {
149 oi->hide(); 149 oi->hide();
150 /** \todo fix the focus here: should go back to the current plugin widget 150 /** \todo fix the focus here: should go back to the current plugin widget
151 * but it doesn't, so we have to tap once on the widget before e.g. buttons 151 * but it doesn't, so we have to tap once on the widget before e.g. buttons
152 * are active again 152 * are active again
153 */ 153 */
154 odebug << "Contact information hidden" << oendl; 154 odebug << "Contact information hidden" << oendl;
155 } 155 }
156 156
157 // perform authentication 157 // perform authentication
158 resultCode = iface->plugin()->authenticate(); 158 resultCode = iface->plugin()->authenticate();
159 159
160 // display the result in command line 160 // display the result in command line
161 switch (resultCode) 161 switch (resultCode)
162 { 162 {
163 case MultiauthPluginObject::Success: 163 case MultiauthPluginObject::Success:
164 resultMessage = "Success!"; 164 resultMessage = "Success!";
165 nbSuccess++; 165 nbSuccess++;
166 break; 166 break;
167 case MultiauthPluginObject::Failure: 167 case MultiauthPluginObject::Failure:
168 resultMessage = "Failure..."; 168 resultMessage = "Failure...";
169 break; 169 break;
170 case MultiauthPluginObject::Skip: 170 case MultiauthPluginObject::Skip:
171 resultMessage = "Skip"; 171 resultMessage = "Skip";
172 break; 172 break;
173 } 173 }
174 odebug << "Plugin result: " << resultMessage << oendl; 174 odebug << "Plugin result: " << resultMessage << oendl;
175 } 175 }
176 delete lib; 176 delete lib;
177 177
178 if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin) 178 if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin)
179 { 179 {
180 if(oi) delete oi; 180 if(oi) delete oi;
181 // we have reached the required number of successes, we can exit the plugin loop 181 // we have reached the required number of successes, we can exit the plugin loop
182 return 0; 182 return 0;
183 } 183 }
184 } else { 184 } else {
185 owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl; 185 owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl;
186 delete lib; 186 delete lib;
187 } // end if plugin recognized 187 } // end if plugin recognized
188 } //end for 188 } //end for
189 if(oi) delete oi; 189 if(oi) delete oi;
190 return 1; 190 return 1;
191} 191}
192 192
193} 193}
194} 194}
195} 195}