home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / uapp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  10.1 KB  |  313 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #pragma once
  20. // ===========================================================================
  21. //    UApp.h
  22. // main application module
  23. // ===========================================================================
  24.  
  25. #include <LDocApplication.h>
  26. #include <LPeriodical.h>
  27. #include <LWindow.h>
  28. #include <LCaption.h>
  29. #include "CTaskBarListener.h"
  30. #include "CURLDispatcher.h"
  31. //#include <QAP_Assist.h>
  32.  
  33. #include <list.h>
  34.  
  35. #ifndef _NetscapeTypes_
  36. #include "ntypes.h"
  37. #endif
  38.  
  39. #include "cstring.h"
  40.  
  41. #include "structs.h"
  42.  
  43. class CStr255;
  44. class EarlManager;
  45. class LDialogBox;
  46. class CMimeMapper;
  47. class StDialogHandler;
  48. class CBrowseWin;
  49. class CCheckMailContext;
  50. class CSplashScreen;
  51. class CStr255;
  52. class CMailNewsWindow;
  53. class CBrowserWindow;
  54. class CPersonalToolbarManager;
  55. class CLICommander;
  56.  
  57. /*****************************************************************************
  58.  * CFrontApp
  59.  * the application class. It takes care of managing the documents. Only one 
  60.  * preference document can be open at any time, and no documents can be opened
  61.  * before we read in the preferences.
  62.  * The application uses windows in place of documents. We could have discarded
  63.  * documents completely, but this would affect AppleEvent recording (I think).
  64.  * 
  65.  * Window is created blank, without the home page. After the window is created,
  66.  * window's function DoOpenURL should be called to open its first document.
  67.  *****************************************************************************/
  68.  
  69.  
  70. // ---------------------------------------------------------------------------
  71. //    For the moment CAppleEventHandler requires a small bit of knowledge
  72. //    about uapp.cp.  All shared info goes here til the separation can
  73. //    be completed.
  74.  
  75. #define FILE_TYPE_PREFS        1
  76. #define FILE_TYPE_ODOC        2
  77. #define FILE_TYPE_GETURL    3
  78. #define FILE_TYPE_NONE        4
  79. #define FILE_TYPE_PROFILES    5
  80. #define FILE_TYPE_ASW        6
  81. #define STARTUP_TYPE_NETPROFILE 7
  82.  
  83. char* GetBookmarksPath( FSSpec& spec, Boolean useDefault );
  84.  
  85. // ----- End stuff required by CAppleEvent.cp
  86.  
  87.  
  88. // ---------------------------------------------------------------------------
  89. class CFrontApp : public LDocApplication, public CTaskBarListener
  90. {
  91. public:
  92.     static CFrontApp*    sApplication;        // One and only instance of the application
  93.     // ÑÑ Constructors/destructors
  94.                         CFrontApp();
  95.     virtual                ~CFrontApp();
  96.     virtual void        Initialize();
  97.     // for changing notification 
  98.     virtual void        EventSuspend(const EventRecord &inMacEvent);
  99.     virtual void        EventResume(const EventRecord &inMacEvent);
  100.  
  101.     // Ñ patches in Mercutio
  102.     virtual void        EventKeyDown( const EventRecord& inMacEvent );
  103.     
  104.     // so plug-ins can get key ups (which are ignored by default)
  105.     virtual void        ProcessNextEvent();
  106.     virtual void        EventKeyUp(const EventRecord &inMacEvent);
  107.  
  108.     Boolean                HasProperlyStartedUp() const { return fProperStartup; }
  109.     
  110.     // Delayed startup. Called with launched open/print file (if any).
  111.     void                 ProperStartup( FSSpec* fileSpec, short fileType );
  112.     
  113.     // Startup w/o any documents
  114.     virtual void        StartUp();        // Creates a home page document on startup
  115.             void        CreateStartupEnvironment( Boolean openStartupWindows );    // Opens the proper window
  116.     // ÑÑ documents/windows
  117.     // Startup w/ a document or 
  118.     virtual void        OpenDocument(FSSpec *inFileSpec);
  119.     virtual void        PrintDocument(FSSpec *inFileSpec);
  120.     virtual void        ChooseDocument();
  121.  
  122.     // Opens a hypertext document    
  123.     virtual LModelObject*     MakeNewDocument();
  124.     
  125.     // ÑÑ Global static routines. Could not think of better place to put them
  126.  
  127.     // Registers types with netlib
  128.     static void            RegisterMimeType(CMimeMapper * mapper);
  129.  
  130.     // returns application object.
  131.  
  132.     static CFrontApp*     GetApplication();    
  133.     
  134.     // ÑÑ Cached preference values (requires application restart to notice new values)
  135.     
  136.     Boolean                HasBookmarksMenu() { return mHasBookmarksMenu; }
  137.     Boolean                HasFrontierMenuSharing() { return mHasFrontierMenuSharing; }
  138.     
  139.     // ÑÑ╩Menubar management
  140.  
  141.     static const list<CommandT>&
  142.                         GetCommandsToUpdateBeforeSelectingMenu() {
  143.                             return sCommandsToUpdateBeforeSelectingMenu;
  144.                         }
  145.  
  146.     virtual void        ClickMenuBar(const EventRecord& inMacEvent);
  147.  
  148.     virtual void        SetMenubar( ResIDT mbar, Boolean inUpdateNow = false );    // If appleMenu is 0, do not rebuild it
  149.     virtual void        UpdateMenus();
  150.     void                UpdateHierarchicalMenus();
  151.     
  152.     static void            InstallMenus();
  153.     static int            BuildConfigurableMenu(MenuHandle, const char* xp_name, short stringsID = 0);
  154.     Boolean                HandleSyntheticCommand( CommandT inCommand );
  155.     static void            DoHelpMenuItem( short itemNum );
  156.  
  157.     // ÑÑ Command handling
  158.     static void         DoGetURL (const cstring& url); // DoGetURL loads the given url into the frontmost window, or new one if there is no frontmost
  159.     static void            DoOpenDirectoryURL( CommandT menuCommand );
  160.     static void            DoOpenLogoURL( CommandT menuCommand );
  161.     void                OpenLocalURL( FSSpec* inFileSpec, 
  162.                                     CBrowserWindow * win = NULL,
  163.                                     char * mime_type = NULL,
  164.                                     Boolean delayed = FALSE);    // use delayed argument if you are using drag'n'drop to avoid errors due to dialogs popping us
  165.     void                OpenBookmarksFile( FSSpec* inFileSpec, CBrowserWindow * win, Boolean delayed);
  166.     void                DoOpenDoc( FSSpec* initDoc, short fileType );
  167.  
  168.     // ÑÑ Taskbar support
  169.     virtual void        ListenToMessage (MessageT inMessage, void *ioParam);
  170.     
  171.     virtual void        ShowAboutBox();
  172.  
  173.     //=== begin: add for TSMSupport
  174.  
  175.     virtual void        DoQuit(Int32 inSaveOption = kAEAsk);    
  176.     virtual void        DispatchEvent(const EventRecord &inMacEvent);
  177.  
  178.     // splash screen
  179.     static  void        SplashProgress(CStr255 inMessage);
  180.  
  181.     // ÑÑ╩Command and menus setup
  182.     virtual Boolean        ObeyCommand(CommandT inCommand, void *ioParam = nil);
  183.     virtual void        FindCommandStatus(CommandT inCommand,
  184.                                             Boolean &outEnabled, Boolean &outUsesMark,
  185.                                             Char16 &outMark, Str255 outName);
  186.     virtual void         ProcessCommandStatus(CommandT    inCommand,
  187.                                             Boolean &outEnabled, Boolean &outUsesMark,
  188.                                             Char16        &outMark, Str255        outName);
  189. //#ifdef QAP_BUILD
  190. //    virtual void        PutOnDuty();
  191. //    virtual void        TakeOffDuty();
  192. //#endif //QAP_BUILD
  193.     
  194.     // ÑÑ AE handling
  195.     virtual void         HandleAppleEvent(const AppleEvent    &inAppleEvent,
  196.                                     AppleEvent            &outAEReply,
  197.                                     AEDesc                &outResult,
  198.                                     long                inAENumber);
  199.     virtual void        GetAEProperty(DescType inProperty,
  200.                                     const AEDesc    &inRequestedType,
  201.                                     AEDesc            &outPropertyDesc) const;
  202.     virtual void        SetAEProperty(DescType inProperty,
  203.                             const AEDesc    &inRequestedType,
  204.                             AEDesc            &outPropertyDesc);
  205.  
  206.     virtual void        SetupPage();
  207.  
  208.     // spy Apple Event suite
  209.  
  210.     static CMailNewsWindow*    GetMailNewsWindow();
  211.  
  212.     // EA - Netcaster support
  213.     void                LaunchNetcaster(void);
  214.     MWContext*            GetNetcasterContext(void);    
  215.     void                SetNetcasterContext(MWContext *);
  216.     
  217.     // 97-05-12 pkc -- dpi support for MWContext
  218.     static double        sHRes;
  219.     static double        sVRes;
  220.     
  221.     // Personal Toolbar support
  222.     static CPersonalToolbarManager* GetPersonalToolbarManager()
  223.                 { return sPersonalToolbarManager; } ;
  224.  
  225.     static CAutoPtr<CNSContext>    sRDFContext;
  226.  
  227. // DW FIX i made these non-static, and protected instead of public
  228. protected:
  229.     void                InitBookmarks();
  230. #ifdef MOZ_LOC_INDEP
  231.     void                InitializeLocationIndependence();
  232. #endif    
  233.     virtual void        UpdateMenusSelf();
  234.  
  235.  
  236.     virtual void        AdjustCursor    (const EventRecord &inMacEvent);
  237.     //=== end: add for TSMSupport
  238.  
  239.     void                ShowSplashScreen(void);
  240.     void                DestroySplashScreen(void);
  241.  
  242.     CSplashScreen*        mSplashScreen;
  243.  
  244.     Boolean                AgreedToLicense( FSSpec* callbackWith, short fileType );
  245.     
  246.     void                MemoryIsLow();
  247.     
  248.     void                DoWindowsMenu(CommandT inCommand);    // Execute windows menu command
  249.  
  250.  
  251.     void                DoOpenURLDialog(void);
  252. #ifdef EDITOR
  253.     void                DoOpenURLDialogInEditor(void);
  254. #endif
  255.  
  256.     void                InsertItemIntoWindowsMenu(CStr255& title, 
  257.                             int currItem, LWindow * win, short iconID=0); // Utility function to add an item into windows menu
  258.  
  259.     void                LaunchExternalApp(OSType inAppSig, ResIDT inAppNameStringResourceID);
  260.     Boolean                Find3270Applet(FSSpec& tn3270File);
  261.     void                Launch3270Applet();
  262.  
  263.     Boolean                LaunchAccountSetup();
  264.     
  265.  
  266.     ResIDT                fCurrentMbar;    // Currently active menu bar
  267.     ResIDT                fWantedMbar;
  268.     
  269.     LArray                fWindowsMenu;    // LWindow * of windows in the window menu.
  270.     static short        sHelpMenuOrigLength;
  271.     static short        sHelpMenuItemCount;
  272.  
  273.     Boolean                fStartupAborted;
  274.     Boolean                fSafeToQuit;
  275.     Boolean                fUserWantsToQuit;
  276.     Boolean                fProperStartup;
  277.     
  278.     LPeriodical*        mLibMsgPeriodical;
  279.     
  280.     Boolean                mConferenceApplicationExists;
  281.     Boolean                mJavaEnabled;
  282.     
  283.     Boolean                mHasBookmarksMenu;
  284.     Boolean                mHasFrontierMenuSharing;
  285.     
  286.     // the object in charge of making sure that the personal toolbars in all the browser
  287.     // windows stays in sync.
  288.     static CPersonalToolbarManager* sPersonalToolbarManager;
  289.     
  290.     static list<CommandT>    sCommandsToUpdateBeforeSelectingMenu;
  291.     
  292. public:
  293.     static    int            SetBooleanWithPref(const char *prefName, void *boolPtr);
  294.                             // boolPtr is really a (boolean *)
  295.  
  296. protected:
  297.     FSSpec                CreateAccountSetupSpec();
  298.     
  299.     MWContext*            mNetcasterContext;    // EA - Track the Netcaster window
  300.     RgnHandle                mMouseRgnH;
  301. };
  302.  
  303. #ifdef PROFILE
  304. void        StartProfiling();
  305. void        StopProfiling();
  306. #endif
  307.  
  308. #ifdef MOZ_MAIL_NEWS
  309. // TRUE if url *must* be loaded in this context type
  310. Boolean URLRequiresContextType( const URL_Struct* url , MWContextType &type);
  311. #endif
  312.  
  313.