-rw-r--r-- | library/qcopenvelope_qws.cpp | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/library/qcopenvelope_qws.cpp b/library/qcopenvelope_qws.cpp index 81bb0f5..0aac32b 100644 --- a/library/qcopenvelope_qws.cpp +++ b/library/qcopenvelope_qws.cpp | |||
@@ -104,4 +104,5 @@ QCopEnvelope::~QCopEnvelope() | |||
104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { | 104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { |
105 | #ifndef Q_OS_WIN32 | ||
105 | if(flock(qcopfile.handle(), LOCK_EX)) { | 106 | if(flock(qcopfile.handle(), LOCK_EX)) { |
106 | /* some error occured */ | 107 | /* some error occurred */ |
107 | qWarning(QString("Failed to obtain file lock on %1 (%2)") | 108 | qWarning(QString("Failed to obtain file lock on %1 (%2)") |
@@ -109,18 +110,3 @@ QCopEnvelope::~QCopEnvelope() | |||
109 | } | 110 | } |
110 | /* file locked, but might be stale (e.g. program for whatever | 111 | #endif |
111 | reason did not start). I modified more than 1 minute ago, | ||
112 | truncate the file */ | ||
113 | struct stat buf; | ||
114 | time_t t; | ||
115 | if (!fstat(qcopfile.handle(), &buf) && (time(&t) != (time_t)-1) ) { | ||
116 | // success on fstat, lets compare times | ||
117 | if (buf.st_ctime + 60 < t) { | ||
118 | qWarning("stale file " + qcopfn + " found. Truncating"); | ||
119 | ftruncate(qcopfile.handle(), 0); | ||
120 | qcopfile.reset(); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | if ( !QCopChannel::isRegistered(ch) ) { | ||
125 | int fsize = qcopfile.size(); | ||
126 | { | 112 | { |
@@ -128,3 +114,6 @@ QCopEnvelope::~QCopEnvelope() | |||
128 | ds << ch << msg << data; | 114 | ds << ch << msg << data; |
115 | qcopfile.flush(); | ||
116 | #ifndef Q_OS_WIN32 | ||
129 | flock(qcopfile.handle(), LOCK_UN); | 117 | flock(qcopfile.handle(), LOCK_UN); |
118 | #endif | ||
130 | qcopfile.close(); | 119 | qcopfile.close(); |
@@ -132,25 +121,10 @@ QCopEnvelope::~QCopEnvelope() | |||
132 | 121 | ||
133 | if (fsize == 0) { | 122 | QByteArray b; |
134 | QString cmd = ch.mid(pref); | 123 | QDataStream stream(b, IO_WriteOnly); |
135 | Global::execute(cmd); | 124 | stream << QString(ch.mid(pref)); |
136 | } | 125 | QCopChannel::send("QPE/Server", "processQCop(QString)", b); |
137 | 126 | delete device(); | |
138 | char c; | 127 | return; |
139 | for (int i=0; (c=msg[i]); i++) { | ||
140 | if ( c == ' ' ) { | ||
141 | // Return-value required | ||
142 | // ###### wait for it | ||
143 | break; | ||
144 | } else if ( c == '(' ) { | ||
145 | // No return value | ||
146 | break; | ||
147 | } | ||
148 | } | ||
149 | goto end; | ||
150 | } // endif isRegisterd | ||
151 | flock(qcopfile.handle(), LOCK_UN); | ||
152 | qcopfile.close(); | ||
153 | qcopfile.remove(); | ||
154 | } else { | 128 | } else { |
155 | qWarning(QString("Failed to obtain file lock on %1") | 129 | qWarning(QString("Failed to open file %1") |
156 | .arg(qcopfn)); | 130 | .arg(qcopfn)); |
@@ -167,4 +141,4 @@ QCopEnvelope::~QCopEnvelope() | |||
167 | } | 141 | } |
142 | |||
168 | QCopChannel::send(ch,msg,data); | 143 | QCopChannel::send(ch,msg,data); |
169 | end: | ||
170 | delete device(); | 144 | delete device(); |