~ubuntu-branches/ubuntu/raring/recorditnow/raring

« back to all changes in this revision

Viewing changes to src/plugins/recorder/recordmydesktop/recordmydesktoprecorder.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-09 14:54:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110109145401-gyckb4airz4fio50
Tags: 0.8.1-0ubuntu1
* New upstream release. (LP: #681270)
  - Update debian/copyright.
* Build-depend on recordmydesktop.
* Add a watch file.
* Drop 01_fix_ftbfs_kwarning_call.diff, fixed upstream.
* Add 01_joschy_install_to_usr_lib.diff.
* Add 02_fix_ftbfs_no-add-needed.diff.
* Add 03_dont_install_header_files.diff.
* Replace dependency on libpolkit-qt-1-0 with policykit-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
}
285
285
 
286
286
 
287
 
bool RecordMyDesktopRecorder::remove(const QString &file)
288
 
{
289
 
 
290
 
    QFile f(file);
291
 
    if (!f.remove()) {
292
 
        emit error(i18nc("%1 = file, %2 = error string", "recordmydesktop: Remove failed: %1.\n"
293
 
                         "Reason: %2", file, f.errorString()));
294
 
        return false;
295
 
    }
296
 
    return true;
297
 
 
298
 
}
299
 
 
300
 
 
301
 
bool RecordMyDesktopRecorder::move(const QString &from, const QString &to)
302
 
{
303
 
 
304
 
    QFile file;
305
 
    if (!file.rename(from, to)) {
306
 
        emit error(i18nc("%1 = source, %1 = destination, %3 = error string",
307
 
                         "Move failed: \"%1\" to \"%2\".\n"
308
 
                         "Reason: %3", from, to, file.errorString()));
309
 
        return false;
310
 
    }
311
 
    return true;
312
 
 
313
 
}
314
 
 
315
 
 
316
287
void RecordMyDesktopRecorder::clean()
317
288
{
318
289
 
344
315
    QFile outputFile(m_data.outputFile);
345
316
    if (outputFile.exists()) {
346
317
        if (m_data.overwrite) {
347
 
            if (!remove(m_data.outputFile)) {
348
 
                clean();
349
 
                return;
350
 
            }
 
318
            m_removeId = remove(m_data.outputFile);
 
319
            return;
351
320
        } else {
352
321
            m_data.outputFile = unique(m_data.outputFile);
353
322
            emit outputFileChanged(m_data.outputFile);
354
323
        }
355
324
    }
356
 
 
357
 
    if (!move(m_data.tmpFile, m_data.outputFile)) {
358
 
        clean();
 
325
    moveToDestination();
 
326
 
 
327
}
 
328
 
 
329
 
 
330
void RecordMyDesktopRecorder::moveToDestination()
 
331
{
 
332
 
 
333
    m_moveId = move(m_data.tmpFile, m_data.outputFile);
 
334
    if (m_moveId.isEmpty()) {
 
335
        emit error(i18n("Internal error!"));
 
336
    }
 
337
 
 
338
}
 
339
 
 
340
 
 
341
void RecordMyDesktopRecorder::jobFinished(const QString &id, const QString &errorString)
 
342
{
 
343
 
 
344
    if (!errorString.isEmpty()) {
 
345
        emit error(errorString);
359
346
        return;
360
347
    }
361
348
 
362
 
    clean();
363
 
 
364
 
    if (status == KProcess::CrashExit) {
365
 
        emit finished(Crash);
366
 
    } else {
 
349
    if (id == m_moveId) {
367
350
        emit finished(Normal);
 
351
    } else if (id == m_removeId) {
 
352
        moveToDestination();
368
353
    }
369
354
 
370
355
}