new brew filesystem protocol

"Simon C" <[email protected]>
Newsgroups gmane.comp.mobile.bitpim.devel
Message-ID <000901c5cfb3$c9a05230$6400a8c0@HOME>
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



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.