85 TQString lockName = lockFileName();
86 kdDebug(5700) <<
"-- lock name: " << lockName <<
endl;
88 if ( TQFile::exists( lockName ) ) {
92 if ( !readLockFile( lockFileName(), pid, app ) ) {
93 mError = i18n(
"Unable to open lock file.");
97 int retval = ::kill( pid, 0 );
98 if ( retval == -1 && errno == ESRCH ) {
99 TQFile::remove( lockName );
100 kdWarning(5700) <<
"Removed stale lock file from process '" << app <<
"'"
103 TQString identifier( mIdentifier );
104 identifier.replace(
'_',
'/' );
106 mError = i18n(
"The address book '%1' is locked by application '%2'.\nIf you believe this is incorrect, just remove the lock file from '%3'")
107 .arg( identifier ).arg( app ).arg(
locateLocal(
"data",
"tdeabc/lock/*.lock" ) );
112 TQString lockUniqueName;
113 lockUniqueName = mIdentifier + tdeApp->randomString( 8 );
114 mLockUniqueName =
locateLocal(
"data",
"tdeabc/lock/" + lockUniqueName );
115 kdDebug(5700) <<
"-- lock unique name: " << mLockUniqueName <<
endl;
118 writeLockFile( mLockUniqueName );
121 int result = ::link( TQFile::encodeName( mLockUniqueName ),
122 TQFile::encodeName( lockName ) );
132 mError = i18n(
"Error");
140 if ( readLockFile( lockFileName(), pid, app ) ) {
141 if ( pid == getpid() ) {
142 TQFile::remove( lockFileName() );
143 TQFile::remove( mLockUniqueName );
146 mError = i18n(
"Unlock failed. Lock file is owned by other process: %1 (%2)")
147 .arg( app ).arg( TQString::number( pid ) );