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