Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > media > main-src > by-pkgid > a6bc312ce50b5c8d0c51736e58ac32bc > files > 122

kdebase-3.4.2-55mdk.src.rpm

--- kdebase-3.1.3/libkonq/konq_popupmenu.cc--	2003-09-01 20:09:00.000000000 -0400
+++ kdebase-3.1.3/libkonq/konq_popupmenu.cc	2003-09-01 20:15:12.000000000 -0400
@@ -134,386 +134,391 @@ KonqPopupMenu::KonqPopupMenu( KBookmarkM
 
 void KonqPopupMenu::setup(bool showPropertiesAndFileType)
 {
-  assert( m_lstItems.count() >= 1 );
+    assert( m_lstItems.count() >= 1 );
 
-  m_ownActions.setWidget( this );
+    m_ownActions.setWidget( this );
 
-  bool currentDir     = false;
-  bool sReading       = true;
-  bool sWriting       = true;
-  bool sDeleting      = true;
-  bool sMoving        = true;
-  m_sMimeType         = m_lstItems.first()->mimetype();
-  mode_t mode         = m_lstItems.first()->mode();
-  bool bTrashIncluded = false;
-  bool bCanChangeSharing = false;
-  m_lstPopupURLs.clear();
-  int id = 0;
-  if( m_sMimeType=="inode/directory" && m_lstItems.first()->isLocalFile())
-    bCanChangeSharing=true;
-  setFont(KGlobalSettings::menuFont());
-  m_pluginList.setAutoDelete( true );
-  m_ownActions.setHighlightingEnabled( true );
-
-  attrName = QString::fromLatin1( "name" );
-
-  prepareXMLGUIStuff();
-  m_builder = new KonqPopupMenuGUIBuilder( this );
-  m_factory = new KXMLGUIFactory( m_builder );
-
-  KURL url;
-  KFileItemListIterator it ( m_lstItems );
-  // Check whether all URLs are correct
-  bool devicesFile = false;
-  for ( ; it.current(); ++it )
-  {
-    url = (*it)->url();
+    bool currentDir     = false;
+    bool sReading       = true;
+    bool sWriting       = true;
+    bool sDeleting      = true;
+    bool sMoving        = true;
+    m_sMimeType         = m_lstItems.first()->mimetype();
+    mode_t mode         = m_lstItems.first()->mode();
+    bool bTrashIncluded = false;
+    bool bCanChangeSharing = false;
+    m_lstPopupURLs.clear();
+    int id = 0;
+    if( m_sMimeType=="inode/directory" && m_lstItems.first()->isLocalFile())
+        bCanChangeSharing=true;
+    setFont(KGlobalSettings::menuFont());
+    m_pluginList.setAutoDelete( true );
+    m_ownActions.setHighlightingEnabled( true );
+
+    attrName = QString::fromLatin1( "name" );
+
+    prepareXMLGUIStuff();
+    m_builder = new KonqPopupMenuGUIBuilder( this );
+    m_factory = new KXMLGUIFactory( m_builder );
+
+    KURL url;
+    KFileItemListIterator it ( m_lstItems );
+    // Check whether all URLs are correct
+    bool devicesFile = false;
+    for ( ; it.current(); ++it )
+    {
+        url = (*it)->url();
 
-    // Build the list of URLs
-    m_lstPopupURLs.append( url );
+        // Build the list of URLs
+        m_lstPopupURLs.append( url );
 
-    // Determine if common mode among all URLs
-    if ( mode != (*it)->mode() )
-      mode = 0; // modes are different => reset to 0
+        // Determine if common mode among all URLs
+        if ( mode != (*it)->mode() )
+            mode = 0; // modes are different => reset to 0
 
-    // Determine if common mimetype among all URLs
-    if ( m_sMimeType != (*it)->mimetype() )
-      m_sMimeType = QString::null; // mimetypes are different => null
+        // Determine if common mimetype among all URLs
+        if ( m_sMimeType != (*it)->mimetype() )
+            m_sMimeType = QString::null; // mimetypes are different => null
 
-    if ( !bTrashIncluded &&
-         (*it)->url().isLocalFile() &&
-         (*it)->url().path( 1 ) == KGlobalSettings::trashPath() )
-        bTrashIncluded = true;
+        if ( !bTrashIncluded &&
+             (*it)->url().isLocalFile() &&
+             (*it)->url().path( 1 ) == KGlobalSettings::trashPath() )
+            bTrashIncluded = true;
 
-    if ( sReading )
-      sReading = KProtocolInfo::supportsReading( url );
+        if ( sReading )
+            sReading = KProtocolInfo::supportsReading( url );
 
-    if ( sWriting )
-      sWriting = KProtocolInfo::supportsWriting( url );
+        if ( sWriting )
+            sWriting = KProtocolInfo::supportsWriting( url );
 
-    if ( sDeleting )
-      sDeleting = KProtocolInfo::supportsDeleting( url );
+        if ( sDeleting )
+            sDeleting = KProtocolInfo::supportsDeleting( url );
 
-    if ( sMoving )
-      sMoving = KProtocolInfo::supportsMoving( url );
-    if ( url.protocol().find("device", 0, false)==0)
-      devicesFile = true;
-  }
-  // Be on the safe side when including the trash
-  if ( bTrashIncluded )
-  {
-      sMoving = false;
-      sDeleting = false;
-  }
-  //check if current url is trash
-  url = m_sViewURL;
-  url.cleanPath();
-
-  m_info.m_Reading = sReading;
-  m_info.m_Writing = sWriting;
-  m_info.m_Deleting = sDeleting;
-  m_info.m_Moving = sMoving;
-  m_info.m_TrashIncluded = bTrashIncluded;
+        if ( sMoving )
+            sMoving = KProtocolInfo::supportsMoving( url );
+        if ( url.protocol().find("device", 0, false)==0)
+            devicesFile = true;
+    }
+    // Be on the safe side when including the trash
+    if ( bTrashIncluded )
+    {
+        sMoving = false;
+        sDeleting = false;
+    }
+    //check if current url is trash
+    url = m_sViewURL;
+    url.cleanPath();
+
+    m_info.m_Reading = sReading;
+    m_info.m_Writing = sWriting;
+    m_info.m_Deleting = sDeleting;
+    m_info.m_Moving = sMoving;
+    m_info.m_TrashIncluded = bTrashIncluded;
 
-  //check if url is current directory
-  if ( m_lstItems.count() == 1 )
-  {
-    KURL firstPopupURL ( m_lstItems.first()->url() );
-    firstPopupURL.cleanPath();
-    //kdDebug(1203) << "View path is " << url.url() << endl;
-    //kdDebug(1203) << "First popup path is " << firstPopupURL.url() << endl;
-    currentDir = firstPopupURL.cmp( url, true /* ignore_trailing */ );
-  }
+    //check if url is current directory
+    if ( m_lstItems.count() == 1 )
+    {
+        KURL firstPopupURL ( m_lstItems.first()->url() );
+        firstPopupURL.cleanPath();
+        //kdDebug(1203) << "View path is " << url.url() << endl;
+        //kdDebug(1203) << "First popup path is " << firstPopupURL.url() << endl;
+        currentDir = firstPopupURL.cmp( url, true /* ignore_trailing */ );
+    }
 
-  bool isCurrentTrash = ( url.isLocalFile() &&
-                          url.path(1) == KGlobalSettings::trashPath() &&
-                          currentDir) ||
-		       ( m_lstItems.count() == 1 && bTrashIncluded );
-  bool isIntoTrash =  url.isLocalFile() && url.path(1).startsWith(KGlobalSettings::trashPath());
-
-  clear();
-
-  //////////////////////////////////////////////////////////////////////////
-
-  KAction * act;
-  if (!isCurrentTrash)
-      addMerge( "konqueror" );
-
-  bool isKDesktop = QCString(  kapp->name() ) == "kdesktop";
-  QString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
-  KAction *actNewView = new KAction( openStr, "window_new", 0, this, SLOT( slotPopupNewView() ), &m_ownActions, "newview" );
-  if ( !isKDesktop )
-    actNewView->setStatusText( i18n( "Open the document in a new window" ) );
+    bool isCurrentTrash = ( url.isLocalFile() &&
+                            url.path(1) == KGlobalSettings::trashPath() &&
+                            currentDir) ||
+                          ( m_lstItems.count() == 1 && bTrashIncluded );
+    bool isIntoTrash =  url.isLocalFile() && url.path(1).startsWith(KGlobalSettings::trashPath());
+
+    clear();
+
+    //////////////////////////////////////////////////////////////////////////
+
+    KAction * act;
+    if (!isCurrentTrash)
+        addMerge( "konqueror" );
+
+    bool isKDesktop = QCString(  kapp->name() ) == "kdesktop";
+    QString openStr = isKDesktop ? i18n( "&Open" ) : i18n( "Open in New &Window" );
+    KAction *actNewView = new KAction( openStr, "window_new", 0, this, SLOT( slotPopupNewView() ), &m_ownActions, "newview" );
+    if ( !isKDesktop )
+        actNewView->setStatusText( i18n( "Open the document in a new window" ) );
 
-  if ( ( isCurrentTrash && currentDir ) ||
-       ( m_lstItems.count() == 1 && bTrashIncluded ) )
-  {
-      if( actNewView)
-          addAction( actNewView );
-    addGroup( "tabhandling" );
-    addSeparator();
+    if ( ( isCurrentTrash && currentDir ) ||
+         ( m_lstItems.count() == 1 && bTrashIncluded ) )
+    {
+        if( actNewView)
+            addAction( actNewView );
+        addGroup( "tabhandling" );
+        addSeparator();
 
-    act = new KAction( i18n( "&Empty Trash Bin" ), 0, this, SLOT( slotPopupEmptyTrashBin() ), &m_ownActions, "empytrash" );
-    addAction( act );
-  }
-  else
-  {
-    if ( S_ISDIR(mode) && sWriting && !isIntoTrash) // A dir, and we can create things into it
+        act = new KAction( i18n( "&Empty Trash Bin" ), 0, this, SLOT( slotPopupEmptyTrashBin() ), &m_ownActions, "empytrash" );
+        addAction( act );
+    }
+    else
     {
-      if ( currentDir && m_pMenuNew ) // Current dir -> add the "new" menu
-      {
-        // As requested by KNewMenu :
-        m_pMenuNew->slotCheckUpToDate();
-        m_pMenuNew->setPopupFiles( m_lstPopupURLs );
+        if ( S_ISDIR(mode) && sWriting && !isIntoTrash) // A dir, and we can create things into it
+        {
+            if ( currentDir && m_pMenuNew ) // Current dir -> add the "new" menu
+            {
+                // As requested by KNewMenu :
+                m_pMenuNew->slotCheckUpToDate();
+                m_pMenuNew->setPopupFiles( m_lstPopupURLs );
 
-        addAction( m_pMenuNew );
+                addAction( m_pMenuNew );
 
-        addSeparator();
-      }
-      else
-      {
-        KAction *actNewDir = new KAction( i18n( "Create Director&y..." ), "folder_new", 0, this, SLOT( slotPopupNewDir() ), &m_ownActions, "newdir" );
-        addAction( actNewDir );
-        addSeparator();
-      }
-    }
+                addSeparator();
+            }
+            else
+            {
+                KAction *actNewDir = new KAction( i18n( "Create Director&y..." ), "folder_new", 0, this, SLOT( slotPopupNewDir() ), &m_ownActions, "newdir" );
+                addAction( actNewDir );
+                addSeparator();
+            }
+        }
 
-    // hack for khtml pages/frames
-    bool httpPage = (m_sViewURL.protocol().find("http", 0, false) == 0);
+        // hack for khtml pages/frames
+        bool httpPage = (m_sViewURL.protocol().find("http", 0, false) == 0);
 
-    if ( currentDir || httpPage ) // rmb on background or html frame
-    {
-      addAction( "back" );
-      addAction( "forward" );
-	  if( !httpPage )
-      	addAction( "up" );
-      if ( currentDir ) // khtml adds a different "reload frame" for frames
-        addAction( "reload" );
-      addGroup( "reload" );
-      addSeparator();
-    }
+        if ( currentDir || httpPage ) // rmb on background or html frame
+        {
+            addAction( "back" );
+            addAction( "forward" );
+            if( !httpPage )
+                addAction( "up" );
+            if ( currentDir ) // khtml adds a different "reload frame" for frames
+                addAction( "reload" );
+            addGroup( "reload" );
+            addSeparator();
+        }
 
-    // "open in new window" always available
-    if( actNewView )
-        addAction( actNewView );
-    addGroup( "tabhandling" );
-    bool separatorAdded = false;
+        // "open in new window" always available
+        if( actNewView )
+            addAction( actNewView );
+        addGroup( "tabhandling" );
+        if( !isCurrentTrash && !isIntoTrash && !devicesFile)
+        {
+            KTrader::OfferList offers;
 
-    if ( !currentDir && sReading && !isIntoTrash && !devicesFile) {
-        addSeparator();
-        separatorAdded = true;
-      if ( sDeleting ) {
-        addAction( "undo" );
-        addAction( "cut" );
-      }
-      addAction( "copy" );
-    }
+            if (kapp->authorizeKAction("openwith"))
+            {
+                // if check m_sMimeType.isNull (no commom mime type) set it to all/all
+                // 3 - Query for applications
+                offers = KTrader::self()->query( m_sMimeType.isNull( ) ? QString::fromLatin1( "all/all" ) : m_sMimeType ,
+                                                 "Type == 'Application' and DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'" );
+            }
 
-    if ( S_ISDIR(mode) && sWriting && !isIntoTrash) {
-        if ( !separatorAdded )
-            addSeparator();
-        if ( currentDir )
-            addAction( "paste" );
-        else
-            addAction( "pasteto" );
-    }
+            //// Ok, we have everything, now insert
 
-    // The actions in this group are defined in PopupMenuGUIClient
-    // When defined, it includes a separator before the 'find' action
-    addGroup( "find" );
-    if( !isIntoTrash )
-    {
-    if (!currentDir)
-    {
-        if ( sReading || sWriting ) // only if we added an action above
-            addSeparator();
+            m_mapPopup.clear();
 
-        if ( m_lstItems.count() == 1 && sWriting )
-            addAction("rename");
+            if ( !offers.isEmpty() )
+            {
+                // First block, app and preview offers
+                addSeparator();
 
-        if ( sMoving )
-            addAction( "trash" );
+                id = 1;
+
+                QDomElement menu = m_menuElement;
+
+                if ( offers.count() > 1 ) // submenu 'open with'
+                {
+                    menu = m_doc.createElement( "menu" );
+                    menu.setAttribute( "name", "openwith submenu" );
+                    m_menuElement.appendChild( menu );
+                    QDomElement text = m_doc.createElement( "text" );
+                    menu.appendChild( text );
+                    text.appendChild( m_doc.createTextNode( i18n("&Open With") ) );
+                }
+
+                if ( menu == m_menuElement ) // no submenu -> open with... above the single offer
+                {
+                    KAction *openWithAct = new KAction( i18n( "&Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
+                    addAction( openWithAct, menu );
+                }
+
+                KTrader::OfferList::ConstIterator it = offers.begin();
+                for( ; it != offers.end(); it++ )
+                {
+                    QCString nam;
+                    nam.setNum( id );
+
+                    act = new KAction( (*it)->name(), (*it)->pixmap( KIcon::Small ), 0,
+                                       this, SLOT( slotRunService() ),
+                                       &m_ownActions, nam.prepend( "appservice_" ) );
+                    addAction( act, menu );
+
+                    m_mapPopup[ id++ ] = *it;
+                }
+
+                if ( menu != m_menuElement ) // submenu
+                {
+                    addSeparator( menu );
+                    KAction *openWithAct = new KAction( i18n( "&Other..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
+                    addAction( openWithAct, menu ); // Other...
+                }
+            }
+            else // no app offers -> Open With...
+            {
+                addSeparator();
+                act = new KAction( i18n( "Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
+                addAction( act );
+            }
 
-        if ( sDeleting ) {
-            addAction( "del" );
-            //if ( m_sViewURL.isLocalFile() )
-            //    addAction( "shred" );
+
+
+            act = new KAction( i18n( "&Add to Bookmarks" ), "bookmark_add", 0, this, SLOT( slotPopupAddToBookmark() ), &m_ownActions, "bookmark_add" );
+            if (kapp->authorizeKAction("bookmarks"))
+                addAction( act );
         }
-    }
-    }
-  }
-  if( !isCurrentTrash && !isIntoTrash)
-  {
-      act = new KAction( i18n( "&Add to Bookmarks" ), "bookmark_add", 0, this, SLOT( slotPopupAddToBookmark() ), &m_ownActions, "bookmark_add" );
-      if (kapp->authorizeKAction("bookmarks"))
-          addAction( act );
-  }
 
-  //////////////////////////////////////////////////////
+        bool separatorAdded = false;
 
-  QValueList<KDEDesktopMimeType::Service> builtin;
-  QValueList<KDEDesktopMimeType::Service> user;
-  QMap<QString, ServiceList> userSubmenus;
+        if ( !currentDir && sReading && !isIntoTrash && !devicesFile) {
+            addSeparator();
+            separatorAdded = true;
+            if ( sDeleting ) {
+                addAction( "undo" );
+                addAction( "cut" );
+            }
+            addAction( "copy" );
+        }
 
-  // 1 - Look for builtin and user-defined services
-  if ( m_sMimeType == "application/x-desktop" && m_lstItems.count() == 1 && m_lstItems.first()->url().isLocalFile() ) // .desktop file
-  {
-      // get builtin services, like mount/unmount
-      builtin = KDEDesktopMimeType::builtinServices( m_lstItems.first()->url() );
-      user = KDEDesktopMimeType::userDefinedServices( m_lstItems.first()->url().path(), url.isLocalFile() );
-  }
-  if ( !isCurrentTrash && !isIntoTrash)
-  {
-  // 2 - Look for "servicesmenus" bindings (konqueror-specific user-defined services)
-  QStringList dirs = KGlobal::dirs()->findDirs( "data", "konqueror/servicemenus/" );
-  QStringList::ConstIterator dIt = dirs.begin();
-  QStringList::ConstIterator dEnd = dirs.end();
+        if ( S_ISDIR(mode) && sWriting && !isIntoTrash) {
+            if ( !separatorAdded )
+                addSeparator();
+            if ( currentDir )
+                addAction( "paste" );
+            else
+                addAction( "pasteto" );
+        }
 
-  for (; dIt != dEnd; ++dIt )
-  {
-      QDir dir( *dIt );
+        // The actions in this group are defined in PopupMenuGUIClient
+        // When defined, it includes a separator before the 'find' action
+        addGroup( "find" );
+        if( !isIntoTrash )
+        {
+            if (!currentDir)
+            {
+                if ( sReading || sWriting ) // only if we added an action above
+                    addSeparator();
 
-      QStringList entries = dir.entryList( QDir::Files );
-      QStringList::ConstIterator eIt = entries.begin();
-      QStringList::ConstIterator eEnd = entries.end();
-
-      for (; eIt != eEnd; ++eIt )
-      {
-          KSimpleConfig cfg( *dIt + *eIt, true );
-
-          cfg.setDesktopGroup();
-
-          if ( cfg.hasKey( "X-KDE-AuthorizeAction") )
-          {
-              bool ok = true;
-              QStringList list = cfg.readListEntry("X-KDE-AuthorizeAction");
-              if (kapp && !list.isEmpty())
-              {
-                  for(QStringList::ConstIterator it = list.begin();
-                      it != list.end();
-                      ++it)
-                  {
-                      if (!kapp->authorize((*it).stripWhiteSpace()))
-                      {
-                          ok = false;
-                          break;
-                      }
-                  }
-              }
-              if (!ok)
-                continue;
-          }
+                if ( m_lstItems.count() == 1 && sWriting )
+                    addAction("rename");
 
-          if ( cfg.hasKey( "Actions" ) && cfg.hasKey( "ServiceTypes" ) )
-          {
-              QStringList types = cfg.readListEntry( "ServiceTypes" );
-			  QStringList excludeTypes = cfg.readListEntry( "ExcludeServiceTypes" );
-              bool ok = !m_sMimeType.isNull() && types.contains( m_sMimeType );
-              if ( !ok ) {
-                  ok = (types[0] == "all/all" ||
-                        types[0] == "allfiles" /*compat with KDE up to 3.0.3*/);
-                  if ( !ok && types[0] == "all/allfiles" )
-                  {
-                      ok = (m_sMimeType != "inode/directory"); // ## or inherits from it
-                  }
-				  
-              }
-			  if ( ok && (excludeTypes.contains( m_sMimeType)))
-					  ok = false;
-              if ( ok )
-              {
-					QString submenuName = cfg.readEntry( "X-KDE-Submenu" );
-                    if (submenuName.isEmpty())
-                    {
-                  		user += KDEDesktopMimeType::userDefinedServices( *dIt + *eIt, url.isLocalFile() );
-					}
-					else
-					{
-						userSubmenus[submenuName] += KDEDesktopMimeType::userDefinedServices( *dIt + *eIt, url.isLocalFile() );
-                    }
-              }
-          }
-      }
-  }
+                if ( sMoving )
+                    addAction( "trash" );
 
-  KTrader::OfferList offers;
+                if ( sDeleting ) {
+                    addAction( "del" );
+                    //if ( m_sViewURL.isLocalFile() )
+                    //    addAction( "shred" );
+                }
+            }
+        }
+    }
 
-  if (kapp->authorizeKAction("openwith"))
-  {
-      // if check m_sMimeType.isNull (no commom mime type) set it to all/all
-      // 3 - Query for applications
-      offers = KTrader::self()->query( m_sMimeType.isNull( ) ? QString::fromLatin1( "all/all" ) : m_sMimeType ,
-   "Type == 'Application' and DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'" );
-  }
+    //////////////////////////////////////////////////////
 
-  //// Ok, we have everything, now insert
+    QValueList<KDEDesktopMimeType::Service> builtin;
+    QValueList<KDEDesktopMimeType::Service> user;
+    QMap<QString, ServiceList> userSubmenus;
 
-  m_mapPopup.clear();
-  m_mapPopupServices.clear();
+    // 1 - Look for builtin and user-defined services
+    if ( m_sMimeType == "application/x-desktop" && m_lstItems.count() == 1 && m_lstItems.first()->url().isLocalFile() ) // .desktop file
+    {
+        // get builtin services, like mount/unmount
+        builtin = KDEDesktopMimeType::builtinServices( m_lstItems.first()->url() );
+        user = KDEDesktopMimeType::userDefinedServices( m_lstItems.first()->url().path(), url.isLocalFile() );
+    }
+    if ( !isCurrentTrash && !isIntoTrash)
+    {
+        // 2 - Look for "servicesmenus" bindings (konqueror-specific user-defined services)
+        QStringList dirs = KGlobal::dirs()->findDirs( "data", "konqueror/servicemenus/" );
+        QStringList::ConstIterator dIt = dirs.begin();
+        QStringList::ConstIterator dEnd = dirs.end();
 
-  if ( !devicesFile)
-  {
-  if ( !offers.isEmpty() )
-  {
-      // First block, app and preview offers
-      addSeparator();
+        for (; dIt != dEnd; ++dIt )
+        {
+            QDir dir( *dIt );
 
-      id = 1;
+            QStringList entries = dir.entryList( QDir::Files );
+            QStringList::ConstIterator eIt = entries.begin();
+            QStringList::ConstIterator eEnd = entries.end();
 
-      QDomElement menu = m_menuElement;
+            for (; eIt != eEnd; ++eIt )
+            {
+                KSimpleConfig cfg( *dIt + *eIt, true );
 
-      if ( offers.count() > 1 ) // submenu 'open with'
-      {
-        menu = m_doc.createElement( "menu" );
-	menu.setAttribute( "name", "openwith submenu" );
-        m_menuElement.appendChild( menu );
-        QDomElement text = m_doc.createElement( "text" );
-        menu.appendChild( text );
-        text.appendChild( m_doc.createTextNode( i18n("&Open With") ) );
-      }
-
-      if ( menu == m_menuElement ) // no submenu -> open with... above the single offer
-      {
-        KAction *openWithAct = new KAction( i18n( "&Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
-        addAction( openWithAct, menu );
-      }
-
-      KTrader::OfferList::ConstIterator it = offers.begin();
-      for( ; it != offers.end(); it++ )
-      {
-        QCString nam;
-        nam.setNum( id );
-
-        act = new KAction( (*it)->name(), (*it)->pixmap( KIcon::Small ), 0,
-                           this, SLOT( slotRunService() ),
-                           &m_ownActions, nam.prepend( "appservice_" ) );
-        addAction( act, menu );
-
-        m_mapPopup[ id++ ] = *it;
-      }
-
-      if ( menu != m_menuElement ) // submenu
-      {
-        addSeparator( menu );
-        KAction *openWithAct = new KAction( i18n( "&Other..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
-        addAction( openWithAct, menu ); // Other...
-      }
-  }
-  else // no app offers -> Open With...
-  {
-      addSeparator();
-      act = new KAction( i18n( "Open With..." ), 0, this, SLOT( slotPopupOpenWith() ), &m_ownActions, "openwith" );
-      addAction( act );
-  }
+                cfg.setDesktopGroup();
 
-  addGroup( "preview" );
-  }
-  addSeparator();
-  }
+                if ( cfg.hasKey( "X-KDE-AuthorizeAction") )
+                {
+                    bool ok = true;
+                    QStringList list = cfg.readListEntry("X-KDE-AuthorizeAction");
+                    if (kapp && !list.isEmpty())
+                    {
+                        for(QStringList::ConstIterator it = list.begin();
+                            it != list.end();
+                            ++it)
+                        {
+                            if (!kapp->authorize((*it).stripWhiteSpace()))
+                            {
+                                ok = false;
+                                break;
+                            }
+                        }
+                    }
+                    if (!ok)
+                        continue;
+                }
+
+                if ( cfg.hasKey( "Actions" ) && cfg.hasKey( "ServiceTypes" ) )
+                {
+                    QStringList types = cfg.readListEntry( "ServiceTypes" );
+                    QStringList excludeTypes = cfg.readListEntry( "ExcludeServiceTypes" );
+                    bool ok = !m_sMimeType.isNull() && types.contains( m_sMimeType );
+                    if ( !ok ) {
+                        ok = (types[0] == "all/all" ||
+                              types[0] == "allfiles" /*compat with KDE up to 3.0.3*/);
+                        if ( !ok && types[0] == "all/allfiles" )
+                        {
+                            ok = (m_sMimeType != "inode/directory"); // ## or inherits from it
+                        }
 
-  // Second block, builtin + user
-  if ( !user.isEmpty() || !userSubmenus.empty() || !builtin.isEmpty() )
-  {
+                    }
+                    if ( ok && (excludeTypes.contains( m_sMimeType)))
+                        ok = false;
+                    if ( ok )
+                    {
+                        QString submenuName = cfg.readEntry( "X-KDE-Submenu" );
+                        if (submenuName.isEmpty())
+                        {
+                            user += KDEDesktopMimeType::userDefinedServices( *dIt + *eIt, url.isLocalFile() );
+                        }
+                        else
+                        {
+                            userSubmenus[submenuName] += KDEDesktopMimeType::userDefinedServices( *dIt + *eIt, url.isLocalFile() );
+                        }
+                    }
+                }
+            }
+        }
+
+        m_mapPopupServices.clear();
+
+        if ( !devicesFile)
+        {
+            addSeparator();
+            addGroup( "preview" );
+        }
+        addSeparator();
+    }
+
+    // Second block, builtin + user
+    if ( !user.isEmpty() || !userSubmenus.empty() || !builtin.isEmpty() )
+    {
         QDomElement actionMenu = m_doc.createElement( "menu" );
         actionMenu.setAttribute( "name", "actions submenu" );
         m_menuElement.appendChild( actionMenu );
@@ -542,95 +547,95 @@ void KonqPopupMenu::setup(bool showPrope
         insertServices(user, actionMenu, false);
         insertServices(builtin, actionMenu, true);
 #if 0
-      bool insertedOffer = false;
+        bool insertedOffer = false;
 
-      QValueList<KDEDesktopMimeType::Service>::Iterator it2 = user.begin();
-      for( ; it2 != user.end(); ++it2 )
-      {
-        if ((*it2).m_display == true)
+        QValueList<KDEDesktopMimeType::Service>::Iterator it2 = user.begin();
+        for( ; it2 != user.end(); ++it2 )
         {
-          QCString nam;
-          nam.setNum( id );
-          act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "userservice_" ) );
-
-          if ( !(*it2).m_strIcon.isEmpty() )
-          {
-            QPixmap pix = SmallIcon( (*it2).m_strIcon );
-            act->setIconSet( pix );
-          }
+            if ((*it2).m_display == true)
+            {
+                QCString nam;
+                nam.setNum( id );
+                act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "userservice_" ) );
+
+                if ( !(*it2).m_strIcon.isEmpty() )
+                {
+                    QPixmap pix = SmallIcon( (*it2).m_strIcon );
+                    act->setIconSet( pix );
+                }
 
-          addAction( act, m_menuElement ); // Add to toplevel menu
+                addAction( act, m_menuElement ); // Add to toplevel menu
 
-          m_mapPopupServices[ id++ ] = *it2;
-          insertedOffer = true;
+                m_mapPopupServices[ id++ ] = *it2;
+                insertedOffer = true;
+            }
         }
-      }
 
-      it2 = builtin.begin();
-      for( ; it2 != builtin.end(); ++it2 )
-      {
-        QCString nam;
-        nam.setNum( id );
+        it2 = builtin.begin();
+        for( ; it2 != builtin.end(); ++it2 )
+        {
+            QCString nam;
+            nam.setNum( id );
 
-        act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "builtinservice_" ) );
+            act = new KAction( (*it2).m_strName, 0, this, SLOT( slotRunService() ), &m_ownActions, nam.prepend( "builtinservice_" ) );
 
-        if ( !(*it2).m_strIcon.isEmpty() )
-        {
-          QPixmap pix = SmallIcon( (*it2).m_strIcon );
-          act->setIconSet( pix );
-        }
+            if ( !(*it2).m_strIcon.isEmpty() )
+            {
+                QPixmap pix = SmallIcon( (*it2).m_strIcon );
+                act->setIconSet( pix );
+            }
 
-        addAction( act, m_menuElement );
+            addAction( act, m_menuElement );
 
-        m_mapPopupServices[ id++ ] = *it2;
-        insertedOffer = true;
-      }
+            m_mapPopupServices[ id++ ] = *it2;
+            insertedOffer = true;
+        }
 
-      if ( insertedOffer )
-        addSeparator();
+        if ( insertedOffer )
+            addSeparator();
 #endif
-  }
-  addSeparator();
+    }
+    addSeparator();
 
-  if( !isCurrentTrash && !isIntoTrash)
-      addPlugins( ); // now it's time to add plugins
+    if( !isCurrentTrash && !isIntoTrash)
+        addPlugins( ); // now it's time to add plugins
 
-  if ( !m_sMimeType.isEmpty() && showPropertiesAndFileType  && !isCurrentTrash && !isIntoTrash &&!devicesFile)
-  {
-      act = new KAction( i18n( "&Edit File Type..." ), 0, this, SLOT( slotPopupMimeType() ),
-                       &m_ownActions, "editfiletype" );
-      addAction( act );
-  }
+    if ( !m_sMimeType.isEmpty() && showPropertiesAndFileType  && !isCurrentTrash && !isIntoTrash &&!devicesFile)
+    {
+        act = new KAction( i18n( "&Edit File Type..." ), 0, this, SLOT( slotPopupMimeType() ),
+                           &m_ownActions, "editfiletype" );
+        addAction( act );
+    }
 
-  if ( KPropertiesDialog::canDisplay( m_lstItems ) && showPropertiesAndFileType )
-  {
-      act = new KAction( i18n( "&Properties" ), 0, this, SLOT( slotPopupProperties() ),
-                         &m_ownActions, "properties" );
-      addAction( act );
-  }
+    if ( KPropertiesDialog::canDisplay( m_lstItems ) && showPropertiesAndFileType )
+    {
+        act = new KAction( i18n( "&Properties" ), 0, this, SLOT( slotPopupProperties() ),
+                           &m_ownActions, "properties" );
+        addAction( act );
+    }
 
-  while ( !m_menuElement.lastChild().isNull() &&
+    while ( !m_menuElement.lastChild().isNull() &&
             m_menuElement.lastChild().toElement().tagName().lower() == "separator" )
-    m_menuElement.removeChild( m_menuElement.lastChild() );
+        m_menuElement.removeChild( m_menuElement.lastChild() );
 
-  if( bCanChangeSharing && !isCurrentTrash && !isIntoTrash)
-  {
-   if(KFileShare::authorization()==KFileShare::Authorized)
-   {
-       addSeparator();
-       QString label;
-       label=i18n("Share");
-
-       act = new KAction( label, 0, this, SLOT( slotOpenShareFileDialog() ),
-                  &m_ownActions, "sharefile" );
-       addAction( act );
-   }
-  }
+    if( bCanChangeSharing && !isCurrentTrash && !isIntoTrash)
+    {
+        if(KFileShare::authorization()==KFileShare::Authorized)
+        {
+            addSeparator();
+            QString label;
+            label=i18n("Share");
+
+            act = new KAction( label, 0, this, SLOT( slotOpenShareFileDialog() ),
+                               &m_ownActions, "sharefile" );
+            addAction( act );
+        }
+    }
 
 
-  addMerge( 0 );
+    addMerge( 0 );
 
-  m_factory->addClient( this );
+    m_factory->addClient( this );
 }