[added .xpcom to the Newsgroups line; perhaps the XPCOM folks will
have opinions on some of the items touched on here]

Paul Sandoz <[EMAIL PROTECTED]> writes:
> 
> >Paul Sandoz <[EMAIL PROTECTED]> writes:
> >> 
> >>    Attached is a revamped set of nsIAbDirectoryQuery*
> >>    interfaces. Decided the nsIProperties interface was
> >>    not suitable.
> >>    Considered using arrays but used nsISupportsArray
> >>    for corresponding attributes instead. 
> >
> >Just out of curiousity, why?  The nsISupportsArray interface is only
> >not very scriptable, after all.
> 
>       I know :-( i decided to go completely one
>       way to see how it looked, then could work
>       out how to make it easier for js.

Fair enough.  I also just added a comment to bug 66138 lobbying for
improving the scriptability of nsISupportsArray.  It sure would be
nice if there was some way to unify XPCOM arrays and
nsISupportsArrays, or, failing that, at least make the latter more
scriptable.  One could even imagine a world where in certain
circumstances, XPConnect could directly map an nsISupportsArray to a
JS array.

> >> #include "nsISupports.idl"
> >> #include "nsISupportsArray.idl"
> >> 
> >> [scriptable, uuid(0E846276-1DD2-11B2-95AD-96B1397240AC)]
> >> interface nsIAbDirectoryQueryProperty : nsISupports
> >> {
> >>    /**
> >>     * The property which should be matched
> >>     *
> >>     * For example 'primaryEmail' or 'homePhone'
> >>     * for card properties.
> >>     *
> >>     * Two further properties are defined that 
> >>     * do not exist as properties on a card.
> >>     * 'card:URI' which represents the URI property
> >>     * of the card as an RDF resource
> >>     * 'card:nsIAbCard' which represents the interface
> >>     * of a card component
> >>     *
> >>     */
> >>    attribute string name;
> >> };
> >> 
> >> [scriptable, uuid(3A6E0C0C-1DD2-11B2-B23D-EA3A8CCB333C)]
> >> interface nsIAbDirectoryQueryPropertyValue : nsIAbDirectoryQueryProperty
> >> {
> >>    /**
> >>     * The value of the property
> >>     *
> >>     */
> >>    attribute wstring value;
> >> };
> >
> >Does these actually need to be interfaces, or could they just be
> >passed around as wstrings?  And how come one of them is a string
> >rather than a wstring?
> >
> 
>       I was trying to ensure that the QueryMatchItem type could
>       also be treated as a Property type. This makes it easy
>       to reuse the QueryMatchItem for the returned properties
>       since what you are searching for is often what you want
>       returned.

Ah, that makes sense.

>       The string represents the property name which will never
>       require i18n support therefore i did not think it
>       needed to be a unicode string.
>       Is this a valid assumption?

Sounds reasonable to me; though my i18n fu is not yet strong.

>       One problem with XPCOM is that it is lacking an 'Any'
>       type (like CORBA_Any) which makes if difficult to
>       combine interfaces and basic, or built-in, types into
>       an array. I suppose i am used to this flexibilty.

Now I get it.

> >>    /**
> >>     * List of defined match items types
> >>     *
> >>     */
> >>    const long matchItemsOneOrMore  = 0;
> >>    const long matchItemsAll        = 1;
> >>
> >
> >Would it be worthwhile to design the interfaces to support boolean
> >logic (and, or, not, precedence), to allow for future expansion?

I'm still curious to hear any thoughts you might have on the above
question.

>       Attached is a version with support for nsISupportsArray
>       and arrays. Additionally added an nsISupports attribute
>       to the QueryPropertyValue interface if a property
>       is associated with an interface (e.g. nsIAbCard).

Cool; it would be interesting to hear any comments on these from
Candice or Ducarroz...

> Thanks,
> Paul.
> 
> 
> | ? + ? = To question
> ----------------\
>    Paul Sandoz
>         x19219
> +353-1-8199219
>  
> 
> -=-=-=-=-=-
> 
> 
> #include "nsISupports.idl"
> #include "nsISupportsArray.idl"
> 
> [scriptable, uuid(0E846276-1DD2-11B2-95AD-96B1397240AC)]
> interface nsIAbDirectoryQueryProperty : nsISupports
> {
>       /**
>        * The property which should be matched
>        *
>        * For example 'primaryEmail' or 'homePhone'
>        * for card properties.
>        *
>        * Two further properties are defined that 
>        * do not exist as properties on a card.
>        * 'card:URI' which represents the URI property
>        * of the card as an RDF resource
>        * 'card:nsIAbCard' which represents the interface
>        * of a card component
>        *
>        */
>       attribute string name;
> };
> 
> [scriptable, uuid(3A6E0C0C-1DD2-11B2-B23D-EA3A8CCB333C)]
> interface nsIAbDirectoryQueryPropertyValue : nsIAbDirectoryQueryProperty
> {
>       /**
>        * The value of the property
>        *
>        */
>       readonly attribute wstring value;
>       
>       /**
>        * The value of the property
>        * as an interface
>        *
>        * Only valid if the corresponding
>        * property name is related to an
>        * interface instead of a wstring
>        *
>        */
>       readonly attribute nsISupports valueISupports;
> };
> 
> [scriptable, uuid(418EEDA8-1DD2-11B2-8FB5-905EF30BC9F6)]
> interface nsIAbDirectoryQueryMatchItem : nsIAbDirectoryQueryProperty
> {
>       /**
>        * List of defined match types
>        *
>        */
>       const long matchExists          = 0;
>       const long matchDoesNotExist    = 1;
>       const long matchContains        = 2;
>       const long matchDoesNotContain  = 3;
>       const long matchIs              = 4;
>       const long matchIsNot           = 5;
>       const long matchBeginsWith      = 6;
>       const long matchEndsWith        = 7;
>       const long matchSoundsLike      = 8;
>       const long matchRegExp          = 9;
> 
>       /**
>        * The type of match, like 4.x search parameters
>        *              contains, does not contain
>        *              is, is not
>        *              begins with, ends with
>        *              sounds like (?)
>        *
>        */
>       attribute long matchType;
> 
>       /**
>        * The match value
>        *
>        * Will be ignored for matchType values of
>        * values 'matchExists' and 'matchDoesNotExist'
>        *
>        */
>       attribute wstring matchValue;
> };
> 
> [scriptable, uuid(41EC291E-1DD2-11B2-B583-C44757081F64)]
> interface nsIAbDirectoryQueryArguments : nsISupports
> {
>       /**
>        * The list of match items which will
>        * be matched against instances of
>        * cards
>        *
>        * nsISupportsArray<nsIAbDirectoryQueryMatchItem>
>        *
>        */
>       attribute nsISupportsArray matchItems;
> 
>       /**
>        * matchItems attribute defined explictly as
>        * an array of nsIAbDirectoryQueryMatchItems
>        *
>        */
>       void asetMatchItems (in unsigned long aMatchItemsSize,
>               [array, size_is(aMatchItemsSize)]
>               in nsIAbDirectoryQueryMatchItem aMatchItemsArray);
>       void agetMatchItems (out unsigned long aMatchItemsSize,
>               [retval, array, size_is(aMatchItemsSize)]
>               out nsIAbDirectoryQueryMatchItem aMatchItemsArray);
> 
>       /**
>        * List of defined match items types
>        *
>        */
>       const long matchItemsOneOrMore  = 0;
>       const long matchItemsAll        = 1;
> 
>       /**
>        * Defines how multiple match items should
>        * be treated for a query result
>        *              Match one or more (or)
>        *              Match all (and)
>        *
>        */
>       attribute long matchItemsType;
> 
>       /**
>        * Defines if sub directories should be
>        * queried 
>        *
>        */
>       attribute boolean querySubDirectories;
> 
>       /**
>        * The list of properties which should
>        * be returned if a match occurs on a card
>        *
>        * nsISupportsArray<nsIAbDirectoryQueryProperty>
>        *
>        */
>       attribute nsISupportsArray returnProperties;
> 
>       /**
>        * returnProperties attribute defined explicity
>        * as an array of strings
>        *
>        */
>       void asetReturnProperties (in unsigned long aReturnPropertiesSize,
>               [array, size_is(aReturnPropertiesSize)]
>               in string aReturnPropertiesArray);
>       void agetReturnProperties (out unsigned long aReturnPropertiesSize,
>               [retval, array, size_is(aReturnPropertiesSize)]
>               out string aReturnPropertiesArray);
> };
> 
> [scriptable, uuid(42E600BA-1DD2-11B2-BC39-C363AC0C93E3)]
> interface nsIAbDirectoryQueryResult : nsISupports
> {
>       /**
>        * The context ID of the query
>        *
>        */
>       readonly attribute long contextID;
> 
>       /**
>        * The context of the query which
>        * corresponds to the arguments that
>        * define the query
>        *
>        */
>       readonly attribute nsIAbDirectoryQueryArguments contextArgs;
> 
>       /**
>        * List of defined query results
>        *
>        */
>       const long queryResultMatch      = 0;
>       const long queryResultComplete   = 1;
>       const long queryResultStopped    = 2;
>       const long queryResultError      = 3;
> 
>       /**
>        * The type of result
>        *
>        * Identifies a query entry, the query has finished
>        * or that an error has occured
>        */
>       readonly attribute long type;
> 
>       /**
>        * The result of a singular match for a card
>        *
>        * Only valid when the attribute type is
>        * of 'query match'
>        *
>        * nsISupportsArray<nsIAbDirectoryQueryPropertyValue>
>        *              Multiple entries corresponding to card
>        *              properties
>        * nsISupportsArray<nsIAbCard>
>        *              Only one entry makese sense
>        * 
>        */
>       readonly attribute nsISupportsArray result;
> 
>       /**
>        * result attribute defined explicitly as an
>        * array of nsISupport interfaces
>        *
>        */
>       void agetResult (out unsigned long aResultSize,
>               [retval, array, size_is(aResultSize)]
>               out nsISupports aResultArray);
> };
> 
> [scriptable, uuid(4290E508-1DD2-11B2-AC3E-9597BBCB25D7)]
> interface nsIAbDirectoryQueryResultListener : nsISupports
> {
>       /**
>        * Called when a match is found. May be
>        * called from a different thread to the
>        * one that initiates the query
>        *
>        * @param result
>        *              A individual result associated returned
>        *              from a query
>        */
>       void onQueryItem (in nsIAbDirectoryQueryResult result);
> };
> 
> [scriptable, uuid(4241C46E-1DD2-11B2-978D-A2FBD0A72AC2)]
> interface nsIAbDirectoryQuery : nsISupports
> {
>       /**
>        * Initiates a query on a directory and 
>        * sub-directories for properties on cards
>        *
>        * @param arguments
>        *              The properties and values to match
>        *              Value could of type nsIAbDirectoryQueryMatchItem
>        *              for matches other than ?contains?
>        * @param listener
>        *              The listener which will obtain individual
>        *              query results
>        * @param resultLimit
>        *              Limits the results returned to a specifed
>        *              maximum value
>        * @return
>        *              Unique number representing the context ID of
>        *              the query
>        *
>        */
>       long doQuery (in nsIAbDirectoryQueryArguments arguments,
>               in nsIAbDirectoryQueryResultListener listener,
>               in long resultLimit);
> 
>       /**
>        * Stops an existing query operation if
>        * operation is asynchronous
>        *
>        * @param contextID
>        *              The unique number returned from
>        *              the doQuery methods
>        *
>        */
>       void stopQuery (in long contextID);
> };
> 


-- 

Reply via email to