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 / k3bexternalbinmanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  4.2 KB  |  163 lines

  1. /* 
  2.  *
  3.  * $Id: k3bexternalbinmanager.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16. #ifndef K3B_EXTERNAL_BIN_MANAGER_H
  17. #define K3B_EXTERNAL_BIN_MANAGER_H
  18.  
  19. #include <qmap.h>
  20. #include <qobject.h>
  21. #include <qstring.h>
  22. #include <qstringlist.h>
  23. #include <qptrlist.h>
  24. #include "k3b_export.h"
  25. #include "k3bversion.h"
  26.  
  27. class KConfig;
  28. class KProcess;
  29.  
  30.  
  31. class K3bExternalProgram;
  32.  
  33.  
  34. /**
  35.  * A K3bExternalBin represents an installed version of a program.
  36.  * All K3bExternalBin objects are managed by K3bExternalPrograms.
  37.  *
  38.  * A bin may have certain features that are represented by a string.
  39.  */
  40. class LIBK3B_EXPORT K3bExternalBin
  41. {
  42.  public:
  43.   K3bExternalBin( K3bExternalProgram* );
  44.   virtual ~K3bExternalBin() {}
  45.  
  46.   K3bVersion version;
  47.   QString path;
  48.   QString copyright;
  49.  
  50.   const QString& name() const;
  51.   bool isEmpty() const;
  52.   const QStringList& userParameters() const;
  53.   const QStringList& features() const { return m_features; }
  54.  
  55.   bool hasFeature( const QString& ) const;
  56.   void addFeature( const QString& );
  57.  
  58.   K3bExternalProgram* program() const { return m_program; }
  59.  
  60.  private:
  61.   QStringList m_features;
  62.   K3bExternalProgram* m_program;
  63. };
  64.  
  65.  
  66. /**
  67.  * This is the main class that represents a program
  68.  * It's scan method has to be reimplemented for every program
  69.  * It manages a list of K3bExternalBin-objects that each represent
  70.  * one installed version of the program.
  71.  */
  72. class LIBK3B_EXPORT K3bExternalProgram
  73. {
  74.  public:
  75.   K3bExternalProgram( const QString& name );
  76.   virtual ~K3bExternalProgram();
  77.  
  78.   const K3bExternalBin* defaultBin() const { return m_bins.getFirst(); }
  79.   const K3bExternalBin* mostRecentBin() const;
  80.  
  81.   void addUserParameter( const QString& );
  82.   void setUserParameters( const QStringList& list ) { m_userParameters = list; }
  83.  
  84.   const QStringList& userParameters() const { return m_userParameters; }
  85.   const QString& name() const { return m_name; }
  86.  
  87.   void addBin( K3bExternalBin* );
  88.   void clear() { m_bins.clear(); }
  89.   void setDefault( const K3bExternalBin* );
  90.   void setDefault( const QString& path );
  91.  
  92.   const QPtrList<K3bExternalBin>& bins() const { return m_bins; }
  93.  
  94.   /**
  95.    * this scans for the program in the given path,
  96.    * adds the found bin object to the list and returnes true.
  97.    * if nothing could be found false is returned.
  98.    */
  99.   virtual bool scan( const QString& ) {return false;}//= 0;
  100.  
  101.   /**
  102.    * reimplement this if it does not make sense to have the user be able
  103.    * to specify additional parameters
  104.    */
  105.   virtual bool supportsUserParameters() const { return true; }
  106.  
  107.  private:
  108.   QString m_name;
  109.   QStringList m_userParameters;
  110.   QPtrList<K3bExternalBin> m_bins;
  111. };
  112.  
  113.  
  114. class LIBK3B_EXPORT K3bExternalBinManager : public QObject
  115. {
  116.   Q_OBJECT
  117.  
  118.  public:
  119.   K3bExternalBinManager( QObject* parent = 0, const char* name = 0 );
  120.   ~K3bExternalBinManager();
  121.  
  122.   void search();
  123.  
  124.   /**
  125.    * read config and add changes to current map.
  126.    * Takes care of setting the config group
  127.    */
  128.   bool readConfig( KConfig* );
  129.  
  130.   /**
  131.    * Takes care of setting the config group
  132.    */
  133.   bool saveConfig( KConfig* );
  134.  
  135.   bool foundBin( const QString& name );
  136.   const QString& binPath( const QString& name );
  137.   const K3bExternalBin* binObject( const QString& name );
  138.   const K3bExternalBin* mostRecentBinObject( const QString& name );
  139.  
  140.   K3bExternalProgram* program( const QString& ) const;
  141.   const QMap<QString, K3bExternalProgram*>& programs() const { return m_programs; }
  142.  
  143.   /** always extends the default searchpath */
  144.   void setSearchPath( const QStringList& );
  145.   void addSearchPath( const QString& );
  146.   void loadDefaultSearchPath();
  147.  
  148.   const QStringList& searchPath() const { return m_searchPath; }
  149.  
  150.   void addProgram( K3bExternalProgram* );
  151.   void clear();
  152.  
  153.  private:
  154.   QMap<QString, K3bExternalProgram*> m_programs;
  155.   QStringList m_searchPath;
  156.  
  157.   static QString m_noPath;  // used for binPath() to return const string
  158.  
  159.   QString m_gatheredOutput;
  160. };
  161.  
  162. #endif
  163.