>>      Attached is some idl, does this 'express' a boolean
>>      expression model for the GUI use cases you and
>>      Matthew have 'expressed'?
>
>Nice work!
>

        Thanks.
        
        
        Attached is the latest query stuff with boolean
        stuff combined. The existing directory query
        not inherits from the nsIBooleanExpression interface
        and the nsIAbDirectoryQueryArguments has a
        nsIBooleanExpression attribute.
        
        Also attached are the factory interfaces we propose
        to use. The nsIAbDirectoryFactoryService works a bit
        like the RDF service and is used to obtain directory
        factories from a uri.
        
        The directory factory service can instantiate an
        enumeration of nsIAbDirectory RDF resource components
        from a set of properties, which could be obtained from
        the preferences. We will reuse the property names in
        the preferences.
        
        The reason why we return an enumeration is that our
        current MAPI address book implementation returns all
        top level address bookoutlook folders. Also its not easy
        to generate space and time unique URIs for MAPI content!
        (This is why we think Windows does not allow a user to
        drag an outlook folder or object to the dekstop as a
        shortcut, well perhaps one of the reasons)
        
        We now have read only MAPI (with mailing lists) and
        personal LDAP working with together local address books.
        
        Our plan is then to implement synchronous query for
        MAPI.
        
        I have been thinking about implementing asynchronous
        query for LDAP (personal and organsizational), just
        got to read up on LDAP filters so i can correctly
        generate from the simple boolean expression.    
        
Paul.

| ? + ? = To question
----------------\
   Paul Sandoz
        x19219
+353-1-8199219
 

#include "nsISupports.idl"
#include "nsISupportsArray.idl"

/**
 * Boolean expression type
 * Marker interface
 *
 */
[scriptable, uuid(F51387B1-5AEF-4A1C-830E-7CD3B02366CE)]
interface nsIBooleanExpression : nsISupports
{
};

/**
 * Boolean condition type
 * Marker interface
 *
 * Represents a leaf node in a boolean expression
 * tree
 */
[scriptable, uuid(212069C0-37C2-4550-82DD-8C5E8B89A154)]
interface nsIBooleanCondition : nsIBooleanExpression
{
};

[scriptable, uuid(C3869D72-CFD0-45F0-A0EC-3F67D83C7110)]
interface nsIBooleanConditionString : nsIBooleanCondition
{
        const long conditionExists              = 0;
        const long conditionDoesNotExist        = 1;
        const long conditionContains            = 2;
        const long conditionDoesNotContain      = 3;
        const long conditionIs                  = 4;
        const long conditionIsNot               = 5;
        const long conditionBeginsWith          = 6;
        const long conditionEndsWith            = 7;
        const long conditionSoundsLike          = 8;
        const long conditionRegExp              = 9;

};

/**
 * Boolean expression operation type
 *
 */
[scriptable, uuid(29CF8008-261E-4312-834C-8B41138AA107)]
interface nsIBooleanExpressionOperation : nsIBooleanExpression
{
        const long operationAND         = 0;
        const long operationOR          = 1;
        const long operationNOT         = 2;
        const long operationNAND        = 3;
        const long operationNOR         = 4;
        const long operationXOR         = 5;

        attribute long operator;
};

/**
 * N Boolean expression type
 *
 * Supports Unary Binary and N boolean expressions
 * Represents a non-leaf node in the expression
 * tree
 *
 */
[scriptable, uuid(67F87C44-2C63-41A2-9545-AFF1D9F09623)]
interface nsIBooleanExpressionNPeer : nsIBooleanExpressionOperation
{
        attribute nsISupportsArray peerExpressions;
};



[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;
};

%{C++
extern NS_COM nsresult
NS_NewIAbDirectoryQueryProperty(nsIAbDirectoryQueryProperty** aInstancePtrResult);
%}

[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;
};

%{C++
extern NS_COM nsresult
NS_NewIAbDirectoryQueryMatchItem(nsIAbDirectoryQueryMatchItem** aInstancePtrResult);
%}

interface nsIAbDirectoryQuerySimpleBooleanExpression : nsIBooleanExpression
{
        /**
         * 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;
};

%{C++
extern NS_COM nsresult
NS_NewIAbDirectoryQuerySimpleBooleanExpression(nsIAbDirectoryQuerySimpleBooleanExpression**
 aInstancePtrResult);
%}


[scriptable, uuid(41EC291E-1DD2-11B2-B583-C44757081F64)]
interface nsIAbDirectoryQueryArguments : nsISupports
{
        /**
         * Defines the boolean expression for
         * the matching of cards
         *
         */
        attribute nsIBooleanExpression expression;

        /**
         * 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);
};

%{C++
extern NS_COM nsresult
NS_NewIAbDirectoryQueryArguments(nsIAbDirectoryQueryArguments** aInstancePtrResult);
%}

[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);
};


#include "nsISupports.idl"

interface nsIAbDirectoryFactory;

[scriptable, uuid(BE2075A8-1DD1-11B2-99BA-BCB9DB1D77CC)]
interface nsIAbDirectoryFactoryService : nsISupports
{
        /**
         * Obtain a directory factory component
         * given a uri representing an address book
         *
         * The scheme is extracted from the uri and
         * contract id is generated of the form:
         * @mozilla.org/addressbook/directory-factory;1?type=<scheme>
         * 
         * This id is used to instantiate a registered
         * component which implemented the nsIAbDirectoryFactory
         * interface
         *
         * @param uri
         *              The uri which contains the scheme that
         *              defines what directory factory instance
         *              is returned
         */
        nsIAbDirectoryFactory getDirectoryFactory (in string uri);
};

#include "nsISupports.idl"
#include "nsIEnumerator.idl"

interface nsIAbDirectory;

[scriptable, uuid(C2308606-1DD1-11B2-87D4-85FCA9B1DC08)]
interface nsIAbDirectoryFactory : nsISupports
{
        /**
         * Instantiate new top level address book
         * directories given an array of property names
         * and values. More than one directory may be
         * returned depending on the implementation
         * and integration with the associated address book
         * sources
         *
         * @param propertiesSize
         *              The number of properties
         * @param propertyNamesArray
         *              The array of property names
         * @param propertyValuesArray
         *              The array of property values
         * @return
         *              Enumeration of nsIAbDirectory
         *              interfaces
         */
        nsISimpleEnumerator createDirectory (
                in unsigned long propertiesSize,
                [array, size_is(propertiesSize)]
                in string propertyNamesArray,
                [array, size_is(propertiesSize)]
                in wstring propertyValuesArray);

        /**
         * Delete a top level address book directory
         * 
         */
        void deleteDirectory (in nsIAbDirectory directory);
};

Reply via email to