Simon C
2005-10-13 05:05:53 UTC
The 8100 supports a new brew protocol for accessing the filesystem in
addition to the old way. I expect other new phones with the same chipset
will support this as well.
The advantage to the user is that it lets them overwrite NVM files,
currently not possible.
I had a look at the way the DebugBrewProtocol was implemented. I'd like to
do something similar for the new protocol that tests an attribute in the
protocol to decide to adjust the class hierarchy to use file functions from
the new protocol class, only implemented functions would be overridden. The
new class and packets would go into the com_brew and p_brew files.
The code to would look something like:
class BrewProtocol(RealBrewProtocol):
"""This is just a wrapper class that allows the manipulation between
RealBrewProtocol and DebugBrewProtocol classes.
"""
def __init__(self):
# if the env var PHONE_FS is set, we're debugging!
phone_path=os.environ.get('PHONE_FS', None)
if __debug__ and phone_path:
print 'Debug Phone File System:',phone_path
# we probably need to do this only once for the whole class,
# but what the heck!
DebugBrewProtocol._fs_path=os.path.normpath(phone_path)
self._update_base_class(self.__class__)
elif getattr(self.protocolclass, "BREW_FILE_SYSTEM", 0) == 2:
self._set_new_brew(self.__class__)
def _set_new_brew(self, klass):
# update the class hierachy to include RealBrewProtocol2 so that
# it's functions override RealBrewProtocol's ones.
_bases=[]
found=False
for e in klass.__bases__:
if e==RealBrewProtocol:
_bases.append(RealBrewProtocol2)
found=True
_bases.append(e)
if found:
klass.__bases__=tuple(_bases)
else:
for e in _bases:
self._set_new_brew(e)
Simon
addition to the old way. I expect other new phones with the same chipset
will support this as well.
The advantage to the user is that it lets them overwrite NVM files,
currently not possible.
I had a look at the way the DebugBrewProtocol was implemented. I'd like to
do something similar for the new protocol that tests an attribute in the
protocol to decide to adjust the class hierarchy to use file functions from
the new protocol class, only implemented functions would be overridden. The
new class and packets would go into the com_brew and p_brew files.
The code to would look something like:
class BrewProtocol(RealBrewProtocol):
"""This is just a wrapper class that allows the manipulation between
RealBrewProtocol and DebugBrewProtocol classes.
"""
def __init__(self):
# if the env var PHONE_FS is set, we're debugging!
phone_path=os.environ.get('PHONE_FS', None)
if __debug__ and phone_path:
print 'Debug Phone File System:',phone_path
# we probably need to do this only once for the whole class,
# but what the heck!
DebugBrewProtocol._fs_path=os.path.normpath(phone_path)
self._update_base_class(self.__class__)
elif getattr(self.protocolclass, "BREW_FILE_SYSTEM", 0) == 2:
self._set_new_brew(self.__class__)
def _set_new_brew(self, klass):
# update the class hierachy to include RealBrewProtocol2 so that
# it's functions override RealBrewProtocol's ones.
_bases=[]
found=False
for e in klass.__bases__:
if e==RealBrewProtocol:
_bases.append(RealBrewProtocol2)
found=True
_bases.append(e)
if found:
klass.__bases__=tuple(_bases)
else:
for e in _bases:
self._set_new_brew(e)
Simon