home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / wfedde.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.8 KB  |  289 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. #ifndef __DDE_H
  20. //    Avoid include redundancy
  21. //
  22. #define __DDE_H
  23.  
  24. //    Purpose:    Header file for DDE remote control
  25. //    Comments:
  26. //    Revision History:
  27. //        12-27-94    created GAB
  28. //        12-28-94    designed DDE wrapper class with multiple conversations
  29. //                        in mind, all conversations using the same HSZ
  30. //                        strings, and a mechanism to find the coversation
  31. //                        on the fly.
  32. //                    The conversations are correctly multiplexed via the
  33. //                        NetscapeDDECallBack function as it can access
  34. //                        all instances of CDDEWrapper and it has the
  35. //                        conversation identifier to compare with.
  36. //
  37.  
  38. //    Required Includes
  39. //
  40. #ifndef WIN32
  41. #include "ddeml2.h"
  42. #else
  43. #include <ddeml.h>
  44. #endif // WIN32
  45. #include "genchrom.h"
  46.  
  47. //    Constants
  48. //
  49. //    Change this on each revision.  Hiword is major, Loword is minor.
  50. const DWORD dwDDEVersion = 0x00030000UL;
  51.  
  52. //  Careful, 32bit bools will byte you.
  53. typedef short TwoByteBool;
  54.  
  55. //    Structures
  56. //
  57. struct CDDEWrapper    {
  58.     //    Enumeration values which index into our static HSZ array.
  59.     //    Faster than list lookups.
  60.     enum    {
  61.         m_MinHSZ = 0,
  62.         m_ServiceName = 0,
  63.         m_TopicStart = 1,    //    Where topics begin, services end
  64.         m_OpenURL = 1,
  65.         m_ShowFile,
  66.         m_Activate,
  67.         m_ListWindows,
  68.         m_GetWindowInfo,
  69.         m_ParseAnchor,
  70.         m_Exit,
  71.         m_RegisterProtocol,
  72.         m_UnRegisterProtocol,
  73.         m_RegisterViewer,
  74.         m_QueryViewer,
  75.         m_ViewDocFile,
  76.         m_UnRegisterViewer,
  77.         m_RegisterURLEcho,
  78.         m_URLEcho,
  79.         m_UnRegisterURLEcho,
  80.         m_RegisterWindowChange,
  81.         m_WindowChange,
  82.         m_UnRegisterWindowChange,
  83.         m_BeginProgress,
  84.         m_SetProgressRange,
  85.         m_MakingProgress,
  86.         m_EndProgress,
  87.         m_Alert,
  88.         m_Version,
  89.         m_CancelProgress,
  90.         m_QueryURLFile,
  91.         m_ListFrameChildren,
  92.         m_GetFrameParent,
  93.         // Here come the new DDE topics for Netscape 5.0    -- Dave Hyatt (8/13/97)
  94.         m_RegisterStatusBarChange, 
  95.         m_StatusBarChange, 
  96.         m_UnRegisterStatusBarChange, 
  97.         m_NavigateBack,
  98.         m_NavigateForward,
  99.         m_Reload,
  100.         m_Stop,
  101.         m_GetDocumentWidth,
  102.         m_GetDocumentHeight,
  103.         m_UserAgent,
  104.         m_Cache_ClearCache,
  105.         m_Cache_Filename,
  106.         m_Cache_InCache,
  107.         m_Cache_RemoveURL,
  108.         m_Cache_AddURL,
  109.         m_History_ClearHistory,
  110.         m_History_InHistory,
  111.         m_History_RemoveURL,
  112.         m_History_AddURL,
  113.         m_History_NumEntries,
  114.         m_History_GetEntry,
  115.         m_GetWindowID,
  116.         m_SupportsMimeType,
  117.         m_ExecuteJavaScript,
  118.         m_PrintWindow,
  119.         m_PrintURL,
  120.         // End of the new topics -- Dave Hyatt (8/13/97)
  121.         m_MaxHSZ,    //    Where all hsz strings end, and where topics end
  122.         m_Timeout = 30000,    //    Timeout value, in milliseconds, that the we will wait as a client.
  123.         m_AlertError = 0,    //    Possible alert box types
  124.         m_AlertWarning = 1,
  125.         m_AlertQuestion = 2,
  126.         m_AlertStatus = 3,
  127.         m_ButtonOk = 0,        //    Possible buttons to show in alert box
  128.         m_ButtonOkCancel = 1,
  129.         m_ButtonYesNo = 2,
  130.         m_ButtonYesNoCancel = 3,
  131.         m_PushedError = 0,
  132.         m_PushedOk = 1,        //    The button pushed in an alert box.
  133.         m_PushedCancel = 2,
  134.         m_PushedNo = 3,
  135.         m_PushedYes = 4
  136.     };
  137.     
  138.     static DWORD m_dwidInst;    //    Our DDEML instance.  Only 1 ever.
  139.     static BOOL m_bDDEActive;    //    Wether or not DDEML was initialized.
  140.     static HSZ m_hsz[m_MaxHSZ];    //    Array of HSZs to be used by all
  141.     static CMapPtrToPtr m_ConvList;    //    Map of current conversations
  142.     static DWORD m_dwafCmd;    //    array of command and filter flags
  143.     static FARPROC m_pfnCallBack;    //    Call back function after MakeProcIntance
  144.     static UINT m_cfFmts[];    //    array of acceptable clipboard formats
  145.     
  146.     CDDEWrapper(HSZ hszService, HSZ hszTopic, HCONV hConv);
  147.     ~CDDEWrapper();
  148.     
  149.     //    Conversation instance specific members
  150.     HSZ m_hszService;    //    The service this object represents.
  151.     int m_iService;    //    The enumerated service number; useful.
  152.     HSZ m_hszTopic;    //    The topic this object represents.
  153.     int m_iTopic;    //    The enumerated topic number; very useful.
  154.     HCONV m_hConv;    //    The conversation this object represents.
  155.     CString m_csProgressApp;    //    The service that we will update.
  156.  
  157.     //    General members for informational lookup
  158.     static CDDEWrapper *GetConvObj(HCONV hConv);
  159.     static int EnumTopic(HSZ& hsz);
  160.     static void ScanArgs(HSZ& hszArgs, const char *pFormat, ...);
  161.     static void ScanDataArgs(HDDEDATA& hArgs, const char *pFormat, ...);
  162.     static HDDEDATA MakeArgs(const char *pFormat, ...);
  163.     static HSZ MakeItemArgs(const char *pFormat, ...);
  164.     static char *SkipToNextFormat(char *pCurrent);
  165.     static char *ExtractArg(HSZ& hszArgs, int iArgNum);
  166.  
  167.     //  Context sensitive.
  168.     CGenericView *GetView(DWORD dwContextID);
  169.     CFrameGlue *GetFrame(DWORD dwContextID);
  170.     CWinCX *GetContext(DWORD dwContextID);
  171.     
  172.     //    DDE Callback handlers for a conversation
  173.     HDDEDATA PokeHandler(HSZ& hszTopic, HSZ& hszItem, HDDEDATA& hData);
  174.     HDDEDATA RequestHandler(HSZ& hszTopic, HSZ& hszItem);
  175.     
  176.     //    Server Requests (Netscape 1-4)
  177.     HDDEDATA OpenURL(HSZ& hszItem);
  178.     HDDEDATA ShowFile(HSZ& hszItem);
  179.     HDDEDATA Activate(HSZ& hszItem);
  180.     HDDEDATA ListWindows(HSZ& hszItem);
  181.     HDDEDATA GetWindowInfo(HSZ& hszItem);
  182.     HDDEDATA ParseAnchor(HSZ& hszItem);
  183.     HDDEDATA RegisterProtocol(HSZ& hszItem);
  184.     HDDEDATA UnRegisterProtocol(HSZ& hszItem);
  185.     HDDEDATA RegisterViewer(HSZ& hszItem);
  186.     HDDEDATA UnRegisterViewer(HSZ& hszItem);
  187.     HDDEDATA RegisterWindowChange(HSZ& hszItem);
  188.     HDDEDATA UnRegisterWindowChange(HSZ& hszItem);
  189.     HDDEDATA BeginProgress(HSZ& hszItem)    { return(NULL); }
  190.     HDDEDATA MakingProgress(HSZ& hszItem)    { return(NULL); }
  191.     HDDEDATA EndProgress(HSZ& hszItem)    { return(NULL); }
  192.     HDDEDATA Version(HSZ& hszItem);
  193.     HDDEDATA QueryURLFile(HSZ& hszItem);
  194.     HDDEDATA ListFrameChildren(HSZ& hszItem);
  195.     HDDEDATA GetFrameParent(HSZ& hszItem);
  196.         
  197.     // New Server Requests for Netscape 5.0 (Dave Hyatt - 8/13/97)
  198.     HDDEDATA RegisterStatusBarChange(HSZ& hszItem);
  199.     HDDEDATA UnRegisterStatusBarChange(HSZ& hszItem); 
  200.     HDDEDATA Stop(HSZ& hszItem);    
  201.     HDDEDATA Reload(HSZ& hszItem);
  202.     HDDEDATA NavigateForward(HSZ& hszItem);    
  203.     HDDEDATA NavigateBack(HSZ& hszItem);
  204.     HDDEDATA UserAgent(HSZ& hszItem);
  205.     HDDEDATA ClearCache(HSZ& hszItem);
  206.     HDDEDATA CacheFilename(HSZ& hszItem);
  207.     HDDEDATA InCache(HSZ& hszItem);
  208.     HDDEDATA CacheRemoveURL(HSZ& hszItem);
  209.     HDDEDATA CacheAddURL(HSZ& hszItem);
  210.     HDDEDATA HistoryAddURL(HSZ& hszItem);
  211.     HDDEDATA HistoryRemoveURL(HSZ& hszItem);
  212.     HDDEDATA InHistory(HSZ& hszItem);
  213.     HDDEDATA ClearHistory(HSZ& hszItem);
  214.     HDDEDATA HistoryNumEntries(HSZ& hszItem);
  215.     HDDEDATA HistoryGetEntry(HSZ& hszItem);
  216.     HDDEDATA GetWindowID(HSZ& hszItem);
  217.     HDDEDATA SupportsMimeType(HSZ& hszItem);
  218.     HDDEDATA ExecuteJavaScript(HSZ& hszItem);
  219.     HDDEDATA PrintWindow(HSZ& hszItem);
  220.     HDDEDATA PrintURL(HSZ& hszItem);
  221.  
  222.     //    Server Pokes (Netscape 1-4)
  223.     HDDEDATA Exit(HSZ& hszItem, HDDEDATA& hData);
  224.     HDDEDATA SetProgressRange(HSZ& hszItem, HDDEDATA& hData)    { return(NULL); }
  225.     HDDEDATA RegisterURLEcho(HSZ& hszItem, HDDEDATA& hData);
  226.     HDDEDATA UnRegisterURLEcho(HSZ& hszItem, HDDEDATA& hData);
  227.     HDDEDATA WindowChange(HSZ& hszItem, HDDEDATA& hData);
  228.     HDDEDATA CancelProgress(HSZ& hszItem, HDDEDATA& hData);
  229.     
  230.     //    Client connection establisher.
  231.     static CDDEWrapper *ClientConnect(const char *cpService,
  232.         HSZ& hszTopic);
  233.     
  234.     //    Client Progress
  235.     static DWORD BeginProgress(CNcapiUrlData *pNcapi, const char *pService,
  236.         DWORD dwWindowID, const char *pMessage);
  237.     static void SetProgressRange(CNcapiUrlData *pNcapi, const char *pService,
  238.         DWORD dwTransactionID, DWORD dwMaxRange);
  239.     static TwoByteBool MakingProgress(CNcapiUrlData *pNcapi, const char *pService,
  240.         DWORD dwTransactionID, const char *pMessage, DWORD dwCurrent);
  241.     static void EndProgress(CNcapiUrlData *pNcapi, const char *pService,
  242.         DWORD dwTransactionID);
  243.     static DWORD AlertProgress(CNcapiUrlData *pNcapi, const char *pService,
  244.         const char *pMessage);
  245.     static DWORD ConfirmProgress(CNcapiUrlData *pNcapi, const char *pService,
  246.         const char *pMessage);
  247.         
  248.     // Helper func for active window retrieval (Dave Hyatt)
  249.     static DWORD fetchLastActiveWindow();
  250.  
  251.     //    Client Viewer Commands
  252.     static void QueryViewer(CDDEDownloadData *pDData);
  253.     static void ViewDocFile(CDDEDownloadData *pDData);
  254.     static void OpenDocument(CDDEDownloadData *pDData);
  255.     
  256.     //    Client Protocol Commands.
  257.     static TwoByteBool OpenURL(CString csProtocol, CString csServiceName, URL_Struct *pURL, MWContext *pContext, FO_Present_Types iFormatOut);
  258.     
  259.     //    Client Echo commands.
  260.     static void URLEcho(CDDEEchoItem *pItem, CString& csURL, CString& csMimeType, DWORD dwWindowID, CString& csReferrer);
  261.     
  262.     //    Client Window change commands.
  263.     static void WindowChange(CDDEWindowChangeItem *pItem, int iChange, TwoByteBool bExiting = FALSE, DWORD dwX = 0, DWORD dwY = 0,
  264.         DWORD dwCX = 0, DWORD cwCY = 0);
  265.  
  266.     static void StatusBarChange(CDDEStatusBarChangeItem *pItem, LPCSTR lpStatusMsg);//JOKI
  267. };
  268.  
  269. //    Global variables
  270. //
  271.  
  272. //    Macros
  273. //
  274.  
  275. //    Function declarations
  276. //
  277. void DDEStartup();
  278. void DDEShutdown();
  279. HDDEDATA 
  280. CALLBACK 
  281. #ifndef XP_WIN32 
  282. _export 
  283. #endif // no _export in windows 32
  284. NetscapeDDECallBack(UINT type, UINT fmt,
  285.     HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1,
  286.     DWORD dwData2);
  287.  
  288. #endif // __DDE_H
  289.