|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include <apgtask.h> |
|
21 #include <eikenv.h> |
|
22 #include <eikappui.h> |
|
23 #include <eikapp.h> |
|
24 #include <eikdoc.h> |
|
25 #include <techview/eikmenup.h> |
|
26 |
|
27 #include <disableexitchecksapp.rsg> |
|
28 #include "DisableExitChecksApp.hrh" |
|
29 #include "DisableExitChecksApp.h" |
|
30 |
|
31 #include <eikstart.h> |
|
32 |
|
33 |
|
34 _LIT8(KETrue,"ETrue"); |
|
35 _LIT8(KEFalse,"EFalse"); |
|
36 const TInt KTestFailed = -667; //random test failure |
|
37 const TUid KUidDisableExitChecksApp = { 0x102857AF }; |
|
38 |
|
39 /** |
|
40 * constructL method that creates the AppView object |
|
41 * |
|
42 */ |
|
43 void CExampleAppUi::ConstructL() |
|
44 { |
|
45 BaseConstructL(); |
|
46 } |
|
47 |
|
48 /** |
|
49 * Destructor |
|
50 * |
|
51 */ |
|
52 CExampleAppUi::~CExampleAppUi() |
|
53 { |
|
54 } |
|
55 |
|
56 /** |
|
57 * Handles the Menu events |
|
58 * @param aCommand - command to be passed based on the menu item |
|
59 * selected by the user |
|
60 * |
|
61 */ |
|
62 void CExampleAppUi::HandleCommandL(TInt /*aCommand*/) |
|
63 { |
|
64 } |
|
65 |
|
66 /** |
|
67 * Processes the command line parameters |
|
68 * @param aCommandLine - command to be passed based on the menu item |
|
69 * selected by the user |
|
70 * |
|
71 * This function leaks intentionally some memory and examines the value of the trailing data |
|
72 * in aCommandLine (expected to be either ETrue or EFalse). According to this value CCoeEnv::DisableExitChecks() |
|
73 * is triggered in order to disable or not the exit checks at kernel resources. |
|
74 * |
|
75 */ |
|
76 TBool CExampleAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine) |
|
77 { |
|
78 CEikAppUi* aAppUI = new(ELeave) CExampleAppUi; //intentionally caused memory leak |
|
79 TPtrC8 tailEnd = aCommandLine.TailEnd(); |
|
80 if(tailEnd.Compare(KETrue) == 0) |
|
81 { |
|
82 RDebug::Print(_L("Disable shutdown checks")); |
|
83 iEikonEnv->DisableExitChecks(ETrue); |
|
84 } |
|
85 else if(tailEnd.Compare(KEFalse) == 0) |
|
86 { |
|
87 RDebug::Print(_L("Enable shutdown checks")); |
|
88 iEikonEnv->DisableExitChecks(EFalse); |
|
89 } |
|
90 else |
|
91 { |
|
92 RDebug::Print(_L("Bad arguments, failing test....")); |
|
93 RProcess().Terminate(KTestFailed); |
|
94 } |
|
95 Exit(); |
|
96 return ETrue; |
|
97 } |
|
98 |
|
99 /** |
|
100 * Constructor that constructs a new document. |
|
101 * @param aApp - The application instance that is creating the document. |
|
102 * |
|
103 */ |
|
104 CExampleDocument::CExampleDocument(CEikApplication& aApp) |
|
105 : CEikDocument(aApp) |
|
106 { |
|
107 } |
|
108 |
|
109 /** |
|
110 * Constructs the application UI |
|
111 * @return A partially-constructed application UI object. |
|
112 * |
|
113 */ |
|
114 CEikAppUi* CExampleDocument::CreateAppUiL() |
|
115 { |
|
116 return new(ELeave) CExampleAppUi; |
|
117 } |
|
118 |
|
119 /** |
|
120 * Gets the application specific UID. |
|
121 * @return - UID of the DisableExitChecksApp application |
|
122 * |
|
123 */ |
|
124 TUid CExampleApplication::AppDllUid() const |
|
125 { |
|
126 return KUidDisableExitChecksApp; |
|
127 } |
|
128 |
|
129 /** |
|
130 * Creates a document object for the application |
|
131 * @return pointer to the newly created document |
|
132 * |
|
133 */ |
|
134 CApaDocument* CExampleApplication::CreateDocumentL() |
|
135 { |
|
136 return new (ELeave) CExampleDocument(*this); |
|
137 } |
|
138 |
|
139 /** |
|
140 * Creates and returns the object of the application |
|
141 * @return pointer to the newly created application |
|
142 * |
|
143 */ |
|
144 LOCAL_C CApaApplication* NewApplication() |
|
145 { |
|
146 return new CExampleApplication; |
|
147 } |
|
148 |
|
149 /** |
|
150 * Entry point for the application |
|
151 * |
|
152 */ |
|
153 GLDEF_C TInt E32Main() |
|
154 { |
|
155 return EikStart::RunApplication(NewApplication); |
|
156 } |