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 / knewstuff / knewstuff.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.1 KB  |  162 lines

  1. /*
  2.     This file is part of KOrganizer.
  3.     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef KNEWSTUFF_H
  21. #define KNEWSTUFF_H
  22.  
  23. #include <qstring.h>
  24.  
  25. #include <kdemacros.h>
  26.  
  27. class QObject;
  28. class QWidget;
  29. class KAction;
  30. class KActionCollection;
  31.  
  32. namespace KNS {
  33. class Engine;
  34. class Entry;
  35.  
  36. KDE_EXPORT KAction* standardAction(const QString& what,
  37.                         const QObject *recvr,
  38.                         const char *slot,
  39.                         KActionCollection* parent,
  40.                         const char *name = 0);
  41. }
  42.  
  43. /**
  44.  * @short This class provides the functionality to download and upload "new stuff".
  45.  *
  46.  * Applications have to subclass KNewStuff, implement the pure virtual functions
  47.  * and link to against libknewstuff.
  48.  *
  49.  * By calling download() the download process is started which means that a list
  50.  * of "providers" is fetched from a "master server", information about new stuff
  51.  * is collected from the providers and presented to the user. Selected entries
  52.  * get downloaded and installed to the application. The required functions to
  53.  * install new stuff are provided by implementing install(). The location where
  54.  * the downloaded files are stored can be customized by reimplementing
  55.  * downloadDestination().
  56.  *
  57.  * By calling upload() the upload process is started which means the user has to
  58.  * select a provider from the list fetched from the master server and to put in
  59.  * information about the entry to be uploaded. Then the file to be uploaded is
  60.  * fetched from the application by calling createUploadFile() and transfered to
  61.  * the upload destination specified in the provider list.
  62.  *
  63.  * @author Cornelius Schumacher (schumacher@kde.org)
  64.  * \par Maintainer:
  65.  * Josef Spillner (spillner@kde.org)
  66.  *
  67.  * @since 3.3
  68.  */
  69. class KDE_EXPORT KNewStuff
  70. {
  71.   public:
  72.     /**
  73.       Constructor.
  74.  
  75.       @param type type of data to be handled, should be something like
  76.                   korganizer/calendar, kword/template, kdesktop/wallpaper
  77.       @param parentWidget parent widget of dialogs opened by the KNewStuff
  78.                           engine
  79.     */
  80.     KNewStuff( const QString &type, QWidget *parentWidget = 0 );
  81.     
  82.     /**
  83.       Constructor.
  84.  
  85.       @param type type of data to be handled, should be something like
  86.                   korganizer/calendar, kword/template, kdesktop/wallpaper
  87.       @param providerList the URL of the provider list
  88.       @param parentWidget parent widget of dialogs opened by the KNewStuff
  89.                           engine
  90.     */
  91.     KNewStuff( const QString &type, const QString &providerList, QWidget *parentWidget = 0 );
  92.     virtual ~KNewStuff();
  93.  
  94.     /**
  95.       Return type of data.
  96.     */
  97.     QString type() const;
  98.  
  99.     /**
  100.       Return parent widget.
  101.     */
  102.     QWidget *parentWidget() const;
  103.  
  104.     /**
  105.       Start download process.
  106.     */
  107.     void download();
  108.  
  109.     /**
  110.       Start upload process.
  111.     */
  112.     void upload();
  113.  
  114.     /**
  115.       Upload with pre-defined files.
  116.     */
  117.     void upload( const QString &fileName, const QString previewName );
  118.  
  119.     /**
  120.       Install file to application. The given fileName points to the file
  121.       downloaded by the KNewStuff engine. This is a temporary file by default.
  122.       The application can do whatever is needed to handle the information
  123.       contained in the file.
  124.  
  125.       The function returns true, when the installation
  126.       was successful and false if were errors.
  127.  
  128.       @param fileName name of downloaded file
  129.     */
  130.     virtual bool install( const QString &fileName ) = 0;
  131.     /**
  132.       Create a file to be uploaded to a "new stuff provider" and return the
  133.       filename. The format of the file is application specific. The only
  134.       constraint is that the corresponding install() implementation is able to
  135.       use the file.
  136.  
  137.       @param fileName name of the file to be written
  138.       @return @c true on success, @c false on error.
  139.     */
  140.     virtual bool createUploadFile( const QString &fileName ) = 0;
  141.  
  142.     /**
  143.       Return a filename which should be used as destination for downloading the
  144.       specified new stuff entry. Reimplement this function, if you don't want
  145.       the new stuff to be downloaded to a temporary file.
  146.     */
  147.     virtual QString downloadDestination( KNS::Entry *entry );
  148.     
  149.     
  150.   protected:
  151.     /**
  152.       Get the pointer to the engine. Needed by subclasses to access the KNS::Engine object.
  153.      */  
  154.     KNS::Engine *engine() { return mEngine; }  
  155.  
  156.     
  157.   private:
  158.     KNS::Engine *mEngine;
  159. };
  160.  
  161. #endif
  162.