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 |
#ifndef SATAPPTONEPROVIDER_H
|
|
18 |
#define SATAPPTONEPROVIDER_H
|
|
19 |
|
|
20 |
// includes
|
|
21 |
#include <QObject>
|
|
22 |
#include <QString>
|
|
23 |
#include <QByteArray>
|
|
24 |
#include <msatuiobserver.h> //for TSatUiResponse
|
|
25 |
#include <mdaaudiotoneplayer.h> //MMdaAudioToneObserver
|
|
26 |
#include <mdaaudiosampleplayer.h> //MMdaAudioPlayerCallback
|
|
27 |
|
|
28 |
// forward declarations
|
|
29 |
class QTimer;
|
|
30 |
class HbMessageBox;
|
|
31 |
class CMdaAudioToneUtility;
|
|
32 |
class CMdaAudioPlayerUtility;
|
|
33 |
class SatAppAction;
|
|
34 |
|
|
35 |
|
|
36 |
class SatAppToneProvider:
|
|
37 |
public QObject,
|
|
38 |
public MMdaAudioToneObserver,
|
|
39 |
public MMdaAudioPlayerCallback
|
|
40 |
{
|
|
41 |
Q_OBJECT
|
|
42 |
|
|
43 |
public:
|
|
44 |
|
|
45 |
SatAppToneProvider(QObject *parent = 0);
|
|
46 |
virtual ~SatAppToneProvider();
|
|
47 |
|
|
48 |
public slots:
|
|
49 |
|
|
50 |
void playTone(SatAppAction& action);
|
|
51 |
|
|
52 |
void clearScreen();
|
|
53 |
|
|
54 |
private:
|
|
55 |
|
|
56 |
enum State {Idle,PlayStandardTone,PlayUserSelectedTone};
|
|
57 |
|
|
58 |
State recognizeTone(
|
|
59 |
int tone,
|
|
60 |
QByteArray& sequence,
|
|
61 |
int& duration);
|
|
62 |
QByteArray charArrayToByteArray(
|
|
63 |
const char tone[],
|
|
64 |
int size);
|
|
65 |
void playStandardTone(
|
|
66 |
const QString& text,
|
|
67 |
const QByteArray& sequence,
|
|
68 |
int duration);
|
|
69 |
void playUserSelectedTone(
|
|
70 |
const QString& text,
|
|
71 |
int tone,
|
|
72 |
int duration);
|
|
73 |
|
|
74 |
public slots:
|
|
75 |
/**
|
|
76 |
* Resets the UI state within the tone provider,
|
|
77 |
* commits pending server requests if any
|
|
78 |
*/
|
|
79 |
void resetState();
|
|
80 |
|
|
81 |
private slots:
|
|
82 |
|
|
83 |
void stopPlayTone();
|
|
84 |
|
|
85 |
// ****************************************************************************
|
|
86 |
// * ************************************************************************ *
|
|
87 |
// * * SYMBIAN PART * *
|
|
88 |
// * ************************************************************************ *
|
|
89 |
// ****************************************************************************
|
|
90 |
|
|
91 |
private:
|
|
92 |
|
|
93 |
void SymbianPrepareAudioToneUtilityL(const TDesC8& sequence);
|
|
94 |
void SymbianStopAudioToneUtility();
|
|
95 |
void SymbianPrepareAudioPlayerL(int tone, int duration);
|
|
96 |
void SymbianStopAudioPlayer();
|
|
97 |
void GetProfileParamsL(
|
|
98 |
int tone=ESatToneNotSet, TDes* toneName=NULL );
|
|
99 |
|
|
100 |
public: // from MMdaAudioToneObserver
|
|
101 |
|
|
102 |
void MatoPrepareComplete( TInt aError );
|
|
103 |
void MatoPlayComplete( TInt aError );
|
|
104 |
|
|
105 |
public: //from MMdaAudioPlayerCallback
|
|
106 |
|
|
107 |
void MapcInitComplete( TInt aError,
|
|
108 |
const TTimeIntervalMicroSeconds& aDuration );
|
|
109 |
void MapcPlayComplete( TInt aError );
|
|
110 |
|
|
111 |
|
|
112 |
private: // Data
|
|
113 |
|
|
114 |
State mState;
|
|
115 |
SatAppAction* mCurrentAction;
|
|
116 |
|
|
117 |
bool mWarningAndPlayTones;
|
|
118 |
int mVolume;
|
|
119 |
CMdaAudioToneUtility *mPlayer;
|
|
120 |
TSatUiResponse mPlayToneError;
|
|
121 |
QTimer *mTimer;
|
|
122 |
HbMessageBox *mPermanentNote;
|
|
123 |
CMdaAudioPlayerUtility *mAudioPlayer;
|
|
124 |
|
|
125 |
// for unit testing
|
|
126 |
friend class ToneProviderTest;
|
|
127 |
};
|
|
128 |
|
|
129 |
#endif //SATAPPTONEPROVIDER_H
|