[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio/kio
From:       John Tapsell <john.tapsell () kdemail ! net>
Date:       2005-05-06 19:52:41
Message-ID: 1115409161.399992.13070.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 410131 by johnflux:

Add the function:
QValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( \
const QString& path, KConfig& cfg, bool bLocalFiles, const KURL::List & file_list )



 M  +34 -2     trunk/KDE/kdelibs/kio/kio/kmimetype.cpp  
 M  +8 -0      trunk/KDE/kdelibs/kio/kio/kmimetype.h  


--- trunk/KDE/kdelibs/kio/kio/kmimetype.cpp #410130:410131
@@ -969,11 +969,16 @@
 
 QValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( \
const QString& path, KConfig& cfg, bool bLocalFiles )  {
+ return userDefinedServices( path, cfg, bLocalFiles, KURL::List() );
+}
+
+QValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( \
const QString& path, KConfig& cfg, bool bLocalFiles, const KURL::List & file_list ) \
+{  QValueList<Service> result;
 
   cfg.setDesktopGroup();
 
-  if ( !cfg.hasKey( "Actions" ) )
+  if ( !cfg.hasKey( "Actions" ) || !cfg.hasKey( "X-KDE-GetActionMenu") )
     return result;
 
   if ( cfg.hasKey( "TryExec" ) )
@@ -985,8 +990,35 @@
       }
   }
 
-  QStringList keys = cfg.readListEntry( "Actions", ';' ); //the desktop standard \
defines ";" as separator! +  QStringList keys;
+  
+  if( cfg.hasKey( "X-KDE-GetActionMenu" )) {
+    QString dcopcall = cfg.readEntry( "X-KDE-GetActionMenu" );
+    const QCString app = dcopcall.section(' ', 0,0).utf8();
+    
+    QByteArray dataToSend;
+    QDataStream dataStream(dataToSend, IO_WriteOnly);
+    dataStream << file_list;
+    QCString replyType;
+    QByteArray replyData;
+    QCString object =    dcopcall.section(' ', 1,-2).utf8();
+    QString function =  dcopcall.section(' ', -1);
+    if(!function.endsWith("(KURL::List)")) {
+      kdWarning() << "Desktop file " << path << " contains an invalid \
X-KDE-ShowIfDcopCall - the function must take the exact parameter (KURL::List) and \
must be specified." << endl; +    } else {
+      if(kapp->dcopClient()->call( app, object,
+                   function.utf8(),
+                   dataToSend, replyType, replyData, true, 100)
+	    && replyType == "QStringList" ) {
+	      
+        QDataStream dataStreamIn(replyData, IO_ReadOnly);
+        dataStreamIn >> keys;
+      }
+    }
+  }
 
+  keys += cfg.readListEntry( "Actions", ';' ); //the desktop standard defines ";" as \
separator! +  
   if ( keys.count() == 0 )
     return result;
 
--- trunk/KDE/kdelibs/kio/kio/kmimetype.h #410130:410131
@@ -566,6 +566,14 @@
    * @since 3.4
    */
   static QValueList<Service> userDefinedServices( const QString& path, KConfig& \
config, bool bLocalFiles ); +  
+  /**
+   * Overload of userDefinedServices but also allows you to pass a list of urls for \
this file. +   * This allows for the menu to be changed depending on the exact files \
via +   * the X-KDE-GetActionMenu extension.
+   * @since 3.5
+   */
+  static QValueList<Service> userDefinedServices( const QString& path, KConfig& \
config, bool bLocalFiles,  const KURL::List & file_list);  
   /**
    * @param _path is the path of the desktop entry.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic