kitchensync Library API Documentation

KSharedFile Class Reference

The point of KSharedFile is to make it possible for more than one program to work with a file.KSharedFile to lock a file. More...

#include <ksharedfile.h>

Inheritance diagram for KSharedFile:

Inheritance graph
[legend]
Collaboration diagram for KSharedFile:

Collaboration graph
[legend]
List of all members.

Signals

void fileWriteUnlocked (const QString &filename)
void fileWriteLocked (const QString &filename)
void fileChanged (const QString &filename)

DCOP Member Functions

ASYNC slotFileChanged (QString)

Public Member Functions

 KSharedFile (const QString &resource)
 KSharedFile (const QFile &file)
void setFileName (const QString &filename)
void setFile (const QFile &file)
QString fileName () const
Ticket * requestWriteTicket ()
Ticket * requestReadTicket ()
bool save (Ticket *ticket, const QString &string)
bool save (Ticket *ticket, const QByteArray &array)
QFilesave (Ticket *ticket)
QString readAsString (bool &ok, Ticket *ticket)
QByteArray readAsByteArray (bool &ok, Ticket *ticket)
QFilereadAsFile (Ticket *ticket)
bool unlockReadFile (Ticket *ticket)
bool unlockWriteFile (Ticket *ticket)
bool canReadLock ()
bool canWriteLock ()
bool didIReadLock ()
bool didIWriteLock ()

Detailed Description

The point of KSharedFile is to make it possible for more than one program to work with a file.KSharedFile to lock a file.

It take's care that only one program writes to the file at a time. It'll not create any locks on the file though. The program creates a instance of KSharedFile and sets the FileName. If it want's to write to the file it calls tryLockFile( ) and either get's the lock or not. Then there are also signal which signalize a change.

Author:
Holger Freyther <freyther@kde.org>
Version:
0.51

Definition at line 46 of file ksharedfile.h.


Constructor & Destructor Documentation

KSharedFile::KSharedFile const QString resource  ) 
 

Instantiate the class.

Parameters:
resource The resource to be shared with others

Definition at line 36 of file ksharedfile.cpp.

References setFileName().

KSharedFile::KSharedFile const QFile file  ) 
 

this function is for convience it does the same a above but takes a file as parameter

Parameters:
file The file to be shared.

Definition at line 52 of file ksharedfile.cpp.

References setFile().


Member Function Documentation

void KSharedFile::setFileName const QString filename  ) 
 

sets the Filename

Parameters:
filename The name of the resource to be shared

Definition at line 75 of file ksharedfile.cpp.

Referenced by KSharedFile(), and setFile().

void KSharedFile::setFile const QFile file  ) 
 

This method is for convience.It sets the File.

Parameters:
file The file to be shared

Definition at line 85 of file ksharedfile.cpp.

References setFileName().

Referenced by KSharedFile().

QString KSharedFile::fileName  )  const
 

Returns:
the fileName of the shared file

Definition at line 89 of file ksharedfile.cpp.

KSharedFile::Ticket * KSharedFile::requestWriteTicket  ) 
 

This tries to lock the file.

It returns right after trying either successful or not

Returns:
if Ticket is not equal to 0l the file was successfully locked

Definition at line 95 of file ksharedfile.cpp.

KSharedFile::Ticket * KSharedFile::requestReadTicket  ) 
 

This tries to to lock the file for reading.

Definition at line 131 of file ksharedfile.cpp.

bool KSharedFile::save Ticket *  ticket,
const QString string
 

This writes to the file if the ticket is valid.

Parameters:
ticket The ticket.
string The string to write
Returns:
failure

Definition at line 241 of file ksharedfile.cpp.

bool KSharedFile::save Ticket *  ticket,
const QByteArray array
 

This writes to the file if the ticket is valid.

Parameters:
ticket The ticket received by locking
array The array to write
Returns:
failure
See also:
save

Definition at line 254 of file ksharedfile.cpp.

bool KSharedFile::unlockReadFile Ticket *  ticket  ) 
 

after locking this unlocks the file

Definition at line 194 of file ksharedfile.cpp.

bool KSharedFile::canReadLock  ) 
 

check whether or not the file is locked

Returns:
the state of the lock

Definition at line 228 of file ksharedfile.cpp.

bool KSharedFile::didIReadLock  ) 
 

Returns:
whether or not I locked the file

Definition at line 314 of file ksharedfile.cpp.

void KSharedFile::slotFileChanged QString   ) 
 

In future this will tell you who to blame for the file is locked.

Definition at line 322 of file ksharedfile.cpp.

void KSharedFile::fileWriteUnlocked const QString filename  )  [signal]
 

This signal get emitted when the file get unlocked.

Parameters:
filename The name of the file which gets locked

void KSharedFile::fileWriteLocked const QString filename  )  [signal]
 

The file got locked.

Parameters:
filename filename got locked

void KSharedFile::fileChanged const QString filename  )  [signal]
 

The file changed during a lock and unlock session.

Parameters:
filename The file with the name filenam changed


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 25 11:18:56 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003