|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Install freestyle MTM account. This exe is executed when |
|
15 * Nokia-Email SIS package is installed |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "emailtrace.h" |
|
22 #include <mtclreg.h> |
|
23 #include <data_caging_path_literals.hrh> // for KDC_MTM_INFO_FILE_DIR' |
|
24 #include <featurecontrol.h> |
|
25 #include <centralrepository.h> |
|
26 #include "FSEmailBuildFlags.h" |
|
27 |
|
28 |
|
29 #include "fsmtmsconstants.h" |
|
30 |
|
31 LOCAL_C TFileName InstallationFilenameL(); |
|
32 LOCAL_C void InstallL(); |
|
33 LOCAL_C void DefineFWflag(); |
|
34 LOCAL_C void DoInstallL(); |
|
35 |
|
36 |
|
37 |
|
38 // Dummy observer class to absorb Message Server session events |
|
39 class TDummyObserver : public MMsvSessionObserver |
|
40 { |
|
41 public: |
|
42 void HandleSessionEventL( TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, |
|
43 TAny* /*aArg2*/, TAny* /*aArg3*/) {}; |
|
44 }; |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // InstallationFilenameL |
|
48 // Finds mtm resource file name path |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 LOCAL_C TFileName InstallationFilenameL() |
|
52 { |
|
53 FUNC_LOG; |
|
54 //Construct the path information for the Installation file. |
|
55 TFileName fileName; |
|
56 RFs fs; |
|
57 User::LeaveIfError( fs.Connect() ); |
|
58 CleanupClosePushL( fs ); |
|
59 TFindFile finder( fs ); |
|
60 User::LeaveIfError( |
|
61 finder.FindByDir( KFsMtmDirAndFile, KDC_MTM_INFO_FILE_DIR ) ); |
|
62 fileName = finder.File(); |
|
63 CleanupStack::PopAndDestroy(); |
|
64 return fileName; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // InstallL |
|
69 // Set up Message Server session and install PushImap MTM group |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 LOCAL_C void InstallL() |
|
73 { |
|
74 FUNC_LOG; |
|
75 TDummyObserver ob; |
|
76 CMsvSession* session = CMsvSession::OpenSyncL( ob ); |
|
77 CleanupStack::PushL( session ); |
|
78 |
|
79 //Construct the path information for the Installation file. |
|
80 TFileName resourceFileName = InstallationFilenameL(); |
|
81 |
|
82 // Install MTMs. |
|
83 TInt err = session->InstallMtmGroup( resourceFileName ); |
|
84 if( err!=KErrNone && err!=KErrAlreadyExists ) |
|
85 { |
|
86 User::LeaveIfError( err ); |
|
87 } |
|
88 |
|
89 // Check if Installed MTM is present in Registry. |
|
90 CClientMtmRegistry* mtmRegistry = CClientMtmRegistry::NewL( *session ); |
|
91 CleanupStack::PushL( mtmRegistry ); |
|
92 if( !mtmRegistry->IsPresent( KUidMsgValTypeFsMtmVal ) ) |
|
93 { |
|
94 User::Leave(KErrNotFound); |
|
95 } |
|
96 CleanupStack::PopAndDestroy( mtmRegistry ); |
|
97 CleanupStack::PopAndDestroy( session ); |
|
98 |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // DefineFWflag |
|
103 // Framework flag will be defined to indicate the FW is installed by SIS |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 LOCAL_C void DefineFWflag() |
|
107 { |
|
108 FUNC_LOG; |
|
109 RFeatureControl featureControl; |
|
110 TInt err = featureControl.Connect(); |
|
111 if ( err == KErrNone ) |
|
112 { |
|
113 featureControl.Close(); |
|
114 } |
|
115 } |
|
116 |
|
117 |
|
118 LOCAL_C void SetUpCenrepParams() |
|
119 { |
|
120 FUNC_LOG; |
|
121 } |
|
122 |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // DoInstallL |
|
126 // Install the MTM |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 LOCAL_C void DoInstallL() |
|
130 { |
|
131 FUNC_LOG; |
|
132 |
|
133 User::LeaveIfError( User::RenameThread( _L("MtmInstall") ) ); |
|
134 // Define Framework Flag |
|
135 DefineFWflag(); |
|
136 SetUpCenrepParams(); |
|
137 // Construct and install the active scheduler |
|
138 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
139 CleanupStack::PushL(scheduler); |
|
140 CActiveScheduler::Install( scheduler ); |
|
141 TRAPD(error,InstallL()); |
|
142 if (error != KErrNone) |
|
143 { |
|
144 User::Leave(error); |
|
145 } |
|
146 CleanupStack::PopAndDestroy(scheduler); |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // E32Main |
|
152 // Called when FS SIS package is installed |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 GLDEF_C TInt E32Main() |
|
156 { |
|
157 FUNC_LOG; |
|
158 __UHEAP_MARK; |
|
159 |
|
160 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
161 TRAP_IGNORE(DoInstallL()); |
|
162 delete cleanup; |
|
163 |
|
164 __UHEAP_MARKEND; |
|
165 return 0; |
|
166 } |
|
167 |