33
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 |
#ifndef SATAPPACTION_H
|
|
20 |
#define SATAPPACTION_H
|
|
21 |
|
|
22 |
#include <QObject>
|
|
23 |
#include <QString>
|
|
24 |
#include <QVariant>
|
|
25 |
#include <QMap>
|
|
26 |
#include <e32base.h> // for symbian-to-qt conversions
|
|
27 |
#include "MSatUiObserver.h" // for the param type definitions
|
|
28 |
#include "satappconstant.h"
|
|
29 |
|
|
30 |
// class declaration
|
|
31 |
class SatAppAction : public QObject
|
|
32 |
{
|
|
33 |
Q_OBJECT
|
|
34 |
|
|
35 |
public:
|
|
36 |
/** creates an action with given identity (TSatAction) */
|
|
37 |
SatAppAction(int action, QObject *parent = 0);
|
|
38 |
~SatAppAction();
|
|
39 |
|
|
40 |
/** synchronous wait until the action has been completed */
|
|
41 |
void waitUntilCompleted();
|
|
42 |
/** completes the action with guiven response */
|
|
43 |
void complete(TSatUiResponse resp);
|
|
44 |
|
|
45 |
public slots:
|
|
46 |
|
|
47 |
/** completes the action */
|
|
48 |
void complete() {complete(response());}
|
|
49 |
|
|
50 |
// comfy methods for completing with certain response
|
|
51 |
void completeWithSuccess() {complete(ESatSuccess);}
|
|
52 |
void completeWithFailure() {complete(ESatFailure);}
|
|
53 |
void completeWithNoResponse() {complete(ESatNoResponseFromUser);}
|
|
54 |
void completeWithBackRequested() {complete(ESatBackwardModeRequestedByUser);}
|
|
55 |
void completeWithSessionTerminated() {complete(ESatSessionTerminatedByUser);}
|
|
56 |
|
|
57 |
signals:
|
|
58 |
|
|
59 |
/** signalled when the action has been completed */
|
|
60 |
void actionCompleted(SatAppAction *action);
|
|
61 |
|
|
62 |
public: // param access
|
|
63 |
|
|
64 |
/** returns the identity of the action (TSatAction) */
|
|
65 |
int action() {return mAction;}
|
|
66 |
|
|
67 |
/** sets the action response */
|
|
68 |
void setResponse(TSatUiResponse resp) {mResponse=resp;}
|
|
69 |
/** the action response (TSatUiResponse) */
|
|
70 |
TSatUiResponse response() {return mResponse;}
|
|
71 |
|
|
72 |
/** sets a value (arbitary type) */
|
|
73 |
void set(const QString& key, QVariant value);
|
|
74 |
|
|
75 |
/** sets QString value after doing symbian-to-qt conversion */
|
|
76 |
void set(const QString& key, const TDesC& value);
|
|
77 |
/** sets QStringList value after doing symbian-to-qt conversion */
|
|
78 |
void set(const QString& key, const MDesCArray& value);
|
|
79 |
/** sets QList<int> value after doing symbian-to-qt conversion */
|
|
80 |
void set(const QString& key, CArrayFixFlat<TInt>& value);
|
|
81 |
/** sets int(millisec) value after doing symbian-to-qt conversion */
|
|
82 |
void set(const QString& key, TTimeIntervalSeconds& value);
|
|
83 |
/** sets int(millisec) value after doing symbian-to-qt conversion */
|
|
84 |
void set(const QString& key, TTimeIntervalMicroSeconds& value);
|
|
85 |
|
|
86 |
/** returns a value (arbitary type) */
|
|
87 |
QVariant value(const QString &key);
|
|
88 |
/** whether a value is present */
|
|
89 |
bool hasValue(const QString &key);
|
|
90 |
|
|
91 |
private: // data
|
|
92 |
|
|
93 |
// identity of this action
|
|
94 |
int mAction;
|
|
95 |
|
|
96 |
// response
|
|
97 |
TSatUiResponse mResponse;
|
|
98 |
|
|
99 |
// parameter map
|
|
100 |
QMap<QString, QVariant> mParams;
|
|
101 |
|
|
102 |
// internal action state
|
|
103 |
enum State {Active,Waiting,Completed};
|
|
104 |
State mState;
|
|
105 |
};
|
|
106 |
|
|
107 |
#endif // SATAPPACTION_H
|
|
108 |
|