# THIS FILE IS AUTOMATICALLY GENERATED.  EDIT THE SOURCE FILE NOT THIS ONE
# Text in this block is placed in the output file

from prototypes import *
from prototypes_samsung import *
from p_samsung_packet import *

NUMPHONENUMBERS=5
NUMPHONEBOOKENTRIES=300
NUMGROUPS=5
MAXNUMBERLEN=32
NUMMEMOENTRIES=9
NUMTODOENTRIES=9
NUMCALENDAREVENTS=70
NUMSMSINENTRIES=211

max_pb_slots=312
max_pb_entries=312
user_pb_entry_range=xrange(1, 301)
max_number_entries=312
max_media_index_entries=302
max_group_entries=6

slot_file_name='nvm/nvm/pclink_tbl'
pb_file_name='nvm/nvm/dial_tbl'
number_file_name='nvm/nvm/dial'
ringer_index_file_name='nvm/nvm/name_ring'
wallpaper_index_file_name='nvm/nvm/avatar'
group_file_name='nvm/nvm/group'
camera_dir='cam/jpeg'
savedtophone_dir='cam/dldJpeg'

camera_index=100 # starting media index for camera images
camera_origin='camera-fullsize'
savedtophone_index=200  # starting media index for saved-to-phone images
savedtophone_origin='camera'
ams_index=300   # starting media index for AmsRegistry items

# Number type
CELLTYPE=1
HOMETYPE=2
WORKTYPE=3
PAGERTYPE=4
OTHERTYPE=5
MAILTYPE=7
URLTYPE=8

# map all UINT fields to lsb version
UINT=UINTlsb
BOOL=BOOLlsb

AMSREGISTRY="ams/AmsRegistry"
ENDTRANSACTION="ams/EndTransaction"
RINGERPREFIX="ams/Ringers/cnts"
WALLPAPERPREFIX="ams/Screen Savers/cnts"

FILETYPE_RINGER=12
FILETYPE_WALLPAPER=13
FILETYPE_APP=16
exts={
    'audio/vnd.qcelp': '.qcp',
    'audio/midi': '.mid',
    'application/x-pmd': '.pmd',
    'audio/mpeg': '.mp3',
    'image/jpeg': '.jpeg',
    'image/png': '.png',
    'image/gif': '.gif',
    'image/bmp': '.bmp',
    }

origins={
    FILETYPE_RINGER: 'ringers',
    FILETYPE_WALLPAPER: 'images',
    }
class groupnameentry(BaseProtogenClass):
    __fields=['gid', 'groupname', 'ringtone', 'dunno2', 'timestamp']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(groupnameentry,self).__init__(**dict)
        if self.__class__ is groupnameentry:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(groupnameentry,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(groupnameentry,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_gid.writetobuffer(buf)
        self.__field_groupname.writetobuffer(buf)
        self.__field_ringtone.writetobuffer(buf)
        self.__field_dunno2.writetobuffer(buf)
        self.__field_timestamp.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_gid=CSVINT()
        self.__field_gid.readfrombuffer(buf)
        self.__field_groupname=CSVSTRING()
        self.__field_groupname.readfrombuffer(buf)
        self.__field_ringtone=CSVINT()
        self.__field_ringtone.readfrombuffer(buf)
        self.__field_dunno2=CSVSTRING(**{'quotechar': None})
        self.__field_dunno2.readfrombuffer(buf)
        self.__field_timestamp=CSVTIME(**{'terminator': None})
        self.__field_timestamp.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_gid(self):
        return self.__field_gid.getvalue()

    def __setfield_gid(self, value):
        if isinstance(value,CSVINT):
            self.__field_gid=value
        else:
            self.__field_gid=CSVINT(value,)

    def __delfield_gid(self): del self.__field_gid

    gid=property(__getfield_gid, __setfield_gid, __delfield_gid, None)

    def __getfield_groupname(self):
        return self.__field_groupname.getvalue()

    def __setfield_groupname(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_groupname=value
        else:
            self.__field_groupname=CSVSTRING(value,)

    def __delfield_groupname(self): del self.__field_groupname

    groupname=property(__getfield_groupname, __setfield_groupname, __delfield_groupname, None)

    def __getfield_ringtone(self):
        return self.__field_ringtone.getvalue()

    def __setfield_ringtone(self, value):
        if isinstance(value,CSVINT):
            self.__field_ringtone=value
        else:
            self.__field_ringtone=CSVINT(value,)

    def __delfield_ringtone(self): del self.__field_ringtone

    ringtone=property(__getfield_ringtone, __setfield_ringtone, __delfield_ringtone, "Ringtone assignment?")

    def __getfield_dunno2(self):
        return self.__field_dunno2.getvalue()

    def __setfield_dunno2(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_dunno2=value
        else:
            self.__field_dunno2=CSVSTRING(value,**{'quotechar': None})

    def __delfield_dunno2(self): del self.__field_dunno2

    dunno2=property(__getfield_dunno2, __setfield_dunno2, __delfield_dunno2, "A single character C or S")

    def __getfield_timestamp(self):
        return self.__field_timestamp.getvalue()

    def __setfield_timestamp(self, value):
        if isinstance(value,CSVTIME):
            self.__field_timestamp=value
        else:
            self.__field_timestamp=CSVTIME(value,**{'terminator': None})

    def __delfield_timestamp(self): del self.__field_timestamp

    timestamp=property(__getfield_timestamp, __setfield_timestamp, __delfield_timestamp, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('gid', self.__field_gid, None)
        yield ('groupname', self.__field_groupname, None)
        yield ('ringtone', self.__field_ringtone, "Ringtone assignment?")
        yield ('dunno2', self.__field_dunno2, "A single character C or S")
        yield ('timestamp', self.__field_timestamp, None)




class groupnameresponse(BaseProtogenClass):
    __fields=['command', 'entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(groupnameresponse,self).__init__(**dict)
        if self.__class__ is groupnameresponse:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(groupnameresponse,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(groupnameresponse,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_command.writetobuffer(buf)
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_command=CSVSTRING(**{'quotechar': None, 'terminator': ord(' '), 'constant': '#PBGRR:'})
        self.__field_command.readfrombuffer(buf)
        self.__field_entry=groupnameentry()
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_command(self):
        return self.__field_command.getvalue()

    def __setfield_command(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_command=value
        else:
            self.__field_command=CSVSTRING(value,**{'quotechar': None, 'terminator': ord(' '), 'constant': '#PBGRR:'})

    def __delfield_command(self): del self.__field_command

    command=property(__getfield_command, __setfield_command, __delfield_command, None)

    def __getfield_entry(self):
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,groupnameentry):
            self.__field_entry=value
        else:
            self.__field_entry=groupnameentry(value,)

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('command', self.__field_command, None)
        yield ('entry', self.__field_entry, None)




class pbentry(BaseProtogenClass):
    __fields=['writeflg', 'slot', 'uslot', 'group', 'ringtone', 'name', 'speeddial', 'dunno1', 'numbers', 'extranumber', 'dunno3', 'dunno4', 'email', 'url', 'birthday', 'wallpaper', 'timestamp']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(pbentry,self).__init__(**dict)
        if self.__class__ is pbentry:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(pbentry,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(pbentry,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed
        try: self.__field_writeflg
        except:
            self.__field_writeflg=BOOL(**{ 'default': False })


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_slot.writetobuffer(buf)
        self.__field_uslot.writetobuffer(buf)
        self.__field_group.writetobuffer(buf)
        try: self.__field_ringtone
        except:
            self.__field_ringtone=CSVINT(**{'default': 20})
        self.__field_ringtone.writetobuffer(buf)
        self.__field_name.writetobuffer(buf)
        self.__field_speeddial.writetobuffer(buf)
        try: self.__field_dunno1
        except:
            self.__field_dunno1=CSVINT(**{'default': 0})
        self.__field_dunno1.writetobuffer(buf)
        try: self.__field_numbers
        except:
            self.__field_numbers=LIST(**{'length': NUMPHONENUMBERS, 'createdefault': True, 'elementclass': phonenumber})
        self.__field_numbers.writetobuffer(buf)
        if self.writeflg:
            try: self.__field_extranumber
            except:
                self.__field_extranumber=phonenumber()
            self.__field_extranumber.writetobuffer(buf)
        try: self.__field_dunno3
        except:
            self.__field_dunno3=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_dunno3.writetobuffer(buf)
        try: self.__field_dunno4
        except:
            self.__field_dunno4=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_dunno4.writetobuffer(buf)
        self.__field_email.writetobuffer(buf)
        self.__field_url.writetobuffer(buf)
        try: self.__field_birthday
        except:
            self.__field_birthday=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_birthday.writetobuffer(buf)
        try: self.__field_wallpaper
        except:
            self.__field_wallpaper=CSVINT(**{'default': 20})
        self.__field_wallpaper.writetobuffer(buf)
        try: self.__field_timestamp
        except:
            self.__field_timestamp=CSVTIME(**{'terminator': None,               'default': DateTime.now()+(0,) })
        self.__field_timestamp.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_slot=CSVINT()
        self.__field_slot.readfrombuffer(buf)
        self.__field_uslot=CSVINT()
        self.__field_uslot.readfrombuffer(buf)
        self.__field_group=CSVINT()
        self.__field_group.readfrombuffer(buf)
        self.__field_ringtone=CSVINT(**{'default': 20})
        self.__field_ringtone.readfrombuffer(buf)
        self.__field_name=CSVSTRING()
        self.__field_name.readfrombuffer(buf)
        self.__field_speeddial=CSVINT()
        self.__field_speeddial.readfrombuffer(buf)
        self.__field_dunno1=CSVINT(**{'default': 0})
        self.__field_dunno1.readfrombuffer(buf)
        self.__field_numbers=LIST(**{'length': NUMPHONENUMBERS, 'createdefault': True, 'elementclass': phonenumber})
        self.__field_numbers.readfrombuffer(buf)
        if self.writeflg:
            self.__field_extranumber=phonenumber()
            self.__field_extranumber.readfrombuffer(buf)
        self.__field_dunno3=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_dunno3.readfrombuffer(buf)
        self.__field_dunno4=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_dunno4.readfrombuffer(buf)
        self.__field_email=CSVSTRING()
        self.__field_email.readfrombuffer(buf)
        self.__field_url=CSVSTRING()
        self.__field_url.readfrombuffer(buf)
        self.__field_birthday=CSVSTRING(**{'quotechar': None, 'default': ""})
        self.__field_birthday.readfrombuffer(buf)
        self.__field_wallpaper=CSVINT(**{'default': 20})
        self.__field_wallpaper.readfrombuffer(buf)
        self.__field_timestamp=CSVTIME(**{'terminator': None,               'default': DateTime.now()+(0,) })
        self.__field_timestamp.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_writeflg(self):
        try: self.__field_writeflg
        except:
            self.__field_writeflg=BOOL(**{ 'default': False })
        return self.__field_writeflg.getvalue()

    def __setfield_writeflg(self, value):
        if isinstance(value,BOOL):
            self.__field_writeflg=value
        else:
            self.__field_writeflg=BOOL(value,**{ 'default': False })

    def __delfield_writeflg(self): del self.__field_writeflg

    writeflg=property(__getfield_writeflg, __setfield_writeflg, __delfield_writeflg, "Set to True when writing to phone")

    def __getfield_slot(self):
        return self.__field_slot.getvalue()

    def __setfield_slot(self, value):
        if isinstance(value,CSVINT):
            self.__field_slot=value
        else:
            self.__field_slot=CSVINT(value,)

    def __delfield_slot(self): del self.__field_slot

    slot=property(__getfield_slot, __setfield_slot, __delfield_slot, "Internal Slot")

    def __getfield_uslot(self):
        return self.__field_uslot.getvalue()

    def __setfield_uslot(self, value):
        if isinstance(value,CSVINT):
            self.__field_uslot=value
        else:
            self.__field_uslot=CSVINT(value,)

    def __delfield_uslot(self): del self.__field_uslot

    uslot=property(__getfield_uslot, __setfield_uslot, __delfield_uslot, "User Slot, Speed dial")

    def __getfield_group(self):
        return self.__field_group.getvalue()

    def __setfield_group(self, value):
        if isinstance(value,CSVINT):
            self.__field_group=value
        else:
            self.__field_group=CSVINT(value,)

    def __delfield_group(self): del self.__field_group

    group=property(__getfield_group, __setfield_group, __delfield_group, None)

    def __getfield_ringtone(self):
        try: self.__field_ringtone
        except:
            self.__field_ringtone=CSVINT(**{'default': 20})
        return self.__field_ringtone.getvalue()

    def __setfield_ringtone(self, value):
        if isinstance(value,CSVINT):
            self.__field_ringtone=value
        else:
            self.__field_ringtone=CSVINT(value,**{'default': 20})

    def __delfield_ringtone(self): del self.__field_ringtone

    ringtone=property(__getfield_ringtone, __setfield_ringtone, __delfield_ringtone, None)

    def __getfield_name(self):
        return self.__field_name.getvalue()

    def __setfield_name(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_name=value
        else:
            self.__field_name=CSVSTRING(value,)

    def __delfield_name(self): del self.__field_name

    name=property(__getfield_name, __setfield_name, __delfield_name, None)

    def __getfield_speeddial(self):
        return self.__field_speeddial.getvalue()

    def __setfield_speeddial(self, value):
        if isinstance(value,CSVINT):
            self.__field_speeddial=value
        else:
            self.__field_speeddial=CSVINT(value,)

    def __delfield_speeddial(self): del self.__field_speeddial

    speeddial=property(__getfield_speeddial, __setfield_speeddial, __delfield_speeddial, "Which phone number assigned to speed dial uslot")

    def __getfield_dunno1(self):
        try: self.__field_dunno1
        except:
            self.__field_dunno1=CSVINT(**{'default': 0})
        return self.__field_dunno1.getvalue()

    def __setfield_dunno1(self, value):
        if isinstance(value,CSVINT):
            self.__field_dunno1=value
        else:
            self.__field_dunno1=CSVINT(value,**{'default': 0})

    def __delfield_dunno1(self): del self.__field_dunno1

    dunno1=property(__getfield_dunno1, __setfield_dunno1, __delfield_dunno1, None)

    def __getfield_numbers(self):
        try: self.__field_numbers
        except:
            self.__field_numbers=LIST(**{'length': NUMPHONENUMBERS, 'createdefault': True, 'elementclass': phonenumber})
        return self.__field_numbers.getvalue()

    def __setfield_numbers(self, value):
        if isinstance(value,LIST):
            self.__field_numbers=value
        else:
            self.__field_numbers=LIST(value,**{'length': NUMPHONENUMBERS, 'createdefault': True, 'elementclass': phonenumber})

    def __delfield_numbers(self): del self.__field_numbers

    numbers=property(__getfield_numbers, __setfield_numbers, __delfield_numbers, None)

    def __getfield_extranumber(self):
        try: self.__field_extranumber
        except:
            self.__field_extranumber=phonenumber()
        return self.__field_extranumber.getvalue()

    def __setfield_extranumber(self, value):
        if isinstance(value,phonenumber):
            self.__field_extranumber=value
        else:
            self.__field_extranumber=phonenumber(value,)

    def __delfield_extranumber(self): del self.__field_extranumber

    extranumber=property(__getfield_extranumber, __setfield_extranumber, __delfield_extranumber, None)

    def __getfield_dunno3(self):
        try: self.__field_dunno3
        except:
            self.__field_dunno3=CSVSTRING(**{'quotechar': None, 'default': ""})
        return self.__field_dunno3.getvalue()

    def __setfield_dunno3(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_dunno3=value
        else:
            self.__field_dunno3=CSVSTRING(value,**{'quotechar': None, 'default': ""})

    def __delfield_dunno3(self): del self.__field_dunno3

    dunno3=property(__getfield_dunno3, __setfield_dunno3, __delfield_dunno3, None)

    def __getfield_dunno4(self):
        try: self.__field_dunno4
        except:
            self.__field_dunno4=CSVSTRING(**{'quotechar': None, 'default': ""})
        return self.__field_dunno4.getvalue()

    def __setfield_dunno4(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_dunno4=value
        else:
            self.__field_dunno4=CSVSTRING(value,**{'quotechar': None, 'default': ""})

    def __delfield_dunno4(self): del self.__field_dunno4

    dunno4=property(__getfield_dunno4, __setfield_dunno4, __delfield_dunno4, None)

    def __getfield_email(self):
        return self.__field_email.getvalue()

    def __setfield_email(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_email=value
        else:
            self.__field_email=CSVSTRING(value,)

    def __delfield_email(self): del self.__field_email

    email=property(__getfield_email, __setfield_email, __delfield_email, None)

    def __getfield_url(self):
        return self.__field_url.getvalue()

    def __setfield_url(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_url=value
        else:
            self.__field_url=CSVSTRING(value,)

    def __delfield_url(self): del self.__field_url

    url=property(__getfield_url, __setfield_url, __delfield_url, None)

    def __getfield_birthday(self):
        try: self.__field_birthday
        except:
            self.__field_birthday=CSVSTRING(**{'quotechar': None, 'default': ""})
        return self.__field_birthday.getvalue()

    def __setfield_birthday(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_birthday=value
        else:
            self.__field_birthday=CSVSTRING(value,**{'quotechar': None, 'default': ""})

    def __delfield_birthday(self): del self.__field_birthday

    birthday=property(__getfield_birthday, __setfield_birthday, __delfield_birthday, None)

    def __getfield_wallpaper(self):
        try: self.__field_wallpaper
        except:
            self.__field_wallpaper=CSVINT(**{'default': 20})
        return self.__field_wallpaper.getvalue()

    def __setfield_wallpaper(self, value):
        if isinstance(value,CSVINT):
            self.__field_wallpaper=value
        else:
            self.__field_wallpaper=CSVINT(value,**{'default': 20})

    def __delfield_wallpaper(self): del self.__field_wallpaper

    wallpaper=property(__getfield_wallpaper, __setfield_wallpaper, __delfield_wallpaper, None)

    def __getfield_timestamp(self):
        try: self.__field_timestamp
        except:
            self.__field_timestamp=CSVTIME(**{'terminator': None,               'default': DateTime.now()+(0,) })
        return self.__field_timestamp.getvalue()

    def __setfield_timestamp(self, value):
        if isinstance(value,CSVTIME):
            self.__field_timestamp=value
        else:
            self.__field_timestamp=CSVTIME(value,**{'terminator': None,               'default': DateTime.now()+(0,) })

    def __delfield_timestamp(self): del self.__field_timestamp

    timestamp=property(__getfield_timestamp, __setfield_timestamp, __delfield_timestamp, "Use terminator None for last item")

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('writeflg', self.__field_writeflg, "Set to True when writing to phone")
        yield ('slot', self.__field_slot, "Internal Slot")
        yield ('uslot', self.__field_uslot, "User Slot, Speed dial")
        yield ('group', self.__field_group, None)
        yield ('ringtone', self.__field_ringtone, None)
        yield ('name', self.__field_name, None)
        yield ('speeddial', self.__field_speeddial, "Which phone number assigned to speed dial uslot")
        yield ('dunno1', self.__field_dunno1, None)
        yield ('numbers', self.__field_numbers, None)
        if self.writeflg:
            yield ('extranumber', self.__field_extranumber, None)
        yield ('dunno3', self.__field_dunno3, None)
        yield ('dunno4', self.__field_dunno4, None)
        yield ('email', self.__field_email, None)
        yield ('url', self.__field_url, None)
        yield ('birthday', self.__field_birthday, None)
        yield ('wallpaper', self.__field_wallpaper, None)
        yield ('timestamp', self.__field_timestamp, "Use terminator None for last item")




class phonebookslotresponse(BaseProtogenClass):
    __fields=['command', 'entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(phonebookslotresponse,self).__init__(**dict)
        if self.__class__ is phonebookslotresponse:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(phonebookslotresponse,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(phonebookslotresponse,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_command.writetobuffer(buf)
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_command=CSVSTRING(**{'quotechar': None, 'terminator': ord(' '), 'constant': '#PBOKR:'})
        self.__field_command.readfrombuffer(buf)
        self.__field_entry=pbentry()
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_command(self):
        return self.__field_command.getvalue()

    def __setfield_command(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_command=value
        else:
            self.__field_command=CSVSTRING(value,**{'quotechar': None, 'terminator': ord(' '), 'constant': '#PBOKR:'})

    def __delfield_command(self): del self.__field_command

    command=property(__getfield_command, __setfield_command, __delfield_command, None)

    def __getfield_entry(self):
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,pbentry):
            self.__field_entry=value
        else:
            self.__field_entry=pbentry(value,)

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('command', self.__field_command, None)
        yield ('entry', self.__field_entry, None)




class phonebookslotupdaterequest(BaseProtogenClass):
    __fields=['command', 'entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(phonebookslotupdaterequest,self).__init__(**dict)
        if self.__class__ is phonebookslotupdaterequest:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(phonebookslotupdaterequest,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(phonebookslotupdaterequest,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_command
        except:
            self.__field_command=CSVSTRING(**{'quotechar': None, 'terminator': None, 'default': '#PBOKW=0,'})
        self.__field_command.writetobuffer(buf)
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_command=CSVSTRING(**{'quotechar': None, 'terminator': None, 'default': '#PBOKW=0,'})
        self.__field_command.readfrombuffer(buf)
        self.__field_entry=pbentry()
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_command(self):
        try: self.__field_command
        except:
            self.__field_command=CSVSTRING(**{'quotechar': None, 'terminator': None, 'default': '#PBOKW=0,'})
        return self.__field_command.getvalue()

    def __setfield_command(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_command=value
        else:
            self.__field_command=CSVSTRING(value,**{'quotechar': None, 'terminator': None, 'default': '#PBOKW=0,'})

    def __delfield_command(self): del self.__field_command

    command=property(__getfield_command, __setfield_command, __delfield_command, None)

    def __getfield_entry(self):
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,pbentry):
            self.__field_entry=value
        else:
            self.__field_entry=pbentry(value,)

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('command', self.__field_command, None)
        yield ('entry', self.__field_entry, None)




class smsinrequest(BaseProtogenClass):
    __fields=['command', 'slot']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(smsinrequest,self).__init__(**dict)
        if self.__class__ is smsinrequest:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(smsinrequest,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(smsinrequest,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_command
        except:
            self.__field_command=CSVSTRING(**{'quotechar': None,                 'terminator': None,                 'default': '#PSRMR='})
        self.__field_command.writetobuffer(buf)
        self.__field_slot.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_command=CSVSTRING(**{'quotechar': None,                 'terminator': None,                 'default': '#PSRMR='})
        self.__field_command.readfrombuffer(buf)
        self.__field_slot=CSVINT(**{'terminator': None})
        self.__field_slot.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_command(self):
        try: self.__field_command
        except:
            self.__field_command=CSVSTRING(**{'quotechar': None,                 'terminator': None,                 'default': '#PSRMR='})
        return self.__field_command.getvalue()

    def __setfield_command(self, value):
        if isinstance(value,CSVSTRING):
            self.__field_command=value
        else:
            self.__field_command=CSVSTRING(value,**{'quotechar': None,                 'terminator': None,                 'default': '#PSRMR='})

    def __delfield_command(self): del self.__field_command

    command=property(__getfield_command, __setfield_command, __delfield_command, None)

    def __getfield_slot(self):
        return self.__field_slot.getvalue()

    def __setfield_slot(self, value):
        if isinstance(value,CSVINT):
            self.__field_slot=value
        else:
            self.__field_slot=CSVINT(value,**{'terminator': None})

    def __delfield_slot(self): del self.__field_slot

    slot=property(__getfield_slot, __setfield_slot, __delfield_slot, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('command', self.__field_command, None)
        yield ('slot', self.__field_slot, None)




class smsinresponse(BaseProtogenClass):
    __fields=['bytes']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(smsinresponse,self).__init__(**dict)
        if self.__class__ is smsinresponse:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(smsinresponse,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(smsinresponse,kwargs)
        if len(args):
            dict2={}
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_bytes=DATA(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_bytes.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_bytes=DATA()
        self.__field_bytes.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_bytes(self):
        return self.__field_bytes.getvalue()

    def __setfield_bytes(self, value):
        if isinstance(value,DATA):
            self.__field_bytes=value
        else:
            self.__field_bytes=DATA(value,)

    def __delfield_bytes(self): del self.__field_bytes

    bytes=property(__getfield_bytes, __setfield_bytes, __delfield_bytes, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('bytes', self.__field_bytes, None)




class fspbslot(BaseProtogenClass):
    __fields=['valid', 'pbbook_index', 'c0', 'timestamp', 'pad']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fspbslot,self).__init__(**dict)
        if self.__class__ is fspbslot:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fspbslot,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fspbslot,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.writetobuffer(buf)
        try: self.__field_pbbook_index
        except:
            self.__field_pbbook_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_pbbook_index.writetobuffer(buf)
        if self.valid:
            try: self.__field_c0
            except:
                self.__field_c0=UINT(**{'sizeinbytes': 2,  'default': 0x0101 })
            self.__field_c0.writetobuffer(buf)
            try: self.__field_timestamp
            except:
                self.__field_timestamp=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
            self.__field_timestamp.writetobuffer(buf)
        else:
            try: self.__field_pad
            except:
                self.__field_pad=DATA(**{'sizeinbytes': 6,  'default': '\x00'*6 })
            self.__field_pad.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.readfrombuffer(buf)
        self.__field_pbbook_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_pbbook_index.readfrombuffer(buf)
        if self.valid:
            self.__field_c0=UINT(**{'sizeinbytes': 2,  'default': 0x0101 })
            self.__field_c0.readfrombuffer(buf)
            self.__field_timestamp=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
            self.__field_timestamp.readfrombuffer(buf)
        else:
            self.__field_pad=DATA(**{'sizeinbytes': 6,  'default': '\x00'*6 })
            self.__field_pad.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_valid(self):
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_valid.getvalue()

    def __setfield_valid(self, value):
        if isinstance(value,UINT):
            self.__field_valid=value
        else:
            self.__field_valid=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_valid(self): del self.__field_valid

    valid=property(__getfield_valid, __setfield_valid, __delfield_valid, "1=valid entry")

    def __getfield_pbbook_index(self):
        try: self.__field_pbbook_index
        except:
            self.__field_pbbook_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_pbbook_index.getvalue()

    def __setfield_pbbook_index(self, value):
        if isinstance(value,UINT):
            self.__field_pbbook_index=value
        else:
            self.__field_pbbook_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_pbbook_index(self): del self.__field_pbbook_index

    pbbook_index=property(__getfield_pbbook_index, __setfield_pbbook_index, __delfield_pbbook_index, "index into pbbook")

    def __getfield_c0(self):
        try: self.__field_c0
        except:
            self.__field_c0=UINT(**{'sizeinbytes': 2,  'default': 0x0101 })
        return self.__field_c0.getvalue()

    def __setfield_c0(self, value):
        if isinstance(value,UINT):
            self.__field_c0=value
        else:
            self.__field_c0=UINT(value,**{'sizeinbytes': 2,  'default': 0x0101 })

    def __delfield_c0(self): del self.__field_c0

    c0=property(__getfield_c0, __setfield_c0, __delfield_c0, None)

    def __getfield_timestamp(self):
        try: self.__field_timestamp
        except:
            self.__field_timestamp=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
        return self.__field_timestamp.getvalue()

    def __setfield_timestamp(self, value):
        if isinstance(value,DateTime):
            self.__field_timestamp=value
        else:
            self.__field_timestamp=DateTime(value,**{'sizeinbytes': 4,  'default': DateTime.now() })

    def __delfield_timestamp(self): del self.__field_timestamp

    timestamp=property(__getfield_timestamp, __setfield_timestamp, __delfield_timestamp, "Last modified date/time")

    def __getfield_pad(self):
        try: self.__field_pad
        except:
            self.__field_pad=DATA(**{'sizeinbytes': 6,  'default': '\x00'*6 })
        return self.__field_pad.getvalue()

    def __setfield_pad(self, value):
        if isinstance(value,DATA):
            self.__field_pad=value
        else:
            self.__field_pad=DATA(value,**{'sizeinbytes': 6,  'default': '\x00'*6 })

    def __delfield_pad(self): del self.__field_pad

    pad=property(__getfield_pad, __setfield_pad, __delfield_pad, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('valid', self.__field_valid, "1=valid entry")
        yield ('pbbook_index', self.__field_pbbook_index, "index into pbbook")
        if self.valid:
            yield ('c0', self.__field_c0, None)
            yield ('timestamp', self.__field_timestamp, "Last modified date/time")
        else:
            yield ('pad', self.__field_pad, None)




class fspbslots(BaseProtogenClass):
    __fields=['slot']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fspbslots,self).__init__(**dict)
        if self.__class__ is fspbslots:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fspbslots,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fspbslots,kwargs)
        if len(args):
            dict2={ 'length': max_pb_slots, 'elementclass': fspbslot }
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_slot=LIST(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_slot
        except:
            self.__field_slot=LIST(**{ 'length': max_pb_slots, 'elementclass': fspbslot })
        self.__field_slot.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_slot=LIST(**{ 'length': max_pb_slots, 'elementclass': fspbslot })
        self.__field_slot.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_slot(self):
        try: self.__field_slot
        except:
            self.__field_slot=LIST(**{ 'length': max_pb_slots, 'elementclass': fspbslot })
        return self.__field_slot.getvalue()

    def __setfield_slot(self, value):
        if isinstance(value,LIST):
            self.__field_slot=value
        else:
            self.__field_slot=LIST(value,**{ 'length': max_pb_slots, 'elementclass': fspbslot })

    def __delfield_slot(self): del self.__field_slot

    slot=property(__getfield_slot, __setfield_slot, __delfield_slot, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('slot', self.__field_slot, None)




class fspbentry(BaseProtogenClass):
    __fields=['valid', 'c1', 'c1', 'main_num_index', 'mobile_num_index', 'home_num_index', 'office_num_index', 'pager_num_index', 'fax_num_index', 'unused_index', 'email_index', 'url_index', 'name', 'group_num', 'nick', 'memo', 'pad']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fspbentry,self).__init__(**dict)
        if self.__class__ is fspbentry:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fspbentry,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fspbentry,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.writetobuffer(buf)
        if self.valid:
            try: self.__field_c1
            except:
                self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0x01BF })
            self.__field_c1.writetobuffer(buf)
        else:
            try: self.__field_c1
            except:
                self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0 })
            self.__field_c1.writetobuffer(buf)
        try: self.__field_main_num_index
        except:
            self.__field_main_num_index=UINT(**{'sizeinbytes': 2,  'default': self.mobile_num_index })
        self.__field_main_num_index.writetobuffer(buf)
        try: self.__field_mobile_num_index
        except:
            self.__field_mobile_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_mobile_num_index.writetobuffer(buf)
        try: self.__field_home_num_index
        except:
            self.__field_home_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_home_num_index.writetobuffer(buf)
        try: self.__field_office_num_index
        except:
            self.__field_office_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_office_num_index.writetobuffer(buf)
        try: self.__field_pager_num_index
        except:
            self.__field_pager_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_pager_num_index.writetobuffer(buf)
        try: self.__field_fax_num_index
        except:
            self.__field_fax_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_fax_num_index.writetobuffer(buf)
        try: self.__field_unused_index
        except:
            self.__field_unused_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_unused_index.writetobuffer(buf)
        try: self.__field_email_index
        except:
            self.__field_email_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_email_index.writetobuffer(buf)
        try: self.__field_url_index
        except:
            self.__field_url_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_url_index.writetobuffer(buf)
        try: self.__field_name
        except:
            self.__field_name=USTRING(**{'sizeinbytes': 31,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_name.writetobuffer(buf)
        try: self.__field_group_num
        except:
            self.__field_group_num=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_group_num.writetobuffer(buf)
        try: self.__field_nick
        except:
            self.__field_nick=USTRING(**{'sizeinbytes': 22,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_nick.writetobuffer(buf)
        try: self.__field_memo
        except:
            self.__field_memo=USTRING(**{'sizeinbytes': 73,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_memo.writetobuffer(buf)
        try: self.__field_pad
        except:
            self.__field_pad=DATA(**{'sizeinbytes': 13,  'default': '\x00'*13 })
        self.__field_pad.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.readfrombuffer(buf)
        if self.valid:
            self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0x01BF })
            self.__field_c1.readfrombuffer(buf)
        else:
            self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0 })
            self.__field_c1.readfrombuffer(buf)
        self.__field_main_num_index=UINT(**{'sizeinbytes': 2,  'default': self.mobile_num_index })
        self.__field_main_num_index.readfrombuffer(buf)
        self.__field_mobile_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_mobile_num_index.readfrombuffer(buf)
        self.__field_home_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_home_num_index.readfrombuffer(buf)
        self.__field_office_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_office_num_index.readfrombuffer(buf)
        self.__field_pager_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_pager_num_index.readfrombuffer(buf)
        self.__field_fax_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_fax_num_index.readfrombuffer(buf)
        self.__field_unused_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_unused_index.readfrombuffer(buf)
        self.__field_email_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_email_index.readfrombuffer(buf)
        self.__field_url_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_url_index.readfrombuffer(buf)
        self.__field_name=USTRING(**{'sizeinbytes': 31,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_name.readfrombuffer(buf)
        self.__field_group_num=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_group_num.readfrombuffer(buf)
        self.__field_nick=USTRING(**{'sizeinbytes': 22,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_nick.readfrombuffer(buf)
        self.__field_memo=USTRING(**{'sizeinbytes': 73,  'pascal': True,                 'terminator': None,                 'default': '' })
        self.__field_memo.readfrombuffer(buf)
        self.__field_pad=DATA(**{'sizeinbytes': 13,  'default': '\x00'*13 })
        self.__field_pad.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_valid(self):
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_valid.getvalue()

    def __setfield_valid(self, value):
        if isinstance(value,UINT):
            self.__field_valid=value
        else:
            self.__field_valid=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_valid(self): del self.__field_valid

    valid=property(__getfield_valid, __setfield_valid, __delfield_valid, "1=valid entry")

    def __getfield_c1(self):
        try: self.__field_c1
        except:
            self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0x01BF })
        return self.__field_c1.getvalue()

    def __setfield_c1(self, value):
        if isinstance(value,UINT):
            self.__field_c1=value
        else:
            self.__field_c1=UINT(value,**{'sizeinbytes': 2,  'default': 0x01BF })

    def __delfield_c1(self): del self.__field_c1

    c1=property(__getfield_c1, __setfield_c1, __delfield_c1, None)

    def __getfield_c1(self):
        try: self.__field_c1
        except:
            self.__field_c1=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_c1.getvalue()

    def __setfield_c1(self, value):
        if isinstance(value,UINT):
            self.__field_c1=value
        else:
            self.__field_c1=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_c1(self): del self.__field_c1

    c1=property(__getfield_c1, __setfield_c1, __delfield_c1, None)

    def __getfield_main_num_index(self):
        try: self.__field_main_num_index
        except:
            self.__field_main_num_index=UINT(**{'sizeinbytes': 2,  'default': self.mobile_num_index })
        return self.__field_main_num_index.getvalue()

    def __setfield_main_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_main_num_index=value
        else:
            self.__field_main_num_index=UINT(value,**{'sizeinbytes': 2,  'default': self.mobile_num_index })

    def __delfield_main_num_index(self): del self.__field_main_num_index

    main_num_index=property(__getfield_main_num_index, __setfield_main_num_index, __delfield_main_num_index, None)

    def __getfield_mobile_num_index(self):
        try: self.__field_mobile_num_index
        except:
            self.__field_mobile_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_mobile_num_index.getvalue()

    def __setfield_mobile_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_mobile_num_index=value
        else:
            self.__field_mobile_num_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_mobile_num_index(self): del self.__field_mobile_num_index

    mobile_num_index=property(__getfield_mobile_num_index, __setfield_mobile_num_index, __delfield_mobile_num_index, None)

    def __getfield_home_num_index(self):
        try: self.__field_home_num_index
        except:
            self.__field_home_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_home_num_index.getvalue()

    def __setfield_home_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_home_num_index=value
        else:
            self.__field_home_num_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_home_num_index(self): del self.__field_home_num_index

    home_num_index=property(__getfield_home_num_index, __setfield_home_num_index, __delfield_home_num_index, None)

    def __getfield_office_num_index(self):
        try: self.__field_office_num_index
        except:
            self.__field_office_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_office_num_index.getvalue()

    def __setfield_office_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_office_num_index=value
        else:
            self.__field_office_num_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_office_num_index(self): del self.__field_office_num_index

    office_num_index=property(__getfield_office_num_index, __setfield_office_num_index, __delfield_office_num_index, None)

    def __getfield_pager_num_index(self):
        try: self.__field_pager_num_index
        except:
            self.__field_pager_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_pager_num_index.getvalue()

    def __setfield_pager_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_pager_num_index=value
        else:
            self.__field_pager_num_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_pager_num_index(self): del self.__field_pager_num_index

    pager_num_index=property(__getfield_pager_num_index, __setfield_pager_num_index, __delfield_pager_num_index, None)

    def __getfield_fax_num_index(self):
        try: self.__field_fax_num_index
        except:
            self.__field_fax_num_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_fax_num_index.getvalue()

    def __setfield_fax_num_index(self, value):
        if isinstance(value,UINT):
            self.__field_fax_num_index=value
        else:
            self.__field_fax_num_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_fax_num_index(self): del self.__field_fax_num_index

    fax_num_index=property(__getfield_fax_num_index, __setfield_fax_num_index, __delfield_fax_num_index, None)

    def __getfield_unused_index(self):
        try: self.__field_unused_index
        except:
            self.__field_unused_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_unused_index.getvalue()

    def __setfield_unused_index(self, value):
        if isinstance(value,UINT):
            self.__field_unused_index=value
        else:
            self.__field_unused_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_unused_index(self): del self.__field_unused_index

    unused_index=property(__getfield_unused_index, __setfield_unused_index, __delfield_unused_index, None)

    def __getfield_email_index(self):
        try: self.__field_email_index
        except:
            self.__field_email_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_email_index.getvalue()

    def __setfield_email_index(self, value):
        if isinstance(value,UINT):
            self.__field_email_index=value
        else:
            self.__field_email_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_email_index(self): del self.__field_email_index

    email_index=property(__getfield_email_index, __setfield_email_index, __delfield_email_index, None)

    def __getfield_url_index(self):
        try: self.__field_url_index
        except:
            self.__field_url_index=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_url_index.getvalue()

    def __setfield_url_index(self, value):
        if isinstance(value,UINT):
            self.__field_url_index=value
        else:
            self.__field_url_index=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_url_index(self): del self.__field_url_index

    url_index=property(__getfield_url_index, __setfield_url_index, __delfield_url_index, None)

    def __getfield_name(self):
        try: self.__field_name
        except:
            self.__field_name=USTRING(**{'sizeinbytes': 31,  'pascal': True,                 'terminator': None,                 'default': '' })
        return self.__field_name.getvalue()

    def __setfield_name(self, value):
        if isinstance(value,USTRING):
            self.__field_name=value
        else:
            self.__field_name=USTRING(value,**{'sizeinbytes': 31,  'pascal': True,                 'terminator': None,                 'default': '' })

    def __delfield_name(self): del self.__field_name

    name=property(__getfield_name, __setfield_name, __delfield_name, None)

    def __getfield_group_num(self):
        try: self.__field_group_num
        except:
            self.__field_group_num=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_group_num.getvalue()

    def __setfield_group_num(self, value):
        if isinstance(value,UINT):
            self.__field_group_num=value
        else:
            self.__field_group_num=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_group_num(self): del self.__field_group_num

    group_num=property(__getfield_group_num, __setfield_group_num, __delfield_group_num, None)

    def __getfield_nick(self):
        try: self.__field_nick
        except:
            self.__field_nick=USTRING(**{'sizeinbytes': 22,  'pascal': True,                 'terminator': None,                 'default': '' })
        return self.__field_nick.getvalue()

    def __setfield_nick(self, value):
        if isinstance(value,USTRING):
            self.__field_nick=value
        else:
            self.__field_nick=USTRING(value,**{'sizeinbytes': 22,  'pascal': True,                 'terminator': None,                 'default': '' })

    def __delfield_nick(self): del self.__field_nick

    nick=property(__getfield_nick, __setfield_nick, __delfield_nick, None)

    def __getfield_memo(self):
        try: self.__field_memo
        except:
            self.__field_memo=USTRING(**{'sizeinbytes': 73,  'pascal': True,                 'terminator': None,                 'default': '' })
        return self.__field_memo.getvalue()

    def __setfield_memo(self, value):
        if isinstance(value,USTRING):
            self.__field_memo=value
        else:
            self.__field_memo=USTRING(value,**{'sizeinbytes': 73,  'pascal': True,                 'terminator': None,                 'default': '' })

    def __delfield_memo(self): del self.__field_memo

    memo=property(__getfield_memo, __setfield_memo, __delfield_memo, None)

    def __getfield_pad(self):
        try: self.__field_pad
        except:
            self.__field_pad=DATA(**{'sizeinbytes': 13,  'default': '\x00'*13 })
        return self.__field_pad.getvalue()

    def __setfield_pad(self, value):
        if isinstance(value,DATA):
            self.__field_pad=value
        else:
            self.__field_pad=DATA(value,**{'sizeinbytes': 13,  'default': '\x00'*13 })

    def __delfield_pad(self): del self.__field_pad

    pad=property(__getfield_pad, __setfield_pad, __delfield_pad, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('valid', self.__field_valid, "1=valid entry")
        if self.valid:
            yield ('c1', self.__field_c1, None)
        else:
            yield ('c1', self.__field_c1, None)
        yield ('main_num_index', self.__field_main_num_index, None)
        yield ('mobile_num_index', self.__field_mobile_num_index, None)
        yield ('home_num_index', self.__field_home_num_index, None)
        yield ('office_num_index', self.__field_office_num_index, None)
        yield ('pager_num_index', self.__field_pager_num_index, None)
        yield ('fax_num_index', self.__field_fax_num_index, None)
        yield ('unused_index', self.__field_unused_index, None)
        yield ('email_index', self.__field_email_index, None)
        yield ('url_index', self.__field_url_index, None)
        yield ('name', self.__field_name, None)
        yield ('group_num', self.__field_group_num, None)
        yield ('nick', self.__field_nick, None)
        yield ('memo', self.__field_memo, None)
        yield ('pad', self.__field_pad, None)




class fspbbook(BaseProtogenClass):
    __fields=['entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fspbbook,self).__init__(**dict)
        if self.__class__ is fspbbook:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fspbbook,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fspbbook,kwargs)
        if len(args):
            dict2={ 'length': max_pb_entries,               'elementclass': fspbentry,               'createdefault': True }
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_entry=LIST(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'length': max_pb_entries,               'elementclass': fspbentry,               'createdefault': True })
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_entry=LIST(**{ 'length': max_pb_entries,               'elementclass': fspbentry,               'createdefault': True })
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_entry(self):
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'length': max_pb_entries,               'elementclass': fspbentry,               'createdefault': True })
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,LIST):
            self.__field_entry=value
        else:
            self.__field_entry=LIST(value,**{ 'length': max_pb_entries,               'elementclass': fspbentry,               'createdefault': True })

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('entry', self.__field_entry, None)




class fsnumber(BaseProtogenClass):
    __fields=['valid', 'c0', 'name', 'number_type']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fsnumber,self).__init__(**dict)
        if self.__class__ is fsnumber:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fsnumber,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fsnumber,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_valid.writetobuffer(buf)
        try: self.__field_c0
        except:
            self.__field_c0=UINT(**{'sizeinbytes': 4,  'default': 0 })
        self.__field_c0.writetobuffer(buf)
        try: self.__field_name
        except:
            self.__field_name=USTRING(**{'sizeinbytes': 74,  'pascal': True,                  'terminator': None,                  'default': '' })
        self.__field_name.writetobuffer(buf)
        try: self.__field_number_type
        except:
            self.__field_number_type=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_number_type.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_valid=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_valid.readfrombuffer(buf)
        self.__field_c0=UINT(**{'sizeinbytes': 4,  'default': 0 })
        self.__field_c0.readfrombuffer(buf)
        self.__field_name=USTRING(**{'sizeinbytes': 74,  'pascal': True,                  'terminator': None,                  'default': '' })
        self.__field_name.readfrombuffer(buf)
        self.__field_number_type=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_number_type.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_valid(self):
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_valid.getvalue()

    def __setfield_valid(self, value):
        if isinstance(value,UINT):
            self.__field_valid=value
        else:
            self.__field_valid=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_valid(self): del self.__field_valid

    valid=property(__getfield_valid, __setfield_valid, __delfield_valid, "1=valid entry")

    def __getfield_c0(self):
        try: self.__field_c0
        except:
            self.__field_c0=UINT(**{'sizeinbytes': 4,  'default': 0 })
        return self.__field_c0.getvalue()

    def __setfield_c0(self, value):
        if isinstance(value,UINT):
            self.__field_c0=value
        else:
            self.__field_c0=UINT(value,**{'sizeinbytes': 4,  'default': 0 })

    def __delfield_c0(self): del self.__field_c0

    c0=property(__getfield_c0, __setfield_c0, __delfield_c0, None)

    def __getfield_name(self):
        try: self.__field_name
        except:
            self.__field_name=USTRING(**{'sizeinbytes': 74,  'pascal': True,                  'terminator': None,                  'default': '' })
        return self.__field_name.getvalue()

    def __setfield_name(self, value):
        if isinstance(value,USTRING):
            self.__field_name=value
        else:
            self.__field_name=USTRING(value,**{'sizeinbytes': 74,  'pascal': True,                  'terminator': None,                  'default': '' })

    def __delfield_name(self): del self.__field_name

    name=property(__getfield_name, __setfield_name, __delfield_name, None)

    def __getfield_number_type(self):
        try: self.__field_number_type
        except:
            self.__field_number_type=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_number_type.getvalue()

    def __setfield_number_type(self, value):
        if isinstance(value,UINT):
            self.__field_number_type=value
        else:
            self.__field_number_type=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_number_type(self): del self.__field_number_type

    number_type=property(__getfield_number_type, __setfield_number_type, __delfield_number_type, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('valid', self.__field_valid, "1=valid entry")
        yield ('c0', self.__field_c0, None)
        yield ('name', self.__field_name, None)
        yield ('number_type', self.__field_number_type, None)




class fsnumbers(BaseProtogenClass):
    __fields=['entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(fsnumbers,self).__init__(**dict)
        if self.__class__ is fsnumbers:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(fsnumbers,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(fsnumbers,kwargs)
        if len(args):
            dict2={ 'length': max_number_entries,              'elementclass': fsnumber,              'createdefault': True }
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_entry=LIST(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'length': max_number_entries,              'elementclass': fsnumber,              'createdefault': True })
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_entry=LIST(**{ 'length': max_number_entries,              'elementclass': fsnumber,              'createdefault': True })
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_entry(self):
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'length': max_number_entries,              'elementclass': fsnumber,              'createdefault': True })
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,LIST):
            self.__field_entry=value
        else:
            self.__field_entry=LIST(value,**{ 'length': max_number_entries,              'elementclass': fsnumber,              'createdefault': True })

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('entry', self.__field_entry, None)




class amsregistry(BaseProtogenClass):
    __fields=['dunno0', 'info', 'dunno1', 'strings', 'dunno2', 'nfiles', 'dunno3']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(amsregistry,self).__init__(**dict)
        if self.__class__ is amsregistry:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(amsregistry,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(amsregistry,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_dunno0.writetobuffer(buf)
        self.__field_info.writetobuffer(buf)
        self.__field_dunno1.writetobuffer(buf)
        self.__field_strings.writetobuffer(buf)
        self.__field_dunno2.writetobuffer(buf)
        self.__field_nfiles.writetobuffer(buf)
        self.__field_dunno3.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_dunno0=DATA(**{'sizeinbytes': 900})
        self.__field_dunno0.readfrombuffer(buf)
        self.__field_info=LIST(**{'elementclass': _gen_p_samsungsphm300_197, 'length': 320})
        self.__field_info.readfrombuffer(buf)
        self.__field_dunno1=DATA(**{'sizeinbytes': 2000})
        self.__field_dunno1.readfrombuffer(buf)
        self.__field_strings=DATA(**{'sizeinbytes': 23000})
        self.__field_strings.readfrombuffer(buf)
        self.__field_dunno2=UINT(**{'sizeinbytes': 4})
        self.__field_dunno2.readfrombuffer(buf)
        self.__field_nfiles=UINT(**{'sizeinbytes': 2})
        self.__field_nfiles.readfrombuffer(buf)
        self.__field_dunno3=DATA()
        self.__field_dunno3.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_dunno0(self):
        return self.__field_dunno0.getvalue()

    def __setfield_dunno0(self, value):
        if isinstance(value,DATA):
            self.__field_dunno0=value
        else:
            self.__field_dunno0=DATA(value,**{'sizeinbytes': 900})

    def __delfield_dunno0(self): del self.__field_dunno0

    dunno0=property(__getfield_dunno0, __setfield_dunno0, __delfield_dunno0, None)

    def __getfield_info(self):
        return self.__field_info.getvalue()

    def __setfield_info(self, value):
        if isinstance(value,LIST):
            self.__field_info=value
        else:
            self.__field_info=LIST(value,**{'elementclass': _gen_p_samsungsphm300_197, 'length': 320})

    def __delfield_info(self): del self.__field_info

    info=property(__getfield_info, __setfield_info, __delfield_info, None)

    def __getfield_dunno1(self):
        return self.__field_dunno1.getvalue()

    def __setfield_dunno1(self, value):
        if isinstance(value,DATA):
            self.__field_dunno1=value
        else:
            self.__field_dunno1=DATA(value,**{'sizeinbytes': 2000})

    def __delfield_dunno1(self): del self.__field_dunno1

    dunno1=property(__getfield_dunno1, __setfield_dunno1, __delfield_dunno1, None)

    def __getfield_strings(self):
        return self.__field_strings.getvalue()

    def __setfield_strings(self, value):
        if isinstance(value,DATA):
            self.__field_strings=value
        else:
            self.__field_strings=DATA(value,**{'sizeinbytes': 23000})

    def __delfield_strings(self): del self.__field_strings

    strings=property(__getfield_strings, __setfield_strings, __delfield_strings, None)

    def __getfield_dunno2(self):
        return self.__field_dunno2.getvalue()

    def __setfield_dunno2(self, value):
        if isinstance(value,UINT):
            self.__field_dunno2=value
        else:
            self.__field_dunno2=UINT(value,**{'sizeinbytes': 4})

    def __delfield_dunno2(self): del self.__field_dunno2

    dunno2=property(__getfield_dunno2, __setfield_dunno2, __delfield_dunno2, None)

    def __getfield_nfiles(self):
        return self.__field_nfiles.getvalue()

    def __setfield_nfiles(self, value):
        if isinstance(value,UINT):
            self.__field_nfiles=value
        else:
            self.__field_nfiles=UINT(value,**{'sizeinbytes': 2})

    def __delfield_nfiles(self): del self.__field_nfiles

    nfiles=property(__getfield_nfiles, __setfield_nfiles, __delfield_nfiles, None)

    def __getfield_dunno3(self):
        return self.__field_dunno3.getvalue()

    def __setfield_dunno3(self, value):
        if isinstance(value,DATA):
            self.__field_dunno3=value
        else:
            self.__field_dunno3=DATA(value,)

    def __delfield_dunno3(self): del self.__field_dunno3

    dunno3=property(__getfield_dunno3, __setfield_dunno3, __delfield_dunno3, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('dunno0', self.__field_dunno0, None)
        yield ('info', self.__field_info, None)
        yield ('dunno1', self.__field_dunno1, None)
        yield ('strings', self.__field_strings, None)
        yield ('dunno2', self.__field_dunno2, None)
        yield ('nfiles', self.__field_nfiles, None)
        yield ('dunno3', self.__field_dunno3, None)

    def getstring(self, ptr):
        # Return the 0-terminated string starting index ptr from field strings
        try:
            return self.strings[ptr:self.strings.index('\x00', ptr)]
        except ValueError:
            return ''
    def dir(self, idx):
        return self.getstring(self.info[idx].dir_ptr)
    def name(self, idx):
        return self.getstring(self.info[idx].name_ptr)
    def mimetype(self, idx):
        return self.getstring(self.info[idx].mimetype_ptr)
    def version(self, idx):
        return self.getstring(self.info[idx].version_ptr)
    def vendor(self, idx):
        return self.getstring(self.info[idx].vendor_ptr)
    def filename(self, idx):
        # return the file name of this item
        global exts
        return self.name(idx)+exts.get(self.mimetype(idx), '')
    def filepath(self, idx):
        # return the full pathname of this item
        return 'ams/'+self.dir(idx)
    def origin(self, idx):
        # return the origin based on the file type
        global origins
        return origins.get(self.info[idx].filetype, None)




class _gen_p_samsungsphm300_197(BaseProtogenClass):
    'Anonymous inner class'
    __fields=['dir_ptr', 'num2', 'name_ptr', 'version_ptr', 'vendor_ptr', 'downloaddomain_ptr', 'num7', 'filetype', 'num8', 'mimetype_ptr', 'num12']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(_gen_p_samsungsphm300_197,self).__init__(**dict)
        if self.__class__ is _gen_p_samsungsphm300_197:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(_gen_p_samsungsphm300_197,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(_gen_p_samsungsphm300_197,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_dir_ptr.writetobuffer(buf)
        self.__field_num2.writetobuffer(buf)
        self.__field_name_ptr.writetobuffer(buf)
        self.__field_version_ptr.writetobuffer(buf)
        self.__field_vendor_ptr.writetobuffer(buf)
        self.__field_downloaddomain_ptr.writetobuffer(buf)
        self.__field_num7.writetobuffer(buf)
        self.__field_filetype.writetobuffer(buf)
        self.__field_num8.writetobuffer(buf)
        self.__field_mimetype_ptr.writetobuffer(buf)
        self.__field_num12.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_dir_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_dir_ptr.readfrombuffer(buf)
        self.__field_num2=UINT(**{'sizeinbytes': 2})
        self.__field_num2.readfrombuffer(buf)
        self.__field_name_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_name_ptr.readfrombuffer(buf)
        self.__field_version_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_version_ptr.readfrombuffer(buf)
        self.__field_vendor_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_vendor_ptr.readfrombuffer(buf)
        self.__field_downloaddomain_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_downloaddomain_ptr.readfrombuffer(buf)
        self.__field_num7=DATA(**{'sizeinbytes': 8})
        self.__field_num7.readfrombuffer(buf)
        self.__field_filetype=UINT(**{'sizeinbytes': 2})
        self.__field_filetype.readfrombuffer(buf)
        self.__field_num8=DATA(**{'sizeinbytes': 2})
        self.__field_num8.readfrombuffer(buf)
        self.__field_mimetype_ptr=UINT(**{'sizeinbytes': 2})
        self.__field_mimetype_ptr.readfrombuffer(buf)
        self.__field_num12=DATA(**{'sizeinbytes': 10})
        self.__field_num12.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_dir_ptr(self):
        return self.__field_dir_ptr.getvalue()

    def __setfield_dir_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_dir_ptr=value
        else:
            self.__field_dir_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_dir_ptr(self): del self.__field_dir_ptr

    dir_ptr=property(__getfield_dir_ptr, __setfield_dir_ptr, __delfield_dir_ptr, None)

    def __getfield_num2(self):
        return self.__field_num2.getvalue()

    def __setfield_num2(self, value):
        if isinstance(value,UINT):
            self.__field_num2=value
        else:
            self.__field_num2=UINT(value,**{'sizeinbytes': 2})

    def __delfield_num2(self): del self.__field_num2

    num2=property(__getfield_num2, __setfield_num2, __delfield_num2, None)

    def __getfield_name_ptr(self):
        return self.__field_name_ptr.getvalue()

    def __setfield_name_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_name_ptr=value
        else:
            self.__field_name_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_name_ptr(self): del self.__field_name_ptr

    name_ptr=property(__getfield_name_ptr, __setfield_name_ptr, __delfield_name_ptr, None)

    def __getfield_version_ptr(self):
        return self.__field_version_ptr.getvalue()

    def __setfield_version_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_version_ptr=value
        else:
            self.__field_version_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_version_ptr(self): del self.__field_version_ptr

    version_ptr=property(__getfield_version_ptr, __setfield_version_ptr, __delfield_version_ptr, None)

    def __getfield_vendor_ptr(self):
        return self.__field_vendor_ptr.getvalue()

    def __setfield_vendor_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_vendor_ptr=value
        else:
            self.__field_vendor_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_vendor_ptr(self): del self.__field_vendor_ptr

    vendor_ptr=property(__getfield_vendor_ptr, __setfield_vendor_ptr, __delfield_vendor_ptr, None)

    def __getfield_downloaddomain_ptr(self):
        return self.__field_downloaddomain_ptr.getvalue()

    def __setfield_downloaddomain_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_downloaddomain_ptr=value
        else:
            self.__field_downloaddomain_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_downloaddomain_ptr(self): del self.__field_downloaddomain_ptr

    downloaddomain_ptr=property(__getfield_downloaddomain_ptr, __setfield_downloaddomain_ptr, __delfield_downloaddomain_ptr, None)

    def __getfield_num7(self):
        return self.__field_num7.getvalue()

    def __setfield_num7(self, value):
        if isinstance(value,DATA):
            self.__field_num7=value
        else:
            self.__field_num7=DATA(value,**{'sizeinbytes': 8})

    def __delfield_num7(self): del self.__field_num7

    num7=property(__getfield_num7, __setfield_num7, __delfield_num7, None)

    def __getfield_filetype(self):
        return self.__field_filetype.getvalue()

    def __setfield_filetype(self, value):
        if isinstance(value,UINT):
            self.__field_filetype=value
        else:
            self.__field_filetype=UINT(value,**{'sizeinbytes': 2})

    def __delfield_filetype(self): del self.__field_filetype

    filetype=property(__getfield_filetype, __setfield_filetype, __delfield_filetype, "12: Ringer, 13 Screen Saver, 15 Apps")

    def __getfield_num8(self):
        return self.__field_num8.getvalue()

    def __setfield_num8(self, value):
        if isinstance(value,DATA):
            self.__field_num8=value
        else:
            self.__field_num8=DATA(value,**{'sizeinbytes': 2})

    def __delfield_num8(self): del self.__field_num8

    num8=property(__getfield_num8, __setfield_num8, __delfield_num8, None)

    def __getfield_mimetype_ptr(self):
        return self.__field_mimetype_ptr.getvalue()

    def __setfield_mimetype_ptr(self, value):
        if isinstance(value,UINT):
            self.__field_mimetype_ptr=value
        else:
            self.__field_mimetype_ptr=UINT(value,**{'sizeinbytes': 2})

    def __delfield_mimetype_ptr(self): del self.__field_mimetype_ptr

    mimetype_ptr=property(__getfield_mimetype_ptr, __setfield_mimetype_ptr, __delfield_mimetype_ptr, None)

    def __getfield_num12(self):
        return self.__field_num12.getvalue()

    def __setfield_num12(self, value):
        if isinstance(value,DATA):
            self.__field_num12=value
        else:
            self.__field_num12=DATA(value,**{'sizeinbytes': 10})

    def __delfield_num12(self): del self.__field_num12

    num12=property(__getfield_num12, __setfield_num12, __delfield_num12, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('dir_ptr', self.__field_dir_ptr, None)
        yield ('num2', self.__field_num2, None)
        yield ('name_ptr', self.__field_name_ptr, None)
        yield ('version_ptr', self.__field_version_ptr, None)
        yield ('vendor_ptr', self.__field_vendor_ptr, None)
        yield ('downloaddomain_ptr', self.__field_downloaddomain_ptr, None)
        yield ('num7', self.__field_num7, None)
        yield ('filetype', self.__field_filetype, "12: Ringer, 13 Screen Saver, 15 Apps")
        yield ('num8', self.__field_num8, None)
        yield ('mimetype_ptr', self.__field_mimetype_ptr, None)
        yield ('num12', self.__field_num12, None)




class CamFile(BaseProtogenClass):
    __fields=['dunno0', 'dunno1', 'caption', 'dunno2', 'dunno3', 'datetime', 'dunno4', 'pad', 'jpeg']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(CamFile,self).__init__(**dict)
        if self.__class__ is CamFile:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(CamFile,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(CamFile,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        self.__field_dunno0.writetobuffer(buf)
        self.__field_dunno1.writetobuffer(buf)
        self.__field_caption.writetobuffer(buf)
        self.__field_dunno2.writetobuffer(buf)
        self.__field_dunno3.writetobuffer(buf)
        self.__field_datetime.writetobuffer(buf)
        self.__field_dunno4.writetobuffer(buf)
        self.__field_pad.writetobuffer(buf)
        self.__field_jpeg.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_dunno0=UINT(**{'sizeinbytes': 4})
        self.__field_dunno0.readfrombuffer(buf)
        self.__field_dunno1=UINT(**{'sizeinbytes': 1})
        self.__field_dunno1.readfrombuffer(buf)
        self.__field_caption=USTRING(**{'sizeinbytes': 16,  'pascal': True,                 'terminator': None})
        self.__field_caption.readfrombuffer(buf)
        self.__field_dunno2=UINT(**{'sizeinbytes': 1})
        self.__field_dunno2.readfrombuffer(buf)
        self.__field_dunno3=DATA(**{'sizeinbytes': 2})
        self.__field_dunno3.readfrombuffer(buf)
        self.__field_datetime=DateTime(**{'sizeinbytes': 4})
        self.__field_datetime.readfrombuffer(buf)
        self.__field_dunno4=UINT(**{'sizeinbytes': 1})
        self.__field_dunno4.readfrombuffer(buf)
        self.__field_pad=DATA(**{'sizeinbytes': 99})
        self.__field_pad.readfrombuffer(buf)
        self.__field_jpeg=DATA()
        self.__field_jpeg.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_dunno0(self):
        return self.__field_dunno0.getvalue()

    def __setfield_dunno0(self, value):
        if isinstance(value,UINT):
            self.__field_dunno0=value
        else:
            self.__field_dunno0=UINT(value,**{'sizeinbytes': 4})

    def __delfield_dunno0(self): del self.__field_dunno0

    dunno0=property(__getfield_dunno0, __setfield_dunno0, __delfield_dunno0, None)

    def __getfield_dunno1(self):
        return self.__field_dunno1.getvalue()

    def __setfield_dunno1(self, value):
        if isinstance(value,UINT):
            self.__field_dunno1=value
        else:
            self.__field_dunno1=UINT(value,**{'sizeinbytes': 1})

    def __delfield_dunno1(self): del self.__field_dunno1

    dunno1=property(__getfield_dunno1, __setfield_dunno1, __delfield_dunno1, None)

    def __getfield_caption(self):
        return self.__field_caption.getvalue()

    def __setfield_caption(self, value):
        if isinstance(value,USTRING):
            self.__field_caption=value
        else:
            self.__field_caption=USTRING(value,**{'sizeinbytes': 16,  'pascal': True,                 'terminator': None})

    def __delfield_caption(self): del self.__field_caption

    caption=property(__getfield_caption, __setfield_caption, __delfield_caption, None)

    def __getfield_dunno2(self):
        return self.__field_dunno2.getvalue()

    def __setfield_dunno2(self, value):
        if isinstance(value,UINT):
            self.__field_dunno2=value
        else:
            self.__field_dunno2=UINT(value,**{'sizeinbytes': 1})

    def __delfield_dunno2(self): del self.__field_dunno2

    dunno2=property(__getfield_dunno2, __setfield_dunno2, __delfield_dunno2, None)

    def __getfield_dunno3(self):
        return self.__field_dunno3.getvalue()

    def __setfield_dunno3(self, value):
        if isinstance(value,DATA):
            self.__field_dunno3=value
        else:
            self.__field_dunno3=DATA(value,**{'sizeinbytes': 2})

    def __delfield_dunno3(self): del self.__field_dunno3

    dunno3=property(__getfield_dunno3, __setfield_dunno3, __delfield_dunno3, None)

    def __getfield_datetime(self):
        return self.__field_datetime.getvalue()

    def __setfield_datetime(self, value):
        if isinstance(value,DateTime):
            self.__field_datetime=value
        else:
            self.__field_datetime=DateTime(value,**{'sizeinbytes': 4})

    def __delfield_datetime(self): del self.__field_datetime

    datetime=property(__getfield_datetime, __setfield_datetime, __delfield_datetime, None)

    def __getfield_dunno4(self):
        return self.__field_dunno4.getvalue()

    def __setfield_dunno4(self, value):
        if isinstance(value,UINT):
            self.__field_dunno4=value
        else:
            self.__field_dunno4=UINT(value,**{'sizeinbytes': 1})

    def __delfield_dunno4(self): del self.__field_dunno4

    dunno4=property(__getfield_dunno4, __setfield_dunno4, __delfield_dunno4, None)

    def __getfield_pad(self):
        return self.__field_pad.getvalue()

    def __setfield_pad(self, value):
        if isinstance(value,DATA):
            self.__field_pad=value
        else:
            self.__field_pad=DATA(value,**{'sizeinbytes': 99})

    def __delfield_pad(self): del self.__field_pad

    pad=property(__getfield_pad, __setfield_pad, __delfield_pad, None)

    def __getfield_jpeg(self):
        return self.__field_jpeg.getvalue()

    def __setfield_jpeg(self, value):
        if isinstance(value,DATA):
            self.__field_jpeg=value
        else:
            self.__field_jpeg=DATA(value,)

    def __delfield_jpeg(self): del self.__field_jpeg

    jpeg=property(__getfield_jpeg, __setfield_jpeg, __delfield_jpeg, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('dunno0', self.__field_dunno0, None)
        yield ('dunno1', self.__field_dunno1, None)
        yield ('caption', self.__field_caption, None)
        yield ('dunno2', self.__field_dunno2, None)
        yield ('dunno3', self.__field_dunno3, None)
        yield ('datetime', self.__field_datetime, None)
        yield ('dunno4', self.__field_dunno4, None)
        yield ('pad', self.__field_pad, None)
        yield ('jpeg', self.__field_jpeg, None)

    def _filename(self):
        return '%(year)04d%(month)02d%(day)02d_%(name)s.jpg'%\
               { 'year': self.datetime[0],
                 'month': self.datetime[1],
                 'day': self.datetime[2],
                 'name': self.caption,
                 }
    filename=property(fget=_filename)
    def save(self, filename=None):
        # save the jpeg data to a file        
        return file(filename if filename else self.filename, 'wb').write(self.jpeg)




class IndexSlot(BaseProtogenClass):
    __fields=['valid', 'group', 'index']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(IndexSlot,self).__init__(**dict)
        if self.__class__ is IndexSlot:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(IndexSlot,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(IndexSlot,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.writetobuffer(buf)
        try: self.__field_group
        except:
            self.__field_group=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_group.writetobuffer(buf)
        try: self.__field_index
        except:
            self.__field_index=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_index.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_valid.readfrombuffer(buf)
        self.__field_group=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_group.readfrombuffer(buf)
        self.__field_index=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_index.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_valid(self):
        try: self.__field_valid
        except:
            self.__field_valid=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_valid.getvalue()

    def __setfield_valid(self, value):
        if isinstance(value,UINT):
            self.__field_valid=value
        else:
            self.__field_valid=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_valid(self): del self.__field_valid

    valid=property(__getfield_valid, __setfield_valid, __delfield_valid, "=1 if valid slot")

    def __getfield_group(self):
        try: self.__field_group
        except:
            self.__field_group=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_group.getvalue()

    def __setfield_group(self, value):
        if isinstance(value,UINT):
            self.__field_group=value
        else:
            self.__field_group=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_group(self): del self.__field_group

    group=property(__getfield_group, __setfield_group, __delfield_group, "Group Index")

    def __getfield_index(self):
        try: self.__field_index
        except:
            self.__field_index=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_index.getvalue()

    def __setfield_index(self, value):
        if isinstance(value,UINT):
            self.__field_index=value
        else:
            self.__field_index=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_index(self): del self.__field_index

    index=property(__getfield_index, __setfield_index, __delfield_index, "Media Index")

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('valid', self.__field_valid, "=1 if valid slot")
        yield ('group', self.__field_group, "Group Index")
        yield ('index', self.__field_index, "Media Index")




class IndexFile(BaseProtogenClass):
    __fields=['entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(IndexFile,self).__init__(**dict)
        if self.__class__ is IndexFile:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(IndexFile,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(IndexFile,kwargs)
        if len(args):
            dict2={ 'elementclass': IndexSlot,             'length': max_media_index_entries,             'createdefault': True }
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_entry=LIST(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'elementclass': IndexSlot,             'length': max_media_index_entries,             'createdefault': True })
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_entry=LIST(**{ 'elementclass': IndexSlot,             'length': max_media_index_entries,             'createdefault': True })
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_entry(self):
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'elementclass': IndexSlot,             'length': max_media_index_entries,             'createdefault': True })
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,LIST):
            self.__field_entry=value
        else:
            self.__field_entry=LIST(value,**{ 'elementclass': IndexSlot,             'length': max_media_index_entries,             'createdefault': True })

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('entry', self.__field_entry, None)




class Group(BaseProtogenClass):
    __fields=['num0', 'num1', 'namelen', 'namestr', 'num5', 'dunno', 'nume3', 'datetime', 'num4']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(Group,self).__init__(**dict)
        if self.__class__ is Group:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(Group,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(Group,kwargs)
        if len(args): raise TypeError('Unexpected arguments supplied: '+`args`)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_num0
        except:
            self.__field_num0=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_num0.writetobuffer(buf)
        try: self.__field_num1
        except:
            self.__field_num1=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        self.__field_num1.writetobuffer(buf)
        try: self.__field_namelen
        except:
            self.__field_namelen=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_namelen.writetobuffer(buf)
        try: self.__field_namestr
        except:
            self.__field_namestr=USTRING(**{'sizeinbytes': 12,  'terminator': None,                 'default': '' })
        self.__field_namestr.writetobuffer(buf)
        try: self.__field_num5
        except:
            self.__field_num5=UINT(**{'sizeinbytes': 1,  'default': 0x30 if self.num0 else 0 })
        self.__field_num5.writetobuffer(buf)
        try: self.__field_dunno
        except:
            self.__field_dunno=DATA(**{'sizeinbytes': 8,  'default': '\x00'*8 })
        self.__field_dunno.writetobuffer(buf)
        try: self.__field_nume3
        except:
            self.__field_nume3=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        self.__field_nume3.writetobuffer(buf)
        if self.num0:
            try: self.__field_datetime
            except:
                self.__field_datetime=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
            self.__field_datetime.writetobuffer(buf)
        else:
            try: self.__field_num4
            except:
                self.__field_num4=UINT(**{'sizeinbytes': 4,  'default': 0 })
            self.__field_num4.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_num0=UINT(**{'sizeinbytes': 1,  'default': 0 })
        self.__field_num0.readfrombuffer(buf)
        self.__field_num1=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        self.__field_num1.readfrombuffer(buf)
        self.__field_namelen=UINT(**{'sizeinbytes': 2,  'default': 0 })
        self.__field_namelen.readfrombuffer(buf)
        self.__field_namestr=USTRING(**{'sizeinbytes': 12,  'terminator': None,                 'default': '' })
        self.__field_namestr.readfrombuffer(buf)
        self.__field_num5=UINT(**{'sizeinbytes': 1,  'default': 0x30 if self.num0 else 0 })
        self.__field_num5.readfrombuffer(buf)
        self.__field_dunno=DATA(**{'sizeinbytes': 8,  'default': '\x00'*8 })
        self.__field_dunno.readfrombuffer(buf)
        self.__field_nume3=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        self.__field_nume3.readfrombuffer(buf)
        if self.num0:
            self.__field_datetime=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
            self.__field_datetime.readfrombuffer(buf)
        else:
            self.__field_num4=UINT(**{'sizeinbytes': 4,  'default': 0 })
            self.__field_num4.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_num0(self):
        try: self.__field_num0
        except:
            self.__field_num0=UINT(**{'sizeinbytes': 1,  'default': 0 })
        return self.__field_num0.getvalue()

    def __setfield_num0(self, value):
        if isinstance(value,UINT):
            self.__field_num0=value
        else:
            self.__field_num0=UINT(value,**{'sizeinbytes': 1,  'default': 0 })

    def __delfield_num0(self): del self.__field_num0

    num0=property(__getfield_num0, __setfield_num0, __delfield_num0, None)

    def __getfield_num1(self):
        try: self.__field_num1
        except:
            self.__field_num1=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        return self.__field_num1.getvalue()

    def __setfield_num1(self, value):
        if isinstance(value,UINT):
            self.__field_num1=value
        else:
            self.__field_num1=UINT(value,**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })

    def __delfield_num1(self): del self.__field_num1

    num1=property(__getfield_num1, __setfield_num1, __delfield_num1, None)

    def __getfield_namelen(self):
        try: self.__field_namelen
        except:
            self.__field_namelen=UINT(**{'sizeinbytes': 2,  'default': 0 })
        return self.__field_namelen.getvalue()

    def __setfield_namelen(self, value):
        if isinstance(value,UINT):
            self.__field_namelen=value
        else:
            self.__field_namelen=UINT(value,**{'sizeinbytes': 2,  'default': 0 })

    def __delfield_namelen(self): del self.__field_namelen

    namelen=property(__getfield_namelen, __setfield_namelen, __delfield_namelen, None)

    def __getfield_namestr(self):
        try: self.__field_namestr
        except:
            self.__field_namestr=USTRING(**{'sizeinbytes': 12,  'terminator': None,                 'default': '' })
        return self.__field_namestr.getvalue()

    def __setfield_namestr(self, value):
        if isinstance(value,USTRING):
            self.__field_namestr=value
        else:
            self.__field_namestr=USTRING(value,**{'sizeinbytes': 12,  'terminator': None,                 'default': '' })

    def __delfield_namestr(self): del self.__field_namestr

    namestr=property(__getfield_namestr, __setfield_namestr, __delfield_namestr, None)

    def __getfield_num5(self):
        try: self.__field_num5
        except:
            self.__field_num5=UINT(**{'sizeinbytes': 1,  'default': 0x30 if self.num0 else 0 })
        return self.__field_num5.getvalue()

    def __setfield_num5(self, value):
        if isinstance(value,UINT):
            self.__field_num5=value
        else:
            self.__field_num5=UINT(value,**{'sizeinbytes': 1,  'default': 0x30 if self.num0 else 0 })

    def __delfield_num5(self): del self.__field_num5

    num5=property(__getfield_num5, __setfield_num5, __delfield_num5, None)

    def __getfield_dunno(self):
        try: self.__field_dunno
        except:
            self.__field_dunno=DATA(**{'sizeinbytes': 8,  'default': '\x00'*8 })
        return self.__field_dunno.getvalue()

    def __setfield_dunno(self, value):
        if isinstance(value,DATA):
            self.__field_dunno=value
        else:
            self.__field_dunno=DATA(value,**{'sizeinbytes': 8,  'default': '\x00'*8 })

    def __delfield_dunno(self): del self.__field_dunno

    dunno=property(__getfield_dunno, __setfield_dunno, __delfield_dunno, None)

    def __getfield_nume3(self):
        try: self.__field_nume3
        except:
            self.__field_nume3=UINT(**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })
        return self.__field_nume3.getvalue()

    def __setfield_nume3(self, value):
        if isinstance(value,UINT):
            self.__field_nume3=value
        else:
            self.__field_nume3=UINT(value,**{'sizeinbytes': 1,  'default': 1 if self.num0 else 0 })

    def __delfield_nume3(self): del self.__field_nume3

    nume3=property(__getfield_nume3, __setfield_nume3, __delfield_nume3, None)

    def __getfield_datetime(self):
        try: self.__field_datetime
        except:
            self.__field_datetime=DateTime(**{'sizeinbytes': 4,  'default': DateTime.now() })
        return self.__field_datetime.getvalue()

    def __setfield_datetime(self, value):
        if isinstance(value,DateTime):
            self.__field_datetime=value
        else:
            self.__field_datetime=DateTime(value,**{'sizeinbytes': 4,  'default': DateTime.now() })

    def __delfield_datetime(self): del self.__field_datetime

    datetime=property(__getfield_datetime, __setfield_datetime, __delfield_datetime, None)

    def __getfield_num4(self):
        try: self.__field_num4
        except:
            self.__field_num4=UINT(**{'sizeinbytes': 4,  'default': 0 })
        return self.__field_num4.getvalue()

    def __setfield_num4(self, value):
        if isinstance(value,UINT):
            self.__field_num4=value
        else:
            self.__field_num4=UINT(value,**{'sizeinbytes': 4,  'default': 0 })

    def __delfield_num4(self): del self.__field_num4

    num4=property(__getfield_num4, __setfield_num4, __delfield_num4, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('num0', self.__field_num0, None)
        yield ('num1', self.__field_num1, None)
        yield ('namelen', self.__field_namelen, None)
        yield ('namestr', self.__field_namestr, None)
        yield ('num5', self.__field_num5, None)
        yield ('dunno', self.__field_dunno, None)
        yield ('nume3', self.__field_nume3, None)
        if self.num0:
            yield ('datetime', self.__field_datetime, None)
        else:
            yield ('num4', self.__field_num4, None)

    def _get_name(self):
        return self.namestr[:self.namelen] if self.namelen else ""
    name=property(fget=_get_name)




class GroupFile(BaseProtogenClass):
    __fields=['entry']

    def __init__(self, *args, **kwargs):
        dict={}
        # What was supplied to this function
        dict.update(kwargs)
        # Parent constructor
        super(GroupFile,self).__init__(**dict)
        if self.__class__ is GroupFile:
            self._update(args,dict)


    def getfields(self):
        return self.__fields


    def _update(self, args, kwargs):
        super(GroupFile,self)._update(args,kwargs)
        keys=kwargs.keys()
        for key in keys:
            if key in self.__fields:
                setattr(self, key, kwargs[key])
                del kwargs[key]
        # Were any unrecognized kwargs passed in?
        if __debug__:
            self._complainaboutunusedargs(GroupFile,kwargs)
        if len(args):
            dict2={ 'elementclass': Group,             'length': max_group_entries,             'createdefault': True }
            dict2.update(kwargs)
            kwargs=dict2
            self.__field_entry=LIST(*args,**dict2)
        # Make all P fields that haven't already been constructed


    def writetobuffer(self,buf,autolog=True,logtitle="<written data>"):
        'Writes this packet to the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'elementclass': Group,             'length': max_group_entries,             'createdefault': True })
        self.__field_entry.writetobuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologwrite(buf, logtitle=logtitle)


    def readfrombuffer(self,buf,autolog=True,logtitle="<read data>"):
        'Reads this packet from the supplied buffer'
        self._bufferstartoffset=buf.getcurrentoffset()
        if autolog and self._bufferstartoffset==0: self.autologread(buf, logtitle=logtitle)
        self.__field_entry=LIST(**{ 'elementclass': Group,             'length': max_group_entries,             'createdefault': True })
        self.__field_entry.readfrombuffer(buf)
        self._bufferendoffset=buf.getcurrentoffset()


    def __getfield_entry(self):
        try: self.__field_entry
        except:
            self.__field_entry=LIST(**{ 'elementclass': Group,             'length': max_group_entries,             'createdefault': True })
        return self.__field_entry.getvalue()

    def __setfield_entry(self, value):
        if isinstance(value,LIST):
            self.__field_entry=value
        else:
            self.__field_entry=LIST(value,**{ 'elementclass': Group,             'length': max_group_entries,             'createdefault': True })

    def __delfield_entry(self): del self.__field_entry

    entry=property(__getfield_entry, __setfield_entry, __delfield_entry, None)

    def iscontainer(self):
        return True

    def containerelements(self):
        yield ('entry', self.__field_entry, None)




