ui/viewmanagement/statehandler/src/processhandler.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
equal deleted inserted replaced
23:74c9f037fd5d 24:99ad1390cd33
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "processhandler.h"
       
    20 #include <QDebug>
       
    21 #include <QtDebug>
       
    22 
       
    23 ProcessHandler::ProcessHandler(QObject *parent)
       
    24 : QObject(parent)
       
    25     {
       
    26     qDebug() << "ProcessHandler::ProcessHandler";
       
    27     process = new QProcess(this);
       
    28     // Start listening process state changes
       
    29     QObject::connect(process, SIGNAL(stateChanged(QProcess::ProcessState)),
       
    30                      this, SLOT(stateChanged(QProcess::ProcessState)));
       
    31     }
       
    32 
       
    33 ProcessHandler::~ProcessHandler()
       
    34     {
       
    35     qDebug() << "ProcessHandler::~ProcessHandler";
       
    36     if (process->state() != QProcess::NotRunning)
       
    37         {
       
    38         // Close process if it is running
       
    39         process->close();
       
    40         }
       
    41     }
       
    42 
       
    43 void ProcessHandler::StartCameraApp()
       
    44     {
       
    45     qDebug() << "ProcessHandler::StartCameraApp";
       
    46     QString program = "cxui.exe";
       
    47     process->start(program);    
       
    48     }
       
    49 
       
    50 void ProcessHandler::error(QProcess::ProcessError error)
       
    51     {
       
    52     switch (error)
       
    53         {
       
    54         case QProcess::FailedToStart:
       
    55             {
       
    56             qDebug() << "FailedToStart";
       
    57             break;
       
    58             }
       
    59         case QProcess::Crashed:
       
    60             {
       
    61             qDebug() << "Crashed";
       
    62             break;
       
    63             }
       
    64         case QProcess::Timedout:
       
    65             {
       
    66             qDebug() << "Timedout";
       
    67             break;
       
    68             }
       
    69         case QProcess::ReadError:
       
    70             {
       
    71             qDebug() << "ReadError";
       
    72             break;
       
    73             }
       
    74         case QProcess::WriteError:
       
    75             {
       
    76             qDebug() << "WriteError";
       
    77             break;
       
    78             }
       
    79         case QProcess::UnknownError:
       
    80             {
       
    81             qDebug() << "UnknownError";
       
    82             break;
       
    83             }
       
    84         default:
       
    85             {
       
    86             break;
       
    87             }
       
    88         };
       
    89     }
       
    90 
       
    91 void ProcessHandler::stateChanged(QProcess::ProcessState state)
       
    92     {
       
    93     switch (state)
       
    94         {
       
    95         case QProcess::NotRunning:
       
    96             {
       
    97             qDebug() << "NotRunning";
       
    98             break;
       
    99             }
       
   100         case QProcess::Starting:
       
   101             {
       
   102             qDebug() << "Starting";
       
   103             break;
       
   104             }
       
   105         case QProcess::Running:
       
   106             {
       
   107             qDebug() << "Running";
       
   108             break;
       
   109             }
       
   110         default:
       
   111             {
       
   112             break;
       
   113             }
       
   114         };
       
   115     }