24
|
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 |
#ifndef CRADIOACCESSORYOBSERVER_H
|
|
19 |
#define CRADIOACCESSORYOBSERVER_H
|
|
20 |
|
|
21 |
#include <AccessoryServer.h>
|
|
22 |
#include <AccessoryConnection.h>
|
|
23 |
#include <AccPolSubblockNameArray.h>
|
|
24 |
|
|
25 |
class MRadioHeadsetEventObserver;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Observer of accessory states.
|
|
29 |
*
|
|
30 |
* Instance of this class observes notifications of headset state changes.
|
|
31 |
* In its turn it sends notifications to its observer of those changes.
|
|
32 |
*
|
|
33 |
*/
|
|
34 |
NONSHARABLE_CLASS( CRadioAccessoryObserver ): public CActive
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
|
|
38 |
/**
|
|
39 |
* C++ default constructor.
|
|
40 |
*/
|
|
41 |
CRadioAccessoryObserver();
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Static constructor.
|
|
45 |
*/
|
|
46 |
static CRadioAccessoryObserver* NewL();
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Destructor.
|
|
50 |
*/
|
|
51 |
virtual ~CRadioAccessoryObserver();
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Sets observer. The observer will be notified when headset has been
|
|
55 |
* pressed or headset is connected/disconnected.
|
|
56 |
*
|
|
57 |
* @param aObserver Observer
|
|
58 |
*/
|
|
59 |
void SetObserver( MRadioHeadsetEventObserver* aObserver );
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Tells if there is a headset connected.
|
|
63 |
*
|
|
64 |
* @return <code>ETrue </code> if headset accessory is connected,
|
|
65 |
* <code>EFalse</code> otherwise
|
|
66 |
*/
|
|
67 |
TBool IsHeadsetConnectedL() const;
|
|
68 |
|
|
69 |
// from base class CActive
|
|
70 |
/**
|
|
71 |
* From CActive
|
|
72 |
*
|
|
73 |
* @see CActive::RunL()
|
|
74 |
*/
|
|
75 |
void RunL();
|
|
76 |
|
|
77 |
/**
|
|
78 |
* From CActive
|
|
79 |
*
|
|
80 |
* @see CActive::DoCancel()
|
|
81 |
*/
|
|
82 |
void DoCancel();
|
|
83 |
|
|
84 |
private:
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Finds an accessory. All wired and bluetooth accessories are taken into account.
|
|
88 |
*
|
|
89 |
* @param aAcceptOnlyHeadset If ETrue, search is succesful only if there is a headset connected.
|
|
90 |
* @param aOutputType The output type of the found accessory ( private/public )
|
|
91 |
* @return ETrue, if suitable accessory was found, EFalse otherwise
|
|
92 |
*/
|
|
93 |
TBool FindAccessoryL( TBool aAcceptOnlyHeadset, TAccAudioOutPutType& aOutputType ) const;
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Tells whether the given accessory is a lineout ( and not a headset ).
|
|
97 |
*
|
|
98 |
* @param aAccPolGenId The accessory being investigated.
|
|
99 |
* @return ETrue if the accessory is a lineout, EFalse otherwise.
|
|
100 |
*/
|
|
101 |
TBool IsLineoutConnectedL( TAccPolGenericID& aAccPolGenId ) const;
|
|
102 |
|
|
103 |
private:
|
|
104 |
|
|
105 |
/**
|
|
106 |
* By default Symbian 2nd phase constructor is private.
|
|
107 |
*
|
|
108 |
* @param aAccessoryServer Existing session for The Accessory Server.
|
|
109 |
*/
|
|
110 |
void ConstructL();
|
|
111 |
|
|
112 |
private:
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Updates the set of known accessories.
|
|
116 |
* Method also informs the caller about added/removed accessories.
|
|
117 |
*
|
|
118 |
* @param aNroChangedAccessories On return contains the number of added/removed accessories.
|
|
119 |
*/
|
|
120 |
void UpdateCurrentAccessoriesL( TInt& aNroChangedAccessories );
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Counts the removed accessories.
|
|
124 |
*
|
|
125 |
* @return The number of removed accessories.
|
|
126 |
*/
|
|
127 |
TInt CountRemovedAccessoriesL() const;
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Counts the added accessories.
|
|
131 |
*
|
|
132 |
* @return The number of added accessories.
|
|
133 |
*/
|
|
134 |
TInt CountAddedAccessoriesL() const;
|
|
135 |
|
|
136 |
private:
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Instance that gets notifications of the headset state changes
|
|
140 |
* Not owned.
|
|
141 |
*/
|
|
142 |
MRadioHeadsetEventObserver* iObserver;
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Session for The Accessory Server.
|
|
146 |
* Owned.
|
|
147 |
*/
|
|
148 |
RAccessoryServer iAccessoryServer;
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Accessory Connection.
|
|
152 |
* Owned.
|
|
153 |
*/
|
|
154 |
RAccessoryConnection iAccessoryConn;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Known set of accessories. CRadioAccessoryObserver uses this set to deduce
|
|
158 |
* which accessory has been removed ( or added ) and whether or not it was an acceptable accessory.
|
|
159 |
* Owned.
|
|
160 |
*/
|
|
161 |
RArray<TAccPolGenericID> iSavedAccessories;
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Array of connected accessories.
|
|
165 |
*/
|
|
166 |
TAccPolGenericIDArray iAccPolGenIdArr;
|
|
167 |
|
|
168 |
};
|
|
169 |
|
|
170 |
#endif // CRADIOACCESSORYOBSERVER_H
|