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
@@ -177,97 +177,97 @@ bool OPluginItem::operator!=( const OPluginItem& r )const{
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();
@@ -778,97 +778,97 @@ void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
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