kitchensync Library API Documentation

ksharedfile.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001, 2002 Holger Freyther <freyher@kde.org> 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 00019 */ 00020 00021 #ifndef ksharedfile_h 00022 #define ksharedfile_h 00023 00024 #include <sys/types.h> 00025 00026 #include <qstring.h> 00027 #include <dcopobject.h> 00028 00029 class QFile; 00030 class QTimer; 00031 00046 class KSharedFile : public QObject, public DCOPObject 00047 { 00048 Q_OBJECT 00049 K_DCOP 00050 public: 00051 00056 KSharedFile( const QString &resource ); 00057 00063 KSharedFile( const QFile &file ); 00064 ~KSharedFile( ); 00065 00066 class Ticket 00067 { 00068 friend class KSharedFile; 00069 Ticket ( const QString &filename ) : m_fileName( filename ) {} 00070 private: 00071 QString m_fileName; 00072 }; 00073 00077 void setFileName (const QString &filename ); 00078 00082 void setFile( const QFile &file ); 00083 00086 QString fileName( ) const; 00087 00091 Ticket* requestWriteTicket( ); 00092 00096 Ticket* requestReadTicket(); 00097 00103 bool save( Ticket *ticket, const QString &string ); 00104 00112 bool save( Ticket *ticket, const QByteArray & array); 00113 00114 00115 QFile* save( Ticket *ticket ); 00116 00117 QString readAsString( bool &ok, Ticket *ticket ); 00118 QByteArray readAsByteArray( bool &ok, Ticket *ticket ); 00119 QFile* readAsFile( Ticket *ticket ); 00120 00123 bool unlockReadFile( Ticket *ticket ); 00124 bool unlockWriteFile( Ticket *ticket ); 00128 bool canReadLock( ); 00129 bool canWriteLock(); 00133 bool didIReadLock( ); 00134 bool didIWriteLock(); 00138 //QString whoHoldsLock( ) const; 00139 k_dcop: 00140 ASYNC slotFileChanged(QString ); 00141 00142 private: 00143 QFile *m_file; 00144 QString m_fileName; 00145 time_t m_ChangeTime; 00146 bool readLock; 00147 bool writeLock; 00148 void updateLocks(); 00149 00150 signals: 00155 void fileWriteUnlocked( const QString &filename); 00159 void fileWriteLocked( const QString &filename ); 00164 void fileChanged( const QString &filename ); 00165 00166 00167 }; 00168 00169 #endif 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:59 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003