|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Implementation of AlfThemeManagerUtil class, the class |
|
15 * which is an interface to the ThemeManager component |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "alf/alfthememanagerutil.h" |
|
20 |
|
21 |
|
22 #include "tm/themeitemmapper.h" |
|
23 #include "tm/thememanager.h" |
|
24 #include "tm/themeexception.h" |
|
25 using namespace Alf; |
|
26 |
|
27 #include <UTF.h> |
|
28 |
|
29 namespace Alf |
|
30 { |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 OSN_EXPORT AlfThemeManagerUtil::AlfThemeManagerUtil() |
|
37 { |
|
38 mThemeManager=NULL; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // Destructor |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 OSN_EXPORT AlfThemeManagerUtil::~AlfThemeManagerUtil() |
|
46 { |
|
47 if(mThemeManager) |
|
48 { |
|
49 ThemeManager::deleteThemeManager(); |
|
50 mThemeManager = NULL; |
|
51 } |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Get Skin Image parameters. Given the logical name this method returns the skinid. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 OSN_EXPORT TAknsItemID AlfThemeManagerUtil::getSkinId(const Utf8* aSkinLogicalName) |
|
59 { |
|
60 |
|
61 TAknsItemID skinid; |
|
62 skinid.Set(0,0); |
|
63 |
|
64 // Create ThemeManager instance |
|
65 if(!mThemeManager) |
|
66 { |
|
67 mThemeManager = ThemeManager::createThemeManager(); |
|
68 } |
|
69 |
|
70 // Query ThemeManager for an ItemMapper interface |
|
71 IThemeItemMapper* itemMapper=NULL; |
|
72 // Get Image data |
|
73 ThemeItemDef item; |
|
74 |
|
75 try |
|
76 { |
|
77 mThemeManager->getItemMapperInterface(&itemMapper); |
|
78 UString alfSkinLogicalname(aSkinLogicalName); |
|
79 if(itemMapper) |
|
80 { |
|
81 item= itemMapper->findItem(alfSkinLogicalname); |
|
82 } |
|
83 } |
|
84 catch(ThemeException& ex) |
|
85 { |
|
86 if(itemMapper) |
|
87 mThemeManager->releaseItemMapperInterface(); |
|
88 throw ex; |
|
89 } |
|
90 |
|
91 skinid.iMajor= item.getMajorId(); |
|
92 skinid.iMinor= item.getMinorId(); |
|
93 |
|
94 // Done with ItemMapper interface, release it |
|
95 if(itemMapper) |
|
96 mThemeManager->releaseItemMapperInterface(); |
|
97 return skinid; |
|
98 } |
|
99 |
|
100 } |