author | zecke <zecke> | 2004-05-17 21:22:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-05-17 21:22:51 (UTC) |
commit | f3d15e6f81369f8495811c7c3624e51d032615ba (patch) (unidiff) | |
tree | 8319000a9aa8634a4214306ca19ac49dbcc5bc2b /libopie2 | |
parent | e0d8fdf2bcf61f8b6793ee757de35b985aef1b8d (diff) | |
download | opie-f3d15e6f81369f8495811c7c3624e51d032615ba.zip opie-f3d15e6f81369f8495811c7c3624e51d032615ba.tar.gz opie-f3d15e6f81369f8495811c7c3624e51d032615ba.tar.bz2 |
OPluginManager first bits of saving, enabling and sorting Plugin Config
At least it compiles, test and GUI will come this week
-rw-r--r-- | libopie2/opiecore/opluginloader.cpp | 369 | ||||
-rw-r--r-- | libopie2/opiecore/opluginloader.h | 59 |
2 files changed, 395 insertions, 33 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp index b473cd7..2aca382 100644 --- a/libopie2/opiecore/opluginloader.cpp +++ b/libopie2/opiecore/opluginloader.cpp | |||
@@ -13,2 +13,3 @@ | |||
13 | #include <qtl.h> | 13 | #include <qtl.h> |
14 | #include <qfile.h> | ||
14 | 15 | ||
@@ -112,8 +113,12 @@ OPluginItem::OPluginItem() | |||
112 | /** | 113 | /** |
114 | * @todo Create Internal name so we can have the plugin names translated. Or only for the gui? I'm not yet sure | ||
113 | * \brief Create an OPluginItem | 115 | * \brief Create an OPluginItem |
114 | * | 116 | * |
115 | * Create a Plugin Item with all information. | 117 | * Create a Plugin Item with all information. If you for some reasons |
118 | * need to create your own OPluginItems make sure that 'name' is always the same | ||
119 | * as it if used for positions and exclude list. | ||
116 | * | 120 | * |
117 | * @param name The if available translated Name | 121 | * @param name The if available translated Name |
118 | * @param path The path to the plugin | 122 | * @param path The path to the plugin must be absolute. |
123 | * @param b If the OPluginItem is enabled or not | ||
119 | * @param pos The position of the plugin if used for sorting | 124 | * @param pos The position of the plugin if used for sorting |
@@ -121,5 +126,5 @@ OPluginItem::OPluginItem() | |||
121 | */ | 126 | */ |
122 | OPluginItem::OPluginItem( const QString& name, const QString& path, int pos ) | 127 | OPluginItem::OPluginItem( const QString& name, const QString& path, bool b, int pos ) |
123 | : m_name( name ), m_path( path ), m_pos( pos ) { | 128 | : m_name( name ), m_path( path ), m_enabled( b ), m_pos( pos ) |
124 | } | 129 | {} |
125 | 130 | ||
@@ -132,2 +137,20 @@ OPluginItem::~OPluginItem() { | |||
132 | /** | 137 | /** |
138 | * \brief Test if this Item is Empty and does not represent a loadable plugin | ||
139 | * Test if a OPluginItem is empty. A OPluginItem is empty if name and path are empty | ||
140 | * ,pos equals -1 and the item is disabled | ||
141 | * | ||
142 | * @see QString::isEmpty() | ||
143 | * | ||
144 | */ | ||
145 | bool OPluginItem::isEmpty()const { | ||
146 | if ( m_pos != -1 ) return false; | ||
147 | if ( m_enabled ) return false; | ||
148 | if ( !m_name.isEmpty() ) return false; | ||
149 | if ( !m_path.isEmpty() ) return false; | ||
150 | |||
151 | return true; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * \brief test equality | ||
133 | * operator to test equalness of two OPluginItem | 156 | * operator to test equalness of two OPluginItem |
@@ -135,5 +158,6 @@ OPluginItem::~OPluginItem() { | |||
135 | bool OPluginItem::operator==( const OPluginItem& r )const{ | 158 | bool OPluginItem::operator==( const OPluginItem& r )const{ |
136 | if ( m_pos != r.m_pos ) return false; | 159 | if ( m_pos != r.m_pos ) return false; |
137 | if ( m_name != r.m_name ) return false; | 160 | if ( m_enabled != r.m_enabled) return false; |
138 | if ( m_path != r.m_path ) return false; | 161 | if ( m_name != r.m_name ) return false; |
162 | if ( m_path != r.m_path ) return false; | ||
139 | return true; | 163 | return true; |
@@ -141,2 +165,6 @@ bool OPluginItem::operator==( const OPluginItem& r )const{ | |||
141 | 165 | ||
166 | /** | ||
167 | * \brief test non equality | ||
168 | * operator to test non-equalness of two OPluginItem | ||
169 | */ | ||
142 | bool OPluginItem::operator!=( const OPluginItem& r )const{ | 170 | bool OPluginItem::operator!=( const OPluginItem& r )const{ |
@@ -146,2 +174,3 @@ bool OPluginItem::operator!=( const OPluginItem& r )const{ | |||
146 | /** | 174 | /** |
175 | * \brief returns the name of the plugin | ||
147 | * return the name of this Plugin | 176 | * return the name of this Plugin |
@@ -153,3 +182,3 @@ QString OPluginItem::name()const { | |||
153 | /** | 182 | /** |
154 | * return the path of the plugin | 183 | * \brief return the path of the plugin |
155 | */ | 184 | */ |
@@ -159,2 +188,19 @@ QString OPluginItem::path()const { | |||
159 | 188 | ||
189 | /** | ||
190 | * \brief Return if this item is enabled. | ||
191 | */ | ||
192 | bool OPluginItem::isEnabled()const { | ||
193 | return m_enabled; | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * \brief return the position of a plugin. | ||
198 | * return the position of the item | ||
199 | * -1 is the default value and means normally that the whole items are unsorted. | ||
200 | * Higher numbers belong to an upper position. With plugins with the postions 20,19,5,3 | ||
201 | * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader | ||
202 | * | ||
203 | * @see OGenericPluginLoader::allAvailable | ||
204 | * @see OGenericPluginLoader::filtered | ||
205 | */ | ||
160 | int OPluginItem::position()const{ | 206 | int OPluginItem::position()const{ |
@@ -164,2 +210,3 @@ int OPluginItem::position()const{ | |||
164 | /** | 210 | /** |
211 | * \brief set the name of a plugin | ||
165 | * Set the name of the Plugin Item | 212 | * Set the name of the Plugin Item |
@@ -172,3 +219,4 @@ void OPluginItem::setName( const QString& name ) { | |||
172 | /** | 219 | /** |
173 | * Set the path of Plugin Item | 220 | * \brief set the path of a plugin |
221 | * Set the path of Plugin Item. The path must be absolute. | ||
174 | * @param name The path of the plugin | 222 | * @param name The path of the plugin |
@@ -180,4 +228,19 @@ void OPluginItem::setPath( const QString& name ) { | |||
180 | /** | 228 | /** |
229 | * \brief enable or disable the to load attribute | ||
230 | * Set the Enabled attribute. Such changes won't be saved. If you want to save it | ||
231 | * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig | ||
232 | * for a graphical frontend. | ||
233 | * | ||
234 | * @param enabled Enable or Disable the Enabled Attribute | ||
235 | */ | ||
236 | void OPluginItem::setEnabled( bool enabled ) { | ||
237 | m_enabled = enabled; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * \brief Set the position. | ||
181 | * Set the position | 242 | * Set the position |
182 | * @param pos The position | 243 | * @param pos The position |
244 | * | ||
245 | * @see position() | ||
183 | */ | 246 | */ |
@@ -226,2 +289,4 @@ OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted) | |||
226 | /** | 289 | /** |
290 | * \brief simple d'tor that cleans up depending on autoDelete | ||
291 | * | ||
227 | * calls clear if autoDelete is true. This will release all interfaces | 292 | * calls clear if autoDelete is true. This will release all interfaces |
@@ -235,2 +300,4 @@ OGenericPluginLoader::~OGenericPluginLoader() { | |||
235 | /** | 300 | /** |
301 | * \brief Enable or disable autoDelete on destruction | ||
302 | * | ||
236 | * enable autoDelete. This will call clear on the d'tor | 303 | * enable autoDelete. This will call clear on the d'tor |
@@ -245,3 +312,3 @@ void OGenericPluginLoader::setAutoDelete( bool t ) { | |||
245 | /** | 312 | /** |
246 | * see if autoDelet is enabled | 313 | * \brief See if autoDelete is enabled. |
247 | */ | 314 | */ |
@@ -252,2 +319,4 @@ bool OGenericPluginLoader::autoDelete()const{ | |||
252 | /** | 319 | /** |
320 | * \brief unload all loaded Plugins | ||
321 | * | ||
253 | * This will unload all returned QUnknownInterfaces by load. Unload | 322 | * This will unload all returned QUnknownInterfaces by load. Unload |
@@ -262,2 +331,4 @@ void OGenericPluginLoader::clear() { | |||
262 | /** | 331 | /** |
332 | * \brief unload the Plugin and the accompanied Resources. | ||
333 | * | ||
263 | * This will take the iface from the internal QPtrDict, Release it, | 334 | * This will take the iface from the internal QPtrDict, Release it, |
@@ -276,2 +347,14 @@ void OGenericPluginLoader::unload( QUnknownInterface* iface ) { | |||
276 | /** | 347 | /** |
348 | * \brief The name of the plugins. | ||
349 | * | ||
350 | * Return the name/type you specified in the constructor. | ||
351 | * This is at least used by the OPluginManager to find the right config | ||
352 | */ | ||
353 | QString OGenericPluginLoader::name()const { | ||
354 | return m_dir; | ||
355 | } | ||
356 | |||
357 | |||
358 | /** | ||
359 | * \brief See if loading of a plugin segfaulted | ||
277 | * This tells you | 360 | * This tells you |
@@ -288,2 +371,3 @@ bool OGenericPluginLoader::isInSafeMode()const { | |||
288 | /** | 371 | /** |
372 | * \brief Return all Plugins found in the plugins dirs. | ||
289 | * Return the list of all available plugins. This will go through all plugin | 373 | * Return the list of all available plugins. This will go through all plugin |
@@ -304,2 +388,3 @@ OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { | |||
304 | /** | 388 | /** |
389 | * \brief Return only the enabled plugins | ||
305 | * Return only activated plugins. | 390 | * Return only activated plugins. |
@@ -320,3 +405,11 @@ OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { | |||
320 | /** | 405 | /** |
406 | * \brief Load a OPluginItem for the specified interface | ||
407 | * This will open the resource of the OPluginItem::path() and then will query | ||
408 | * if the Interface specified in the uuid is available and then will manage the | ||
409 | * resource and Interface. | ||
410 | * | ||
411 | * @param item The OPluginItem that should be loaded | ||
412 | * @param uuid The Interface to query for | ||
321 | * | 413 | * |
414 | * @return Either 0 in case of failure or the Plugin as QUnknownInterface* | ||
322 | */ | 415 | */ |
@@ -360,3 +453,5 @@ QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QU | |||
360 | void OGenericPluginLoader::readConfig() { | 453 | void OGenericPluginLoader::readConfig() { |
361 | /* read the config for SafeMode */ | 454 | |
455 | |||
456 | /* read the config for SafeMode */ | ||
362 | OConfig conf( m_dir + "-odpplugins" ); | 457 | OConfig conf( m_dir + "-odpplugins" ); |
@@ -367,3 +462,3 @@ void OGenericPluginLoader::readConfig() { | |||
367 | /** | 462 | /** |
368 | * Enter or leave SafeMode | 463 | * @internal Enter or leave SafeMode |
369 | */ | 464 | */ |
@@ -422,3 +517,7 @@ QString OGenericPluginLoader::unlibify( const QString& str ) { | |||
422 | /** | 517 | /** |
423 | * Return a List of Plugins for a dir and add positions and remove disabled. | 518 | * @internal |
519 | * | ||
520 | * \brief method to return available plugins. Internal and for reeimplementations | ||
521 | * | ||
522 | *Return a List of Plugins for a dir and add positions and remove disabled. | ||
424 | * If a plugin is on the excluded list assign position -2 | 523 | * If a plugin is on the excluded list assign position -2 |
@@ -475,3 +574,3 @@ OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorte | |||
475 | /* | 574 | /* |
476 | * if disabled but we should show all assign a -2 | 575 | * if disabled but we should show all mark it as disabled |
477 | * else continue because we don't want to add the item | 576 | * else continue because we don't want to add the item |
@@ -480,3 +579,3 @@ OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorte | |||
480 | if ( ex && !disabled) | 579 | if ( ex && !disabled) |
481 | item.setPosition( -2 ); | 580 | item.setEnabled( false ); |
482 | else if ( ex && disabled ) | 581 | else if ( ex && disabled ) |
@@ -516,2 +615,6 @@ QStringList OGenericPluginLoader::languageList() { | |||
516 | 615 | ||
616 | /** | ||
617 | * @internal | ||
618 | * Tries to install languages using the languageList for the type | ||
619 | */ | ||
517 | void OGenericPluginLoader::installTranslators(const QString& type) { | 620 | void OGenericPluginLoader::installTranslators(const QString& type) { |
@@ -537,3 +640,237 @@ void OGenericPluginLoader::installTranslators(const QString& type) { | |||
537 | 640 | ||
641 | /** | ||
642 | * \brief Simple c'tor. | ||
643 | * | ||
644 | * Simple C'tor same as the one of the base class. Additional this | ||
645 | * class can cast for you if you nee it. | ||
646 | * | ||
647 | * | ||
648 | * @param name The name of your plugin class | ||
649 | * @param sorted If plugins are sorted | ||
650 | * | ||
651 | * @see OGenericPluginLoader | ||
652 | */ | ||
653 | OPluginLoader::OPluginLoader( const QString& name, bool sorted ) | ||
654 | : OGenericPluginLoader( name, sorted ) | ||
655 | { | ||
656 | } | ||
657 | |||
658 | /** | ||
659 | * d'tor | ||
660 | * @see OGenericPluginLoader::~OGenericPluginLoader | ||
661 | */ | ||
662 | OPluginLoader::~OPluginLoader() { | ||
663 | } | ||
664 | |||
665 | /** | ||
666 | * \brief C'Tor using a OGenericPluginLoader | ||
667 | * The C'tor. Pass your OGenericPluginLoader to manage | ||
668 | * OGenericPluginLoader::allAvailable plugins. | ||
669 | * | ||
670 | * | ||
671 | * @param loader A Pointer to your OGenericPluginLoader | ||
672 | * @param name The name | ||
673 | */ | ||
674 | OPluginManager::OPluginManager( OGenericPluginLoader* loader) | ||
675 | : m_loader( loader ) | ||
676 | { | ||
677 | } | ||
678 | |||
679 | /** | ||
680 | * \brief Overloaded c'tor using a List of Plugins and a type name | ||
681 | * Overloaded Constructor to work with a 'Type' of plugins | ||
682 | * and a correspending list of those. In this case calling load | ||
683 | * is a no operation. | ||
684 | * | ||
685 | * @param name The name of your plugin ('today','inputmethods','applets') | ||
686 | * @param lst A List with plugins of your type to manage | ||
687 | * @param isSorted If the List should be treated sorted | ||
688 | */ | ||
689 | OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted) | ||
690 | : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted ) | ||
691 | { | ||
692 | } | ||
693 | |||
694 | /** | ||
695 | * \brief A simple d'tor | ||
696 | */ | ||
697 | OPluginManager::~OPluginManager() { | ||
698 | } | ||
699 | |||
700 | /** | ||
701 | * \brief Return the OPluginItem where loading is likely to have crashed on. | ||
538 | 702 | ||
703 | * Return the Item that made the OGenericPluginLoader crash | ||
704 | * the returned OPluginItem could be empty if no crash occured | ||
705 | * which should apply most of the time. It could also be empty if the crashed | ||
706 | * plugin is not in the current list of available/managed plugins | ||
707 | * | ||
708 | * @see OPluginItem::isEmpty | ||
709 | * @return OPluginItem that crashed the loader | ||
710 | */ | ||
711 | OPluginItem OPluginManager::crashedPlugin()const { | ||
712 | return m_crashed; | ||
713 | } | ||
714 | |||
715 | /** | ||
716 | * \brief Return a list of plugins that are managed by this OPluginManager | ||
717 | * | ||
718 | * Return the list of managed plugins. This could either result | ||
719 | * from passing a OGenericPluginLoader and calling load or by | ||
720 | * giving name and a list of plugins. | ||
721 | */ | ||
722 | OPluginItem::List OPluginManager::managedPlugins()const { | ||
723 | return m_plugins; | ||
724 | } | ||
725 | |||
726 | /** | ||
727 | * \brief Set the position of the items | ||
728 | * | ||
729 | * Replace the OPluginItem with the name and path and this way | ||
730 | * apply the new position. The search is linear and this way O(n/2) | ||
731 | * You still need to call save() to make your changes effective. After saving | ||
732 | * a call to OGenericPluginLoader::filtered() returns the newly configured order and items | ||
733 | * | ||
734 | * @param item The OPluginItem to be replaced internall | ||
735 | * | ||
736 | */ | ||
737 | void OPluginManager::setPosition( const OPluginItem& item) { | ||
738 | replace( item ); | ||
739 | } | ||
740 | |||
741 | /** | ||
742 | * \brief Enable the item specified as argument | ||
743 | * | ||
744 | * This will make sure that OPluginItem::setEnabled is called and then will replace | ||
745 | * the item with one that matches name and path internally. | ||
746 | * @see setPosition | ||
747 | * | ||
748 | * @param the Item to enable | ||
749 | */ | ||
750 | void OPluginManager::enable( const OPluginItem& item ) { | ||
751 | setEnabled( item, true ); | ||
752 | } | ||
753 | |||
754 | /** | ||
755 | * \brief disable the Item. | ||
756 | * | ||
757 | * Disable the OPluginItem. Same applies as in | ||
758 | * @see setPosition and @see enable | ||
759 | * | ||
760 | * @param item Item to disable | ||
761 | */ | ||
762 | void OPluginManager::disable( const OPluginItem& item) { | ||
763 | setEnabled( item, false ); | ||
764 | } | ||
765 | |||
766 | /** | ||
767 | * \brief Enable or disable the OPluginItem. | ||
768 | * Depending on the value of the parameter this will either disable | ||
769 | * or enable the pluginitem. | ||
770 | * Beside that same as in @see disable, @see enable, @see setPosition | ||
771 | * applies. | ||
772 | * | ||
773 | * @param _item The OPluginItem to enable or to disable. | ||
774 | * @param b Enable or disable the plugin. | ||
775 | * | ||
776 | */ | ||
777 | void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) { | ||
778 | OPluginItem item = _item; | ||
779 | item.setEnabled( b ); | ||
780 | replace( item ); | ||
781 | } | ||
782 | |||
783 | /** | ||
784 | * \brief Load necessary information after constructing the object | ||
785 | * If you speified a OGenericPluginLoader you need to call this method | ||
786 | * so that this manager knows what to manage and have a right value for \sa crashedPlugin | ||
787 | * For the name and the list of plugins this does only try to find out the crashed plugin | ||
788 | */ | ||
789 | void OPluginManager::load() { | ||
790 | OConfig cfg( configName() ); | ||
791 | cfg.setGroup( "General" ); | ||
792 | QString crashedPath = cfg.readEntry( "CrashedPlugin" ); | ||
793 | |||
794 | /* if we've a loader this applies if we were called from the first part */ | ||
795 | if ( m_loader ) | ||
796 | m_plugins = m_loader->allAvailable( m_loader->isSorted() ); | ||
797 | |||
798 | /* fast and normal route if we did not crash... */ | ||
799 | if ( crashedPath.isEmpty() ) | ||
800 | return; | ||
801 | |||
802 | /* lets try to find the plugin path and this way the associated item */ | ||
803 | for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) | ||
804 | if ( (*it).path() == crashedPath ) { | ||
805 | m_crashed = *it; | ||
806 | break; | ||
807 | } | ||
808 | } | ||
809 | |||
810 | |||
811 | /** | ||
812 | * \brief Save the values and this way make it available. | ||
813 | * | ||
814 | * Save the current set of data. A call to @see OGenericPluginLoader::filtered | ||
815 | * now would return your saved changes. | ||
816 | */ | ||
817 | void OPluginManager::save() { | ||
818 | QMap<QString, QStringList> excluded; // map for path to excluded name | ||
819 | QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs | ||
820 | bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; | ||
821 | |||
822 | /* | ||
823 | * We will create some maps for the groups to include positions a | ||
824 | */ | ||
825 | for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { | ||
826 | OPluginItem item = *it; | ||
827 | QString path = QFileInfo( item.path() ).filePath(); | ||
828 | if ( sorted ) { | ||
829 | positions[path].append( item.name() ); | ||
830 | positions[path].append( QString::number( item.position() ) ); | ||
831 | } | ||
832 | |||
833 | if ( !item.isEnabled() ) | ||
834 | excluded[path].append( item.name() ); | ||
835 | } | ||
836 | |||
837 | /* | ||
838 | * The code below wouldn't work because we can't delete groups/keys from the config | ||
839 | * ### for ODP make Config right! | ||
840 | */ | ||
841 | // if ( excluded.isEmpty() && positions.isEmpty() ) return; | ||
842 | /* | ||
843 | * Now safe for each path | ||
844 | */ | ||
845 | OConfig cfg( configName() ); | ||
846 | |||
847 | /* safe excluded items */ | ||
848 | for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { | ||
849 | OConfigGroupSaver saver( &cfg, it.key() ); | ||
850 | cfg.writeEntry("Excluded", it.data(), ',' ); | ||
851 | } | ||
852 | |||
853 | /* safe positions we could also see if positions.contains(path) and remove/write in the above loop | ||
854 | * ### Write a Test Suite that can profile these runs... | ||
855 | */ | ||
856 | for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { | ||
857 | OConfigGroupSaver saver( &cfg, it.key() ); | ||
858 | cfg.writeEntry("Positions", it.data(), '.' ); | ||
859 | } | ||
860 | } | ||
861 | |||
862 | /** | ||
863 | * @internal | ||
864 | */ | ||
865 | QString OPluginManager::configName()const { | ||
866 | QString str = m_loader ? m_loader->name() : m_cfgName; | ||
867 | return str + "odpplugins"; | ||
868 | } | ||
869 | |||
870 | /** | ||
871 | * @internal.. replace in m_plugins by path... this is linear search O(n/2) | ||
872 | */ | ||
873 | void OPluginManager::replace( const OPluginItem& item ) { | ||
874 | // ### fixme | ||
875 | } | ||
539 | 876 | ||
diff --git a/libopie2/opiecore/opluginloader.h b/libopie2/opiecore/opluginloader.h index 6166b75..2f9ec2a 100644 --- a/libopie2/opiecore/opluginloader.h +++ b/libopie2/opiecore/opluginloader.h | |||
@@ -34,5 +34,7 @@ public: | |||
34 | OPluginItem(); | 34 | OPluginItem(); |
35 | OPluginItem( const QString& name, const QString& path, int pos = -1 ); | 35 | OPluginItem( const QString& name, const QString& path, bool enabled = true, int pos = -1 ); |
36 | ~OPluginItem(); | 36 | ~OPluginItem(); |
37 | 37 | ||
38 | bool isEmpty()const; | ||
39 | |||
38 | bool operator==( const OPluginItem& )const; | 40 | bool operator==( const OPluginItem& )const; |
@@ -43,2 +45,3 @@ public: | |||
43 | QString path()const; | 45 | QString path()const; |
46 | bool isEnabled()const; | ||
44 | int position()const; | 47 | int position()const; |
@@ -47,2 +50,3 @@ public: | |||
47 | void setPath( const QString& ); | 50 | void setPath( const QString& ); |
51 | void setEnabled( bool ); | ||
48 | void setPosition( int ); | 52 | void setPosition( int ); |
@@ -52,2 +56,3 @@ private: | |||
52 | QString m_path; | 56 | QString m_path; |
57 | bool m_enabled : 1; | ||
53 | int m_pos; | 58 | int m_pos; |
@@ -78,3 +83,4 @@ public: | |||
78 | 83 | ||
79 | 84 | QString name()const; | |
85 | bool isSorted()const; | ||
80 | bool isInSafeMode()const; | 86 | bool isInSafeMode()const; |
@@ -82,4 +88,4 @@ public: | |||
82 | 88 | ||
83 | List allAvailable(bool sorted = FALSE)const; | 89 | List allAvailable(bool sorted = false )const; |
84 | List filtered(bool sorted = FALSE)const; | 90 | List filtered(bool sorted = false )const; |
85 | 91 | ||
@@ -90,2 +96,3 @@ public: | |||
90 | protected: | 96 | protected: |
97 | friend class OPluginManager; // we need the static unlibify | ||
91 | void readConfig(); | 98 | void readConfig(); |
@@ -94,6 +101,4 @@ protected: | |||
94 | void setPluginDir( const QString& ); | 101 | void setPluginDir( const QString& ); |
95 | bool isSorted()const; | ||
96 | void setSafeMode(const QString& app = QString::null, bool b = false); | 102 | void setSafeMode(const QString& app = QString::null, bool b = false); |
97 | static QString unlibify( const QString& str ); | 103 | static QString unlibify( const QString& str ); |
98 | |||
99 | private: | 104 | private: |
@@ -135,3 +140,3 @@ public: | |||
135 | OPluginLoader( const QString& name, bool sorted = false ); | 140 | OPluginLoader( const QString& name, bool sorted = false ); |
136 | ~OPluginLoader(); | 141 | virtual ~OPluginLoader(); |
137 | 142 | ||
@@ -142,3 +147,3 @@ public: | |||
142 | /** | 147 | /** |
143 | * \brief A class to manager order and activation of plugins | 148 | * \brief A class to manage order and activation of plugins |
144 | * | 149 | * |
@@ -147,4 +152,5 @@ public: | |||
147 | * on the OPluginLoader you supply. | 152 | * on the OPluginLoader you supply. |
153 | * You must call load() and save after construnction an instance | ||
148 | * | 154 | * |
149 | * @see OPluginConfig | 155 | * @see Opie::Ui::OPluginConfig |
150 | * | 156 | * |
@@ -153,9 +159,9 @@ class OPluginManager { | |||
153 | public: | 159 | public: |
154 | OPluginManager( OGenericPluginLoader* , const QString& name); | 160 | OPluginManager( OGenericPluginLoader* ); |
155 | OPluginManager( OConfig* conf, const QString&, | 161 | OPluginManager( const QString& name, const OPluginItem::List&, bool isSorted = false ); |
156 | const QCString& group, const OPluginItem::List& ); | 162 | virtual ~OPluginManager(); |
157 | ~OPluginManager(); | ||
158 | 163 | ||
159 | QString name(); | 164 | OPluginItem crashedPlugin()const; |
160 | void setName( const QString& ); | 165 | |
166 | OPluginItem::List managedPlugins()const; | ||
161 | 167 | ||
@@ -166,4 +172,14 @@ public: | |||
166 | 172 | ||
167 | void load(); | 173 | virtual void load(); |
168 | void save(); | 174 | virtual void save(); |
175 | |||
176 | protected: | ||
177 | QString configName()const; | ||
178 | void replace( const OPluginItem& ); | ||
179 | private: | ||
180 | OGenericPluginLoader *m_loader; | ||
181 | QString m_cfgName; | ||
182 | OPluginItem::List m_plugins; | ||
183 | OPluginItem m_crashed; | ||
184 | bool m_isSorted : 1; | ||
169 | }; | 185 | }; |
@@ -171,2 +187,11 @@ public: | |||
171 | 187 | ||
188 | /** | ||
189 | * This is a template method allowing you to safely cast | ||
190 | * your load function | ||
191 | * | ||
192 | * \code | ||
193 | * MyTypePlugin *plug = load->load<MyTypePlugin>( item, IID_MyPlugin ); | ||
194 | * \endcode | ||
195 | * | ||
196 | */ | ||
172 | template<class IFace> | 197 | template<class IFace> |