summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-05-29 17:11:23 (UTC)
committer harlekin <harlekin>2004-05-29 17:11:23 (UTC)
commitf568ff9c68bdc61cbc4482f9b2c6e1096cecaae0 (patch) (unidiff)
tree656b1216596c578ba672c2c0d25782d24110406a
parente163b479be800d0b388cf52d046adfc83f5cc1d8 (diff)
downloadopie-f568ff9c68bdc61cbc4482f9b2c6e1096cecaae0.zip
opie-f568ff9c68bdc61cbc4482f9b2c6e1096cecaae0.tar.gz
opie-f568ff9c68bdc61cbc4482f9b2c6e1096cecaae0.tar.bz2
fix path handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index c2dc239..3d286e5 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -161,129 +161,129 @@ bool OPluginItem::operator==( const OPluginItem& r )const{
161 if ( m_name != r.m_name ) return false; 161 if ( m_name != r.m_name ) return false;
162 if ( m_path != r.m_path ) return false; 162 if ( m_path != r.m_path ) return false;
163 return true; 163 return true;
164} 164}
165 165
166/** 166/**
167 * \brief test non equality 167 * \brief test non equality
168 * operator to test non-equalness of two OPluginItem 168 * operator to test non-equalness of two OPluginItem
169 */ 169 */
170bool OPluginItem::operator!=( const OPluginItem& r )const{ 170bool OPluginItem::operator!=( const OPluginItem& r )const{
171 return !( *this == r ); 171 return !( *this == r );
172} 172}
173 173
174/** 174/**
175 * \brief returns the name of the plugin 175 * \brief returns the name of the plugin
176 * return the name of this Plugin 176 * return the name of this Plugin
177 */ 177 */
178QString OPluginItem::name()const { 178QString OPluginItem::name()const {
179 return m_name; 179 return m_name;
180} 180}
181 181
182/** 182/**
183 * \brief return the path of the plugin 183 * \brief return the path of the plugin
184 */ 184 */
185QString OPluginItem::path()const { 185QString OPluginItem::path()const {
186 return m_path; 186 return m_path;
187} 187}
188 188
189/** 189/**
190 * \brief Return if this item is enabled. 190 * \brief Return if this item is enabled.
191 */ 191 */
192bool OPluginItem::isEnabled()const { 192bool OPluginItem::isEnabled()const {
193 return m_enabled; 193 return m_enabled;
194} 194}
195 195
196/** 196/**
197 * \brief return the position of a plugin. 197 * \brief return the position of a plugin.
198 * return the position of the item 198 * return the position of the item
199 * -1 is the default value and means normally that the whole items are unsorted. 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 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 201 * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader
202 * 202 *
203 * @see OGenericPluginLoader::allAvailable 203 * @see OGenericPluginLoader::allAvailable
204 * @see OGenericPluginLoader::filtered 204 * @see OGenericPluginLoader::filtered
205 */ 205 */
206int OPluginItem::position()const{ 206int OPluginItem::position()const{
207 return m_pos; 207 return m_pos;
208} 208}
209 209
210/** 210/**
211 * \brief set the name of a plugin 211 * \brief set the name of a plugin
212 * Set the name of the Plugin Item 212 * Set the name of the Plugin Item
213 * @param name 213 * @param name
214 */ 214 */
215void OPluginItem::setName( const QString& name ) { 215void OPluginItem::setName( const QString& name ) {
216 m_name = name; 216 m_name = name;
217} 217}
218 218
219/** 219/**
220 * \brief set the path of a plugin 220 * \brief set the path of a plugin
221 * Set the path of Plugin Item. The path must be absolute. 221 * Set the path of Plugin Item. The path must be absolute.
222 * @param name The path of the plugin 222 * @param name The path of the plugin
223 */ 223 */
224void OPluginItem::setPath( const QString& name ) { 224void OPluginItem::setPath( const QString& name ) {
225 m_name = name; 225 m_path = name;
226} 226}
227 227
228/** 228/**
229 * \brief enable or disable the to load attribute 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 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 231 * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig
232 * for a graphical frontend. 232 * for a graphical frontend.
233 * 233 *
234 * @param enabled Enable or Disable the Enabled Attribute 234 * @param enabled Enable or Disable the Enabled Attribute
235 */ 235 */
236void OPluginItem::setEnabled( bool enabled ) { 236void OPluginItem::setEnabled( bool enabled ) {
237 m_enabled = enabled; 237 m_enabled = enabled;
238} 238}
239 239
240/** 240/**
241 * \brief Set the position. 241 * \brief Set the position.
242 * Set the position 242 * Set the position
243 * @param pos The position 243 * @param pos The position
244 * 244 *
245 * @see position() 245 * @see position()
246 */ 246 */
247void OPluginItem::setPosition( int pos ) { 247void OPluginItem::setPosition( int pos ) {
248 m_pos = pos; 248 m_pos = pos;
249} 249}
250 250
251 251
252 252
253/** 253/**
254 * \brief create a PluginLoader 254 * \brief create a PluginLoader
255 * 255 *
256 * Create a PluginLoader autoDelete is set to false 256 * Create a PluginLoader autoDelete is set to false
257 * 257 *
258 * \code 258 * \code
259 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 259 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
260 * Opie::Core::OPluginItem::List lst = loader.filtered(); 260 * Opie::Core::OPluginItem::List lst = loader.filtered();
261 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 261 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
262 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 262 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
263 * } 263 * }
264 * \endcode 264 * \endcode
265 * 265 *
266 * \code 266 * \code
267 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 267 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
268 * Opie::Core::OPluginItem::List lst = loader.filtered(); 268 * Opie::Core::OPluginItem::List lst = loader.filtered();
269 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 269 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
270 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 270 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
271 * } 271 * }
272 * ... 272 * ...
273 * loader.clear(); 273 * loader.clear();
274 * 274 *
275 * \endcode 275 * \endcode
276 * 276 *
277 * @param name The name of the plugin directory. 277 * @param name The name of the plugin directory.
278 * @param isSorted Tell the PluginLoader if your Plugins are sorted 278 * @param isSorted Tell the PluginLoader if your Plugins are sorted
279 */ 279 */
280OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted) 280OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted)
281 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ), 281 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ),
282 m_isSorted( isSorted ) 282 m_isSorted( isSorted )
283{ 283{
284 setPluginDir( QPEApplication::qpeDir() + "/plugins/"+name ); 284 setPluginDir( QPEApplication::qpeDir() + "/plugins/"+name );
285 readConfig(); 285 readConfig();
286} 286}
287 287
288 288
289/** 289/**
@@ -762,129 +762,129 @@ void OPluginManager::disable( const OPluginItem& item) {
762 setEnabled( item, false ); 762 setEnabled( item, false );
763} 763}
764 764
765/** 765/**
766 * \brief Enable or disable the OPluginItem. 766 * \brief Enable or disable the OPluginItem.
767 * Depending on the value of the parameter this will either disable 767 * Depending on the value of the parameter this will either disable
768 * or enable the pluginitem. 768 * or enable the pluginitem.
769 * Beside that same as in @see disable, @see enable, @see setPosition 769 * Beside that same as in @see disable, @see enable, @see setPosition
770 * applies. 770 * applies.
771 * 771 *
772 * @param _item The OPluginItem to enable or to disable. 772 * @param _item The OPluginItem to enable or to disable.
773 * @param b Enable or disable the plugin. 773 * @param b Enable or disable the plugin.
774 * 774 *
775 */ 775 */
776void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) { 776void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
777 OPluginItem item = _item; 777 OPluginItem item = _item;
778 item.setEnabled( b ); 778 item.setEnabled( b );
779 replace( item ); 779 replace( item );
780} 780}
781 781
782/** 782/**
783 * \brief Load necessary information after constructing the object 783 * \brief Load necessary information after constructing the object
784 * If you speified a OGenericPluginLoader you need to call this method 784 * If you speified a OGenericPluginLoader you need to call this method
785 * so that this manager knows what to manage and have a right value for \sa crashedPlugin 785 * so that this manager knows what to manage and have a right value for \sa crashedPlugin
786 * For the name and the list of plugins this does only try to find out the crashed plugin 786 * For the name and the list of plugins this does only try to find out the crashed plugin
787 */ 787 */
788void OPluginManager::load() { 788void OPluginManager::load() {
789 OConfig cfg( configName() ); 789 OConfig cfg( configName() );
790 cfg.setGroup( "General" ); 790 cfg.setGroup( "General" );
791 QString crashedPath = cfg.readEntry( "CrashedPlugin" ); 791 QString crashedPath = cfg.readEntry( "CrashedPlugin" );
792 792
793 /* if we've a loader this applies if we were called from the first part */ 793 /* if we've a loader this applies if we were called from the first part */
794 if ( m_loader ) 794 if ( m_loader )
795 m_plugins = m_loader->allAvailable( m_loader->isSorted() ); 795 m_plugins = m_loader->allAvailable( m_loader->isSorted() );
796 796
797 /* fast and normal route if we did not crash... */ 797 /* fast and normal route if we did not crash... */
798 if ( crashedPath.isEmpty() ) 798 if ( crashedPath.isEmpty() )
799 return; 799 return;
800 800
801 /* lets try to find the plugin path and this way the associated item */ 801 /* lets try to find the plugin path and this way the associated item */
802 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) 802 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it )
803 if ( (*it).path() == crashedPath ) { 803 if ( (*it).path() == crashedPath ) {
804 m_crashed = *it; 804 m_crashed = *it;
805 break; 805 break;
806 } 806 }
807} 807}
808 808
809 809
810/** 810/**
811 * \brief Save the values and this way make it available. 811 * \brief Save the values and this way make it available.
812 * 812 *
813 * Save the current set of data. A call to @see OGenericPluginLoader::filtered 813 * Save the current set of data. A call to @see OGenericPluginLoader::filtered
814 * now would return your saved changes. 814 * now would return your saved changes.
815 */ 815 */
816void OPluginManager::save() { 816void OPluginManager::save() {
817 QMap<QString, QStringList> excluded; // map for path to excluded name 817 QMap<QString, QStringList> excluded; // map for path to excluded name
818 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs 818 QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
819 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; 819 bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
820 820
821 /* 821 /*
822 * We will create some maps for the groups to include positions a 822 * We will create some maps for the groups to include positions a
823 */ 823 */
824 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { 824 for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
825 OPluginItem item = *it; 825 OPluginItem item = *it;
826 QString path = QFileInfo( item.path() ).filePath(); 826 QString path = QFileInfo( item.path() ).dirPath(true);
827 if ( sorted ) { 827 if ( sorted ) {
828 positions[path].append( item.name() ); 828 positions[path].append( item.name() );
829 positions[path].append( QString::number( item.position() ) ); 829 positions[path].append( QString::number( item.position() ) );
830 } 830 }
831 831
832 if ( !item.isEnabled() ) 832 if ( !item.isEnabled() )
833 excluded[path].append( item.name() ); 833 excluded[path].append( item.name() );
834 } 834 }
835 835
836/* 836/*
837 * The code below wouldn't work because we can't delete groups/keys from the config 837 * The code below wouldn't work because we can't delete groups/keys from the config
838 * ### for ODP make Config right! 838 * ### for ODP make Config right!
839 */ 839 */
840// if ( excluded.isEmpty() && positions.isEmpty() ) return; 840// if ( excluded.isEmpty() && positions.isEmpty() ) return;
841 /* 841 /*
842 * Now safe for each path 842 * Now safe for each path
843 */ 843 */
844 OConfig cfg( configName() ); 844 OConfig cfg( configName() );
845 845
846 /* safe excluded items */ 846 /* safe excluded items */
847 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { 847 for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
848 OConfigGroupSaver saver( &cfg, it.key() ); 848 OConfigGroupSaver saver( &cfg, it.key() );
849 cfg.writeEntry("Excluded", it.data(), ',' ); 849 cfg.writeEntry("Excluded", it.data(), ',' );
850 } 850 }
851 851
852 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop 852 /* safe positions we could also see if positions.contains(path) and remove/write in the above loop
853 * ### Write a Test Suite that can profile these runs... 853 * ### Write a Test Suite that can profile these runs...
854 */ 854 */
855 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { 855 for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) {
856 OConfigGroupSaver saver( &cfg, it.key() ); 856 OConfigGroupSaver saver( &cfg, it.key() );
857 cfg.writeEntry("Positions", it.data(), '.' ); 857 cfg.writeEntry("Positions", it.data(), '.' );
858 } 858 }
859} 859}
860 860
861/** 861/**
862 * @internal 862 * @internal
863 */ 863 */
864QString OPluginManager::configName()const { 864QString OPluginManager::configName()const {
865 QString str = m_loader ? m_loader->name() : m_cfgName; 865 QString str = m_loader ? m_loader->name() : m_cfgName;
866 return str + "-odpplugins"; 866 return str + "-odpplugins";
867} 867}
868 868
869/** 869/**
870 * @internal.. replace in m_plugins by path... this is linear search O(n/2) 870 * @internal.. replace in m_plugins by path... this is linear search O(n/2)
871 */ 871 */
872void OPluginManager::replace( const OPluginItem& item ) { 872void OPluginManager::replace( const OPluginItem& item ) {
873 OPluginItem _item; 873 OPluginItem _item;
874 874
875 /* for all plugins */ 875 /* for all plugins */
876 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) { 876 for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) {
877 _item = *it; 877 _item = *it;
878 /* if path and name are the same we will remove, readd and return */ 878 /* if path and name are the same we will remove, readd and return */
879 if ( _item.path() == item.path() && 879 if ( _item.path() == item.path() &&
880 _item.name() == item.name() ) { 880 _item.name() == item.name() ) {
881 it = m_plugins.remove( it ); 881 it = m_plugins.remove( it );
882 m_plugins.append( item ); 882 m_plugins.append( item );
883 return; 883 return;
884 } 884 }
885 885
886 } 886 }
887} 887}
888 888
889} 889}
890} 890}