+/****************************************************************************\r
+**\r
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\r
+** All rights reserved.\r
+** Contact: Nokia Corporation (qt-info@nokia.com)\r
+**\r
+** This file is part of the Qt Mobility Components.\r
+**\r
+** $QT_BEGIN_LICENSE:BSD$\r
+** You may use this file under the terms of the BSD license as follows:\r
+**\r
+** "Redistribution and use in source and binary forms, with or without\r
+** modification, are permitted provided that the following conditions are\r
+** met:\r
+** * Redistributions of source code must retain the above copyright\r
+** notice, this list of conditions and the following disclaimer.\r
+** * Redistributions in binary form must reproduce the above copyright\r
+** notice, this list of conditions and the following disclaimer in\r
+** the documentation and/or other materials provided with the\r
+** distribution.\r
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor\r
+** the names of its contributors may be used to endorse or promote\r
+** products derived from this software without specific prior written\r
+** permission.\r
+**\r
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."\r
+** $QT_END_LICENSE$\r
+**\r
+****************************************************************************/\r
+\r
+#include "mediakeysobserver.h"\r
+#include "trace.h"\r
+\r
+static MediaKeysObserver *theInstance;\r
+\r
+MediaKeysObserver *MediaKeysObserver::instance()\r
+{\r
+ if (!theInstance) {\r
+ theInstance = new MediaKeysObserver();\r
+ }\r
+ return theInstance;\r
+}\r
+\r
+void MediaKeysObserver::close()\r
+{\r
+ delete theInstance;\r
+ theInstance = 0;\r
+}\r
+\r
+MediaKeysObserver::MediaKeysObserver(QObject *parent) : QObject(parent)\r
+{\r
+ TRACE;\r
+ iInterfaceSelector = CRemConInterfaceSelector::NewL();\r
+ iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);\r
+ iInterfaceSelector->OpenTargetL();\r
+}\r
+\r
+MediaKeysObserver::~MediaKeysObserver()\r
+{\r
+ TRACE;\r
+ delete iInterfaceSelector;\r
+}\r
+\r
+void MediaKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId,\r
+ TRemConCoreApiButtonAction aButtonAct)\r
+{\r
+ TRACE;\r
+ TRequestStatus status;\r
+ switch(aOperationId)\r
+ {\r
+ case ERemConCoreApiPausePlayFunction:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EPlayPauseKey);\r
+\r
+ //Send the response back to Remcon server\r
+ iCoreTarget->PausePlayFunctionResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+\r
+ case ERemConCoreApiStop:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EStopKey);\r
+ iCoreTarget->StopResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ case ERemConCoreApiRewind:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EFastRewindKey);\r
+ iCoreTarget->RewindResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ case ERemConCoreApiForward:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EForwardKey);\r
+ iCoreTarget->ForwardResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ case ERemConCoreApiVolumeUp:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EVolIncKey);\r
+ iCoreTarget->VolumeUpResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+\r
+ break;\r
+ }\r
+ case ERemConCoreApiVolumeDown:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EVolDecKey);\r
+ iCoreTarget->VolumeDownResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ case ERemConCoreApiFastForward:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EFastForwardKey);\r
+ iCoreTarget->FastForwardResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ case ERemConCoreApiBackward:\r
+ {\r
+ if (aButtonAct == ERemConCoreApiButtonClick)\r
+ emit mediaKeyPressed(MediaKeysObserver::EBackwardKey);\r
+ iCoreTarget->BackwardResponse(status, KErrNone);\r
+ User::WaitForRequest(status);\r
+ break;\r
+ }\r
+ default:\r
+ break;\r
+ }\r
+}\r