Thursday, April 29, 2010

How to view messageText table for command line or any tools

Thunderbird 3 or later uses SQLite3 to index mail body for "Gloda" full-text search. Gloda uses custom tokenizer "mozporter" to support non-ASCII characters. So when you open global-messages-db.sqlite, you cannot view a data into some tables such as messageText.

There is the way to view messageText table for command line version of SQLite3.

Before you try this, you should backup your database file!

  1. Get the module address for porter tokenizer
    sqlite> select hex(fts3_tokenizer('porter'));
    00EF420A8C7F0000
    
  2. Register dummy "mozporter" with same address of porter
    sqlite> select fts3_tokenizer('mozporter',X'00EF420A8C7F0000');

Then, you can view a data into messageText using SQL.

Monday, April 5, 2010

structure support on js-ctypes

I posted an article to Japanese Mozilla community site about js-ctypes on Firefox.next (3.7). Firefox.next improves many features such as struct support and callback support for js-ctypes.

This is a sample to use color picker on Windows using js-ctypes. ComDlg32 has color picker API "ChooseColor()". This sample is to access ChooseColor().

Components.utils.import("resource://gre/modules/ctypes.jsm");
 
var custColors_type = ctypes.ArrayType(ctypes.int32_t, 16);
const CHOOSECOLOR = new ctypes.StructType(
 'CHOOSECOLOR',
 [
  {'lStructSize': ctypes.uint32_t},
  {'hwndOwner' : ctypes.uint32_t},
  {'hInstance' : ctypes.uint32_t},
  {'rgbResult' : ctypes.uint32_t},
  {'lpCustColors' : custColors_type.ptr},
  {'Flags' : ctypes.uint32_t},
  {'lCustData' : ctypes.uint32_t},
  {'lpfnHook' : ctypes.uint32_t},
  {'lpTemplateName' : ctypes.uint32_t}
 ]);
 
var comdlg32 = ctypes.open("comdlg32");
var ChooseColor = comdlg32.declare("ChooseColorW",
                                   ctypes.stdcall_abi,
                                   ctypes.int32_t,
                                   CHOOSECOLOR.ptr);
 
var custColors = new custColors_type();
var col = new CHOOSECOLOR (CHOOSECOLOR.size, 0, 0, 0,
                           custColors.address(), 0, 0, 0, 0);
 
ChooseColor(col.address());
alert(col.rgbResult);