On Fri, Apr 03, 2009 at 12:40:02PM +0800, Ryan Li wrote:
> Hello Chris,
>
> I've been working on the sms parser for Barry, the code is raw, since the
> data structure for SMS is really strange and I can't use a packed struct to
> handle this effectively. But at least, it works now. And I'll do some
> refinement later when I have finished my homework.
Thanks! And thanks for using the same headers as the rest of the code...
that takes care of the GPL licensing issue I had before. :-)
I've applied your patches, with some changes. I have a few comments:
- Does the Encoding need to be public? It looks like technical
details that the parser class should handle automatically.
I suppose if it is a read-only item, through a member
function, that's ok.
Remember that the goal is to expose this data to applications,
so that apps can write SMS records back into the device
if appropriate, so we need to make the API easy, or at
least as bullet proof as possible.
Hmmm... looking at the charset issues you had, maybe
Encoding is important... If contacts use WINDOWS-1252,
and SMS messages use a combination of charsets, this
may need to be more flexible.
- Timestamps should be in time_t by default. The parser class
should do the conversion as it is reading/writing from
the device. The application programmer should be able
to look at the class and know immediately what to do
with a time_t. He won't know what to do with a uint64_t. :-)
If you could send me a patch for this, that would be great.
- be careful with the sizes... when parsing, check that the data
exists before actually accessing it. I added some size
checks to the parser, but it's a good thing to keep in mind.
In general we should never trust data from external sources,
including data from the Blackberry.
- the Encoding value is taken straight from the Blackberry and
passed through to the API without change. This has been
done elsewhere in the code, but with comments. The thing
we have to watch for is that the Blackberry might change,
but our API should not. See r_contact.cc for my attempt
at doing this with functions, with the enums there.
Another clean way to do it is to do what you did with
MessageStatus, and set the value through if statements.
That way, if the Blackberry changes, we can update the code
without changing the enum API for applications that depend
on it.
> However, I've checked the common.h file and found that the iconv.cc in Barry
> converts WINDOWS-1252 to UTF-8, but with SMS encoded as UCS-2, btool
> displays my Chinese messages as garbled text. Furthermore, after I changed
> the definition of BLACKBERRY_CHARSET to `UCS-2', the output doesn't change.
> I thought there's something wrong with iconv.cc? My Memo in 100% English
> can't be interpreted correctly either.
Btool doesn't use IConverter unless it is specified on the command line.
Instead of changing BLACKBERRY_CHARSET, try using btool's -i switch and see
if that changes your output at all.
Thanks for the patch!
- Chris
------------------------------------------------------------------------------
_______________________________________________
Barry-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/barry-devel