|
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: FM Radio widget process handler |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 // User includes |
|
21 #include "fmradiohswidgetprocesshandler.h" |
|
22 #include "fmradiohswidget.h" |
|
23 |
|
24 /*! |
|
25 Constructor |
|
26 */ |
|
27 FmRadioHsWidgetProcessHandler::FmRadioHsWidgetProcessHandler(QObject *parent) : |
|
28 QObject(parent), mProcess(new QProcess(this)) |
|
29 { |
|
30 QObject::connect(mProcess, SIGNAL(stateChanged(QProcess::ProcessState)), |
|
31 this, SLOT(handleStateChange(QProcess::ProcessState))); |
|
32 QObject::connect(mProcess, SIGNAL(error(QProcess::ProcessError error)), |
|
33 this, SLOT(handleError(QProcess::ProcessError error))); |
|
34 QObject::connect(mProcess, |
|
35 SIGNAL(finished(int exitCode, QProcess::ExitStatus exitStatus)), |
|
36 this, |
|
37 SLOT(handleFinish(int exitCode, QProcess::ExitStatus exitStatus))); |
|
38 } |
|
39 |
|
40 /*! |
|
41 Destructor |
|
42 */ |
|
43 FmRadioHsWidgetProcessHandler::~FmRadioHsWidgetProcessHandler() |
|
44 { |
|
45 } |
|
46 |
|
47 /*! |
|
48 Launching of FM Radio application process. |
|
49 */ |
|
50 void FmRadioHsWidgetProcessHandler::startFmRadioApplication() |
|
51 { |
|
52 if (mProcess->pid() == qint64(0)) { |
|
53 QString executablePath = KRadioExecutablePath; |
|
54 QStringList arguments; |
|
55 arguments << KRadioExecutableArguments; |
|
56 mProcess->start(executablePath, arguments); |
|
57 } |
|
58 } |
|
59 |
|
60 /*! |
|
61 Handles state change notifications from FM Radio application process. |
|
62 */ |
|
63 void FmRadioHsWidgetProcessHandler::handleStateChange( |
|
64 QProcess::ProcessState state) |
|
65 { |
|
66 switch (state) { |
|
67 case QProcess::NotRunning: |
|
68 emit fmRadioApplicationStateChanged(QVariant(FmRadioHsWidget::NotRunning)); |
|
69 break; |
|
70 case QProcess::Starting: |
|
71 emit fmRadioApplicationStateChanged(QVariant(FmRadioHsWidget::Starting)); |
|
72 break; |
|
73 case QProcess::Running: |
|
74 emit fmRadioApplicationStateChanged(QVariant(FmRadioHsWidget::Running)); |
|
75 break; |
|
76 default: |
|
77 break; |
|
78 } |
|
79 } |
|
80 |
|
81 /*! |
|
82 Handles error notifications from FM Radio application process. |
|
83 */ |
|
84 void FmRadioHsWidgetProcessHandler::handleError( |
|
85 QProcess::ProcessError error) |
|
86 { |
|
87 switch (error) { |
|
88 case QProcess::FailedToStart: |
|
89 break; |
|
90 case QProcess::Crashed: |
|
91 break; |
|
92 case QProcess::Timedout: |
|
93 break; |
|
94 case QProcess::WriteError: |
|
95 break; |
|
96 case QProcess::ReadError: |
|
97 break; |
|
98 case QProcess::UnknownError: |
|
99 break; |
|
100 default: |
|
101 break; |
|
102 } |
|
103 } |
|
104 |
|
105 /*! |
|
106 Handles finished process notifications from FM Radio application process. |
|
107 */ |
|
108 void FmRadioHsWidgetProcessHandler::handleFinish(int /*exitCode*/, |
|
109 QProcess::ExitStatus exitStatus) |
|
110 { |
|
111 switch (exitStatus) { |
|
112 case QProcess::NormalExit: |
|
113 break; |
|
114 case QProcess::CrashExit: |
|
115 break; |
|
116 default: |
|
117 break; |
|
118 } |
|
119 } |