home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdesktopfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  6.8 KB  |  252 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (c) 1999 Pietro Iglio <iglio@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.    
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef _KDESKTOPFILE_H
  20. #define _KDESKTOPFILE_H
  21.  
  22. #include "kconfig.h"
  23. #include "kdelibs_export.h"
  24.  
  25. class KDesktopFilePrivate;
  26.  
  27. /** 
  28.  * KDE Desktop File Management.
  29.  *
  30.  * @author Pietro Iglio <iglio@kde.org>
  31.  * @see  KConfigBase  KConfig
  32.  * @short KDE Desktop File Management class
  33.  */
  34. class KDECORE_EXPORT KDesktopFile : public KConfig
  35. {
  36.   Q_OBJECT
  37.  
  38. public:
  39.   /**
  40.    * Constructs a KDesktopFile object and make it either read-write
  41.    * or read-only.
  42.    *
  43.    * @param fileName  The name or path of the desktop file. If it
  44.    *                  is not absolute, it will be located
  45.    *                  using the resource type @p resType.
  46.    * @param readOnly  Whether the object should be read-only.
  47.    * @param resType   Allows you to change what sort of resource
  48.    *                  to search for if @p fileName is not absolute.  For
  49.    *                  instance, you might want to specify "config".
  50.    */
  51.   KDesktopFile( const QString &fileName, bool readOnly = false,
  52.         const char * resType = "apps");
  53.  
  54.   /**
  55.    * Destructs the KDesktopFile object.
  56.    *
  57.    * Writes back any dirty configuration entries.
  58.    */
  59.   virtual ~KDesktopFile();
  60.  
  61.   /**
  62.    * Checks whether this is really a desktop file.
  63.    *
  64.    * The check is performed looking at the file extension (the file is not
  65.    * opened).
  66.    * Currently, valid extensions are ".kdelnk" and ".desktop".
  67.    * @param path the path of the file to check
  68.    * @return true if the file appears to be a desktop file.
  69.    */
  70.   static bool isDesktopFile(const QString& path);
  71.  
  72.   /**
  73.    * Checks whether the user is authorized to run this desktop file.
  74.    * By default users are authorized to run all desktop files but
  75.    * the KIOSK framework can be used to activate certain restrictions.
  76.    * See README.kiosk for more information.
  77.    * @param path the file to check
  78.    * @return true if the user is authorized to run the file
  79.    * @since 3.1
  80.    */
  81.   static bool isAuthorizedDesktopFile(const QString& path);
  82.  
  83.   /**
  84.    * Returns the location where changes for the .desktop file @p path
  85.    * should be written to.
  86.    * @since 3.2
  87.    */
  88.   static QString locateLocal(const QString &path);
  89.  
  90.   /**
  91.    * Returns the value of the "Type=" entry.
  92.    * @return the type or QString::null if not specified
  93.    */
  94.   QString readType() const;
  95.  
  96.   /**
  97.    * Returns the value of the "Icon=" entry.
  98.    * @return the icon or QString::null if not specified 
  99.    */
  100.   QString readIcon() const;
  101.  
  102.   /**
  103.    * Returns the value of the "Name=" entry.
  104.    * @return the name or QString::null if not specified
  105.    */
  106.   QString readName() const;
  107.  
  108.   /**
  109.    * Returns the value of the "Comment=" entry.
  110.    * @return the comment or QString::null if not specified
  111.    */
  112.   QString readComment() const;
  113.  
  114.   /**
  115.    * Returns the value of the "GenericName=" entry.
  116.    * @return the generic name or QString::null if not specified
  117.    */
  118.   QString readGenericName() const;
  119.  
  120.   /**
  121.    * Returns the value of the "Path=" entry.
  122.    * @return the path or QString::null if not specified
  123.    */
  124.   QString readPath() const;
  125.  
  126.   /**
  127.    * Returns the value of the "Dev=" entry.
  128.    * @return the device or QString::null if not specified
  129.    */
  130.   QString readDevice() const;
  131.  
  132.   /**
  133.    * Returns the value of the "URL=" entry.
  134.    * @return the URL or QString::null if not specified
  135.    */
  136.   QString readURL() const;
  137.  
  138.   /**
  139.    * Returns a list of the "Actions=" entries.
  140.    * @return the list of actions
  141.    */
  142.   QStringList readActions() const;
  143.  
  144.   /**
  145.    * Sets the desktop action group.
  146.    * @param group the new action group
  147.    */
  148.   void setActionGroup(const QString &group);
  149.  
  150.   /**
  151.    * Returns true if the action group exists, false otherwise
  152.    * @param group the action group to test
  153.    * @return true if the action group exists
  154.    */
  155.   bool hasActionGroup(const QString &group) const;
  156.  
  157.   /**
  158.    * Checks whether there is a "Type=Link" entry.
  159.    *
  160.    * The link points to the "URL=" entry.
  161.    * @return true if there is a "Type=Link" entry
  162.    */
  163.   bool hasLinkType() const;
  164.  
  165.   /**
  166.    * Checks whether there is an entry "Type=Application".
  167.    * @return true if there is a "Type=Application" entry
  168.    */
  169.   bool hasApplicationType() const;
  170.  
  171.   /**
  172.    * Checks whether there is an entry "Type=MimeType".
  173.    * @return true if there is a "Type=MimeType" entry
  174.    */
  175.   bool hasMimeTypeType() const; // funny name :)
  176.  
  177.   /**
  178.    * Checks whether there is an entry "Type=FSDev".
  179.    * @return true if there is a "Type=FSDev" entry
  180.    */
  181.   bool hasDeviceType() const;
  182.  
  183.   /**
  184.    * Checks whether the TryExec field contains a binary
  185.    * which is found on the local system.
  186.    * @return true if TryExec contains an existing binary
  187.    */
  188.   bool tryExec() const;
  189.  
  190.   /**
  191.    * Returns the file name.
  192.    * @return The filename as passed to the constructor.
  193.    */
  194.   QString fileName() const;
  195.  
  196.   /**
  197.    * Returns the resource.
  198.    * @return The resource type as passed to the constructor.
  199.    */
  200.   QString resource() const;
  201.  
  202.   /**
  203.    * Returns the value of the "X-DocPath=" Or "DocPath=" entry.
  204.      * X-DocPath should be used and DocPath is depreciated and will
  205.      * one day be not supported.
  206.    * @return The value of the "X-DocPath=" Or "DocPath=" entry.
  207.    * @since 3.1
  208.    */
  209.   QString readDocPath() const;
  210.  
  211.   /**
  212.    * Returns the entry of the "SortOrder=" entry.
  213.    * @return the value of the "SortOrder=" entry.
  214.    */
  215.   QStringList sortOrder() const;
  216.  
  217.   /**
  218.    * Copies all entries from this config object to a new 
  219.    * KDesktopFile object that will save itself to @p file.
  220.    *
  221.    * Actual saving to @p file happens when the returned object is
  222.    * destructed or when sync() is called upon it.
  223.    *
  224.    * @param file the new KDesktopFile object it will save itself to.
  225.    * @since 3.2
  226.    */
  227.   KDesktopFile* copyTo(const QString &file) const;
  228.  
  229. #ifdef KDE_NO_COMPAT
  230. private:
  231. #endif
  232.   /**
  233.    * @deprecated Use fileName() instead.
  234.    */
  235.     KDE_DEPRECATED QString filename() const { return fileName(); };
  236.  
  237. private:
  238.  
  239.   // copy-construction and assignment are not allowed
  240.   KDesktopFile( const KDesktopFile& );
  241.   KDesktopFile& operator= ( const KDesktopFile& );
  242.  
  243. protected:
  244.   virtual void virtual_hook( int id, void* data );
  245. private:
  246.   KDesktopFilePrivate *d;
  247. };
  248.  
  249.  
  250. #endif
  251.  
  252.