Diffstat (limited to 'qmake/tools/qgpluginmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/tools/qgpluginmanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qmake/tools/qgpluginmanager.cpp b/qmake/tools/qgpluginmanager.cpp index 46c85f5..72246ac 100644 --- a/qmake/tools/qgpluginmanager.cpp +++ b/qmake/tools/qgpluginmanager.cpp | |||
@@ -1,54 +1,54 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Implementation of QGPluginManager class | 4 | ** Implementation of QGPluginManager class |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2000-2001 Trolltech AS. All rights reserved. | 6 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the tools module of the Qt GUI Toolkit. | 8 | ** This file is part of the tools module of the Qt GUI Toolkit. |
9 | ** | 9 | ** |
10 | ** This file may be distributed under the terms of the Q Public License | 10 | ** This file may be distributed under the terms of the Q Public License |
11 | ** as defined by Trolltech AS of Norway and appearing in the file | 11 | ** as defined by Trolltech AS of Norway and appearing in the file |
12 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file may be distributed and/or modified under the terms of the | 14 | ** This file may be distributed and/or modified under the terms of the |
15 | ** GNU General Public License version 2 as published by the Free Software | 15 | ** GNU General Public License version 2 as published by the Free Software |
16 | ** Foundation and appearing in the file LICENSE.GPL included in the | 16 | ** Foundation and appearing in the file LICENSE.GPL included in the |
17 | ** packaging of this file. | 17 | ** packaging of this file. |
18 | ** | 18 | ** |
19 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 19 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
20 | ** licenses may use this file in accordance with the Qt Commercial License | 20 | ** licenses may use this file in accordance with the Qt Commercial License |
21 | ** Agreement provided with the Software. | 21 | ** Agreement provided with the Software. |
22 | ** | 22 | ** |
23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
25 | ** | 25 | ** |
26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
27 | ** information about Qt Commercial License Agreements. | 27 | ** information about Qt Commercial License Agreements. |
28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
30 | ** | 30 | ** |
31 | ** Contact info@trolltech.com if any conditions of this licensing are | 31 | ** Contact info@trolltech.com if any conditions of this licensing are |
32 | ** not clear to you. | 32 | ** not clear to you. |
33 | ** | 33 | ** |
34 | **********************************************************************/ | 34 | **********************************************************************/ |
35 | 35 | ||
36 | #include "qgpluginmanager_p.h" | 36 | #include "qgpluginmanager_p.h" |
37 | #ifndef QT_NO_COMPONENT | 37 | #ifndef QT_NO_COMPONENT |
38 | #include "qcomlibrary_p.h" | 38 | #include "qcomlibrary_p.h" |
39 | #include "qmap.h" | 39 | #include "qmap.h" |
40 | #include "qdir.h" | 40 | #include "qdir.h" |
41 | 41 | ||
42 | /* | 42 | /* |
43 | The following co-occurrence code is borrowed from Qt Linguist. | 43 | The following co-occurrence code is borrowed from Qt Linguist. |
44 | 44 | ||
45 | How similar are two texts? The approach used here relies on | 45 | How similar are two texts? The approach used here relies on |
46 | co-occurrence matrices and is very efficient. | 46 | co-occurrence matrices and is very efficient. |
47 | 47 | ||
48 | Let's see with an example: how similar are "here" and "hither"? The | 48 | Let's see with an example: how similar are "here" and "hither"? The |
49 | co-occurrence matrix M for "here" is M[h,e] = 1, M[e,r] = 1, | 49 | co-occurrence matrix M for "here" is M[h,e] = 1, M[e,r] = 1, |
50 | M[r,e] = 1 and 0 elsewhere; the matrix N for "hither" is N[h,i] = 1, | 50 | M[r,e] = 1 and 0 elsewhere; the matrix N for "hither" is N[h,i] = 1, |
51 | N[i,t] = 1, ..., N[h,e] = 1, N[e,r] = 1 and 0 elsewhere. The union | 51 | N[i,t] = 1, ..., N[h,e] = 1, N[e,r] = 1 and 0 elsewhere. The union |
52 | U of both matrices is the matrix U[i,j] = max { M[i,j], N[i,j] }, | 52 | U of both matrices is the matrix U[i,j] = max { M[i,j], N[i,j] }, |
53 | and the intersection V is V[i,j] = min { M[i,j], N[i,j] }. The score | 53 | and the intersection V is V[i,j] = min { M[i,j], N[i,j] }. The score |
54 | for a pair of texts is | 54 | for a pair of texts is |
@@ -430,97 +430,97 @@ QStringList QGPluginManager::featureList() const | |||
430 | continue; | 430 | continue; |
431 | QComLibrary* library = new QComLibrary( *it ); | 431 | QComLibrary* library = new QComLibrary( *it ); |
432 | if ( library->qtVersion() == QT_VERSION ) { | 432 | if ( library->qtVersion() == QT_VERSION ) { |
433 | that->addLibrary( library ); | 433 | that->addLibrary( library ); |
434 | phase2Deny << QFileInfo( *it ).baseName(); | 434 | phase2Deny << QFileInfo( *it ).baseName(); |
435 | } else { | 435 | } else { |
436 | delete library; | 436 | delete library; |
437 | phase2Libs << *it; | 437 | phase2Libs << *it; |
438 | } | 438 | } |
439 | } | 439 | } |
440 | for ( it = phase2Libs.begin(); it != phase2Libs.end(); ++it ) | 440 | for ( it = phase2Libs.begin(); it != phase2Libs.end(); ++it ) |
441 | if ( !phase2Deny.contains( QFileInfo( *it ).baseName() ) ) | 441 | if ( !phase2Deny.contains( QFileInfo( *it ).baseName() ) ) |
442 | that->addLibrary( new QComLibrary( *it ) ); | 442 | that->addLibrary( new QComLibrary( *it ) ); |
443 | 443 | ||
444 | for ( QDictIterator<QLibrary> pit( plugDict ); pit.current(); ++pit ) | 444 | for ( QDictIterator<QLibrary> pit( plugDict ); pit.current(); ++pit ) |
445 | features << pit.currentKey(); | 445 | features << pit.currentKey(); |
446 | 446 | ||
447 | return features; | 447 | return features; |
448 | } | 448 | } |
449 | 449 | ||
450 | bool QGPluginManager::addLibrary( QLibrary* lib ) | 450 | bool QGPluginManager::addLibrary( QLibrary* lib ) |
451 | { | 451 | { |
452 | if ( !enabled() || !lib ) | 452 | if ( !enabled() || !lib ) |
453 | return FALSE; | 453 | return FALSE; |
454 | 454 | ||
455 | QComLibrary* plugin = (QComLibrary*)lib; | 455 | QComLibrary* plugin = (QComLibrary*)lib; |
456 | bool useful = FALSE; | 456 | bool useful = FALSE; |
457 | 457 | ||
458 | QUnknownInterface* iFace = 0; | 458 | QUnknownInterface* iFace = 0; |
459 | plugin->queryInterface( interfaceId, &iFace ); | 459 | plugin->queryInterface( interfaceId, &iFace ); |
460 | if ( iFace ) { | 460 | if ( iFace ) { |
461 | QFeatureListInterface *fliFace = 0; | 461 | QFeatureListInterface *fliFace = 0; |
462 | QComponentInformationInterface *cpiFace = 0; | 462 | QComponentInformationInterface *cpiFace = 0; |
463 | iFace->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); | 463 | iFace->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); |
464 | if ( !fliFace ) | 464 | if ( !fliFace ) |
465 | plugin->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); | 465 | plugin->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); |
466 | if ( !fliFace ) { | 466 | if ( !fliFace ) { |
467 | iFace->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); | 467 | iFace->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); |
468 | if ( !cpiFace ) | 468 | if ( !cpiFace ) |
469 | plugin->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); | 469 | plugin->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); |
470 | } | 470 | } |
471 | QStringList fl; | 471 | QStringList fl; |
472 | if ( fliFace ) | 472 | if ( fliFace ) |
473 | // Map all found features to the library | 473 | // Map all found features to the library |
474 | fl = fliFace->featureList(); | 474 | fl = fliFace->featureList(); |
475 | else if ( cpiFace ) | 475 | else if ( cpiFace ) |
476 | fl << cpiFace->name(); | 476 | fl << cpiFace->name(); |
477 | 477 | ||
478 | for ( QStringList::Iterator f = fl.begin(); f != fl.end(); f++ ) { | 478 | for ( QStringList::Iterator f = fl.begin(); f != fl.end(); ++f ) { |
479 | QLibrary *old = plugDict[*f]; | 479 | QLibrary *old = plugDict[*f]; |
480 | if ( !old ) { | 480 | if ( !old ) { |
481 | useful = TRUE; | 481 | useful = TRUE; |
482 | plugDict.replace( *f, plugin ); | 482 | plugDict.replace( *f, plugin ); |
483 | } else { | 483 | } else { |
484 | // we have old *and* plugin, which one to pick? | 484 | // we have old *and* plugin, which one to pick? |
485 | QComLibrary* first = (QComLibrary*)old; | 485 | QComLibrary* first = (QComLibrary*)old; |
486 | QComLibrary* second = (QComLibrary*)plugin; | 486 | QComLibrary* second = (QComLibrary*)plugin; |
487 | bool takeFirst = TRUE; | 487 | bool takeFirst = TRUE; |
488 | if ( first->qtVersion() != QT_VERSION ) { | 488 | if ( first->qtVersion() != QT_VERSION ) { |
489 | if ( second->qtVersion() == QT_VERSION ) | 489 | if ( second->qtVersion() == QT_VERSION ) |
490 | takeFirst = FALSE; | 490 | takeFirst = FALSE; |
491 | else if ( second->qtVersion() < QT_VERSION && | 491 | else if ( second->qtVersion() < QT_VERSION && |
492 | first->qtVersion() > QT_VERSION ) | 492 | first->qtVersion() > QT_VERSION ) |
493 | takeFirst = FALSE; | 493 | takeFirst = FALSE; |
494 | } | 494 | } |
495 | if ( !takeFirst ) { | 495 | if ( !takeFirst ) { |
496 | useful = TRUE; | 496 | useful = TRUE; |
497 | plugDict.replace( *f, plugin ); | 497 | plugDict.replace( *f, plugin ); |
498 | qWarning("%s: Discarding feature %s in %s!", | 498 | qWarning("%s: Discarding feature %s in %s!", |
499 | (const char*) QFile::encodeName( plugin->library()), | 499 | (const char*) QFile::encodeName( plugin->library()), |
500 | (*f).latin1(), | 500 | (*f).latin1(), |
501 | (const char*) QFile::encodeName( old->library() ) ); | 501 | (const char*) QFile::encodeName( old->library() ) ); |
502 | } else { | 502 | } else { |
503 | qWarning("%s: Feature %s already defined in %s!", | 503 | qWarning("%s: Feature %s already defined in %s!", |
504 | (const char*) QFile::encodeName( old->library() ), | 504 | (const char*) QFile::encodeName( old->library() ), |
505 | (*f).latin1(), | 505 | (*f).latin1(), |
506 | (const char*) QFile::encodeName( plugin->library() ) ); | 506 | (const char*) QFile::encodeName( plugin->library() ) ); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | } | 509 | } |
510 | if ( fliFace ) | 510 | if ( fliFace ) |
511 | fliFace->release(); | 511 | fliFace->release(); |
512 | if ( cpiFace ) | 512 | if ( cpiFace ) |
513 | cpiFace->release(); | 513 | cpiFace->release(); |
514 | iFace->release(); | 514 | iFace->release(); |
515 | } | 515 | } |
516 | 516 | ||
517 | if ( useful ) { | 517 | if ( useful ) { |
518 | libDict.replace( plugin->library(), plugin ); | 518 | libDict.replace( plugin->library(), plugin ); |
519 | if ( !libList.contains( plugin->library() ) ) | 519 | if ( !libList.contains( plugin->library() ) ) |
520 | libList.append( plugin->library() ); | 520 | libList.append( plugin->library() ); |
521 | return TRUE; | 521 | return TRUE; |
522 | } | 522 | } |
523 | delete plugin; | 523 | delete plugin; |
524 | return FALSE; | 524 | return FALSE; |
525 | } | 525 | } |
526 | 526 | ||