Back to index

lightning-sunbird  0.9+nobinonly
nsAECoreClass.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 
00041 #ifndef __AECORECLASS__
00042 #define __AECORECLASS__
00043 
00044 #ifdef __cplusplus
00045 
00046 
00047 #include <AEDataModel.h>
00048 #include <AppleEvents.h>
00049 #include <AEObjects.h>
00050 
00051 #include "nsAEClassDispatcher.h"
00052 
00053 #include "nsAEMozillaSuiteHandler.h"
00054 #include "nsAEGetURLSuiteHandler.h"
00055 #include "nsAESpyglassSuiteHandler.h"
00056 
00057 class AEApplicationClass;
00058 class AEDocumentClass;
00059 class AEWindowClass;
00060 
00061 class AECoreClass
00062 {
00063 public:
00064        
00065                                           AECoreClass(Boolean suspendEvents = false);      // throws OSErrs
00066                                           ~AECoreClass();
00067 
00068        void                               HandleCoreSuiteEvent(const AppleEvent *appleEvent, AppleEvent *reply);                     // throws OSErrs
00069        void                               HandleRequiredSuiteEvent(const AppleEvent *appleEvent, AppleEvent *reply);          // throws OSErrs
00070 
00071        void                               HandleMozillaSuiteEvent(const AppleEvent *appleEvent, AppleEvent *reply);           // throws OSErrs
00072        void                               HandleGetURLSuiteEvent(const AppleEvent *appleEvent, AppleEvent *reply);            // throws OSErrs
00073        void                               HandleSpyglassSuiteEvent(const AppleEvent *appleEvent, AppleEvent *reply);          // throws OSErrs
00074 
00075        void                               HandleCreateElementEvent(const AppleEvent *appleEvent, AppleEvent *reply);          // throws OSErrs
00076        
00077        void                               HandleEventSuspend(const AppleEvent *appleEvent, AppleEvent *reply);
00078        void                               ResumeEventHandling(const AppleEvent *appleEvent, AppleEvent *reply, Boolean dispatchEvent);
00079        
00080        // AE Handlers
00081        static pascal OSErr         SuspendEventHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00082        static pascal OSErr         RequiredSuiteHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00083        static pascal OSErr         CoreSuiteHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00084        static pascal OSErr         CreateElementHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00085 
00086        // Handler for Mozilla Suite events
00087        static pascal OSErr         MozillaSuiteHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00088 
00089        // Handler for GetURL events
00090        static pascal OSErr         GetURLSuiteHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00091 
00092        // Handler for GetURL events
00093        static pascal OSErr         SpyglassSuiteHandler(const AppleEvent *appleEvent, AppleEvent *reply, SInt32 refCon);
00094 
00095 
00096        AEDispatchHandler*          GetDispatchHandler(DescType dispatchClass);
00097        
00098        
00099        void                               GetSuspendedEvent(AppleEvent *appleEvent, AppleEvent *reply)
00100                                           {
00101                                                  *appleEvent = mSuspendedEvent;
00102                                                  *reply = mReplyToSuspendedEvent;
00103                                           }
00104                                           
00105 protected:
00106 
00107        // Property token from list of tokens accessor
00108        void                               PropertyTokenFromList(                    DescType                    desiredClass,
00109                                                                                            const AEDesc*        containerToken,
00110                                                                                            DescType                    containerClass,
00111                                                                                            DescType                    keyForm,
00112                                                                                            const AEDesc*        keyData,
00113                                                                                            AEDesc*                     resultToken);
00114        
00115        void                               GetAnythingFromApp(                DescType                    desiredClass,
00116                                                                                            const AEDesc*        containerToken,
00117                                                                                            DescType                    containerClass,
00118                                                                                            DescType                    keyForm,
00119                                                                                            const AEDesc*        keyData,
00120                                                                                            AEDesc*                     resultToken);
00121        
00122        void                               RegisterClassHandler(                     DescType                    handlerClass,
00123                                                                                            AEGenericClass*      classHandler,
00124                                                                                            Boolean                     isDuplicate = false);
00125 
00126 
00127        void                               InstallSuiteHandlers(                            Boolean                     suspendEvents);
00128        
00129 public:
00130 
00131        void                               GetEventKeyDataParameter(          const AppleEvent*    appleEvent,
00132                                                                                            DescType                    requestedType,
00133                                                                                            AEDesc*                     data);
00134 
00135        static pascal OSErr         PropertyTokenFromAnything(         DescType                    desiredClass,
00136                                                                                            const AEDesc*        containerToken,
00137                                                                                            DescType                    containerClass,
00138                                                                                            DescType                    keyForm,
00139                                                                                            const AEDesc*        keyData,
00140                                                                                            AEDesc*                     resultToken,
00141                                                                                            long                        refCon);
00142 
00143        static pascal OSErr         AnythingFromAppAccessor(           DescType                    desiredClass,
00144                                                                                            const AEDesc*        containerToken,
00145                                                                                            DescType                    containerClass,
00146                                                                                            DescType                    keyForm,
00147                                                                                            const AEDesc*        keyData,
00148                                                                                            AEDesc*                     resultToken,
00149                                                                                            long                        refCon);
00150 
00151        static pascal OSErr         CompareObjectsCallback(                   DescType                    comparisonOperator,  // operator to use
00152                                                                                            const AEDesc *              object,                            // left-hand side
00153                                                                                            const AEDesc *              descriptorOrObject,         // right-hand side
00154                                                                                            Boolean *                   result);
00155 
00156 
00157        static pascal OSErr         CountObjectsCallback(                     DescType                    desiredType,
00158                                                                                            DescType                    containerClass,
00159                                                                                            const AEDesc *              container,
00160                                                                                            long *               result);
00161 
00162        void                               ExtractData(                              const AEDesc*        source,
00163                                                                                            AEDesc*                     data);
00164        
00165        
00166        static AEDispatchHandler*   GetDispatchHandlerForClass( DescType                    dispatchClass);
00167        
00168 protected:
00169        
00170        AEDispatchTree                     mDispatchTree;                            // tree of handler dispatchers
00171 
00172        AEEventHandlerUPP           mSuspendEventHandlerUPP;
00173        
00174        AEEventHandlerUPP           mStandardSuiteHandlerUPP;
00175        AEEventHandlerUPP           mRequiredSuiteHandlerUPP;
00176        AEEventHandlerUPP           mCreateElementHandlerUPP;
00177 
00178        AEEventHandlerUPP           mMozillaSuiteHandlerUPP;
00179        AEEventHandlerUPP           mGetURLSuiteHandlerUPP;
00180        AEEventHandlerUPP           mSpyGlassSuiteHandlerUPP;
00181 
00182         AEMozillaSuiteHandler      mMozillaSuiteHandler;
00183         AEGetURLSuiteHandler      mGetURLSuiteHandler;
00184         AESpyglassSuiteHandler   mSpyglassSuiteHandler;
00185         
00186        OSLAccessorUPP              mPropertyFromListAccessor;
00187        OSLAccessorUPP              mAnythingFromAppAccessor;
00188 
00189        OSLCountUPP                 mCountItemsCallback;
00190        OSLCompareUPP        mCompareItemsCallback;
00191 
00192 private:
00193 
00194        AppleEvent                  mSuspendedEvent;
00195        AppleEvent                  mReplyToSuspendedEvent;
00196        
00197 public:
00198 
00199        static AECoreClass*         GetAECoreHandler() { return sAECoreHandler; }
00200        static AECoreClass*         sAECoreHandler;
00201 
00202 };
00203 
00204 #endif //__cplusplus
00205 
00206 #endif /* __AECORECLASS__ */
00207