BlackBerry SMS Messages Record Format

This information is result of over 9000 btool -d Tasks dumps from a *single* BB 8800.

RIM 8800 Series Colour GPRS Handheld
App Version v4.5.0.81(108), platform 2.7.0.78

There are several cases not tested yet, which are hard to catch, i.e. `Pending', etc.
information on these incidents is welcomed. Incidentally, some listings here may be inaccurate.

==Header==
Length = const 0x0f bytes

00000000: 04 00 x0 x1 40 ?? 44 05 01 00 x2 x3 x4 x5 00  ....@.D........
          _____ _____ ___________ _____ ___________ __
          type  len   var0        index uniqueID

type        - always 04 00, perhaps SMS uses this but others also do
len         - length of this record in bytes, including header.
var0        - 40 02 44 05/40 01 44 05(according to my 9000+ messages), change but all records keep the same.
index       - the record number within the data base.
              determines posting order in the device (That is, if you
              change sort order, the indices of tasks will be modified.
              Similarly, if you change the priority or due date of a task
              the ordinal might change as well.
uniqueID    - 32byte Integer, unique for each task,
              generated by time.

==Content Fields==

The content is divided into 7+ parts, each with a 3byte header:
id# format meaning
--- ------ -------
00  2byte  size(excluding this header)
01  1byte  field type

The field type has 7 possible values, ordered as their appearances:

===Field Type 01===
Meaning: Metadata
Size: 0x40
Repeat Count: 1
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    byte     yes         00=SENT/DRAFT, 01=RECV
01    yes    byte     yes         status flags, 80=SEND ERROR, 40=DELIVERY REPORT ON(!not sure),
                                  20=START NEW CONVERSATION, 10=SAVED, 08=DELETED, 01=OPENED
02    yes    byte     yes         00=OLD, 01=NEW
03    no     2byte    yes         00 00
04    yes    4byte    yes         ff 07 00 00=RECV, ff 1f 00 00=SEND ERROR, ff ff 3f 00=DELIVERY SUCCEDDED
                                  ff ff ff 01=SENT, ff ff ff 07=WAITING, ff ff ff 7f=DRAFT
05    yes    4byte    no          error id, 00 00 00 00=NO ERROR, 84 34 00 00=Unidentified Subscriber
06    yes    8byte    yes         8byteInt representing UNIX time(in milliseconds), first 4 bytes=uniqueID
07    yes    8byte    yes         representing sent time(like #06), probably not in UTC.
08    yes    byte     yes         Data Coding Scheme: 00=7bit, 01=VCARD, 02=UCS2
09    yes    2byte    no          00 00=SENT/DRAFT, 04 00=RECV, sometimes all 04 00, probably garbage information
0a    yes    4byte    yes         00 00 00 00=TEXT, 02 00 00 04=SEND AS FAX3, 03 00 00 04=SEND AS FAX4,
                                  04 00 00 04=SEND AS VOICE, 05 00 00 04=SEND AS ERMES
0b    yes    28byte   yes         00 00 00 00 00 00 00 00
                                  00 00 00 00 00 00 00 00
                                  00 00 00 00 00 00 00 00
                                  00 00 00 00

===Field Type 09===
Meaning: Unknown
Size: Multiple of 0x8(The multiplier is probably send_times)
Repeat Count: 1
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    unknonwn no          Unknown


===Field Type 0B===
Meaning: Unknown
Size: Half of the size of field type 09
Repeat Count: 1
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    unknown  no          Unknown

===Field Type 02===
Meaning: Phone Number
Size: pn_length + 0x5
Repeat Count: recipient_num
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    4byte    no          00 00 00 00/01 00 00 00/03 00 00 00
01    yes    string   yes         current recipient's number
02    no     byte     yes         trailing NULL

===Field Type 04===
Meaning: SMS Content
Size: content_length
Repeat Count: 1
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    string   yes         content

===Field Type 07===
Meaning: Unknown
Size: 0xf
Repeat Count: 1
Content(May be very inaccurate):

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    yes    3byte    no          Unknown
01    yes    byte     yes         `Sent As', 00=TEXT, 02=FAX3, 03=FAX4, 04=VOICE, 05=ERMES
02    no     2byte    yes         00 00
03    yes    byte     yes         00=DEFAULT, 04=SEND AS NON-TEXT
04    yes    4byte    yes         00 00 00 00=SEND AS NON-TEXT, 00 00 00 01=DEFAULT
06    no     byte     yes         01
07    yes    byte     yes         00=DELIVERY REPORT OFF, 01=DELIVERY REPORT ON
08    no     2byte    yes         00 00

===Field Type 0c===
Meaning: Possibly Footer
Size: 0x8
Repeat Count: 1
Content:

id#   var    format   worked-out  meaning(variable)/value(constant)
----  ---    -------  ----------  ---------------------------------------
00    no     8byte    yes         00 00 00 00 ff ff ff ff
