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 / kabc / lock.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.0 KB  |  89 lines

  1. /*
  2.     This file is part of libkabc.
  3.  
  4.     Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef KABC_LOCK_H
  22. #define KABC_LOCK_H
  23.  
  24. #include <qstring.h>
  25. #include <qobject.h>
  26.  
  27. #include <kdelibs_export.h>
  28.  
  29. namespace KABC {
  30.  
  31. /**
  32.   This class provides locking functionality for a file, directory or an
  33.   arbitrary string-represented resource.
  34. */
  35. class KABC_EXPORT Lock : public QObject
  36. {
  37.     Q_OBJECT
  38.   public:
  39.     /**
  40.       Constructor.
  41.  
  42.       @param identifier An identifier for the resource to be locked, e.g. a file
  43.                         name.
  44.      */
  45.     Lock( const QString &identifier );
  46.  
  47.     /**
  48.       Destruct lock object. This also removes the lock on the resource.
  49.     */
  50.     ~Lock();
  51.  
  52.     /**
  53.       Lock resource.
  54.     */
  55.     virtual bool lock();
  56.     
  57.     /**
  58.       Unlock resource.
  59.     */
  60.     virtual bool unlock();
  61.  
  62.     virtual QString error() const;
  63.  
  64.     QString lockFileName() const;
  65.  
  66.     static bool readLockFile( const QString &filename, int &pid, QString &app );
  67.     static bool writeLockFile( const QString &filename );
  68.  
  69.     static QString locksDir();
  70.  
  71.   signals:
  72.     void locked();
  73.     void unlocked();
  74.  
  75.   private:
  76.     QString mIdentifier;
  77.     
  78.     QString mLockUniqueName;
  79.  
  80.     QString mError;
  81.  
  82.     class Private;
  83.     Private *d;
  84. };
  85.  
  86. }
  87.  
  88. #endif
  89.