import widgets
playlist_key='playlist'
masterlist_key='masterlist'
playlists_list='playlists'
mp3_type='mp3'
wma_type='wma'
playlist_type=(mp3_type, wma_type)
class MasterListDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({ 'masterlist': ['name'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, (list, tuple)):
            return
        self.update({'masterlist': [{ 'name': x } for x in data] })
masterlistobjectfactory=database.dataobjectfactory(MasterListDataObject)
class PlaylistDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'playlist': ['name'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, (list, tuple)):
            return
        self.update({'playlist': [{'name': x} for x in data]})
playlistobjectfactory=database.dataobjectfactory(PlaylistDataObject)
class PlaylistEntryDataObject(database.basedataobject):
    _knownproperties=['type']
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({ 'songs': ['name']})
    def __init__(self, data=None):
        if data is None or not isinstance(data, PlaylistEntry):
	def OnDataSendPhoneGotFundamentals(self, data, todo, exception, results):

        if exception!=None:

            if not self.silent:

                self.mw.HandleException(exception)

            self.log("Auto Sync: Failed, Exception getting phone fundementals")

            self.mw.OnBusyEnd()

            return

        data.update(results)

        self.log("Auto Sync: Sending results to phone")

        self.mw.MakeCall(gui.Request(self.mw.wt.senddata, data, todo),
                      gui.Callback(self.OnDataSendCalenderResults))

	def OnDataSendCalenderResults(self, exception, results):

        if exception!=None:

            if not self.silent:

                self.mw.HandleException(exception)

            self.log("Auto Sync: Failed, Exception writing calender to phone")

            self.mw.OnBusyEnd()

            return

        if self.silent==0:

            wx.MessageBox('Phone Synchronized OK',
                          'Synchronize Complete', wx.OK)

        self.log("Auto Sync: Synchronize Completed OK")

        self.mw.OnBusyEnd()

	def sync(self, mw, silent, profile="Default Autosync"):

        self.silent=silent

        self.mw=mw

        if mw.config.ReadInt("SafeMode", False):

            self.log("Auto Sync: Disabled, BitPim in safe mode")

            return 0

        if wx.IsBusy():

            self.log("Auto Sync: Failed, BitPim busy")

            return 0

        self.log("Auto Sync: Starting (silent mode=%d)..." % (silent))

        self.mw.OnBusyStart()

        self.mw.GetStatusBar().progressminor(0, 100, 'AutoSync in progress ...')

        self.settings=_getsettings(mw, profile)

        res=self.importcalenderdata()

        if res==1:

            res=self.sendcalendertophone()

        else:

            self.mw.OnBusyEnd()

            if silent==0:

                wx.MessageBox('Unable to synchronize phone schedule',
                              'Synchronize failed', wx.OK)

            self.log("Auto Sync: Failed, Unable to synchronize phone schedule")

        return res


class  AutoSyncSettingsobject (database.basedataobject) :
	_knownproperties=['caltype', 'calender_id', 'sync_on_connect', 'sync_frequency', \
                      'start_offset', 'end_offset', 'no_alarm', 'rpt_events', 'categories', \
                      'ringtone', 'vibrate', 'alarm_override', 'alarm_value']
	    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
	    def __init__(self, data=None):

        if data is None or not isinstance(data, AutoSyncSettingsEntry):

            return;

        self.update(data.get_db_dict())

autosyncsettingsobjectfactory=database.dataobjectfactory(AutoSyncSettingsobject)
class  AutoSyncSettingsEntry (object) :
	_caltype_key='caltype'
	    _calender_id_key='calender_id'
	    _sync_on_connect_key='sync_on_connect'
	    _sync_frequency_key='sync_frequency'
	    def __init__(self):

        self._data={ 'serials': [] }

	def __eq__(self, rhs):

        return self.caltype==rhs.caltype and self.calender_id==rhs.calender_id and\
               self.sync_frequency==rhs.sync_frequency and self.sync_on_connect==rhs.sync_on_connect

	def __ne__(self, rhs):

        return (not __eq__(rhs))

	def get(self):

        return copy.deepcopy(self._data, {})

	def set(self, d):

        self._data={}

        self._data.update(d)

	def get_db_dict(self):

        return self.get()

	def set_db_dict(self, d):

        self.set(d)

	def _get_id(self):

        s=self._data.get('serials', [])

        for n in s:

            if n.get('sourcetype', None)=='bitpim':

                return n.get('id', None)

        return None

	def _set_id(self, id):

        s=self._data.get('serials', [])

        for n in s:

            if n.get('sourcetype', None)=='bitpim':

                n['id']=id

                return

        self._data['serials'].append({'sourcetype': 'bitpim', 'id': id } )

	id=property(fget=_get_id, fset=_set_id)
	    def _set_or_del(self, key, v, v_list=[]):

        if v is None or v in v_list:

            if self._data.has_key(key):

                del self._data[key]

        else:

            self._data[key]=v

	def _get_caltype(self):

        return self._data.get(self._caltype_key, 'None')

	def _set_caltype(self, v):

        self._set_or_del(self._caltype_key, v, [''])

	caltype=property(fget=_get_caltype, fset=_set_caltype)
	    def _get_calender_id(self):

        return self._data.get(self._calender_id_key, '')

	def _set_calender_id(self, v):

        self._set_or_del(self._calender_id_key, v, [''])

	calender_id=property(fget=_get_calender_id, fset=_set_calender_id)
	    def _get_sync_on_connect(self):

        return self._data.get(self._sync_on_connect_key, False)

	def _set_sync_on_connect(self, v):

        self._set_or_del(self._sync_on_connect_key, v, [''])

	sync_on_connect=property(fget=_get_sync_on_connect, fset=_set_sync_on_connect)
	    def _get_sync_frequency(self):

        return self._data.get(self._sync_frequency_key, 0)

	def _set_sync_frequency(self, v):

        self._set_or_del(self._sync_frequency_key, v, [''])

	sync_frequency=property(fget=_get_sync_frequency, fset=_set_sync_frequency)

class  AutoSyncSettingsDialog (wx.Dialog) :
	ID_CALSETTINGS=wx.NewId()
	    def __init__(self, mainwindow, frame, title="Schedule Auto Sync Settings", profile="Default Autosync", id=-1):

        t=title+" - "+profile

        wx.Dialog.__init__(self, frame, id, t,
                          style=wx.CAPTION|wx.SYSTEM_MENU|wx.DEFAULT_DIALOG_STYLE)

        self.mw=mainwindow

        self.profile=profile

        gs=wx.GridBagSizer(10, 10)

        gs.AddGrowableCol(1)

        gs.Add( wx.StaticText(self, -1, "Calender Type"), pos=(0,0), flag=wx.ALIGN_CENTER_VERTICAL)

        calendertype=('None',)

        for entry in self.mw.calenders:

            calendertype+=(entry[0], )

        self.caltype=wx.ComboBox(self, -1, calendertype[0], style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=calendertype)

        gs.Add( self.caltype, pos=(0,1), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.Button(self, self.ID_CALSETTINGS, "Calender Settings..."), pos=(0,2), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.StaticText(self, -1, "Update when phone re-connected"), pos=(1,0), flag=wx.ALIGN_CENTER_VERTICAL)

        self.sync_on_connect=wx.CheckBox(self, wx.NewId(), "")

        gs.Add( self.sync_on_connect, pos=(1,1), flag=wx.ALIGN_CENTER_VERTICAL)

        gs.Add( wx.StaticText(self, -1, "Update Frequency (mins) 0=never"), pos=(2,0), flag=wx.ALIGN_CENTER_VERTICAL)

        self.sync_frequency=wx.lib.intctrl.IntCtrl(self, -1, value=0, min=0, max=1440)

        gs.Add( self.sync_frequency, pos=(2,1), flag=wx.ALIGN_CENTER_VERTICAL)

        bs=wx.BoxSizer(wx.VERTICAL)

        bs.Add(gs, 0, wx.EXPAND|wx.ALL, 10)

        bs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 7)

        but=self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP)

        bs.Add(but, 0, wx.CENTER|wx.ALL, 10)

        wx.EVT_BUTTON(self, wx.ID_HELP, self.OnHelp)

        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)

        wx.EVT_BUTTON(self, self.ID_CALSETTINGS, self.OnConfigCalender)

        wx.EVT_COMBOBOX(self, self.caltype.GetId(), self.OnCaltypeChange)

        self.settings=AutoSyncSettingsEntry()

        self.SetSizer(bs)

        self.SetAutoLayout(True)

        bs.Fit(self)

        self.getfromfs()

        self.auto_sync_timer_id = wx.NewId()

        self.auto_sync_timer = wx.Timer(self, self.auto_sync_timer_id)

        self.SetAutoSyncTimer()

        guiwidgets.set_size("AutoSyncSettingsDialog", self, screenpct=-1,  aspect=3.5)

        wx.EVT_CLOSE(self, self.OnClose)

	def OnCaltypeChange(self, _):

        if self.settings.caltype!=self.caltype.GetValue():

            self.OnConfigCalender()

        return

	def OnConfigCalender(self, _=None):

        old_folder=self.settings.calender_id

        for entry in self.mw.calenders:

            if entry[0]==self.caltype.GetValue():

                if self.settings.caltype!=self.caltype.GetValue():

                    self.settings.calender_id=''    

                filter={}

                for setting in _filter_keys:

                    if self.settings._data.has_key(setting) and self.settings._data[setting]!=None:

                        if setting=="categories":

                            filter[setting]=self.settings._data[setting].split("||")

                        else:

                            filter[setting]=self.settings._data[setting]

                res, temp=entry[1](self.mw, self.settings.calender_id, filter)

                if res==wx.ID_OK:

                    self.settings.calender_id=temp[0]

                    for setting in _filter_keys:

                        if(temp[1].has_key(setting) and temp[1][setting]!=None):

                            if setting=="categories":

                                cat_str=""

                                for cat in temp[1][setting]:

                                    if len(cat_str):

                                        cat_str=cat_str+"||"+cat

                                    else:

                                        cat_str=cat

                                self.settings._data[setting]=cat_str

                            else:

                                self.settings._data[setting]=temp[1][setting]

                        else:

                            if self.settings._data.has_key(setting):

                                del self.settings._data[setting]

                    self.settings.caltype=self.caltype.GetValue()

                else: 

                    self.caltype.SetValue(self.settings.caltype)

                    self.settings.calender_id=old_folder

                return

        return

	def OnCancel(self, _):

        self.saveSize()

        self.EndModal(wx.ID_CANCEL)

        return

	def OnOK(self, _):

        self.saveSize()

        self.EndModal(wx.ID_OK)

        return

	def OnHelp(self, _):

        return

	def OnClose(self, evt):

        self.saveSize()

        self.EndModal(wx.ID_CANCEL)

        return

	def _save_to_db(self):

        db_rr={}

        self.settings.caltype=self.caltype.GetValue()

        self.settings.sync_on_connect=self.sync_on_connect.GetValue()

        self.settings.sync_frequency=self.sync_frequency.GetValue()

        self.settings.id=self.profile

        db_rr[self.settings.id]=AutoSyncSettingsobject(self.settings)

        database.ensurerecordtype(db_rr, autosyncsettingsobjectfactory)

        self.mw.tree.GetActivePhone().GetDatabase().savemajordict(_data_key, db_rr)

	def getfromfs(self):

        self.settings=_getsettings(self.mw, self.profile)

        self.caltype.SetValue(self.settings.caltype)

        self.sync_on_connect.SetValue(int(self.settings.sync_on_connect))

        self.sync_frequency.SetValue(int(self.settings.sync_frequency))

        return

	def IsConfigured(self):

        return self.settings.caltype!='None'

	def updatevariables(self):

        self.mw.auto_save_dict=self.settings

	def ShowModal(self):

        self.getfromfs()

        ec=wx.Dialog.ShowModal(self)

        if ec==wx.ID_OK:

            self._save_to_db()

            self.updatevariables()

            self.SetAutoSyncTimer()

        return ec

	def saveSize(self):

        guiwidgets.save_size("AutoSyncSettingsDialog", self.GetRect())

	def SetAutoSyncTimer(self):

        self.auto_sync_timer.Stop()

        oneShot = True

        timeout=self.settings.sync_frequency*60000 

        if timeout:

            self.auto_sync_timer.Start(timeout, oneShot)

            self.Bind(wx.EVT_TIMER, self.OnTimer, self.auto_sync_timer)

	def OnTimer(self, event):

        self.mw.log("Auto Sync: Timed update")

        SyncSchedule(self.mw).sync(self.mw, silent=1)

        self.SetAutoSyncTimer()
Esempio n. 3
0
import guihelper
import helpids
import widgets

# module constants--------------------------------------------------------------
dict_key='T9 Data'

#-------------------------------------------------------------------------------
class T9WordsDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'words': ['word'] })
    def __init__(self, data=None):
        if data and isinstance(data, dict):
            self.update(data)
t9wordsdataobjectfactory=database.dataobjectfactory(T9WordsDataObject)

#-------------------------------------------------------------------------------
class T9WordsList(object):
    _t9_dict={'0': '0', '1': '1',
              'a': '2', 'b': '2', 'c': '2', '2': '2',
              'd': '3', 'e': '3', 'f': '3', '3': '3',
              'g': '4', 'h': '4', 'i': '4', '4': '4',
              'j': '5', 'k': '5', 'l': '5', '5': '5',
              'm': '6', 'n': '6', 'o': '6', '6': '6',
              'p': '7', 'q': '7', 'r': '7', 's': '7', '7': '7',
              't': '8', 'u': '8', 'v': '8', '8': '8',
              'w': '9', 'x': '9', 'y': '9', 'z': '9', '9': '9',
              }
    def __init__(self):
        self._data={}
import wx.lib.scrolledpanel as scrolled
import database
import guiwidgets
import guihelper
import phonenumber
import pubsub
import today
import widgets
class CallHistoryDataobject(database.basedataobject):
    _knownproperties=['folder', 'datetime', 'number', 'name', 'duration' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    def __init__(self, data=None):
        if data is None or not isinstance(data, CallHistoryEntry):
            return;
        self.update(data.get_db_dict())
callhistoryobjectfactory=database.dataobjectfactory(CallHistoryDataobject)
class CallHistoryEntry(object):
    Folder_Incoming='Incoming'
    Folder_Outgoing='Outgoing'
    Folder_Missed='Missed'
    Folder_Data='Data'
    Valid_Folders=(Folder_Incoming, Folder_Outgoing, Folder_Missed, Folder_Data)
    _folder_key='folder'
    _datetime_key='datetime'
    _number_key='number'
    _name_key='name'
    _duration_key='duration'
    _unknown_datetime='YYYY-MM-DD hh:mm:ss'
    _id_index=0
    _max_id_index=999
    def __init__(self):
Esempio n. 5
0
class MemoDataObject(database.basedataobject):
    _knownproperties = ['subject', 'date']
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({
        'categories': ['category'],
        'flags': ['secret'],
        'body': ['type', 'data', '*']
    })

    def __init__(self, data=None):
        if data is None or not isinstance(data, MemoEntry):
            return
        self.update(data.get_db_dict())


memoobjectfactory = database.dataobjectfactory(MemoDataObject)


#-------------------------------------------------------------------------------
class MemoEntry(object):
    _body_subject_len = 12  # the # of chars from body to fill in for subj + ...
    _id_index = 0
    _max_id_index = 999

    def __init__(self):
        self._data = {'body': [], 'serials': []}
        self.set_date_now()
        self._create_id()

    def get(self):
        return copy.deepcopy(self._data, {})
            self.mw.OnBusyEnd()
            if silent==0:
                wx.MessageBox('Unable to synchronize phone schedule',
                              'Synchronize failed', wx.OK)
            self.log("Auto Sync: Failed, Unable to synchronize phone schedule")
        return res
class AutoSyncSettingsobject(database.basedataobject):
    _knownproperties=['caltype', 'calender_id', 'sync_on_connect', 'sync_frequency', \
                      'start_offset', 'end_offset', 'no_alarm', 'rpt_events', 'categories', \
                      'ringtone', 'vibrate', 'alarm_override', 'alarm_value']
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    def __init__(self, data=None):
        if data is None or not isinstance(data, AutoSyncSettingsEntry):
            return;
        self.update(data.get_db_dict())
autosyncsettingsobjectfactory=database.dataobjectfactory(AutoSyncSettingsobject)
class AutoSyncSettingsEntry(object):
    _caltype_key='caltype'
    _calender_id_key='calender_id'
    _sync_on_connect_key='sync_on_connect'
    _sync_frequency_key='sync_frequency'
    def __init__(self):
        self._data={ 'serials': [] }
    def __eq__(self, rhs):
        return self.caltype==rhs.caltype and self.calender_id==rhs.calender_id and\
               self.sync_frequency==rhs.sync_frequency and self.sync_on_connect==rhs.sync_on_connect
    def __ne__(self, rhs):
        return (not __eq__(rhs))
    def get(self):
        return copy.deepcopy(self._data, {})
    def set(self, d):
Esempio n. 7
0
masterlist_key='masterlist'
playlists_list='playlists'
mp3_type='mp3'
wma_type='wma'
playlist_type=(mp3_type, wma_type)

#-------------------------------------------------------------------------------
class MasterListDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({ 'masterlist': ['name'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, (list, tuple)):
            return
        self.update({'masterlist': [{ 'name': x } for x in data] })
masterlistobjectfactory=database.dataobjectfactory(MasterListDataObject)

#-------------------------------------------------------------------------------
class PlaylistDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'playlist': ['name'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, (list, tuple)):
            return
        self.update({'playlist': [{'name': x} for x in data]})
playlistobjectfactory=database.dataobjectfactory(PlaylistDataObject)

#-------------------------------------------------------------------------------
class PlaylistEntryDataObject(database.basedataobject):
    _knownproperties=['type']
    class will also be updated and eventually replace CalendarEntry.
    """
    _knownproperties=['description', 'location', 'priority', 'alarm',
                      'notes', 'ringtone', 'wallpaper',
                      'start', 'end', 'vibrate', 'voice' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( {
                                  'repeat': ['type', 'interval',
                                             'interval2', 'dow'],
                                  'suppressed': ['date'],
                                  'categories': ['category'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, CalendarEntry):
            return
        self.update(data.get_db_dict())
calendarobjectfactory=database.dataobjectfactory(CalendarDataObject)
class RepeatEntry(object):
    daily='daily'
    weekly='weekly'
    monthly='monthly'
    yearly='yearly'
    _interval=0
    _dow=1
    _dom=0
    _moy=1
    _interval2=2
    _dow_names=(
        {1: 'Sun'}, {2: 'Mon'}, {4: 'Tue'}, {8: 'Wed'},
        {16: 'Thu'}, {32: 'Fri'}, {64: 'Sat'})
    _dow_num={ 1: wx.DateTime.Sun,
               2: wx.DateTime.Mon,
Esempio n. 9
0
# modules constants
IMP_OPTION_REPLACEALL=0
IMP_OPTION_ADD=1
IMP_OPTION_PREVIEW=2
IMP_OPTION_MERGE=3

#-------------------------------------------------------------------------------
class ImportCalendarDataObject(common_calendar.FilterDataObject):
    _knownproperties=common_calendar.FilterDataObject._knownproperties+\
                      ['name', 'type', 'source_id', 'option' ]
    _knownlistproperties=common_calendar.FilterDataObject._knownlistproperties
    allproperties=_knownproperties+\
                    [x for x in _knownlistproperties]+\
                    [x for x in common_calendar.FilterDataObject._knowndictproperties]
importcalendarobjectfactory=database.dataobjectfactory(ImportCalendarDataObject)

#-------------------------------------------------------------------------------
class ImportCalendarEntry(dict):
    # a dict class that automatically generates an ID for use with
    # BitPim database.

    def __init__(self, data=None):
        super(ImportCalendarEntry, self).__init__()
        if data:
            self.update(data)

    _persistrandom=random.Random()
    def _create_id(self):
        "Create a BitPim serial for this entry"
        rand2=random.Random() # this random is seeded when this function is called
Esempio n. 10
0
IMP_OPTION_ADD = 1
IMP_OPTION_PREVIEW = 2
IMP_OPTION_MERGE = 3


#-------------------------------------------------------------------------------
class ImportCalendarDataObject(common_calendar.FilterDataObject):
    _knownproperties=common_calendar.FilterDataObject._knownproperties+\
                      ['name', 'type', 'source_id', 'option' ]
    _knownlistproperties = common_calendar.FilterDataObject._knownlistproperties
    allproperties=_knownproperties+\
                    [x for x in _knownlistproperties]+\
                    [x for x in common_calendar.FilterDataObject._knowndictproperties]


importcalendarobjectfactory = database.dataobjectfactory(
    ImportCalendarDataObject)


#-------------------------------------------------------------------------------
class ImportCalendarEntry(dict):
    # a dict class that automatically generates an ID for use with
    # BitPim database.

    def __init__(self, data=None):
        super(ImportCalendarEntry, self).__init__()
        if data:
            self.update(data)

    _persistrandom = random.Random()

    def _create_id(self):
Esempio n. 11
0
#-------------------------------------------------------------------------------
URLDictKey = 'URLs'
URLDictName = 'gCalURL'


class URLDataObject(database.basedataobject):
    # object to store a list of URLs & names in the DB
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({'urls': ['url', 'name']})

    def __init__(self, data=None):
        if data:
            self.update(data)


urlobjectfactory = database.dataobjectfactory(URLDataObject)


#-------------------------------------------------------------------------------
class gCalendarServer(vcal.vCalendarFile):
    def _open(self, name):
        return urllib2.urlopen(name)


#-------------------------------------------------------------------------------
parentclass = ical.iCalendarImportData


class gCalendarImportData(parentclass):
    _source_data_class = gCalendarServer
Esempio n. 12
0

#-------------------------------------------------------------------------------
class AutoSyncSettingsobject(database.basedataobject):
    _knownproperties=['caltype', 'calender_id', 'sync_on_connect', 'sync_frequency', \
                      'start_offset', 'end_offset', 'no_alarm', 'rpt_events', 'categories', \
                      'ringtone', 'vibrate', 'alarm_override', 'alarm_value']
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()

    def __init__(self, data=None):
        if data is None or not isinstance(data, AutoSyncSettingsEntry):
            return
        self.update(data.get_db_dict())


autosyncsettingsobjectfactory = database.dataobjectfactory(
    AutoSyncSettingsobject)


#-------------------------------------------------------------------------------
class AutoSyncSettingsEntry(object):
    _caltype_key = 'caltype'
    _calender_id_key = 'calender_id'
    _sync_on_connect_key = 'sync_on_connect'
    _sync_frequency_key = 'sync_frequency'

    #_start_offset_key='start_offset'
    #_end_offset_key='end_offset'
    #_no_alarm_key='no_alarm'
    #_categories_key='categories'
    #_rpt_event_key='rpt_event'
    #_vibrate_key='vibrate'
Esempio n. 13
0
import guihelper
import helpids
import widgets

# module constants--------------------------------------------------------------
dict_key='T9 Data'

#-------------------------------------------------------------------------------
class T9WordsDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'words': ['word'] })
    def __init__(self, data=None):
        if data and isinstance(data, dict):
            self.update(data)
t9wordsdataobjectfactory=database.dataobjectfactory(T9WordsDataObject)

#-------------------------------------------------------------------------------
class T9WordsList(object):
    _t9_dict={'0': '0', '1': '1',
              'a': '2', 'b': '2', 'c': '2', '2': '2',
              'd': '3', 'e': '3', 'f': '3', '3': '3',
              'g': '4', 'h': '4', 'i': '4', '4': '4',
              'j': '5', 'k': '5', 'l': '5', '5': '5',
              'm': '6', 'n': '6', 'o': '6', '6': '6',
              'p': '7', 'q': '7', 'r': '7', 's': '7', '7': '7',
              't': '8', 'u': '8', 'v': '8', '8': '8',
              'w': '9', 'x': '9', 'y': '9', 'z': '9', '9': '9',
              }
    def __init__(self):
        self._data={}
    def __save_size(self, evt):
        if self.__config_name is not None:
            guiwidgets.save_size(self.__config_name, self.GetRect())
        evt.Skip()
class FilterDataObject(database.basedataobject):
    _knownproperties=['rpt_events', 'no_alarm', 'alarm_override',
                      'ringtone', 'vibrate', 'alarm_value',
                      'preset_date' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( {'categories': ['category'],
                                  'start': ['year', 'month', 'day'],
                                  'end': ['year', 'month', 'day'] })
    def __init__(self, data=None):
        if data:
            self.update(data)
filterobjectfactory=database.dataobjectfactory(FilterDataObject)
class FilterDialogBase(wx.Dialog):
    unnamed="Select:"
    def __init__(self, parent, id, caption, categories, style=wx.DEFAULT_DIALOG_STYLE):
        wx.Dialog.__init__(self, parent, id,
                           title=caption, style=style)
        bs=wx.BoxSizer(wx.VERTICAL)
        main_fgs=wx.FlexGridSizer(0, 1, 0, 0)
        fgs=wx.FlexGridSizer(3, 2, 0, 5)
        fgs1=wx.FlexGridSizer(0, 1, 0, 0)
        fgs2=wx.FlexGridSizer(0, 2, 0, 5)
        self.SetDateControls(fgs, fgs1)
        self._rpt_chkbox=wx.CheckBox(self, id=wx.NewId(), label='Repeat Events:',
                                      style=wx.ALIGN_RIGHT)
        self._rpt_chkbox.Disable()
        fgs.Add(self._rpt_chkbox, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 5)
import pubsub
import today
import guihelper
import widgets
widgets_list=[]
class MemoDataObject(database.basedataobject):
    _knownproperties=['subject', 'date']
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( {'categories': ['category'],
                                  'flags': ['secret'],
                                  'body': ['type', 'data', '*' ] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, MemoEntry):
            return;
        self.update(data.get_db_dict())
memoobjectfactory=database.dataobjectfactory(MemoDataObject)
class MemoEntry(object):
    _body_subject_len=12   # the # of chars from body to fill in for subj + ...
    _id_index=0
    _max_id_index=999
    def __init__(self):
        self._data={ 'body': [], 'serials': [] }
        self.set_date_now()
        self._create_id()
    def get(self):
        return copy.deepcopy(self._data, {})
    def set(self, d):
        self._data={}
        self._data.update(d)
    def get_db_dict(self):
        return self.get()
Esempio n. 16
0
        'summary', 'note', 'due_date', 'status', 'percent_complete',
        'completion_date', 'priority'
    ]
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({
        'categories': ['category'],
        'flags': ['secret']
    })

    def __init__(self, data=None):
        if data is None or not isinstance(data, TodoEntry):
            return
        self.update(data.get_db_dict())


todoobjectfactory = database.dataobjectfactory(TodoDataObject)


#-------------------------------------------------------------------------------
class TodoEntry(object):
    ST_NotStarted = 1
    ST_InProgress = 2
    ST_NeedActions = 3
    ST_Completed = 4
    ST_Cancelled = 5
    ST_Last = 6
    ST_Range = xrange(ST_NotStarted, ST_Last)
    ST_Names = ('<None>', 'Not Started', 'In Progess', 'Need Actions',
                'Completed', 'Cancelled', 'LAST')
    PC_Range = xrange(101)  # % Complete: 0-100%
    PR_Range = xrange(1, 11)
Esempio n. 17
0
        evt.Skip()

#-------------------------------------------------------------------------------
class FilterDataObject(database.basedataobject):
    _knownproperties=['rpt_events', 'no_alarm', 'alarm_override',
                      'ringtone', 'vibrate', 'alarm_value',
                      'preset_date' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( {'categories': ['category'],
                                  'start': ['year', 'month', 'day'],
                                  'end': ['year', 'month', 'day'] })
    def __init__(self, data=None):
        if data:
            self.update(data)

filterobjectfactory=database.dataobjectfactory(FilterDataObject)
#-------------------------------------------------------------------------------
class FilterDialogBase(wx.Dialog):
    unnamed="Select:"
    def __init__(self, parent, id, caption, categories, style=wx.DEFAULT_DIALOG_STYLE):
        wx.Dialog.__init__(self, parent, id,
                           title=caption, style=style)
        # the main box sizer
        bs=wx.BoxSizer(wx.VERTICAL)
        # the flex grid sizers for the editable items
        main_fgs=wx.FlexGridSizer(0, 1, 0, 0)
        fgs=wx.FlexGridSizer(3, 2, 0, 5)
        fgs1=wx.FlexGridSizer(0, 1, 0, 0)
        fgs2=wx.FlexGridSizer(0, 2, 0, 5)
        # set the date options
        self.SetDateControls(fgs, fgs1)
import common
import widgets
import guiwidgets
import shutil
import database
basename=common.basename
stripext=common.stripext
getext=common.getext
class MediaDataObject(database.basedataobject):
    _knownproperties=['name', 'origin', 'index', 'mediadata', 'timestamp' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    def __init__(self, data=None):
        if data is None or not isinstance(data, MediaEntry):
            return;
        self.update(data.get_db_dict())
mediaobjectfactory=database.dataobjectfactory(MediaDataObject)
class MediaEntry(object):
    _id_index=0
    _max_id_index=999
    def __init__(self):
        self._data={ 'serials': [] }
        self._create_id()
    def get(self):
        return copy.deepcopy(self._data, {})
    def set(self, d):
        self._data={}
        self._data.update(d)
    def get_db_dict(self):
        return self.get()
    def set_db_dict(self, d):
        self.set(d)
	_knownproperties=['summary', 'note', 'due_date', 'status',
                      'percent_complete', 'completion_date', 'priority' ]
	    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
	    _knownlistproperties.update( {'categories': ['category'],
                                  'flags': ['secret'] })
	    def __init__(self, data=None):

        if data is None or not isinstance(data, TodoEntry):

            return;

        self.update(data.get_db_dict())

	    _knownlistproperties.update( {'categories': ['category'],
                                  'flags': ['secret'] })
todoobjectfactory=database.dataobjectfactory(TodoDataObject)
class  TodoEntry (object) :
	ST_NotStarted=1
	    ST_InProgress=2
	    ST_NeedActions=3
	    ST_Completed=4
	    ST_Cancelled=5
	    ST_Last=6
	    ST_Range=xrange(ST_NotStarted, ST_Last)
	    ST_Names=(
        '<None>', 'Not Started', 'In Progess', 'Need Actions',
        'Completed', 'Cancelled', 'LAST')
	    PC_Range=xrange(101)
	    PR_Range=xrange(1, 11)
	    _id_index=0
	    _max_id_index=999
Esempio n. 20
0
File: sms.py Progetto: deosai/bitpim
        '_from', '_to', 'subject', 'text', 'datetime', 'callback', 'folder',
        'msg_id', 'read', 'priority'
    ]
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({
        'flags': ['locked', 'read'],
        'receivers': ['name', 'confirmed_datetime']
    })

    def __init__(self, data=None):
        if data is None or not isinstance(data, SMSEntry):
            return
        self.update(data.get_db_dict())


smsobjectfactory = database.dataobjectfactory(SMSDataObject)


#-------------------------------------------------------------------------------
class CannedMsgDataObject(database.basedataobject):
    _knownproperties = []
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update({'canned_msg': ['text', 'type']})

    def __init__(self, data=None):
        if data is None or not isinstance(data, CannedMsgEntry):
            return
        self.update(data.get_db_dict())


cannedmsgobjectfactory = database.dataobjectfactory(CannedMsgDataObject)
"""
import copy
import sha
import time
import database
class SMSDataObject(database.basedataobject):
    _knownproperties=['_from', '_to', 'subject', 'text', 'datetime',
                      'callback', 'folder', 'msg_id', 'read', 'priority' ]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'flags': ['locked', 'read'],
                                   'receivers': ['name', 'confirmed_datetime'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, SMSEntry):
            return;
        self.update(data.get_db_dict())
smsobjectfactory=database.dataobjectfactory(SMSDataObject)
class CannedMsgDataObject(database.basedataobject):
    _knownproperties=[]
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'canned_msg': ['text', 'type'] })
    def __init__(self, data=None):
        if data is None or not isinstance(data, CannedMsgEntry):
            return;
        self.update(data.get_db_dict())
cannedmsgobjectfactory=database.dataobjectfactory(CannedMsgDataObject)
class SMSEntry(object):
    Folder_Inbox='Inbox'
    Folder_Sent='Sent'
    Folder_Saved='Saved'
    Valid_Folders=(Folder_Inbox, Folder_Sent, Folder_Saved)
    _id_index=0
Esempio n. 22
0
                                                       parent.GetActiveDatabase()),
                                       True) as (dlg, retcode):
            if retcode==wx.ID_OK:
                self._source=dlg.GetPath()

#-------------------------------------------------------------------------------
URLDictKey='URLs'
URLDictName='gCalURL'
class URLDataObject(database.basedataobject):
    # object to store a list of URLs & names in the DB
    _knownlistproperties=database.basedataobject._knownlistproperties.copy()
    _knownlistproperties.update( { 'urls': [ 'url', 'name'] })
    def __init__(self, data=None):
        if data:
            self.update(data)
urlobjectfactory=database.dataobjectfactory(URLDataObject)

#-------------------------------------------------------------------------------
class gCalendarServer(vcal.vCalendarFile):

    def _open(self, name):
        return urllib2.urlopen(name)

#-------------------------------------------------------------------------------
parentclass=ical.iCalendarImportData
class gCalendarImportData(parentclass):
    _source_data_class=gCalendarServer
    def read(self, file_name=None, update_dlg=None):
        try:
            super(gCalendarImportData, self).read(file_name, update_dlg)
        except urllib2.URLError:
Esempio n. 23
0
import today
import widgets


#-------------------------------------------------------------------------------
class CallHistoryDataobject(database.basedataobject):
    _knownproperties = ['folder', 'datetime', 'number', 'name', 'duration']
    _knownlistproperties = database.basedataobject._knownlistproperties.copy()

    def __init__(self, data=None):
        if data is None or not isinstance(data, CallHistoryEntry):
            return
        self.update(data.get_db_dict())


callhistoryobjectfactory = database.dataobjectfactory(CallHistoryDataobject)


#-------------------------------------------------------------------------------
def GetDurationStr(duration):
    """convert duration int into an h:mm:ss formatted string"""
    if duration is None:
        return ''
    else:
        sec = duration % 60
        min = duration / 60
        hr = min / 60
        min = min % 60
    return "%d:%02d:%02d" % (hr, min, sec)