Python Framework for Symbian Series 60 phones

< 1 2 3 4 5 >

Monday 16 October 2006

Journal

Last week we found out with Jouni how to workaround the problem of static datain dll for 1st and 2nd edition. It's quite simple... when we know how to do. Here are the big lines: If we need to have SHA224type and SHA256type as global reference (static data) for all our functions we start with

/*
=============================================================================================
This structure embeed all the static object definition we would need. That will allow use to 
use TLS
=============================================================================================
*/
struct myWrapper
{
    PyTypeObject SHA224type;
    PyTypeObject SHA256type;
};

Then we'll create constant structures for both type:

const PyTypeObject SHA224typeConst =
        {
        PyObject_HEAD_INIT(NULL)
        0,			            /*ob_size*/
        "pys60crypto.sha224",       /*tp_name*/
        ...
        };
 
const PyTypeObject SHA256typeConst =
        {
        PyObject_HEAD_INIT(NULL)
        0,			            /*ob_size*/
        "pys60crypto.sha256",       /*tp_name*/
        ...
        };

Now we are about to set those data in the Tls:

PyMODINIT_FUNC init_sha256(void)
    {
    PyObject *m;
    /* first we create a pointer to a new myWrapper structure */
    struct myWrapper* xx = new struct myWrapper;
 
    if (xx)
        {
        /* now we copy the data of SHA224typeConst & SHA256typeConst to the structure that will 
        be accessible from every functions */
        memcpy((PyTypeObject*)&xx->SHA224type, (PyTypeObject*) &SHA224typeConst, sizeof(SHA224typeConst));
        memcpy((PyTypeObject*)&xx->SHA256type, (PyTypeObject*) &SHA256typeConst, sizeof(SHA256typeConst));
 
        /* finaly we try to set the TLS with the myWrapper structure */
        TRAPD(err, Dll::SetTls(xx));
        if (err != KErrNone)
            {
            return;
            }
        ....

Quite simple isn't it? Only 3 weeks to figure that out :D

Tuesday 10 October 2006

Journal

Here is a link to the official table to allocate UID for applications: https://www.symbiansigned.com/app/page/uidfaq

Wednesday 4 October 2006

Journal

I spent the last 2 days trying to fix the building error for the dll. Polymophic dlls for 1st and 2nd S60 edition don't allow static data in the source. So I have to wrap everything in a class and that's where it gives me some problem since I'm not very experimented with C++.

I'm waiting for a helping hand from Jouni when he will have some time.

Monday 2 October 2006

Journal

Today we succeeded to build the SHA256 module for the phone. There has been some wrong initialisation in the source so it took me 1/2 day to find it.

I have named the module pys60crypto. It includes SHA256 and SHA224 encryption. Those two SHA object have the following methods:

  • update()
  • copy()
  • digest()
  • hexdigest()

Usage :

import pys60crypto
x = pys60crypto.sha256("blabla")
print x.hexdigest()

You'll get :

ccadd99b16cd3d200c22d6db45d8b6630ef3d936767127347ec8a76ab992c2ea

I get an error when building for the phone. I'm waiting for an answer to fix this.

Wednesday 27 September 2006

Journal

Today has been quite productive. I've searched in the poor documentation of the XML module we are using on the phone the methods we need for parsing a complete file. The result is quite satisfying. The XML module takes a little while to be loaded but after result is very fast.

So, we have a new method MParser inheriting from ElementTree added to MobiliiPuntariAPI.xml package able to:

  • parse from url (fromurl())
  • parse from file (fromfile())
  • parse from string (fromstring())
  • convert a tree object to a string (tostring())

Maybe an error handler could be added later if new issues are found. Tomorrow, I'll add the possibility to pass a callback method to extract and return only the information needed to a dictionary format.

< 1 2 3 4 5 >

LEFEVRE Damien
http://www.lfdm.net
contact@lfdm.net