[qt_honey] [7] EOL setting modified.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 10月 9日 (金) 18:09:37 JST


Revision: 7
          http://sourceforge.jp/projects/cres/svn/view?view=rev&revision=7
Author:   kyagroup
Date:     2009-10-09 18:09:37 +0900 (Fri, 09 Oct 2009)

Log Message:
-----------
EOL setting modified. (svn:eol-style = native)

Modified Paths:
--------------
    src/chrome/content/aescipher.js
    src/chrome/content/configuration.js
    src/chrome/content/logtoolbar.js
    src/chrome/content/logtoolbar.xul
    src/chrome/content/qth.js
    src/chrome/content/settings.js
    src/chrome/content/settings.xul
    src/chrome/content/specialblacklist.js
    src/chrome/content/specialblacklist.xul
    src/chrome/content/status.xul
    src/chrome/content/upload.js
    src/chrome/content/utils.js
    src/chrome.manifest
    src/components/qth_toolbar_singleton.js
    src/defaults/preferences/defaults.js

Property Changed:
----------------
    src/chrome/content/aescipher.js
    src/chrome/content/configuration.js
    src/chrome/content/logtoolbar.js
    src/chrome/content/logtoolbar.xul
    src/chrome/content/qth.js
    src/chrome/content/service.js
    src/chrome/content/settings.js
    src/chrome/content/settings.xul
    src/chrome/content/specialblacklist.js
    src/chrome/content/specialblacklist.xul
    src/chrome/content/status.xul
    src/chrome/content/upload.js
    src/chrome/content/upload.xul
    src/chrome/content/utils.js
    src/chrome.manifest
    src/components/qth_toolbar_singleton.js
    src/defaults/preferences/defaults.js

Modified: src/chrome/content/aescipher.js
===================================================================
--- src/chrome/content/aescipher.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/aescipher.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,290 +1,290 @@
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
-
-/*
- * AES Cipher function: encrypt 'input' with Rijndael algorithm
- *
- *   takes   byte-array 'input' (16 bytes)
- *           2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
- *
- *   applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
- *
- *   returns byte-array encrypted value (16 bytes)
- *
- * Code under LGPL use from:
- * (c) 2005–2007 Chris Veness
- * Website: http://www.movable-type.co.uk/scripts/aes.html
- */
-function Cipher(input, w) {    // main Cipher function [§5.1]
-  var Nb = 4;               // block size (in words): no of columns in state (fixed at 4 for AES)
-  var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
-
-  var state = [[],[],[],[]];  // initialise 4xNb byte-array 'state' with input [§3.4]
-  for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
-
-  state = AddRoundKey(state, w, 0, Nb);
-
-  for (var round=1; round<Nr; round++) {
-    state = SubBytes(state, Nb);
-    state = ShiftRows(state, Nb);
-    state = MixColumns(state, Nb);
-    state = AddRoundKey(state, w, round, Nb);
-  }
-
-  state = SubBytes(state, Nb);
-  state = ShiftRows(state, Nb);
-  state = AddRoundKey(state, w, Nr, Nb);
-
-  var output = new Array(4*Nb);  // convert state to 1-d array before returning [§3.4]
-  for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
-  return output;
-}
-
-
-function SubBytes(s, Nb) {    // apply SBox to state S [§5.1.1]
-  for (var r=0; r<4; r++) {
-    for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
-  }
-  return s;
-}
-
-
-function ShiftRows(s, Nb) {    // shift row r of state S left by r bytes [§5.1.2]
-  var t = new Array(4);
-  for (var r=1; r<4; r++) {
-    for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb];  // shift into temp copy
-    for (var c=0; c<4; c++) s[r][c] = t[c];         // and copy back
-  }          // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
-  return s;  // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf 
-}
-
-
-function MixColumns(s, Nb) {   // combine bytes of each col of state S [§5.1.3]
-  for (var c=0; c<4; c++) {
-    var a = new Array(4);  // 'a' is a copy of the current column from 's'
-    var b = new Array(4);  // 'b' is a•{02} in GF(2^8)
-    for (var i=0; i<4; i++) {
-      a[i] = s[i][c];
-      b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
-    }
-    // a[n] ^ b[n] is a•{03} in GF(2^8)
-    s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
-    s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
-    s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
-    s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
-  }
-  return s;
-}
-
-
-function AddRoundKey(state, w, rnd, Nb) {  // xor Round Key into state S [§5.1.4]
-  for (var r=0; r<4; r++) {
-    for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
-  }
-  return state;
-}
-
-
-function KeyExpansion(key) {  // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
-  var Nb = 4;            // block size (in words): no of columns in state (fixed at 4 for AES)
-  var Nk = key.length/4  // key length (in words): 4/6/8 for 128/192/256-bit keys
-  var Nr = Nk + 6;       // no of rounds: 10/12/14 for 128/192/256-bit keys
-
-  var w = new Array(Nb*(Nr+1));
-  var temp = new Array(4);
-
-  for (var i=0; i<Nk; i++) {
-    var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
-    w[i] = r;
-  }
-
-  for (var i=Nk; i<(Nb*(Nr+1)); i++) {
-    w[i] = new Array(4);
-    for (var t=0; t<4; t++) temp[t] = w[i-1][t];
-    if (i % Nk == 0) {
-      temp = SubWord(RotWord(temp));
-      for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
-    } else if (Nk > 6 && i%Nk == 4) {
-      temp = SubWord(temp);
-    }
-    for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
-  }
-
-  return w;
-}
-
-function SubWord(w) {    // apply SBox to 4-byte word w
-  for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
-  return w;
-}
-
-function RotWord(w) {    // rotate 4-byte word w left by one byte
-  w[4] = w[0];
-  for (var i=0; i<4; i++) w[i] = w[i+1];
-  return w;
-}
-
-
-// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [§5.1.1]
-var Sbox =  [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
-             0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
-             0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
-             0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
-             0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
-             0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
-             0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
-             0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
-             0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
-             0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
-             0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
-             0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
-             0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
-             0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
-             0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
-             0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
-
-// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
-var Rcon = [ [0x00, 0x00, 0x00, 0x00],
-             [0x01, 0x00, 0x00, 0x00],
-             [0x02, 0x00, 0x00, 0x00],
-             [0x04, 0x00, 0x00, 0x00],
-             [0x08, 0x00, 0x00, 0x00],
-             [0x10, 0x00, 0x00, 0x00],
-             [0x20, 0x00, 0x00, 0x00],
-             [0x40, 0x00, 0x00, 0x00],
-             [0x80, 0x00, 0x00, 0x00],
-             [0x1b, 0x00, 0x00, 0x00],
-             [0x36, 0x00, 0x00, 0x00] ]; 
-
-
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
-
-/* 
- * Use AES to encrypt 'plaintext' with 'password' using 'nBits' key, in 'Counter' mode of operation
- *                           - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
- *   for each block
- *   - outputblock = cipher(counter, key)
- *   - cipherblock = plaintext xor outputblock
- */
-function AESEncryptCtr(plaintext, password, nBits) {
-  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
-  
-  // for this example script, generate the key by applying Cipher to 1st 16/24/32 chars of password; 
-  // for real-world applications, a more secure approach would be to hash the password e.g. with SHA-1
-  var nBytes = nBits/8;  // no bytes in key
-  var pwBytes = new Array(nBytes);
-  for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
-  var key = Cipher(pwBytes, KeyExpansion(pwBytes));
-  key = key.concat(key.slice(0, nBytes-16));  // key is now 16/24/32 bytes long
-
-  // initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in 1st 8 bytes,
-  // block counter in 2nd 8 bytes
-  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
-  var counterBlock = new Array(blockSize);  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
-  var nonce = (new Date()).getTime();  // milliseconds since 1-Jan-1970
-
-  // encode nonce in two stages to cater for JavaScript 32-bit limit on bitwise ops
-  for (var i=0; i<4; i++) counterBlock[i] = (nonce >>> i*8) & 0xff;
-  for (var i=0; i<4; i++) counterBlock[i+4] = (nonce/0x100000000 >>> i*8) & 0xff; 
-
-  // generate key schedule - an expansion of the key into distinct Key Rounds for each round
-  var keySchedule = KeyExpansion(key);
-
-  var blockCount = Math.ceil(plaintext.length/blockSize);
-  var ciphertext = new Array(blockCount);  // ciphertext as array of strings
-  
-  for (var b=0; b<blockCount; b++) {
-    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
-    // again done in two stages for 32-bit ops
-    for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
-    for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
-
-    var cipherCntr = Cipher(counterBlock, keySchedule);  // -- encrypt counter block --
-    
-    // calculate length of final block:
-    var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
-
-    var ct = '';
-    for (var i=0; i<blockLength; i++) {  // -- xor plaintext with ciphered counter byte-by-byte --
-      var plaintextByte = plaintext.charCodeAt(b*blockSize+i);
-      var cipherByte = plaintextByte ^ cipherCntr[i];
-      ct += String.fromCharCode(cipherByte);
-    }
-    // ct is now ciphertext for this block
-
-    ciphertext[b] = escCtrlChars(ct);  // escape troublesome characters in ciphertext
-  }
-
-  // convert the nonce to a string to go on the front of the ciphertext
-  var ctrTxt = '';
-  for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
-  ctrTxt = escCtrlChars(ctrTxt);
-
-  // use '-' to separate blocks, use Array.join to concatenate arrays of strings for efficiency
-  return ctrTxt + '-' + ciphertext.join('-');
-}
-
-
-/* 
- * Use AES to decrypt 'ciphertext' with 'password' using 'nBits' key, in Counter mode of operation
- *
- *   for each block
- *   - outputblock = cipher(counter, key)
- *   - cipherblock = plaintext xor outputblock
- */
-function AESDecryptCtr(ciphertext, password, nBits) {
-  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
-
-  var nBytes = nBits/8;  // no bytes in key
-  var pwBytes = new Array(nBytes);
-  for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
-  var pwKeySchedule = KeyExpansion(pwBytes);
-  var key = Cipher(pwBytes, pwKeySchedule);
-  key = key.concat(key.slice(0, nBytes-16));  // key is now 16/24/32 bytes long
-
-  var keySchedule = KeyExpansion(key);
-
-  ciphertext = ciphertext.split('-');  // split ciphertext into array of block-length strings 
-
-  // recover nonce from 1st element of ciphertext
-  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
-  var counterBlock = new Array(blockSize);
-  var ctrTxt = unescCtrlChars(ciphertext[0]);
-  for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
-
-  var plaintext = new Array(ciphertext.length-1);
-
-  for (var b=1; b<ciphertext.length; b++) {
-    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
-    for (var c=0; c<4; c++) counterBlock[15-c] = ((b-1) >>> c*8) & 0xff;
-    for (var c=0; c<4; c++) counterBlock[15-c-4] = ((b/0x100000000-1) >>> c*8) & 0xff;
-
-    var cipherCntr = Cipher(counterBlock, keySchedule);  // encrypt counter block
-
-    ciphertext[b] = unescCtrlChars(ciphertext[b]);
-
-    var pt = '';
-    for (var i=0; i<ciphertext[b].length; i++) {
-      // -- xor plaintext with ciphered counter byte-by-byte --
-      var ciphertextByte = ciphertext[b].charCodeAt(i);
-      var plaintextByte = ciphertextByte ^ cipherCntr[i];
-      pt += String.fromCharCode(plaintextByte);
-    }
-    // pt is now plaintext for this block
-
-    plaintext[b-1] = pt;  // b-1 'cos no initial nonce block in plaintext
-  }
-
-  return plaintext.join('');
-}
-
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
-
-function escCtrlChars(str) {  // escape control chars which might cause problems handling ciphertext
-  return str.replace(/[\0\t\n\v\f\r\xa0'"!-]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
-}  // \xa0 to cater for bug in Firefox; include '-' to leave it free for use as a block marker
-
-function unescCtrlChars(str) {  // unescape potentially problematic control characters
-  return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
-}
-
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+
+/*
+ * AES Cipher function: encrypt 'input' with Rijndael algorithm
+ *
+ *   takes   byte-array 'input' (16 bytes)
+ *           2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
+ *
+ *   applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
+ *
+ *   returns byte-array encrypted value (16 bytes)
+ *
+ * Code under LGPL use from:
+ * (c) 2005–2007 Chris Veness
+ * Website: http://www.movable-type.co.uk/scripts/aes.html
+ */
+function Cipher(input, w) {    // main Cipher function [§5.1]
+  var Nb = 4;               // block size (in words): no of columns in state (fixed at 4 for AES)
+  var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
+
+  var state = [[],[],[],[]];  // initialise 4xNb byte-array 'state' with input [§3.4]
+  for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
+
+  state = AddRoundKey(state, w, 0, Nb);
+
+  for (var round=1; round<Nr; round++) {
+    state = SubBytes(state, Nb);
+    state = ShiftRows(state, Nb);
+    state = MixColumns(state, Nb);
+    state = AddRoundKey(state, w, round, Nb);
+  }
+
+  state = SubBytes(state, Nb);
+  state = ShiftRows(state, Nb);
+  state = AddRoundKey(state, w, Nr, Nb);
+
+  var output = new Array(4*Nb);  // convert state to 1-d array before returning [§3.4]
+  for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
+  return output;
+}
+
+
+function SubBytes(s, Nb) {    // apply SBox to state S [§5.1.1]
+  for (var r=0; r<4; r++) {
+    for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
+  }
+  return s;
+}
+
+
+function ShiftRows(s, Nb) {    // shift row r of state S left by r bytes [§5.1.2]
+  var t = new Array(4);
+  for (var r=1; r<4; r++) {
+    for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb];  // shift into temp copy
+    for (var c=0; c<4; c++) s[r][c] = t[c];         // and copy back
+  }          // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
+  return s;  // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf 
+}
+
+
+function MixColumns(s, Nb) {   // combine bytes of each col of state S [§5.1.3]
+  for (var c=0; c<4; c++) {
+    var a = new Array(4);  // 'a' is a copy of the current column from 's'
+    var b = new Array(4);  // 'b' is a•{02} in GF(2^8)
+    for (var i=0; i<4; i++) {
+      a[i] = s[i][c];
+      b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
+    }
+    // a[n] ^ b[n] is a•{03} in GF(2^8)
+    s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
+    s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
+    s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
+    s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
+  }
+  return s;
+}
+
+
+function AddRoundKey(state, w, rnd, Nb) {  // xor Round Key into state S [§5.1.4]
+  for (var r=0; r<4; r++) {
+    for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
+  }
+  return state;
+}
+
+
+function KeyExpansion(key) {  // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
+  var Nb = 4;            // block size (in words): no of columns in state (fixed at 4 for AES)
+  var Nk = key.length/4  // key length (in words): 4/6/8 for 128/192/256-bit keys
+  var Nr = Nk + 6;       // no of rounds: 10/12/14 for 128/192/256-bit keys
+
+  var w = new Array(Nb*(Nr+1));
+  var temp = new Array(4);
+
+  for (var i=0; i<Nk; i++) {
+    var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
+    w[i] = r;
+  }
+
+  for (var i=Nk; i<(Nb*(Nr+1)); i++) {
+    w[i] = new Array(4);
+    for (var t=0; t<4; t++) temp[t] = w[i-1][t];
+    if (i % Nk == 0) {
+      temp = SubWord(RotWord(temp));
+      for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
+    } else if (Nk > 6 && i%Nk == 4) {
+      temp = SubWord(temp);
+    }
+    for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
+  }
+
+  return w;
+}
+
+function SubWord(w) {    // apply SBox to 4-byte word w
+  for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
+  return w;
+}
+
+function RotWord(w) {    // rotate 4-byte word w left by one byte
+  w[4] = w[0];
+  for (var i=0; i<4; i++) w[i] = w[i+1];
+  return w;
+}
+
+
+// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [§5.1.1]
+var Sbox =  [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
+             0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
+             0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
+             0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
+             0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
+             0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
+             0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
+             0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
+             0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
+             0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
+             0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
+             0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
+             0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
+             0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
+             0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
+             0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
+
+// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
+var Rcon = [ [0x00, 0x00, 0x00, 0x00],
+             [0x01, 0x00, 0x00, 0x00],
+             [0x02, 0x00, 0x00, 0x00],
+             [0x04, 0x00, 0x00, 0x00],
+             [0x08, 0x00, 0x00, 0x00],
+             [0x10, 0x00, 0x00, 0x00],
+             [0x20, 0x00, 0x00, 0x00],
+             [0x40, 0x00, 0x00, 0x00],
+             [0x80, 0x00, 0x00, 0x00],
+             [0x1b, 0x00, 0x00, 0x00],
+             [0x36, 0x00, 0x00, 0x00] ]; 
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+
+/* 
+ * Use AES to encrypt 'plaintext' with 'password' using 'nBits' key, in 'Counter' mode of operation
+ *                           - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
+ *   for each block
+ *   - outputblock = cipher(counter, key)
+ *   - cipherblock = plaintext xor outputblock
+ */
+function AESEncryptCtr(plaintext, password, nBits) {
+  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
+  
+  // for this example script, generate the key by applying Cipher to 1st 16/24/32 chars of password; 
+  // for real-world applications, a more secure approach would be to hash the password e.g. with SHA-1
+  var nBytes = nBits/8;  // no bytes in key
+  var pwBytes = new Array(nBytes);
+  for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
+  var key = Cipher(pwBytes, KeyExpansion(pwBytes));
+  key = key.concat(key.slice(0, nBytes-16));  // key is now 16/24/32 bytes long
+
+  // initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in 1st 8 bytes,
+  // block counter in 2nd 8 bytes
+  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
+  var counterBlock = new Array(blockSize);  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
+  var nonce = (new Date()).getTime();  // milliseconds since 1-Jan-1970
+
+  // encode nonce in two stages to cater for JavaScript 32-bit limit on bitwise ops
+  for (var i=0; i<4; i++) counterBlock[i] = (nonce >>> i*8) & 0xff;
+  for (var i=0; i<4; i++) counterBlock[i+4] = (nonce/0x100000000 >>> i*8) & 0xff; 
+
+  // generate key schedule - an expansion of the key into distinct Key Rounds for each round
+  var keySchedule = KeyExpansion(key);
+
+  var blockCount = Math.ceil(plaintext.length/blockSize);
+  var ciphertext = new Array(blockCount);  // ciphertext as array of strings
+  
+  for (var b=0; b<blockCount; b++) {
+    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
+    // again done in two stages for 32-bit ops
+    for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
+    for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
+
+    var cipherCntr = Cipher(counterBlock, keySchedule);  // -- encrypt counter block --
+    
+    // calculate length of final block:
+    var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
+
+    var ct = '';
+    for (var i=0; i<blockLength; i++) {  // -- xor plaintext with ciphered counter byte-by-byte --
+      var plaintextByte = plaintext.charCodeAt(b*blockSize+i);
+      var cipherByte = plaintextByte ^ cipherCntr[i];
+      ct += String.fromCharCode(cipherByte);
+    }
+    // ct is now ciphertext for this block
+
+    ciphertext[b] = escCtrlChars(ct);  // escape troublesome characters in ciphertext
+  }
+
+  // convert the nonce to a string to go on the front of the ciphertext
+  var ctrTxt = '';
+  for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
+  ctrTxt = escCtrlChars(ctrTxt);
+
+  // use '-' to separate blocks, use Array.join to concatenate arrays of strings for efficiency
+  return ctrTxt + '-' + ciphertext.join('-');
+}
+
+
+/* 
+ * Use AES to decrypt 'ciphertext' with 'password' using 'nBits' key, in Counter mode of operation
+ *
+ *   for each block
+ *   - outputblock = cipher(counter, key)
+ *   - cipherblock = plaintext xor outputblock
+ */
+function AESDecryptCtr(ciphertext, password, nBits) {
+  if (!(nBits==128 || nBits==192 || nBits==256)) return '';  // standard allows 128/192/256 bit keys
+
+  var nBytes = nBits/8;  // no bytes in key
+  var pwBytes = new Array(nBytes);
+  for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
+  var pwKeySchedule = KeyExpansion(pwBytes);
+  var key = Cipher(pwBytes, pwKeySchedule);
+  key = key.concat(key.slice(0, nBytes-16));  // key is now 16/24/32 bytes long
+
+  var keySchedule = KeyExpansion(key);
+
+  ciphertext = ciphertext.split('-');  // split ciphertext into array of block-length strings 
+
+  // recover nonce from 1st element of ciphertext
+  var blockSize = 16;  // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
+  var counterBlock = new Array(blockSize);
+  var ctrTxt = unescCtrlChars(ciphertext[0]);
+  for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
+
+  var plaintext = new Array(ciphertext.length-1);
+
+  for (var b=1; b<ciphertext.length; b++) {
+    // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
+    for (var c=0; c<4; c++) counterBlock[15-c] = ((b-1) >>> c*8) & 0xff;
+    for (var c=0; c<4; c++) counterBlock[15-c-4] = ((b/0x100000000-1) >>> c*8) & 0xff;
+
+    var cipherCntr = Cipher(counterBlock, keySchedule);  // encrypt counter block
+
+    ciphertext[b] = unescCtrlChars(ciphertext[b]);
+
+    var pt = '';
+    for (var i=0; i<ciphertext[b].length; i++) {
+      // -- xor plaintext with ciphered counter byte-by-byte --
+      var ciphertextByte = ciphertext[b].charCodeAt(i);
+      var plaintextByte = ciphertextByte ^ cipherCntr[i];
+      pt += String.fromCharCode(plaintextByte);
+    }
+    // pt is now plaintext for this block
+
+    plaintext[b-1] = pt;  // b-1 'cos no initial nonce block in plaintext
+  }
+
+  return plaintext.join('');
+}
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
+
+function escCtrlChars(str) {  // escape control chars which might cause problems handling ciphertext
+  return str.replace(/[\0\t\n\v\f\r\xa0'"!-]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
+}  // \xa0 to cater for bug in Firefox; include '-' to leave it free for use as a block marker
+
+function unescCtrlChars(str) {  // unescape potentially problematic control characters
+  return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
+}
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */


Property changes on: src/chrome/content/aescipher.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/configuration.js
===================================================================
--- src/chrome/content/configuration.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/configuration.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,239 +1,239 @@
-
-String.prototype.trim = function () {
-  return this.replace(/^\s*/, "").replace(/\s*$/, "");
-}
-
-var regexFilterSafeString="(\\\\|\\/|\\(|\\)|\\[|\\]|\\{|\\}|\\*|\\+|\\?|\\||\\^|\\$|\\.|\\-)";
-var regexFilterSafe=new RegExp(regexFilterSafeString);
-
-String.prototype.safeForRegEx = function () {
-  // characters to escape:
-  // \/()[]{}*+?|^$.-
-  var tmpVar=this.replace(regexFilterSafe, "\\$1");
-  return tmpVar;
-}
-
-var LemurLogToolbarConfiguration = {
-
-  _needToRefreshSettings: true,
-
-  _serverBaseURL: "",
-
-  _allowRandomSessionId: true,
-  _useRandomSessionId: false,
-
-  _allowBlacklistPersonal: true,
-  _allowBlacklistAddress: true,
-  _allowBlacklistProperName: true,
-  _allowBlacklistKeywords: true,
-  
-  _useBlacklistPersonal: true,
-  _useBlacklistAddress: true,
-  _useBlacklistProperName: true,
-  _useBlacklistKeywords: true,
-  
-  _useDesktopSearch: true,
-  
-  _serverEncryptionModulus: "",
-  _serverEncryptionExponent: "",
-  
-  _blacklistPersonalItems: "",
-  _blacklistAddressItems: "",
-  _blacklistPropernameItems: "",
-  _blacklistKeywordItems: "",
-  
-  _blacklistPersonalRegex: "",
-  _blacklistAddressRegex: "",
-  _blacklistPropernameRegex: "",
-  _blacklistKeywordRegex: "",
-  
-  prefs: null,
-  
-  startup: function () {
-  },
-
-  getDefaultServerConfiguration: function (forceReload) {
-    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                 .getService(Components.interfaces.nsIPrefService)
-                 .getBranch("extensions.lemurquerylog.");
-    this._serverBaseURL=this.prefs.getCharPref("server");
-                 
-    if (this._needToRefreshSettings==true || (forceReload && forceReload==true)) {
-    
-      if (this.loadServerConfiguration()==true) {
-        // save user prefs
-        this.saveLocalUserConfiguration();
-      }
-    }
-  },
-  
-  prefPwd: function() {
-    var pString=lemurlog_GetUniqueStringFromProfilePath(false);
-    pString+="_eSa1T";
-    return pString;
-  },
-  
-  getEncryptedCharPref: function(prefName) {
-    var encValue=this.prefs.getCharPref(prefName);
-    return encValue;
-    // return (AESDecryptCtr(encValue, this.prefPwd(), 192));
-  },
-  
-  setEncryptedCharPref: function(prefName, prefValue) {
-    //var encValue=AESEncryptCtr(prefValue.trim(), this.prefPwd(), 192);
-    //this.prefs.setCharPref(prefName, encValue);
-    this.prefs.setCharPref(prefName, prefValue);
-  },
-  
-  loadLocalUserConfiguration: function() {
-    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                 .getService(Components.interfaces.nsIPrefService)
-                 .getBranch("extensions.lemurquerylog.");
-    
-    this._serverBaseURL=this.prefs.getCharPref("server").trim();
-    this._useRandomSessionId=this.prefs.getBoolPref("userandomsession");
-    this._useDesktopSearch=this.prefs.getBoolPref("logdesktopsearch");
-
-    this._useBlacklistPersonal=this.prefs.getBoolPref("usepersonalbl");
-    this._useBlacklistAddress=this.prefs.getBoolPref("useaddressbl");
-    this._useBlacklistProperName=this.prefs.getBoolPref("usepropernamebl");
-    this._useBlacklistKeywords=this.prefs.getBoolPref("usekeywordbl");
-
-    this._serverEncryptionModulus=this.prefs.getCharPref("encmodulus");
-    this._serverEncryptionExponent=this.prefs.getCharPref("encexponent");
-    
-    this._blacklistPersonalItems=this.getEncryptedCharPref("bl.personal");
-    this._blacklistAddressItems=this.getEncryptedCharPref("bl.address");
-    this._blacklistPropernameItems=this.getEncryptedCharPref("bl.propername");
-    this._blacklistKeywordItems=this.getEncryptedCharPref("bl.keyword");
-    
-    this._blacklistPersonalRegex=this.getEncryptedCharPref("bl.personalrx");
-    this._blacklistAddressRegex=this.getEncryptedCharPref("bl.addressrx");
-    this._blacklistPropernameRegex=this.getEncryptedCharPref("bl.propernamerx");
-    this._blacklistKeywordRegex=this.getEncryptedCharPref("bl.keywordrx");
-  },
-
-  saveLocalUserConfiguration: function () {
-    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                 .getService(Components.interfaces.nsIPrefService)
-                 .getBranch("extensions.lemurquerylog.");
-                 
-    this.prefs.setCharPref("server", this._serverBaseURL.trim());
-    this.prefs.setBoolPref("userandomsession", this._useRandomSessionId);
-    this.prefs.setBoolPref("logdesktopsearch", this._useDesktopSearch);
-    
-    this.prefs.setBoolPref("usepersonalbl", this._useBlacklistPersonal);
-    this.prefs.setBoolPref("useaddressbl", this._useBlacklistAddress);
-    this.prefs.setBoolPref("usepropernamebl", this._useBlacklistProperName);
-    this.prefs.setBoolPref("usekeywordbl", this._useBlacklistKeywords);
-    this.prefs.setCharPref("encmodulus", this._serverEncryptionModulus);
-    this.prefs.setCharPref("encexponent", this._serverEncryptionExponent);
-
-    this.setEncryptedCharPref("bl.personal", this._blacklistPersonalItems);
-    this.setEncryptedCharPref("bl.address", this._blacklistAddressItems);
-    this.setEncryptedCharPref("bl.propername", this._blacklistPropernameItems);
-    this.setEncryptedCharPref("bl.keyword", this._blacklistKeywordItems);
-
-    this.setEncryptedCharPref("bl.personalrx", this._blacklistPersonalRegex);
-    this.setEncryptedCharPref("bl.addressrx", this._blacklistAddressRegex);
-    this.setEncryptedCharPref("bl.propernamerx", this._blacklistPropernameRegex);
-    this.setEncryptedCharPref("bl.keywordrx", this._blacklistKeywordRegex);
-  },
-
-  loadServerConfiguration: function () {
-
-    if (this._serverBaseURL.length==0) {
-      return false;
-    }
-    
-    var xmlRequest=new XMLHttpRequest();
-    var configUrl=this._serverBaseURL + "/GetConfiguration";
-
-    try {
-      xmlRequest.open("GET", configUrl, false);
-      xmlRequest.send(null);
-    } catch (e) {
-      alert("QT Honey Toolbar:\nError retrieving configuration from server.\n Is the server URL set properly?");
-      return false;
-    }
-    
-    if (xmlRequest.status!=200) {
-      alert("QT Honey Toolbar:\nError retrieving configuration from server.\n Is the server URL set properly?");
-      return false;
-    }
-
-    var xmlDoc=xmlRequest.responseXML.documentElement;
-
-    var cryptoElement=xmlDoc.getElementsByTagName("publickey");
-    if (!cryptoElement || cryptoElement.length != 1) {
-      alert("Invalid configuration - could not retrieve public key information");
-      return false;
-    }
-
-    var modulus=cryptoElement[0].getElementsByTagName("modulus");
-    var exponent=cryptoElement[0].getElementsByTagName("exponent");
-    if ((modulus.length!=1) || (exponent.length!=1)) {
-      alert("Invalid configuration - could not retrieve public key malformed");
-      return false;
-    }
-
-    this._serverEncryptionModulus=modulus[0].firstChild.nodeValue;
-    this._serverEncryptionExponent=exponent[0].firstChild.nodeValue;
-
-    var rndSessionElement=xmlDoc.getElementsByTagName("allowrandomsession");
-    var allowPersonalBLElement=xmlDoc.getElementsByTagName("allowpersonalblacklist");
-    var allowAddressBLElement=xmlDoc.getElementsByTagName("allowaddressblacklist");
-    var allowProperNameBLElement=xmlDoc.getElementsByTagName("allowpropernameblacklist");
-    var allowKeywordBLElement=xmlDoc.getElementsByTagName("allowkeywordblacklist");
-
-    if (rndSessionElement && rndSessionElement.length>0) {
-      var thisValue=rndSessionElement[0].firstChild.nodeValue;
-      if (thisValue=='false') {
-        this._allowRandomSessionId=false;
-      } else {
-        this._allowRandomSessionId=true;
-      }
-    }
-
-    if (allowPersonalBLElement && allowPersonalBLElement.length>0) {
-      var thisValue=allowPersonalBLElement[0].firstChild.nodeValue;
-      if (thisValue=='false') {
-        this._allowBlacklistPersonal=false;
-      } else {
-        this._allowBlacklistPersonal=true;
-      }
-    }
-
-    if (allowAddressBLElement && allowAddressBLElement.length>0) {
-      var thisValue=allowAddressBLElement[0].firstChild.nodeValue;
-      if (thisValue=='false') {
-        this._allowBlacklistAddress=false;
-      } else {
-        this._allowBlacklistAddress=true;
-      }
-    }
-
-    if (allowProperNameBLElement && allowProperNameBLElement.length>0) {
-      var thisValue=allowProperNameBLElement[0].firstChild.nodeValue;
-      if (thisValue=='false') {
-        this._allowBlacklistProperName=false;
-      } else {
-        this._allowBlacklistProperName=true;
-      }
-    }
-
-    if (allowKeywordBLElement && allowKeywordBLElement.length>0) {
-      var thisValue=allowKeywordBLElement[0].firstChild.nodeValue;
-      if (thisValue=='false') {
-        this._allowBlacklistKeywords=false;
-      } else {
-        this._allowBlacklistKeywords=true;
-      }
-    }
-
-    this._needToRefreshSettings=false;
-    return true;
-  }
-};
-
-
+
+String.prototype.trim = function () {
+  return this.replace(/^\s*/, "").replace(/\s*$/, "");
+}
+
+var regexFilterSafeString="(\\\\|\\/|\\(|\\)|\\[|\\]|\\{|\\}|\\*|\\+|\\?|\\||\\^|\\$|\\.|\\-)";
+var regexFilterSafe=new RegExp(regexFilterSafeString);
+
+String.prototype.safeForRegEx = function () {
+  // characters to escape:
+  // \/()[]{}*+?|^$.-
+  var tmpVar=this.replace(regexFilterSafe, "\\$1");
+  return tmpVar;
+}
+
+var LemurLogToolbarConfiguration = {
+
+  _needToRefreshSettings: true,
+
+  _serverBaseURL: "",
+
+  _allowRandomSessionId: true,
+  _useRandomSessionId: false,
+
+  _allowBlacklistPersonal: true,
+  _allowBlacklistAddress: true,
+  _allowBlacklistProperName: true,
+  _allowBlacklistKeywords: true,
+  
+  _useBlacklistPersonal: true,
+  _useBlacklistAddress: true,
+  _useBlacklistProperName: true,
+  _useBlacklistKeywords: true,
+  
+  _useDesktopSearch: true,
+  
+  _serverEncryptionModulus: "",
+  _serverEncryptionExponent: "",
+  
+  _blacklistPersonalItems: "",
+  _blacklistAddressItems: "",
+  _blacklistPropernameItems: "",
+  _blacklistKeywordItems: "",
+  
+  _blacklistPersonalRegex: "",
+  _blacklistAddressRegex: "",
+  _blacklistPropernameRegex: "",
+  _blacklistKeywordRegex: "",
+  
+  prefs: null,
+  
+  startup: function () {
+  },
+
+  getDefaultServerConfiguration: function (forceReload) {
+    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                 .getService(Components.interfaces.nsIPrefService)
+                 .getBranch("extensions.lemurquerylog.");
+    this._serverBaseURL=this.prefs.getCharPref("server");
+                 
+    if (this._needToRefreshSettings==true || (forceReload && forceReload==true)) {
+    
+      if (this.loadServerConfiguration()==true) {
+        // save user prefs
+        this.saveLocalUserConfiguration();
+      }
+    }
+  },
+  
+  prefPwd: function() {
+    var pString=lemurlog_GetUniqueStringFromProfilePath(false);
+    pString+="_eSa1T";
+    return pString;
+  },
+  
+  getEncryptedCharPref: function(prefName) {
+    var encValue=this.prefs.getCharPref(prefName);
+    return encValue;
+    // return (AESDecryptCtr(encValue, this.prefPwd(), 192));
+  },
+  
+  setEncryptedCharPref: function(prefName, prefValue) {
+    //var encValue=AESEncryptCtr(prefValue.trim(), this.prefPwd(), 192);
+    //this.prefs.setCharPref(prefName, encValue);
+    this.prefs.setCharPref(prefName, prefValue);
+  },
+  
+  loadLocalUserConfiguration: function() {
+    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                 .getService(Components.interfaces.nsIPrefService)
+                 .getBranch("extensions.lemurquerylog.");
+    
+    this._serverBaseURL=this.prefs.getCharPref("server").trim();
+    this._useRandomSessionId=this.prefs.getBoolPref("userandomsession");
+    this._useDesktopSearch=this.prefs.getBoolPref("logdesktopsearch");
+
+    this._useBlacklistPersonal=this.prefs.getBoolPref("usepersonalbl");
+    this._useBlacklistAddress=this.prefs.getBoolPref("useaddressbl");
+    this._useBlacklistProperName=this.prefs.getBoolPref("usepropernamebl");
+    this._useBlacklistKeywords=this.prefs.getBoolPref("usekeywordbl");
+
+    this._serverEncryptionModulus=this.prefs.getCharPref("encmodulus");
+    this._serverEncryptionExponent=this.prefs.getCharPref("encexponent");
+    
+    this._blacklistPersonalItems=this.getEncryptedCharPref("bl.personal");
+    this._blacklistAddressItems=this.getEncryptedCharPref("bl.address");
+    this._blacklistPropernameItems=this.getEncryptedCharPref("bl.propername");
+    this._blacklistKeywordItems=this.getEncryptedCharPref("bl.keyword");
+    
+    this._blacklistPersonalRegex=this.getEncryptedCharPref("bl.personalrx");
+    this._blacklistAddressRegex=this.getEncryptedCharPref("bl.addressrx");
+    this._blacklistPropernameRegex=this.getEncryptedCharPref("bl.propernamerx");
+    this._blacklistKeywordRegex=this.getEncryptedCharPref("bl.keywordrx");
+  },
+
+  saveLocalUserConfiguration: function () {
+    this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                 .getService(Components.interfaces.nsIPrefService)
+                 .getBranch("extensions.lemurquerylog.");
+                 
+    this.prefs.setCharPref("server", this._serverBaseURL.trim());
+    this.prefs.setBoolPref("userandomsession", this._useRandomSessionId);
+    this.prefs.setBoolPref("logdesktopsearch", this._useDesktopSearch);
+    
+    this.prefs.setBoolPref("usepersonalbl", this._useBlacklistPersonal);
+    this.prefs.setBoolPref("useaddressbl", this._useBlacklistAddress);
+    this.prefs.setBoolPref("usepropernamebl", this._useBlacklistProperName);
+    this.prefs.setBoolPref("usekeywordbl", this._useBlacklistKeywords);
+    this.prefs.setCharPref("encmodulus", this._serverEncryptionModulus);
+    this.prefs.setCharPref("encexponent", this._serverEncryptionExponent);
+
+    this.setEncryptedCharPref("bl.personal", this._blacklistPersonalItems);
+    this.setEncryptedCharPref("bl.address", this._blacklistAddressItems);
+    this.setEncryptedCharPref("bl.propername", this._blacklistPropernameItems);
+    this.setEncryptedCharPref("bl.keyword", this._blacklistKeywordItems);
+
+    this.setEncryptedCharPref("bl.personalrx", this._blacklistPersonalRegex);
+    this.setEncryptedCharPref("bl.addressrx", this._blacklistAddressRegex);
+    this.setEncryptedCharPref("bl.propernamerx", this._blacklistPropernameRegex);
+    this.setEncryptedCharPref("bl.keywordrx", this._blacklistKeywordRegex);
+  },
+
+  loadServerConfiguration: function () {
+
+    if (this._serverBaseURL.length==0) {
+      return false;
+    }
+    
+    var xmlRequest=new XMLHttpRequest();
+    var configUrl=this._serverBaseURL + "/GetConfiguration";
+
+    try {
+      xmlRequest.open("GET", configUrl, false);
+      xmlRequest.send(null);
+    } catch (e) {
+      alert("QT Honey Toolbar:\nError retrieving configuration from server.\n Is the server URL set properly?");
+      return false;
+    }
+    
+    if (xmlRequest.status!=200) {
+      alert("QT Honey Toolbar:\nError retrieving configuration from server.\n Is the server URL set properly?");
+      return false;
+    }
+
+    var xmlDoc=xmlRequest.responseXML.documentElement;
+
+    var cryptoElement=xmlDoc.getElementsByTagName("publickey");
+    if (!cryptoElement || cryptoElement.length != 1) {
+      alert("Invalid configuration - could not retrieve public key information");
+      return false;
+    }
+
+    var modulus=cryptoElement[0].getElementsByTagName("modulus");
+    var exponent=cryptoElement[0].getElementsByTagName("exponent");
+    if ((modulus.length!=1) || (exponent.length!=1)) {
+      alert("Invalid configuration - could not retrieve public key malformed");
+      return false;
+    }
+
+    this._serverEncryptionModulus=modulus[0].firstChild.nodeValue;
+    this._serverEncryptionExponent=exponent[0].firstChild.nodeValue;
+
+    var rndSessionElement=xmlDoc.getElementsByTagName("allowrandomsession");
+    var allowPersonalBLElement=xmlDoc.getElementsByTagName("allowpersonalblacklist");
+    var allowAddressBLElement=xmlDoc.getElementsByTagName("allowaddressblacklist");
+    var allowProperNameBLElement=xmlDoc.getElementsByTagName("allowpropernameblacklist");
+    var allowKeywordBLElement=xmlDoc.getElementsByTagName("allowkeywordblacklist");
+
+    if (rndSessionElement && rndSessionElement.length>0) {
+      var thisValue=rndSessionElement[0].firstChild.nodeValue;
+      if (thisValue=='false') {
+        this._allowRandomSessionId=false;
+      } else {
+        this._allowRandomSessionId=true;
+      }
+    }
+
+    if (allowPersonalBLElement && allowPersonalBLElement.length>0) {
+      var thisValue=allowPersonalBLElement[0].firstChild.nodeValue;
+      if (thisValue=='false') {
+        this._allowBlacklistPersonal=false;
+      } else {
+        this._allowBlacklistPersonal=true;
+      }
+    }
+
+    if (allowAddressBLElement && allowAddressBLElement.length>0) {
+      var thisValue=allowAddressBLElement[0].firstChild.nodeValue;
+      if (thisValue=='false') {
+        this._allowBlacklistAddress=false;
+      } else {
+        this._allowBlacklistAddress=true;
+      }
+    }
+
+    if (allowProperNameBLElement && allowProperNameBLElement.length>0) {
+      var thisValue=allowProperNameBLElement[0].firstChild.nodeValue;
+      if (thisValue=='false') {
+        this._allowBlacklistProperName=false;
+      } else {
+        this._allowBlacklistProperName=true;
+      }
+    }
+
+    if (allowKeywordBLElement && allowKeywordBLElement.length>0) {
+      var thisValue=allowKeywordBLElement[0].firstChild.nodeValue;
+      if (thisValue=='false') {
+        this._allowBlacklistKeywords=false;
+      } else {
+        this._allowBlacklistKeywords=true;
+      }
+    }
+
+    this._needToRefreshSettings=false;
+    return true;
+  }
+};
+
+


Property changes on: src/chrome/content/configuration.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/logtoolbar.js
===================================================================
--- src/chrome/content/logtoolbar.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/logtoolbar.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,614 +1,614 @@
-//global variables
-var lemurlog_g_enable = true;
-var lemurlog_g_recordable = false;
-
-var lemurlog_prev_scroll_time = 0;
-var lemurlog_prev_blur_time = 0;
-var lemurlog_prev_show_time = 0;
-var lemurlog_prev_hide_time = 0;
-var lemurlog_prev_ctrlc_time = 0;
-
-var lemurlog_prev_focus_url = null;
-var lemurlog_prev_load_url = null;
-
-var lemurlog_ctrlc_down = false;
-
-var lemurlog_search_urls = new Array();
-
-var lemurlog_upload_service = null;
-
-///////////////////////////////////////////////////////////////////////
-// Upload log files to remote server
-///////////////////////////////////////////////////////////////////////
-function lemurlog_Upload_Log(event)
-{
-  var result = confirm("Would you like to upload log files?");
-  if(!result)
-  {
-    return;
-  }
-  
-  // before uploading - scrub the log files
-  // remember to remove any search results that match
-  // a query where any query term is blacklisted...
-  
-  lemurlog_upload_service = new lemurlog_uploadService();
-  window.openDialog("chrome://qthtoolbar/content/upload.xul", "LogTB-Upload", "chrome=yes,modal=no,centerscreen=yes,status=no", window);
-
-}
-
-function lemurlog_showsettings(event) {
-  window.openDialog('chrome://qthtoolbar/content/settings.xul', 'Log Toolbar Settings', 'chrome=yes,modal=yes,status=no', LemurLogToolbarConfiguration);
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// display help page
-///////////////////////////////////////////////////////////////////////
-function lemurlog_Help(event)
-{
-  lemurlog_LoadURL("http://www.lemurproject.org/querylogtoolbar/docs/client/");
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'keyup' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnKeyUp(event)
-{
-
-  if(!lemurlog_g_enable || !lemurlog_g_recordable || event.keyCode !== 67 || !lemurlog_ctrlc_down)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  if(time - lemurlog_prev_ctrlc_time > 1000)
-  {
-    return;
-  }
-  lemurlog_ctrlc_down = false;//reset
-
-  //The clipboard is (usually) ready when 'keyup', it's not ready when 'keydown' or 'keypress'
-
-  var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
-  if (!clipboard) 
-  {
-    return;
-  } 
-  var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
-  if (!trans) 
-  {
-    return;
-  }
-  trans.addDataFlavor("text/unicode"); 
-  clipboard.getData(trans, clipboard.kGlobalClipboard); 
-  var str = new Object(); 
-  var strLength = new Object(); 
-  trans.getTransferData("text/unicode", str,strLength); 
-  if (str)
-  {
-    str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
-  }
-  var text="";
-  if (str) 
-  {
-    text = str.data.substring(0,strLength.value / 2); 
-  }
-  //remove repeated spaces
-  text = washAndRinse(lemurlog_TrimString(text));
-
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "CtrlC\t" + time +"\t"+ text.length +"\t" + text +"\n");
-} 
-
-///////////////////////////////////////////////////////////////////////
-// 'keydown' event handler
-// event.keyCode for keydown and keyup (case insensitive)
-// event.charCode for keypress (case sensitive)
-// event.which for all
-// keyCode of C = 67, charCode of C = 67, charCode of c = 99
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnKeyDown(event)
-{
-
-  if(!lemurlog_g_enable || !lemurlog_g_recordable)
-  {
-    return;
-  }
-  if(!event.ctrlKey || event.keyCode !== 67)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  if(time - lemurlog_prev_ctrlc_time < lemurlog_MIN_INTERVAL)
-  {
-    lemurlog_prev_ctrlc_time = time;
-    return;
-  }
-  lemurlog_prev_ctrlc_time = time;
-  lemurlog_ctrlc_down = true;
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'mousedown' event handler
-// record mousedown(left/middle/right) on a hyperlink
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnMouseDown(event)
-{
-
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var url = this.href;
-  if(!lemurlog_IsRecordableURL(url))
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  url = washAndRinse(lemurlog_TrimString(url));
-
-  switch(event.button)
-  {
-    case 0:
-      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LClick\t" + time +"\t"+ url +"\n");
-      break;
-    case 1:
-      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "MClick\t" + time +"\t"+ url +"\n");
-      break;
-    case 2:
-      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RClick\t" + time +"\t"+ url +"\n");
-      break;
-    default:
-  }
-}
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is added
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabAdded_15(event)
-{
-  if (event.relatedNode !== gBrowser.mPanelContainer)
-  {
-    return; //Could be anywhere in the DOM (unless bubbling is caught at the interface?)
-  }
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-
-  if (event.target.localName == "vbox")// Firefox
-  { 
-    var time = new Date().getTime();
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "AddTab\t" + time + "\n");
-  }
-}
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is removed
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabRemoved_15(event)
-{
-  if (event.relatedNode !== gBrowser.mPanelContainer)
-  {
-    return; //Could be anywhere in the DOM (unless bubbling is caught at the interface?)
-  }
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  if (event.target.localName == "vbox")// Firefox
-  { 
-    var time = new Date().getTime();
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RmTab\t" + time + "\n");
-  }
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is selected
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabSelected_15(event)
-{
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var url = window.content.location.href; 
-  if(lemurlog_IsRecordableURL(url))
-  {
-    var time = new Date().getTime();
-    url=washAndRinse(url, true);
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "SelTab\t" + time + "\t" + url + "\n");
-  }
-}
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is added
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabAdded_20(event)
-{
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "AddTab\t" + time + "\n");
-}
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is removed
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabRemoved_20(event)
-{
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RmTab\t" + time + "\n");
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// when a tab is selected
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnTabSelected_20(event)
-{
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-
-  var browser = gBrowser.selectedTab;
-  if(!browser)
-  {
-    return;
-  }
-  var url = window.content.location.href; 
-  if(lemurlog_IsRecordableURL(url))
-  {
-    var time = new Date().getTime();
-    url=washAndRinse(url, true);
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "SelTab\t" + time + "\t" + url + "\n");
-  }
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'focus' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnFocus(event) 
-{
-  lemurlog_SetButtons();
-
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-
-  var time = new Date().getTime();
-  var url = window.content.location.href;
-  if(url == lemurlog_prev_focus_url)
-  {
-    return;
-  }
-  lemurlog_prev_focus_url = url;
-  if(lemurlog_IsRecordableURL(url))
-  {
-    lemurlog_g_recordable = true;
-  }
-  else
-  {
-    lemurlog_g_recordable = false;
-    return;
-  }
-  url=washAndRinse(url, true);
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Focus\t" + time + "\t" + url + "\n");
-
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'blur' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnBlur(event) 
-{
-
-  if(!lemurlog_g_enable || !lemurlog_g_recordable)
-  {
-    return;
-  }
-  lemurlog_prev_focus_url = null;//reset
-  var time = new Date().getTime();
-  if(time - lemurlog_prev_blur_time < lemurlog_MIN_INTERVAL)
-  {
-    lemurlog_prev_blur_time = time;
-    return;
-  }
-  lemurlog_prev_blur_time = time;
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Blur\t" + time + "\n");
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'scroll' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnScroll(event) 
-{
-  if(lemurlog_g_enable === false || lemurlog_g_recordable === false)
-  {
-    return;
-  }
-
-  var time = new Date().getTime();
-  if((time - lemurlog_prev_scroll_time) < lemurlog_MIN_INTERVAL)
-  {
-    lemurlog_prev_scroll_time = time;
-    return;
-  }
-  lemurlog_prev_scroll_time = time;
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Scroll\t" + time + "\n");
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'pageshow' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnShow(event) 
-{
-  lemurlog_SetButtons();
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  var url = window.content.location.href;
-  if(lemurlog_IsRecordableURL(url))
-  {
-    lemurlog_g_recordable = true;
-  }
-  else
-  {
-    lemurlog_g_recordable = false;
-    return;
-  }
-
-  if(time - lemurlog_prev_show_time < lemurlog_MIN_INTERVAL)
-  {
-    lemurlog_prev_show_time = time;
-    return;
-  }
-  lemurlog_prev_show_time = time;
-  url=washAndRinse(url, true);
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Show\t" + time + "\t" + url + "\n");
-
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'pagehide' event handler
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnHide(event) 
-{
-  if(!lemurlog_g_enable || !lemurlog_g_recordable)
-  {
-    return;
-  }
-  var time = new Date().getTime();
-  if(time - lemurlog_prev_hide_time < lemurlog_MIN_INTERVAL)
-  {
-    lemurlog_prev_hide_time = time;
-    return;
-  }
-  lemurlog_prev_hide_time = time;
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Hide\t" + time + "\n");
-}
-
-///////////////////////////////////////////////////////////////////////
-// Turn on/off logging by switching the value of lemurlog_g_enable 
-///////////////////////////////////////////////////////////////////////
-function lemurlog_Switch(event, mode)
-{
-  var time = new Date().getTime();
-  if(mode === true)
-  {
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "StartLogging\t" + time + "\n");
-  }
-  else
-  {
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "PauseLogging\t" + time + "\n");
-  }
-  lemurlog_g_enable = mode;
-  lemurlog_SetButtons();
-}
-
-///////////////////////////////////////////////////////////////////////
-// 'load' event handler in capture phase
-// initialize
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnLoad_Cap(event) 
-{
-  //log load events
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var url = window.content.location.href;
-  if(url == lemurlog_prev_load_url)
-  {
-    return;
-  }
-  lemurlog_prev_load_url = url;
-
-  if(!lemurlog_IsRecordableURL(url))
-  {
-    // alert("LoadCapEvent - not recordable: " + url);
-    return;
-  }
-  var time = new Date().getTime();
-  var printableurl=washAndRinse(url, true);
-  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LoadCap\t" + time + "\t" + printableurl + "\n");
-
-  //add mousedown listeners to all links
-  var links = window.content.document.links;
-  for (i = 0; i < links.length; i++)
-  {
-    links[i].addEventListener('mousedown', lemurlog_OnMouseDown, true);
-  }
-
-  //log search history
-  // if it's a search URL and our last URL wasn't sanitized...
-  if(lemurlog_IsSearchURL(url) && (printableurl.indexOf(sanitizedSubstitution) < 0)) 
-  { 
-    //save new  search results
-    var found = false;
-    var i;
-    for(i = lemurlog_search_urls.length -1 ; i>=0; i--)
-    {
-      if(url == lemurlog_search_urls[i])
-      {
-        found = true;
-        break;
-      }
-
-    }
-    if(found === false)//new search url
-    {
-      var thisUrl=washAndRinse(url, true);
-      lemurlog_search_urls[lemurlog_search_urls.length]=thisUrl;
-      var html_content = washAndRinse(window.content.document.documentElement.innerHTML);
-      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Search\t"+time+"\t"+html_content.length+"\n");
-      lemurlog_WriteLogFile(lemurlog_PAGE_FILE, "LOGTB_BEGIN_SEARCH_PAGE\nID="+time+"\nURL="+thisUrl+"\nLength="+html_content.length+"\n<html>\n"+html_content+"\n</html>\n");
-    }
-  }
-}
-///////////////////////////////////////////////////////////////////////
-// 'load' event handler in bubbling phase
-// initialize
-///////////////////////////////////////////////////////////////////////
-function lemurlog_OnLoad_Bub(event) 
-{
-
-  //log load events
-  if(lemurlog_g_enable === false)
-  {
-    return;
-  }
-  var url = window.content.location.href;
-  if(url == lemurlog_prev_load_url)
-  {
-    return;
-  }
-  lemurlog_prev_load_url = url;
-
-  var time = new Date().getTime();
-  if(lemurlog_IsRecordableURL(url))
-  {
-    url=washAndRinse(url, true);
-    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LoadBub\t" + time + "\t" + url + "\n");
-  }
-
-}
-
-
-
-///////////////////////////////////////////////////////////////////////
-// View the log file with the browser
-///////////////////////////////////////////////////////////////////////
-function lemurlog_View_Log(event, log_id)
-{
-  var file;
-  if(log_id == 0)
-  {
-    file = lemurlog_GetLogFile(lemurlog_LOG_FILE);
-  }
-  else if(log_id == 1)
-  {
-    file = lemurlog_GetLogFile(lemurlog_PAGE_FILE);
-  }
-  if(!file.exists())
-  {
-    file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE , 0644);
-  }
-  lemurlog_LoadURL("file:///" + file.path);
-}
-
-///////////////////////////////////////////////////////////////////////
-// Remove all log files
-///////////////////////////////////////////////////////////////////////
-function lemurlog_Clear_Log(event)
-{
-  var result = confirm("Clear all log files?");
-  if(!result)
-  {
-    return;
-  }
-  lemurlog_RemoveLogFile(lemurlog_LOG_FILE);
-  lemurlog_RemoveLogFile(lemurlog_PAGE_FILE);
-  // clear the search URLs
-  lemurlog_search_urls=[];
-}
-
-
-
-//add listeners
-window.addEventListener('load', lemurlog_OnLoad_Cap, true);//if false, sometimes isn't triggerred
-window.addEventListener('load', lemurlog_OnLoad_Bub, false);//if true, gBrowser is not ready yet
-
-window.addEventListener('pageshow', lemurlog_OnShow, false);
-window.addEventListener('pagehide', lemurlog_OnHide, false);
-
-window.addEventListener('focus', lemurlog_OnFocus, true);//not bubbling
-window.addEventListener('blur', lemurlog_OnBlur, true);//not bubbling
-
-window.addEventListener('scroll', lemurlog_OnScroll, false);
-
-window.addEventListener('keydown', lemurlog_OnKeyDown, false);
-window.addEventListener('keyup', lemurlog_OnKeyUp, false);
-
-// add tab listener
-const lemurlog_appInfo = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo);
-const lemurlog_versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator);
-lemurlog_WriteLogFile(lemurlog_LOG_FILE, "FirefoxVersion\t" + lemurlog_appInfo.version + "\n");
-window.setTimeout("lemurlog_AddTabEventListener();", 5000);
-
-function lemurlog_AddTabEventListener()
-{
-  var lemurlog_tabContainer = null;
-  if(lemurlog_versionChecker.compare(lemurlog_appInfo.version, "1.5") >= 0 && lemurlog_versionChecker.compare(lemurlog_appInfo.version, "2.0") < 0 ) {
-    //initialize for tab listeners
-    lemurlog_tabContainer = gBrowser.mPanelContainer;
-    lemurlog_tabContainer.addEventListener("DOMNodeInserted", lemurlog_OnTabAdded_15, false);
-    lemurlog_tabContainer.addEventListener("DOMNodeRemoved", lemurlog_OnTabRemoved_15, false);
-    lemurlog_tabContainer.addEventListener("select", lemurlog_OnTabSelected_15, false);
-  }
-  else if(lemurlog_versionChecker.compare(lemurlog_appInfo.version, "2.0") >= 0)
-  {
-    lemurlog_tabContainer = gBrowser.tabContainer;
-    lemurlog_tabContainer.addEventListener("TabOpen", lemurlog_OnTabAdded_20, false);
-    lemurlog_tabContainer.addEventListener("TabClose", lemurlog_OnTabRemoved_20, false);
-    lemurlog_tabContainer.addEventListener("TabSelect", lemurlog_OnTabSelected_20, false);
-  }
-}
-
-
-
-///////////////////////////////////////////////////////////
-// Supported log records:
-///////////////////////////////////////////////////////////
-// LoadCap
-// LoadBub
-
-// Show
-// Hide
-
-// Focus
-// Blur
-
-// AddTab
-// SelTab
-// RmTab
-
-// LClick: left click 
-// MClick: wheel click
-// RClick: right click
-
-// Scroll
-// Ctrol-C
-
-// Search
-// 
+//global variables
+var lemurlog_g_enable = true;
+var lemurlog_g_recordable = false;
+
+var lemurlog_prev_scroll_time = 0;
+var lemurlog_prev_blur_time = 0;
+var lemurlog_prev_show_time = 0;
+var lemurlog_prev_hide_time = 0;
+var lemurlog_prev_ctrlc_time = 0;
+
+var lemurlog_prev_focus_url = null;
+var lemurlog_prev_load_url = null;
+
+var lemurlog_ctrlc_down = false;
+
+var lemurlog_search_urls = new Array();
+
+var lemurlog_upload_service = null;
+
+///////////////////////////////////////////////////////////////////////
+// Upload log files to remote server
+///////////////////////////////////////////////////////////////////////
+function lemurlog_Upload_Log(event)
+{
+  var result = confirm("Would you like to upload log files?");
+  if(!result)
+  {
+    return;
+  }
+  
+  // before uploading - scrub the log files
+  // remember to remove any search results that match
+  // a query where any query term is blacklisted...
+  
+  lemurlog_upload_service = new lemurlog_uploadService();
+  window.openDialog("chrome://qthtoolbar/content/upload.xul", "LogTB-Upload", "chrome=yes,modal=no,centerscreen=yes,status=no", window);
+
+}
+
+function lemurlog_showsettings(event) {
+  window.openDialog('chrome://qthtoolbar/content/settings.xul', 'Log Toolbar Settings', 'chrome=yes,modal=yes,status=no', LemurLogToolbarConfiguration);
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// display help page
+///////////////////////////////////////////////////////////////////////
+function lemurlog_Help(event)
+{
+  lemurlog_LoadURL("http://www.lemurproject.org/querylogtoolbar/docs/client/");
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'keyup' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnKeyUp(event)
+{
+
+  if(!lemurlog_g_enable || !lemurlog_g_recordable || event.keyCode !== 67 || !lemurlog_ctrlc_down)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  if(time - lemurlog_prev_ctrlc_time > 1000)
+  {
+    return;
+  }
+  lemurlog_ctrlc_down = false;//reset
+
+  //The clipboard is (usually) ready when 'keyup', it's not ready when 'keydown' or 'keypress'
+
+  var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
+  if (!clipboard) 
+  {
+    return;
+  } 
+  var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
+  if (!trans) 
+  {
+    return;
+  }
+  trans.addDataFlavor("text/unicode"); 
+  clipboard.getData(trans, clipboard.kGlobalClipboard); 
+  var str = new Object(); 
+  var strLength = new Object(); 
+  trans.getTransferData("text/unicode", str,strLength); 
+  if (str)
+  {
+    str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
+  }
+  var text="";
+  if (str) 
+  {
+    text = str.data.substring(0,strLength.value / 2); 
+  }
+  //remove repeated spaces
+  text = washAndRinse(lemurlog_TrimString(text));
+
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "CtrlC\t" + time +"\t"+ text.length +"\t" + text +"\n");
+} 
+
+///////////////////////////////////////////////////////////////////////
+// 'keydown' event handler
+// event.keyCode for keydown and keyup (case insensitive)
+// event.charCode for keypress (case sensitive)
+// event.which for all
+// keyCode of C = 67, charCode of C = 67, charCode of c = 99
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnKeyDown(event)
+{
+
+  if(!lemurlog_g_enable || !lemurlog_g_recordable)
+  {
+    return;
+  }
+  if(!event.ctrlKey || event.keyCode !== 67)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  if(time - lemurlog_prev_ctrlc_time < lemurlog_MIN_INTERVAL)
+  {
+    lemurlog_prev_ctrlc_time = time;
+    return;
+  }
+  lemurlog_prev_ctrlc_time = time;
+  lemurlog_ctrlc_down = true;
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'mousedown' event handler
+// record mousedown(left/middle/right) on a hyperlink
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnMouseDown(event)
+{
+
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var url = this.href;
+  if(!lemurlog_IsRecordableURL(url))
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  url = washAndRinse(lemurlog_TrimString(url));
+
+  switch(event.button)
+  {
+    case 0:
+      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LClick\t" + time +"\t"+ url +"\n");
+      break;
+    case 1:
+      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "MClick\t" + time +"\t"+ url +"\n");
+      break;
+    case 2:
+      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RClick\t" + time +"\t"+ url +"\n");
+      break;
+    default:
+  }
+}
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is added
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabAdded_15(event)
+{
+  if (event.relatedNode !== gBrowser.mPanelContainer)
+  {
+    return; //Could be anywhere in the DOM (unless bubbling is caught at the interface?)
+  }
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+
+  if (event.target.localName == "vbox")// Firefox
+  { 
+    var time = new Date().getTime();
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "AddTab\t" + time + "\n");
+  }
+}
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is removed
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabRemoved_15(event)
+{
+  if (event.relatedNode !== gBrowser.mPanelContainer)
+  {
+    return; //Could be anywhere in the DOM (unless bubbling is caught at the interface?)
+  }
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  if (event.target.localName == "vbox")// Firefox
+  { 
+    var time = new Date().getTime();
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RmTab\t" + time + "\n");
+  }
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is selected
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabSelected_15(event)
+{
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var url = window.content.location.href; 
+  if(lemurlog_IsRecordableURL(url))
+  {
+    var time = new Date().getTime();
+    url=washAndRinse(url, true);
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "SelTab\t" + time + "\t" + url + "\n");
+  }
+}
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is added
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabAdded_20(event)
+{
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "AddTab\t" + time + "\n");
+}
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is removed
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabRemoved_20(event)
+{
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "RmTab\t" + time + "\n");
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// when a tab is selected
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnTabSelected_20(event)
+{
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+
+  var browser = gBrowser.selectedTab;
+  if(!browser)
+  {
+    return;
+  }
+  var url = window.content.location.href; 
+  if(lemurlog_IsRecordableURL(url))
+  {
+    var time = new Date().getTime();
+    url=washAndRinse(url, true);
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "SelTab\t" + time + "\t" + url + "\n");
+  }
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'focus' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnFocus(event) 
+{
+  lemurlog_SetButtons();
+
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+
+  var time = new Date().getTime();
+  var url = window.content.location.href;
+  if(url == lemurlog_prev_focus_url)
+  {
+    return;
+  }
+  lemurlog_prev_focus_url = url;
+  if(lemurlog_IsRecordableURL(url))
+  {
+    lemurlog_g_recordable = true;
+  }
+  else
+  {
+    lemurlog_g_recordable = false;
+    return;
+  }
+  url=washAndRinse(url, true);
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Focus\t" + time + "\t" + url + "\n");
+
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'blur' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnBlur(event) 
+{
+
+  if(!lemurlog_g_enable || !lemurlog_g_recordable)
+  {
+    return;
+  }
+  lemurlog_prev_focus_url = null;//reset
+  var time = new Date().getTime();
+  if(time - lemurlog_prev_blur_time < lemurlog_MIN_INTERVAL)
+  {
+    lemurlog_prev_blur_time = time;
+    return;
+  }
+  lemurlog_prev_blur_time = time;
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Blur\t" + time + "\n");
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'scroll' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnScroll(event) 
+{
+  if(lemurlog_g_enable === false || lemurlog_g_recordable === false)
+  {
+    return;
+  }
+
+  var time = new Date().getTime();
+  if((time - lemurlog_prev_scroll_time) < lemurlog_MIN_INTERVAL)
+  {
+    lemurlog_prev_scroll_time = time;
+    return;
+  }
+  lemurlog_prev_scroll_time = time;
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Scroll\t" + time + "\n");
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'pageshow' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnShow(event) 
+{
+  lemurlog_SetButtons();
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  var url = window.content.location.href;
+  if(lemurlog_IsRecordableURL(url))
+  {
+    lemurlog_g_recordable = true;
+  }
+  else
+  {
+    lemurlog_g_recordable = false;
+    return;
+  }
+
+  if(time - lemurlog_prev_show_time < lemurlog_MIN_INTERVAL)
+  {
+    lemurlog_prev_show_time = time;
+    return;
+  }
+  lemurlog_prev_show_time = time;
+  url=washAndRinse(url, true);
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Show\t" + time + "\t" + url + "\n");
+
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'pagehide' event handler
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnHide(event) 
+{
+  if(!lemurlog_g_enable || !lemurlog_g_recordable)
+  {
+    return;
+  }
+  var time = new Date().getTime();
+  if(time - lemurlog_prev_hide_time < lemurlog_MIN_INTERVAL)
+  {
+    lemurlog_prev_hide_time = time;
+    return;
+  }
+  lemurlog_prev_hide_time = time;
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Hide\t" + time + "\n");
+}
+
+///////////////////////////////////////////////////////////////////////
+// Turn on/off logging by switching the value of lemurlog_g_enable 
+///////////////////////////////////////////////////////////////////////
+function lemurlog_Switch(event, mode)
+{
+  var time = new Date().getTime();
+  if(mode === true)
+  {
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "StartLogging\t" + time + "\n");
+  }
+  else
+  {
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "PauseLogging\t" + time + "\n");
+  }
+  lemurlog_g_enable = mode;
+  lemurlog_SetButtons();
+}
+
+///////////////////////////////////////////////////////////////////////
+// 'load' event handler in capture phase
+// initialize
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnLoad_Cap(event) 
+{
+  //log load events
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var url = window.content.location.href;
+  if(url == lemurlog_prev_load_url)
+  {
+    return;
+  }
+  lemurlog_prev_load_url = url;
+
+  if(!lemurlog_IsRecordableURL(url))
+  {
+    // alert("LoadCapEvent - not recordable: " + url);
+    return;
+  }
+  var time = new Date().getTime();
+  var printableurl=washAndRinse(url, true);
+  lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LoadCap\t" + time + "\t" + printableurl + "\n");
+
+  //add mousedown listeners to all links
+  var links = window.content.document.links;
+  for (i = 0; i < links.length; i++)
+  {
+    links[i].addEventListener('mousedown', lemurlog_OnMouseDown, true);
+  }
+
+  //log search history
+  // if it's a search URL and our last URL wasn't sanitized...
+  if(lemurlog_IsSearchURL(url) && (printableurl.indexOf(sanitizedSubstitution) < 0)) 
+  { 
+    //save new  search results
+    var found = false;
+    var i;
+    for(i = lemurlog_search_urls.length -1 ; i>=0; i--)
+    {
+      if(url == lemurlog_search_urls[i])
+      {
+        found = true;
+        break;
+      }
+
+    }
+    if(found === false)//new search url
+    {
+      var thisUrl=washAndRinse(url, true);
+      lemurlog_search_urls[lemurlog_search_urls.length]=thisUrl;
+      var html_content = washAndRinse(window.content.document.documentElement.innerHTML);
+      lemurlog_WriteLogFile(lemurlog_LOG_FILE, "Search\t"+time+"\t"+html_content.length+"\n");
+      lemurlog_WriteLogFile(lemurlog_PAGE_FILE, "LOGTB_BEGIN_SEARCH_PAGE\nID="+time+"\nURL="+thisUrl+"\nLength="+html_content.length+"\n<html>\n"+html_content+"\n</html>\n");
+    }
+  }
+}
+///////////////////////////////////////////////////////////////////////
+// 'load' event handler in bubbling phase
+// initialize
+///////////////////////////////////////////////////////////////////////
+function lemurlog_OnLoad_Bub(event) 
+{
+
+  //log load events
+  if(lemurlog_g_enable === false)
+  {
+    return;
+  }
+  var url = window.content.location.href;
+  if(url == lemurlog_prev_load_url)
+  {
+    return;
+  }
+  lemurlog_prev_load_url = url;
+
+  var time = new Date().getTime();
+  if(lemurlog_IsRecordableURL(url))
+  {
+    url=washAndRinse(url, true);
+    lemurlog_WriteLogFile(lemurlog_LOG_FILE, "LoadBub\t" + time + "\t" + url + "\n");
+  }
+
+}
+
+
+
+///////////////////////////////////////////////////////////////////////
+// View the log file with the browser
+///////////////////////////////////////////////////////////////////////
+function lemurlog_View_Log(event, log_id)
+{
+  var file;
+  if(log_id == 0)
+  {
+    file = lemurlog_GetLogFile(lemurlog_LOG_FILE);
+  }
+  else if(log_id == 1)
+  {
+    file = lemurlog_GetLogFile(lemurlog_PAGE_FILE);
+  }
+  if(!file.exists())
+  {
+    file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE , 0644);
+  }
+  lemurlog_LoadURL("file:///" + file.path);
+}
+
+///////////////////////////////////////////////////////////////////////
+// Remove all log files
+///////////////////////////////////////////////////////////////////////
+function lemurlog_Clear_Log(event)
+{
+  var result = confirm("Clear all log files?");
+  if(!result)
+  {
+    return;
+  }
+  lemurlog_RemoveLogFile(lemurlog_LOG_FILE);
+  lemurlog_RemoveLogFile(lemurlog_PAGE_FILE);
+  // clear the search URLs
+  lemurlog_search_urls=[];
+}
+
+
+
+//add listeners
+window.addEventListener('load', lemurlog_OnLoad_Cap, true);//if false, sometimes isn't triggerred
+window.addEventListener('load', lemurlog_OnLoad_Bub, false);//if true, gBrowser is not ready yet
+
+window.addEventListener('pageshow', lemurlog_OnShow, false);
+window.addEventListener('pagehide', lemurlog_OnHide, false);
+
+window.addEventListener('focus', lemurlog_OnFocus, true);//not bubbling
+window.addEventListener('blur', lemurlog_OnBlur, true);//not bubbling
+
+window.addEventListener('scroll', lemurlog_OnScroll, false);
+
+window.addEventListener('keydown', lemurlog_OnKeyDown, false);
+window.addEventListener('keyup', lemurlog_OnKeyUp, false);
+
+// add tab listener
+const lemurlog_appInfo = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo);
+const lemurlog_versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator);
+lemurlog_WriteLogFile(lemurlog_LOG_FILE, "FirefoxVersion\t" + lemurlog_appInfo.version + "\n");
+window.setTimeout("lemurlog_AddTabEventListener();", 5000);
+
+function lemurlog_AddTabEventListener()
+{
+  var lemurlog_tabContainer = null;
+  if(lemurlog_versionChecker.compare(lemurlog_appInfo.version, "1.5") >= 0 && lemurlog_versionChecker.compare(lemurlog_appInfo.version, "2.0") < 0 ) {
+    //initialize for tab listeners
+    lemurlog_tabContainer = gBrowser.mPanelContainer;
+    lemurlog_tabContainer.addEventListener("DOMNodeInserted", lemurlog_OnTabAdded_15, false);
+    lemurlog_tabContainer.addEventListener("DOMNodeRemoved", lemurlog_OnTabRemoved_15, false);
+    lemurlog_tabContainer.addEventListener("select", lemurlog_OnTabSelected_15, false);
+  }
+  else if(lemurlog_versionChecker.compare(lemurlog_appInfo.version, "2.0") >= 0)
+  {
+    lemurlog_tabContainer = gBrowser.tabContainer;
+    lemurlog_tabContainer.addEventListener("TabOpen", lemurlog_OnTabAdded_20, false);
+    lemurlog_tabContainer.addEventListener("TabClose", lemurlog_OnTabRemoved_20, false);
+    lemurlog_tabContainer.addEventListener("TabSelect", lemurlog_OnTabSelected_20, false);
+  }
+}
+
+
+
+///////////////////////////////////////////////////////////
+// Supported log records:
+///////////////////////////////////////////////////////////
+// LoadCap
+// LoadBub
+
+// Show
+// Hide
+
+// Focus
+// Blur
+
+// AddTab
+// SelTab
+// RmTab
+
+// LClick: left click 
+// MClick: wheel click
+// RClick: right click
+
+// Scroll
+// Ctrol-C
+
+// Search
+// 


Property changes on: src/chrome/content/logtoolbar.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/logtoolbar.xul
===================================================================
--- src/chrome/content/logtoolbar.xul	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/logtoolbar.xul	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,110 +1,110 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet 
-  href="chrome://qthtoolbar/skin/lemurlogtoolbar.css"
-  type="text/css" 
-?>
-
-<overlay 
-  id="LogTB-Overlay"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
->
-
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/aescipher.js"/>
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/utils.js" />
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/service.js" />
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/logtoolbar.js" />
-  <script type="application/x-javascript" src="chrome://qthtoolbar/content/qth.js" />
-
-  <toolbox id="navigator-toolbox">
-
-    <toolbar 
-      id="LogTB-Toolbar" 
-      toolbarname="QT Honey Toolbar" 
-      accesskey="L" 
-      class="chromeclass-toolbar" 
-      context="toolbar-context-menu" 
-      hidden="false" 
-      persist="hidden"
-    >
-      <toolbaritem flex="0">
-        <toolbarseparator />
-        <toolbarbutton 
-          id="LogTB-Start-Button" 
-          tooltiptext="Start Logging"
-          label="Start" 
-          oncommand="lemurlog_Switch(event, true)"
-        />
-        <toolbarbutton 
-          id="LogTB-Start-Button-Gray" 
-          tooltiptext="Start Logging"
-          label="Start"
-          oncommand="lemurlog_Switch(event, true)"
-        />
-        <toolbarbutton 
-          id="LogTB-Pause-Button"
-          tooltiptext="Pause logging"
-          label="Pause" 
-          oncommand="lemurlog_Switch(event, false)" 
-        />
-        <toolbarbutton 
-          id="LogTB-Pause-Button-Gray" 
-          tooltiptext="Pause logging"
-          label="Pause" 
-          oncommand="lemurlog_Switch(event, false)" 
-        />
-        <toolbarbutton
-          id="LogTB-View-Button"
-          type="menu"
-          label="View  "
-          tooltiptext="View log files"
-        >
-          <menupopup>
-            <menuitem
-              label="QT Honey log"
-              tooltiptext="View QT Honey log"
-              id="qth_view_log"
-            />
-            <menuitem
-              label="Lemur Activity log"
-              tooltiptext="View activity log"
-              oncommand="lemurlog_View_Log(event, 0)" 
-            />
-            <menuitem
-              label="Lemur Search log"
-              tooltiptext="View search log"
-              oncommand="lemurlog_View_Log(event, 1)" 
-            />
-          </menupopup>
-        </toolbarbutton>
-        <toolbarbutton 
-          id="LogTB-Clear-Button" 
-          tooltiptext="Clear all log files"
-          label="Clear"
-          oncommand="lemurlog_Clear_Log(event)" 
-        />
-        <toolbarbutton 
-          id="LogTB-Upload-Button" 
-          tooltiptext="Upload log files"
-          label="Upload" 
-          oncommand="lemurlog_Upload_Log(event)" 
-        />
-        <toolbarbutton 
-          id="LogTB-Settings-Button" 
-          tooltiptext="Settings Options"
-          label="Settings"
-          oncommand="lemurlog_showsettings(event)"
-        />
-        <toolbarbutton 
-          id="LogTB-Help-Button" 
-          tooltiptext="Help information"
-          label="Help" 
-          oncommand="lemurlog_Help(event)" 
-        />
-      </toolbaritem>
-      <toolbarspring />
-    </toolbar>
-  </toolbox>
-</overlay>
-
+<?xml version="1.0"?>
+
+<?xml-stylesheet 
+  href="chrome://qthtoolbar/skin/lemurlogtoolbar.css"
+  type="text/css" 
+?>
+
+<overlay 
+  id="LogTB-Overlay"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+>
+
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/aescipher.js"/>
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/utils.js" />
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/service.js" />
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/logtoolbar.js" />
+  <script type="application/x-javascript" src="chrome://qthtoolbar/content/qth.js" />
+
+  <toolbox id="navigator-toolbox">
+
+    <toolbar 
+      id="LogTB-Toolbar" 
+      toolbarname="QT Honey Toolbar" 
+      accesskey="L" 
+      class="chromeclass-toolbar" 
+      context="toolbar-context-menu" 
+      hidden="false" 
+      persist="hidden"
+    >
+      <toolbaritem flex="0">
+        <toolbarseparator />
+        <toolbarbutton 
+          id="LogTB-Start-Button" 
+          tooltiptext="Start Logging"
+          label="Start" 
+          oncommand="lemurlog_Switch(event, true)"
+        />
+        <toolbarbutton 
+          id="LogTB-Start-Button-Gray" 
+          tooltiptext="Start Logging"
+          label="Start"
+          oncommand="lemurlog_Switch(event, true)"
+        />
+        <toolbarbutton 
+          id="LogTB-Pause-Button"
+          tooltiptext="Pause logging"
+          label="Pause" 
+          oncommand="lemurlog_Switch(event, false)" 
+        />
+        <toolbarbutton 
+          id="LogTB-Pause-Button-Gray" 
+          tooltiptext="Pause logging"
+          label="Pause" 
+          oncommand="lemurlog_Switch(event, false)" 
+        />
+        <toolbarbutton
+          id="LogTB-View-Button"
+          type="menu"
+          label="View  "
+          tooltiptext="View log files"
+        >
+          <menupopup>
+            <menuitem
+              label="QT Honey log"
+              tooltiptext="View QT Honey log"
+              id="qth_view_log"
+            />
+            <menuitem
+              label="Lemur Activity log"
+              tooltiptext="View activity log"
+              oncommand="lemurlog_View_Log(event, 0)" 
+            />
+            <menuitem
+              label="Lemur Search log"
+              tooltiptext="View search log"
+              oncommand="lemurlog_View_Log(event, 1)" 
+            />
+          </menupopup>
+        </toolbarbutton>
+        <toolbarbutton 
+          id="LogTB-Clear-Button" 
+          tooltiptext="Clear all log files"
+          label="Clear"
+          oncommand="lemurlog_Clear_Log(event)" 
+        />
+        <toolbarbutton 
+          id="LogTB-Upload-Button" 
+          tooltiptext="Upload log files"
+          label="Upload" 
+          oncommand="lemurlog_Upload_Log(event)" 
+        />
+        <toolbarbutton 
+          id="LogTB-Settings-Button" 
+          tooltiptext="Settings Options"
+          label="Settings"
+          oncommand="lemurlog_showsettings(event)"
+        />
+        <toolbarbutton 
+          id="LogTB-Help-Button" 
+          tooltiptext="Help information"
+          label="Help" 
+          oncommand="lemurlog_Help(event)" 
+        />
+      </toolbaritem>
+      <toolbarspring />
+    </toolbar>
+  </toolbox>
+</overlay>
+


Property changes on: src/chrome/content/logtoolbar.xul
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/qth.js
===================================================================
--- src/chrome/content/qth.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/qth.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,814 +1,814 @@
-(function(){
-////////////////////////////////////////////////////////////////////////////////
-// ライブラリ
-
-function event_observe(
-	target_element, event_name, observer_func, capture_or_bubbling) {
-	target_element.addEventListener(
-		event_name, observer_func, capture_or_bubbling || false);
-}
-
-function array_each(obj, func) {
-	if('number' == typeof obj)
-		for(var index = 0; index < obj; ++index) { if(func(index)) return; }
-	else if(undefined != obj.length)
-		for(var index2 = 0; index2 < obj.length; ++index2) {
-			if(func(obj[index2], index2)) return;
-		}
-	else
-		for(var name in obj) { if(func(obj[name], name)) return }
-}
-
-function array_each_result(array, init, func) {
-	array_each(array, function(value, key) {
-		var result = func(init, value, key);
-		init = result[0];
-		if(1 < result.length)
-			return result[1];
-		return false;
-	})
-	return init
-}
-
-function array_reduce(array, init, func) {
-	return array_each_result(array, init,
-		function(result, value, key) { return [func(result,value, key)]; }
-	)
-}
-
-function array_map(array, func) {
-	return array_reduce(array, [],
-		function(results, value, key) {
-			results.push(func(value, key)); return results;
-		}
-	)
-}
-
-function path_get_ifile(type) {
-	return Components.classes['@mozilla.org/file/directory_service;1']
-		.getService(Components.interfaces.nsIProperties)
-		.get(type, Components.interfaces.nsIFile);
-}
-
-function path_get_profile_dir() {
-	return path_get_ifile('ProfD');
-}
-
-function debug_log() {
-	if(debug_log.release)
-		return;
-
-	if(!debug_log.count)
-		debug_log.count = 0;
-	
-	var log = array_map(arguments,
-		function(item){
-			if('object' == typeof(item)) {
-				var results = [];
-				for(var key in item)
-					results.push('\t[' + key + ']=[' + item[key] + ']');
-				return '{\n' + results.sort().join(',\n') + '\n}';
-			}
-			return '[' + item + ']';
-		}
-	);
-	log = log.join(', ');
-	log = 'debug_log(' + (debug_log.count++) + ') : ' + log;
-	if(debug_log.dump)
-		dump(log + '\n');
-	else {
-		if(!debug_log.console) {
-			var nsIConsoleService = Components.interfaces.nsIConsoleService;
-			debug_log.console =
-				Components.classes['@mozilla.org/consoleservice;1']
-					.getService(nsIConsoleService);
-		}
-		debug_log.console.logStringMessage(log);
-		if(toJavaScriptConsole && !debug_log.show_console_id) {
-			debug_log.show_console_id = setTimeout(
-				function() {
-					toJavaScriptConsole();
-					debug_log.show_console_id = null;
-				}
-			);
-		}
-	}
-}
-
-var debug_message = debug_log;
-debug_log.release = (-1 == path_get_profile_dir().leafName.indexOf('develop'));
-
-function path_cd(ifile/*, args*/) {
-	var args = array_create(arguments)
-	var result = args.shift().clone()
-	return array_reduce(
-		args, result,
-		function(result, item) { result.append(item); return result }
-	)
-}
-
-function array_create(obj) {
-	return array_map(obj, function(item) { return item })
-}
-
-function ifile_append(ifile, data) {
-	var PR_WRONLY = 0x02;
-	var PR_CREATE_FILE = 0x08;
-	var PR_APPEND = 0x10
-
-	var stream = Components
-		.classes['@mozilla.org/network/file-output-stream;1']
-		.createInstance(Components.interfaces.nsIFileOutputStream);
-	stream.init(ifile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0600, false);
-	try {
-		stream.write(data, data.length);
-	}
-	finally {
-		stream.close();
-	}
-}
-
-function path_enable_dir(ifile) {
-	if (!ifile.exists())
-		ifile.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0600);
-}
-
-function path_enable(ifile) {
-	path_enable_dir(ifile.parent)
-}
-
-function string_format(format, values) {
-	function parse(format, reg_string, value) {
-		var reg_format = '([#0 -+]*)([1-9][0-9]*)?(\\.[0-9]+)*([hlL]?)([diouxXeEfFgGcrs])';
-		var matches = format.match(new RegExp(reg_string + reg_format));
-		if(!matches)
-			return format;
-		var width = parseInt(matches[3]);
-		if(!width)
-			width = 6;
-		if('i' == matches[5] || 'd' == matches[5])
-			value = parseInt(value).toString();
-		else if('o' == matches[5])
-			value = parseInt(value).toString(8);
-		else if('u' == matches[5])
-			value = (0xffffffff - parseInt(value) + 1).toString();
-		else if('x' == matches[5])
-			value = parseInt(value).toString(16).toLowerCase();
-		else if('X' == matches[5])
-			value = parseInt(value).toString(16).toUpperCase();
-		else if('e' == matches[5])
-			value = parseFloat(value).toExponential(width).toLowerCase();
-		else if('E' == matches[5])
-			value = parseFloat(value).toExponential(width).toUpperCase();
-		else if('g' == matches[5])
-			value = parseFloat(value).toPrecision(4).toLowerCase();
-		else if('G' == matches[5])
-			value = parseFloat(value).toPrecision(4).toUpperCase();
-		else if('f' == matches[5])
-			value = parseFloat(value).toFixed(width).toLowerCase();
-		else if('F' == matches[5])
-			value = parseFloat(value).toFixed(width).toUpperCase();
-
-		if(-1 != matches[1].indexOf('# ') && 'o' == matches[5] &&
-											 '0' != value.substr(0, 1))
-			value = '0' + value;
-
-		if('i' == matches[5] || 'd' == matches[5] || 'e' == matches[5] ||
-		   'E' == matches[5] || 'f' == matches[5] || 'F' == matches[5])
-		{
-			if('-' != value.substr(0,1)) {
-				if(-1 != matches[1].indexOf('+'))
-					value = '+' + value;
-				else if(-1 != matches[1].indexOf(' '))
-					value = ' ' + value;
-			}
-		}
-
-		if('i' == matches[5] || 'd' == matches[5] || 'o' == matches[5] ||
-		   'u' == matches[5] || 'x' == matches[5] || 'X' == matches[5] ||
-		   'f' == matches[5] || 'F' == matches[5])
-		{
-			if(-1 != matches[1].indexOf('0')) {
-				while(value.length < matches[2])
-					value = '0' + value;
-			}
-		}
-
-		if(-1 != matches[1].indexOf('-')) {
-			while(value.length < matches[2])
-				value += ' ';
-		}
-		return format.replace(matches[0], value);
-	}
-	if(values.length) {
-		for(var index = 0; index < values.length; ++index)
-			format = parse(format, '%', values[index]);
-	} else {
-		for(key in values)
-			format = parse(format, '%\\(' + key + '\\)', values[key]);
-	}
-	return format;
-}
-
-function date_time_get_now_dict() {
-	var now = new Date();
-	return {
-		'year': now.getFullYear(),
-		'month': now.getMonth() + 1,
-		'date': now.getDate(),
-		'hour': now.getHours(),
-		'min': now.getMinutes(),
-		'sec': now.getSeconds(),
-		'msec': now.getMilliseconds()
-	}
-}
-
-function config_get(key, default_value) {
-	const nsIPrefBranch = Components.interfaces.nsIPrefBranch
-	const prefBranch = Components.classes['@mozilla.org/preferences;1']
-													.getService(nsIPrefBranch)
-	switch(prefBranch.getPrefType(key)) {
-		case nsIPrefBranch.PREF_INVALID: return default_value || null;
-		case nsIPrefBranch.PREF_INT: return prefBranch.getIntPref(key);
-		case nsIPrefBranch.PREF_BOOL: return prefBranch.getBoolPref(key);
-		case nsIPrefBranch.PREF_STRING:
-			try {
-				var result = prefBranch.getCharPref(key);
-				var chrome_str = 'chrome://';
-				if(chrome_str == result.substr(0, chrome_str.length)) {
-					return Components.classes['@mozilla.org/intl/stringbundle;1']
-						.getService(Components.interfaces.nsIStringBundleService)
-						.createBundle(result).GetStringFromName(key)
-				} else
-					return result;
-			} catch(e) {
-				return default_value || null;
-			}
-	}
-	return default_value || null;
-}
-
-function config_set(key, value) {
-	//http://piro.sakura.ne.jp/xul/tips/x0007.html
-	const nsIPrefBranch = Components.interfaces.nsIPrefBranch
-	const prefBranch = Components.classes['@mozilla.org/preferences;1']
-													.getService(nsIPrefBranch)
-	var setter = prefBranch.setCharPref;
-	switch(typeof value) {
-		case 'boolean': setter = prefBranch.setBoolPref; break;
-		case 'number': setter = prefBranch.setIntPref; break;
-	}
-	try {
-		setter(key, value)
-	} catch(e) {
-		prefBranch.clearUserPref(key)
-		setter(key, value)
-	}
-}
-
-function session_set(tab, key, value) {
-	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
-							.getService(Components.interfaces.nsISessionStore);
-	nsISessionStore.setTabValue(tab, key, value);
-}
-
-function session_get(tab, key, default_value) {
-	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
-							.getService(Components.interfaces.nsISessionStore);
-	return nsISessionStore.getTabValue(tab, key) || default_value;
-}
-
-function session_del(tab, key) {
-	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
-							.getService(Components.interfaces.nsISessionStore);
-	return nsISessionStore.deleteTabValue(tab, key);
-}
-
-function date_time_get_epoch() {
-	return (new Date()).getTime();
-}
-
-function string_encode(string, src, dst) {
-	var result = string.toString();
-	var UConv = Components.classes['@mozilla.org/intl/scriptableunicodeconverter']
-			.getService(Components.interfaces.nsIScriptableUnicodeConverter);
-	if(src) {
-		UConv.charset = src;
-		result = UConv.ConvertToUnicode(result);
-	}
-	if(dst) {
-		UConv.charset = dst;
-		result = UConv.ConvertFromUnicode(result);
-	}
-	return result
-}
-
-function dict_update(target, arg) {
-	for(var key in arg)
-		target[key] = arg[key];
-	return target;
-}
-
-function dict_get( dict, key, default_value )
-{
-	if( !( key in dict ) )
-		return default_value || null
-	return dict[key]
-}
-
-function dom_get(id) {
-	return document.getElementById(id)
-}
-
-function xpcom_get(component_id) {
-	return Components.classes[component_id].getService().wrappedJSObject;
-}
-
-function dict_set_default(dict, key, default_value) {
-	if(!(key in dict))
-		dict[key] = default_value
-	return dict[key]
-}
-
-function function_wrap(original_func, wrap_func){
-	return function(){
-		return wrap_func.apply({original_func: original_func}, arguments);
-	}
-}
-
-function url_split(url) {
-	var url_part = url.split('?')
-	return [url_part.shift(), url_parse_query(url_part.join('?'))]
-}
-
-function url_parse_query(queries) {
-	return array_reduce(queries.split('&'), {}, 
-		function(results, query, index) {
-			var key_value = query.split('=')
-			results[decodeURIComponent(key_value[0])] =
-				decodeURIComponent(key_value[1])
-			return results
-		}
-	)
-}
-
-function ifile_from_path(path) {
-	var ifile = Components.classes['@mozilla.org/file/local;1']
-							.createInstance(Components.interfaces.nsILocalFile);
-	ifile.initWithPath(path);
-	return ifile;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// QTH実装
-
-// まずlemurのログ関数をラップして、lemurのイベントをフックする。
-lemurlog_WriteLogFile = function_wrap(lemurlog_WriteLogFile, function(fileName, text) {
-	on_lemur_event(text);
-	this.original_func(fileName, text);
-});
-
-// lemurのログ関数のフックハンドラ。lemurのイベントのうち、使えるものは使う。
-
-function on_lemur_event(original_log) {
-	// ログ用の辞書を用意
-	var log = {'original_log': original_log}
-
-	// イベントラベルをチェック
-	switch(original_log.split('\t')[0]) {
-		case 'StartLogging': log['event_label'] = 'start'; break;
-		case 'PauseLogging': log['event_label'] = 'end'; break;
-		case 'Focus': log['event_label'] = 'focus'; break;
-		case 'Blur': log['event_label'] = 'blur'; break;
-		case 'Scroll': log['event_label'] = 'scroll'; break;
-		case 'CtrlC': log['event_label'] = 'copy'; break;
-		case 'RmTab': log['event_label'] = 'close'; break;
-		//処理しない。
-		case 'SelTab': //log['event_label'] = 'change'; break;	//-> 独自に検出するので処理しない。
-		case 'AddTab':
-		case 'Show':
-		case 'Hide':
-			return;
-		default: debug_log(original_log); return;
-	}
-
-	// ログデータを作成
-	append_log(build_log(log))
-
-	//この後、従来通りlemurのログも保存される
-}
-
-// qth専用で、全てのウインドウ共有の辞書を取得
-function get_globals() {
-	var qth_globals = xpcom_get('@kyagroup.com/qth_toolbar/singleton_object;1');
-
-	// 起動直後の場合は初期化しておく
-
-	// タブの通し番号用変数が初期化されていなければ0に初期化
-	dict_set_default(qth_globals, 'tab_count', 0);
-	// changeイベント用の前回アクティブだったタブId用変数を0に初期化
-	dict_set_default(qth_globals, 'pre_tab_id', 0);
-	// タブの付帯データ辞書もなければ初期化
-	dict_set_default(qth_globals, 'tabs', {});
-	dict_set_default(qth_globals, 'pre_search_data', default_search_data());
-	
-
-	return qth_globals
-}
-
-// ログ文字列作成用のパラメータを作って返す。
-// ログ項目のデフォルト値を持った辞書を作成する。
-// 作成した辞書に、引数の辞書で上書きしたものを返す。
-function build_log(log_option) {
-	// ログ用の辞書を用意
-	var log = {};
-
-	// 現在の日時を示す文字列を作成して記録
-	var date_format = '%(year)04d%(month)02d%(date)02d%(hour)02d%(min)02d%(sec)02d.%(msec)04d';
-	log['date_str'] = string_format(date_format, date_time_get_now_dict());
-
-	// アクティブなタブのIDを取得
-	var tab_id = get_current_tab_id();
-	log['tab_id'] = tab_id;
-
-	// そのIDに紐づいたデータ辞書を取得
-	var tab_data = get_current_tab_data(tab_id);
-	log['session_time'] = date_time_get_epoch() - tab_data.created;
-
-	// URLやタイトルを記録
-	log['title'] = gBrowser.contentDocument.title;
-	log['url'] = gBrowser.contentDocument.location.href;
-
-	// ページIDを取得
-	log['page_id'] = get_page_id(tab_data, log['url']);
-
-	// 検索結果かどうかを判定
-	log = dict_update(log, extract_search_data(log['url']))
-
-	// デフォルト値を設定
-	log['anchor_text'] = '';
-	log['next_url'] = '';
-	log['next_page_id'] = '';
-	log['source_name'] = '';
-
-	log['bookmark_title'] = '';
-	log['submit_options'] = '';
-	log['submit_action_url'] = '';
-
-	return dict_update(log, log_option);
-}
-
-function extract_search_data(url) {
-	var splitted_url = url_split(url);
-	
-	if(!get_globals().search_engines) {
-		var search_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_search_list.json');
-
-		var data = "";
-		var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
-		                        .createInstance(Components.interfaces.nsIFileInputStream);
-		var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
-		                        .createInstance(Components.interfaces.nsIScriptableInputStream);
-		try {
-			fstream.init(search_ifile, -1, 0, 0);
-			try {
-				sstream.init(fstream); 
-				var str = sstream.read(4096);
-				while (str.length > 0) {
-				  data += str;
-				  str = sstream.read(4096);
-				}
-
-				var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
-				get_globals().search_engines = nativeJSON.decode(data);
-			} catch(e){
-			}
-			sstream.close();
-		} catch(e) {
-			get_globals().search_engines = [];
-		}
-		fstream.close();
-	}
-
-	var search_engines = get_globals().search_engines;
-
-	for(var i = 0; i < search_engines.length; i++) {
-		var search_engine = search_engines[i];
-		var matched = splitted_url[0].match(search_engine['base_url'])
-		if(matched) {
-			var result = {
-				'search_label': search_engines[i]['search_label'],
-				'page_kind': 'search_result_page',
-				'result_item_index': dict_get(splitted_url[1], search_engines[i]['index_key'], 0)
-			};
-
-			if('in_url' == search_engine['keyword_type'])
-				result['keyword'] = matched[search_engine['keyword_index']];
-			else if('parameter' == search_engine['keyword_type'])
-				result['keyword'] = splitted_url[1][search_engine['keyword_key']];
-
-			return result;
-		}
-	}
-
-	return default_search_data();
-}
-
-function	default_search_data() {
-	return {
-		'search_label': '',
-		'page_kind': 'unknown_page',	// 基本的に未知のページとみなす。
-		'keyword': '',
-		'result_item_index': ''
-	};
-}
-
-// アクティブなタブのQTH管理用IDを取得する。
-// もしまだIDが降られていなければ振って、付帯データストアを初期化する。
-function get_current_tab_id() {
-	// タブからIDを取ってみる
-	var tab_id = session_get(gBrowser.selectedTab, 'qth_tab_id');
-	if(!tab_id || !(tab_id in get_globals().tabs)) {
-		// タブにセッションIDがない == 新規セッション
-		// 新しいidを取得
-		tab_id = get_globals().tab_count++;
-
-		// タブにidを関連付け
-		session_set(gBrowser.selectedTab, 'qth_tab_id', tab_id);
-
-		// タブに対応するデータ辞書を初期化
-		get_globals().tabs[tab_id] = init_tab_data(tab_id);
-	}
-
-	return tab_id;
-}
-
-function init_tab_data(tab_id) {
-	var tab_data = {};
-
-	// セッションの開始時間を記録
-	tab_data.created = date_time_get_epoch();
-
-	// ページ番号を初期化
-	tab_data.page_count = 0;
-	tab_data.url2page_id = {};
-	
-	// セッションのURLも初期化
-	tab_data.pre_url = '';
-
-	return tab_data;
-}
-
-function get_current_tab_data(/*[optional]*/ tab_id) {
-	tab_id = tab_id || get_current_tab_id();
-	return get_globals().tabs[tab_id];
-}
-
-// URLに対応するページIDを返す。
-function get_page_id(tab_data, current_url) {
-	// すでに開いたことのあるページならそのページのIDを返す。
-	if(current_url in tab_data.url2page_id)
-		return tab_data.url2page_id[current_url];
-	
-	// 新しいページなので、ページIDを振りあて
-	tab_data.url2page_id[current_url] = ++tab_data.page_count;
-
-	// ページを保存する
-	var date_format = '%(year)04d-%(month)02d-%(date)02d_%(hour)02d-%(min)02d-%(sec)02d-%(msec)04d';
-	var current_date_str = string_format(date_format, date_time_get_now_dict());
-	
-	var base_name = current_date_str + '.' + tab_data.url2page_id[current_url];
-
-	var dst_ifile = path_cd(path_get_profile_dir(), 'QT', 'archive', 'data', base_name +'.html');
-	path_enable(dst_ifile);
-
-	var dst_folder_ifile = path_cd(path_get_profile_dir(), 'QT', 'archive', 'data', base_name);
-
-	var persist = makeWebBrowserPersist();
-
-    const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
-    var persist_flags = 0;
-    persist_flags |=  nsIWBP.PERSIST_FLAGS_FROM_CACHE;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_IGNORE_REDIRECTED_DATA;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_IGNORE_IFRAMES;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
-    persist_flags |=  nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FIXUP_ORIGINAL_DOM;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FIXUP_LINKS_TO_DESTINATION;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_DONT_FIXUP_LINKS;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_SERIALIZE_OUTPUT;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_DONT_CHANGE_FILENAMES;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS;
-//     persist_flags |=  nsIWBP.PERSIST_FLAGS_CLEANUP_ON_FAILURE;
-    persist_flags |=  nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
-
-	persist.persistFlags = persist_flags;
-
-	persist.saveDocument(gBrowser.contentDocument, dst_ifile, dst_folder_ifile, 'text/html', Components.interfaces.nsIWebBrowserPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES, 80);
-
-	return tab_data.url2page_id[current_url];
-}
-
-// 実際に文字列を生成してログファイルに書き込む
-function append_log(log) {
-
-	// もし、前回のログ保存時からtab_idが変わっていたらchangeイベントを発行する。
-	if(get_globals().pre_tab_id != log['tab_id']) {
-		get_globals().pre_tab_id = log['tab_id'];
-		append_log(build_log({'event_label': 'change'}));
-	}
-
-	// ログファイルに書き込み
-	var log_format = '%(date_str)s\t%(session_time)s\t%(tab_id)s\t%(page_id)s\t%(event_label)s\t%(url)s\t%(title)s\t%(page_kind)s\t%(search_label)s\t%(keyword)s\t%(anchor_text)s\t%(next_url)s\t%(bookmark_title)s\t%(source_name)s\t%(submit_options)s\t%(submit_action_url)s\t%(next_page_id)s\t%(result_item_index)s\n';
-	var log_text = string_format(log_format, log);
-
-	log_text = string_encode(log_text, null, 'UTF-8');
-
-	// QTH用のログファイルを用意
-	var log_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_toolbar_log');
-	path_enable(log_ifile);
-
-	// 追記
-	ifile_append(log_ifile, log_text);
-	
-	// ステータスダイアログを更新
-	// window.openDialog('chrome://qthtoolbar/content/status.xul', 'qth_status', 'width=300,height=100,chrome', log, debug_log);
-}
-
-
-// 以降QTH独自のイベントを得るための処理
-// まずウインドウの初期化終了時にアタッチ
-event_observe(window, 'load',
-	function() {
-		// 次にウインドウ内のページが読み込まれたときのイベントにアタッチ
-		// link用
-		attach_on_content_loaded()
-
-		// 進むボタン・戻るボタンにもアタッチ
-		// next, return用
-		event_observe(dom_get('back-button'), 'click',
-			function(){
-				var tab_data = get_current_tab_data();
-
-				var log = {
-					'event_label': 'return',
-					'next_url': gBrowser.contentWindow.history.previous
-				};
-
-				log['next_page_id'] = get_page_id(tab_data, log['next_url']);
-
-				append_log(build_log(log));
-			}
-		)
-		event_observe(dom_get('forward-button'), 'click',
-			function(){
-				var tab_data = get_current_tab_data();
-
-				var log = {
-					'event_label': 'next',
-					'next_url': gBrowser.contentWindow.history.next
-				};
-
-				log['next_page_id'] = get_page_id(tab_data, log['next_url']);
-
-				append_log(build_log(log));
-			}
-		)
-		event_observe(dom_get('qth_view_log'), 'click',
-			function() {
-				var log_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_toolbar_log');
-				loadURI(log_ifile.path)
-			}
-		);
-
-		var orig = document.getElementById('FindToolbar').open;
-		document.getElementById('FindToolbar').open = function(){
-			append_log(build_log({'event_label': 'find'}));
-			return orig.apply(document.getElementById('FindToolbar'), arguments);
-		}
-		
-		event_observe(document.getElementById('editBookmarkPanelDoneButton'), 'click',
-			function(){
-				var log = build_log({'event_label': 'bookmark'});
-				log['bookmark_title'] = log['title']
-				append_log(log);
-			}
-		)
-	}
-)
-
-// 各ページの読み込み完了時のハンドラ。
-// すべてのAタグにアタッチしてlinkイベントを取る。
-function attach_on_content_loaded() {
-	event_observe(document.getElementById('appcontent'), 'DOMContentLoaded',
-		function(){
-			append_log(build_log({'event_label': 'load'}));
-		},
-		true
-	)
-
-	// ウインドウ内のページが読み込まれたときのイベントにアタッチ
-	event_observe(document.getElementById('appcontent'), 'DOMContentLoaded',
-		function(event) {
-			append_log(build_log({'event_label': 'show'}));
-			// 読み込まれたページのdocumentを取得
-			var document = event.target.defaultView.document;
-
-			array_each(document.getElementsByTagName('INPUT'),
-				function(tag) {
-					event_observe(tag, 'paste',
-						function(event) {
-							append_log(build_log({'event_label': 'paste'}));
-						}
-					)
-				}
-			)
-			array_each(document.getElementsByTagName('TEXTAREA'),
-				function(tag) {
-					event_observe(tag, 'paste',
-						function(event) {
-							append_log(build_log({'event_label': 'paste'}));
-						}
-					)
-				}
-			)
-			
-			// linkイベントのためにaタグのclickイベントにアタッチ
-			var a_tags = document.getElementsByTagName('A');
-			array_each(a_tags,
-				function(a_tag) {
-					event_observe(a_tag, 'click',
-						function(event) {
-							var tab_data = get_current_tab_data();
-
-							var log = {
-								'event_label': 'link',
-								'anchor_text': event.target.textContent,
-								'next_url': event.target.getAttribute('href')
-							};
-
-							log['next_page_id'] = get_page_id(tab_data, log['next_url']);
-
-							if(event.target.hasAttribute('name'))
-								log['source_name'] = event.target.getAttribute('name');
-
-							append_log(build_log(log));
-						}
-					)
-				}
-			)
-			var form_tags = document.getElementsByTagName('FORM');
-			array_each(form_tags,
-				function(form_tag) {
-					event_observe(form_tag, 'submit',
-						function(event) {
-
-							var log = {
-								'event_label': 'submit',
-								'submit_action_url': event.target.getAttribute('action')
-							};
-
-							var tab_data = get_current_tab_data();
-							log['next_page_id'] = get_page_id(tab_data, log['submit_action_url']);
-
-							if(event.target.hasAttribute('id'))
-								log['source_name'] = event.target.getAttribute('id');
-							else if(event.target.hasAttribute('name'))
-								log['source_name'] = event.target.getAttribute('name');
-
-							//log['submit_options'] = ;
-
-							append_log(build_log(log));
-						}
-					)
-				}
-			)
-
-			// 検索結果ならsearch/browseイベントをログ
-			var url = document.location.href;
-			var search_data = extract_search_data(url);
-			if('search_result_page' == search_data['page_kind']) {
-				// 検索結果。search/browseイベント発生。
-				// 今検索中で、前回とサーチエンジンとキーワードが同じならbrowse
-				var pre_search_data = get_globals().pre_search_data;
-				if(
-					pre_search_data['search_label'] == search_data['search_label'] &&
-					pre_search_data['keyword'] == search_data['keyword']
-				) {
-					// 同じ。browse
-					append_log(build_log({'event_label': 'browse'}));
-				} else {
-					// 違う。search。
-					append_log(build_log({'event_label': 'search'}));
-				}
-			}
-			// 検索に関するデータを保存
-			get_globals().pre_search_data = search_data;
-		}
-	)
-}
-
-////////////////////////////////////////////////////////////////////////////////
-})()
+(function(){
+////////////////////////////////////////////////////////////////////////////////
+// ライブラリ
+
+function event_observe(
+	target_element, event_name, observer_func, capture_or_bubbling) {
+	target_element.addEventListener(
+		event_name, observer_func, capture_or_bubbling || false);
+}
+
+function array_each(obj, func) {
+	if('number' == typeof obj)
+		for(var index = 0; index < obj; ++index) { if(func(index)) return; }
+	else if(undefined != obj.length)
+		for(var index2 = 0; index2 < obj.length; ++index2) {
+			if(func(obj[index2], index2)) return;
+		}
+	else
+		for(var name in obj) { if(func(obj[name], name)) return }
+}
+
+function array_each_result(array, init, func) {
+	array_each(array, function(value, key) {
+		var result = func(init, value, key);
+		init = result[0];
+		if(1 < result.length)
+			return result[1];
+		return false;
+	})
+	return init
+}
+
+function array_reduce(array, init, func) {
+	return array_each_result(array, init,
+		function(result, value, key) { return [func(result,value, key)]; }
+	)
+}
+
+function array_map(array, func) {
+	return array_reduce(array, [],
+		function(results, value, key) {
+			results.push(func(value, key)); return results;
+		}
+	)
+}
+
+function path_get_ifile(type) {
+	return Components.classes['@mozilla.org/file/directory_service;1']
+		.getService(Components.interfaces.nsIProperties)
+		.get(type, Components.interfaces.nsIFile);
+}
+
+function path_get_profile_dir() {
+	return path_get_ifile('ProfD');
+}
+
+function debug_log() {
+	if(debug_log.release)
+		return;
+
+	if(!debug_log.count)
+		debug_log.count = 0;
+	
+	var log = array_map(arguments,
+		function(item){
+			if('object' == typeof(item)) {
+				var results = [];
+				for(var key in item)
+					results.push('\t[' + key + ']=[' + item[key] + ']');
+				return '{\n' + results.sort().join(',\n') + '\n}';
+			}
+			return '[' + item + ']';
+		}
+	);
+	log = log.join(', ');
+	log = 'debug_log(' + (debug_log.count++) + ') : ' + log;
+	if(debug_log.dump)
+		dump(log + '\n');
+	else {
+		if(!debug_log.console) {
+			var nsIConsoleService = Components.interfaces.nsIConsoleService;
+			debug_log.console =
+				Components.classes['@mozilla.org/consoleservice;1']
+					.getService(nsIConsoleService);
+		}
+		debug_log.console.logStringMessage(log);
+		if(toJavaScriptConsole && !debug_log.show_console_id) {
+			debug_log.show_console_id = setTimeout(
+				function() {
+					toJavaScriptConsole();
+					debug_log.show_console_id = null;
+				}
+			);
+		}
+	}
+}
+
+var debug_message = debug_log;
+debug_log.release = (-1 == path_get_profile_dir().leafName.indexOf('develop'));
+
+function path_cd(ifile/*, args*/) {
+	var args = array_create(arguments)
+	var result = args.shift().clone()
+	return array_reduce(
+		args, result,
+		function(result, item) { result.append(item); return result }
+	)
+}
+
+function array_create(obj) {
+	return array_map(obj, function(item) { return item })
+}
+
+function ifile_append(ifile, data) {
+	var PR_WRONLY = 0x02;
+	var PR_CREATE_FILE = 0x08;
+	var PR_APPEND = 0x10
+
+	var stream = Components
+		.classes['@mozilla.org/network/file-output-stream;1']
+		.createInstance(Components.interfaces.nsIFileOutputStream);
+	stream.init(ifile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0600, false);
+	try {
+		stream.write(data, data.length);
+	}
+	finally {
+		stream.close();
+	}
+}
+
+function path_enable_dir(ifile) {
+	if (!ifile.exists())
+		ifile.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0600);
+}
+
+function path_enable(ifile) {
+	path_enable_dir(ifile.parent)
+}
+
+function string_format(format, values) {
+	function parse(format, reg_string, value) {
+		var reg_format = '([#0 -+]*)([1-9][0-9]*)?(\\.[0-9]+)*([hlL]?)([diouxXeEfFgGcrs])';
+		var matches = format.match(new RegExp(reg_string + reg_format));
+		if(!matches)
+			return format;
+		var width = parseInt(matches[3]);
+		if(!width)
+			width = 6;
+		if('i' == matches[5] || 'd' == matches[5])
+			value = parseInt(value).toString();
+		else if('o' == matches[5])
+			value = parseInt(value).toString(8);
+		else if('u' == matches[5])
+			value = (0xffffffff - parseInt(value) + 1).toString();
+		else if('x' == matches[5])
+			value = parseInt(value).toString(16).toLowerCase();
+		else if('X' == matches[5])
+			value = parseInt(value).toString(16).toUpperCase();
+		else if('e' == matches[5])
+			value = parseFloat(value).toExponential(width).toLowerCase();
+		else if('E' == matches[5])
+			value = parseFloat(value).toExponential(width).toUpperCase();
+		else if('g' == matches[5])
+			value = parseFloat(value).toPrecision(4).toLowerCase();
+		else if('G' == matches[5])
+			value = parseFloat(value).toPrecision(4).toUpperCase();
+		else if('f' == matches[5])
+			value = parseFloat(value).toFixed(width).toLowerCase();
+		else if('F' == matches[5])
+			value = parseFloat(value).toFixed(width).toUpperCase();
+
+		if(-1 != matches[1].indexOf('# ') && 'o' == matches[5] &&
+											 '0' != value.substr(0, 1))
+			value = '0' + value;
+
+		if('i' == matches[5] || 'd' == matches[5] || 'e' == matches[5] ||
+		   'E' == matches[5] || 'f' == matches[5] || 'F' == matches[5])
+		{
+			if('-' != value.substr(0,1)) {
+				if(-1 != matches[1].indexOf('+'))
+					value = '+' + value;
+				else if(-1 != matches[1].indexOf(' '))
+					value = ' ' + value;
+			}
+		}
+
+		if('i' == matches[5] || 'd' == matches[5] || 'o' == matches[5] ||
+		   'u' == matches[5] || 'x' == matches[5] || 'X' == matches[5] ||
+		   'f' == matches[5] || 'F' == matches[5])
+		{
+			if(-1 != matches[1].indexOf('0')) {
+				while(value.length < matches[2])
+					value = '0' + value;
+			}
+		}
+
+		if(-1 != matches[1].indexOf('-')) {
+			while(value.length < matches[2])
+				value += ' ';
+		}
+		return format.replace(matches[0], value);
+	}
+	if(values.length) {
+		for(var index = 0; index < values.length; ++index)
+			format = parse(format, '%', values[index]);
+	} else {
+		for(key in values)
+			format = parse(format, '%\\(' + key + '\\)', values[key]);
+	}
+	return format;
+}
+
+function date_time_get_now_dict() {
+	var now = new Date();
+	return {
+		'year': now.getFullYear(),
+		'month': now.getMonth() + 1,
+		'date': now.getDate(),
+		'hour': now.getHours(),
+		'min': now.getMinutes(),
+		'sec': now.getSeconds(),
+		'msec': now.getMilliseconds()
+	}
+}
+
+function config_get(key, default_value) {
+	const nsIPrefBranch = Components.interfaces.nsIPrefBranch
+	const prefBranch = Components.classes['@mozilla.org/preferences;1']
+													.getService(nsIPrefBranch)
+	switch(prefBranch.getPrefType(key)) {
+		case nsIPrefBranch.PREF_INVALID: return default_value || null;
+		case nsIPrefBranch.PREF_INT: return prefBranch.getIntPref(key);
+		case nsIPrefBranch.PREF_BOOL: return prefBranch.getBoolPref(key);
+		case nsIPrefBranch.PREF_STRING:
+			try {
+				var result = prefBranch.getCharPref(key);
+				var chrome_str = 'chrome://';
+				if(chrome_str == result.substr(0, chrome_str.length)) {
+					return Components.classes['@mozilla.org/intl/stringbundle;1']
+						.getService(Components.interfaces.nsIStringBundleService)
+						.createBundle(result).GetStringFromName(key)
+				} else
+					return result;
+			} catch(e) {
+				return default_value || null;
+			}
+	}
+	return default_value || null;
+}
+
+function config_set(key, value) {
+	//http://piro.sakura.ne.jp/xul/tips/x0007.html
+	const nsIPrefBranch = Components.interfaces.nsIPrefBranch
+	const prefBranch = Components.classes['@mozilla.org/preferences;1']
+													.getService(nsIPrefBranch)
+	var setter = prefBranch.setCharPref;
+	switch(typeof value) {
+		case 'boolean': setter = prefBranch.setBoolPref; break;
+		case 'number': setter = prefBranch.setIntPref; break;
+	}
+	try {
+		setter(key, value)
+	} catch(e) {
+		prefBranch.clearUserPref(key)
+		setter(key, value)
+	}
+}
+
+function session_set(tab, key, value) {
+	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
+							.getService(Components.interfaces.nsISessionStore);
+	nsISessionStore.setTabValue(tab, key, value);
+}
+
+function session_get(tab, key, default_value) {
+	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
+							.getService(Components.interfaces.nsISessionStore);
+	return nsISessionStore.getTabValue(tab, key) || default_value;
+}
+
+function session_del(tab, key) {
+	var nsISessionStore = Components.classes["@mozilla.org/browser/sessionstore;1"]
+							.getService(Components.interfaces.nsISessionStore);
+	return nsISessionStore.deleteTabValue(tab, key);
+}
+
+function date_time_get_epoch() {
+	return (new Date()).getTime();
+}
+
+function string_encode(string, src, dst) {
+	var result = string.toString();
+	var UConv = Components.classes['@mozilla.org/intl/scriptableunicodeconverter']
+			.getService(Components.interfaces.nsIScriptableUnicodeConverter);
+	if(src) {
+		UConv.charset = src;
+		result = UConv.ConvertToUnicode(result);
+	}
+	if(dst) {
+		UConv.charset = dst;
+		result = UConv.ConvertFromUnicode(result);
+	}
+	return result
+}
+
+function dict_update(target, arg) {
+	for(var key in arg)
+		target[key] = arg[key];
+	return target;
+}
+
+function dict_get( dict, key, default_value )
+{
+	if( !( key in dict ) )
+		return default_value || null
+	return dict[key]
+}
+
+function dom_get(id) {
+	return document.getElementById(id)
+}
+
+function xpcom_get(component_id) {
+	return Components.classes[component_id].getService().wrappedJSObject;
+}
+
+function dict_set_default(dict, key, default_value) {
+	if(!(key in dict))
+		dict[key] = default_value
+	return dict[key]
+}
+
+function function_wrap(original_func, wrap_func){
+	return function(){
+		return wrap_func.apply({original_func: original_func}, arguments);
+	}
+}
+
+function url_split(url) {
+	var url_part = url.split('?')
+	return [url_part.shift(), url_parse_query(url_part.join('?'))]
+}
+
+function url_parse_query(queries) {
+	return array_reduce(queries.split('&'), {}, 
+		function(results, query, index) {
+			var key_value = query.split('=')
+			results[decodeURIComponent(key_value[0])] =
+				decodeURIComponent(key_value[1])
+			return results
+		}
+	)
+}
+
+function ifile_from_path(path) {
+	var ifile = Components.classes['@mozilla.org/file/local;1']
+							.createInstance(Components.interfaces.nsILocalFile);
+	ifile.initWithPath(path);
+	return ifile;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// QTH実装
+
+// まずlemurのログ関数をラップして、lemurのイベントをフックする。
+lemurlog_WriteLogFile = function_wrap(lemurlog_WriteLogFile, function(fileName, text) {
+	on_lemur_event(text);
+	this.original_func(fileName, text);
+});
+
+// lemurのログ関数のフックハンドラ。lemurのイベントのうち、使えるものは使う。
+
+function on_lemur_event(original_log) {
+	// ログ用の辞書を用意
+	var log = {'original_log': original_log}
+
+	// イベントラベルをチェック
+	switch(original_log.split('\t')[0]) {
+		case 'StartLogging': log['event_label'] = 'start'; break;
+		case 'PauseLogging': log['event_label'] = 'end'; break;
+		case 'Focus': log['event_label'] = 'focus'; break;
+		case 'Blur': log['event_label'] = 'blur'; break;
+		case 'Scroll': log['event_label'] = 'scroll'; break;
+		case 'CtrlC': log['event_label'] = 'copy'; break;
+		case 'RmTab': log['event_label'] = 'close'; break;
+		//処理しない。
+		case 'SelTab': //log['event_label'] = 'change'; break;	//-> 独自に検出するので処理しない。
+		case 'AddTab':
+		case 'Show':
+		case 'Hide':
+			return;
+		default: debug_log(original_log); return;
+	}
+
+	// ログデータを作成
+	append_log(build_log(log))
+
+	//この後、従来通りlemurのログも保存される
+}
+
+// qth専用で、全てのウインドウ共有の辞書を取得
+function get_globals() {
+	var qth_globals = xpcom_get('@kyagroup.com/qth_toolbar/singleton_object;1');
+
+	// 起動直後の場合は初期化しておく
+
+	// タブの通し番号用変数が初期化されていなければ0に初期化
+	dict_set_default(qth_globals, 'tab_count', 0);
+	// changeイベント用の前回アクティブだったタブId用変数を0に初期化
+	dict_set_default(qth_globals, 'pre_tab_id', 0);
+	// タブの付帯データ辞書もなければ初期化
+	dict_set_default(qth_globals, 'tabs', {});
+	dict_set_default(qth_globals, 'pre_search_data', default_search_data());
+	
+
+	return qth_globals
+}
+
+// ログ文字列作成用のパラメータを作って返す。
+// ログ項目のデフォルト値を持った辞書を作成する。
+// 作成した辞書に、引数の辞書で上書きしたものを返す。
+function build_log(log_option) {
+	// ログ用の辞書を用意
+	var log = {};
+
+	// 現在の日時を示す文字列を作成して記録
+	var date_format = '%(year)04d%(month)02d%(date)02d%(hour)02d%(min)02d%(sec)02d.%(msec)04d';
+	log['date_str'] = string_format(date_format, date_time_get_now_dict());
+
+	// アクティブなタブのIDを取得
+	var tab_id = get_current_tab_id();
+	log['tab_id'] = tab_id;
+
+	// そのIDに紐づいたデータ辞書を取得
+	var tab_data = get_current_tab_data(tab_id);
+	log['session_time'] = date_time_get_epoch() - tab_data.created;
+
+	// URLやタイトルを記録
+	log['title'] = gBrowser.contentDocument.title;
+	log['url'] = gBrowser.contentDocument.location.href;
+
+	// ページIDを取得
+	log['page_id'] = get_page_id(tab_data, log['url']);
+
+	// 検索結果かどうかを判定
+	log = dict_update(log, extract_search_data(log['url']))
+
+	// デフォルト値を設定
+	log['anchor_text'] = '';
+	log['next_url'] = '';
+	log['next_page_id'] = '';
+	log['source_name'] = '';
+
+	log['bookmark_title'] = '';
+	log['submit_options'] = '';
+	log['submit_action_url'] = '';
+
+	return dict_update(log, log_option);
+}
+
+function extract_search_data(url) {
+	var splitted_url = url_split(url);
+	
+	if(!get_globals().search_engines) {
+		var search_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_search_list.json');
+
+		var data = "";
+		var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
+		                        .createInstance(Components.interfaces.nsIFileInputStream);
+		var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
+		                        .createInstance(Components.interfaces.nsIScriptableInputStream);
+		try {
+			fstream.init(search_ifile, -1, 0, 0);
+			try {
+				sstream.init(fstream); 
+				var str = sstream.read(4096);
+				while (str.length > 0) {
+				  data += str;
+				  str = sstream.read(4096);
+				}
+
+				var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
+				get_globals().search_engines = nativeJSON.decode(data);
+			} catch(e){
+			}
+			sstream.close();
+		} catch(e) {
+			get_globals().search_engines = [];
+		}
+		fstream.close();
+	}
+
+	var search_engines = get_globals().search_engines;
+
+	for(var i = 0; i < search_engines.length; i++) {
+		var search_engine = search_engines[i];
+		var matched = splitted_url[0].match(search_engine['base_url'])
+		if(matched) {
+			var result = {
+				'search_label': search_engines[i]['search_label'],
+				'page_kind': 'search_result_page',
+				'result_item_index': dict_get(splitted_url[1], search_engines[i]['index_key'], 0)
+			};
+
+			if('in_url' == search_engine['keyword_type'])
+				result['keyword'] = matched[search_engine['keyword_index']];
+			else if('parameter' == search_engine['keyword_type'])
+				result['keyword'] = splitted_url[1][search_engine['keyword_key']];
+
+			return result;
+		}
+	}
+
+	return default_search_data();
+}
+
+function	default_search_data() {
+	return {
+		'search_label': '',
+		'page_kind': 'unknown_page',	// 基本的に未知のページとみなす。
+		'keyword': '',
+		'result_item_index': ''
+	};
+}
+
+// アクティブなタブのQTH管理用IDを取得する。
+// もしまだIDが降られていなければ振って、付帯データストアを初期化する。
+function get_current_tab_id() {
+	// タブからIDを取ってみる
+	var tab_id = session_get(gBrowser.selectedTab, 'qth_tab_id');
+	if(!tab_id || !(tab_id in get_globals().tabs)) {
+		// タブにセッションIDがない == 新規セッション
+		// 新しいidを取得
+		tab_id = get_globals().tab_count++;
+
+		// タブにidを関連付け
+		session_set(gBrowser.selectedTab, 'qth_tab_id', tab_id);
+
+		// タブに対応するデータ辞書を初期化
+		get_globals().tabs[tab_id] = init_tab_data(tab_id);
+	}
+
+	return tab_id;
+}
+
+function init_tab_data(tab_id) {
+	var tab_data = {};
+
+	// セッションの開始時間を記録
+	tab_data.created = date_time_get_epoch();
+
+	// ページ番号を初期化
+	tab_data.page_count = 0;
+	tab_data.url2page_id = {};
+	
+	// セッションのURLも初期化
+	tab_data.pre_url = '';
+
+	return tab_data;
+}
+
+function get_current_tab_data(/*[optional]*/ tab_id) {
+	tab_id = tab_id || get_current_tab_id();
+	return get_globals().tabs[tab_id];
+}
+
+// URLに対応するページIDを返す。
+function get_page_id(tab_data, current_url) {
+	// すでに開いたことのあるページならそのページのIDを返す。
+	if(current_url in tab_data.url2page_id)
+		return tab_data.url2page_id[current_url];
+	
+	// 新しいページなので、ページIDを振りあて
+	tab_data.url2page_id[current_url] = ++tab_data.page_count;
+
+	// ページを保存する
+	var date_format = '%(year)04d-%(month)02d-%(date)02d_%(hour)02d-%(min)02d-%(sec)02d-%(msec)04d';
+	var current_date_str = string_format(date_format, date_time_get_now_dict());
+	
+	var base_name = current_date_str + '.' + tab_data.url2page_id[current_url];
+
+	var dst_ifile = path_cd(path_get_profile_dir(), 'QT', 'archive', 'data', base_name +'.html');
+	path_enable(dst_ifile);
+
+	var dst_folder_ifile = path_cd(path_get_profile_dir(), 'QT', 'archive', 'data', base_name);
+
+	var persist = makeWebBrowserPersist();
+
+    const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
+    var persist_flags = 0;
+    persist_flags |=  nsIWBP.PERSIST_FLAGS_FROM_CACHE;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_IGNORE_REDIRECTED_DATA;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_IGNORE_IFRAMES;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
+    persist_flags |=  nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FIXUP_ORIGINAL_DOM;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FIXUP_LINKS_TO_DESTINATION;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_DONT_FIXUP_LINKS;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_SERIALIZE_OUTPUT;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_DONT_CHANGE_FILENAMES;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS;
+//     persist_flags |=  nsIWBP.PERSIST_FLAGS_CLEANUP_ON_FAILURE;
+    persist_flags |=  nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
+
+	persist.persistFlags = persist_flags;
+
+	persist.saveDocument(gBrowser.contentDocument, dst_ifile, dst_folder_ifile, 'text/html', Components.interfaces.nsIWebBrowserPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES, 80);
+
+	return tab_data.url2page_id[current_url];
+}
+
+// 実際に文字列を生成してログファイルに書き込む
+function append_log(log) {
+
+	// もし、前回のログ保存時からtab_idが変わっていたらchangeイベントを発行する。
+	if(get_globals().pre_tab_id != log['tab_id']) {
+		get_globals().pre_tab_id = log['tab_id'];
+		append_log(build_log({'event_label': 'change'}));
+	}
+
+	// ログファイルに書き込み
+	var log_format = '%(date_str)s\t%(session_time)s\t%(tab_id)s\t%(page_id)s\t%(event_label)s\t%(url)s\t%(title)s\t%(page_kind)s\t%(search_label)s\t%(keyword)s\t%(anchor_text)s\t%(next_url)s\t%(bookmark_title)s\t%(source_name)s\t%(submit_options)s\t%(submit_action_url)s\t%(next_page_id)s\t%(result_item_index)s\n';
+	var log_text = string_format(log_format, log);
+
+	log_text = string_encode(log_text, null, 'UTF-8');
+
+	// QTH用のログファイルを用意
+	var log_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_toolbar_log');
+	path_enable(log_ifile);
+
+	// 追記
+	ifile_append(log_ifile, log_text);
+	
+	// ステータスダイアログを更新
+	// window.openDialog('chrome://qthtoolbar/content/status.xul', 'qth_status', 'width=300,height=100,chrome', log, debug_log);
+}
+
+
+// 以降QTH独自のイベントを得るための処理
+// まずウインドウの初期化終了時にアタッチ
+event_observe(window, 'load',
+	function() {
+		// 次にウインドウ内のページが読み込まれたときのイベントにアタッチ
+		// link用
+		attach_on_content_loaded()
+
+		// 進むボタン・戻るボタンにもアタッチ
+		// next, return用
+		event_observe(dom_get('back-button'), 'click',
+			function(){
+				var tab_data = get_current_tab_data();
+
+				var log = {
+					'event_label': 'return',
+					'next_url': gBrowser.contentWindow.history.previous
+				};
+
+				log['next_page_id'] = get_page_id(tab_data, log['next_url']);
+
+				append_log(build_log(log));
+			}
+		)
+		event_observe(dom_get('forward-button'), 'click',
+			function(){
+				var tab_data = get_current_tab_data();
+
+				var log = {
+					'event_label': 'next',
+					'next_url': gBrowser.contentWindow.history.next
+				};
+
+				log['next_page_id'] = get_page_id(tab_data, log['next_url']);
+
+				append_log(build_log(log));
+			}
+		)
+		event_observe(dom_get('qth_view_log'), 'click',
+			function() {
+				var log_ifile = path_cd(path_get_profile_dir(), 'QT', 'qth_toolbar_log');
+				loadURI(log_ifile.path)
+			}
+		);
+
+		var orig = document.getElementById('FindToolbar').open;
+		document.getElementById('FindToolbar').open = function(){
+			append_log(build_log({'event_label': 'find'}));
+			return orig.apply(document.getElementById('FindToolbar'), arguments);
+		}
+		
+		event_observe(document.getElementById('editBookmarkPanelDoneButton'), 'click',
+			function(){
+				var log = build_log({'event_label': 'bookmark'});
+				log['bookmark_title'] = log['title']
+				append_log(log);
+			}
+		)
+	}
+)
+
+// 各ページの読み込み完了時のハンドラ。
+// すべてのAタグにアタッチしてlinkイベントを取る。
+function attach_on_content_loaded() {
+	event_observe(document.getElementById('appcontent'), 'DOMContentLoaded',
+		function(){
+			append_log(build_log({'event_label': 'load'}));
+		},
+		true
+	)
+
+	// ウインドウ内のページが読み込まれたときのイベントにアタッチ
+	event_observe(document.getElementById('appcontent'), 'DOMContentLoaded',
+		function(event) {
+			append_log(build_log({'event_label': 'show'}));
+			// 読み込まれたページのdocumentを取得
+			var document = event.target.defaultView.document;
+
+			array_each(document.getElementsByTagName('INPUT'),
+				function(tag) {
+					event_observe(tag, 'paste',
+						function(event) {
+							append_log(build_log({'event_label': 'paste'}));
+						}
+					)
+				}
+			)
+			array_each(document.getElementsByTagName('TEXTAREA'),
+				function(tag) {
+					event_observe(tag, 'paste',
+						function(event) {
+							append_log(build_log({'event_label': 'paste'}));
+						}
+					)
+				}
+			)
+			
+			// linkイベントのためにaタグのclickイベントにアタッチ
+			var a_tags = document.getElementsByTagName('A');
+			array_each(a_tags,
+				function(a_tag) {
+					event_observe(a_tag, 'click',
+						function(event) {
+							var tab_data = get_current_tab_data();
+
+							var log = {
+								'event_label': 'link',
+								'anchor_text': event.target.textContent,
+								'next_url': event.target.getAttribute('href')
+							};
+
+							log['next_page_id'] = get_page_id(tab_data, log['next_url']);
+
+							if(event.target.hasAttribute('name'))
+								log['source_name'] = event.target.getAttribute('name');
+
+							append_log(build_log(log));
+						}
+					)
+				}
+			)
+			var form_tags = document.getElementsByTagName('FORM');
+			array_each(form_tags,
+				function(form_tag) {
+					event_observe(form_tag, 'submit',
+						function(event) {
+
+							var log = {
+								'event_label': 'submit',
+								'submit_action_url': event.target.getAttribute('action')
+							};
+
+							var tab_data = get_current_tab_data();
+							log['next_page_id'] = get_page_id(tab_data, log['submit_action_url']);
+
+							if(event.target.hasAttribute('id'))
+								log['source_name'] = event.target.getAttribute('id');
+							else if(event.target.hasAttribute('name'))
+								log['source_name'] = event.target.getAttribute('name');
+
+							//log['submit_options'] = ;
+
+							append_log(build_log(log));
+						}
+					)
+				}
+			)
+
+			// 検索結果ならsearch/browseイベントをログ
+			var url = document.location.href;
+			var search_data = extract_search_data(url);
+			if('search_result_page' == search_data['page_kind']) {
+				// 検索結果。search/browseイベント発生。
+				// 今検索中で、前回とサーチエンジンとキーワードが同じならbrowse
+				var pre_search_data = get_globals().pre_search_data;
+				if(
+					pre_search_data['search_label'] == search_data['search_label'] &&
+					pre_search_data['keyword'] == search_data['keyword']
+				) {
+					// 同じ。browse
+					append_log(build_log({'event_label': 'browse'}));
+				} else {
+					// 違う。search。
+					append_log(build_log({'event_label': 'search'}));
+				}
+			}
+			// 検索に関するデータを保存
+			get_globals().pre_search_data = search_data;
+		}
+	)
+}
+
+////////////////////////////////////////////////////////////////////////////////
+})()


Property changes on: src/chrome/content/qth.js
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: src/chrome/content/service.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/settings.js
===================================================================
--- src/chrome/content/settings.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/settings.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,352 +1,352 @@
-
-
-var LemurLogToolbarConfiguration=window.arguments[0];
-
-var PersonalBLItemsRegex=new Array();
-var AddressBLItemsRegex=new Array();
-var ProperNameBLItemsRegex=new Array();
-var KeywordBLItemsRegex=new Array();
-
-/**
- * retrieves the value as a boolean from a checkbox element
- * @param checkboxId the name of the checkbox component
- * @return true or value (value)
- */
-function getCheckboxItemValue(checkboxId) {
-  var thisBox=document.getElementById(checkboxId);
-  if (thisBox) {
-    return thisBox.checked;
-  }
-  return false;
-}
-
-function setCheckboxItemValue(checkboxId, newvalue) {
-  var thisBox=document.getElementById(checkboxId);
-  if (thisBox) {
-    thisBox.checked=newvalue;
-  }
-}
-
-/**
- * retrieves a listbox element's values and places them
- * in a string delimited by \n
- * @param lstItem the list element
- * @return encoded string
- */
-function getListItemAsString(lstItemId) {
-  var lstItem=document.getElementById(lstItemId);
-  if (!lstItem) { return ""; }
-  
-  var retString="";
-  var hasOne=false;
-  var numItems=lstItem.getRowCount();
-  for (var i=0; i < numItems; i++) {
-    var thisItemValue=lstItem.getItemAtIndex(i).value;
-    if (thisItemValue.length > 0) {
-      if (hasOne) { retString +="\n"; }
-      retString += thisItemValue;
-      hasOne=true;
-    }
-  }
-  return retString;
-}
-
-function getArrayItemAsString(thisArray) {
-  var retString="";
-  var hasOne=false;
-  for (var i=0; i < thisArray.length; i++) {
-    if (hasOne) { retString +="\n"; }
-    retString += thisArray[i];
-    hasOne=true;
-  }
-  return retString;
-}
-
-/**
- * populates a listbox element's values 
- * 
- * @param lstItemId the ID of list element
- * @param inString the input string (\n delimited)
- */
-function populateListboxFromString(lstItemId, inString) {
-  var lstItem=document.getElementById(lstItemId);
-  if (!lstItem) { return; }
-  
-  // clear the listbox
-  while (lstItem.getRowCount() != 0) {
-    lstItem.removeItemAt(0);
-  
-  }
-  var items=inString.split("\n");
-  for (var i=0; i < items.length; i++) {
-    if (items[i].length > 0) {
-      lstItem.appendItem(items[i], items[i]);
-    }
-  }
-}
-
-function populateArrayFromString(thisArray, inString) {
-  thisArray=new Array();
-  var items=inString.split("\n");
-  for (var i=0; i < items.length; i++) {
-    if (items[i].length > 0) {
-      thisArray[i]=items[i];
-    }
-  }
-}
-
-function setOptionsSettings() {
-  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-  LemurLogToolbarConfiguration.getDefaultServerConfiguration();
-
-  // if (LemurLogToolbarConfiguration._serverBaseURL.length==0) {
-  //  LemurLogToolbarConfiguration._serverBaseURL=window.prompt("No server address is defined\nPlease enter one\n(or leave blank for none):");
-  // }
-  
-  // load current configuration here...
-  if (LemurLogToolbarConfiguration._allowRandomSessionId==false) {
-    var thisCheckbox=document.getElementById('chkAnonSession');
-    thisCheckbox.value=false;
-    thisCheckbox.disabled=true;
-  }
-  
-  if (LemurLogToolbarConfiguration._allowBlacklistPersonal==false) {
-    var thisCheckbox=document.getElementById('chkPersonalData');
-    thisCheckbox.value=false;
-    thisCheckbox.disabled=true;
-    var thisListbox=document.getElementById('tabBlacklistPersonal');
-    thisListbox.disabled=true; 
-  }
-
-  if (LemurLogToolbarConfiguration._allowBlacklistAddress==false) {
-    var thisCheckbox=document.getElementById('chkAddressData');
-    thisCheckbox.value=false;
-    thisCheckbox.disabled=true;
-    var thisListbox=document.getElementById('tabBlacklistAddress');
-    thisListbox.disabled=true; 
-  }
-  
-  if (LemurLogToolbarConfiguration._allowBlacklistProperName==false) {
-    var thisCheckbox=document.getElementById('chkProperNameData');
-    thisCheckbox.value=false;
-    thisCheckbox.disabled=true;
-    var thisListbox=document.getElementById('tabBlacklistNames');
-    thisListbox.disabled=true; 
-  }
-  
-  if (LemurLogToolbarConfiguration._allowBlacklistKeywords==false) {
-    var thisCheckbox=document.getElementById('chkKeywordData');
-    thisCheckbox.value=false;
-    thisCheckbox.disabled=true;
-    var thisListbox=document.getElementById('tabBlacklistKeywords');
-    thisListbox.disabled=true; 
-  }
-  
-  populateListboxFromString('lstBlacklistPersonalData', LemurLogToolbarConfiguration._blacklistPersonalItems);
-  populateListboxFromString('lstBlacklistAddressData', LemurLogToolbarConfiguration._blacklistAddressItems);
-  populateListboxFromString('lstBlacklistNameData', LemurLogToolbarConfiguration._blacklistPropernameItems);
-  populateListboxFromString('lstBlacklistKeywordData', LemurLogToolbarConfiguration._blacklistKeywordItems);
-  
-  populateArrayFromString(PersonalBLItemsRegex, LemurLogToolbarConfiguration._blacklistPersonalRegex);
-  populateArrayFromString(AddressBLItemsRegex, LemurLogToolbarConfiguration._blacklistAddressRegex);
-  populateArrayFromString(ProperNameBLItemsRegex, LemurLogToolbarConfiguration._blacklistPropernameRegex);
-  populateArrayFromString(KeywordBLItemsRegex, LemurLogToolbarConfiguration._blacklistKeywordRegex);
-  
-  setCheckboxItemValue('chkAnonSession', LemurLogToolbarConfiguration._useRandomSessionId);
-  setCheckboxItemValue('chkUseDesktopSearch', LemurLogToolbarConfiguration._useDesktopSearch);
-  setCheckboxItemValue('chkPersonalData', LemurLogToolbarConfiguration._useBlacklistPersonal);
-  setCheckboxItemValue('chkAddressData', LemurLogToolbarConfiguration._useBlacklistAddress);
-  setCheckboxItemValue('chkProperNameData', LemurLogToolbarConfiguration._useBlacklistProperName);
-  setCheckboxItemValue('chkKeywordData', LemurLogToolbarConfiguration._useBlacklistKeywords);
-  
-  chkPersonalDataOnChange();
-  chkAddressDataOnChange();
-  chkProperNameDataOnChange();
-  chkKeywordDataOnChange();
-     
-  var txtServer=document.getElementById('txtServer');
-  txtServer.value=LemurLogToolbarConfiguration._serverBaseURL;
-}
-
-function saveSettings() {
-  // LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-  
-  var txtServer=document.getElementById('txtServer');
-  
-  LemurLogToolbarConfiguration._serverBaseURL=txtServer.value;
-  LemurLogToolbarConfiguration._useRandomSessionId=getCheckboxItemValue('chkAnonSession');
-  LemurLogToolbarConfiguration._useDesktopSearch=getCheckboxItemValue('chkUseDesktopSearch');
-  
-  LemurLogToolbarConfiguration._blacklistPersonalItems=getListItemAsString('lstBlacklistPersonalData');
-  LemurLogToolbarConfiguration._blacklistAddressItems=getListItemAsString('lstBlacklistAddressData');
-  LemurLogToolbarConfiguration._blacklistPropernameItems=getListItemAsString('lstBlacklistNameData');
-  LemurLogToolbarConfiguration._blacklistKeywordItems=getListItemAsString('lstBlacklistKeywordData');
-  
-  LemurLogToolbarConfiguration._blacklistPersonalRegex=getArrayItemAsString(PersonalBLItemsRegex);
-  LemurLogToolbarConfiguration._blacklistAddressRegex=getArrayItemAsString(AddressBLItemsRegex);
-  LemurLogToolbarConfiguration._blacklistPropernameRegex=getArrayItemAsString(ProperNameBLItemsRegex);
-  LemurLogToolbarConfiguration._blacklistKeywordRegex=getArrayItemAsString(KeywordBLItemsRegex);
-
-  LemurLogToolbarConfiguration._useBlacklistPersonal=getCheckboxItemValue('chkPersonalData');
-  LemurLogToolbarConfiguration._useBlacklistAddress=getCheckboxItemValue('chkAddressData');
-  LemurLogToolbarConfiguration._useBlacklistProperName=getCheckboxItemValue('chkProperNameData');
-  LemurLogToolbarConfiguration._useBlacklistKeywords=getCheckboxItemValue('chkKeywordData');
-  
-  LemurLogToolbarConfiguration.saveLocalUserConfiguration();
-  return true;
-}
-
-function txtServerOnChange() {
-  var txtServer=document.getElementById('txtServer');
-  
-  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-  if (txtServer.value!=LemurLogToolbarConfiguration._serverBaseURL) {
-    var doReloadVal=window.confirm("The server address has changed.\nClick \"OK\" to retrieve the server configuration.");
-    if (doReloadVal) {
-      LemurLogToolbarConfiguration._serverBaseURL=txtServer.value;
-      LemurLogToolbarConfiguration.saveLocalUserConfiguration();
-      LemurLogToolbarConfiguration.getDefaultServerConfiguration(true);
-      setOptionsSettings();
-    }
-  }
-}
-
-function chkPersonalDataOnChange() {
-  var thisCheckbox=document.getElementById('chkPersonalData');
-  var thisListbox=document.getElementById('lstBlacklistPersonalData');
-  if (thisCheckbox.checked) {
-    thisListbox.disabled=false;
-  } else {
-    thisListbox.disabled=true;
-  }
-  drpBlacklists_OnSelect();
-}
-
-function chkAddressDataOnChange() {
-  var thisCheckbox=document.getElementById('chkAddressData');
-  var thisListbox=document.getElementById('lstBlacklistAddressData');
-  if (thisCheckbox.checked) {
-    thisListbox.disabled=false;
-  } else {
-    thisListbox.disabled=true;
-  }
-  drpBlacklists_OnSelect();
-}
-
-function chkProperNameDataOnChange() {
-  var thisCheckbox=document.getElementById('chkProperNameData');
-  var thisListbox=document.getElementById('lstBlacklistNameData');
-  if (thisCheckbox.checked) {
-    thisListbox.disabled=false;
-  } else {
-    thisListbox.disabled=true;
-  }
-  drpBlacklists_OnSelect();
-}
-
-function chkKeywordDataOnChange() {
-  var thisCheckbox=document.getElementById('chkKeywordData');
-  var thisListbox=document.getElementById('lstBlacklistKeywordData');
-  if (thisCheckbox.checked) {
-    thisListbox.disabled=false;
-  } else {
-    thisListbox.disabled=true;
-  }
-  drpBlacklists_OnSelect();
-}
-
-function setWhichBlacklistItems(thisListBox) {
-  var groupLabel=document.getElementById('lblBlacklistGroup');
-  document.getElementById('btnRemoveListItem').disabled=true;
-  if (thisListBox.disabled) {
-    document.getElementById('txtNewListItem').disabled=true;
-    document.getElementById('btnAddListItem').disabled=true;
-    groupLabel.value += ' (disabled)';
-  } else {
-    document.getElementById('txtNewListItem').disabled=false;
-    document.getElementById('btnAddListItem').disabled=false;
-  }
-}
-
-// when user selects the dropdown menu for blacklists
-function drpBlacklists_OnSelect() {
-  var drpBlacklists=document.getElementById('drpBlacklists');
-  var groupLabel=document.getElementById('lblBlacklistGroup');
-  var groupTab=document.getElementById('tbBlacklists');
-  var whichPanel;
-  switch (drpBlacklists.selectedIndex) {
-    case 0:
-      groupLabel.setAttribute('value', 'Personal Data:');
-      whichPanel=document.getElementById('tabBlacklistPersonal');
-      break;
-    case 1:
-      groupLabel.setAttribute('value', 'Addresses:');
-      whichPanel=document.getElementById('tabBlacklistAddress');
-      break;
-    case 2:
-      groupLabel.setAttribute('value', 'Proper Names:');
-      whichPanel=document.getElementById('tabBlacklistNames');
-      break;
-    default:
-      groupLabel.setAttribute('value', 'Keywords:');
-      whichPanel=document.getElementById('tabBlacklistKeywords');
-  }
-  groupTab.selectedPanel=whichPanel;
-  setWhichBlacklistItems(getWhichBlacklistControl());
-}
-
-function getWhichBlacklistControl() {
-  var drpBlacklists=document.getElementById('drpBlacklists');
-  switch (drpBlacklists.selectedIndex) {
-    case 0: return document.getElementById('lstBlacklistPersonalData');
-    case 1: return document.getElementById('lstBlacklistAddressData');
-    case 2: return document.getElementById('lstBlacklistNameData');
-    default: return document.getElementById('lstBlacklistKeywordData');
-  }
-}
-
-function getWhichRegexArray() {
-  var drpBlacklists=document.getElementById('drpBlacklists');
-  switch (drpBlacklists.selectedIndex) {
-    case 0: return PersonalBLItemsRegex;
-    case 1: return AddressBLItemsRegex;
-    case 2: return ProperNameBLItemsRegex;
-    default: return KeywordBLItemsRegex;
-  }
-}
-
-function btnRemoveListItemOnClick() {
-  var thisListBox=getWhichBlacklistControl();
-  var thisArray=getWhichRegexArray();
-  if (thisListBox.selectedIndex > -1) {
-    thisArray.splice(thisListBox.selectedIndex, 1);
-    thisListBox.removeItemAt(thisListBox.selectedIndex);
-  }
-}
-
-function btnAddListItemOnClick() {
-  var thisListBox=getWhichBlacklistControl();
-  var thisTextBox=document.getElementById('txtNewListItem');
-  var thisArray=getWhichRegexArray();
-  var thisValue=thisTextBox.value;
-  if (thisValue.length > 0) {
-    // ensure it will properly evaluate to 
-    // a regex correct item
-    thisListBox.appendItem(thisValue, thisValue);
-    thisArray.splice(thisArray.length, 0, thisValue.safeForRegEx());
-  }
-}
-
-function doListItemSelection() {
-  var thisListBox=getWhichBlacklistControl();
-  if (thisListBox.selectedIndex > -1) {
-    document.getElementById('btnRemoveListItem').disabled=false;
-  } else {
-    document.getElementById('btnRemoveListItem').disabled=true;
-  }  
-}
-
-function btnAddSpecialPersonalOnClick() {
-  window.openDialog('chrome://qthtoolbar/content/specialblacklist.xul', 'Personal Information Blacklist', 'chrome=yes,modal=yes,status=no', this, PersonalBLItemsRegex);
-}
-
+
+
+var LemurLogToolbarConfiguration=window.arguments[0];
+
+var PersonalBLItemsRegex=new Array();
+var AddressBLItemsRegex=new Array();
+var ProperNameBLItemsRegex=new Array();
+var KeywordBLItemsRegex=new Array();
+
+/**
+ * retrieves the value as a boolean from a checkbox element
+ * @param checkboxId the name of the checkbox component
+ * @return true or value (value)
+ */
+function getCheckboxItemValue(checkboxId) {
+  var thisBox=document.getElementById(checkboxId);
+  if (thisBox) {
+    return thisBox.checked;
+  }
+  return false;
+}
+
+function setCheckboxItemValue(checkboxId, newvalue) {
+  var thisBox=document.getElementById(checkboxId);
+  if (thisBox) {
+    thisBox.checked=newvalue;
+  }
+}
+
+/**
+ * retrieves a listbox element's values and places them
+ * in a string delimited by \n
+ * @param lstItem the list element
+ * @return encoded string
+ */
+function getListItemAsString(lstItemId) {
+  var lstItem=document.getElementById(lstItemId);
+  if (!lstItem) { return ""; }
+  
+  var retString="";
+  var hasOne=false;
+  var numItems=lstItem.getRowCount();
+  for (var i=0; i < numItems; i++) {
+    var thisItemValue=lstItem.getItemAtIndex(i).value;
+    if (thisItemValue.length > 0) {
+      if (hasOne) { retString +="\n"; }
+      retString += thisItemValue;
+      hasOne=true;
+    }
+  }
+  return retString;
+}
+
+function getArrayItemAsString(thisArray) {
+  var retString="";
+  var hasOne=false;
+  for (var i=0; i < thisArray.length; i++) {
+    if (hasOne) { retString +="\n"; }
+    retString += thisArray[i];
+    hasOne=true;
+  }
+  return retString;
+}
+
+/**
+ * populates a listbox element's values 
+ * 
+ * @param lstItemId the ID of list element
+ * @param inString the input string (\n delimited)
+ */
+function populateListboxFromString(lstItemId, inString) {
+  var lstItem=document.getElementById(lstItemId);
+  if (!lstItem) { return; }
+  
+  // clear the listbox
+  while (lstItem.getRowCount() != 0) {
+    lstItem.removeItemAt(0);
+  
+  }
+  var items=inString.split("\n");
+  for (var i=0; i < items.length; i++) {
+    if (items[i].length > 0) {
+      lstItem.appendItem(items[i], items[i]);
+    }
+  }
+}
+
+function populateArrayFromString(thisArray, inString) {
+  thisArray=new Array();
+  var items=inString.split("\n");
+  for (var i=0; i < items.length; i++) {
+    if (items[i].length > 0) {
+      thisArray[i]=items[i];
+    }
+  }
+}
+
+function setOptionsSettings() {
+  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+  LemurLogToolbarConfiguration.getDefaultServerConfiguration();
+
+  // if (LemurLogToolbarConfiguration._serverBaseURL.length==0) {
+  //  LemurLogToolbarConfiguration._serverBaseURL=window.prompt("No server address is defined\nPlease enter one\n(or leave blank for none):");
+  // }
+  
+  // load current configuration here...
+  if (LemurLogToolbarConfiguration._allowRandomSessionId==false) {
+    var thisCheckbox=document.getElementById('chkAnonSession');
+    thisCheckbox.value=false;
+    thisCheckbox.disabled=true;
+  }
+  
+  if (LemurLogToolbarConfiguration._allowBlacklistPersonal==false) {
+    var thisCheckbox=document.getElementById('chkPersonalData');
+    thisCheckbox.value=false;
+    thisCheckbox.disabled=true;
+    var thisListbox=document.getElementById('tabBlacklistPersonal');
+    thisListbox.disabled=true; 
+  }
+
+  if (LemurLogToolbarConfiguration._allowBlacklistAddress==false) {
+    var thisCheckbox=document.getElementById('chkAddressData');
+    thisCheckbox.value=false;
+    thisCheckbox.disabled=true;
+    var thisListbox=document.getElementById('tabBlacklistAddress');
+    thisListbox.disabled=true; 
+  }
+  
+  if (LemurLogToolbarConfiguration._allowBlacklistProperName==false) {
+    var thisCheckbox=document.getElementById('chkProperNameData');
+    thisCheckbox.value=false;
+    thisCheckbox.disabled=true;
+    var thisListbox=document.getElementById('tabBlacklistNames');
+    thisListbox.disabled=true; 
+  }
+  
+  if (LemurLogToolbarConfiguration._allowBlacklistKeywords==false) {
+    var thisCheckbox=document.getElementById('chkKeywordData');
+    thisCheckbox.value=false;
+    thisCheckbox.disabled=true;
+    var thisListbox=document.getElementById('tabBlacklistKeywords');
+    thisListbox.disabled=true; 
+  }
+  
+  populateListboxFromString('lstBlacklistPersonalData', LemurLogToolbarConfiguration._blacklistPersonalItems);
+  populateListboxFromString('lstBlacklistAddressData', LemurLogToolbarConfiguration._blacklistAddressItems);
+  populateListboxFromString('lstBlacklistNameData', LemurLogToolbarConfiguration._blacklistPropernameItems);
+  populateListboxFromString('lstBlacklistKeywordData', LemurLogToolbarConfiguration._blacklistKeywordItems);
+  
+  populateArrayFromString(PersonalBLItemsRegex, LemurLogToolbarConfiguration._blacklistPersonalRegex);
+  populateArrayFromString(AddressBLItemsRegex, LemurLogToolbarConfiguration._blacklistAddressRegex);
+  populateArrayFromString(ProperNameBLItemsRegex, LemurLogToolbarConfiguration._blacklistPropernameRegex);
+  populateArrayFromString(KeywordBLItemsRegex, LemurLogToolbarConfiguration._blacklistKeywordRegex);
+  
+  setCheckboxItemValue('chkAnonSession', LemurLogToolbarConfiguration._useRandomSessionId);
+  setCheckboxItemValue('chkUseDesktopSearch', LemurLogToolbarConfiguration._useDesktopSearch);
+  setCheckboxItemValue('chkPersonalData', LemurLogToolbarConfiguration._useBlacklistPersonal);
+  setCheckboxItemValue('chkAddressData', LemurLogToolbarConfiguration._useBlacklistAddress);
+  setCheckboxItemValue('chkProperNameData', LemurLogToolbarConfiguration._useBlacklistProperName);
+  setCheckboxItemValue('chkKeywordData', LemurLogToolbarConfiguration._useBlacklistKeywords);
+  
+  chkPersonalDataOnChange();
+  chkAddressDataOnChange();
+  chkProperNameDataOnChange();
+  chkKeywordDataOnChange();
+     
+  var txtServer=document.getElementById('txtServer');
+  txtServer.value=LemurLogToolbarConfiguration._serverBaseURL;
+}
+
+function saveSettings() {
+  // LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+  
+  var txtServer=document.getElementById('txtServer');
+  
+  LemurLogToolbarConfiguration._serverBaseURL=txtServer.value;
+  LemurLogToolbarConfiguration._useRandomSessionId=getCheckboxItemValue('chkAnonSession');
+  LemurLogToolbarConfiguration._useDesktopSearch=getCheckboxItemValue('chkUseDesktopSearch');
+  
+  LemurLogToolbarConfiguration._blacklistPersonalItems=getListItemAsString('lstBlacklistPersonalData');
+  LemurLogToolbarConfiguration._blacklistAddressItems=getListItemAsString('lstBlacklistAddressData');
+  LemurLogToolbarConfiguration._blacklistPropernameItems=getListItemAsString('lstBlacklistNameData');
+  LemurLogToolbarConfiguration._blacklistKeywordItems=getListItemAsString('lstBlacklistKeywordData');
+  
+  LemurLogToolbarConfiguration._blacklistPersonalRegex=getArrayItemAsString(PersonalBLItemsRegex);
+  LemurLogToolbarConfiguration._blacklistAddressRegex=getArrayItemAsString(AddressBLItemsRegex);
+  LemurLogToolbarConfiguration._blacklistPropernameRegex=getArrayItemAsString(ProperNameBLItemsRegex);
+  LemurLogToolbarConfiguration._blacklistKeywordRegex=getArrayItemAsString(KeywordBLItemsRegex);
+
+  LemurLogToolbarConfiguration._useBlacklistPersonal=getCheckboxItemValue('chkPersonalData');
+  LemurLogToolbarConfiguration._useBlacklistAddress=getCheckboxItemValue('chkAddressData');
+  LemurLogToolbarConfiguration._useBlacklistProperName=getCheckboxItemValue('chkProperNameData');
+  LemurLogToolbarConfiguration._useBlacklistKeywords=getCheckboxItemValue('chkKeywordData');
+  
+  LemurLogToolbarConfiguration.saveLocalUserConfiguration();
+  return true;
+}
+
+function txtServerOnChange() {
+  var txtServer=document.getElementById('txtServer');
+  
+  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+  if (txtServer.value!=LemurLogToolbarConfiguration._serverBaseURL) {
+    var doReloadVal=window.confirm("The server address has changed.\nClick \"OK\" to retrieve the server configuration.");
+    if (doReloadVal) {
+      LemurLogToolbarConfiguration._serverBaseURL=txtServer.value;
+      LemurLogToolbarConfiguration.saveLocalUserConfiguration();
+      LemurLogToolbarConfiguration.getDefaultServerConfiguration(true);
+      setOptionsSettings();
+    }
+  }
+}
+
+function chkPersonalDataOnChange() {
+  var thisCheckbox=document.getElementById('chkPersonalData');
+  var thisListbox=document.getElementById('lstBlacklistPersonalData');
+  if (thisCheckbox.checked) {
+    thisListbox.disabled=false;
+  } else {
+    thisListbox.disabled=true;
+  }
+  drpBlacklists_OnSelect();
+}
+
+function chkAddressDataOnChange() {
+  var thisCheckbox=document.getElementById('chkAddressData');
+  var thisListbox=document.getElementById('lstBlacklistAddressData');
+  if (thisCheckbox.checked) {
+    thisListbox.disabled=false;
+  } else {
+    thisListbox.disabled=true;
+  }
+  drpBlacklists_OnSelect();
+}
+
+function chkProperNameDataOnChange() {
+  var thisCheckbox=document.getElementById('chkProperNameData');
+  var thisListbox=document.getElementById('lstBlacklistNameData');
+  if (thisCheckbox.checked) {
+    thisListbox.disabled=false;
+  } else {
+    thisListbox.disabled=true;
+  }
+  drpBlacklists_OnSelect();
+}
+
+function chkKeywordDataOnChange() {
+  var thisCheckbox=document.getElementById('chkKeywordData');
+  var thisListbox=document.getElementById('lstBlacklistKeywordData');
+  if (thisCheckbox.checked) {
+    thisListbox.disabled=false;
+  } else {
+    thisListbox.disabled=true;
+  }
+  drpBlacklists_OnSelect();
+}
+
+function setWhichBlacklistItems(thisListBox) {
+  var groupLabel=document.getElementById('lblBlacklistGroup');
+  document.getElementById('btnRemoveListItem').disabled=true;
+  if (thisListBox.disabled) {
+    document.getElementById('txtNewListItem').disabled=true;
+    document.getElementById('btnAddListItem').disabled=true;
+    groupLabel.value += ' (disabled)';
+  } else {
+    document.getElementById('txtNewListItem').disabled=false;
+    document.getElementById('btnAddListItem').disabled=false;
+  }
+}
+
+// when user selects the dropdown menu for blacklists
+function drpBlacklists_OnSelect() {
+  var drpBlacklists=document.getElementById('drpBlacklists');
+  var groupLabel=document.getElementById('lblBlacklistGroup');
+  var groupTab=document.getElementById('tbBlacklists');
+  var whichPanel;
+  switch (drpBlacklists.selectedIndex) {
+    case 0:
+      groupLabel.setAttribute('value', 'Personal Data:');
+      whichPanel=document.getElementById('tabBlacklistPersonal');
+      break;
+    case 1:
+      groupLabel.setAttribute('value', 'Addresses:');
+      whichPanel=document.getElementById('tabBlacklistAddress');
+      break;
+    case 2:
+      groupLabel.setAttribute('value', 'Proper Names:');
+      whichPanel=document.getElementById('tabBlacklistNames');
+      break;
+    default:
+      groupLabel.setAttribute('value', 'Keywords:');
+      whichPanel=document.getElementById('tabBlacklistKeywords');
+  }
+  groupTab.selectedPanel=whichPanel;
+  setWhichBlacklistItems(getWhichBlacklistControl());
+}
+
+function getWhichBlacklistControl() {
+  var drpBlacklists=document.getElementById('drpBlacklists');
+  switch (drpBlacklists.selectedIndex) {
+    case 0: return document.getElementById('lstBlacklistPersonalData');
+    case 1: return document.getElementById('lstBlacklistAddressData');
+    case 2: return document.getElementById('lstBlacklistNameData');
+    default: return document.getElementById('lstBlacklistKeywordData');
+  }
+}
+
+function getWhichRegexArray() {
+  var drpBlacklists=document.getElementById('drpBlacklists');
+  switch (drpBlacklists.selectedIndex) {
+    case 0: return PersonalBLItemsRegex;
+    case 1: return AddressBLItemsRegex;
+    case 2: return ProperNameBLItemsRegex;
+    default: return KeywordBLItemsRegex;
+  }
+}
+
+function btnRemoveListItemOnClick() {
+  var thisListBox=getWhichBlacklistControl();
+  var thisArray=getWhichRegexArray();
+  if (thisListBox.selectedIndex > -1) {
+    thisArray.splice(thisListBox.selectedIndex, 1);
+    thisListBox.removeItemAt(thisListBox.selectedIndex);
+  }
+}
+
+function btnAddListItemOnClick() {
+  var thisListBox=getWhichBlacklistControl();
+  var thisTextBox=document.getElementById('txtNewListItem');
+  var thisArray=getWhichRegexArray();
+  var thisValue=thisTextBox.value;
+  if (thisValue.length > 0) {
+    // ensure it will properly evaluate to 
+    // a regex correct item
+    thisListBox.appendItem(thisValue, thisValue);
+    thisArray.splice(thisArray.length, 0, thisValue.safeForRegEx());
+  }
+}
+
+function doListItemSelection() {
+  var thisListBox=getWhichBlacklistControl();
+  if (thisListBox.selectedIndex > -1) {
+    document.getElementById('btnRemoveListItem').disabled=false;
+  } else {
+    document.getElementById('btnRemoveListItem').disabled=true;
+  }  
+}
+
+function btnAddSpecialPersonalOnClick() {
+  window.openDialog('chrome://qthtoolbar/content/specialblacklist.xul', 'Personal Information Blacklist', 'chrome=yes,modal=yes,status=no', this, PersonalBLItemsRegex);
+}
+


Property changes on: src/chrome/content/settings.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/settings.xul
===================================================================
--- src/chrome/content/settings.xul	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/settings.xul	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,130 +1,130 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
-
-<dialog 
-  id="dlgToolbarSettings"
-  title="QT Honey Toolbar - Settings"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-  buttons="accept,cancel,extra1"
-  ondialogaccept="return saveSettings();"
-  ondialogcancel="return true;"
-  buttonlabelextra1="Apply"
-  ondialogextra1="saveSettings();"
-  
->
-
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/aescipher.js"/>
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/settings.js" />
-
-<tabbox id="tbSettings">
-  <tabs>
-    <tab label="General" />
-    <tab label="Blacklists" />
-  </tabs>
-  <tabpanels>
-  
-    <tabpanel id="tabSettingsGeneral">
-      <vbox>
-        <groupbox>
-          <caption label="General Settings" />
-          <vbox>
-            <checkbox id="chkAnonSession" label="Generate random session ID" />
-            <checkbox id="chkUseDesktopSearch" label="Log Desktop Search Results" />
-          </vbox>
-        </groupbox>
-        <groupbox>
-          <caption label="Server Settings" />
-          <hbox>
-            <label value="Address:" control="txtServer" />
-            <textbox id="txtServer" value="" size="48" onchange="txtServerOnChange();" />
-          </hbox>
-        </groupbox>
-        <groupbox>
-          <caption label="Blacklist Settings" />
-          <vbox>
-            <checkbox id="chkPersonalData" oncommand="chkPersonalDataOnChange();" label="Blacklist Personal Data (CC#'s, phone, Etc.)" checked="true" />
-            <checkbox id="chkAddressData" oncommand="chkAddressDataOnChange();"  label="Blacklist Address Data" checked="true" />
-            <checkbox id="chkProperNameData" oncommand="chkProperNameDataOnChange();"  label="Blacklist Proper Names" checked="true" />
-            <checkbox id="chkKeywordData" oncommand="chkKeywordDataOnChange();"  label="Blacklist Keywords" checked="true" />
-            <label value="Note: the above blacklist items will not be" />
-            <label value="effective unless the blacklist entries on the" />
-            <label value="Blacklists tab are set." />
-          </vbox>
-        </groupbox>
-      </vbox>
-    </tabpanel>
-    
-    <tabpanel id="tabSettingsBlacklist">
-      <vbox>
-        <hbox>
-          <label value="Blacklists:" control="drpBlacklists" />
-          <menulist id="drpBlacklists" oncommand="drpBlacklists_OnSelect();">
-            <menupopup>
-              <menuitem label="Personal Data" selected="true" />
-              <menuitem label="Address Data" />
-              <menuitem label="Proper Names" />
-              <menuitem label="Keywords" />
-            </menupopup>
-          </menulist>
-        </hbox>
-        <vbox>
-          <label id="lblBlacklistGroup" value="Personal Data" />
-          <tabbox id="tbBlacklists" selectedIndex="1">
-            <tabpanels id="tbBlacklistPanels">
-              <tabpanel id="tabBlacklistPersonal" style="border: none;">
-                <vbox>
-                  <label value="Personal data such as SSNs, credit card information," width="300" />
-                  <label value="driver's license numbers, etc. should be entered here" width="300" />
-                  <listbox id="lstBlacklistPersonalData" seltype="single" onselect="doListItemSelection();" />
-                  <button id="btnAddSpecialPersonal" label="Add Special Information" oncommand="btnAddSpecialPersonalOnClick();" />
-                </vbox>
-              </tabpanel>
-              <tabpanel id="tabBlacklistAddress" style="border: none;">
-                <vbox>
-                  <label value="Any addresses to filter should be entered here" width="300" />
-                  <label value="" width="300" />
-                  <listbox id="lstBlacklistAddressData" seltype="single" onselect="doListItemSelection();" />
-                </vbox>
-              </tabpanel>
-              <tabpanel id="tabBlacklistNames" style="border: none;">
-                <vbox>
-                  <label value="Proper names such as people or businesses should be" width="300" />
-                  <label value="entered here" width="300" />
-                  <listbox id="lstBlacklistNameData" seltype="single" onselect="doListItemSelection();" />
-                </vbox>
-              </tabpanel>
-              <tabpanel id="tabBlacklistKeywords" style="border: none;">
-                <vbox>
-                  <label value="Any additional keywords to be filtered should be" width="300" />
-                  <label value="entered here" width="300" />
-                  <listbox id="lstBlacklistKeywordData" seltype="single" onselect="doListItemSelection();" />
-                </vbox>
-              </tabpanel>
-            </tabpanels>
-          </tabbox>
-        </vbox>
-        <hbox>
-          <button id="btnRemoveListItem" align="end" label="Remove Selected" disabled="true" oncommand="btnRemoveListItemOnClick();" />
-        </hbox>
-        <hbox>
-          <label value="New item:" control="txtNewListItem" />
-          <textbox id="txtNewListItem" />
-          <button id="btnAddListItem" align="end" label="Add" oncommand="btnAddListItemOnClick();" />
-        </hbox>
-      </vbox>
-    </tabpanel>
-  
-  </tabpanels>
-</tabbox>
-
-<script>
-
-  // on load - ensure we have the proper settings
-  
-  setOptionsSettings();
-  
-</script>
-
-</dialog>
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+
+<dialog 
+  id="dlgToolbarSettings"
+  title="QT Honey Toolbar - Settings"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+  buttons="accept,cancel,extra1"
+  ondialogaccept="return saveSettings();"
+  ondialogcancel="return true;"
+  buttonlabelextra1="Apply"
+  ondialogextra1="saveSettings();"
+  
+>
+
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/aescipher.js"/>
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/settings.js" />
+
+<tabbox id="tbSettings">
+  <tabs>
+    <tab label="General" />
+    <tab label="Blacklists" />
+  </tabs>
+  <tabpanels>
+  
+    <tabpanel id="tabSettingsGeneral">
+      <vbox>
+        <groupbox>
+          <caption label="General Settings" />
+          <vbox>
+            <checkbox id="chkAnonSession" label="Generate random session ID" />
+            <checkbox id="chkUseDesktopSearch" label="Log Desktop Search Results" />
+          </vbox>
+        </groupbox>
+        <groupbox>
+          <caption label="Server Settings" />
+          <hbox>
+            <label value="Address:" control="txtServer" />
+            <textbox id="txtServer" value="" size="48" onchange="txtServerOnChange();" />
+          </hbox>
+        </groupbox>
+        <groupbox>
+          <caption label="Blacklist Settings" />
+          <vbox>
+            <checkbox id="chkPersonalData" oncommand="chkPersonalDataOnChange();" label="Blacklist Personal Data (CC#'s, phone, Etc.)" checked="true" />
+            <checkbox id="chkAddressData" oncommand="chkAddressDataOnChange();"  label="Blacklist Address Data" checked="true" />
+            <checkbox id="chkProperNameData" oncommand="chkProperNameDataOnChange();"  label="Blacklist Proper Names" checked="true" />
+            <checkbox id="chkKeywordData" oncommand="chkKeywordDataOnChange();"  label="Blacklist Keywords" checked="true" />
+            <label value="Note: the above blacklist items will not be" />
+            <label value="effective unless the blacklist entries on the" />
+            <label value="Blacklists tab are set." />
+          </vbox>
+        </groupbox>
+      </vbox>
+    </tabpanel>
+    
+    <tabpanel id="tabSettingsBlacklist">
+      <vbox>
+        <hbox>
+          <label value="Blacklists:" control="drpBlacklists" />
+          <menulist id="drpBlacklists" oncommand="drpBlacklists_OnSelect();">
+            <menupopup>
+              <menuitem label="Personal Data" selected="true" />
+              <menuitem label="Address Data" />
+              <menuitem label="Proper Names" />
+              <menuitem label="Keywords" />
+            </menupopup>
+          </menulist>
+        </hbox>
+        <vbox>
+          <label id="lblBlacklistGroup" value="Personal Data" />
+          <tabbox id="tbBlacklists" selectedIndex="1">
+            <tabpanels id="tbBlacklistPanels">
+              <tabpanel id="tabBlacklistPersonal" style="border: none;">
+                <vbox>
+                  <label value="Personal data such as SSNs, credit card information," width="300" />
+                  <label value="driver's license numbers, etc. should be entered here" width="300" />
+                  <listbox id="lstBlacklistPersonalData" seltype="single" onselect="doListItemSelection();" />
+                  <button id="btnAddSpecialPersonal" label="Add Special Information" oncommand="btnAddSpecialPersonalOnClick();" />
+                </vbox>
+              </tabpanel>
+              <tabpanel id="tabBlacklistAddress" style="border: none;">
+                <vbox>
+                  <label value="Any addresses to filter should be entered here" width="300" />
+                  <label value="" width="300" />
+                  <listbox id="lstBlacklistAddressData" seltype="single" onselect="doListItemSelection();" />
+                </vbox>
+              </tabpanel>
+              <tabpanel id="tabBlacklistNames" style="border: none;">
+                <vbox>
+                  <label value="Proper names such as people or businesses should be" width="300" />
+                  <label value="entered here" width="300" />
+                  <listbox id="lstBlacklistNameData" seltype="single" onselect="doListItemSelection();" />
+                </vbox>
+              </tabpanel>
+              <tabpanel id="tabBlacklistKeywords" style="border: none;">
+                <vbox>
+                  <label value="Any additional keywords to be filtered should be" width="300" />
+                  <label value="entered here" width="300" />
+                  <listbox id="lstBlacklistKeywordData" seltype="single" onselect="doListItemSelection();" />
+                </vbox>
+              </tabpanel>
+            </tabpanels>
+          </tabbox>
+        </vbox>
+        <hbox>
+          <button id="btnRemoveListItem" align="end" label="Remove Selected" disabled="true" oncommand="btnRemoveListItemOnClick();" />
+        </hbox>
+        <hbox>
+          <label value="New item:" control="txtNewListItem" />
+          <textbox id="txtNewListItem" />
+          <button id="btnAddListItem" align="end" label="Add" oncommand="btnAddListItemOnClick();" />
+        </hbox>
+      </vbox>
+    </tabpanel>
+  
+  </tabpanels>
+</tabbox>
+
+<script>
+
+  // on load - ensure we have the proper settings
+  
+  setOptionsSettings();
+  
+</script>
+
+</dialog>


Property changes on: src/chrome/content/settings.xul
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/specialblacklist.js
===================================================================
--- src/chrome/content/specialblacklist.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/specialblacklist.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,144 +1,144 @@
-var DlgSettingsWindow=window.arguments[0];
-var PersonalBLItemsRegex=window.arguments[1];
-
-function addToPersonalBlacklist(readableValue, valueToAdd) {
-  var lstBlacklist=DlgSettingsWindow.document.getElementById('lstBlacklistPersonalData')
-  lstBlacklist.appendItem(readableValue, readableValue);
-  PersonalBLItemsRegex.splice(PersonalBLItemsRegex.length, 0, valueToAdd);
-}
-
-function btnAddPhoneOnClick() {
-  var txtPhone=document.getElementById('txtPhoneNumber');
-  var phoneValue=txtPhone.value.trim();
-
-  // US phone
-  var testValue=phoneValue.match("^(?:\\+)?(?:1[\\s\\.\\-]?)?[(]?(\\d{3})?[\\s\\)\\-\\.]?[\\s]?(\\d{3})[\\s\\-\\.]?(\\d{4})$");
-  if (testValue!=null && testValue.length==4) {
-    var val="";
-    if (testValue[1]==undefined) {
-      // only 7 digits
-      val=testValue[2] + "[\\s\\-\\.]?" + testValue[3];
-    } else {
-      // 7 digits + area code
-      val="\\+?(1[\\s\\.\\-]?)?[\\(]?" + testValue[1] + "[\\s\\)\\-\\.]?[\\s]?" + testValue[2] + "[\\s\\-\\.]?" + testValue[3];
-    }
-    addToPersonalBlacklist(phoneValue, val);
-    close();
-    return;
-  }
-  
-  // international phone
-  // i.e. +44 (0) 28 9065 1066
-  
-  // optional +
-  // optional space
-  // optional 2 digits (grouping)
-  // optional space
-  // optional ( or -
-  // optional 1 digit (grouping)
-  // optional ) - (if first ( or - matched)
-  // optional space
-  // required 1 digit (grouping)
-  // required 7 to 20 digits with - space or . matched (grouping)
-  
-  testValue=phoneValue.match("^\\+?\\s?(?:(\\d{1,2})?[\\-\\.\\s])?(?:[\\s\\.\\(\\-]+(\\d)[\\s\\.\\)\\-]+)?\\s?([\\d\\-\\.\\s]{7,20})$");
-  
-  if (testValue!=null && testValue.length==4) {
-    var val="\\+?\\s?";
-    if (testValue[1]!=undefined && testValue[2]==undefined) {
-      val=testValue[1] + "[\\-\\.\\s]";
-      var replacementDel=new RegExp("[\\-\\.\\s]", "g");
-      val += testValue[3].replace(replacementDel, "[\\-\\.\\s]");
-    } else {
-    
-      if (testValue[1]!=undefined) {
-        val += testValue[1];
-      } else {
-        val += "(?:(\\d{1,2})?[\\-\\.\\s])?"
-      }
-      val += "(?:[\\s\\.\\(\\-]+";
-      if (testValue[2]!=undefined) {
-        val += testValue[2];
-      } else {
-        val += "\\d";
-      }
-      val += "[\\s\\.\\)\\-]+)?\\s?";
-
-      var replacementDel=new RegExp("[\\-\\.\\s]", "g");
-      val += testValue[3].replace(replacementDel, "[\\-\\.\\s]");
-    }
-    
-    addToPersonalBlacklist(phoneValue, val);
-    close();
-    return;
-  }
-  
-  alert("Please enter a valid phone number.");
-}
-
-function btnAddCCOnClick() {
-  // visa, mc, discover / amex 
-  // var regexCC=new RegExp("^(?:(\\d{4})[ -]?(\\d{4})[ -]?(\\d{4})[ -]?(\\d{4}))|(?:(\\d{4})[ -]?(\\d{5})[ -]?(\\d{5}))$");
-  
-  var txtCreditCard=document.getElementById('txtCreditCard');
-  var ccValue=txtCreditCard.value.trim();
-  var testValue=ccValue.match("^(\\d{4})[ -]?(\\d{4})[\\s\\-]?(\\d{4})[\\s\\-]?(\\d{4})$");
-  if (testValue!=null && testValue.length==5) {
-    // mc / discover / visa
-    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3] + "[\\s\\-]?" + testValue[4];
-    addToPersonalBlacklist(ccValue, val);
-    close();
-    return;
-  }
-  
-  testValue=ccValue.match("^(\\d{4})[\\s\\-]?(\\d{5})[\\s\\-]?(\\d{5})$");
-  if (testValue!=null && testValue.length==4) {
-    // amex
-    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3];
-    addToPersonalBlacklist(ccValue, val);
-    close();
-    return;
-  }
-  
-  alert("The credit card you entered does not appear valid.");
-}
-
-function btnAddSSNOnClick() {
-  
-  var txtSSN=document.getElementById('txtSSN');
-  var ssnValue=txtSSN.value.trim();
-  var testValue=ssnValue.match("^(\\d{3})[\\s\\-]?(\\d{2})[\\s\\-]?(\\d{4})$");
-  if (testValue!=null && testValue.length==4) {
-    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3];
-    addToPersonalBlacklist(ssnValue, val);
-    close();
-    return;
-  }
-  alert("The SSN you entered does not appear valid.\nPlease enter a SSN in the form of:\n###-##-#### or ### ## #### or #########");
-}
-
-function btnAddDriversOnClick() {
-  // search for:
-  // possibly 2 letter abbriv. ([\\w]{2})?  
-  // space / - separator or none
-  // digits - min 6, up to 16 with potential spacers
-  var txtDriversLic=document.getElementById('txtDriversLic');
-  var dlValue=txtDriversLic.value.trim();
-  var testValue=dlValue.match("^(\\w{1,2})?[\\s\\-]?([\\d\\s\\-]{6,16})$");
-  if (testValue!=null && testValue.length==3) {
-    var val="";
-    
-    if (testValue[1]!=undefined) {
-      val += testValue[1] + "[\\s\\-]?";
-    }
-    
-    var replacementDel=new RegExp("[\\-\\s]", "g");
-    val += testValue[2].replace(replacementDel, "[\\-\\s]");
-    
-    addToPersonalBlacklist(dlValue, val);
-    close();
-    return;
-  }
-  alert("The Driver's License you entered does not appear valid.\nPlease enter the number (without the state or country abbreviation).");
-  
-}
+var DlgSettingsWindow=window.arguments[0];
+var PersonalBLItemsRegex=window.arguments[1];
+
+function addToPersonalBlacklist(readableValue, valueToAdd) {
+  var lstBlacklist=DlgSettingsWindow.document.getElementById('lstBlacklistPersonalData')
+  lstBlacklist.appendItem(readableValue, readableValue);
+  PersonalBLItemsRegex.splice(PersonalBLItemsRegex.length, 0, valueToAdd);
+}
+
+function btnAddPhoneOnClick() {
+  var txtPhone=document.getElementById('txtPhoneNumber');
+  var phoneValue=txtPhone.value.trim();
+
+  // US phone
+  var testValue=phoneValue.match("^(?:\\+)?(?:1[\\s\\.\\-]?)?[(]?(\\d{3})?[\\s\\)\\-\\.]?[\\s]?(\\d{3})[\\s\\-\\.]?(\\d{4})$");
+  if (testValue!=null && testValue.length==4) {
+    var val="";
+    if (testValue[1]==undefined) {
+      // only 7 digits
+      val=testValue[2] + "[\\s\\-\\.]?" + testValue[3];
+    } else {
+      // 7 digits + area code
+      val="\\+?(1[\\s\\.\\-]?)?[\\(]?" + testValue[1] + "[\\s\\)\\-\\.]?[\\s]?" + testValue[2] + "[\\s\\-\\.]?" + testValue[3];
+    }
+    addToPersonalBlacklist(phoneValue, val);
+    close();
+    return;
+  }
+  
+  // international phone
+  // i.e. +44 (0) 28 9065 1066
+  
+  // optional +
+  // optional space
+  // optional 2 digits (grouping)
+  // optional space
+  // optional ( or -
+  // optional 1 digit (grouping)
+  // optional ) - (if first ( or - matched)
+  // optional space
+  // required 1 digit (grouping)
+  // required 7 to 20 digits with - space or . matched (grouping)
+  
+  testValue=phoneValue.match("^\\+?\\s?(?:(\\d{1,2})?[\\-\\.\\s])?(?:[\\s\\.\\(\\-]+(\\d)[\\s\\.\\)\\-]+)?\\s?([\\d\\-\\.\\s]{7,20})$");
+  
+  if (testValue!=null && testValue.length==4) {
+    var val="\\+?\\s?";
+    if (testValue[1]!=undefined && testValue[2]==undefined) {
+      val=testValue[1] + "[\\-\\.\\s]";
+      var replacementDel=new RegExp("[\\-\\.\\s]", "g");
+      val += testValue[3].replace(replacementDel, "[\\-\\.\\s]");
+    } else {
+    
+      if (testValue[1]!=undefined) {
+        val += testValue[1];
+      } else {
+        val += "(?:(\\d{1,2})?[\\-\\.\\s])?"
+      }
+      val += "(?:[\\s\\.\\(\\-]+";
+      if (testValue[2]!=undefined) {
+        val += testValue[2];
+      } else {
+        val += "\\d";
+      }
+      val += "[\\s\\.\\)\\-]+)?\\s?";
+
+      var replacementDel=new RegExp("[\\-\\.\\s]", "g");
+      val += testValue[3].replace(replacementDel, "[\\-\\.\\s]");
+    }
+    
+    addToPersonalBlacklist(phoneValue, val);
+    close();
+    return;
+  }
+  
+  alert("Please enter a valid phone number.");
+}
+
+function btnAddCCOnClick() {
+  // visa, mc, discover / amex 
+  // var regexCC=new RegExp("^(?:(\\d{4})[ -]?(\\d{4})[ -]?(\\d{4})[ -]?(\\d{4}))|(?:(\\d{4})[ -]?(\\d{5})[ -]?(\\d{5}))$");
+  
+  var txtCreditCard=document.getElementById('txtCreditCard');
+  var ccValue=txtCreditCard.value.trim();
+  var testValue=ccValue.match("^(\\d{4})[ -]?(\\d{4})[\\s\\-]?(\\d{4})[\\s\\-]?(\\d{4})$");
+  if (testValue!=null && testValue.length==5) {
+    // mc / discover / visa
+    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3] + "[\\s\\-]?" + testValue[4];
+    addToPersonalBlacklist(ccValue, val);
+    close();
+    return;
+  }
+  
+  testValue=ccValue.match("^(\\d{4})[\\s\\-]?(\\d{5})[\\s\\-]?(\\d{5})$");
+  if (testValue!=null && testValue.length==4) {
+    // amex
+    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3];
+    addToPersonalBlacklist(ccValue, val);
+    close();
+    return;
+  }
+  
+  alert("The credit card you entered does not appear valid.");
+}
+
+function btnAddSSNOnClick() {
+  
+  var txtSSN=document.getElementById('txtSSN');
+  var ssnValue=txtSSN.value.trim();
+  var testValue=ssnValue.match("^(\\d{3})[\\s\\-]?(\\d{2})[\\s\\-]?(\\d{4})$");
+  if (testValue!=null && testValue.length==4) {
+    var val=testValue[1]+"[\\s\\-]?" + testValue[2] + "[\\s\\-]?" + testValue[3];
+    addToPersonalBlacklist(ssnValue, val);
+    close();
+    return;
+  }
+  alert("The SSN you entered does not appear valid.\nPlease enter a SSN in the form of:\n###-##-#### or ### ## #### or #########");
+}
+
+function btnAddDriversOnClick() {
+  // search for:
+  // possibly 2 letter abbriv. ([\\w]{2})?  
+  // space / - separator or none
+  // digits - min 6, up to 16 with potential spacers
+  var txtDriversLic=document.getElementById('txtDriversLic');
+  var dlValue=txtDriversLic.value.trim();
+  var testValue=dlValue.match("^(\\w{1,2})?[\\s\\-]?([\\d\\s\\-]{6,16})$");
+  if (testValue!=null && testValue.length==3) {
+    var val="";
+    
+    if (testValue[1]!=undefined) {
+      val += testValue[1] + "[\\s\\-]?";
+    }
+    
+    var replacementDel=new RegExp("[\\-\\s]", "g");
+    val += testValue[2].replace(replacementDel, "[\\-\\s]");
+    
+    addToPersonalBlacklist(dlValue, val);
+    close();
+    return;
+  }
+  alert("The Driver's License you entered does not appear valid.\nPlease enter the number (without the state or country abbreviation).");
+  
+}


Property changes on: src/chrome/content/specialblacklist.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/specialblacklist.xul
===================================================================
--- src/chrome/content/specialblacklist.xul	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/specialblacklist.xul	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,52 +1,52 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
-
-<dialog 
-  id="dlgSpecialBlacklist"
-  title="QT Honey Toolbar - Special Blacklist Items"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-  buttons="cancel"
-  ondialogcancel="return true;"
-  buttonlabelcancel="Close"
->
-
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/settings.js" />
-<script type="application/x-javascript" src="chrome://qthtoolbar/content/specialblacklist.js" />
-
-<groupbox>
-  <caption label="Personal Information Fields" />
-  <grid flex="1">
-    <rows>
-      <row />
-      <row />
-      <row />
-      <row />
-      <row />
-    </rows>
-    
-    <columns>
-      <column>
-        <label value="Phone Number" control="txtPhoneNumber" />
-        <label value="Credit Card" control="txtCreditCard" />
-        <label value="Social Security #" control="txtSSN" />
-        <label value="Driver's License" control="txtDriversLic" />
-      </column>
-      <column flex="1">
-        <textbox id="txtPhoneNumber" value="" size="20" />
-        <textbox id="txtCreditCard" value="" size="20" />
-        <textbox id="txtSSN" value="" size="20" />
-        <textbox id="txtDriversLic" value="" size="20" />
-      </column>
-      <column>
-        <button label="Add" oncommand="btnAddPhoneOnClick();" />
-        <button label="Add" oncommand="btnAddCCOnClick();" />
-        <button label="Add" oncommand="btnAddSSNOnClick();" />
-        <button label="Add" oncommand="btnAddDriversOnClick();" />
-      </column>
-    </columns>
-  </grid>
-</groupbox>
-
-</dialog>
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+
+<dialog 
+  id="dlgSpecialBlacklist"
+  title="QT Honey Toolbar - Special Blacklist Items"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+  buttons="cancel"
+  ondialogcancel="return true;"
+  buttonlabelcancel="Close"
+>
+
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/configuration.js" />
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/settings.js" />
+<script type="application/x-javascript" src="chrome://qthtoolbar/content/specialblacklist.js" />
+
+<groupbox>
+  <caption label="Personal Information Fields" />
+  <grid flex="1">
+    <rows>
+      <row />
+      <row />
+      <row />
+      <row />
+      <row />
+    </rows>
+    
+    <columns>
+      <column>
+        <label value="Phone Number" control="txtPhoneNumber" />
+        <label value="Credit Card" control="txtCreditCard" />
+        <label value="Social Security #" control="txtSSN" />
+        <label value="Driver's License" control="txtDriversLic" />
+      </column>
+      <column flex="1">
+        <textbox id="txtPhoneNumber" value="" size="20" />
+        <textbox id="txtCreditCard" value="" size="20" />
+        <textbox id="txtSSN" value="" size="20" />
+        <textbox id="txtDriversLic" value="" size="20" />
+      </column>
+      <column>
+        <button label="Add" oncommand="btnAddPhoneOnClick();" />
+        <button label="Add" oncommand="btnAddCCOnClick();" />
+        <button label="Add" oncommand="btnAddSSNOnClick();" />
+        <button label="Add" oncommand="btnAddDriversOnClick();" />
+      </column>
+    </columns>
+  </grid>
+</groupbox>
+
+</dialog>


Property changes on: src/chrome/content/specialblacklist.xul
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/status.xul
===================================================================
--- src/chrome/content/status.xul	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/status.xul	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,45 +1,45 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
-
-<window 
-  id="qth_status_dialog"
-  title="QT Honey Toolbar - Status"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
->
-
-<label id="qth_status_label" style="font-size:75pt;width:300px;height:100px" value="start"/>
-
-<script type="text/javascript">
-	<![CDATA[
-	(function(){
-	////////////////////////////////////////////////////////////////////////////////
-	
-	function event_observe(
-		target_element, event_name, observer_func, capture_or_bubbling) {
-		target_element.addEventListener(
-			event_name, observer_func, capture_or_bubbling || false);
-	}
-
-	function dom_get(id) {
-		return document.getElementById(id)
-	}
-
-	////////////////////////////////////////
-
-	event_observe(window, 'load',
-		function(){
-			var log = window.arguments[0];
-			var debug_log = window.arguments[1];
-
-			//debug_log(log['event_label'])
-			dom_get('qth_status_label').setAttribute('value', log['event_label']);
-		}
-	)
-
-	////////////////////////////////////////////////////////////////////////////////
-	})();
-	]]>
-</script>
-
-</window>
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+
+<window 
+  id="qth_status_dialog"
+  title="QT Honey Toolbar - Status"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+>
+
+<label id="qth_status_label" style="font-size:75pt;width:300px;height:100px" value="start"/>
+
+<script type="text/javascript">
+	<![CDATA[
+	(function(){
+	////////////////////////////////////////////////////////////////////////////////
+	
+	function event_observe(
+		target_element, event_name, observer_func, capture_or_bubbling) {
+		target_element.addEventListener(
+			event_name, observer_func, capture_or_bubbling || false);
+	}
+
+	function dom_get(id) {
+		return document.getElementById(id)
+	}
+
+	////////////////////////////////////////
+
+	event_observe(window, 'load',
+		function(){
+			var log = window.arguments[0];
+			var debug_log = window.arguments[1];
+
+			//debug_log(log['event_label'])
+			dom_get('qth_status_label').setAttribute('value', log['event_label']);
+		}
+	)
+
+	////////////////////////////////////////////////////////////////////////////////
+	})();
+	]]>
+</script>
+
+</window>


Property changes on: src/chrome/content/status.xul
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/upload.js
===================================================================
--- src/chrome/content/upload.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/upload.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,79 +1,79 @@
-var lemurlog_MainWin;
-
-function lemurlog_up_onLoad()
-{
-  lemurlog_MainWin = window.arguments[0];
-  lemurlog_MainWin.lemurlog_UploadWin = window;
-
-  //disable OK button
-  var btn = document.documentElement.getButton("accept");
-  btn.collapsed = true;
-
-  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-
-  var log_file_size = lemurlog_GetLogFileSize(lemurlog_LOG_FILE);
-  var page_file_size = lemurlog_GetLogFileSize(lemurlog_PAGE_FILE);
-
-  var log_str ="Activity log: "+lemurlog_NumberToHumanReadable(log_file_size);
-  var page_str ="Search log: "+lemurlog_NumberToHumanReadable(page_file_size);
-
-
-  // ensure we have a server setup!
-  if (LemurLogToolbarConfiguration._serverBaseURL.length==0) {
-    LemurLogToolbarConfiguration._serverBaseURL=window.prompt("No server address is defined\nPlease enter one\n(or leave blank for none):");
-  }
-  
-  var baseURL=LemurLogToolbarConfiguration._serverBaseURL;
-  if (baseURL==null || baseURL.length==0) {
-    lemurlog_up_onCancel();
-    window.close();
-    return;
-  } else {
-    LemurLogToolbarConfiguration.saveLocalUserConfiguration();
-  }
-
-  // Add labels
-  var item;
-  item = document.getElementById("LogTB-Up-Desc0");
-  item.setAttribute("value", "Uploading log files to " + LemurLogToolbarConfiguration._serverBaseURL + ":");
-
-  item = document.getElementById("LogTB-Up-Desc1");
-  item.setAttribute("value", log_str);
-
-  item = document.getElementById("LogTB-Up-Desc2");
-  item.setAttribute("value", page_str);
-  
-  // before uploading - scrub the files
-  item = document.getElementById("LogTB-Up-Result");
-  item.setAttribute("value", "Scrubbing log files before upload");
-  
-  lemurlog_scrubLogFiles();
-  
-  item.setAttribute("value", "Uploading...");
-
-  //upload the first file
-  // var cgi_url = "http://"+lemurlog_UPLOAD_HOST+lemurlog_UPLOAD_CGI;
-  
-  var cgi_url=baseURL + "/Upload";
-  lemurlog_MainWin.lemurlog_upload_service.cgi_url = cgi_url;
-  lemurlog_MainWin.lemurlog_upload_service.timestamp = new Date().getTime();
-  lemurlog_MainWin.lemurlog_upload_service.cur_file = lemurlog_LOG_FILE;
-  lemurlog_MainWin.lemurlog_upload_service.upload();
-}
-
-function lemurlog_up_onAccept()
-{
-  return true;
-}
-
-
-function lemurlog_up_onCancel()
-{
-  if(!lemurlog_MainWin.lemurlog_upload_service)
-  {
-    return true;
-  }
-  lemurlog_MainWin.lemurlog_upload_service.cancelUpload();
-  return true;
-}
-
+var lemurlog_MainWin;
+
+function lemurlog_up_onLoad()
+{
+  lemurlog_MainWin = window.arguments[0];
+  lemurlog_MainWin.lemurlog_UploadWin = window;
+
+  //disable OK button
+  var btn = document.documentElement.getButton("accept");
+  btn.collapsed = true;
+
+  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+
+  var log_file_size = lemurlog_GetLogFileSize(lemurlog_LOG_FILE);
+  var page_file_size = lemurlog_GetLogFileSize(lemurlog_PAGE_FILE);
+
+  var log_str ="Activity log: "+lemurlog_NumberToHumanReadable(log_file_size);
+  var page_str ="Search log: "+lemurlog_NumberToHumanReadable(page_file_size);
+
+
+  // ensure we have a server setup!
+  if (LemurLogToolbarConfiguration._serverBaseURL.length==0) {
+    LemurLogToolbarConfiguration._serverBaseURL=window.prompt("No server address is defined\nPlease enter one\n(or leave blank for none):");
+  }
+  
+  var baseURL=LemurLogToolbarConfiguration._serverBaseURL;
+  if (baseURL==null || baseURL.length==0) {
+    lemurlog_up_onCancel();
+    window.close();
+    return;
+  } else {
+    LemurLogToolbarConfiguration.saveLocalUserConfiguration();
+  }
+
+  // Add labels
+  var item;
+  item = document.getElementById("LogTB-Up-Desc0");
+  item.setAttribute("value", "Uploading log files to " + LemurLogToolbarConfiguration._serverBaseURL + ":");
+
+  item = document.getElementById("LogTB-Up-Desc1");
+  item.setAttribute("value", log_str);
+
+  item = document.getElementById("LogTB-Up-Desc2");
+  item.setAttribute("value", page_str);
+  
+  // before uploading - scrub the files
+  item = document.getElementById("LogTB-Up-Result");
+  item.setAttribute("value", "Scrubbing log files before upload");
+  
+  lemurlog_scrubLogFiles();
+  
+  item.setAttribute("value", "Uploading...");
+
+  //upload the first file
+  // var cgi_url = "http://"+lemurlog_UPLOAD_HOST+lemurlog_UPLOAD_CGI;
+  
+  var cgi_url=baseURL + "/Upload";
+  lemurlog_MainWin.lemurlog_upload_service.cgi_url = cgi_url;
+  lemurlog_MainWin.lemurlog_upload_service.timestamp = new Date().getTime();
+  lemurlog_MainWin.lemurlog_upload_service.cur_file = lemurlog_LOG_FILE;
+  lemurlog_MainWin.lemurlog_upload_service.upload();
+}
+
+function lemurlog_up_onAccept()
+{
+  return true;
+}
+
+
+function lemurlog_up_onCancel()
+{
+  if(!lemurlog_MainWin.lemurlog_upload_service)
+  {
+    return true;
+  }
+  lemurlog_MainWin.lemurlog_upload_service.cancelUpload();
+  return true;
+}
+


Property changes on: src/chrome/content/upload.js
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: src/chrome/content/upload.xul
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome/content/utils.js
===================================================================
--- src/chrome/content/utils.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome/content/utils.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,574 +1,574 @@
-//To avoid confliction with other extensions, we put prefix "logtb_" on every global variables and functions
-//constant variables
-const lemurlog_DATA_DIR = "qthtoolbar_data";
-const lemurlog_LOG_FILE = "qthtoolbar_log";
-const lemurlog_PAGE_FILE = "qthtoolbar_pages";
-const lemurlog_TEMP_LOG_FILE = "qthtoolbar_log_tmp";
-const lemurlog_TEMP_PAGE_FILE = "qthtoolbar_pages_tmp";
-const lemurlog_LOCK_FILE = "qthtoolbar_lock";
-
-const lemurlog_UPLOAD_SUCCEED_STR="LOGTOOLBAR_UPLOAD_SUCCEED";
-
-const lemurlog_MIN_INTERVAL = 500;//milliseconds
-
-LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-LemurLogToolbarConfiguration.getDefaultServerConfiguration(true);
-
-var sanitizedSubstitution="##--##";
-
-function sanitizeString(inputString, sanitizeString) {
-  var retVal=inputString;
-  var stringPieces=sanitizeString.split("\n");
-  for (var i=0; i < stringPieces.length; i++) {
-    if (stringPieces[i].length > 0) {
-      var r=new RegExp(stringPieces[i], "gi")
-      retVal=retVal.replace(r, sanitizedSubstitution);
-    }
-  }
-  return retVal;
-}
-
-function washAndRinse(inputString, isUrl) {
-  if (isUrl==null) { isUrl=false; }
-  var outputString=inputString;
-  if (isUrl) {
-    outputString = outputString.replace(/\+/g, "%20");
-    outputString=unescape(outputString);
-  }
-  if (LemurLogToolbarConfiguration._allowBlacklistPersonal && LemurLogToolbarConfiguration._useBlacklistPersonal) {
-    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistPersonalRegex);
-  }
-  if (LemurLogToolbarConfiguration._allowBlacklistAddress && LemurLogToolbarConfiguration._useBlacklistAddress) {
-    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistAddressRegex);
-  }
-  if (LemurLogToolbarConfiguration._allowBlacklistProperName && LemurLogToolbarConfiguration._useBlacklistProperName) {
-    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistPropernameRegex);
-  }
-  if (LemurLogToolbarConfiguration._allowBlacklistKeywords && LemurLogToolbarConfiguration._useBlacklistKeywords) {
-    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistKeywordRegex);
-  }
-  return outputString;
-}
-
-///////////////////////////////////////////////////////////////////////
-// Print debug info to javascript console
-///////////////////////////////////////////////////////////////////////
-function lemurlog_PrintToConsole(text)
-{
-  var consoleService = Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
-  consoleService.logStringMessage('LemurLogToolbar: ' + text);
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// check if it's a url of search engine 
-///////////////////////////////////////////////////////////////////////
-function lemurlog_IsSearchURL(url)
-{
-  if (url.indexOf("http://www.google.com/search?") === 0
-      ||url.indexOf("http://search.live.com/results.aspx?") === 0
-      ||url.indexOf("http://search.msn.com/results.aspx?") === 0
-      ||url.indexOf("http://search.yahoo.com/search?") === 0 ) {
-
-      return true;
-  }
-  
-  // check for desktop search?
-  if (LemurLogToolbarConfiguration._useDesktopSearch==true) {
-    // check for Google desktop search
-    if ((url.indexOf("http://127.0.0.1:")===0) && (url.indexOf("/search") > 0) ) {
-      return true;
-    }
-  }
-  
-  return false;
-}
-
-///////////////////////////////////////////////////////////////////////
-// check if it's a "recordable" url 
-///////////////////////////////////////////////////////////////////////
-function lemurlog_IsRecordableURL(url)
-{
-  var isHttp=url.indexOf("http://");
-  var isHttps=url.indexOf("https://");
-
-  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
-  var isConfigServer=-1;
-  if (LemurLogToolbarConfiguration._serverBaseURL.length > 0) {
-    isConfigServer=url.indexOf(LemurLogToolbarConfiguration._serverBaseURL);
-  }
-
-  if ( ( (isHttp==0) || (isHttps==0) ) && (isConfigServer==-1) ) {
-    return true;
-  }
-  
-  // alert("In isRecordable - isHttp:" + isHttp + "\nisHttps:" + isHttps + "\nURL: " + url + "\nConfig: " + isConfigServer);
-
-  return false;
-}
-
-///////////////////////////////////////////////////////////////////////
-// Set buttons to enabled/disabled according to lemurlog_g_enalbe
-///////////////////////////////////////////////////////////////////////
-function lemurlog_SetButtons()
-{
-  var button = document.getElementById("LogTB-Pause-Button");
-  button.collapsed = (!lemurlog_g_enable);
-  button.disabled = (!lemurlog_g_enable);
-
-  var button = document.getElementById("LogTB-Pause-Button-Gray");
-  button.collapsed = lemurlog_g_enable;
-  button.disabled = true;
-
-  button = document.getElementById("LogTB-Start-Button");
-  button.collapsed = lemurlog_g_enable;
-  button.disabled = lemurlog_g_enable;
-
-  button = document.getElementById("LogTB-Start-Button-Gray");
-  button.collapsed = (!lemurlog_g_enable);
-  button.disabled = true;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-// Move file in the log directory
-///////////////////////////////////////////////////////////////////////
-function lemurlog_CreateLogFile(filename)
-{
-  var file = lemurlog_GetLogFile(filename);
-  if (!file) 
-  {
-    return;
-  }
-  if(file.exists())
-  {
-    return;
-  }
-  file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE , 0644);
-  return;
-}
-
-///////////////////////////////////////////////////////////////////////
-// Move file in the log directory
-///////////////////////////////////////////////////////////////////////
-function lemurlog_MoveLogFile(src_filename, des_filename)
-{
-  var file = lemurlog_GetLogFile(src_filename);
-  var dir = lemurlog_GetLogDir();
-  if (!file || !dir) 
-  {
-    return;
-  }
-  file.moveTo(dir, des_filename);
-  return;
-}
-
-///////////////////////////////////////////////////////////////////////
-// Remove file in the log directory
-///////////////////////////////////////////////////////////////////////
-function lemurlog_RemoveLogFile(filename)
-{
-  var file = lemurlog_GetLogFile(filename);
-  if (!file) 
-  {
-    return;
-  }
-  if(!file.exists())
-  {
-    return;
-  }
-  file.remove(false);//non-recursive
-  return;
-}
-
-function isScrubbableLogLine(logLineType) {
-  if (logLineType=="CtrlC") { return true; }
-  if (logLineType=="LClick") { return true; }
-  if (logLineType=="MClick") { return true; }
-  if (logLineType=="RClick") { return true; }
-  if (logLineType=="SelTab") { return true; }
-  if (logLineType=="Focus") { return true; }
-  if (logLineType=="Show") { return true; }
-  if (logLineType=="LoadCap") { return true; }
-  if (logLineType=="LoadBub") { return true; }
-  
-  return false;
-}
-
-///////////////////////////////////////////////////////////////////////
-// scrubs the log files based on the blacklist filters
-// also - if any blacklist term occurs in a known search query
-// remove the search results for that item
-///////////////////////////////////////////////////////////////////////
-function lemurlog_scrubLogFiles() {
-
-  // if we're locked - just return
-  var lockfile = lemurlog_GetLogFile(lemurlog_LOCK_FILE);
-  if(lockfile.exists())
-  {
-    return;
-  }
-
-  // first - lock the log
-  lemurlog_CreateLogFile(lemurlog_LOCK_FILE);
-  
-  // create an array to hold our result IDs to filter
-  var resultIdsToFilter=new Array();
-  
-  // get our temporary output log file
-  lemurlog_CreateLogFile(lemurlog_TEMP_LOG_FILE);
-  var outlogfile=lemurlog_GetLogFile(lemurlog_TEMP_LOG_FILE);
-  if (!outlogfile.exists()) {
-    return;
-  }
-  
-  var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
-  foStream.init(outlogfile, 0x02 | 0x08 | 0x10, 0600, 0);//append
-  
-  // next - roll through the log writing to the new temp
-  // keeping track of search result IDs that need filtered
-  // search IDs will be in the form of:
-  //
-  // LoadCap  <ID> <URL>
-  // Search <ID> <SIZE>
-  
-  var logfile = lemurlog_GetLogFile(lemurlog_LOG_FILE);
-  var istream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);  
-  istream.init(logfile, 0x01, 0444, 0);
-  istream.QueryInterface(Components.interfaces.nsILineInputStream);
-  
-  var lastLineWasScrubbed=false;
-  var lastLineWasLoadCap=false;
-  var lastKnownURL="";
-  var readingLine={};
-  var currentWorkingLine="";
-  var hasMore;
-  
-  do {
-    hasMore=istream.readLine(readingLine);
-    if (readingLine.value!=null) {
-      currentWorkingLine=readingLine.value;
-      
-      // split the current working line by tabs
-      var stringSplit=currentWorkingLine.split(/\t/);
-      if (stringSplit.length < 2) {
-        // just write out the line and move on
-        currentWorkingLine+="\n";
-        foStream.write(currentWorkingLine, currentWorkingLine.length);
-        continue;
-      } 
-      
-      // if the current item is a search...  
-      if (stringSplit[0]=="Search") {
-        // if last line was scrubbed and it was a loadcap event, _and_ it was a search...
-        if ((lastLineWasScrubbed==true) && (lastLineWasLoadCap==true) && (lemurlog_IsSearchURL(lastKnownURL))) {
-          // add this log ID to the list
-          resultIdsToFilter.push(stringSplit[1]);
-          
-          // and don't add the search line to the new log...
-          continue;
-        }
-      } // end if (stringSplit[0]=="Search") 
-
-      // is it one of the types we need to check?
-      if (isScrubbableLogLine(stringSplit[0])) {
-        // yes - we need to scrub it
-        // if it's CtrlC, the text is the 4th item in the array
-        // else, the URL is the 3rd
-        lastLineWasScrubbed=false;
-        lastLineWasLoadCap=false;
-        lastKnownURL="";
-        
-        if (stringSplit[0]=="CtrlC") {
-          stringSplit[3]=washAndRinse(stringSplit[3], false);
-          // was this line scrubbed? check for our delimiter
-          if (stringSplit[3].indexOf(sanitizedSubstitution) >= 0) {
-            lastLineWasScrubbed=true;
-          }
-        } else {
-          stringSplit[2]=washAndRinse(stringSplit[2], true);
-          
-          // save the last URL
-          lastKnownURL=stringSplit[2];
-          
-          // need to look for loadcap events - possible indication
-          // of a search ID coming up
-          if (stringSplit[0]=="LoadCap") {
-            lastLineWasLoadCap=true;
-          }
-
-          // was this line scrubbed? check for our delimiter
-          if (stringSplit[2].indexOf(sanitizedSubstitution) >= 0) {
-            lastLineWasScrubbed=true;
-          }
-        } // end if (stringSplit[0]=="CtrlC")
-        
-        // and recombine the line if we were scrubbed
-        if (lastLineWasScrubbed) {
-          var recomLine=stringSplit[0];
-          for (var i=1; i < stringSplit.length; i++) {
-            recomLine += "\t" + stringSplit[i];
-          }
-          currentWorkingLine=recomLine;
-        }
-      } // end if (isScrubbableLogLine(stringSplit[0]))
-      
-      // write out the possibly scrubbed line
-      currentWorkingLine+="\n";
-      foStream.write(currentWorkingLine, currentWorkingLine.length);
-    } // end if (readingLine.value!=null) {
-  } while (hasMore); // end do
-  
-  foStream.close();
-  istream.close();
-  
-  // remove the old log and rename the new one
-  lemurlog_RemoveLogFile(lemurlog_LOG_FILE);
-  lemurlog_MoveLogFile(lemurlog_TEMP_LOG_FILE, lemurlog_LOG_FILE);
-  
-  // roll through the search results log
-  // create our temp page file
-  lemurlog_CreateLogFile(lemurlog_TEMP_PAGE_FILE);
-  var outpagefile=lemurlog_GetLogFile(lemurlog_TEMP_PAGE_FILE);
-  if (!outpagefile.exists()) {
-    return;
-  }
-  
-  var pageoutStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
-  pageoutStream.init(outpagefile, 0x02 | 0x08 | 0x10, 0600, 0);//append
-  
-  // now open our original page file
-  var pagefile = lemurlog_GetLogFile(lemurlog_PAGE_FILE);
-  var pageinstream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);  
-  pageinstream.init(pagefile, 0x01, 0444, 0);
-  pageinstream.QueryInterface(Components.interfaces.nsILineInputStream);  
-  
-  var skipThisOne=false;
-  var lastLineWasHeader=false;
-  do {
-    hasMore=pageinstream.readLine(readingLine);
-    if (readingLine.value!=null) {
-      if (skipThisOne==false) {
-        currentWorkingLine=readingLine.value;
-
-        if (lastLineWasHeader) {
-          // should be our ID
-          // ID=1194982335173
-          var stringSplit=currentWorkingLine.split(/=/);
-          if (stringSplit.length==2) {
-            // does this ID appear in the ones we want to filter?
-            for (var i=0; (i < resultIdsToFilter.length) && (skipThisOne==false); i++) {
-              if (resultIdsToFilter[i]==stringSplit[1]) {
-               // yes - it's filtered
-               skipThisOne=true;
-              }
-            } // end for...
-          } // end if (stringSplit.length==2)
-          
-          if (skipThisOne==false) {
-            // no? Write out our header LOGTB\n + ID\n + the rest
-            var headerLine="LOGTB_BEGIN_SEARCH_PAGE\n";
-            pageoutStream.write(headerLine, headerLine.length);
-            currentWorkingLine+="\n";
-            pageoutStream.write(currentWorkingLine, currentWorkingLine.length);
-          }
-
-          lastLineWasHeader=false;
-        } else if (currentWorkingLine.indexOf("LOGTB_BEGIN_SEARCH_PAGE") >= 0) {
-          // look for our header: LOGTB_BEGIN_SEARCH_PAGE        
-          // next line will be ID
-          lastLineWasHeader=true;
-        } else {
-          // we're clear to write if we get here...
-          currentWorkingLine+="\n";
-          pageoutStream.write(currentWorkingLine, currentWorkingLine.length);
-        }
-      } else {
-        // we're skipping - read
-        // until the next header or EOF
-        do {
-          hasMore=pageinstream.readLine(readingLine);
-          if (readingLine.value!=null) {
-            currentWorkingLine=readingLine.value;
-            if (currentWorkingLine.indexOf("LOGTB_BEGIN_SEARCH_PAGE") >= 0) {
-              lastLineWasHeader=true;
-              break;
-            }
-          }
-        } while (hasMore);
-        
-        // reset our skip flag
-        skipThisOne=false;
-      } // end if (skipThisOne==false)
-    } // end if (readingLine.value!=null)
-  } while (hasMore); // end do
-
-  // we're done - close out output / input
-  pageoutStream.close();
-  pageinstream.close();
-  
-  // rename the new page file to the old
-  lemurlog_RemoveLogFile(lemurlog_PAGE_FILE);
-  lemurlog_MoveLogFile(lemurlog_TEMP_PAGE_FILE, lemurlog_PAGE_FILE);
-  
-  // unlock the log
-  lemurlog_RemoveLogFile(lemurlog_LOCK_FILE);
-} // end function lemurlog_scrubLogFiles()
-
-///////////////////////////////////////////////////////////////////////
-// Remove all leading and ending spaces,
-// then replace repeated spaces into a single one
-///////////////////////////////////////////////////////////////////////
-function lemurlog_TrimString(str)
-{
-  var s = str.replace(/^\s+/,"");
-  s = s.replace(/\s+$/,"");
-  return s.replace(/\s+/g, " ");
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Loads the specified URL in the browser.
-////////////////////////////////////////////////////////////////////////////////
-function lemurlog_LoadURL(url)
-{
-  // Set the browser window's location to the incoming URL
-  window.content.document.location = url;
-
-  // Make sure that we get the focus
-  window.content.focus();
-}
-
-///////////////////////////////////////////////////////////////////////
-// Get the size of a log file
-// return: number
-///////////////////////////////////////////////////////////////////////
-function lemurlog_GetLogFileSize(fileName)
-{
-  var file = lemurlog_GetLogFile(fileName);
-  if(!file.exists())
-  {
-    file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
-    return 0;
-  }
-  return file.fileSize;
-
-}
-
-///////////////////////////////////////////////////////////////////////
-// Convert positive integer into human readable form
-// e.g. 2000->2K, 2000000->2M, ...
-// return: string
-///////////////////////////////////////////////////////////////////////
-function lemurlog_NumberToHumanReadable(n)
-{
-  if(n<1000)
-  {
-    return Math.floor(n)+" B";
-  }
-  else if(n<1000000)
-  {
-    return Math.floor(n/1000)+" KB";
-  }
-  else if(n<1000000000)
-  {
-    return Math.floor(n/1000000)+" MB";
-  }
-  else
-  {
-    return Math.floor(n/1000000000)+" GB";
-  }
-
-}
-
-///////////////////////////////////////////////////////////////////////
-// Get the nsIFile object of log data directory
-///////////////////////////////////////////////////////////////////////
-function lemurlog_GetLogDir()
-{
-  // Get profile directory.
-  var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
-  if(!dirService)
-  {
-    return null;
-  }
-  var dir = dirService.get("ProfD", Components.interfaces.nsIFile);
-  if(!dir)
-  {
-    return null;
-  }
-  dir.append(lemurlog_DATA_DIR);
-  if (!dir.exists())
-  {
-    dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
-  }
-  return dir;
-}
-///////////////////////////////////////////////////////////////////////
-// Get the nsIFile object of a log file
-///////////////////////////////////////////////////////////////////////
-function lemurlog_GetLogFile(fileName)
-{
-  var file = lemurlog_GetLogDir();
-  if(!file)
-  {
-    return null;
-  }
-  file.append(fileName);
-  return file;
-}
-
-///////////////////////////////////////////////////////////////////////
-// Write text to a log file
-///////////////////////////////////////////////////////////////////////
-function lemurlog_WriteLogFile(fileName, text) 
-{
-  //avoid read/write confliction
-  if(!lemurlog_g_enable)
-  {
-    return;
-  }
-  //use a lock file instead of a global variable
-  var lockfile = lemurlog_GetLogFile(lemurlog_LOCK_FILE);
-  if(lockfile.exists())
-  {
-    return;
-  }
-  //write file
-  var file = lemurlog_GetLogFile(fileName);
-  if(!file)
-  {
-    return;
-  }
-  var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
-  foStream.init(file, 0x02 | 0x08 | 0x10, 0600, 0);//append
-  foStream.write(text, text.length);
-  foStream.close();
-}
-
-///////////////////////////////////////////////////////////////////////
-// Extract the random unique string(8 characters) from the path of user profile(windows only)
-///////////////////////////////////////////////////////////////////////
-function lemurlog_GetUniqueStringFromProfilePath(forUpload)
-{
-  if (forUpload!=null && forUpload==true) {
-    if (LemurLogToolbarConfiguration._allowRandomSessionId && LemurLogToolbarConfiguration._useRandomSessionId) {
-      var rand_no = Math.random();
-      return "" + (rand_no*100000.0);
-    }
-  }
-  // Get profile directory.
-  var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
-  if(!dirService)
-  {
-    return null;
-  }
-  var prof_dir = dirService.get("ProfD", Components.interfaces.nsIFile);
-  if(!prof_dir)
-  {
-    return null;
-  }
-  var unique_str = prof_dir.leafName.substring(0, 8);
-  return unique_str;
-}
-
-
+//To avoid confliction with other extensions, we put prefix "logtb_" on every global variables and functions
+//constant variables
+const lemurlog_DATA_DIR = "qthtoolbar_data";
+const lemurlog_LOG_FILE = "qthtoolbar_log";
+const lemurlog_PAGE_FILE = "qthtoolbar_pages";
+const lemurlog_TEMP_LOG_FILE = "qthtoolbar_log_tmp";
+const lemurlog_TEMP_PAGE_FILE = "qthtoolbar_pages_tmp";
+const lemurlog_LOCK_FILE = "qthtoolbar_lock";
+
+const lemurlog_UPLOAD_SUCCEED_STR="LOGTOOLBAR_UPLOAD_SUCCEED";
+
+const lemurlog_MIN_INTERVAL = 500;//milliseconds
+
+LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+LemurLogToolbarConfiguration.getDefaultServerConfiguration(true);
+
+var sanitizedSubstitution="##--##";
+
+function sanitizeString(inputString, sanitizeString) {
+  var retVal=inputString;
+  var stringPieces=sanitizeString.split("\n");
+  for (var i=0; i < stringPieces.length; i++) {
+    if (stringPieces[i].length > 0) {
+      var r=new RegExp(stringPieces[i], "gi")
+      retVal=retVal.replace(r, sanitizedSubstitution);
+    }
+  }
+  return retVal;
+}
+
+function washAndRinse(inputString, isUrl) {
+  if (isUrl==null) { isUrl=false; }
+  var outputString=inputString;
+  if (isUrl) {
+    outputString = outputString.replace(/\+/g, "%20");
+    outputString=unescape(outputString);
+  }
+  if (LemurLogToolbarConfiguration._allowBlacklistPersonal && LemurLogToolbarConfiguration._useBlacklistPersonal) {
+    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistPersonalRegex);
+  }
+  if (LemurLogToolbarConfiguration._allowBlacklistAddress && LemurLogToolbarConfiguration._useBlacklistAddress) {
+    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistAddressRegex);
+  }
+  if (LemurLogToolbarConfiguration._allowBlacklistProperName && LemurLogToolbarConfiguration._useBlacklistProperName) {
+    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistPropernameRegex);
+  }
+  if (LemurLogToolbarConfiguration._allowBlacklistKeywords && LemurLogToolbarConfiguration._useBlacklistKeywords) {
+    outputString=sanitizeString(outputString, LemurLogToolbarConfiguration._blacklistKeywordRegex);
+  }
+  return outputString;
+}
+
+///////////////////////////////////////////////////////////////////////
+// Print debug info to javascript console
+///////////////////////////////////////////////////////////////////////
+function lemurlog_PrintToConsole(text)
+{
+  var consoleService = Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
+  consoleService.logStringMessage('LemurLogToolbar: ' + text);
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// check if it's a url of search engine 
+///////////////////////////////////////////////////////////////////////
+function lemurlog_IsSearchURL(url)
+{
+  if (url.indexOf("http://www.google.com/search?") === 0
+      ||url.indexOf("http://search.live.com/results.aspx?") === 0
+      ||url.indexOf("http://search.msn.com/results.aspx?") === 0
+      ||url.indexOf("http://search.yahoo.com/search?") === 0 ) {
+
+      return true;
+  }
+  
+  // check for desktop search?
+  if (LemurLogToolbarConfiguration._useDesktopSearch==true) {
+    // check for Google desktop search
+    if ((url.indexOf("http://127.0.0.1:")===0) && (url.indexOf("/search") > 0) ) {
+      return true;
+    }
+  }
+  
+  return false;
+}
+
+///////////////////////////////////////////////////////////////////////
+// check if it's a "recordable" url 
+///////////////////////////////////////////////////////////////////////
+function lemurlog_IsRecordableURL(url)
+{
+  var isHttp=url.indexOf("http://");
+  var isHttps=url.indexOf("https://");
+
+  LemurLogToolbarConfiguration.loadLocalUserConfiguration();
+  var isConfigServer=-1;
+  if (LemurLogToolbarConfiguration._serverBaseURL.length > 0) {
+    isConfigServer=url.indexOf(LemurLogToolbarConfiguration._serverBaseURL);
+  }
+
+  if ( ( (isHttp==0) || (isHttps==0) ) && (isConfigServer==-1) ) {
+    return true;
+  }
+  
+  // alert("In isRecordable - isHttp:" + isHttp + "\nisHttps:" + isHttps + "\nURL: " + url + "\nConfig: " + isConfigServer);
+
+  return false;
+}
+
+///////////////////////////////////////////////////////////////////////
+// Set buttons to enabled/disabled according to lemurlog_g_enalbe
+///////////////////////////////////////////////////////////////////////
+function lemurlog_SetButtons()
+{
+  var button = document.getElementById("LogTB-Pause-Button");
+  button.collapsed = (!lemurlog_g_enable);
+  button.disabled = (!lemurlog_g_enable);
+
+  var button = document.getElementById("LogTB-Pause-Button-Gray");
+  button.collapsed = lemurlog_g_enable;
+  button.disabled = true;
+
+  button = document.getElementById("LogTB-Start-Button");
+  button.collapsed = lemurlog_g_enable;
+  button.disabled = lemurlog_g_enable;
+
+  button = document.getElementById("LogTB-Start-Button-Gray");
+  button.collapsed = (!lemurlog_g_enable);
+  button.disabled = true;
+}
+
+
+///////////////////////////////////////////////////////////////////////
+// Move file in the log directory
+///////////////////////////////////////////////////////////////////////
+function lemurlog_CreateLogFile(filename)
+{
+  var file = lemurlog_GetLogFile(filename);
+  if (!file) 
+  {
+    return;
+  }
+  if(file.exists())
+  {
+    return;
+  }
+  file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE , 0644);
+  return;
+}
+
+///////////////////////////////////////////////////////////////////////
+// Move file in the log directory
+///////////////////////////////////////////////////////////////////////
+function lemurlog_MoveLogFile(src_filename, des_filename)
+{
+  var file = lemurlog_GetLogFile(src_filename);
+  var dir = lemurlog_GetLogDir();
+  if (!file || !dir) 
+  {
+    return;
+  }
+  file.moveTo(dir, des_filename);
+  return;
+}
+
+///////////////////////////////////////////////////////////////////////
+// Remove file in the log directory
+///////////////////////////////////////////////////////////////////////
+function lemurlog_RemoveLogFile(filename)
+{
+  var file = lemurlog_GetLogFile(filename);
+  if (!file) 
+  {
+    return;
+  }
+  if(!file.exists())
+  {
+    return;
+  }
+  file.remove(false);//non-recursive
+  return;
+}
+
+function isScrubbableLogLine(logLineType) {
+  if (logLineType=="CtrlC") { return true; }
+  if (logLineType=="LClick") { return true; }
+  if (logLineType=="MClick") { return true; }
+  if (logLineType=="RClick") { return true; }
+  if (logLineType=="SelTab") { return true; }
+  if (logLineType=="Focus") { return true; }
+  if (logLineType=="Show") { return true; }
+  if (logLineType=="LoadCap") { return true; }
+  if (logLineType=="LoadBub") { return true; }
+  
+  return false;
+}
+
+///////////////////////////////////////////////////////////////////////
+// scrubs the log files based on the blacklist filters
+// also - if any blacklist term occurs in a known search query
+// remove the search results for that item
+///////////////////////////////////////////////////////////////////////
+function lemurlog_scrubLogFiles() {
+
+  // if we're locked - just return
+  var lockfile = lemurlog_GetLogFile(lemurlog_LOCK_FILE);
+  if(lockfile.exists())
+  {
+    return;
+  }
+
+  // first - lock the log
+  lemurlog_CreateLogFile(lemurlog_LOCK_FILE);
+  
+  // create an array to hold our result IDs to filter
+  var resultIdsToFilter=new Array();
+  
+  // get our temporary output log file
+  lemurlog_CreateLogFile(lemurlog_TEMP_LOG_FILE);
+  var outlogfile=lemurlog_GetLogFile(lemurlog_TEMP_LOG_FILE);
+  if (!outlogfile.exists()) {
+    return;
+  }
+  
+  var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
+  foStream.init(outlogfile, 0x02 | 0x08 | 0x10, 0600, 0);//append
+  
+  // next - roll through the log writing to the new temp
+  // keeping track of search result IDs that need filtered
+  // search IDs will be in the form of:
+  //
+  // LoadCap  <ID> <URL>
+  // Search <ID> <SIZE>
+  
+  var logfile = lemurlog_GetLogFile(lemurlog_LOG_FILE);
+  var istream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);  
+  istream.init(logfile, 0x01, 0444, 0);
+  istream.QueryInterface(Components.interfaces.nsILineInputStream);
+  
+  var lastLineWasScrubbed=false;
+  var lastLineWasLoadCap=false;
+  var lastKnownURL="";
+  var readingLine={};
+  var currentWorkingLine="";
+  var hasMore;
+  
+  do {
+    hasMore=istream.readLine(readingLine);
+    if (readingLine.value!=null) {
+      currentWorkingLine=readingLine.value;
+      
+      // split the current working line by tabs
+      var stringSplit=currentWorkingLine.split(/\t/);
+      if (stringSplit.length < 2) {
+        // just write out the line and move on
+        currentWorkingLine+="\n";
+        foStream.write(currentWorkingLine, currentWorkingLine.length);
+        continue;
+      } 
+      
+      // if the current item is a search...  
+      if (stringSplit[0]=="Search") {
+        // if last line was scrubbed and it was a loadcap event, _and_ it was a search...
+        if ((lastLineWasScrubbed==true) && (lastLineWasLoadCap==true) && (lemurlog_IsSearchURL(lastKnownURL))) {
+          // add this log ID to the list
+          resultIdsToFilter.push(stringSplit[1]);
+          
+          // and don't add the search line to the new log...
+          continue;
+        }
+      } // end if (stringSplit[0]=="Search") 
+
+      // is it one of the types we need to check?
+      if (isScrubbableLogLine(stringSplit[0])) {
+        // yes - we need to scrub it
+        // if it's CtrlC, the text is the 4th item in the array
+        // else, the URL is the 3rd
+        lastLineWasScrubbed=false;
+        lastLineWasLoadCap=false;
+        lastKnownURL="";
+        
+        if (stringSplit[0]=="CtrlC") {
+          stringSplit[3]=washAndRinse(stringSplit[3], false);
+          // was this line scrubbed? check for our delimiter
+          if (stringSplit[3].indexOf(sanitizedSubstitution) >= 0) {
+            lastLineWasScrubbed=true;
+          }
+        } else {
+          stringSplit[2]=washAndRinse(stringSplit[2], true);
+          
+          // save the last URL
+          lastKnownURL=stringSplit[2];
+          
+          // need to look for loadcap events - possible indication
+          // of a search ID coming up
+          if (stringSplit[0]=="LoadCap") {
+            lastLineWasLoadCap=true;
+          }
+
+          // was this line scrubbed? check for our delimiter
+          if (stringSplit[2].indexOf(sanitizedSubstitution) >= 0) {
+            lastLineWasScrubbed=true;
+          }
+        } // end if (stringSplit[0]=="CtrlC")
+        
+        // and recombine the line if we were scrubbed
+        if (lastLineWasScrubbed) {
+          var recomLine=stringSplit[0];
+          for (var i=1; i < stringSplit.length; i++) {
+            recomLine += "\t" + stringSplit[i];
+          }
+          currentWorkingLine=recomLine;
+        }
+      } // end if (isScrubbableLogLine(stringSplit[0]))
+      
+      // write out the possibly scrubbed line
+      currentWorkingLine+="\n";
+      foStream.write(currentWorkingLine, currentWorkingLine.length);
+    } // end if (readingLine.value!=null) {
+  } while (hasMore); // end do
+  
+  foStream.close();
+  istream.close();
+  
+  // remove the old log and rename the new one
+  lemurlog_RemoveLogFile(lemurlog_LOG_FILE);
+  lemurlog_MoveLogFile(lemurlog_TEMP_LOG_FILE, lemurlog_LOG_FILE);
+  
+  // roll through the search results log
+  // create our temp page file
+  lemurlog_CreateLogFile(lemurlog_TEMP_PAGE_FILE);
+  var outpagefile=lemurlog_GetLogFile(lemurlog_TEMP_PAGE_FILE);
+  if (!outpagefile.exists()) {
+    return;
+  }
+  
+  var pageoutStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
+  pageoutStream.init(outpagefile, 0x02 | 0x08 | 0x10, 0600, 0);//append
+  
+  // now open our original page file
+  var pagefile = lemurlog_GetLogFile(lemurlog_PAGE_FILE);
+  var pageinstream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);  
+  pageinstream.init(pagefile, 0x01, 0444, 0);
+  pageinstream.QueryInterface(Components.interfaces.nsILineInputStream);  
+  
+  var skipThisOne=false;
+  var lastLineWasHeader=false;
+  do {
+    hasMore=pageinstream.readLine(readingLine);
+    if (readingLine.value!=null) {
+      if (skipThisOne==false) {
+        currentWorkingLine=readingLine.value;
+
+        if (lastLineWasHeader) {
+          // should be our ID
+          // ID=1194982335173
+          var stringSplit=currentWorkingLine.split(/=/);
+          if (stringSplit.length==2) {
+            // does this ID appear in the ones we want to filter?
+            for (var i=0; (i < resultIdsToFilter.length) && (skipThisOne==false); i++) {
+              if (resultIdsToFilter[i]==stringSplit[1]) {
+               // yes - it's filtered
+               skipThisOne=true;
+              }
+            } // end for...
+          } // end if (stringSplit.length==2)
+          
+          if (skipThisOne==false) {
+            // no? Write out our header LOGTB\n + ID\n + the rest
+            var headerLine="LOGTB_BEGIN_SEARCH_PAGE\n";
+            pageoutStream.write(headerLine, headerLine.length);
+            currentWorkingLine+="\n";
+            pageoutStream.write(currentWorkingLine, currentWorkingLine.length);
+          }
+
+          lastLineWasHeader=false;
+        } else if (currentWorkingLine.indexOf("LOGTB_BEGIN_SEARCH_PAGE") >= 0) {
+          // look for our header: LOGTB_BEGIN_SEARCH_PAGE        
+          // next line will be ID
+          lastLineWasHeader=true;
+        } else {
+          // we're clear to write if we get here...
+          currentWorkingLine+="\n";
+          pageoutStream.write(currentWorkingLine, currentWorkingLine.length);
+        }
+      } else {
+        // we're skipping - read
+        // until the next header or EOF
+        do {
+          hasMore=pageinstream.readLine(readingLine);
+          if (readingLine.value!=null) {
+            currentWorkingLine=readingLine.value;
+            if (currentWorkingLine.indexOf("LOGTB_BEGIN_SEARCH_PAGE") >= 0) {
+              lastLineWasHeader=true;
+              break;
+            }
+          }
+        } while (hasMore);
+        
+        // reset our skip flag
+        skipThisOne=false;
+      } // end if (skipThisOne==false)
+    } // end if (readingLine.value!=null)
+  } while (hasMore); // end do
+
+  // we're done - close out output / input
+  pageoutStream.close();
+  pageinstream.close();
+  
+  // rename the new page file to the old
+  lemurlog_RemoveLogFile(lemurlog_PAGE_FILE);
+  lemurlog_MoveLogFile(lemurlog_TEMP_PAGE_FILE, lemurlog_PAGE_FILE);
+  
+  // unlock the log
+  lemurlog_RemoveLogFile(lemurlog_LOCK_FILE);
+} // end function lemurlog_scrubLogFiles()
+
+///////////////////////////////////////////////////////////////////////
+// Remove all leading and ending spaces,
+// then replace repeated spaces into a single one
+///////////////////////////////////////////////////////////////////////
+function lemurlog_TrimString(str)
+{
+  var s = str.replace(/^\s+/,"");
+  s = s.replace(/\s+$/,"");
+  return s.replace(/\s+/g, " ");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Loads the specified URL in the browser.
+////////////////////////////////////////////////////////////////////////////////
+function lemurlog_LoadURL(url)
+{
+  // Set the browser window's location to the incoming URL
+  window.content.document.location = url;
+
+  // Make sure that we get the focus
+  window.content.focus();
+}
+
+///////////////////////////////////////////////////////////////////////
+// Get the size of a log file
+// return: number
+///////////////////////////////////////////////////////////////////////
+function lemurlog_GetLogFileSize(fileName)
+{
+  var file = lemurlog_GetLogFile(fileName);
+  if(!file.exists())
+  {
+    file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
+    return 0;
+  }
+  return file.fileSize;
+
+}
+
+///////////////////////////////////////////////////////////////////////
+// Convert positive integer into human readable form
+// e.g. 2000->2K, 2000000->2M, ...
+// return: string
+///////////////////////////////////////////////////////////////////////
+function lemurlog_NumberToHumanReadable(n)
+{
+  if(n<1000)
+  {
+    return Math.floor(n)+" B";
+  }
+  else if(n<1000000)
+  {
+    return Math.floor(n/1000)+" KB";
+  }
+  else if(n<1000000000)
+  {
+    return Math.floor(n/1000000)+" MB";
+  }
+  else
+  {
+    return Math.floor(n/1000000000)+" GB";
+  }
+
+}
+
+///////////////////////////////////////////////////////////////////////
+// Get the nsIFile object of log data directory
+///////////////////////////////////////////////////////////////////////
+function lemurlog_GetLogDir()
+{
+  // Get profile directory.
+  var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
+  if(!dirService)
+  {
+    return null;
+  }
+  var dir = dirService.get("ProfD", Components.interfaces.nsIFile);
+  if(!dir)
+  {
+    return null;
+  }
+  dir.append(lemurlog_DATA_DIR);
+  if (!dir.exists())
+  {
+    dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
+  }
+  return dir;
+}
+///////////////////////////////////////////////////////////////////////
+// Get the nsIFile object of a log file
+///////////////////////////////////////////////////////////////////////
+function lemurlog_GetLogFile(fileName)
+{
+  var file = lemurlog_GetLogDir();
+  if(!file)
+  {
+    return null;
+  }
+  file.append(fileName);
+  return file;
+}
+
+///////////////////////////////////////////////////////////////////////
+// Write text to a log file
+///////////////////////////////////////////////////////////////////////
+function lemurlog_WriteLogFile(fileName, text) 
+{
+  //avoid read/write confliction
+  if(!lemurlog_g_enable)
+  {
+    return;
+  }
+  //use a lock file instead of a global variable
+  var lockfile = lemurlog_GetLogFile(lemurlog_LOCK_FILE);
+  if(lockfile.exists())
+  {
+    return;
+  }
+  //write file
+  var file = lemurlog_GetLogFile(fileName);
+  if(!file)
+  {
+    return;
+  }
+  var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
+  foStream.init(file, 0x02 | 0x08 | 0x10, 0600, 0);//append
+  foStream.write(text, text.length);
+  foStream.close();
+}
+
+///////////////////////////////////////////////////////////////////////
+// Extract the random unique string(8 characters) from the path of user profile(windows only)
+///////////////////////////////////////////////////////////////////////
+function lemurlog_GetUniqueStringFromProfilePath(forUpload)
+{
+  if (forUpload!=null && forUpload==true) {
+    if (LemurLogToolbarConfiguration._allowRandomSessionId && LemurLogToolbarConfiguration._useRandomSessionId) {
+      var rand_no = Math.random();
+      return "" + (rand_no*100000.0);
+    }
+  }
+  // Get profile directory.
+  var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
+  if(!dirService)
+  {
+    return null;
+  }
+  var prof_dir = dirService.get("ProfD", Components.interfaces.nsIFile);
+  if(!prof_dir)
+  {
+    return null;
+  }
+  var unique_str = prof_dir.leafName.substring(0, 8);
+  return unique_str;
+}
+
+


Property changes on: src/chrome/content/utils.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/chrome.manifest
===================================================================
--- src/chrome.manifest	2009-10-08 04:40:32 UTC (rev 6)
+++ src/chrome.manifest	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,4 +1,4 @@
-overlay	chrome://browser/content/browser.xul	chrome://qthtoolbar/content/logtoolbar.xul
-overlay	chrome://navigator/content/navigator.xul	chrome://qthtoolbar/content/logtoolbar.xul
-content	qthtoolbar	jar:chrome/qth_toolbar.jar!/content/
-skin	qthtoolbar	classic/1.0	jar:chrome/qth_toolbar.jar!/skin/
+overlay	chrome://browser/content/browser.xul	chrome://qthtoolbar/content/logtoolbar.xul
+overlay	chrome://navigator/content/navigator.xul	chrome://qthtoolbar/content/logtoolbar.xul
+content	qthtoolbar	jar:chrome/qth_toolbar.jar!/content/
+skin	qthtoolbar	classic/1.0	jar:chrome/qth_toolbar.jar!/skin/


Property changes on: src/chrome.manifest
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/components/qth_toolbar_singleton.js
===================================================================
--- src/components/qth_toolbar_singleton.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/components/qth_toolbar_singleton.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,35 +1,35 @@
-////////////////////////////////////////////////////////////////////////////////
-
-function NSGetModule() {
-	function xpcom_ns_get_module_impl(conponent_uuid, component_name, conponent_id, create_instance_func) {
-		if(!create_instance_func)
-			create_instance_func = function(){ return {}; }
-		return {
-			registerSelf : function (compMgr, fileSpec, location, type) {
-				compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar).registerFactoryLocation(
-					Components.ID(conponent_uuid),
-					component_name,
-					conponent_id,
-					fileSpec,
-					location,
-					type
-				);
-			},
-			getClassObject : function() {
-				return {
-					createInstance : function() {
-						var instance = create_instance_func();
-						instance.wrappedJSObject = instance;
-						return instance;
-					}
-				};
-			},
-			canUnload : function() {
-				return true;
-			}
-		}
-	}
-	return xpcom_ns_get_module_impl('9636088b-c9d9-49e9-9be6-53479e870f34', 'qth_toolbar_singleton_object', '@kyagroup.com/qth_toolbar/singleton_object;1')
-}
-
-///////////////////////////////////////////////////////////////////070913.171300
+////////////////////////////////////////////////////////////////////////////////
+
+function NSGetModule() {
+	function xpcom_ns_get_module_impl(conponent_uuid, component_name, conponent_id, create_instance_func) {
+		if(!create_instance_func)
+			create_instance_func = function(){ return {}; }
+		return {
+			registerSelf : function (compMgr, fileSpec, location, type) {
+				compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar).registerFactoryLocation(
+					Components.ID(conponent_uuid),
+					component_name,
+					conponent_id,
+					fileSpec,
+					location,
+					type
+				);
+			},
+			getClassObject : function() {
+				return {
+					createInstance : function() {
+						var instance = create_instance_func();
+						instance.wrappedJSObject = instance;
+						return instance;
+					}
+				};
+			},
+			canUnload : function() {
+				return true;
+			}
+		}
+	}
+	return xpcom_ns_get_module_impl('9636088b-c9d9-49e9-9be6-53479e870f34', 'qth_toolbar_singleton_object', '@kyagroup.com/qth_toolbar/singleton_object;1')
+}
+
+///////////////////////////////////////////////////////////////////070913.171300


Property changes on: src/components/qth_toolbar_singleton.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: src/defaults/preferences/defaults.js
===================================================================
--- src/defaults/preferences/defaults.js	2009-10-08 04:40:32 UTC (rev 6)
+++ src/defaults/preferences/defaults.js	2009-10-09 09:09:37 UTC (rev 7)
@@ -1,22 +1,22 @@
-pref("extensions.lemurquerylog.server", "");
-pref("extensions.lemurquerylog.userandomsession", false);
-
-pref("extensions.lemurquerylog.logdesktopsearch", true);
-
-pref("extensions.lemurquerylog.usepersonalbl", true);
-pref("extensions.lemurquerylog.useaddressbl", true);
-pref("extensions.lemurquerylog.usepropernamebl", true);
-pref("extensions.lemurquerylog.usekeywordbl", true);
-
-pref("extensions.lemurquerylog.encmodulus", "");
-pref("extensions.lemurquerylog.encexponent", "");
-
-pref("extensions.lemurquerylog.bl.personal", "");
-pref("extensions.lemurquerylog.bl.address", "");
-pref("extensions.lemurquerylog.bl.propername", "");
-pref("extensions.lemurquerylog.bl.keyword", "");
-
-pref("extensions.lemurquerylog.bl.personalrx", "");
-pref("extensions.lemurquerylog.bl.addressrx", "");
-pref("extensions.lemurquerylog.bl.propernamerx", "");
-pref("extensions.lemurquerylog.bl.keywordrx", "");
+pref("extensions.lemurquerylog.server", "");
+pref("extensions.lemurquerylog.userandomsession", false);
+
+pref("extensions.lemurquerylog.logdesktopsearch", true);
+
+pref("extensions.lemurquerylog.usepersonalbl", true);
+pref("extensions.lemurquerylog.useaddressbl", true);
+pref("extensions.lemurquerylog.usepropernamebl", true);
+pref("extensions.lemurquerylog.usekeywordbl", true);
+
+pref("extensions.lemurquerylog.encmodulus", "");
+pref("extensions.lemurquerylog.encexponent", "");
+
+pref("extensions.lemurquerylog.bl.personal", "");
+pref("extensions.lemurquerylog.bl.address", "");
+pref("extensions.lemurquerylog.bl.propername", "");
+pref("extensions.lemurquerylog.bl.keyword", "");
+
+pref("extensions.lemurquerylog.bl.personalrx", "");
+pref("extensions.lemurquerylog.bl.addressrx", "");
+pref("extensions.lemurquerylog.bl.propernamerx", "");
+pref("extensions.lemurquerylog.bl.keywordrx", "");


Property changes on: src/defaults/preferences/defaults.js
___________________________________________________________________
Added: svn:eol-style
   + native




Cres-cvs メーリングリストの案内
Back to archive index