home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / genfram2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  10.1 KB  |  393 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. #include "stdafx.h"
  20. #include "ssl.h"
  21. #include "secnav.h"
  22. #include "wfemsg.h"
  23. #include "printpag.h"
  24. #include "prefapi.h"
  25. #include "navfram.h"
  26. #include "confhook.h"
  27. #include "msgcom.h"
  28. #include "prefinfo.h"
  29. #include "prefs.h"
  30. #ifdef EDITOR
  31. #include "edt.h"
  32. #endif // EDITOR
  33. #include "nethelp.h"
  34. #include "navfram.h"
  35. #include "prefapi.h"
  36.  
  37. void CGenericFrame::OnSecurity()
  38. {
  39.   MWContext * pContext = GetMainContext()->GetContext();  
  40.   
  41.   if (pContext != NULL)
  42.   {
  43.       CAbstractCX * pCX = ABSTRACTCX(pContext);   
  44.  
  45.       if (pCX != NULL)
  46.       {      
  47.         URL_Struct * pURL = pCX->CreateUrlFromHist(TRUE); 
  48.   
  49.         SECNAV_SecurityAdvisor(pContext, pURL);
  50.       }  
  51.   }  
  52.  
  53. }
  54.  
  55. void CGenericFrame::OnUpdateSecurity(CCmdUI *pCmdUI)
  56. {
  57.     int status = XP_GetSecurityStatus(GetMainContext()->GetContext());    
  58.  
  59.     pCmdUI->Enable(status == SSL_SECURITY_STATUS_ON_LOW || status == SSL_SECURITY_STATUS_ON_HIGH);
  60. }
  61.  
  62. void CGenericFrame::OnEnterIdle(UINT nWhy, CWnd* pWho )
  63. {
  64.     CFrameWnd::OnEnterIdle(nWhy, pWho);
  65. }
  66.  
  67. CFrameWnd *CGenericFrame::GetFrameWnd()    
  68. {
  69.     return((CFrameWnd *)this);
  70. }
  71.  
  72. void CGenericFrame::UpdateHistoryDialog()    {
  73. }
  74.  
  75. BOOL CGenericFrame::PreTranslateMessage(MSG* pMsg)
  76. {
  77.     if (m_bDisableHotkeys && pMsg->message == WM_SYSCOMMAND && 
  78.             pMsg->wParam == SC_CLOSE && pMsg->lParam == 0)
  79.         return TRUE;  // This is a hotkey close message so kill it.
  80.  
  81.     return CFrameWnd::PreTranslateMessage(pMsg);
  82. }
  83.  
  84. void CGenericFrame::OnClose()
  85. {
  86.     //    See if the document will allow closing.
  87.     //  Do not only query the active document as MFC does.
  88.     //  Instead, query the main context document, and it will check children also.
  89.     CDocument* pDocument = NULL;
  90. //    if(m_NavCenterFrame) {
  91. //        m_NavCenterFrame->DestroyWindow();
  92. //        m_NavCenterFrame = NULL;
  93. //    }
  94.  
  95.     if(GetMainWinContext())    {
  96.         pDocument = (CDocument *)GetMainWinContext()->GetDocument();
  97.     }
  98.  
  99.     if (pDocument != NULL && !pDocument->CanCloseFrame(this))
  100.     {
  101.         // document can't close right now -- don't close it
  102.         return;
  103.     }
  104.     m_isClosing = TRUE;
  105.     CFrameWnd::OnClose();
  106. }
  107.  
  108. void CGenericFrame::OnFishCam()
  109. {
  110.     if(GetMainContext())    {
  111.         GetMainContext()->NormalGetUrl("http://home.netscape.com/fishcam/fishcam.html");
  112.     }
  113. }
  114.  
  115. void CGenericFrame::OnOpenMailWindow()
  116. {
  117. #ifdef MOZ_MAIL_NEWS
  118.     // Had to put this if condition here because
  119.     //putting it inside of CFolderFrame::Open was causing
  120.     //"Collabra Discussions" to bring up "AltMailMsgCenter"
  121.     if(theApp.m_hPostalLib)
  122.         FEU_AltMail_ShowMessageCenter(); 
  123.     else 
  124.         WFE_MSGOpenFolders();
  125. #endif // MOZ_MAIL_NEWS
  126. }
  127.  
  128. void CGenericFrame::OnOpenInboxWindow()
  129. {
  130. #ifdef MOZ_MAIL_NEWS
  131.     WFE_MSGOpenInbox();
  132. #endif
  133. }
  134.  
  135. void CGenericFrame::OnOpenNewsWindow()
  136. {
  137. #ifdef MOZ_MAIL_NEWS
  138.     WFE_MSGOpenNews();
  139. #endif
  140. }
  141.  
  142. void CGenericFrame::OnShowAddressBookWindow()
  143. {
  144. #ifdef MOZ_MAIL_NEWS
  145.     WFE_MSGOpenAB();
  146. #endif
  147. }
  148.  
  149. void CGenericFrame::OnFileMailNew()
  150. {
  151. #ifdef MOZ_MAIL_NEWS
  152.     if (GetMainContext()) 
  153.     {
  154.         if (WFE_MSGCheckWizard(this))
  155.             MSG_Mail (GetMainContext()->GetContext());
  156.     }
  157. #endif
  158. }
  159.  
  160. void CGenericFrame::OnLDAPSearch()
  161. {
  162. #ifdef MOZ_LDAP
  163.     WFE_MSGOpenLDAPSearch();
  164. #endif
  165. }
  166.  
  167. //    Set some options for printing.
  168. void CGenericFrame::OnFilePageSetup() 
  169. {
  170.     CPrintPageSetup * cdlg = new CPrintPageSetup ( this );
  171.     if(cdlg != NULL)    {
  172.         cdlg->DoModal ( );
  173.     } 
  174.     delete cdlg;
  175. }
  176.  
  177. void CGenericFrame::OnGoHistory()
  178. {
  179.     theApp.CreateNewNavCenter(NULL, TRUE, HT_VIEW_HISTORY);
  180. }
  181.  
  182. void CGenericFrame::OnPageFromWizard()
  183. {
  184. #ifdef EDITOR
  185.     char * url=NULL;
  186.     int bOK = PREF_CopyConfigString("internal_url.page_from_wizard.url",&url);
  187.     if (bOK == PREF_NOERROR) {
  188.         if(GetMainContext())    {
  189.             if( EDT_IS_EDITOR(GetMainContext()->GetContext()) ){
  190.                 // Load into a new Navigator window
  191.                 FE_LoadUrl(url, LOAD_URL_NAVIGATOR);
  192.             } else {
  193.                 GetMainContext()->NormalGetUrl(url);
  194.             }
  195.         }
  196.     }
  197.     if (url) XP_FREE(url);
  198. #endif /* EDITOR */
  199. }
  200.  
  201. void CGenericFrame::OnLiveCall()
  202. {
  203.     LaunchConfEndpoint( NULL, GetSafeHwnd() );
  204. }
  205.  
  206. void CGenericFrame::OnSysColorChange() 
  207. {
  208.     //    Update our idea of the current system info.
  209.     sysInfo.UpdateInfo();
  210.     prefInfo.SysColorChange();
  211.     
  212.     //    We'll need to do a reload to handle the current
  213.     //        colors internal to the document.
  214. //#ifdef GOLD
  215.     // This fixes critical bug 27239
  216.     //  put in ifdef GOLD to minizize impact on non-gold version - TEMPORARY:
  217.     // TODO: MERGE THIS TO REMOVE IFDEF GOLD
  218.     if(GetMainContext())    {
  219.         CWinCX *pContext = GetMainWinContext();
  220.         if( pContext && pContext->GetContext()){
  221. #ifdef EDITOR
  222.             if( EDT_IS_EDITOR(pContext->GetContext()) ) {
  223.                 // Relayout page without having to do NET_GetURL
  224.                 EDT_RefreshLayout(pContext->GetContext());
  225.             } else 
  226. #endif // EDITOR
  227.             {
  228.                 pContext->NiceReload();
  229.             }
  230.         }
  231.     }
  232. //#else
  233. //    if(GetMainContext())    {
  234. //        GetMainContext()->NiceReload();
  235. //    }
  236. //#endif
  237.  
  238.     //    Hopfully they'll redraw us so that the frame takes
  239.     //        on the new colors.
  240.     CFrameWnd::OnSysColorChange();
  241. }
  242.  
  243.  
  244. ////////////////////////////////////////////////////////////////////////////
  245. // Pop up the preferences box to let the user modify program configuration
  246. //
  247.  
  248. void
  249. CGenericFrame::OnDisplayPreferences()
  250. {
  251.     wfe_DisplayPreferences(this);
  252. }
  253.  
  254. // Pop up the preferences box to let the user modify program configuration
  255. //
  256. void CGenericFrame::OnPrefsMailNews()
  257. {
  258.     wfe_DisplayPreferences(this);
  259. }
  260.  
  261.  
  262. void CGenericFrame::OnHelpMenu()
  263. {
  264.     NetHelp( HELP_COMMUNICATOR );
  265. }
  266.  
  267.  
  268. LRESULT CGenericFrame::OnHelpMsg(WPARAM wParam, LPARAM lParam) 
  269. {
  270.  
  271.     //currently we only handle this message for the find replace dialog.
  272.      CFindReplaceDialog * dlg = ::CFindReplaceDialog::GetNotifier(lParam);
  273.     if (!dlg) 
  274.         return FALSE;
  275.  
  276.     // if it's the current find replace dialog then call help
  277.     if(dlg->m_hWnd == (HWND)wParam)
  278.     {
  279.         NetHelp("FIND_IN");
  280.         return TRUE;
  281.     }
  282.     return(FALSE);
  283.  
  284. }
  285.  
  286. void CGenericFrame::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized)
  287. {
  288.     CNSGenFrame::OnActivate(nState, pWndOther, bMinimized);
  289. }
  290. void CGenericFrame::RefreshNewEncoding(int16 csid, BOOL bSave )
  291. {
  292.      m_iCSID = csid;
  293.      XP_ASSERT(0); // subclass should overload this
  294. }
  295. int16 nIDToCsid(UINT nID)
  296. {
  297.      static int16 nid_to_csid[] = {
  298.        CS_LATIN1,                  // ID_OPTIONS_ENCODING_1
  299.        CS_LATIN2,                  // ID_OPTIONS_ENCODING_2
  300.        CS_SJIS_AUTO,               // ID_OPTIONS_ENCODING_3
  301.        CS_SJIS,                    // ID_OPTIONS_ENCODING_4
  302.        CS_EUCJP,                   // ID_OPTIONS_ENCODING_5
  303.        CS_BIG5,                    // ID_OPTIONS_ENCODING_6
  304.        CS_CNS_8BIT,                // ID_OPTIONS_ENCODING_7
  305.        CS_GB_8BIT,                 // ID_OPTIONS_ENCODING_8
  306.        CS_KSC_8BIT_AUTO,           // ID_OPTIONS_ENCODING_9
  307.        CS_USER_DEFINED_ENCODING,   // ID_OPTIONS_ENCODING_10
  308.        CS_CP_1250,                 // ID_OPTIONS_ENCODING_11
  309.        CS_CP_1251,                 // ID_OPTIONS_ENCODING_12
  310.        CS_8859_5,                  // ID_OPTIONS_ENCODING_13
  311.        CS_KOI8_R,                  // ID_OPTIONS_ENCODING_14
  312.        CS_8859_7,                  // ID_OPTIONS_ENCODING_15
  313.        CS_CP_1253,                 // ID_OPTIONS_ENCODING_16
  314.        CS_8859_9,                  // ID_OPTIONS_ENCODING_17
  315.        CS_UTF8,                    // ID_OPTIONS_ENCODING_18
  316.        CS_UCS2,                    // ID_OPTIONS_ENCODING_19
  317.        CS_UTF7                     // ID_OPTIONS_ENCODING_20
  318.      };
  319.  
  320.      if( nID >= ID_OPTIONS_ENCODING_1 && nID <= ID_OPTIONS_ENCODING_70)
  321.      {
  322.         int idx = nID - ID_OPTIONS_ENCODING_1;
  323.  
  324.         XP_ASSERT(idx < (sizeof(nid_to_csid)/ sizeof(int16)));
  325.  
  326.         int16 csid = nid_to_csid[nID - ID_OPTIONS_ENCODING_1];
  327.         return csid;
  328.      }
  329.      XP_ASSERT(0);
  330.      return 0;
  331. }
  332. void CGenericFrame::OnToggleEncoding(UINT nID)
  333. {
  334.      int16 csid = nIDToCsid(nID);
  335.      this->RefreshNewEncoding(csid);
  336. }
  337. void CGenericFrame::OnUpdateEncoding(CCmdUI* pCmdUI)
  338. {
  339.      BOOL bCheck;
  340.      bCheck = FALSE;
  341.      int16 csid = nIDToCsid(pCmdUI->m_nID);
  342.      bCheck = (m_iCSID == csid) ? TRUE : FALSE;
  343.      // handle special case here
  344.      if(FALSE ==  bCheck)
  345.      {
  346.         switch(csid)
  347.         {
  348.           case CS_UCS2:
  349.             bCheck = (m_iCSID == CS_UCS2_SWAP) ? TRUE : FALSE;
  350.             break;
  351.           case CS_KSC_8BIT:
  352.             bCheck = (m_iCSID == CS_KSC_8BIT_AUTO) ? TRUE : FALSE;
  353.             break;
  354.           default:
  355.             break;
  356.         }
  357.      }
  358.      pCmdUI->SetCheck(bCheck);
  359. }
  360.  
  361. BEGIN_MESSAGE_MAP(CNSGenFrame, CFrameWnd)
  362.     ON_WM_ACTIVATE()
  363. END_MESSAGE_MAP()
  364.  
  365. void CNSGenFrame::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized)
  366. {
  367.     CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
  368. }
  369.  
  370. CNSNavFrame *CNSGenFrame::GetDockedNavCenter()
  371. {
  372.     CNSNavFrame *pRetval = NULL;
  373.     
  374.     //  Do we have one?
  375.     CWnd *pWnd = GetDescendantWindow(NC_IDW_SELECTOR);
  376.     if(pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CSelector))) {
  377.         CSelector *pSelector = (CSelector *)pWnd;
  378.         CFrameWnd *pFrame = pSelector->GetParentFrame();
  379.         if(pFrame && pFrame->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) {
  380.             pRetval = (CNSNavFrame *)pFrame;
  381.         }
  382.     }
  383.     
  384.     return(pRetval);
  385. }
  386.  
  387. BOOL CNSGenFrame::AllowDocking()
  388. {
  389.     return(FALSE);
  390. }
  391.  
  392.  
  393.