Increase heap size on Symbian.
[dorian] / widgets / mediakeysobserver.cpp
1 /****************************************************************************\r
2 **\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
6 **\r
7 ** This file is part of the Qt Mobility Components.\r
8 **\r
9 ** $QT_BEGIN_LICENSE:BSD$\r
10 ** You may use this file under the terms of the BSD license as follows:\r
11 **\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
14 ** met:\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
20 **     distribution.\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
24 **     permission.\r
25 **\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
37 ** $QT_END_LICENSE$\r
38 **\r
39 ****************************************************************************/\r
40 \r
41 #include "mediakeysobserver.h"\r
42 #include "trace.h"\r
43 \r
44 static MediaKeysObserver *theInstance;\r
45 \r
46 MediaKeysObserver *MediaKeysObserver::instance()\r
47 {\r
48     if (!theInstance) {\r
49         theInstance = new MediaKeysObserver();\r
50     }\r
51     return theInstance;\r
52 }\r
53 \r
54 void MediaKeysObserver::close()\r
55 {\r
56     delete theInstance;\r
57     theInstance = 0;\r
58 }\r
59 \r
60 MediaKeysObserver::MediaKeysObserver(QObject *parent) : QObject(parent)\r
61 {\r
62     TRACE;\r
63     iInterfaceSelector = CRemConInterfaceSelector::NewL();\r
64     iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);\r
65     iInterfaceSelector->OpenTargetL();\r
66 }\r
67 \r
68 MediaKeysObserver::~MediaKeysObserver()\r
69 {\r
70     TRACE;\r
71     delete iInterfaceSelector;\r
72 }\r
73 \r
74 void MediaKeysObserver::MrccatoCommand(TRemConCoreApiOperationId aOperationId,\r
75                                        TRemConCoreApiButtonAction aButtonAct)\r
76 {\r
77     TRACE;\r
78     TRequestStatus status;\r
79     switch(aOperationId)\r
80     {\r
81     case ERemConCoreApiPausePlayFunction:\r
82         {\r
83             if (aButtonAct == ERemConCoreApiButtonClick)\r
84                 emit mediaKeyPressed(MediaKeysObserver::EPlayPauseKey);\r
85 \r
86             //Send the response back to Remcon server\r
87             iCoreTarget->PausePlayFunctionResponse(status, KErrNone);\r
88             User::WaitForRequest(status);\r
89             break;\r
90         }\r
91 \r
92     case ERemConCoreApiStop:\r
93         {\r
94             if (aButtonAct == ERemConCoreApiButtonClick)\r
95                 emit mediaKeyPressed(MediaKeysObserver::EStopKey);\r
96             iCoreTarget->StopResponse(status, KErrNone);\r
97             User::WaitForRequest(status);\r
98             break;\r
99         }\r
100     case ERemConCoreApiRewind:\r
101         {\r
102             if (aButtonAct == ERemConCoreApiButtonClick)\r
103                 emit mediaKeyPressed(MediaKeysObserver::EFastRewindKey);\r
104             iCoreTarget->RewindResponse(status, KErrNone);\r
105             User::WaitForRequest(status);\r
106             break;\r
107         }\r
108     case ERemConCoreApiForward:\r
109         {\r
110             if (aButtonAct == ERemConCoreApiButtonClick)\r
111                 emit mediaKeyPressed(MediaKeysObserver::EForwardKey);\r
112             iCoreTarget->ForwardResponse(status, KErrNone);\r
113             User::WaitForRequest(status);\r
114             break;\r
115         }\r
116     case ERemConCoreApiVolumeUp:\r
117         {\r
118             if (aButtonAct == ERemConCoreApiButtonClick)\r
119                 emit mediaKeyPressed(MediaKeysObserver::EVolIncKey);\r
120             iCoreTarget->VolumeUpResponse(status, KErrNone);\r
121             User::WaitForRequest(status);\r
122 \r
123             break;\r
124         }\r
125     case ERemConCoreApiVolumeDown:\r
126         {\r
127             if (aButtonAct == ERemConCoreApiButtonClick)\r
128                 emit mediaKeyPressed(MediaKeysObserver::EVolDecKey);\r
129             iCoreTarget->VolumeDownResponse(status, KErrNone);\r
130             User::WaitForRequest(status);\r
131             break;\r
132         }\r
133     case ERemConCoreApiFastForward:\r
134         {\r
135             if (aButtonAct == ERemConCoreApiButtonClick)\r
136                 emit mediaKeyPressed(MediaKeysObserver::EFastForwardKey);\r
137             iCoreTarget->FastForwardResponse(status, KErrNone);\r
138             User::WaitForRequest(status);\r
139             break;\r
140         }\r
141     case ERemConCoreApiBackward:\r
142         {\r
143             if (aButtonAct == ERemConCoreApiButtonClick)\r
144                 emit mediaKeyPressed(MediaKeysObserver::EBackwardKey);\r
145             iCoreTarget->BackwardResponse(status, KErrNone);\r
146             User::WaitForRequest(status);\r
147             break;\r
148         }\r
149     default:\r
150         break;\r
151     }\r
152 }\r