|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 #include "tsexternalactivationwatcher_p.h" |
|
18 #include "tsexternalactivationwatcher.h" |
|
19 |
|
20 const TUid KTaskswitcherCategory = { 0x2002677D }; |
|
21 const TUint KExternalActivationKey = 0x1; |
|
22 const TInt KTaskswitcherActivateFlag = 1; |
|
23 |
|
24 /*! |
|
25 \class TsExternalActivationWatcherPrivate |
|
26 \ingroup group_tsserviceplugin |
|
27 \brief Private implementation of external activation watcher. |
|
28 */ |
|
29 |
|
30 TsExternalActivationWatcherPrivate::TsExternalActivationWatcherPrivate(TsExternalActivationWatcher *parent) : CActive(CActive::EPriorityStandard), mParent(parent) |
|
31 { |
|
32 CActiveScheduler::Add(this); |
|
33 |
|
34 TInt err = RProperty::Define(KTaskswitcherCategory, KExternalActivationKey, RProperty::EInt); |
|
35 if (err == KErrNone || err == KErrAlreadyExists) { |
|
36 err = mProperty.Attach(KTaskswitcherCategory, KExternalActivationKey); |
|
37 } |
|
38 |
|
39 Q_ASSERT_X(err == KErrNone, "TsExternalActivationWatcherPrivate", qPrintable(QString("Cannot define/attach to activation watcher property %1").arg(err))); |
|
40 |
|
41 mProperty.Subscribe(iStatus); |
|
42 SetActive(); |
|
43 } |
|
44 |
|
45 TsExternalActivationWatcherPrivate::~TsExternalActivationWatcherPrivate() |
|
46 { |
|
47 Cancel(); |
|
48 mProperty.Close(); |
|
49 } |
|
50 |
|
51 void TsExternalActivationWatcherPrivate::ResetActivationFlag() |
|
52 { |
|
53 TInt value(0); |
|
54 mProperty.Set(value); |
|
55 } |
|
56 |
|
57 void TsExternalActivationWatcherPrivate::DoCancel() |
|
58 { |
|
59 mProperty.Cancel(); |
|
60 } |
|
61 |
|
62 void TsExternalActivationWatcherPrivate::RunL() |
|
63 { |
|
64 if (iStatus.Int() != KErrCancel) { |
|
65 |
|
66 if (CheckActivationFlag()) { |
|
67 ResetActivationFlag(); |
|
68 QT_TRYCATCH_LEAVING(emit mParent->activationRequested()); |
|
69 } |
|
70 mProperty.Subscribe(iStatus); |
|
71 SetActive(); |
|
72 } |
|
73 } |
|
74 |
|
75 bool TsExternalActivationWatcherPrivate::CheckActivationFlag() |
|
76 { |
|
77 TInt value(0); |
|
78 TInt result = mProperty.Get(value); |
|
79 return (result == KErrNone && value & KTaskswitcherActivateFlag); |
|
80 } |