1 /****************************************************************************
\r
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
\r
4 ** All rights reserved.
\r
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
\r
7 ** This file is part of the Qt Mobility Components.
\r
9 ** $QT_BEGIN_LICENSE:BSD$
\r
10 ** You may use this file under the terms of the BSD license as follows:
\r
12 ** "Redistribution and use in source and binary forms, with or without
\r
13 ** modification, are permitted provided that the following conditions are
\r
15 ** * Redistributions of source code must retain the above copyright
\r
16 ** notice, this list of conditions and the following disclaimer.
\r
17 ** * Redistributions in binary form must reproduce the above copyright
\r
18 ** notice, this list of conditions and the following disclaimer in
\r
19 ** the documentation and/or other materials provided with the
\r
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
\r
22 ** the names of its contributors may be used to endorse or promote
\r
23 ** products derived from this software without specific prior written
\r
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
\r
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
\r
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
\r
39 ****************************************************************************/
\r
41 #include "mediakeysobserver.h"
\r
44 static MediaKeysObserver *theInstance;
\r
46 MediaKeysObserver *MediaKeysObserver::instance()
\r
49 theInstance = new MediaKeysObserver();
\r
54 void MediaKeysObserver::close()
\r
60 MediaKeysObserver::MediaKeysObserver(QObject *parent) : QObject(parent)
\r
63 iInterfaceSelector = CRemConInterfaceSelector::NewL();
\r
64 iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);
\r
65 iInterfaceSelector->OpenTargetL();
\r
68 MediaKeysObserver::~MediaKeysObserver()
\r
71 delete iInterfaceSelector;
\r
74 void MediaKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
\r
75 TRemConCoreApiButtonAction aButtonAct)
\r
78 TRequestStatus status;
\r
79 switch(aOperationId)
\r
81 case ERemConCoreApiPausePlayFunction:
\r
83 if (aButtonAct == ERemConCoreApiButtonClick)
\r
84 emit mediaKeyPressed(MediaKeysObserver::EPlayPauseKey);
\r
86 //Send the response back to Remcon server
\r
87 iCoreTarget->PausePlayFunctionResponse(status, KErrNone);
\r
88 User::WaitForRequest(status);
\r
92 case ERemConCoreApiStop:
\r
94 if (aButtonAct == ERemConCoreApiButtonClick)
\r
95 emit mediaKeyPressed(MediaKeysObserver::EStopKey);
\r
96 iCoreTarget->StopResponse(status, KErrNone);
\r
97 User::WaitForRequest(status);
\r
100 case ERemConCoreApiRewind:
\r
102 if (aButtonAct == ERemConCoreApiButtonClick)
\r
103 emit mediaKeyPressed(MediaKeysObserver::EFastRewindKey);
\r
104 iCoreTarget->RewindResponse(status, KErrNone);
\r
105 User::WaitForRequest(status);
\r
108 case ERemConCoreApiForward:
\r
110 if (aButtonAct == ERemConCoreApiButtonClick)
\r
111 emit mediaKeyPressed(MediaKeysObserver::EForwardKey);
\r
112 iCoreTarget->ForwardResponse(status, KErrNone);
\r
113 User::WaitForRequest(status);
\r
116 case ERemConCoreApiVolumeUp:
\r
118 if (aButtonAct == ERemConCoreApiButtonClick)
\r
119 emit mediaKeyPressed(MediaKeysObserver::EVolIncKey);
\r
120 iCoreTarget->VolumeUpResponse(status, KErrNone);
\r
121 User::WaitForRequest(status);
\r
125 case ERemConCoreApiVolumeDown:
\r
127 if (aButtonAct == ERemConCoreApiButtonClick)
\r
128 emit mediaKeyPressed(MediaKeysObserver::EVolDecKey);
\r
129 iCoreTarget->VolumeDownResponse(status, KErrNone);
\r
130 User::WaitForRequest(status);
\r
133 case ERemConCoreApiFastForward:
\r
135 if (aButtonAct == ERemConCoreApiButtonClick)
\r
136 emit mediaKeyPressed(MediaKeysObserver::EFastForwardKey);
\r
137 iCoreTarget->FastForwardResponse(status, KErrNone);
\r
138 User::WaitForRequest(status);
\r
141 case ERemConCoreApiBackward:
\r
143 if (aButtonAct == ERemConCoreApiButtonClick)
\r
144 emit mediaKeyPressed(MediaKeysObserver::EBackwardKey);
\r
145 iCoreTarget->BackwardResponse(status, KErrNone);
\r
146 User::WaitForRequest(status);
\r