~ubuntu-branches/ubuntu/edgy/digikam/edgy-updates

« back to all changes in this revision

Viewing changes to digikam/digikamcameraprocess.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2005-03-10 02:39:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050310023902-023nymfst5mg696c
Tags: 0.7.2-2
* debian/TODO: clean
* digikam manpage: better --detect-camera description

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ============================================================
2
 
 * File  : digikamcameraprocess.cpp
3
 
 * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
4
 
 * Date  : 2003-02-19
5
 
 * Description : 
6
 
 * 
7
 
 * Copyright 2003 by Renchi Raju
8
 
 
9
 
 * This program is free software; you can redistribute it
10
 
 * and/or modify it under the terms of the GNU General
11
 
 * Public License as published bythe Free Software Foundation;
12
 
 * either version 2, or (at your option)
13
 
 * any later version.
14
 
 * 
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 * 
20
 
 * ============================================================ */
21
 
 
22
 
#include <kprocess.h>
23
 
#include <klocale.h>
24
 
#include <kdebug.h>
25
 
#include <kapplication.h>
26
 
#include <kmessagebox.h>
27
 
#include <dcopclient.h>
28
 
#include <qcstring.h>
29
 
 
30
 
#include "digikamcameraprocess.h"
31
 
 
32
 
 
33
 
DigikamCameraProcess::DigikamCameraProcess(QObject *parent)
34
 
    : QObject(parent)
35
 
{
36
 
    process_ = new KProcess;
37
 
    *process_ << "digikamcameraclient";
38
 
 
39
 
    connect(process_, SIGNAL(processExited(KProcess*)),
40
 
            this,     SLOT(slotProcessEnded()));
41
 
}
42
 
 
43
 
DigikamCameraProcess::~DigikamCameraProcess()
44
 
{
45
 
    disconnect(process_, SIGNAL(processExited(KProcess*)),
46
 
               this,     SLOT(slotProcessEnded()));
47
 
    stop();
48
 
    delete process_;
49
 
}
50
 
 
51
 
void DigikamCameraProcess::start()
52
 
{
53
 
    if (!process_->start()) {
54
 
        kdError() << "DigikamCameraProcess: "
55
 
                  << "Failed to launch Camera Process" << endl;
56
 
        KMessageBox::error(0, i18n("Failed to launch Camera Client. "
57
 
                                   "You would not be able to access the camera(s) "
58
 
                                   "(Make sure that `digikamcameraclient' is"
59
 
                                   " installed correctly)"));
60
 
    }
61
 
    else
62
 
        kdDebug() << "DigikamCameraProcess: "
63
 
                  << "Launched Camera Process" << endl;
64
 
}
65
 
 
66
 
void DigikamCameraProcess::kill()
67
 
{
68
 
    process_->kill();
69
 
}
70
 
 
71
 
void DigikamCameraProcess::stop()
72
 
{
73
 
    QByteArray data, replyData;
74
 
    QCString replyType;
75
 
    
76
 
    DCOPClient *client = kapp->dcopClient();
77
 
    if (!client->call("digikamcameraclient", "DigikamCameraClient",
78
 
                      "close()", data, replyType, replyData))
79
 
        kdError() << "DigikamCameraProcess: DCOP communication error" << endl;
80
 
    else
81
 
        kdDebug() << "DigikamCameraProcess: Stopped client" << endl;
82
 
}
83
 
 
84
 
void DigikamCameraProcess::slotProcessEnded()
85
 
{
86
 
    if (KMessageBox::questionYesNo(0, i18n("Camera Client Died Unexpectedly. "
87
 
                                           "Shall I restart the process? "
88
 
                                           "(Note: Otherwise you would not be able to "
89
 
                                           "access the camera(s))")) ==
90
 
        KMessageBox::Yes) {
91
 
        start();
92
 
    }
93
 
}