|
1 /* |
|
2 * Copyright (c) 2010 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: Family gets resolution and orientation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "hspsfamily.h" |
|
19 #include "hsps_builds_cfg.hrh" |
|
20 #include "hspsmanifest.h" |
|
21 #include <featmgr.h> |
|
22 |
|
23 |
|
24 _LIT8(KTch, "_tch"); |
|
25 const TInt KMaxFamilyLength( 20 ); |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // ChspsFamily::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 ChspsFamily* ChspsFamily::NewL() |
|
36 { |
|
37 ChspsFamily* self = new(ELeave) ChspsFamily(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // ChspsFamily::ChspsFamily |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 ChspsFamily::ChspsFamily() |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // ChspsFamily::ConstructL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void ChspsFamily::ConstructL() |
|
57 { |
|
58 |
|
59 User::LeaveIfError( iWsSession.Connect() ); |
|
60 |
|
61 iScreenDevice = new (ELeave) CWsScreenDevice( iWsSession ); |
|
62 |
|
63 User::LeaveIfError( iScreenDevice->Construct() ); |
|
64 |
|
65 } |
|
66 |
|
67 |
|
68 // ------------------------------------------------------------------------------ |
|
69 // ChspsFamily::~ChspsFamily |
|
70 // ------------------------------------------------------------------------------ |
|
71 ChspsFamily::~ChspsFamily() |
|
72 { |
|
73 |
|
74 delete iScreenDevice; |
|
75 iWsSession.Close(); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // ChspsFamily::GetFamilyString |
|
80 // ----------------------------------------------------------------------------- |
|
81 void ChspsFamily::GetFamilyString( |
|
82 TDes8& aFamily ) |
|
83 { |
|
84 // Append input with a prefix based on the active screen resolution |
|
85 TPixelsTwipsAndRotation sizeAndRotation; |
|
86 iScreenDevice->GetDefaultScreenSizeAndRotation( sizeAndRotation ); |
|
87 TSize resolution( sizeAndRotation.iPixelSize ); |
|
88 if( resolution.iWidth > resolution.iHeight ) |
|
89 { |
|
90 TInt temp = resolution.iHeight; |
|
91 resolution.iHeight = resolution.iWidth; |
|
92 resolution.iWidth = temp; |
|
93 } |
|
94 switch( resolution.iHeight ) |
|
95 { |
|
96 case 320: |
|
97 { |
|
98 if ( resolution.iWidth == 240 ) |
|
99 { |
|
100 aFamily.Append( KFamilyQvga ); |
|
101 } |
|
102 } |
|
103 break; |
|
104 case 640: |
|
105 { |
|
106 if( resolution.iWidth == 360 ) |
|
107 { |
|
108 aFamily.Append( KFamilyQhd ); |
|
109 } |
|
110 else if( resolution.iWidth == 480 ) |
|
111 { |
|
112 aFamily.Append( KFamilyVga ); |
|
113 } |
|
114 } |
|
115 break; |
|
116 |
|
117 default: |
|
118 break; |
|
119 } |
|
120 if( aFamily.Length() > 0 ) |
|
121 { |
|
122 aFamily.Append( KTch ); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // ChspsFamily::GetFamilyType |
|
128 // ----------------------------------------------------------------------------- |
|
129 ThspsFamily ChspsFamily::GetFamilyType( |
|
130 const TDesC8& aFamilyString ) |
|
131 { |
|
132 ThspsFamily family( EhspsFamilyUnknown ); |
|
133 |
|
134 if( aFamilyString == KFamilyQvga ) |
|
135 { |
|
136 family = EhspsFamilyQvga; |
|
137 } |
|
138 else if( aFamilyString == KFamilyQvga2 ) |
|
139 { |
|
140 family = EhspsFamilyQvga2; |
|
141 } |
|
142 else if( aFamilyString == KFamilyVga ) |
|
143 { |
|
144 family = EhspsFamilyVga; |
|
145 } |
|
146 else if( aFamilyString == KFamilyVga3 ) |
|
147 { |
|
148 family = EhspsFamilyVga3; |
|
149 } |
|
150 else if( aFamilyString == KFamilyQhd ) |
|
151 { |
|
152 family = EhspsFamilyQhd; |
|
153 } |
|
154 else if( aFamilyString == KFamilyQhd_tch ) |
|
155 { |
|
156 family = EhspsFamilyQhd_tch; |
|
157 } |
|
158 else if( aFamilyString == KFamilyVga_tch ) |
|
159 { |
|
160 family = EhspsFamilyVga_tch; |
|
161 } |
|
162 |
|
163 return family; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // ChspsFamily::GetFamilyType |
|
168 // ----------------------------------------------------------------------------- |
|
169 ThspsFamily ChspsFamily::GetFamilyType() |
|
170 { |
|
171 TBuf8<KMaxFamilyLength> familyString; |
|
172 GetFamilyString( familyString ); |
|
173 return GetFamilyType( familyString ); |
|
174 } |
|
175 |
|
176 |
|
177 |
|
178 // End of File |
|
179 |