|
1 /* |
|
2 * Copyright (c) 2003 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: Contains implementation of the CDosServerObserver class. which is the |
|
15 * notification interface to the DOS Server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <DosSvrServices.h> |
|
22 |
|
23 #include "debug.h" |
|
24 #include "fmradioengine.h" |
|
25 #include "fmradioengineradiosettings.h" |
|
26 #include "fmradioenginedosserverobserver.h" |
|
27 |
|
28 // ---------------------------------------------------- |
|
29 // CDosServerObserver::CDosServerObserver |
|
30 // Default class constructor. |
|
31 // ---------------------------------------------------- |
|
32 // |
|
33 CDosServerObserver::CDosServerObserver(CRadioEngine* aEngine, TRadioSettings* aRadioSettings) |
|
34 : iEngine(aEngine), iRadioSettings(aRadioSettings) |
|
35 { |
|
36 } |
|
37 |
|
38 // ---------------------------------------------------- |
|
39 // CDosServerObserver::NewL |
|
40 // Two-phased class constructor. |
|
41 // ---------------------------------------------------- |
|
42 // |
|
43 CDosServerObserver *CDosServerObserver::NewL(CRadioEngine* aEngine, TRadioSettings* aRadioSettings) |
|
44 { |
|
45 CDosServerObserver *self = new (ELeave)CDosServerObserver(aEngine, aRadioSettings); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 |
|
53 // ---------------------------------------------------- |
|
54 // CDosServerObserver::ConstructL |
|
55 // Second phase class constructor. |
|
56 // ---------------------------------------------------- |
|
57 // |
|
58 void CDosServerObserver::ConstructL() |
|
59 { |
|
60 iRadioSettings->SetHeadsetConnected(); |
|
61 RDosServer* server = const_cast< RDosServer* >( &DosServer() ); |
|
62 User::LeaveIfError( iDosAudio.Open(*server) ); |
|
63 TRegisterEvent eventList[] = {{KHandsfreeModeChanged, sizeof(EPSHandsFreeMode),EOnlyLast}, {KHeadsetButtonChanged,sizeof(EPSButtonState), EQueue} }; |
|
64 StartListeningL(eventList,sizeof(eventList)/sizeof(TRegisterEvent)); |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------- |
|
68 // CDosServerObserver::~CDosServerObserver |
|
69 // Destructor of CDosServerObserver class. |
|
70 // ---------------------------------------------------- |
|
71 // |
|
72 CDosServerObserver::~CDosServerObserver() |
|
73 { |
|
74 Stop(); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CDosServerObserver::SetAudioRouting |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 TInt CDosServerObserver::SetAudioRouting(CRadioEngine::TFMRadioAudioOutput aAudioOutput) |
|
83 { |
|
84 TInt err(KErrNone); |
|
85 EPSHandsFreeMode mode = (aAudioOutput == CRadioEngine::EFMRadioOutputHeadset) ? EPSIhfOff : EPSIhfOn; |
|
86 err = iDosAudio.SetHandsfreeMode(mode); |
|
87 return err; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CDosServerObserver::HeadsetButtonChangedL |
|
92 // Handling notification about headset button state change. |
|
93 // (other items were commented in a header). |
|
94 // Status : Draft/Proposal/Approved |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CDosServerObserver::HeadsetButtonChangedL(EPSButtonState aState) |
|
98 { |
|
99 if(aState == EPSButtonUp) |
|
100 { |
|
101 iEngine->HandleHeadsetButtonPress(); |
|
102 } |
|
103 |
|
104 } |
|
105 // end of file |