Package phones :: Module com_samsungschu470
[hide private]
[frames] | no frames]

Source Code for Module phones.com_samsungschu470

  1  ### BITPIM 
  2  ### 
  3  ### Copyright (C) 2006 Joe Pham <djpham@bitpim.org> 
  4  ### 
  5  ### This program is free software; you can redistribute it and/or modify 
  6  ### it under the terms of the BitPim license as detailed in the LICENSE file. 
  7  ### 
  8  ### $Id: com_samsungschu470.py 4777 2010-01-07 03:24:27Z djpham $ 
  9   
 10  """Communicate with the Samsung SCH-U470 (Juke) Phone""" 
 11   
 12  import common 
 13  import com_samsungschu740 as u740 
 14  import p_samsungschu470 as p_u470 
 15  import helpids 
 16   
 17  parentphone=u740.Phone 
18 -class Phone(parentphone):
19 desc='SCH-U470' 20 helpid=helpids.ID_PHONE_SAMSUNGSCHU470 21 protocolclass=p_u470 22 serialsname='schu470' 23 24 ringtone_noring_range='range_tones_preloaded_el_no_rings' 25 ringtone_default_range='range_tones_preloaded_el_01' 26 builtin_ringtones={ 27 'VZW Default Tone': ringtone_default_range, 28 'Bell 1': 'range_tones_preloaded_el_02', 29 'Bell 2': 'range_tones_preloaded_el_03', 30 'Bell 3': 'range_tones_preloaded_el_04', 31 'Melody 1': 'range_tones_preloaded_el_05', 32 'Melody 2': 'range_tones_preloaded_el_06', 33 'Melody 3': 'range_tones_preloaded_el_07', 34 'Melody 4': 'range_tones_preloaded_el_08', 35 'Melody 5': 'range_tones_preloaded_el_09', 36 'Melody 6': 'range_tones_preloaded_el_10', 37 'Beep Once': 'range_tones_preloaded_el_11', 38 'No Ring': ringtone_noring_range, 39 } 40 # can we use Sounds as ringtones? 41 builtin_sounds={} 42 ## builtin_sounds={ 43 ## 'Clapping': 'range_sound_preloaded_el_clapping', 44 ## 'Crowd Roar': 'range_sound_preloaded_el_crowed_roar', 45 ## 'Happy Birthday': 'range_sound_preloaded_el_birthday', 46 ## 'Rainforest': 'range_sound_preloaded_el_rainforest', 47 ## 'Train': 'range_sound_preloaded_el_train', 48 ## # same as ringtones ?? 49 ## 'Sound Beep Once': 'range_sound_preloaded_el_beep_once', 50 ## 'Sound No Ring': 'range_sound_preloaded_el_no_rings', 51 ## } 52 builtin_wallpapers={ 53 'Preloaded1': 'range_f_wallpaper_preloaded_el_01', 54 'Preloaded2': 'range_f_wallpaper_preloaded_el_02', 55 'Preloaded3': 'range_f_wallpaper_preloaded_el_03', 56 'Preloaded4': 'range_f_wallpaper_preloaded_el_04', 57 'Preloaded5': 'range_f_wallpaper_preloaded_el_05', 58 } 59 builtin_groups={ 60 1: 'Business', 61 2: 'Colleague', 62 3: 'Family', 63 4: 'Friends' 64 } 65 66 my_model='SCH-U470/Juke' 67 my_manufacturer='SAMSUNG' 68 detected_model='U470' 69
70 - def __init__(self, logtarget, commport):
71 "Calls all the constructors and sets initial modes" 72 parentphone.__init__(self, logtarget, commport) 73 global PBEntry 74 self.pbentryclass=PBEntry
75
76 - def _read_ringtone_range(self, fundamentals):
77 fundamentals['ringtone-range']={}
78
79 - def get_ringtone_range(self, name, fundamentals):
80 if not name: 81 # return No Rings 82 return self.ringtone_default_range 83 # check the builtin ringtones 84 if self.builtin_ringtones.has_key(name): 85 return self.builtin_ringtones[name] 86 if self.builtin_sounds.has_key(name): 87 return self.builtin_sounds[name] 88 # check for custom ringtones, 89 # this model does not use ranges for custom ringtones, just straight 90 # file names instead. 91 _rt_index=fundamentals.get('ringtone-index', {}) 92 for _entry in _rt_index.values(): 93 if _entry['name']==name: 94 _filename=_entry.get('filename', None) 95 if _filename: 96 return '/ff/'+_filename
97
98 - def ringtone_name_from_range(self, range, fundamentals):
99 # check for builtin ringtones 100 for _key,_value in self.builtin_ringtones.items(): 101 if range==_value: 102 return _key 103 # check for builtin sounds 104 for _key,_value in self.builtin_sounds.items(): 105 if range==_value: 106 return _key 107 # now check for the "custom" ones 108 # Again, this model does not use ringtone ranges, just filename 109 if range.startswith('/ff/'): 110 return common.basename(range)
111 112 # Wallpaper stuff-----------------------------------------------------------
113 - def _get_file_wallpaper_index(self, idx, result, 114 path, origin):
115 for _filename in self.listfiles(path): 116 result[idx]={ 'name': self.basename(_filename), 117 'filename': _filename, 118 'origin': origin } 119 idx+=1 120 return idx
121
122 - def get_wallpaper_index(self):
123 _res={} 124 _idx=self._get_builtin_wallpaper_index(0, _res) 125 _idx=self._get_file_wallpaper_index(_idx, _res, 126 self.protocolclass.PIC_PATH, 127 'images') 128 return _res
129
130 - def savewallpapers(self, fundamentals, merge):
131 # send wallpapers to the phone 132 """Save wallpapers to the phone""" 133 self.log('Writing wallpapers to the phone') 134 try: 135 _del_list, _new_list=self._get_del_new_list('wallpaper-index', 136 'wallpapers', 137 merge, 138 fundamentals, 139 frozenset(['video'])) 140 if __debug__: 141 self.log('Delete list: '+','.join(_del_list)) 142 self.log('New list: '+','.join(_new_list)) 143 self._add_files('wallpaper-index', 'wallpapers', 144 _new_list, fundamentals) 145 fundamentals['rebootphone']=True 146 except: 147 if __debug__: 148 raise 149 return fundamentals
150 151 # CalendarEntry class----------------------------------------------------------- 152 parentcalendarentry=u740.CalendarEntry
153 -class CalendarEntry(parentcalendarentry):
154 pass
155 156 # PBEntry class----------------------------------------------------------------- 157 parentpbentry=u740.PBEntry
158 -class PBEntry(parentpbentry):
159
160 - def _extract_ringtone(self, entry, p_class):
161 if self.pb.has_ringtone and \ 162 self.pb.ringtone: 163 if self.pb.ringtone.startswith('/ff/'): 164 # user's ringtone 165 _ringtone=common.basename(self.pb.ringtone) 166 else: 167 # built-in ringtone 168 _ringtone=self.phone.ringtone_name_from_range( 169 self.pb.ringtone, self.fundamentals) 170 if _ringtone: 171 entry['ringtones']=[{ 'ringtone': _ringtone, 172 'use': 'call' }]
173
174 - def getvalue(self):
175 _entry=parentpbentry.getvalue(self) 176 self._extract_ringtone(_entry, self.phone.protocolclass) 177 return _entry
178 179 # Profile class----------------------------------------------------------------- 180 parentprofile=u740.Profile
181 -class Profile(parentprofile):
182 serialsname=Phone.serialsname 183 WALLPAPER_WIDTH=176 184 WALLPAPER_HEIGHT=220 185 autodetect_delay=3 186 usbids=( ( 0x04e8, 0x6640, 2),) 187 deviceclasses=("serial",) 188 BP_Calendar_Version=3 189 # For phone detection 190 phone_manufacturer=Phone.my_manufacturer 191 phone_model=Phone.my_model 192 193 # our targets are the same for all origins 194 imagetargets={} 195 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "wallpaper", 196 {'width': 128, 'height': 164, 'format': "JPEG"})) 197 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "pictureid", 198 {'width': 112, 'height': 84, 'format': "JPEG"})) 199 imagetargets.update(common.getkv(parentprofile.stockimagetargets, "fullscreen", 200 {'width': 128, 'height': 220, 'format': "JPEG"})) 201 imageorigins={} 202 imageorigins.update(common.getkv(parentprofile.stockimageorigins, "images"))
203