0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 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:
|
|
15 |
#
|
|
16 |
|
|
17 |
import os
|
|
18 |
|
|
19 |
def get_fixed_target_path(feature, setting):
|
|
20 |
type_ref = setting + '_type'
|
|
21 |
type = feature.get_feature(type_ref)
|
|
22 |
type_value = type.get_value()
|
|
23 |
ret = ""
|
|
24 |
if type_value == '1':
|
|
25 |
None
|
|
26 |
elif type_value == '2':
|
|
27 |
icon = feature.get_feature(setting + '_icon')
|
|
28 |
if icon != None:
|
|
29 |
ret = get_fixed_icon_target(icon)
|
|
30 |
else:
|
|
31 |
None
|
|
32 |
|
|
33 |
return ret
|
|
34 |
|
|
35 |
def get_fixed_icon_target(icon):
|
|
36 |
targetPath = icon.get_feature('targetPath').get_value()
|
|
37 |
localPath = icon.get_feature('localPath').get_value()
|
|
38 |
target = get_target_without_extension(targetPath)
|
|
39 |
extension = get_correct_extension(localPath)
|
|
40 |
fixed = ""
|
|
41 |
if extension != None:
|
|
42 |
if len(target) > 0 and len(extension) > 0:
|
|
43 |
fixed = target + extension
|
|
44 |
return fixed
|
|
45 |
|
|
46 |
def get_target_without_extension(targetPath):
|
|
47 |
(target,_) = os.path.splitext(targetPath)
|
|
48 |
return target
|
|
49 |
|
|
50 |
def get_correct_extension(localPath):
|
|
51 |
|
|
52 |
if localPath != None:
|
|
53 |
(_,extension) = os.path.splitext(localPath)
|
|
54 |
if extension == '.bmp':
|
|
55 |
return '.mbm'
|
|
56 |
elif extension == '.svg':
|
|
57 |
return '.mif'
|
|
58 |
else:
|
|
59 |
return extension
|
|
60 |
else:
|
|
61 |
return None
|
|
62 |
|
|
63 |
def get_shortcut_string(feature, setting):
|
|
64 |
type_ref = setting + '_type'
|
|
65 |
type_value = feature.get_feature(type_ref).get_value()
|
|
66 |
ret = ""
|
|
67 |
if type_value == '1':
|
|
68 |
app_ref = setting + '_app'
|
|
69 |
application = feature.get_feature(app_ref).get_value()
|
|
70 |
ret = application
|
|
71 |
elif type_value == '2':
|
|
72 |
url = feature.get_feature(setting+'_URL').get_value()
|
|
73 |
title = feature.get_feature(setting+'_title').get_value()
|
|
74 |
|
|
75 |
if title == None:
|
|
76 |
title = ""
|
|
77 |
else:
|
|
78 |
title = 'customtitle=' + title
|
|
79 |
|
|
80 |
icon = feature.get_feature(setting + '_icon')
|
|
81 |
image_path = icon.get_feature('targetPath').get_value()
|
|
82 |
|
|
83 |
icon_str = ""
|
|
84 |
|
|
85 |
if image_path != None and image_path != "":
|
|
86 |
icon_str = 'iconmifpath='
|
|
87 |
if image_path.endswith('.mif'): index = '16384'
|
|
88 |
else: index = '0'
|
|
89 |
icon_str = icon_str + image_path + ';' + index + '&'
|
|
90 |
|
|
91 |
ret = url + '?custom?' + icon_str + title
|
|
92 |
return ret
|
|
93 |
|
|
94 |
#print get_shortcut_string('1', '2', '3')
|
|
95 |
#http://www.nokia2.com?custom?iconmifpath=Z:\\resource\\apps\\icon2.mbm;1&customtitle=Nokia2
|