1 /* |
|
2 * Copyright (c) 2002-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: This file contains the implementation of CUIUtils |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <bautils.h> |
|
22 #include <coemain.h> |
|
23 |
|
24 #include "CUIUtils.h" |
|
25 |
|
26 using namespace SwiUI::CommonUI; |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CCUIUtils::LoadResourceFileL |
|
32 // Load the given resource file. |
|
33 // (other items were commented in a header). |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C TInt CUIUtils::LoadResourceFileL( const TDesC& aFileName, CCoeEnv* aCoeEnv ) |
|
37 { |
|
38 TFileName file; |
|
39 // If user gives full path let's use it. |
|
40 if ( TParsePtrC( aFileName ).DrivePresent() ) |
|
41 { |
|
42 file.Zero(); |
|
43 file.Append( aFileName ); |
|
44 } |
|
45 else |
|
46 { |
|
47 // get dll path, this returns ComminUIs path. |
|
48 Dll::FileName( file ); |
|
49 TDriveName drive( TParsePtrC( file ).Drive( ) ); // solve drive |
|
50 file.Zero(); |
|
51 file.Append( drive ); |
|
52 file.Append( aFileName ); |
|
53 } |
|
54 // Get the rsc file path. Note this function does return Z: drive |
|
55 // if drive lietter is not give. It do not scan user drives: C,E,D etc. |
|
56 BaflUtils::NearestLanguageFile( aCoeEnv->FsSession(), file ); |
|
57 |
|
58 return aCoeEnv->AddResourceFileL( file ); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CCUIUtils::ConstructVersionString |
|
63 // Construct a string representation of given version. |
|
64 // (other items were commented in a header). |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C HBufC* CUIUtils::ConstructVersionStringLC( TInt aMajor, TInt aMinor, TInt aBuild ) |
|
68 { |
|
69 // Sanity check |
|
70 if ( aMajor < 0 ) |
|
71 { |
|
72 aMajor = 0; |
|
73 } |
|
74 if ( aMinor < 0 ) |
|
75 { |
|
76 aMinor = 0; |
|
77 } |
|
78 if ( aBuild < 0 ) |
|
79 { |
|
80 aBuild = 0; |
|
81 } |
|
82 |
|
83 // First calculate the number of digits in version numbers |
|
84 TInt result( 0 ); |
|
85 TInt majorDigits( 1 ); |
|
86 TInt minorDigits( 1 ); |
|
87 TInt buildDigits( 1 ); |
|
88 |
|
89 result = aMajor / 10; |
|
90 while ( result > 0 ) |
|
91 { |
|
92 result = result / 10; |
|
93 majorDigits++; |
|
94 } |
|
95 |
|
96 result = aMinor / 10; |
|
97 while ( result > 0 ) |
|
98 { |
|
99 result = result / 10; |
|
100 minorDigits++; |
|
101 } |
|
102 |
|
103 result = aBuild / 10; |
|
104 while ( result > 0 ) |
|
105 { |
|
106 result = result / 10; |
|
107 buildDigits++; |
|
108 } |
|
109 |
|
110 // Now we can construct the actual version descriptor |
|
111 |
|
112 HBufC* tmp = HBufC::NewLC( majorDigits + minorDigits + buildDigits + 4 ); // . + possible 0 and brackets |
|
113 TPtr tmpBuf( tmp->Des() ); |
|
114 |
|
115 //tmpBuf.Append( ' ' ); |
|
116 tmpBuf.AppendNum( aMajor ); |
|
117 tmpBuf.Append( '.' ); |
|
118 if ( aMinor < 10 ) |
|
119 { |
|
120 tmpBuf.Append('0'); |
|
121 } |
|
122 |
|
123 tmpBuf.AppendNum( aMinor ); |
|
124 |
|
125 tmpBuf.Append( '(' ); |
|
126 tmpBuf.AppendNum( aBuild ); |
|
127 tmpBuf.Append( ')' ); |
|
128 |
|
129 return tmp; |
|
130 } |
|
131 |
|
132 // End of File |
|
133 |
|
134 |
|
135 |
|