|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 //Custom command to validate RTC and publish the result using Publish and Subscribe mechanism |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 @released |
|
20 */ |
|
21 |
|
22 #include "cmdvalidatertc.h" |
|
23 #include "ssmdebug.h" |
|
24 #include "ssmuiproviderdll.h" |
|
25 #include <e32property.h> |
|
26 |
|
27 CCustomCmdValidateRTC* CCustomCmdValidateRTC::NewL() |
|
28 { |
|
29 CCustomCmdValidateRTC* self = new (ELeave) CCustomCmdValidateRTC(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CCustomCmdValidateRTC::CCustomCmdValidateRTC() |
|
34 :CActive(EPriorityNormal) |
|
35 { |
|
36 CActiveScheduler::Add(this); |
|
37 } |
|
38 |
|
39 CCustomCmdValidateRTC::~CCustomCmdValidateRTC() |
|
40 { |
|
41 //Cancel the request if there is any |
|
42 ExecuteCancel(); |
|
43 } |
|
44 |
|
45 TInt CCustomCmdValidateRTC::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/) |
|
46 { |
|
47 iPckgValidateRtc = EFalse; |
|
48 |
|
49 //Connect RSsmRtcAdaptation |
|
50 return iSsmRtcAdaptation.Connect(); |
|
51 } |
|
52 |
|
53 void CCustomCmdValidateRTC::Close() |
|
54 { |
|
55 //Cancel the request if there is any |
|
56 ExecuteCancel(); |
|
57 |
|
58 //Close RSsmRtcAdaptation |
|
59 iSsmRtcAdaptation.Close(); |
|
60 } |
|
61 |
|
62 void CCustomCmdValidateRTC::Release() |
|
63 { |
|
64 delete this; |
|
65 } |
|
66 |
|
67 void CCustomCmdValidateRTC::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus) |
|
68 { |
|
69 //Set the user request to pending |
|
70 aStatus = KRequestPending; |
|
71 iExecuteRequest = &aStatus; |
|
72 |
|
73 //Request RTC adaptation to validate RTC |
|
74 iSsmRtcAdaptation.ValidateRtc(iPckgValidateRtc, iStatus); |
|
75 SetActive(); |
|
76 } |
|
77 |
|
78 void CCustomCmdValidateRTC::RunL() |
|
79 { |
|
80 TInt result = iStatus.Int(); |
|
81 if (KErrNone == result) |
|
82 { |
|
83 //Set the PS value for RTC validation |
|
84 result = RProperty::Set(CSsmUiSpecific::ValidateRTCPropertyCategory(), |
|
85 CSsmUiSpecific::ValidateRTCPropertyKey(), iPckgValidateRtc()); |
|
86 if(KErrNone != result) |
|
87 { |
|
88 DEBUGPRINT2A("Setting PS key value for Validating RTC custom cmd failed with error: %d", result); |
|
89 } |
|
90 } |
|
91 CompleteClientRequest(result); |
|
92 } |
|
93 |
|
94 void CCustomCmdValidateRTC::DoCancel() |
|
95 { |
|
96 //Cancel the request if there is any |
|
97 iSsmRtcAdaptation.Cancel(); |
|
98 } |
|
99 |
|
100 TInt CCustomCmdValidateRTC::RunError(TInt aError) |
|
101 { |
|
102 DEBUGPRINT2A("CCustomCmdValidateRTC::RunError received error: %d", aError); |
|
103 CompleteClientRequest(aError); |
|
104 |
|
105 // We've returned the error via the status so return KErrNone here. |
|
106 return KErrNone; |
|
107 } |
|
108 |
|
109 void CCustomCmdValidateRTC::ExecuteCancel() |
|
110 { |
|
111 Cancel(); |
|
112 CompleteClientRequest(KErrCancel); |
|
113 } |
|
114 |
|
115 void CCustomCmdValidateRTC::CompleteClientRequest(TInt aError) |
|
116 { |
|
117 if (iExecuteRequest) |
|
118 { |
|
119 //Complete the user request with the given completion code |
|
120 User::RequestComplete(iExecuteRequest, aError); |
|
121 |
|
122 //Reset iExecuteRequest |
|
123 iExecuteRequest = NULL; |
|
124 } |
|
125 } |