def bluetooth_device_search_bluez(self): ''' Initiates searching for Bluetooth devices using PyBluez stack. ''' # read devices list if self.msgcallback is not None: self.msgcallback( _('Discovering Bluetooth devices using %s') % 'PyBluez') try: discovery = Wammu.BluezDiscovery.Discovery(self) discovery.find_devices() discovery.process_inquiry() if len(discovery.names_found ) == 0 and self.msgcallback is not None: self.msgcallback(_('No Bluetooth device found')) if self.msgcallback is not None: self.msgcallback( _('All Bluetooth devices discovered, connection tests still in progress…' )) except bluetooth.BluetoothError as txt: if self.msgcallback is not None: self.msgcallback( _('Could not access Bluetooth subsystem (%s)') % StrConv(txt))
def __set_properties(self): # begin wxGlade: TalkbackFeaturesDialog.__set_properties self.SetTitle(_("Select features")) self.feature_phonebook_checkbox.SetToolTipString(_("You can access name and phone number.")) self.feature_enhancedphonebook_checkbox.SetToolTipString( _("You have access to more phone numbers per entry or additional fields as email.") )
def __init_data(self): self.numberlist = [] self.optionslist = [] for item in self.contacts: numbers = [] texts = [] prefix = '' if item['Name'] != '': prefix = '%s: ' % item['Name'] for i in range(len(item['Entries'])): if Wammu.Utils.GetItemType(item['Entries'][i]['Type']) == 'phone': numbers.append(item['Entries'][i]['Value']) texts.append(StrConv('%s (%s)' % (item['Entries'][i]['Value'], item['Entries'][i]['Type']))) if len(numbers) == 0: continue for x in range(len(numbers)): self.numberlist.append(numbers[x]) self.optionslist.append(prefix + texts[x]) self.currentlist = Wammu.PhoneValidator.SplitNumbers(self.current) self.wildcard = '' self.wildcard += _('Contact list') + ' (*.contactlist)|*.contactlist|' self.wildcard += _('All files') + ' (*.*)|*.*'
def run(self): try: self.listed_device_search() self.bluetooth_device_search() i = 0 while len(self.threads) > 0: if self.threads[i].isAlive(): i += 1 else: if self.msgcallback is not None: self.msgcallback( _('Finished %s') % StrConv(self.threads[i].getName())) del self.threads[i] if i >= len(self.threads): i = 0 if self.msgcallback is not None: self.msgcallback( _('All finished, found %d phones') % len(self.list)) if self.callback is not None: self.callback(self.list) except: evt = Wammu.Events.ExceptionEvent(data=sys.exc_info()) wx.PostEvent(self.win, evt)
def SelectContact(parent, contactlist, index=False): ''' Dialog for selecting contact. ''' contactlist.sort(SortName) choices = [] for entry in contactlist: if entry['Name'] == '': choices.append(StrConv(entry['Number'])) else: choices.append(StrConv(entry['Name'])) dlg = wx.SingleChoiceDialog( parent, _('Select contact from below list'), _('Select contact'), choices, wx.CHOICEDLG_STYLE | wx.RESIZE_BORDER) if dlg.ShowModal() == wx.ID_OK and len(choices) > 0: result = dlg.GetSelection() if not index: result = contactlist[result]['Location'] else: result = -1 del dlg return result
def SelectContactNumber(parent, item): ''' Selects number of chosen contact. If it has single number, it returns it directly, otherwise user has to select which number to use. ''' numbers = [] texts = [] for i in range(len(item['Entries'])): if Wammu.Utils.GetItemType(item['Entries'][i]['Type']) == 'phone': numbers.append(item['Entries'][i]['Value']) texts.append( StrConv( '%s : %s' % (item['Entries'][i]['Type'], item['Entries'][i]['Value']))) if len(numbers) == 0: return None elif len(numbers) == 1: return numbers[0] dlg = wx.SingleChoiceDialog(parent, _('Select number for selected contact'), _('Select phone number'), texts, wx.CHOICEDLG_STYLE | wx.RESIZE_BORDER) if dlg.ShowModal() == wx.ID_OK: result = numbers[dlg.GetSelection()] else: result = None del dlg return result
def __init__(self, parent): Wammu.Wizard.InputPage.__init__(self, parent, _('Configuration done'), _('Thank you for configuring phone connection.'), parent.settings.GetName(), _('You can enter any name which you will use to identify your phone.') )
def GetDevicesUNIX(self): type = self.GetPortType() result = [] if type in ['serial', None]: self.AddDevs(result, '/dev/cua%d', UNX_DEVICES) self.AddDevs(result, '/dev/ttyS%d', UNX_DEVICES) self.AddDevs(result, '/dev/tts/%d', UNX_DEVICES) if type in ['btserial', None]: self.AddDevs(result, '/dev/rfcomm%d', UNX_DEVICES) if type in ['irdaserial', None]: self.AddDevs(result, '/dev/ircomm%d', UNX_DEVICES) if type in ['usbserial', 'dku', None]: self.AddDevs(result, '/dev/ttyACM%d', UNX_DEVICES) self.AddDevs(result, '/dev/ttyUSB%d', UNX_DEVICES) self.AddDevs(result, '/dev/usb/tts/%d', UNX_DEVICES) self.AddDevs(result, '/dev/usb/acm/%d', UNX_DEVICES) self.AddDevs(result, '/dev/input/ttyACM%d', UNX_DEVICES) if type in ['bluetooth', None]: result += self.GetBluezDevices() help = '' if type == 'serial': help = _('Enter device name of serial port.') elif type in ['btserial', 'irdaserial']: help = _('Enter device name of emulated serial port.') elif type == 'bluetooth': help = _('Enter Bluetooth address of your phone.') elif type in ['usbserial', 'dku']: help = _('Enter device name of USB port.') elif type in ['irda', 'dku']: help = _('You don\'t have to enter anything for this settings.') return result, help
def Load(self, evt=None): dlg = wx.FileDialog( self, _('Load contacts from file'), os.getcwd(), '', self.wildcard, wx.OPEN | wx.CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() try: newlist = [] data = file(path, 'r') for line in data: newlist.append(line.strip()) data.close() self.currentlist = newlist self.current_contacts.Set(newlist) except IOError: wx.MessageDialog( self, _('Selected file "%s" was not found, no data read.') % path, _('File not found!'), wx.OK | wx.ICON_ERROR ).ShowModal()
def SelectContactNumber(parent, item): ''' Selects number of chosen contact. If it has single number, it returns it directly, otherwise user has to select which number to use. ''' numbers = [] texts = [] for i in range(len(item['Entries'])): if Wammu.Utils.GetItemType(item['Entries'][i]['Type']) == 'phone': numbers.append(item['Entries'][i]['Value']) texts.append(StrConv('%s : %s' % ( item['Entries'][i]['Type'], item['Entries'][i]['Value']))) if len(numbers) == 0: return None elif len(numbers) == 1: return numbers[0] dlg = wx.SingleChoiceDialog( parent, _('Select number for selected contact'), _('Select phone number'), texts, wx.CHOICEDLG_STYLE | wx.RESIZE_BORDER) if dlg.ShowModal() == wx.ID_OK: result = numbers[dlg.GetSelection()] else: result = None del dlg return result
def SMSExport(parent, messages, contacts): # Select where to export dlg = wx.SingleChoiceDialog( parent, _('Where do you want to export emails created from your messages?'), _('Select export type'), [_('Mailbox file'), _('Maildir folder'), _('IMAP account')], wx.CHOICEDLG_STYLE | wx.RESIZE_BORDER ) if dlg.ShowModal() != wx.ID_OK: return idx = dlg.GetSelection() del dlg # Mailbox if idx == 0: SMSToMailbox(parent, messages, contacts) # Maildir elif idx == 1: SMSToMaildir(parent, messages, contacts) # IMAP elif idx == 2: SMSToIMAP(parent, messages, contacts) else: raise Exception('Not implemented export functionality!')
def Blocked(self, evt): if evt.GetDirection() and self.edit.GetValue() == '': wx.MessageDialog( self, _('You need to select device which will be used.'), _('No device selected!'), wx.OK | wx.ICON_ERROR).ShowModal() return True return False
def __init__(self, parent): Wammu.Wizard.InputPage.__init__( self, parent, _('Configuration done'), _('Thank you for configuring phone connection.'), parent.settings.GetName(), _('You can enter any name which you will use to identify your phone.' ))
def __init__(self, parent, cfg): ''' Creates window and initializes event handlers. ''' self.cfg = cfg if cfg.HasEntry('/Debug/X') and cfg.HasEntry('/Debug/Y'): pos = wx.Point( cfg.ReadInt('/Debug/X'), cfg.ReadInt('/Debug/Y')) else: pos = wx.DefaultPosition size = wx.Size( cfg.ReadInt('/Debug/Width'), cfg.ReadInt('/Debug/Height') ) wx.Frame.__init__( self, parent, -1, _('Wammu debug log'), pos, size, wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER ) self.txt = wx.TextCtrl( self, -1, _('Here will appear debug messages from Gammu...\n'), style=wx.TE_MULTILINE | wx.TE_READONLY ) self.txt.SetFont(wx.Font(9, wx.MODERN, wx.NORMAL, wx.NORMAL)) Wammu.Events.EVT_LOG(self, self.OnLog) wx.EVT_SIZE(self, self.OnSize) self.OnSize(None)
def __init_data(self): self.numberlist = [] self.optionslist = [] for item in self.contacts: numbers = [] texts = [] prefix = '' if item['Name'] != '': prefix = '%s: ' % item['Name'] for i in range(len(item['Entries'])): if Wammu.Utils.GetItemType( item['Entries'][i]['Type']) == 'phone': numbers.append(item['Entries'][i]['Value']) texts.append( StrConv('%s (%s)' % (item['Entries'][i]['Value'], item['Entries'][i]['Type']))) if len(numbers) == 0: continue for x in range(len(numbers)): self.numberlist.append(numbers[x]) self.optionslist.append(prefix + texts[x]) self.currentlist = Wammu.PhoneValidator.SplitNumbers(self.current) self.wildcard = '' self.wildcard += _('Contact list') + ' (*.contactlist)|*.contactlist|' self.wildcard += _('All files') + ' (*.*)|*.*'
def run(self): try: self.listed_device_search() self.bluetooth_device_search() i = 0 while len(self.threads) > 0: if self.threads[i].isAlive(): i += 1 else: if self.msgcallback is not None: self.msgcallback( _('Finished %s') % StrConv(self.threads[i].getName()) ) del self.threads[i] if i >= len(self.threads): i = 0 if self.msgcallback is not None: self.msgcallback( _('All finished, found %d phones') % len(self.list) ) if self.callback is not None: self.callback(self.list) except: evt = Wammu.Events.ExceptionEvent(data=sys.exc_info()) wx.PostEvent(self.win, evt)
def AddOBEX(self, names, connections, helps): names.append('obex') connections.append(_('OBEX and IrMC protocols')) if self.manufacturer in ['symbian', 'nokia']: helps.append(_('Standard access to filesystem. Not a good choice for Nokia if you want to access data.')) else: helps.append(_('Standard access to filesystem and sometimes also to phone data. Good choice for recent phones.'))
def AddAT(self, names, connections, helps): names.append('at') connections.append(_('AT based')) if self.manufacturer in ['symbian', 'nokia']: helps.append(_('This provides minimal access to phone features. It is recommended to use other connection type.')) else: helps.append(_('Good choice for most phones except Nokia and Symbian based. Provides access to most phone features.'))
def SMSExportXML(parent, messages, contacts): count = len(messages) wildcard = _('XML File') + ' (*.xml)|*.xml|' + _( 'All files') + ' (*.*)|*.*;*' exts = ['xml'] exts.append(None) dlg = wx.FileDialog(parent, _('Select XML file…'), os.getcwd(), "", wildcard, wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() ext = exts[dlg.GetFilterIndex()] # Add automatic extension if we know one and file does not # have any if (os.path.splitext(path)[1] == '' and ext is not None): path += '.' + ext parent.ShowProgress(_('Saving messages to XML')) try: f = file(path, 'w') f.write(XMLheader) f.write("<messages>\n") for i in range(count): if not parent.progress.Update(i * 100 / count): del parent.progress parent.SetStatusText(_('Export terminated')) return sms = messages[i] j = SearchNumber(contacts, sms['Number']) if j == -1: contact = sms['Number'] else: contact = contacts[j]['Name'] data = Wammu.SMSXML.SMSToXML(parent.cfg, sms, contact) f.write(data) f.write("</messages>\n") f.close() except IOError: wx.MessageDialog(parent, _('Creating of file %s failed, bailing out.') % path, _('Can not create file!'), wx.OK | wx.ICON_ERROR).ShowModal() del parent.progress parent.SetStatusText(_('Export terminated')) return parent.progress.Update(100) del parent.progress parent.SetStatusText( _('%(count)d messages exported to "%(path)s" (%(type)s)') % { 'count': count, 'path': path, 'type': _('mailbox') })
def __init__(self, parent, pg0, pg1, pg2): Wammu.Wizard.ChoicePage.__init__( self, parent, _('Configuration style'), _('Configuration style'), [ _('Guided configuration'), _('Automatically search for a phone'), _('Manual configuration'), ], [ _('You will be guided through configuration by phone connection type and vendor.'), _('Wizard will attempt to search phone on usual ports.'), _('You know what you are doing and know exact parameters you need for connecting to phone.'), ], [pg0, pg1, pg2], extratext=_('How do you want to configure your phone connection?'), ) self.info = wx.StaticText( self, -1, _('If you have no idea how to configure your phone connection, you can look at Gammu Phone Database for other users experiences:')) self.info.Wrap(400) self.sizer.Add(self.info, 0, wx.ALL, 5) self.link = wx.lib.hyperlink.HyperLinkCtrl( self, -1, 'http://%scihar.com/gammu/phonedb' % Wammu.Utils.GetWebsiteLang()) self.sizer.Add(self.link, 0, wx.ALL, 5)
def GenerateCurrent(self, select = 0): self.current.DeleteAllItems() for i in range(len(self.entry['SMSInfo']['Entries'])): found = False x = self.entry['SMSInfo']['Entries'][i] for p in SMSParts: if x['ID'] in p[2]: self.current.InsertImageStringItem(i, p[1], p[0]) found = True break if not found: self.current.InsertImageStringItem(i, _('Not supported id: %s') % x['ID'], -1) print 'Not supported id: %s' % x['ID'] count = self.current.GetItemCount() if count > 0: while select > count: select = select - 1 self.current.SetItemState(select, wx.LIST_STATE_FOCUSED | wx.LIST_STATE_SELECTED, wx.LIST_STATE_FOCUSED | wx.LIST_STATE_SELECTED) else: if hasattr(self, 'editor'): self.sizer.Detach(self.editor) self.editor.Destroy() del self.editor self.editor = wx.StaticText(self, -1, _('Create new message by adding part to left list...'), size = (-1, 150)) self.sizer.Add(self.editor, pos = (self.editorrow,1), flag = wx.EXPAND, span = wx.GBSpan(colspan = 7)) self.sizer.Layout()
def __init__(self, parent, contacts, current, *args, **kwds): self.contacts = contacts self.current = current kwds['style'] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER wx.Dialog.__init__(self, parent, *args, **kwds) self.__init_data() self.all_label = wx.StaticText(self, -1, _('Available contacts:')) self.all_contacts = wx.ListBox(self, -1, choices=self.optionslist, style=wx.LB_EXTENDED) self.add_button = wx.Button(self, wx.ID_ADD) self.delete_button = wx.Button(self, wx.ID_DELETE) self.current_label = wx.StaticText(self, -1, _('Current recipients:')) self.current_contacts = wx.ListBox(self, -1, choices=self.currentlist, style=wx.LB_EXTENDED) self.save_button = wx.Button(self, wx.ID_SAVEAS) # TODO: Load would be better self.load_button = wx.Button(self, wx.ID_OPEN) self.button_sizer = wx.StdDialogButtonSizer() self.button_sizer.AddButton(wx.Button(self, wx.ID_OK)) self.button_sizer.AddButton(wx.Button(self, wx.ID_CANCEL)) self.__set_properties() self.__do_layout() self.__bind_events()
def __init__(self, parent): ports, helptext = parent.settings.GetDevices() Wammu.Wizard.InputPage.__init__(self, parent, _('Phone Device'), _('Please enter device where phone is accessible') + ':', ports, helptext)
def __init__(self, parent, message, title, traceid=None, autolog=None, exception=None): wx.Dialog.__init__(self, parent, -1, title) sizer = wx.BoxSizer(wx.VERTICAL) textsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(textsizer, flag=wx.ALL, border=10) bitmap = wx.Bitmap(Wammu.Paths.MiscPath('error')) icon = wx.StaticBitmap(self, -1, bitmap, size=(bitmap.GetWidth(), bitmap.GetHeight())) textsizer.Add(icon, flag=wx.RIGHT, border=10) if exception is not None: message += '\n\n' message += exception if autolog is not None: message += '\n\n' message += (_( 'Debug log has been automatically saved to %s, you are strongly encouraged to include it in bugreport.' ) % autolog) msg = wx.TextCtrl(self, style=wx.TE_BESTWRAP | wx.TE_MULTILINE | wx.TE_READONLY | wx.BORDER_NONE, size=(500, 400)) msg.SetValue(message) msg.SetBackgroundColour(wx.SystemSettings.GetColour(4)) textsizer.Add(msg) buttonsizer = wx.StdDialogButtonSizer() buttonsizer.AddButton(wx.Button(self, wx.ID_OK)) if traceid is None: savebutton = wx.Button(self, -1, _('Save debug log...')) buttonsizer.SetCancelButton(savebutton) self.Bind(wx.EVT_BUTTON, self.OnSave, savebutton) else: self.traceid = traceid searchbutton = wx.Button(self, -1, _('Search for similar reports')) buttonsizer.SetCancelButton(searchbutton) self.Bind(wx.EVT_BUTTON, self.OnSearch, searchbutton) self.reportbutton = wx.Button(self, -1, _('Report bug')) buttonsizer.SetNegativeButton(self.reportbutton) self.Bind(wx.EVT_BUTTON, self.OnReport, self.reportbutton) buttonsizer.Realize() sizer.Add(buttonsizer, flag=wx.ALIGN_RIGHT | wx.ALL, border=10) sizer.Fit(self) self.SetAutoLayout(True) self.SetSizer(sizer)
def OnClick(self, evt): if subprocess.call('which timidity') != 0: wx.MessageDialog( self, _('Could not find timidity, melody can not be played'), _('Timidity not found'), wx.OK | wx.ICON_ERROR).ShowModal() return f = os.popen('timidity -', 'w') thread.start_new_thread(gammu.SaveRingtone, (f, self.ringtone, "mid"))
def __set_properties(self): # begin wxGlade: TalkbackFeaturesDialog.__set_properties self.SetTitle(_("Select features")) self.feature_phonebook_checkbox.SetToolTipString( _("You can access name and phone number.")) self.feature_enhancedphonebook_checkbox.SetToolTipString( _("You have access to more phone numbers per entry or additional fields as email." ))
def Blocked(self, evt): if evt.GetDirection() and self.edit.GetValue() == '': wx.MessageDialog(self, _('You need to select device which will be used.'), _('No device selected!'), wx.OK | wx.ICON_ERROR).ShowModal() return True return False
def __init__(self, parent): Wammu.Wizard.TextPage.__init__(self, parent, _('Phone search'), _('Phone searching status') + ':') self.Bind(Wammu.Events.EVT_DONE, self.OnDone) self.Bind(Wammu.Events.EVT_TEXT, self.OnText) self.Bind(Wammu.Events.EVT_SHOW_MESSAGE, self.OnShowMessage) self.results = [] self.thread = None
def AddNokia(self, names, connections, helps): names.append('fbus') connections.append(_('Nokia proprietary protocol')) helps.append(_('Nokia proprietary protocol FBUS.')) if self.connection == 'serial': names.append('mbus') connections.append(_('Nokia proprietary service protocol')) helps.append(_('Nokia proprietary protocol MBUS. Older version, use FBUS if possible.'))
def __init__(self, parent, cfg, values, entry): if entry == {}: location = '' else: location = '%d' % entry['Location'] GenericEditor.__init__(self, parent, cfg, values, entry, 'calendar', _('calendar event'), location, 'Type', _('Event type'), Wammu.Data.CalendarTypes, Wammu.Data.CalendarValueTypes)
def GetContactText(self, val): if val < 1: return _('None') else: l = Wammu.Utils.SearchLocation(self.values['contact']['ME'], val) if l == -1: return _('Unknown') else: return self.values['contact']['ME'][l]['Name']
def __init__(self, parent): Wammu.Wizard.MultiInputPage.__init__( self, parent, _('Manual configuration'), [ _('Device where phone is connected') + ':', _('Connection type') + ':', ], [ parent.settings.GetDevices()[0], Wammu.Data.Connections, ])
def __init__(self, parent, cfg, values, entry): if entry == {}: location = '' else: location = '%d' % entry['Location'] GenericEditor.__init__(self, parent, cfg, values, entry, 'todo', _('todo item'), location, 'Priority', _('Priority'), Wammu.Data.TodoPriorities, Wammu.Data.TodoValueTypes)
def Cancel(self, evt): # FIXME: we should abort searching here if self.thread is not None and self.thread.isAlive(): wx.MessageDialog( self, _('Phone search is still active, you can not continue.'), _('Searching still active!'), wx.OK | wx.ICON_ERROR).ShowModal() return False return True
def __init__(self, parent): ports, helptext = parent.settings.GetDevices() Wammu.Wizard.InputPage.__init__( self, parent, _('Phone Device'), _('Please enter device where phone is accessible') + ':', ports, helptext )
def __init__(self, parent, cfg, values, entry): if entry == {}: location = '' else: location = '%s:%d' % (entry['MemoryType'], entry['Location']) GenericEditor.__init__(self, parent, cfg, values, entry, 'contact', _('contact'), location, 'MemoryType', _('Memory type'), Wammu.Data.ContactMemoryTypes, Wammu.Data.MemoryValueTypes)
def OnClick(self, evt): if commands.getstatusoutput('which timidity')[0] != 0: wx.MessageDialog(self, _('Could not find timidity, melody can not be played'), _('Timidity not found'), wx.OK | wx.ICON_ERROR).ShowModal() return f = os.popen('timidity -', 'w') thread.start_new_thread(gammu.SaveRingtone, (f, self.ringtone, "mid"))
def __init__(self, parent): self.names, connections, helps = parent.settings.GetManufacturers() Wammu.Wizard.ChoicePage.__init__(self, parent, _('Phone type'), _('Phone type'), connections, helps, extratext = _('Please select phone manufacturer or type. Try to be as specific as possible.'), )
def Cancel(self, evt): # FIXME: we should abort searching here if self.thread is not None and self.thread.isAlive(): wx.MessageDialog(self, _('Phone search is still active, you can not continue.'), _('Searching still active!'), wx.OK | wx.ICON_ERROR).ShowModal() return False return True
def __init__(self, parent): self.names, connections, helps = parent.settings.GetDrivers() Wammu.Wizard.ChoicePage.__init__(self, parent, _('Connection type'), _('Connection type'), connections, helps, extratext = _('Please select connection type, default choice should be best in most cases.') )
def __init__(self, parent): self.names, connections, helps = parent.settings.GetManufacturers() Wammu.Wizard.ChoicePage.__init__( self, parent, _('Phone type'), _('Phone type'), connections, helps, extratext=_('Please select phone manufacturer or type. Try to be as specific as possible.'), )
def AddNokia(self, names, connections, helps): names.append('fbus') connections.append(_('Nokia proprietary protocol')) helps.append(_('Nokia proprietary protocol FBUS.')) if self.connection == 'serial': names.append('mbus') connections.append(_('Nokia proprietary service protocol')) helps.append( _('Nokia proprietary protocol MBUS. Older version, use FBUS if possible.' ))
def __init__(self, parent): Wammu.Wizard.SimplePage.__init__(self, parent, _('Connection test')) self.detail = wx.StaticText( self, -1, _('Wammu is now testing phone connection, please wait...')) self.detail.Wrap(400) self.sizer.Add(self.detail, 0, wx.ALL, 5) self.name = '' self.thread = None self.Bind(Wammu.Events.EVT_DATA, self.OnSearchEnd)
def usage(): ''' Shows program usage. ''' version() print _('Usage: %s [OPTION...]' % os.path.basename(__file__)) print print _('Options:') print '%-20s ... %s' % ( '-h/--help', _('show this help') ) print '%-20s ... %s' % ( '-v/--version', _('show program version') ) print '%-20s ... %s' % ( '-l/--local-locales', _('force using of locales from current directory rather than system ones') ) print '%-20s ... %s' % ( '-i/--info', _('prints connection settings and tries to connect the phone') ) print '%-20s ... %s' % ( '-d/--debug', _('enables debug output to stderr') ) print
def AddAT(self, names, connections, helps): names.append('at') connections.append(_('AT based')) if self.manufacturer in ['symbian', 'nokia']: helps.append( _('This provides minimal access to phone features. It is recommended to use other connection type.' )) else: helps.append( _('Good choice for most phones except Nokia and Symbian based. Provides access to most phone features.' ))
def Canceled(self): lck = threading.Lock() lck.acquire() evt = Wammu.Events.ShowMessageEvent( message = _('Action canceled by user!'), title = _('Action canceled'), type = wx.ICON_WARNING, lock = lck) wx.PostEvent(self.win, evt) lck.acquire() self.ShowProgress(100)
def __init__(self, parent): Wammu.Wizard.MultiInputPage.__init__(self, parent, _('Manual configuration'), [ _('Device where phone is connected') + ':', _('Connection type') + ':', ], [ parent.settings.GetDevices()[0], Wammu.Data.Connections, ])
def Run(): ''' Wrapper to execute Wammu. Installs graphical error handler and launches WammuApp. ''' try: sys.excepthook = Wammu.Error.Handler except: print _('Failed to set exception handler.') app = WammuApp() app.MainLoop()
def SMSToMailbox(parent, messages, contacts): count = len(messages) wildcard = _('Mailboxes') + ' (*.mbox)|*.mbox|' + _('All files') + ' (*.*)|*.*;*' exts = ['mbox'] exts.append(None) dlg = wx.FileDialog(parent, _('Select mailbox file…'), os.getcwd(), "", wildcard, wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() ext = exts[dlg.GetFilterIndex()] # Add automatic extension if we know one and file does not # have any if (os.path.splitext(path)[1] == '' and ext is not None): path += '.' + ext parent.ShowProgress(_('Saving messages to mailbox')) try: f = file(path, 'w') for i in range(count): if not parent.progress.Update(i * 100 / count): del parent.progress parent.SetStatusText(_('Export terminated')) return sms = messages[i] filename, data, unused_msgid = Wammu.MailWriter.SMSToMail(parent.cfg, sms, contacts, True) f.write(data) f.write('\n') f.write('\n') f.close() except IOError: wx.MessageDialog( parent, _('Creating of file %s failed, bailing out.') % path, _('Can not create file!'), wx.OK | wx.ICON_ERROR ).ShowModal() del parent.progress parent.SetStatusText(_('Export terminated')) return parent.progress.Update(100) del parent.progress parent.SetStatusText( _('%(count)d messages exported to "%(path)s" (%(type)s)') % { 'count': count, 'path': path, 'type': _('mailbox') } )
def __init__(self, parent): self.names, connections, helps = parent.settings.GetDrivers() Wammu.Wizard.ChoicePage.__init__( self, parent, _('Connection type'), _('Connection type'), connections, helps, extratext=_('Please select connection type, default choice should be best in most cases.') )
def SMSToMailbox(parent, messages, contacts): count = len(messages) wildcard = _('Mailboxes') + ' (*.mbox)|*.mbox|' + _('All files') + ' (*.*)|*.*;*' exts = ['mbox'] exts.append(None) dlg = wx.FileDialog(parent, _('Select mailbox file...'), os.getcwd(), "", wildcard, wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() ext = exts[dlg.GetFilterIndex()] # Add automatic extension if we know one and file does not # have any if (os.path.splitext(path)[1] == '' and ext is not None): path += '.' + ext parent.ShowProgress(_('Saving messages to mailbox')) try: f = file(path, 'w') for i in range(count): if not parent.progress.Update(i * 100 / count): del parent.progress parent.SetStatusText(_('Export terminated')) return sms = messages[i] filename, data, unused_msgid = Wammu.MailWriter.SMSToMail(parent.cfg, sms, contacts, True) f.write(data) f.write('\n') f.write('\n') f.close() except IOError: wx.MessageDialog( parent, _('Creating of file %s failed, bailing out.') % path, _('Can not create file!'), wx.OK | wx.ICON_ERROR ).ShowModal() del parent.progress parent.SetStatusText(_('Export terminated')) return parent.progress.Update(100) del parent.progress parent.SetStatusText( _('%(count)d messages exported to "%(path)s" (%(type)s)') % { 'count': count, 'path': path, 'type': _('mailbox') } )
def Canceled(self): lck = threading.Lock() lck.acquire() evt = Wammu.Events.ShowMessageEvent( message=_('Action canceled by user!'), title=_('Action canceled'), type=wx.ICON_WARNING, lock=lck) wx.PostEvent(self.win, evt) lck.acquire() self.ShowProgress(100)
def __init__(self, parent, message, title, traceid=None, autolog=None, exception=None): wx.Dialog.__init__(self, parent, -1, title) sizer = wx.BoxSizer(wx.VERTICAL) textsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(textsizer, flag=wx.ALL, border=10) bitmap = wx.Bitmap(Wammu.Paths.MiscPath('error')) icon = wx.StaticBitmap( self, -1, bitmap, size=(bitmap.GetWidth(), bitmap.GetHeight()) ) textsizer.Add(icon, flag=wx.RIGHT, border=10) if exception is not None: message += '\n\n' message += exception if autolog is not None: message += '\n\n' message += ( _('Debug log has been automatically saved to %s, you are strongly encouraged to include it in bugreport.') % autolog) msg = wx.TextCtrl(self, style=wx.TE_BESTWRAP|wx.TE_MULTILINE|wx.TE_READONLY|wx.BORDER_NONE, size=(500, 400)) msg.SetValue(message) msg.SetBackgroundColour(wx.SystemSettings.GetColour(4)) textsizer.Add(msg) buttonsizer = wx.StdDialogButtonSizer() buttonsizer.AddButton(wx.Button(self, wx.ID_OK)) if traceid is None: savebutton = wx.Button(self, -1, _('Save debug log...')) buttonsizer.SetCancelButton(savebutton) self.Bind(wx.EVT_BUTTON, self.OnSave, savebutton) else: self.traceid = traceid searchbutton = wx.Button(self, -1, _('Search for similar reports')) buttonsizer.SetCancelButton(searchbutton) self.Bind(wx.EVT_BUTTON, self.OnSearch, searchbutton) self.reportbutton = wx.Button(self, -1, _('Report bug')) buttonsizer.SetNegativeButton(self.reportbutton) self.Bind(wx.EVT_BUTTON, self.OnReport, self.reportbutton) buttonsizer.Realize() sizer.Add(buttonsizer, flag=wx.ALIGN_RIGHT | wx.ALL, border=10) sizer.Fit(self) self.SetAutoLayout(True) self.SetSizer(sizer)