Back to index

lightning-sunbird  0.9+nobinonly
nsAEGenericClass.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Simon Fraser <sfraser@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 
00040 #ifndef __AEGENERICCLASS__
00041 #define __AEGENERICCLASS__
00042 
00043 
00044 #include "nsAEClassIterator.h"
00045 
00046 // pure virtual base class that provides stubs for much objecct functionality.
00047 
00048 class AEGenericClass
00049 {
00050        friend class AEDispatchHandler;
00051 public:
00052        
00053                                           AEGenericClass(DescType classType, DescType containerClass);                 // throws OSErrs
00054        virtual                            ~AEGenericClass();
00055 
00056 
00057        // ----------------------------------------------------------------------------
00058        //     Dispatch routine
00059        // ----------------------------------------------------------------------------
00060        void                               DispatchEvent(                                   AEDesc*                     token, 
00061                                                                                            const AppleEvent*    appleEvent,
00062                                                                                            AppleEvent*          reply);       // throws OSErrs
00063 
00064        // ----------------------------------------------------------------------------
00065        //     Item from container accessor
00066        // ----------------------------------------------------------------------------
00067        static pascal OSErr         ItemFromContainerAccessor(         DescType                    desiredClass,
00068                                                                                            const AEDesc*        containerToken,
00069                                                                                            DescType                    containerClass, 
00070                                                                                            DescType                    keyForm,
00071                                                                                            const AEDesc*        keyData,
00072                                                                                            AEDesc*                     resultToken,
00073                                                                                            long                        refCon);
00074 
00075 protected:    
00076        
00077        // MT-NW suite events
00078        enum {
00079               kAEExtract                  = 'Extr',
00080               kExtractKeyDestFolder       = 'Fold',
00081               
00082               kAESendMessage              = 'Post'
00083        };
00084        
00085        
00086        virtual void                GetPropertyFromObject(                    DescType                    desiredClass,
00087                                                                                            const AEDesc*        containerToken,
00088                                                                                            DescType                    containerClass,
00089                                                                                            DescType                    keyForm,
00090                                                                                            const AEDesc*        keyData,
00091                                                                                            AEDesc*                     resultToken);
00092 
00093        virtual void                GetProperty(                              DescType                    desiredClass,
00094                                                                                            const AEDesc*        containerToken,
00095                                                                                            DescType                    containerClass,
00096                                                                                            DescType                    keyForm,
00097                                                                                            const AEDesc*        keyData,
00098                                                                                            AEDesc*                     resultToken);
00099        
00100        // ----------------------------------------------------------------------------
00101        //     GetItemFromContainer
00102        //            
00103        //     Overridable method to get an item from its container.
00104        //            
00105        // ----------------------------------------------------------------------------
00106        virtual void                GetItemFromContainer(                     DescType                    desiredClass,
00107                                                                                            const AEDesc*        containerToken,
00108                                                                                            DescType                    containerClass, 
00109                                                                                            DescType                    keyForm,
00110                                                                                            const AEDesc*        keyData,
00111                                                                                            AEDesc*                     resultToken) = 0;
00112                                                                       
00113        // ----------------------------------------------------------------------------
00114        //     OSL Callbacks (compare and count)
00115        // ----------------------------------------------------------------------------
00116        virtual void                CompareObjects(                           DescType                    comparisonOperator,
00117                                                                                            const AEDesc *              object,
00118                                                                                            const AEDesc *              descriptorOrObject,
00119                                                                                            Boolean *                   result);
00120 
00121        virtual void                CountObjects(                             DescType                    desiredType,
00122                                                                                            DescType                    containerClass,
00123                                                                                            const AEDesc *              container,
00124                                                                                            long *               result);
00125 
00126        // ----------------------------------------------------------------------------
00127        //     Core Suite Object Event handlers
00128        // ----------------------------------------------------------------------------
00129        virtual void                HandleClose(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00130        virtual void                HandleCount(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00131        virtual void                HandleSetData(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00132        virtual void                HandleGetData(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00133        virtual void                HandleDataSize(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00134        virtual void                HandleDelete(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00135        virtual void                HandleDuplicate(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00136        virtual void                HandleExists(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00137        virtual void                HandleMake(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00138        virtual void                HandleMove(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00139        virtual void                HandleOpen(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00140        virtual void                HandleReOpen(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00141        virtual void                HandleRun(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00142        virtual void                HandlePrint(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00143        virtual void                HandleQuit(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00144        virtual void                HandleSave(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00145 
00146        // ----------------------------------------------------------------------------
00147        //     MT-NW suite event handlers
00148        // ----------------------------------------------------------------------------
00149        virtual void                HandleExtract(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00150        virtual void                HandleSendMessage(AEDesc *token, const AppleEvent *appleEvent, AppleEvent *reply);
00151        
00152        // ----------------------------------------------------------------------------
00153        //     Get and Set methods for objects and list. Note that the object methods are pure virtual
00154        // ----------------------------------------------------------------------------
00155        
00156        virtual void                GetDataFromObject(const AEDesc *token, AEDesc *desiredTypes, AEDesc *data) = 0;
00157        virtual void                SetDataForObject(const AEDesc *token, AEDesc *data) = 0;
00158 
00159        // ----------------------------------------------------------------------------
00160        //     Methods for creating self and container specifiers
00161        // ----------------------------------------------------------------------------
00162 
00163        void                               CreateSpecifier(const AEDesc *token, AEDesc *outSpecifier);
00164        virtual void                GetContainerSpecifier(const AEDesc *token, AEDesc *outContainerSpecifier);
00165 
00166        virtual void                CreateSelfSpecifier(const AEDesc *token, AEDesc *outSpecifier) = 0;
00167 
00168        void                               GetDataFromListOrObject(const AEDesc *tokenOrTokenList, AEDesc *desiredTypes, AEDesc *data);
00169        void                               SetDataForListOrObject(const AEDesc *tokenOrTokenList, const AppleEvent *appleEvent, AppleEvent *reply);
00170 
00171        void                               GetDataFromList(const AEDesc *srcList, AEDesc *desiredTypes, AEDesc *dstList);
00172        void                               SetDataForList(const AEDesc *token, AEDesc *data);
00173 
00174        void                               GetPropertyFromListOrObject(              DescType                    desiredClass,
00175                                                                                            const AEDesc*        containerToken,
00176                                                                                            DescType                    containerClass,
00177                                                                                            DescType                    keyForm,
00178                                                                                            const AEDesc*        keyData,
00179                                                                                            AEDesc*                     resultToken);
00180        
00181        void                               GetPropertyFromList(               DescType                    desiredClass,
00182                                                                                            const AEDesc*        containerToken,
00183                                                                                            DescType                    containerClass,
00184                                                                                            DescType                    keyForm,
00185                                                                                            const AEDesc*        keyData,
00186                                                                                            AEDesc*                     resultToken);
00187 
00188        virtual DescType            GetKeyEventDataAs(DescType propertyCode);
00189        
00190        virtual Boolean                    CanSetProperty(DescType propertyCode) = 0;
00191        virtual Boolean                    CanGetProperty(DescType propertyCode) = 0;
00192 
00193        DescType                           GetClass()                         { return mClass; }
00194 
00195 
00196        // ----------------------------------------------------------------------------
00197        //     Methods called from the main handlers
00198        // ----------------------------------------------------------------------------
00199 
00200        virtual void                MakeNewObject(                            const DescType              insertionPosition,
00201                                                                                            const AEDesc*        token,
00202                                                                                            const AEDesc*        ptrToWithData, 
00203                                                                                            const AEDesc*        ptrToWithProperties,
00204                                                                                            AppleEvent*          reply);
00205 
00206 
00207 protected:
00208 
00209        DescType                           mClass;
00210        DescType                           mContainerClass;
00211        
00212        OSLAccessorUPP              mItemFromContainerAccessor;
00213 
00214 };
00215 
00216 
00217 #endif /* __AEGENERICCLASS__ */
00218