I am building an ext for tb addressbook. I need to query the local
address book directory for particular kind of cards.  Contact
searching  is currently being done in tb using nsIAbView interface
which is promarily used for geting the xul tree view of the search
results. I can not use it as my query results are not viewed as a
tree.
   So i tried using nsIDirectoryQuery interface. Found no help on the
web abt its usage - looks like none on the planet tried it ;)
    The problem is, i get a SegFault in
nsAbDirectoryQueryProxy::DoQuery()   ....  libmail.so

  Here is the JS code.

   var qs = Cc["@mozilla.org/boolean-expression/condition-string;1"]
                           .createInstance(Ci.nsIAbBooleanConditionString);
   qs.name = "firstName";  // XXX: no idea what this should be.
guessing
   qs.value = "xyz";
   qs.condition = Ci.nsIAbBooleanConditionTypes.IsNot;

   var qe = Cc["@mozilla.org/boolean-expression/n-peer;1"]
                             .createInstance(Ci.nsIAbBooleanExpression);
   var exprArr = Components.classes["@mozilla.org/supports-array;1"]
                             
.createInstance(Components.interfaces.nsISupportsArray);
   exprArr.AppendElement(qs);
   // qe.asetExpressions(1,exprArr);  //not implemented.. setting
directly
   qe.expressions = exprArr;
   //qe.operation = Ci.nsIAbBooleanOperationTypes.OR;  //not
accessible. setting it manually
   qe.operation = 0;

  var queryArgs = Cc["@mozilla.org/addressbook/directory/query-
arguments;1"]
                                         
.createInstance(Ci.nsIAbDirectoryQueryArguments);
  queryArgs.querySubDirectories = true;
  queryArgs.setReturnProperties(1, ["card:nsIAbCard"] );  // XXX: no
sure if this is the correct 2nd arg. found it in comp source.
  queryArgs.expression = qe;

  var dirQProxy = Cc["@mozilla.org/addressbook/directory-query/proxy;
1"]
                                        
.createInstance(Ci.nsIAbDirectoryQueryProxy);  //
Is this connected to DirQuer??
   var directory = rdf.GetResource(GetSelectedDirectory())
                                         
.QueryInterface(Components.interfaces.nsIAbDirectory);
   dirQProxy.initiate(directory);

  var dirQuery = Cc["@mozilla.org/addressbook/directory-query/proxy;
1"]
                                        .createInstance(Ci.nsIAbDirectoryQuery);
  dirQuery.doQuery( queryArgs, dirQueryResListener, 10, 100);

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to