kabc
locknull.cpp
00001 /* 00002 This file is part of libkabc. 00003 00004 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 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 }