92
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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: Main plugin class
|
116
|
15 |
*
|
92
|
16 |
*/
|
|
17 |
|
|
18 |
#include <w32std.h>
|
|
19 |
#include <eikenv.h>
|
|
20 |
#include <apgtask.h>
|
|
21 |
#include <apgcli.h>
|
102
|
22 |
#include <e32property.h>
|
92
|
23 |
#include <hb/hbcore/hbdevicedialogsymbian.h>
|
116
|
24 |
#include <hb/hbcore/hbsymbianvariant.h>
|
102
|
25 |
#include <tspropertydefs.h>
|
107
|
26 |
#include <afactivitylauncher.h>
|
|
27 |
#include <homescreendomainpskeys.h>
|
92
|
28 |
#include "hsappkeyplugin.h"
|
|
29 |
|
116
|
30 |
_LIT( KHsActivactionUri, "appto://20022F35?activityname=HsIdleView" );
|
|
31 |
_LIT( KAppLibActivactionUri, "appto://20022F35?activityname=AppLibMainView" );
|
127
|
32 |
_LIT( KHsHomeKeyPressedOnBackground, "appto://20022F35?activityname=HsHomeKeyPressedOnBackground" );
|
116
|
33 |
_LIT( KTsPluginName, "com.nokia.taskswitcher.tsdevicedialogplugin/1.0" );
|
92
|
34 |
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
116
|
39 |
//
|
92
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CHsAppKeyPlugin::CHsAppKeyPlugin()
|
116
|
43 |
: iEikEnv( CEikonEnv::Static() ) // codescanner::eikonenvstatic
|
|
44 |
{
|
|
45 |
}
|
92
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// Two-phased constructor.
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CHsAppKeyPlugin* CHsAppKeyPlugin::NewL()
|
116
|
52 |
{
|
|
53 |
CHsAppKeyPlugin* self = new ( ELeave ) CHsAppKeyPlugin;
|
92
|
54 |
return self;
|
116
|
55 |
}
|
|
56 |
|
92
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// C++ Destructor
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CHsAppKeyPlugin::~CHsAppKeyPlugin()
|
116
|
62 |
{
|
|
63 |
delete iDialog;
|
|
64 |
}
|
92
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// From MHbDeviceDialogObserver
|
116
|
68 |
//
|
92
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
116
|
71 |
void CHsAppKeyPlugin::DataReceived( CHbSymbianVariantMap& /*aData*/ )
|
|
72 |
{
|
92
|
73 |
//no implementation required
|
116
|
74 |
}
|
92
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// From MHbDeviceDialogObserver
|
116
|
78 |
//
|
92
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
116
|
81 |
void CHsAppKeyPlugin::DeviceDialogClosed( TInt /*aCompletionCode*/ )
|
|
82 |
{
|
|
83 |
delete iDialog;
|
|
84 |
iDialog = 0;
|
|
85 |
}
|
92
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// From CSysapKeyHandlerPlugin
|
116
|
89 |
//
|
92
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
//
|
116
|
92 |
TKeyResponse CHsAppKeyPlugin::HandleKeyEventL( const TKeyEvent& aKeyEvent,
|
|
93 |
TEventCode /*aType*/ )
|
|
94 |
{
|
|
95 |
TKeyResponse retVal( EKeyWasNotConsumed );
|
|
96 |
if ( aKeyEvent.iCode == EKeyApplication0 )
|
|
97 |
{
|
|
98 |
if ( aKeyEvent.iRepeats > 0 )
|
|
99 |
{
|
|
100 |
HandleLongPressL();
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
HandleShortPressL();
|
|
105 |
}
|
|
106 |
retVal = EKeyWasConsumed;
|
92
|
107 |
}
|
116
|
108 |
return retVal;
|
92
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
// From CSysapKeyHandlerPlugin
|
116
|
113 |
//
|
92
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
116
|
116 |
void CHsAppKeyPlugin::ProvideKeyEventsL( RArray<TKeyEvent>& aKeyEventArray ) // codescanner::LFunctionCantLeave
|
|
117 |
{
|
92
|
118 |
TKeyEvent key;
|
|
119 |
key.iCode = EKeyApplication0;
|
|
120 |
key.iScanCode = EStdKeyApplication0;
|
|
121 |
key.iModifiers = 0;
|
102
|
122 |
key.iRepeats = 0;
|
116
|
123 |
aKeyEventArray.Append( key );
|
|
124 |
|
102
|
125 |
TKeyEvent longkey;
|
|
126 |
longkey.iCode = EKeyApplication0;
|
|
127 |
longkey.iScanCode = EStdKeyApplication0;
|
|
128 |
longkey.iModifiers = 0;
|
|
129 |
longkey.iRepeats = 1;
|
116
|
130 |
aKeyEventArray.Append( longkey );
|
|
131 |
}
|
92
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
116
|
134 |
//
|
92
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
void CHsAppKeyPlugin::HandleShortPressL()
|
116
|
138 |
{
|
|
139 |
TInt value( 0 );
|
|
140 |
RProperty::Get( TsProperty::KCategory, TsProperty::KVisibilityKey, value );
|
|
141 |
if ( value )
|
|
142 |
{
|
112
|
143 |
// when Task Switcher dialog is visible, Appkey is used to dismiss it
|
116
|
144 |
DismissTaskSwitcher();
|
112
|
145 |
}
|
116
|
146 |
else
|
|
147 |
{
|
112
|
148 |
// when there is no Task Switcher dialog, Appkey is used to switch between Applib and HomeScreen
|
|
149 |
RApaLsSession apaLsSession;
|
116
|
150 |
CleanupClosePushL( apaLsSession );
|
|
151 |
User::LeaveIfError( apaLsSession.Connect() );
|
|
152 |
CAfActivityLauncher* activityEnabler =
|
|
153 |
CAfActivityLauncher::NewLC( apaLsSession,
|
|
154 |
iEikEnv->WsSession() );
|
|
155 |
TInt state( 0 );
|
|
156 |
RProperty::Get( KHsCategoryUid, KHsCategoryStateKey, state );
|
|
157 |
if ( state == EHomeScreenWidgetViewForeground )
|
|
158 |
{
|
|
159 |
activityEnabler->launchActivityL( KAppLibActivactionUri );
|
|
160 |
}
|
127
|
161 |
else if ( (state & EHomeScreenApplicationBackground) == EHomeScreenApplicationBackground)
|
|
162 |
{
|
|
163 |
activityEnabler->launchActivityL( KHsHomeKeyPressedOnBackground );
|
|
164 |
}
|
|
165 |
else
|
116
|
166 |
{
|
|
167 |
activityEnabler->launchActivityL( KHsActivactionUri );
|
127
|
168 |
}
|
116
|
169 |
CleanupStack::PopAndDestroy( activityEnabler );
|
|
170 |
CleanupStack::PopAndDestroy( &apaLsSession );
|
|
171 |
}
|
112
|
172 |
}
|
92
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
116
|
175 |
//
|
92
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CHsAppKeyPlugin::HandleLongPressL()
|
116
|
179 |
{
|
|
180 |
TInt tsVisible( 0 );
|
|
181 |
RProperty::Get( TsProperty::KCategory,
|
102
|
182 |
TsProperty::KVisibilityKey,
|
116
|
183 |
tsVisible );
|
|
184 |
if ( tsVisible )
|
|
185 |
{
|
|
186 |
DismissTaskSwitcher();
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
if ( !iDialog )
|
|
191 |
{
|
|
192 |
iDialog = CHbDeviceDialogSymbian::NewL();
|
102
|
193 |
CHbSymbianVariantMap* params = CHbSymbianVariantMap::NewL();
|
116
|
194 |
if ( KErrNone != iDialog->Show( KTsPluginName, *params, this ) )
|
|
195 |
{
|
|
196 |
delete iDialog;
|
|
197 |
iDialog = 0;
|
|
198 |
}
|
|
199 |
delete params;
|
102
|
200 |
}
|
92
|
201 |
}
|
|
202 |
}
|
|
203 |
|
116
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CHsAppKeyPlugin::DismissTaskSwitcher()
|
|
209 |
{
|
|
210 |
// @todo: remove notification through property when SharedDialog flag
|
|
211 |
// is implemented in Orbit.
|
|
212 |
if ( !iDialog )
|
|
213 |
{
|
|
214 |
// dismiss dialog launched from HomeScreen
|
|
215 |
User::LeaveIfError( RProperty::Set( TsProperty::KCategory, TsProperty::KDismissRequestKey, 1 ) );
|
|
216 |
}
|
|
217 |
else
|
|
218 |
{
|
|
219 |
// dismiss dialog launched by this plugin
|
|
220 |
delete iDialog;
|
|
221 |
iDialog = 0;
|
|
222 |
}
|
|
223 |
}
|