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 / knewstuffsecure.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.7 KB  |  102 lines

  1. /***************************************************************************
  2.                         knewstuffsecure.h  -  description
  3.                              -------------------
  4.     begin               : Tue Jun 22 12:19:55 2004
  5.     copyright          : (C) 2004, 2005 by Andras Mantia <amantia@kde.org>
  6.  ***************************************************************************/
  7.  
  8. /***************************************************************************
  9.  *                                                                         *
  10.  *   This program is free software; you can redistribute it and/or modify  *
  11.  *   it under the terms of the GNU Library General Public License as       *
  12.  *   published by the Free Software Foundation; version 2 of the License.  *
  13.  *                                                                         *
  14.  ***************************************************************************/
  15.  
  16. #ifndef KNEWSTUFFSECURE_H
  17. #define KNEWSTUFFSECURE_H
  18.  
  19. //qt includes
  20. #include <qobject.h>
  21.  
  22. //kde includes
  23. #include "knewstuff.h"
  24.  
  25. class KTempDir;
  26. /**
  27. Makes possible downloading and installing signed resource files from a server.
  28. You must subclass it and implement the @ref installResource() pure
  29. virtual method to install a resource. For uploading you must create a resource
  30. tarball (which is installabale by @ref installResource()) and call the 
  31. @ref uploadResource() method with this tarball as the argument.
  32. Signing and verification is done by the gpg application, so the user must
  33. have it installed, otherwise this class does not give any extra security compared
  34. to the standard KNewStuff class.
  35.  
  36. @since 3.4
  37.  
  38. @author Andras Mantia <amantia@kde.org>
  39. */
  40. class KDE_EXPORT KNewStuffSecure : public  QObject, public KNewStuff
  41. {
  42.   Q_OBJECT
  43.  
  44. public:
  45.     /** Constructor.
  46.  
  47.       @param type type of data to be handled, should be something like
  48.              korganizer/calendar, kword/template, kdesktop/wallpaper
  49.       @param parentWidget parent widget of dialogs opened by the KNewStuff
  50.               engine
  51.      */
  52.     KNewStuffSecure(const QString &type,  QWidget *parentWidget=0);
  53.     virtual ~KNewStuffSecure();
  54.  
  55.     /** Installs the downloaded resource. Do not call or reimplement directly. 
  56.         It's reimplemented from KNewStuff for internal reasons. 
  57.     */
  58.     bool install( const QString &fileName );
  59.     
  60.     /** Reimplemented for internal reasons. */
  61.     bool createUploadFile(const QString &fileName);
  62.     
  63.     /** Initiates a download. This is the method that must be called in
  64.     * order to download a signed resource. */
  65.     void downloadResource();
  66.     
  67.     /** Signs the file and uploads to the central server.
  68.     * @param fileName The file to be signed and uploaded
  69.     */
  70.     void uploadResource(const QString &fileName);
  71.     
  72.  
  73. private slots:
  74.     /** Checks the validity of the downloaded tarball and installs it*/
  75.     void slotValidated(int result);
  76.     /** The file is signed, so it can be uploaded.*/
  77.     void slotFileSigned(int result);
  78.     /** Called when the upload has finished. 
  79.         @param result the result of the upload
  80.         Be careful if you reimplement it, as it deletes the temporary directory
  81.         m_tempDir used for upload. You must also delete it (call the parent's method)
  82.         if you reimplement it.
  83.     */
  84.     void slotUploadFinished(bool result);  
  85.  
  86. signals:
  87.     void installFinished();
  88.     
  89. protected:
  90.    /** Installs the resource specified by m_tarName. Implement it in the subclass. */
  91.     virtual void installResource() = 0;
  92.     /** Removes the temporary directory m_tempDir. */
  93.     void removeTempDirectory();    
  94.     
  95.     KTempDir *m_tempDir;
  96.     QString m_tarName; 
  97.     QString m_signedFileName;
  98.     QMap<QString, QString> m_installedResources;
  99. };
  100.  
  101. #endif
  102.