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
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <w32std.h>
|
|
20 |
#include <eikenv.h>
|
|
21 |
#include <apgtask.h>
|
|
22 |
#include <apgcli.h>
|
102
|
23 |
#include <e32property.h>
|
92
|
24 |
#include <hb/hbcore/hbdevicedialogsymbian.h>
|
|
25 |
#include <hb/hbcore/hbsymbianvariant.h>
|
102
|
26 |
#include <tspropertydefs.h>
|
107
|
27 |
#include <afactivitylauncher.h>
|
|
28 |
#include <homescreendomainpskeys.h>
|
92
|
29 |
#include "hsappkeyplugin.h"
|
|
30 |
|
107
|
31 |
_LIT(KHsActivactionUri, "appto://20022F35?activityname=HsIdleView");
|
|
32 |
_LIT(KAppLibActivactionUri, "appto://20022F35?activityname=AppLibMainView");
|
92
|
33 |
_LIT(KTsPluginName, "com.nokia.taskswitcher.tsdevicedialogplugin/1.0");
|
|
34 |
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CHsAppKeyPlugin::CHsAppKeyPlugin()
|
|
43 |
: iEikEnv( CEikonEnv::Static() )
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// Two-phased constructor.
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CHsAppKeyPlugin* CHsAppKeyPlugin::NewL()
|
|
52 |
{
|
|
53 |
CHsAppKeyPlugin* self = new (ELeave) CHsAppKeyPlugin;
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// C++ Destructor
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CHsAppKeyPlugin::~CHsAppKeyPlugin()
|
|
62 |
{
|
|
63 |
delete mDialog;
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// From MHbDeviceDialogObserver
|
|
68 |
//
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
void CHsAppKeyPlugin::DataReceived(CHbSymbianVariantMap& /*aData*/)
|
|
72 |
{
|
|
73 |
//no implementation required
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// From MHbDeviceDialogObserver
|
|
78 |
//
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
void CHsAppKeyPlugin::DeviceDialogClosed(TInt /*aCompletionCode*/)
|
|
82 |
{
|
|
83 |
delete mDialog;
|
|
84 |
mDialog = 0;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// From CSysapKeyHandlerPlugin
|
|
89 |
//
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
TKeyResponse CHsAppKeyPlugin::HandleKeyEventL( const TKeyEvent& aKeyEvent ,
|
|
93 |
TEventCode /*aType*/
|
|
94 |
)
|
|
95 |
{
|
|
96 |
TKeyResponse retVal(EKeyWasNotConsumed);
|
|
97 |
if (aKeyEvent.iCode == EKeyApplication0) {
|
|
98 |
if (iSecondEvent) {
|
|
99 |
if (aKeyEvent.iRepeats > 0)
|
|
100 |
HandleLongPressL();
|
|
101 |
else
|
|
102 |
HandleShortPressL();
|
|
103 |
retVal = EKeyWasConsumed;
|
|
104 |
}
|
|
105 |
iSecondEvent =!iSecondEvent;
|
|
106 |
}
|
|
107 |
return retVal;
|
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
// From CSysapKeyHandlerPlugin
|
|
112 |
//
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CHsAppKeyPlugin::ProvideKeyEventsL(RArray<TKeyEvent>& aKeyEventArray)
|
|
116 |
{
|
|
117 |
TKeyEvent key;
|
|
118 |
key.iCode = EKeyApplication0;
|
|
119 |
key.iScanCode = EStdKeyApplication0;
|
|
120 |
key.iModifiers = 0;
|
102
|
121 |
key.iRepeats = 0;
|
92
|
122 |
aKeyEventArray.Append(key);
|
102
|
123 |
|
|
124 |
TKeyEvent longkey;
|
|
125 |
longkey.iCode = EKeyApplication0;
|
|
126 |
longkey.iScanCode = EStdKeyApplication0;
|
|
127 |
longkey.iModifiers = 0;
|
|
128 |
longkey.iRepeats = 1;
|
|
129 |
aKeyEventArray.Append(longkey);
|
|
130 |
|
92
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
void CHsAppKeyPlugin::HandleShortPressL()
|
107
|
138 |
{
|
|
139 |
RApaLsSession apaLsSession;
|
|
140 |
CleanupClosePushL(apaLsSession);
|
|
141 |
User::LeaveIfError(apaLsSession.Connect());
|
|
142 |
CAfActivityLauncher *activityEnabler =
|
|
143 |
CAfActivityLauncher::NewLC(apaLsSession,
|
|
144 |
iEikEnv->WsSession());
|
|
145 |
TInt state(0);
|
|
146 |
RProperty::Get(KHsCategoryUid, KHsCategoryStateKey, state);
|
|
147 |
if (state == EHomeScreenIdleState) {
|
|
148 |
activityEnabler->launchActivityL(KAppLibActivactionUri);
|
|
149 |
} else {
|
|
150 |
activityEnabler->launchActivityL(KHsActivactionUri);
|
|
151 |
}
|
|
152 |
CleanupStack::PopAndDestroy(activityEnabler);
|
|
153 |
CleanupStack::PopAndDestroy(&apaLsSession);
|
92
|
154 |
delete mDialog;
|
|
155 |
mDialog =0;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CHsAppKeyPlugin::HandleLongPressL()
|
|
163 |
{
|
|
164 |
if( !mDialog ) {
|
102
|
165 |
TInt value( 0 );
|
|
166 |
RProperty::Get( TsProperty::KCategory,
|
|
167 |
TsProperty::KVisibilityKey,
|
|
168 |
value );
|
|
169 |
if(!value){
|
|
170 |
mDialog = CHbDeviceDialogSymbian::NewL();
|
|
171 |
|
|
172 |
CHbSymbianVariantMap* params = CHbSymbianVariantMap::NewL();
|
92
|
173 |
if(KErrNone != mDialog->Show(KTsPluginName,*params,this)) {
|
|
174 |
delete mDialog;
|
93
|
175 |
mDialog = 0;
|
102
|
176 |
}
|
|
177 |
delete params;
|
92
|
178 |
}
|
|
179 |
}
|
|
180 |
}
|
|
181 |
// End of File
|
|
182 |
|
|
183 |
|