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