This file is indexed.

/usr/lib/python2.7/dist-packages/Wammu/Settings.py is in wammu 0.40-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# -*- coding: UTF-8 -*-
#
# Copyright © 2003 - 2015 Michal Čihař <michal@cihar.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# vim: expandtab sw=4 ts=4 sts=4:
'''
Wammu - Phone manager
Settings dialog
'''

import wx
import wx.lib.rcsizer
from wx.lib.filebrowsebutton import FileBrowseButton
from wx.lib.masked.timectrl import TimeCtrl
import os
import sys
import Wammu
import Wammu.GammuSettings
import Wammu.PhoneWizard
from Wammu.Locales import ugettext as _


class Settings(wx.Dialog):
    def __init__(self, parent, config):
        wx.Dialog.__init__(self, parent, -1, _('Settings'), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # notebook
        self.notebook = wx.Notebook(self, -1)
        self.notebook_gammu = wx.Panel(self.notebook, -1)
        self.notebook_connection = wx.Panel(self.notebook, -1)
        self.notebook_messages = wx.Panel(self.notebook, -1)
        self.notebook_view = wx.Panel(self.notebook, -1)
        self.notebook_other = wx.Panel(self.notebook, -1)
        self.notebook_hacks = wx.Panel(self.notebook, -1)

        # main layout
        self.sizer = wx.lib.rcsizer.RowColSizer()

        self.sizer.AddGrowableCol(2)
        self.sizer.AddGrowableRow(1)

        self.sizer.AddSpacer(1, 1, pos=(0, 0))
        self.sizer.AddSpacer(1, 1, pos=(0, 4))

        self.sizer.Add(self.notebook, pos=(1, 1), colspan=3, flag=wx.EXPAND)

        self.sizer.Add(wx.StaticLine(self, -1), pos=(2, 1), colspan=3, flag=wx.EXPAND)

        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.button_sizer.Realize()

        self.sizer.Add(self.button_sizer, pos=(3, 1), colspan=3, flag=wx.ALIGN_RIGHT)

        self.sizer.AddSpacer(1, 1, pos=(4, 0), colspan=5)

        self.config = config
        self.gammu_config = config.gammu

        # gammu tab
        self.sizer_gammu = wx.lib.rcsizer.RowColSizer()

        self.sizer_gammu.AddGrowableCol(1)

        self.sizer_gammu.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        self.editcfgpath = FileBrowseButton(
            self.notebook_gammu,
            size=(250, -1),
            labelText='',
            initialValue=config.Read('/Gammu/Gammurc', False),
            toolTip=_('Please enter here path to gammu configuration file you want to use.'),
            changeCallback=self.OnConfigChange,
            fileMode=wx.OPEN
        )
        self.sizer_gammu.Add(wx.StaticText(self.notebook_gammu, -1, _('Gammurc path')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_gammu.Add(self.editcfgpath, pos=(r, 2), flag=wx.EXPAND)
        r += 1

        self.sizer_gammu.Add(wx.StaticText(self.notebook_gammu, -1, _('You can configure connection parameters on Connection tab.')), pos=(r, 1), colspan=2)
        r += 1

        self.sizer_gammu.AddSpacer(1, 1, pos=(r, 3))
        r += 1

        self.editauto = wx.CheckBox(self.notebook_gammu, -1, _('Automatically connect to phone on startup'))
        self.editauto.SetToolTipString(_('Whether you want application automatically connect to phone when it is started.'))
        self.editauto.SetValue(config.Read('/Wammu/AutoConnect') == 'yes')
        self.sizer_gammu.Add(self.editauto, pos=(r, 1), colspan=2)
        r += 1

        self.editdebug = wx.CheckBox(self.notebook_gammu, -1, _('Show debug log'))
        self.editdebug.SetToolTipString(_('Show debug information on error output.'))
        self.editdebug.SetValue(config.Read('/Debug/Show') == 'yes')
        self.sizer_gammu.Add(self.editdebug, pos=(r, 1), colspan=2)
        r += 1

        self.editsync = wx.CheckBox(self.notebook_gammu, -1, _('Synchronize time'))
        self.editsync.SetToolTipString(_('Synchronise time in phone with computer time while connecting.'))
        self.editsync.SetValue(config.ReadBool('/Gammu/SyncTime'))
        self.sizer_gammu.Add(self.editsync, pos=(r, 1), colspan=2)
        r += 1

        self.editinfo = wx.CheckBox(self.notebook_gammu, -1, _('Startup information'))
        self.editinfo.SetToolTipString(_('Display startup on phone (not supported by all models).'))
        self.editinfo.SetValue(config.ReadBool('/Gammu/StartInfo'))
        self.sizer_gammu.Add(self.editinfo, pos=(r, 1), colspan=2)
        r += 1

        if sys.platform != 'win32':
            # locking not available on windoze
            self.editlock = wx.CheckBox(self.notebook_gammu, -1, _('Lock device'))
            self.editlock.SetToolTipString(_('Whether to lock device in /var/lock. On some systems you might lack privileges to do so.'))
            self.editlock.SetValue(config.ReadBool('/Gammu/LockDevice'))
            self.sizer_gammu.Add(self.editlock, pos=(r, 1), colspan=2)
            r += 1

        self.sizer_gammu.AddSpacer(1, 1, pos=(r, 3))

        # size gammu tab
        self.notebook_gammu.SetAutoLayout(True)
        self.notebook_gammu.SetSizer(self.sizer_gammu)
        self.sizer_gammu.Fit(self.notebook_gammu)
        self.sizer_gammu.SetSizeHints(self.notebook_gammu)

        # connection tab
        self.sizer_connection = wx.lib.rcsizer.RowColSizer()

        self.sizer_connection.AddGrowableCol(1)

        self.sizer_connection.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        lst, choices = config.gammu.GetConfigList()
        self.editsection = wx.Choice(self.notebook_connection, choices=choices, size=(250, -1))
        section = config.ReadInt('/Gammu/Section')
        for i in range(len(lst)):
            if lst[i]['Id'] == section:
                self.editsection.SetSelection(i)
                break
        self.sizer_connection.Add(wx.StaticText(self.notebook_connection, -1, _('Phone connection')), pos=(r, 1), rowspan=2, flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_connection.Add(self.editsection, pos=(r, 2))
        self.Bind(wx.EVT_CHOICE, self.OnConnectionChange, self.editsection)
        r += 1

        self.addsection = wx.Button(self.notebook_connection, wx.ID_ADD)
        self.sizer_connection.Add(self.addsection, pos=(r, 2), flag=wx.EXPAND)
        r += 1

        self.sizer_connection.AddSpacer(1, 1, pos=(r, 3))
        r += 1

        self.editname = wx.TextCtrl(self.notebook_connection, -1, '', size=(250, -1))
        self.editname.SetToolTipString(_('Name for this configuration.'))
        self.sizer_connection.Add(wx.StaticText(self.notebook_connection, -1, _('Name')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_connection.Add(self.editname, pos=(r, 2))
        r += 1

        self.editdev = wx.ComboBox(self.notebook_connection, -1, '', choices=Wammu.Data.Devices, size=(150, -1))
        self.editdev.SetToolTipString(_('Device, where your phone is connected.'))
        self.sizer_connection.Add(wx.StaticText(self.notebook_connection, -1, _('Device')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_connection.Add(self.editdev, pos=(r, 2), flag=wx.ALIGN_RIGHT | wx.EXPAND)
        r += 1

        self.editconn = wx.ComboBox(self.notebook_connection, -1, '', choices=Wammu.Data.Connections, size=(150, -1))
        self.editconn.SetToolTipString(_('Connection which your phone understands, check Gammu documentation for connection details.'))
        self.sizer_connection.Add(wx.StaticText(self.notebook_connection, -1, _('Connection')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_connection.Add(self.editconn, pos=(r, 2), flag=wx.ALIGN_RIGHT | wx.EXPAND)
        r += 1

        self.editmodel = wx.ComboBox(self.notebook_connection, -1, '', choices=Wammu.Data.Models, size=(150, -1))
        self.editmodel.SetToolTipString(_('Phone model, you can usually keep here auto unless you have any problems.'))
        if self.editmodel.GetValue() == '':
            self.editmodel.SetValue('auto')
        self.sizer_connection.Add(wx.StaticText(self.notebook_connection, -1, _('Model')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_connection.Add(self.editmodel, pos=(r, 2), flag=wx.ALIGN_RIGHT | wx.EXPAND)
        r += 1

        # Initialise above fields
        self.OnConnectionChange()

        self.sizer_connection.AddSpacer(1, 1, pos=(r, 3))

        # size connection tab
        self.notebook_connection.SetAutoLayout(True)
        self.notebook_connection.SetSizer(self.sizer_connection)
        self.sizer_connection.Fit(self.notebook_connection)
        self.sizer_connection.SetSizeHints(self.notebook_connection)

        # messages tab
        self.sizer_messages = wx.lib.rcsizer.RowColSizer()

        self.sizer_messages.AddGrowableCol(1)

        self.sizer_messages.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        v = config.ReadInt('/Message/ScaleImage')
        self.editscale = wx.SpinCtrl(
            self.notebook_messages,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=1, max=20,
            initial=v,
            size=(150, -1)
        )
        self.editscale.SetToolTipString(_('Whether images in messages should be scaled when displayed. This is usually good idea as they are pretty small.'))
        self.sizer_messages.Add(wx.StaticText(self.notebook_messages, -1, _('Scale images')), pos=(r, 1))
        self.sizer_messages.Add(self.editscale, pos=(r, 2))
        r += 1

        self.editformat = wx.CheckBox(self.notebook_messages, -1, _('Attempt to reformat text'))
        self.editformat.SetToolTipString(_('If you get sometimes "compressed" messages likeTHIStext, you should be interested in this choice.'))
        self.editformat.SetValue(config.Read('/Message/Format') == 'yes')
        self.sizer_messages.Add(self.editformat, pos=(r, 1), colspan=2)
        r += 1

        # options for new message
        self.new_message_panel = wx.Panel(self.notebook_messages, -1)
        self.sizer_messages.Add(self.new_message_panel, pos=(r, 1), colspan=2, flag=wx.EXPAND)
        r += 1

        self.sizer_message_new = wx.StaticBoxSizer(wx.StaticBox(self.new_message_panel, -1, _('Default options for new message')), wx.HORIZONTAL)
        self.new_message_panel_2 = wx.Panel(self.new_message_panel, -1)
        self.sizer_message_new.Add(self.new_message_panel_2, 1, wx.EXPAND, 0)

        self.sizer_message_new_2 = wx.lib.rcsizer.RowColSizer()

        self.sizer_message_new_2.AddGrowableCol(1)

        r2 = 0

        self.editconcat = wx.CheckBox(self.new_message_panel_2, -1, _('Concatenated'))
        self.editconcat.SetToolTipString(_('Create concatenated message, what allows to send longer messages.'))
        self.editconcat.SetValue(config.Read('/Message/Concatenated') == 'yes')
        self.sizer_message_new_2.Add(self.editconcat, pos=(r2, 0), colspan=2)
        r2 += 1

        self.editunicode = wx.CheckBox(self.new_message_panel_2, -1, _('Create unicode message'))
        self.editunicode.SetToolTipString(_('Unicode messages can contain national and other special characters, check this if you use non latin-1 characters. Your messages will require more space, so you can write less characters into single message.'))
        self.editunicode.SetValue(config.Read('/Message/Unicode') == 'yes')
        self.sizer_message_new_2.Add(self.editunicode, pos=(r2, 0), colspan=2)
        r2 += 1

        self.editreport = wx.CheckBox(self.new_message_panel_2, -1, _('Request delivery report by default'))
        self.editreport.SetToolTipString(_('Check to request delivery report for message.'))
        self.editreport.SetValue(config.Read('/Message/DeliveryReport') == 'yes')
        self.sizer_message_new_2.Add(self.editreport, pos=(r2, 0), colspan=2)
        r2 += 1

        self.edit16bit = wx.CheckBox(self.new_message_panel_2, -1, _('Use 16bit Id'))
        self.edit16bit.SetToolTipString(_('Use 16 bit Id inside message. This is safe for most cases.'))
        self.edit16bit.SetValue(config.Read('/Message/16bitId') == 'yes')
        self.sizer_message_new_2.Add(self.edit16bit, pos=(r2, 0), colspan=2)
        r2 += 1

        self.new_message_panel_2.SetAutoLayout(True)
        self.new_message_panel_2.SetSizer(self.sizer_message_new_2)
        self.sizer_message_new_2.Fit(self.new_message_panel_2)
        self.sizer_message_new_2.SetSizeHints(self.new_message_panel_2)

        self.new_message_panel.SetAutoLayout(True)
        self.new_message_panel.SetSizer(self.sizer_message_new)
        self.sizer_message_new.Fit(self.new_message_panel)
        self.sizer_message_new.SetSizeHints(self.new_message_panel)

        self.sizer_messages.AddSpacer(1, 1, pos=(r, 3))

        # size messages tab
        self.notebook_messages.SetAutoLayout(True)
        self.notebook_messages.SetSizer(self.sizer_messages)
        self.sizer_messages.Fit(self.notebook_messages)
        self.sizer_messages.SetSizeHints(self.notebook_messages)

        # view tab
        self.sizer_view = wx.lib.rcsizer.RowColSizer()

        self.sizer_view.AddGrowableCol(1)

        self.sizer_view.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        v = config.Read('/Wammu/NameFormat')
        self.editnameformat = wx.Choice(
            self.notebook_view,
            choices=[
                _('Automatic'),
                _('Automatic starting with first name'),
                _('Automatic starting with last name'),
                _('Custom, use format string below')
            ],
            size=(250, -1)
        )
        if v == 'auto':
            self.editnameformat.SetSelection(0)
        elif v == 'auto-first-last':
            self.editnameformat.SetSelection(1)
        elif v == 'auto-last-first':
            self.editnameformat.SetSelection(2)
        elif v == 'custom':
            self.editnameformat.SetSelection(3)
        self.sizer_view.Add(wx.StaticText(self.notebook_view, -1, _('Name display format')), pos=(r, 1))
        self.sizer_view.Add(self.editnameformat, pos=(r, 2), flag=wx.EXPAND)
        self.Bind(wx.EVT_CHOICE, self.OnNameFormatChange, self.editnameformat)
        r += 1

        v = config.Read('/Wammu/NameFormatString')
        self.editnamestring = wx.ComboBox(self.notebook_view, -1, v, choices=[
            v,
            '%(FirstName)s %(LastName)s (%(Company)s)',
            '%(LastName)s, %(FirstName)s (%(Company)s)',
            '%(LastName)s, %(FirstName)s (%(NickName)s)',
            ])
        # l10n: The %s will be replaced by list of currently supported tags, %%(value)s should be kept intact (you can translate word value).
        self.editnamestring.SetToolTipString(
            _('Format string for name displaying. You can use %%(value)s format marks. Currently available values are: %s.') %
            'Name, FirstName, LastName, NickName, FormalName, Company'
        )
        self.sizer_view.Add(wx.StaticText(self.notebook_view, -1, _('Name format string')), pos=(r, 1), flag=wx.ALIGN_CENTER_VERTICAL)
        self.sizer_view.Add(self.editnamestring, pos=(r, 2), flag=wx.ALIGN_RIGHT | wx.EXPAND)
        r += 1

        self.sizer_view.AddSpacer(1, 1, pos=(r, 3))

        # size view tab
        self.notebook_view.SetAutoLayout(True)
        self.notebook_view.SetSizer(self.sizer_view)
        self.sizer_view.Fit(self.notebook_view)
        self.sizer_view.SetSizeHints(self.notebook_view)

        # other tab
        self.sizer_other = wx.lib.rcsizer.RowColSizer()

        self.sizer_other.AddGrowableCol(1)

        self.sizer_other.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        v = config.ReadInt('/Wammu/RefreshState')
        self.editrefresh = wx.SpinCtrl(
            self.notebook_other,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=0, max=10000000,
            initial=v,
            size=(150, -1)
        )
        self.editrefresh.SetToolTipString(_('How often refresh phone state in application status bar. Enter value in miliseconds, 0 to disable.'))
        self.sizer_other.Add(wx.StaticText(self.notebook_other, -1, _('Refresh phone state')), pos=(r, 1))
        self.sizer_other.Add(self.editrefresh, pos=(r, 2))
        r += 1

        self.editconfirm = wx.CheckBox(self.notebook_other, -1, _('Confirm deleting'))
        self.editconfirm.SetToolTipString(_('Whether to ask for confirmation when deleting entries.'))
        self.editconfirm.SetValue(config.Read('/Wammu/ConfirmDelete') == 'yes')
        self.sizer_other.Add(self.editconfirm, pos=(r, 1), colspan=2)
        r += 1

        self.taskbaricon = wx.CheckBox(self.notebook_other, -1, _('Task bar icon'))
        self.taskbaricon.SetToolTipString(_('Show icon in task bar.'))
        self.taskbaricon.SetValue(config.Read('/Wammu/TaskBarIcon') == 'yes')
        self.sizer_other.Add(self.taskbaricon, pos=(r, 1), colspan=2)
        r += 1

        dtime = config.Read('/Wammu/DefaultTime')
        try:
            times = dtime.split(':')
            th = int(times[0])
            tm = int(times[1])
            ts = int(times[2])
        except:
            th = 9
            tm = 0
            ts = 0
        self.edittime = TimeCtrl(self.notebook_other, -1, fmt24hr=True)
        Wammu.Utils.FixupMaskedEdit(self.edittime)
        self.edittime.SetValue(wx.DateTimeFromHMS(th, tm, ts))
        self.edittime.SetToolTipString(_('Default time to be used for newly created time fields.'))
        self.sizer_other.Add(wx.StaticText(self.notebook_other, -1, _('Default time')), pos=(r, 1))
        self.sizer_other.Add(self.edittime, pos=(r, 2))
        r += 1

        v = config.ReadInt('/Wammu/DefaultDateOffset')
        self.editdate = wx.SpinCtrl(
            self.notebook_other,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=-10000000, max=10000000,
            initial=v,
            size=(150, -1)
        )
        self.editdate.SetToolTipString(_('Default date to be used for newly created time fields. Enter amount of days from today (1=tommorow).'))
        self.sizer_other.Add(wx.StaticText(self.notebook_other, -1, _('Default date=now + x days')), pos=(r, 1))
        self.sizer_other.Add(self.editdate, pos=(r, 2))
        r += 1

        v = config.ReadInt('/Wammu/DefaultEntries')
        self.editentries = wx.SpinCtrl(
            self.notebook_other,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=0, max=20,
            initial=v,
            size=(150, -1)
        )
        self.editentries.SetToolTipString(_('How many entries will be shown in newly created item.'))
        self.sizer_other.Add(wx.StaticText(self.notebook_other, -1, _('Entries for new item')), pos=(r, 1))
        self.sizer_other.Add(self.editentries, pos=(r, 2))
        r += 1

        lst = ['Auto']
        lst += Wammu.Data.InternationalPrefixes
        self.editprefix = wx.ComboBox(self.notebook_other, -1, config.Read('/Wammu/PhonePrefix'), choices=lst, size=(150, -1))
        self.editprefix.SetToolTipString(_('Prefix for non international phone numbers.'))
        self.sizer_other.Add(wx.StaticText(self.notebook_other, -1, _('Number prefix')), pos=(r, 1))
        self.sizer_other.Add(self.editprefix, pos=(r, 2))
        r += 1

        self.sizer_other.AddSpacer(1, 1, pos=(r, 3))

        # size other tab
        self.notebook_other.SetAutoLayout(True)
        self.notebook_other.SetSizer(self.sizer_other)
        self.sizer_other.Fit(self.notebook_other)
        self.sizer_other.SetSizeHints(self.notebook_other)

        # hacks tab
        self.sizer_hacks = wx.lib.rcsizer.RowColSizer()

        self.sizer_hacks.AddGrowableCol(1)

        self.sizer_hacks.AddSpacer(1, 1, pos=(0, 0))
        r = 1

        v = config.ReadInt('/Hacks/MaxEmptyGuess')
        self.editmaxemptyguess = wx.SpinCtrl(
            self.notebook_hacks,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=0, max=10000000,
            initial=v,
            size=(150, -1)
        )
        self.editmaxemptyguess.SetToolTipString(_('Applies only when Wammu can not find proper count of entries to read. This number limits how many empty entries will be read before reading will be stopped.'))
        self.sizer_hacks.Add(wx.StaticText(self.notebook_hacks, -1, _('Maximal empty entries if total is guessed')), pos=(r, 1))
        self.sizer_hacks.Add(self.editmaxemptyguess, pos=(r, 2))
        r += 1

        v = config.ReadInt('/Hacks/MaxEmptyKnown')
        self.editmaxemptyknown = wx.SpinCtrl(
            self.notebook_hacks,
            -1,
            str(v),
            style=wx.SP_WRAP | wx.SP_ARROW_KEYS,
            min=0, max=10000000,
            initial=v,
            size=(150, -1)
        )
        self.editmaxemptyknown.SetToolTipString(_('In case phone reports wrongly number of entries, Wammu would try to read infinitely or till error. This number limits how many empty entries will be read before reading will be stopped.'))
        self.sizer_hacks.Add(wx.StaticText(self.notebook_hacks, -1, _('Maximal empty entries if total is known')), pos=(r, 1))
        self.sizer_hacks.Add(self.editmaxemptyknown, pos=(r, 2))
        r += 1

        self.sizer_hacks.AddSpacer(1, 1, pos=(r, 3))

        # size hacks tab
        self.notebook_hacks.SetAutoLayout(True)
        self.notebook_hacks.SetSizer(self.sizer_hacks)
        self.sizer_hacks.Fit(self.notebook_hacks)
        self.sizer_hacks.SetSizeHints(self.notebook_hacks)

        # add pages to notebook
        self.notebook.AddPage(self.notebook_gammu, _('Gammu'))
        self.notebook.AddPage(self.notebook_connection, _('Connection'))
        self.notebook.AddPage(self.notebook_messages, _('Messages'))
        self.notebook.AddPage(self.notebook_view, _('View'))
        self.notebook.AddPage(self.notebook_other, _('Other'))
        self.notebook.AddPage(self.notebook_hacks, _('Hacks'))

        # size main layout
        self.SetAutoLayout(True)
        self.SetSizer(self.sizer)
        self.sizer.Fit(self)
        self.sizer.SetSizeHints(self)

        # workaround, when sizers don't set correct size
        sz = self.GetSize()
        if sz.y < 150:
            self.SetSize((400, 400))

        # Intialise fields
        self.OnNameFormatChange()

        # event handlers
        self.Bind(wx.EVT_BUTTON, self.Okay, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.AddPhone, id=wx.ID_ADD)

    def OnNameFormatChange(self, evt=None):
        selection = self.editnameformat.GetSelection()
        if selection < 0:
            selection = 0
        if selection == 3:
            self.editnamestring.Enable(True)
        else:
            self.editnamestring.Enable(False)

    def OnConnectionChange(self, evt=None):
        selection = self.editsection.GetSelection()
        if selection < 0:
            selection = 0
        lst, choices = self.gammu_config.GetConfigList()
        if len(lst) == 0:
            self.editdev.Enable(False)
            self.editmodel.Enable(False)
            self.editname.Enable(False)
            self.editconn.Enable(False)
            return

        self.editdev.Enable(True)
        self.editmodel.Enable(True)
        self.editname.Enable(True)
        self.editconn.Enable(True)
        current = lst[selection]
        gammu = self.gammu_config.GetConfig(current['Id'])
        self.editdev.SetValue(gammu['Device'])
        self.editmodel.SetValue(gammu['Model'])
        self.editname.SetValue(gammu['Name'])
        self.editconn.SetValue(gammu['Connection'])

    def OnConfigChange(self, evt=None):
        # temporarily change gammu config data
        newpath = self.editcfgpath.GetValue()
        self.gammu_config = Wammu.GammuSettings.GammuSettings(self.config, os.path.expanduser(newpath))
        self.RereadConfig()

    def RereadConfig(self):
        lst, choices = self.gammu_config.GetConfigList()
        self.editsection.Clear()
        for x in choices:
            self.editsection.Append(x)
        if len(choices) > 0:
            self.editsection.SetSelection(0)
        self.OnConnectionChange()

    def AddPhone(self, evt=None):
        index = self.gammu_config.FirstFree()
        result = Wammu.PhoneWizard.RunConfigureWizard(self, index)
        if result is not None:
            self.gammu_config.SetConfig(result['Position'], result['Device'], result['Connection'], result['Name'])
            self.RereadConfig()
            lst, choices = self.gammu_config.GetConfigList()
            self.editsection.SetSelection(len(lst) - 1)
            self.OnConnectionChange()

    def Okay(self, evt):
        lst, choices = self.config.gammu.GetConfigList()

        # Check whether we have some configuration
        if len(lst) == 0:
            wx.MessageDialog(
                self,
                _('You don\'t have any phone connection configured. Wammu will not be able to conect to your phone!'),
                _('No phone configured!'),
                wx.OK | wx.ICON_ERROR
            ).ShowModal()
        else:
            current = lst[self.editsection.GetSelection()]
            self.config.gammu = self.gammu_config
            self.config.gammu.SetConfig(
                current['Id'],
                self.editdev.GetValue(),
                self.editconn.GetValue(),
                self.editname.GetValue(),
                self.editmodel.GetValue()
            )
            self.config.Write('/Gammu/Gammurc', self.editcfgpath.GetValue())
            self.config.WriteInt('/Gammu/Section', current['Id'])

        self.config.WriteBool('/Gammu/SyncTime', self.editsync.GetValue())
        if sys.platform != 'win32':
            self.config.WriteBool('/Gammu/LockDevice', self.editlock.GetValue())
        self.config.WriteBool('/Gammu/StartInfo', self.editinfo.GetValue())
        if self.editdebug.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Debug/Show', value)
        if self.editauto.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Wammu/AutoConnect', value)
        if self.editformat.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Message/Format', value)
        if self.editconcat.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Message/Concatenated', value)
        if self.editunicode.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Message/Unicode', value)
        if self.editreport.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Message/DeliveryReport', value)
        if self.edit16bit.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Message/16bitId', value)
        self.config.WriteInt('/Message/ScaleImage', self.editscale.GetValue())
        self.config.WriteInt('/Wammu/RefreshState', self.editrefresh.GetValue())
        if self.editconfirm.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('Wammu/ConfirmDelete', value)
        if self.taskbaricon.GetValue():
            value = 'yes'
        else:
            value = 'no'
        self.config.Write('/Wammu/TaskBarIcon', value)
        self.config.Write('Wammu/DefaultTime', self.edittime.GetValue())
        self.config.WriteInt('/Wammu/DefaultDateOffset', self.editdate.GetValue())
        self.config.WriteInt('/Wammu/DefaultEntries', self.editentries.GetValue())
        self.config.Write('/Wammu/PhonePrefix', self.editprefix.GetValue())
        self.config.Write('/Wammu/NameFormat', self.editnamestring.GetValue())
        ind = self.editnameformat.GetSelection()
        if ind == 0:
            val = 'auto'
        elif ind == 1:
            val = 'auto-first-last'
        elif ind == 2:
            val = 'auto-last-first'
        elif ind == 3:
            val = 'custom'
        else:
            raise Exception('Invalid NameFormatString id: %d' % ind)
        self.config.Write('/Wammu/NameFormat', val)

        self.config.WriteInt('/Hacks/MaxEmptyGuess', self.editmaxemptyguess.GetValue())
        self.config.WriteInt('/Hacks/MaxEmptyKnown', self.editmaxemptyknown.GetValue())
        self.EndModal(wx.ID_OK)