/*
 * Copyright 2006 OST-SYSTEMS. All rights reserved.
 */

function FirefoxLocalDir(path) {
  this.path = path;
  this.self = this;
}

FirefoxLocalDir.prototype.getCategoryList = function(callback) {
  callback(null);
}
  
FirefoxLocalDir.prototype.getPathList = function(callback, category) {
  if (window.netscape) {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
  }
  request = createXMLHttpRequest();
  request.open("GET", this.path, true);
  request.onload = function(e) {
    var response = request.responseText;
    var result = new Array();
    var i = 0;
    var index = response.indexOf("201: ");
    while (index >= 0) {
      var index2 = response.indexOf(" ", index + 5);
      if (index2 >= 0) {
        var dir = response.substring(index + 5, index2);
        result[i] = new Object();
        result[i].path = dir;
        result[i].title = dir;
        i++;
        index = response.indexOf("201: ", index2);
      }
      else {
        index = -1;
      }
    }
    callback(result);
  }
  request.send(null);    
}
  
FirefoxLocalDir.prototype.getWidgetsCount = function(callback) {
  if (window.netscape) {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
  }
  request = createXMLHttpRequest();
  request.open("GET", this.path, true);
  request.onload = function(e) {
    var response = request.responseText;
    var i = 0;
    var index = response.indexOf("201: ");
    while (index >= 0) {
      var index2 = response.indexOf(" ", index + 5);
      if (index2 >= 0) {
        i++;
        index = response.indexOf("201: ", index2);
      }
      else {
        index = -1;
      }
    }
    callback(i);
  }
  request.send(null);    
}
  
FirefoxLocalDir.prototype.getWidgetInfo = function(callback, path) {
  result = Object();
  result.path = path;
  result.title = path;
  result.description = "No description";
  result.summary = "No summary";
  result.version = "1.0";
  result.size = "unknown";
  callback(result);
}

FirefoxLocalDir.prototype.widgetAdded = function(path) {
}  

FirefoxLocalDir.prototype.favouriteRemoved = function(path) {
}  
