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

  1. /* This file is part of the KDE project
  2.    Copyright (c) 2001 David Faure <david@mandrakesoft.com>
  3.    Copyright (c) 2001 Laurent Montel <lmontel@mandrakesoft.com>
  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 version 2 as published by the Free Software Foundation.
  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.  
  20. #ifndef kfileshare_h
  21. #define kfileshare_h
  22. #include <qobject.h>
  23.  
  24. #include <kdelibs_export.h>
  25.  
  26. class KDirWatch;
  27.  
  28. /**
  29.  * @internal
  30.  * Do not use, ever.
  31.  */
  32. class KFileSharePrivate : public QObject
  33. {
  34.   Q_OBJECT
  35.  
  36. public:
  37.   KFileSharePrivate();
  38.   ~KFileSharePrivate();
  39.   KDirWatch* m_watchFile;
  40.   static KFileSharePrivate *self();
  41.   static KFileSharePrivate *_self;
  42. protected slots: // this is why this class needs to be in the .h
  43.  void slotFileChange(const QString &);
  44. };
  45.  
  46. /**
  47.  * Common functionality for the file sharing
  48.  * (communication with the backend)
  49.  * @since 3.1
  50.  */
  51. class KIO_EXPORT KFileShare
  52. {
  53.  
  54.   
  55. public:
  56.     /**
  57.      * Reads the file share configuration file
  58.      */
  59.     static void readConfig();
  60.     
  61.     /**
  62.      * Reads the list of shared folders
  63.      */
  64.     static void readShareList();
  65.  
  66.  
  67.     /**
  68.      * Call this to know if a directory is currently shared
  69.      */
  70.     static bool isDirectoryShared( const QString& path );
  71.  
  72.     enum Authorization { NotInitialized, ErrorNotFound, Authorized, UserNotAllowed };
  73.     /**
  74.      * Call this to know if the current user is authorized to share directories
  75.      */
  76.     static Authorization authorization();
  77.  
  78.     static QString findExe( const char* exeName );
  79.  
  80.     /**
  81.      * Uses a suid perl script to share the given path 
  82.      * with NFS and Samba
  83.      * @param path the path to share
  84.      * @param shared whether the path should be shared or not
  85.      * @returns whether the perl script was successful
  86.      */
  87.     static bool setShared( const QString& path, bool shared );
  88.     
  89.     /**
  90.      * The used share mode.
  91.      * Simple means that the simple sharing dialog is used and
  92.      * users can share only folders from there HOME folder.
  93.      * Advanced means that the advanced sharing dialog is used and
  94.      * users can share any folder.
  95.      */
  96.     enum ShareMode { Simple, Advanced };
  97.     
  98.     /**
  99.      * Returns whether sharing is enabled
  100.      * If this is false, file sharing is disabled and
  101.      * nobody can share files.
  102.      */
  103.     static bool sharingEnabled();
  104.     
  105.     /**
  106.      * Returns whether file sharing is restricted.
  107.      * If it is not restricted every user can shar files.
  108.      * If it is restricted only users in the configured
  109.      * file share group can share files.
  110.      */
  111.     static bool isRestricted();
  112.     
  113.     /**
  114.      * Returns the group that is used for file sharing.
  115.      * That is, all users in that group are allowed to
  116.      * share files if file sharing is restricted.
  117.      */
  118.     static QString fileShareGroup();
  119.     
  120.     /**
  121.      * Returns the configured share mode
  122.      */
  123.     static ShareMode shareMode();
  124.     
  125.     /**
  126.      * Returns whether Samba is enabled
  127.      */
  128.     static bool sambaEnabled();
  129.     
  130.     /** 
  131.      * Returns whether NFS is enabled
  132.      */
  133.     static bool nfsEnabled();
  134.  
  135. private:
  136.     static Authorization s_authorization;
  137.     static QStringList* s_shareList;
  138.     static ShareMode s_shareMode;
  139.     static bool s_sambaEnabled;
  140.     static bool s_nfsEnabled;
  141.     static bool s_restricted;
  142.     static QString s_fileShareGroup;
  143.     static bool s_sharingEnabled;
  144.     
  145. };
  146.  
  147. #endif
  148.