1 /* |
|
2 * Copyright (c) 2006 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: Utility class for accessing sis-registry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <swi/sisregistryentry.h> |
|
21 #include <swi/sisregistrysession.h> |
|
22 #include <AknUtils.h> |
|
23 #include <SWInstApi.h> |
|
24 #include <swi/sisregistrypackage.h> |
|
25 #include <CUIDetailsDialog.h> |
|
26 #include <SWInstDefs.h> |
|
27 #include <StringLoader.h> |
|
28 #include <mseng.rsg> |
|
29 |
|
30 // USER INCLUDES |
|
31 #include "msengsisxinfo.h" |
|
32 #include "memscanutils.h" |
|
33 |
|
34 // constants |
|
35 _LIT( KDriveC, "C"); |
|
36 _LIT( KDriveZ, "Z"); |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CMsengSisxInfo::ConstructL |
|
42 // Symbian 2nd phase constructor can leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 void CMsengSisxInfo::ConstructL( Swi::RSisRegistryEntry& aEntry, TDriveNumber aDrive ) |
|
46 { |
|
47 TInt err; |
|
48 TChar driveLetter; |
|
49 RFs::DriveToChar(aDrive, driveLetter); |
|
50 driveLetter.UpperCase(); |
|
51 const TInt KDriveLength = 1; |
|
52 TBuf<KDriveLength> driveName; |
|
53 driveName.Append(driveLetter); |
|
54 |
|
55 TRAP(err, aEntry.FilesL(iFiles)); |
|
56 |
|
57 // Get the name of the app |
|
58 HBufC* packageName = aEntry.PackageNameL(); |
|
59 CleanupStack::PushL( packageName ); |
|
60 TParse parse; |
|
61 |
|
62 parse.SetNoWild( *packageName, NULL, NULL ); |
|
63 iFileName = parse.Name().AllocL(); |
|
64 CleanupStack::PopAndDestroy(packageName); |
|
65 TPtr tmpPtr2 = iFileName->Des(); |
|
66 TRACES( RDebug::Print( _L("CMsengSisxInfo::ConstructL - %S"), &tmpPtr2 ); ); |
|
67 |
|
68 // Get Location |
|
69 TChar selectedDrive( aEntry.SelectedDriveL() ); |
|
70 selectedDrive.UpperCase(); |
|
71 iRequestedLocation = EFalse; |
|
72 |
|
73 if( selectedDrive == driveLetter ) |
|
74 { |
|
75 // Phone memory |
|
76 iRequestedLocation = ETrue; |
|
77 } |
|
78 else |
|
79 { |
|
80 // Check the disk from files |
|
81 // if all have C, the software is installed to phone |
|
82 // else it is installed to memory card |
|
83 TInt count = iFiles.Count(); |
|
84 |
|
85 TInt allFilesInCZ = 0; |
|
86 for ( TInt index = 0; index < count; index++ ) |
|
87 { |
|
88 TPtrC firstChar = iFiles[index]->Des().Left(1); |
|
89 TRACES( RDebug::Print( _L("Checking location of %S"), iFiles[index]); ); |
|
90 |
|
91 if ( ( firstChar.CompareF( KDriveC ) == KErrNone ) || |
|
92 ( firstChar.CompareF( KDriveZ ) == KErrNone ) ) |
|
93 { |
|
94 allFilesInCZ++; |
|
95 } |
|
96 } |
|
97 |
|
98 if ( allFilesInCZ == count && (driveName.CompareF( KDriveC ) == KErrNone ) ) |
|
99 { |
|
100 // Phone memory |
|
101 iRequestedLocation = ETrue; |
|
102 } |
|
103 } |
|
104 |
|
105 TRACES( RDebug::Print( _L("Requested location %d"), iRequestedLocation); ); |
|
106 } |
|
107 |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMsengSisxInfo::NewL |
|
111 // Two-phased constructor. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 CMsengSisxInfo* CMsengSisxInfo::NewL( Swi::RSisRegistryEntry& aEntry, |
|
115 TDriveNumber aDrive ) |
|
116 { |
|
117 CMsengSisxInfo* self = new ( ELeave ) CMsengSisxInfo( ); |
|
118 CleanupStack::PushL( self ); |
|
119 self->ConstructL( aEntry, aDrive ); |
|
120 CleanupStack::Pop( self ); |
|
121 return self; |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMsengSisxInfo::~CMsengSisxInfo |
|
127 // Destructor. |
|
128 // ----------------------------------------------------------------------------- |
|
129 CMsengSisxInfo::~CMsengSisxInfo() |
|
130 { |
|
131 delete iFileName; |
|
132 iFiles.ResetAndDestroy(); |
|
133 iFiles.Close(); |
|
134 } |
|
135 |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CAppMngrSisxInfo::RequestedLocation |
|
139 // Get location of the application. |
|
140 // (other items were commented in a header). |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TBool CMsengSisxInfo::RequestedLocation() const |
|
144 { |
|
145 return iRequestedLocation; |
|
146 } |
|
147 |
|
148 |
|
149 // End of File |
|