kabc
locknull.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "locknull.h"
00023
00024 #include <klocale.h>
00025 #include <kdebug.h>
00026
00027 using namespace KABC;
00028
00029 class LockNull::Private
00030 {
00031 public:
00032 Private( bool allowAccess )
00033 : mAllowAccess( allowAccess )
00034 {
00035 }
00036
00037 bool mAllowAccess;
00038 };
00039
00040 LockNull::LockNull( bool allowAccess )
00041 : Lock( QString() ), d( new Private( allowAccess ) )
00042 {
00043 }
00044
00045 LockNull::~LockNull()
00046 {
00047 unlock();
00048
00049 delete d;
00050 }
00051
00052 bool LockNull::lock()
00053 {
00054 if ( !d->mAllowAccess ) {
00055 return false;
00056 }
00057
00058 kWarning(5700) << "LockNull::lock() force success. Doesn't actually lock.";
00059
00060 emit locked();
00061
00062 return true;
00063 }
00064
00065 bool LockNull::unlock()
00066 {
00067 emit unlocked();
00068 return true;
00069 }
00070
00071 QString LockNull::error() const
00072 {
00073 if ( d->mAllowAccess ) {
00074 return i18n( "LockNull: All locks succeed but no actual locking is done." );
00075 } else {
00076 return i18n( "LockNull: All locks fail." );
00077 }
00078 }