home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ThreadFrame.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  33.8 KB  |  1,197 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.    ThreadFrame.cpp -- Thread window stuff
  20.    Created: Chris Toshok <toshok@netscape.com>, 29-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #include "MozillaApp.h"
  26. #include "FolderFrame.h"
  27. #include "FolderView.h"
  28. #include "FolderMenu.h"
  29. #include "AttachmentMenu.h"
  30. #include "ThreadFrame.h"
  31. #include "ThreadView.h"
  32. #include "Dashboard.h"
  33. #include "MsgView.h"
  34. #include "ViewGlue.h"
  35. #include "xpassert.h"
  36. #include "prefapi.h"
  37. #ifdef CLEAN_UP_NEWS
  38. #include "Xfe/Xfe.h"
  39. #include "MailDownloadFrame.h"
  40. #endif
  41.  
  42. #ifdef USE_3PANE
  43. #include "ThreePaneView.h"
  44. #endif
  45.  
  46. #include "libi18n.h"
  47. #include "intl_csi.h"
  48.  
  49. #ifdef DEBUG_toshok
  50. #define D(x) x
  51. #else
  52. #define D(x)
  53. #endif
  54.  
  55. #ifdef DEBUG_ramiro
  56. #define DR(x) x
  57. #else
  58. #define DR(x)
  59. #endif
  60.  
  61. #ifdef DEBUG_dora
  62. #define DD(x) x
  63. #else
  64. #define DD(x)
  65. #endif
  66.  
  67. #include "xpgetstr.h"
  68. extern int XFE_FOLDER_ON_SERVER;
  69. extern int XFE_FOLDER_ON_LOCAL_MACHINE;
  70. extern int XFE_MN_UNREAD_AND_TOTAL;
  71. extern int XFE_INBOX_DOESNT_EXIST;
  72. extern int XFE_SEND_UNSENTMAIL;
  73.  
  74.  
  75. #define THREEPANEVIEW_SHOW_PREF "mail.threadpane.3pane"
  76. //
  77. MenuSpec XFE_ThreadFrame::file_menu_spec[] = {
  78.     { "newSubmenu",                CASCADEBUTTON, (MenuSpec *) &XFE_Frame::new_submenu_spec },
  79.     { xfeCmdNewFolder,            PUSHBUTTON },
  80.     { xfeCmdOpenSelected,        PUSHBUTTON },
  81. //      { "openAttachmentsSubmenu",    DYNA_CASCADEBUTTON, 
  82. //          NULL, NULL, False, NULL, XFE_AttachmentMenu::generate },
  83.     MENU_SEPARATOR,
  84.     { xfeCmdSaveMessagesAs,    PUSHBUTTON },
  85.     { xfeCmdEditMessage,    PUSHBUTTON },
  86.     MENU_SEPARATOR,
  87.     { xfeCmdEmptyTrash,        PUSHBUTTON },
  88.     { xfeCmdCompressFolders,PUSHBUTTON },
  89.     { xfeCmdCompressAllFolders,PUSHBUTTON },
  90.     MENU_SEPARATOR,
  91.     { "newMsgSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::newMsg_submenu_spec },
  92.     { xfeCmdSendMessagesInOutbox,    PUSHBUTTON },
  93.     { xfeCmdCleanUpDisk, PUSHBUTTON },
  94. #if 0
  95.     { xfeCmdUpdateMessageCount,        PUSHBUTTON },
  96. #endif
  97.     { xfeCmdAddNewsgroup,            PUSHBUTTON },
  98.     //MENU_SEPARATOR,
  99.     //{ xfeCmdGoOffline,        PUSHBUTTON },
  100.     MENU_SEPARATOR,
  101.     //{ xfeCmdPrintSetup,        PUSHBUTTON },
  102.     //{ xfeCmdPrintPreview,    PUSHBUTTON },
  103.     { xfeCmdPrint,            PUSHBUTTON },
  104.     MENU_SEPARATOR,
  105.     { xfeCmdClose,            PUSHBUTTON },
  106.     { xfeCmdExit,            PUSHBUTTON },
  107.     { NULL }
  108. };
  109.  
  110. MenuSpec XFE_ThreadFrame::edit_menu_spec[] = {
  111.     { xfeCmdUndo,            PUSHBUTTON },
  112.     { xfeCmdRedo,            PUSHBUTTON },
  113.     MENU_SEPARATOR,
  114.     { xfeCmdCut,            PUSHBUTTON },
  115.     { xfeCmdCopy,            PUSHBUTTON },
  116.     { xfeCmdPaste,            PUSHBUTTON },
  117.     { xfeCmdDeleteMessage,    PUSHBUTTON },
  118.  
  119.     { "selectSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::select_submenu_spec },
  120.     MENU_SEPARATOR,
  121.     { xfeCmdFindInObject,        PUSHBUTTON },
  122.     { xfeCmdFindAgain,        PUSHBUTTON },
  123.     { xfeCmdSearch,            PUSHBUTTON },
  124.     { xfeCmdSearchAddress,    PUSHBUTTON },
  125.     MENU_SEPARATOR,
  126.     { xfeCmdEditConfiguration,    PUSHBUTTON },
  127.     { xfeCmdModerateDiscussion,    PUSHBUTTON },
  128.     MENU_SEPARATOR,
  129.     { xfeCmdEditMailFilterRules,PUSHBUTTON },
  130.     //xxxAdd Folder/Discussion Properties
  131.     { xfeCmdEditPreferences,    PUSHBUTTON },
  132.     { NULL }
  133. };
  134.  
  135. MenuSpec XFE_ThreadFrame::view_menu_spec[] = {
  136.     { xfeCmdToggleNavigationToolbar,PUSHBUTTON },
  137.     { xfeCmdToggleLocationToolbar,    PUSHBUTTON },
  138.     { xfeCmdToggleMessageExpansion,    PUSHBUTTON },
  139.     MENU_SEPARATOR,
  140.     { "sortSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::sort_submenu_spec },
  141.     { "expandCollapseSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::expand_collapse_submenu_spec },
  142.     { "threadSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::threads_submenu_spec },
  143.     { "headersSubmenu",        CASCADEBUTTON, (MenuSpec *) &XFE_Frame::headers_submenu_spec },
  144.     // This should just be a toggle.  -slamm
  145.     { "attachmentsSubmenu",    CASCADEBUTTON, (MenuSpec *) &XFE_Frame::attachments_submenu_spec },
  146.     MENU_SEPARATOR,
  147.     { xfeCmdIncreaseFont,        PUSHBUTTON },
  148.     { xfeCmdDecreaseFont,        PUSHBUTTON },
  149.     MENU_SEPARATOR,
  150.     { xfeCmdReload,        PUSHBUTTON },
  151.     { xfeCmdShowImages,        PUSHBUTTON },
  152.     { xfeCmdRefresh,        PUSHBUTTON },
  153.     { xfeCmdStopLoading,        PUSHBUTTON },
  154.     MENU_SEPARATOR,
  155.     { xfeCmdRot13Message,        PUSHBUTTON },
  156.     { xfeCmdWrapLongLines,        TOGGLEBUTTON },
  157.     MENU_SEPARATOR,
  158.     { xfeCmdViewPageSource,    PUSHBUTTON },
  159.     { xfeCmdViewPageInfo,    PUSHBUTTON },
  160.     MENU_SEPARATOR,
  161.     { "encodingSubmenu",    CASCADEBUTTON, (MenuSpec *) &XFE_Frame::encoding_menu_spec },
  162.     { NULL }
  163. };
  164.  
  165. //
  166. MenuSpec XFE_ThreadFrame::go_menu_spec[] = {
  167.     { xfeCmdNextMessage,            PUSHBUTTON },
  168.     { xfeCmdNextUnreadMessage,        PUSHBUTTON },
  169.     { xfeCmdNextFlaggedMessage,        PUSHBUTTON },
  170.     { xfeCmdNextUnreadThread,        PUSHBUTTON },
  171.     { xfeCmdNextCollection,            PUSHBUTTON },
  172.     { xfeCmdNextUnreadCollection,     PUSHBUTTON },
  173.     MENU_SEPARATOR,
  174.     { xfeCmdPreviousMessage,        PUSHBUTTON },
  175.     { xfeCmdPreviousUnreadMessage,    PUSHBUTTON },
  176.     { xfeCmdPreviousFlaggedMessage,    PUSHBUTTON },
  177.     MENU_SEPARATOR,
  178.     { xfeCmdFirstFlaggedMessage,    PUSHBUTTON },
  179.     MENU_SEPARATOR,
  180.     { xfeCmdBack,            PUSHBUTTON },
  181.     { xfeCmdForward,        PUSHBUTTON },
  182.     { NULL }
  183. };
  184.  
  185. //
  186. MenuSpec XFE_ThreadFrame::offline_submenu_spec[] = {
  187.     { xfeCmdGetSelectedMessagesForOffline, PUSHBUTTON },
  188.     { xfeCmdGetFlaggedMessagesForOffline,     PUSHBUTTON },
  189.     { xfeCmdChooseMessagesForOffline,     PUSHBUTTON },
  190.     { NULL }
  191. };
  192.  
  193. MenuSpec XFE_ThreadFrame::ignore_submenu_spec[] = {
  194.     { xfeCmdIgnoreThread,        PUSHBUTTON },
  195.     { NULL }
  196. };
  197.  
  198. MenuSpec XFE_ThreadFrame::message_menu_spec[] = {
  199.     { xfeCmdComposeMessage,        PUSHBUTTON },
  200.     { "replySubmenu",            CASCADEBUTTON, (MenuSpec *) &XFE_Frame::reply_submenu_spec },
  201.     { xfeCmdForwardMessage,        PUSHBUTTON },
  202.     { xfeCmdForwardMessageQuoted,        PUSHBUTTON },
  203.     //{ xfeCmdInviteToNewsgroup,        PUSHBUTTON },
  204.     MENU_SEPARATOR,
  205.     { "addToABSubmenu",            CASCADEBUTTON, (MenuSpec *) &XFE_Frame::addrbk_submenu_spec },
  206.     { "fileSubmenu",            DYNA_CASCADEBUTTON, NULL, NULL, False, (void*)xfeCmdMoveMessage, XFE_FolderMenu::generate },
  207.     { "copySubmenu",            DYNA_CASCADEBUTTON, NULL, NULL, False, (void*)xfeCmdCopyMessage, XFE_FolderMenu::generate },
  208.     MENU_SEPARATOR,
  209.     { "markSubmenu",            CASCADEBUTTON, (MenuSpec *) &XFE_Frame::mark_submenu_spec },
  210.     { xfeCmdMarkMessage,            PUSHBUTTON },
  211.     { xfeCmdUnmarkMessage,        PUSHBUTTON },
  212.     MENU_SEPARATOR,
  213.     { xfeCmdIgnoreThread,        PUSHBUTTON },
  214.     { xfeCmdWatchThread,        PUSHBUTTON },
  215.     { NULL }
  216. };
  217.  
  218. //
  219. MenuSpec XFE_ThreadFrame::menu_bar_spec[] = {
  220.     { xfeMenuFile,     CASCADEBUTTON, file_menu_spec },
  221.     { xfeMenuEdit,     CASCADEBUTTON, edit_menu_spec },
  222.     { xfeMenuView,     CASCADEBUTTON, view_menu_spec },
  223.     { xfeMenuGo,         CASCADEBUTTON, go_menu_spec },
  224.     { xfeMenuMessage,     CASCADEBUTTON, message_menu_spec },
  225.     { xfeMenuWindow,    CASCADEBUTTON, XFE_Frame::window_menu_spec },
  226.     { xfeMenuHelp,     CASCADEBUTTON, XFE_Frame::help_menu_spec },
  227.     { NULL }
  228. };
  229.  
  230. ToolbarSpec XFE_ThreadFrame::toolbar_spec[] = {
  231.     { xfeCmdGetNewMessages,    PUSHBUTTON, &MNTB_GetMsg_group},
  232.     {  // XX mail only
  233.         xfeCmdComposeMessage,    
  234.         CASCADEBUTTON, 
  235.         &MNTB_Compose_group, NULL, NULL, NULL,                // Icons
  236.         compose_message_submenu_spec,                                    // Submenu spec
  237.         NULL, NULL,                                            // Generate proc/arg
  238.         XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  239.     },
  240.     {  // XX newsgroup only
  241.         xfeCmdComposeArticle,    
  242.         CASCADEBUTTON, 
  243.         &MNTB_Compose_group, NULL, NULL, NULL,                // Icons
  244.         compose_article_submenu_spec,                                    // Submenu spec
  245.         NULL, NULL,                                            // Generate proc/arg
  246.         XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  247.     },
  248.     TOOLBAR_SEPARATOR,
  249.     {  // XX mail only
  250.         xfeCmdReplyToSender,    
  251.         CASCADEBUTTON, 
  252.         &MNTB_Reply_group, NULL, NULL, NULL,                // Icons
  253.         reply_submenu_spec,                                    // Submenu spec
  254.         NULL, NULL,                                            // Generate proc/arg
  255.         XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  256.     },
  257.     {  // XX news only
  258.         xfeCmdReplyToNewsgroup,    
  259.         CASCADEBUTTON, 
  260.         &MNTB_Reply_group, NULL, NULL, NULL,                // Icons
  261.         reply_submenu_spec,                                    // Submenu spec
  262.         NULL, NULL,                                            // Generate proc/arg
  263.         XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  264.     },
  265.     { xfeCmdForwardMessage,    PUSHBUTTON, &MNTB_Forward_group },
  266.     TOOLBAR_SEPARATOR,
  267.     {
  268.         xfeCmdCopyMessage,  // XX news only
  269.         DYNA_CASCADEBUTTON, 
  270.         &MNTB_File_group, NULL, NULL, NULL, NULL,
  271.         XFE_FolderMenu::generate, (void*)xfeCmdCopyMessage,
  272.         XFE_TOOLBAR_DELAY_SHORT
  273.     },
  274.     {
  275.         xfeCmdMoveMessage, // XX mail only
  276.         DYNA_CASCADEBUTTON, 
  277.         &MNTB_File_group, NULL, NULL, NULL, NULL,
  278.         XFE_FolderMenu::generate, (void*)xfeCmdMoveMessage,
  279.         XFE_TOOLBAR_DELAY_SHORT
  280.     },
  281.     {
  282.         xfeCmdNextUnreadMessage,
  283.         CASCADEBUTTON, 
  284.         &MNTB_Next_group, NULL, NULL, NULL,                    // Icons
  285.         next_submenu_spec,                                    // Submenu spec
  286.         NULL, NULL,                                            // Generate proc/arg
  287.         XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  288.     },
  289.     { xfeCmdPrint,            PUSHBUTTON, &TB_Print_group },
  290.     { xfeCmdViewSecurity,        PUSHBUTTON, 
  291.             &TB_Unsecure_group,
  292.                            &TB_Secure_group,
  293.                            &MNTB_SignUnsecure_group,
  294.                         &MNTB_SignSecure_group},
  295.     { xfeCmdMarkMessageRead, // XX news only
  296.       CASCADEBUTTON, 
  297.       &MNTB_MarkRead_group, NULL, NULL, NULL,                // Icons
  298.       mark_submenu_spec,                                    // Submenu spec
  299.       NULL, NULL,                                            // Generate proc/arg
  300.       XFE_TOOLBAR_DELAY_LONG                                // Popup delay
  301.     },
  302.     { xfeCmdDeleteMessage,    PUSHBUTTON, &MNTB_Trash_group }, // XX mail only
  303.     { xfeCmdStopLoading,        PUSHBUTTON, &TB_Stop_group },
  304.     { NULL }
  305. };
  306.  
  307. XFE_ThreadFrame::XFE_ThreadFrame(Widget toplevel, XFE_Frame *parent_frame,
  308.                                  Chrome *chromespec)
  309.     : XFE_Frame("MailThread", toplevel, parent_frame,
  310.                 FRAME_MAILNEWS_THREAD, chromespec, True)
  311. {
  312.   INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(m_context);
  313.   INTL_SetCSIWinCSID(c, 
  314.         INTL_DocToWinCharSetID (CONTEXT_DATA (m_context)->xfe_doc_csid));
  315.  
  316.     geometryPrefName = "mail.thread";
  317.  
  318.     // create the thread view
  319. #ifdef USE_3PANE
  320.     XFE_ThreePaneView *view3;
  321. #endif
  322.     XFE_ThreadView *tview;
  323.     XFE_ProxyIcon *proxy;
  324.  
  325.     if (parent_frame)
  326.       fe_copy_context_settings(m_context, parent_frame->getContext());
  327.  
  328.     m_banner = new XFE_MNBanner(this, m_toolbox);
  329.     
  330. #ifdef USE_3PANE
  331.  
  332.         XP_Bool show_folder;
  333.         PREF_GetBoolPref(THREEPANEVIEW_SHOW_PREF, &show_folder);
  334.  
  335.         m_banner->setShowFolder(show_folder); /* This has to be set before view 
  336.                       creation */
  337.     view3 = new XFE_ThreePaneView(this, getViewParent(), NULL, m_context);
  338.  
  339.     tview = (XFE_ThreadView*)(view3->getThreadView());
  340.  
  341. #else
  342.     tview = new XFE_ThreadView(this, getViewParent(), NULL, m_context);
  343. #endif
  344.  
  345.  
  346.     m_dropdown = new XFE_FolderDropdown(this, m_banner->getComponentParent(), False, True, True);
  347.     
  348.     m_dropdown->registerInterest(XFE_FolderDropdown::folderSelected, 
  349.                                  this,
  350.                                  (XFE_FunctionNotification)dropdownFolderLoad_cb);
  351.  
  352.     m_banner->setTitleComponent(m_dropdown);
  353.     m_banner->setMommyIcon(&MN_Mommy_group);
  354.  
  355.     tview->registerInterest(XFE_MNView::bannerNeedsUpdating,
  356.                             this,
  357.                             (XFE_FunctionNotification)updateBanner_cb);
  358.  
  359. #ifdef USE_3PANE
  360.     setView(view3);
  361.     XtVaSetValues(view3->getBaseWidget(),
  362.                   XmNleftAttachment, XmATTACH_FORM,
  363.                   XmNtopAttachment, XmATTACH_FORM,
  364.                   XmNrightAttachment, XmATTACH_FORM,
  365.                   XmNbottomAttachment, XmATTACH_FORM,
  366.                   NULL);
  367. #else
  368.     setView(tview);
  369.  
  370.     XtVaSetValues(tview->getBaseWidget(),
  371.                   XmNleftAttachment, XmATTACH_FORM,
  372.                   XmNtopAttachment, XmATTACH_FORM,
  373.                   XmNrightAttachment, XmATTACH_FORM,
  374.                   XmNbottomAttachment, XmATTACH_FORM,
  375.                   NULL);
  376. #endif
  377.  
  378.  
  379.     setMenubar(menu_bar_spec);
  380.     setToolbar(toolbar_spec);
  381.  
  382. //    m_banner->show();
  383. #ifdef USE_3PANE
  384.     view3->show();
  385. #else
  386.     tview->show();
  387. #endif
  388.  
  389.     /* we need the different folder icons initialized in the FolderView for our proxy. */
  390.     {
  391.         Pixel bg_pixel;
  392.         
  393.         XtVaGetValues(m_banner->getBaseWidget(), XmNbackground, &bg_pixel, 0);
  394.  
  395.         XFE_FolderView::initFolderIcons(m_widget, bg_pixel, getFGPixel());
  396.     }
  397.  
  398.     // safe defaults.  They will be overridden when we update the banner.
  399.     m_banner->setProxyIcon(&XFE_MNView::folderIcon);
  400.     proxy = m_banner->getProxyIcon();
  401. #if !defined(USE_MOTIF_DND)
  402.     proxy->setDragType(FE_DND_MAIL_FOLDER, tview, &XFE_ThreadView::source_drop_func);
  403. #endif
  404.  
  405.     // Configure the dashboard
  406.     XP_ASSERT( m_dashboard != NULL );
  407.     
  408.     m_dashboard->setShowSecurityIcon(True);
  409.     m_dashboard->setShowSignedIcon(True);
  410.     m_dashboard->setShowStatusBar(True);
  411.     m_dashboard->setShowProgressBar(True);
  412.  
  413.   // Configure the toolbox for the first time
  414.   configureToolbox();
  415.  
  416.     XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::MNChromeNeedsUpdating,
  417.                                                this,
  418.                                                (XFE_FunctionNotification)MNChromeUpdate_cb);
  419.  
  420.     XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::folderChromeNeedsUpdating,
  421.                                                this,
  422.                                                (XFE_FunctionNotification)FolderChromeUpdate_cb);
  423.  
  424.     XFE_MozillaApp::theApp()->registerInterest(XFE_MNView::folderDeleted,
  425.                                                this,
  426.                                                (XFE_FunctionNotification)folderDeleted_cb);
  427.  
  428. }
  429.  
  430.  
  431.  
  432. XFE_ThreadFrame::~XFE_ThreadFrame()
  433. {
  434.     D(printf ("In XFE_ThreadFrame::~XFE_ThreadFrame()\n");)
  435.  
  436.     XFE_MozillaApp::theApp()->unregisterInterest(XFE_MNView::MNChromeNeedsUpdating,
  437.                                                  this,
  438.                                                  (XFE_FunctionNotification)MNChromeUpdate_cb);
  439.     
  440.     XFE_MozillaApp::theApp()->unregisterInterest(XFE_MNView::folderChromeNeedsUpdating,
  441.                                                  this,
  442.                                                  (XFE_FunctionNotification)FolderChromeUpdate_cb);
  443.  
  444. #ifdef USE_3PANE
  445.     XFE_ThreePaneView *view3 = (XFE_ThreePaneView*)m_view;
  446.     XFE_ThreadView *tview = (XFE_ThreadView*)(view3->getThreadView());
  447. #else
  448.     XFE_ThreadView *tview = (XFE_ThreadView*)m_view;
  449. #endif
  450.     tview->unregisterInterest(XFE_MNView::bannerNeedsUpdating,
  451.                                                  this,
  452.                                                  (XFE_FunctionNotification)updateBanner_cb);
  453.  
  454.     XFE_MozillaApp::theApp()->unregisterInterest(XFE_MNView::folderDeleted,
  455.                                                  this,
  456.                                                  (XFE_FunctionNotification)folderDeleted_cb);
  457. }
  458.  
  459. XFE_CALLBACK_DEFN(XFE_ThreadFrame, mommy)(XFE_NotificationCenter *,
  460.                                           void *,
  461.                                           void *)
  462. {
  463.     fe_showFolders(XtParent(m_widget), this, NULL);
  464. }
  465.  
  466. XFE_CALLBACK_DEFN(XFE_ThreadFrame, updateBanner)(XFE_NotificationCenter *,
  467.                                                  void *,
  468.                                                  void *)
  469. {
  470.     MSG_FolderLine folderline;
  471. #ifdef USE_3PANE
  472.         XFE_ThreadView *t_view = (XFE_ThreadView*)(
  473.             ((XFE_ThreePaneView*)m_view)->getThreadView());
  474. #else
  475.         XFE_ThreadView *t_view = (XFE_ThreadView*)m_view;
  476. #endif
  477.     XFE_ProxyIcon *proxy;
  478.  
  479.     updateReadAndTotalCounts();
  480.  
  481.     if (MSG_GetFolderLineById(XFE_MNView::getMaster(),
  482.                               t_view->getFolderInfo(), &folderline))
  483.         {
  484.  
  485.             m_dropdown->selectFolder(t_view->getFolderInfo(),False);
  486.             
  487.             m_banner->setProxyIcon(XFE_FolderView::treeInfoToIcon(folderline.level - 1,
  488.                                                                   folderline.flags,
  489.                                                                   False));
  490.  
  491.             proxy = m_banner->getProxyIcon();
  492.                                    
  493.             if (folderline.flags & MSG_FOLDER_FLAG_NEWSGROUP)
  494.                 {
  495. #if !defined(USE_MOTIF_DND)
  496.                     proxy->setDragType(FE_DND_NEWS_FOLDER, t_view, &XFE_ThreadView::source_drop_func);
  497. #endif
  498.  
  499.                     m_banner->setSubtitle("");
  500.                 }
  501.             else
  502.                 {
  503. #if !defined(USE_MOTIF_DND)
  504.                     proxy->setDragType(FE_DND_MAIL_FOLDER, t_view, &XFE_ThreadView::source_drop_func);
  505. #endif
  506.                     
  507.                     if (folderline.flags & MSG_FOLDER_FLAG_IMAPBOX)
  508.                         m_banner->setSubtitle(XP_GetString (XFE_FOLDER_ON_SERVER ));
  509.                     else
  510.                         m_banner->setSubtitle(XP_GetString ( XFE_FOLDER_ON_LOCAL_MACHINE ));
  511.                 }
  512.         }
  513. }
  514.  
  515. XFE_CALLBACK_DEFN(XFE_ThreadFrame, folderDeleted)(XFE_NotificationCenter*,
  516.                            void *, void *cdata)
  517. {
  518.     /* Need to check if this folder ?
  519.      * hide or switch ?
  520.      */
  521.     MSG_FolderInfo *info = (MSG_FolderInfo *) cdata;
  522.     if (info == getFolderInfo())
  523.         delete_response();
  524. }
  525.  
  526.  
  527. void
  528. XFE_ThreadFrame::loadFolder(MSG_FolderInfo *folderInfo)
  529. {
  530. #ifdef USE_3PANE
  531.     XFE_ThreePaneView *view3 = (XFE_ThreePaneView*)m_view;
  532.     XFE_ThreadView *tview = (XFE_ThreadView*)(view3->getThreadView());
  533. #else
  534.     XFE_ThreadView *tview = (XFE_ThreadView*)m_view;
  535. #endif
  536.     MSG_FolderLine folderline;
  537.     uint16 foldercsid;
  538.  
  539.     foldercsid = MSG_GetFolderCSID(folderInfo);
  540.     if ((CS_UNKNOWN==foldercsid) || (CS_DEFAULT==foldercsid))
  541.         {
  542.             foldercsid = INTL_DefaultDocCharSetID(NULL);
  543.             MSG_SetFolderCSID(folderInfo, foldercsid);
  544.         }
  545.     CONTEXT_DATA(m_context)->xfe_doc_csid = foldercsid;
  546.     if (MSG_GetFolderLineById(XFE_MNView::getMaster(),
  547.                               folderInfo, &folderline))
  548.         {
  549.             if (folderline.flags & MSG_FOLDER_FLAG_NEWSGROUP)
  550.                 {
  551.                     m_toolbar->hideButton(xfeCmdComposeMessage, PUSHBUTTON);
  552.                     m_toolbar->hideButton(xfeCmdDeleteMessage, PUSHBUTTON);
  553.                     m_toolbar->hideButton(xfeCmdReplyToSender, CASCADEBUTTON);
  554.                     m_toolbar->hideButton(xfeCmdMoveMessage, CASCADEBUTTON);
  555.  
  556.                     m_toolbar->showButton(xfeCmdComposeArticle, PUSHBUTTON);
  557.                     m_toolbar->showButton(xfeCmdReplyToNewsgroup, CASCADEBUTTON);
  558.                     m_toolbar->showButton(xfeCmdMarkMessageRead, CASCADEBUTTON);
  559.                     m_toolbar->showButton(xfeCmdCopyMessage, CASCADEBUTTON);
  560.                 }
  561.             else
  562.                 {
  563.                     m_toolbar->showButton(xfeCmdComposeMessage, PUSHBUTTON);
  564.                     m_toolbar->showButton(xfeCmdDeleteMessage, PUSHBUTTON);
  565.                     m_toolbar->showButton(xfeCmdReplyToSender, CASCADEBUTTON);
  566.                     m_toolbar->showButton(xfeCmdMoveMessage, CASCADEBUTTON);
  567.                     
  568.                     m_toolbar->hideButton(xfeCmdComposeArticle, PUSHBUTTON);
  569.                     m_toolbar->hideButton(xfeCmdReplyToNewsgroup, CASCADEBUTTON);
  570.                     m_toolbar->hideButton(xfeCmdMarkMessageRead, CASCADEBUTTON);
  571.                     m_toolbar->hideButton(xfeCmdCopyMessage, CASCADEBUTTON);
  572.                 }
  573.         }
  574.  
  575. #ifdef USE_3PANE
  576.     view3->selectFolder(folderInfo);
  577.     DD(printf("ThreadFrame::loadFolder x%x \n", folderInfo);)
  578. #endif
  579.     tview->loadFolder(folderInfo);
  580. }
  581.  
  582. MSG_FolderInfo *
  583. XFE_ThreadFrame::getFolderInfo()
  584. {
  585. #ifdef USE_3PANE
  586.     XFE_ThreadView *tview = (XFE_ThreadView*)(
  587.             ((XFE_ThreePaneView*)m_view)->getThreadView());
  588. #else
  589.     XFE_ThreadView *tview = (XFE_ThreadView*)m_view;
  590. #endif
  591.  
  592.     return tview->getFolderInfo();
  593. }
  594.  
  595. void
  596. XFE_ThreadFrame::updateReadAndTotalCounts()
  597. {
  598.     MSG_FolderLine folderline;
  599. #ifdef USE_3PANE
  600.         XFE_ThreadView *t_view = (XFE_ThreadView*)(
  601.             ((XFE_ThreePaneView*)m_view)->getThreadView());
  602. #else
  603.     XFE_ThreadView *t_view = (XFE_ThreadView*)m_view;
  604. #endif
  605.     MSG_FolderInfo *info = t_view->getFolderInfo();
  606.  
  607.     if (info)
  608.         {
  609.             if (MSG_GetFolderLineById(XFE_MNView::getMaster(),
  610.                                       info, &folderline))
  611.                 {
  612.                     char buf[200];
  613.                     
  614.                     PR_snprintf(buf, sizeof(buf), 
  615.                                 XP_GetString(XFE_MN_UNREAD_AND_TOTAL),
  616.                                 folderline.unseen,
  617.                                 folderline.total);
  618.                     
  619.                     m_banner->setInfo(buf);
  620.                 }
  621.         }
  622. }
  623.  
  624. XFE_CALLBACK_DEFN(XFE_ThreadFrame, dropdownFolderLoad)(XFE_NotificationCenter*,
  625.                                                        void *, void *calldata)
  626. {
  627.     MSG_FolderInfo *info = (MSG_FolderInfo*)calldata;
  628.     
  629.     loadFolder(info);
  630. }
  631.  
  632. XFE_CALLBACK_DEFN(XFE_ThreadFrame, MNChromeUpdate)(XFE_NotificationCenter*,
  633.                                                    void*, void*)
  634. {
  635.     notifyInterested(XFE_View::chromeNeedsUpdating);
  636.  
  637.     updateReadAndTotalCounts();
  638. }
  639.  
  640. XFE_CALLBACK_DEFN(XFE_ThreadFrame, FolderChromeUpdate)(XFE_NotificationCenter*,
  641.                                                        void*, void *cd)
  642. {
  643.     MSG_FolderInfo *info = (MSG_FolderInfo*)cd;
  644.  
  645.     if (info == getFolderInfo())
  646.         {
  647.             notifyInterested(XFE_View::chromeNeedsUpdating);
  648.             
  649.             updateReadAndTotalCounts();
  650.         }
  651. }
  652.  
  653. XFE_ThreadFrame *
  654. XFE_ThreadFrame::frameForInfo(MSG_FolderInfo *info)
  655. {
  656.     XP_List *thread_frame_list = XFE_MozillaApp::theApp()->getFrameList( FRAME_MAILNEWS_THREAD );
  657.     XP_List *current_list_entry;
  658.  
  659.     for (current_list_entry = thread_frame_list;
  660.          current_list_entry != NULL;
  661.          current_list_entry = current_list_entry->next)
  662.         {
  663.             if (current_list_entry->object
  664.                 && ((XFE_Frame*)current_list_entry->object)->getType() == FRAME_MAILNEWS_THREAD // sanity check
  665.                 && ((XFE_ThreadFrame*)current_list_entry->object)->getFolderInfo() == info)
  666.                 {
  667.                     D( printf ("Found one.\n");)
  668.                         return (XFE_ThreadFrame*)current_list_entry->object;
  669.                 }
  670.         }
  671.  
  672.     return NULL;
  673. }
  674.  
  675. extern "C" MWContext*
  676. fe_showInbox(Widget toplevel, XFE_Frame *parent_frame,
  677.              Chrome *chromespec, XP_Bool with_reuse, XP_Bool getNewMail)
  678. {
  679.     MSG_FolderInfo *inbox_info = NULL;
  680.     int num_inboxes;
  681.  
  682.     num_inboxes = MSG_GetFoldersWithFlag(XFE_MNView::getMaster(),
  683.                                          MSG_FOLDER_FLAG_INBOX,
  684.                                          NULL, 0);
  685.     if (num_inboxes > 0) {
  686.         int32 error = MSG_GetFoldersWithFlag(XFE_MNView::getMaster(),
  687.                                              MSG_FOLDER_FLAG_INBOX,
  688.                                              &inbox_info, 1);
  689.         if (error > 0)
  690.             return fe_showMessages(toplevel, parent_frame, 
  691.                                    chromespec, inbox_info, 
  692.                                    with_reuse, getNewMail, 
  693.                                    MSG_MESSAGEKEYNONE);
  694.     }/* if */
  695.  
  696.     char tmp[256];
  697.     XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  698.                     "%s",
  699.                     XP_GetString(XFE_INBOX_DOESNT_EXIST));
  700.     if (toplevel)
  701.         fe_Alert_2(toplevel, tmp);
  702.     return NULL;
  703. }
  704.  
  705. extern "C" MWContext*
  706. fe_showMessages(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec, 
  707.                 MSG_FolderInfo *info, XP_Bool with_reuse, XP_Bool getNewMail, MessageKey key)
  708. {
  709.     XFE_ThreadFrame *theFrame = NULL;
  710.     MSG_FolderInfo *curFolderInfo = NULL;
  711.     XP_Bool getNewNow = True; /* use this flag to tell when to get new mail
  712.                                  */
  713.  
  714.     D(    printf ("in fe_showThread()\n");)
  715.  
  716.     if (with_reuse)
  717.         {
  718.             XP_List *thread_frame_list = 
  719.                 XFE_MozillaApp::theApp()->getFrameList( FRAME_MAILNEWS_THREAD );
  720.      
  721.             if (!XP_ListIsEmpty(thread_frame_list))
  722.                 {
  723.                     theFrame = (XFE_ThreadFrame*)XP_ListTopObject( thread_frame_list );
  724.                 }
  725.             else
  726.                 {
  727.                     theFrame = new XFE_ThreadFrame(toplevel, parent_frame, chromespec);
  728.                     getNewNow = False;
  729.                 }
  730.  
  731.             /* query cur folder info
  732.              */
  733.             curFolderInfo = theFrame->getFolderInfo();
  734.  
  735.             if (theFrame)
  736.                 {
  737.                     if ( key != MSG_MESSAGEKEYNONE)
  738.                     {
  739.                 
  740. #ifdef USE_3PANE
  741.                             XFE_ThreadView *t_view = (XFE_ThreadView*)( 
  742.                             ((XFE_ThreePaneView*)(theFrame->getView()))->getThreadView());
  743.                           t_view->openWithKey(key);
  744. #else
  745.                       ((XFE_ThreadView*)(theFrame->getView()))->openWithKey(key);
  746. #endif
  747.                       /* only raise the window to be visible if thread window is not mapped */
  748.                       /* has to be shown before loading folder, otherwise, 
  749.                          it will cause an abort in lay.c */
  750.                       if ( !theFrame->isShown())
  751.                           theFrame->show(); 
  752.  
  753.                       /* we need to wait until the folder is loaded
  754.                        */
  755.                       if ((curFolderInfo == NULL) ||
  756.                           (curFolderInfo != info))
  757.                           getNewNow = False;
  758.                       else
  759.                           getNewNow = True;
  760.  
  761.                       theFrame->loadFolder(info);
  762.  
  763.                     }
  764.                      else
  765.                     {
  766.                     theFrame->show();
  767.  
  768.                     if ((curFolderInfo == NULL) ||
  769.                         (curFolderInfo != info)) {
  770.                         theFrame->loadFolder(info);
  771.                         getNewNow = False;
  772.                     }
  773.                     else
  774.                         getNewNow = True;
  775.                     }
  776.                 }
  777.         }
  778.     else
  779.         {
  780.             theFrame = XFE_ThreadFrame::frameForInfo(info);
  781.             if (!theFrame)
  782.                 {
  783.                     theFrame = new XFE_ThreadFrame(toplevel, parent_frame, chromespec);
  784.                     if ( key != MSG_MESSAGEKEYNONE)
  785.                     {
  786. #ifdef USE_3PANE
  787.                         XFE_ThreadView *t_view = (XFE_ThreadView*)( 
  788.                             ((XFE_ThreePaneView*)(theFrame->getView()))->getThreadView());
  789.                     t_view->openWithKey(key);
  790. #else
  791.                     ((XFE_ThreadView*)(theFrame->getView()))->openWithKey(key);
  792. #endif
  793.  
  794.                     //  ((XFE_ThreadView*)(theFrame->getView()))->openWithKey(key);
  795.                      /* has to be shown before loading folder, otherwise, 
  796.                         it will cause an abort in lay.c */
  797.                       if ( !theFrame->isShown() )
  798.                         theFrame->show();
  799.                     }
  800.                     else
  801.                        theFrame->show();
  802.                     theFrame->loadFolder(info);
  803.  
  804.                     /* get after folder is loaded
  805.                      */
  806.                     getNewNow = False;
  807.                 }
  808.             else
  809.                 {
  810.                     /* query cur folder info
  811.                      */
  812.                     curFolderInfo = theFrame->getFolderInfo();
  813.  
  814.                     /* need to test if folder is loaded
  815.                      */
  816.                     if ((curFolderInfo == NULL) ||
  817.                         (curFolderInfo != info)) {
  818.                         getNewNow = False;
  819.                     }
  820.                     else
  821.                         getNewNow = True;
  822.  
  823.                     if ( key != MSG_MESSAGEKEYNONE)
  824.                     {
  825. #ifdef USE_3PANE
  826.                         XFE_ThreadView *t_view = (XFE_ThreadView*)( 
  827.                             ((XFE_ThreePaneView*)(theFrame->getView()))->getThreadView());
  828.                     t_view->openWithKey(key);
  829. #else
  830.                     ((XFE_ThreadView*)(theFrame->getView()))->openWithKey(key);
  831. #endif
  832.                      /* has to be shown before loading folder, otherwise, 
  833.                         it will cause an abort in lay.c */
  834.                       if ( !theFrame->isShown() )
  835.                         theFrame->show();
  836.  
  837.  
  838.                       theFrame->loadFolder(info);
  839.                     }
  840.                     else
  841.                       theFrame->show();
  842.                 }
  843.         }
  844.     
  845.     if (getNewMail)
  846.         if (theFrame->isCommandEnabled(xfeCmdGetNewMessages)) {
  847.             if (getNewNow)
  848.                 /* folder already loaded
  849.                  */
  850.                 theFrame->doCommand(xfeCmdGetNewMessages);            
  851.             else
  852.             {
  853.                 /* set flag to get new msg after folder is loaded
  854.                  */
  855. #ifdef USE_3PANE
  856.                     XFE_ThreadView *t_view = (XFE_ThreadView*)( 
  857.                             ((XFE_ThreePaneView*)(theFrame->getView()))->getThreadView());
  858.                 t_view->setGetNewMsg(True);
  859. #else
  860.                 ((XFE_ThreadView*)(theFrame->getView()))->setGetNewMsg(True);                
  861. #endif
  862.  
  863.             }
  864.         }/* if */
  865.  
  866.     D(    printf ("leaving fe_showThread()\n");)
  867.  
  868.     return theFrame->getContext();
  869. }
  870.  
  871. XP_Bool
  872. XFE_ThreadFrame::isCommandEnabled(CommandType cmd,
  873.                                    void *calldata, XFE_CommandInfo*)
  874. {
  875.     if (cmd == xfeCmdToggleLocationToolbar)
  876.         return True;
  877.     else if (cmd == xfeCmdToggleKilledThreads)
  878.         return True;
  879.     else if (cmd == xfeCmdCleanUpDisk)
  880.         return True;
  881.     else
  882.         return XFE_Frame::isCommandEnabled(cmd, calldata);
  883. }
  884.  
  885. void
  886. XFE_ThreadFrame::doCommand(CommandType cmd,
  887.                             void *calldata, XFE_CommandInfo* info)
  888. {
  889.     if (cmd == xfeCmdToggleLocationToolbar)
  890.     {
  891.         if (m_banner)
  892.         {
  893.             // Toggle the showing state
  894.             m_banner->toggle();
  895.             
  896.             // Configure the logo
  897.             configureLogo();
  898.             
  899.             // Do the attachments
  900.             doAttachments();
  901.             
  902.             // Update prefs
  903.             toolboxItemChangeShowing(m_banner);
  904.  
  905.             // Update chrome
  906.             notifyInterested(XFE_View::chromeNeedsUpdating);
  907.         }
  908.  
  909.         return;
  910.     } else if ( (cmd == xfeCmdComposeMessage) ||
  911.         (cmd == xfeCmdComposeMessagePlain) ||
  912.         (cmd == xfeCmdComposeMessageHTML) || 
  913.         (cmd == xfeCmdComposeArticle) ||
  914.         (cmd == xfeCmdComposeArticlePlain) ||
  915.         (cmd == xfeCmdComposeArticleHTML) )
  916.         
  917.     {
  918.         m_view->doCommand(cmd, calldata,info);    
  919.     }
  920.     else
  921.         XFE_Frame::doCommand(cmd, calldata, info);
  922. }
  923.  
  924. XP_Bool
  925. XFE_ThreadFrame::handlesCommand(CommandType cmd,
  926.                  void *calldata, XFE_CommandInfo*)
  927. {
  928.     if (cmd == xfeCmdToggleLocationToolbar)
  929.         return True;
  930.     else
  931.         return XFE_Frame::handlesCommand(cmd, calldata);
  932. }
  933.  
  934. char *
  935. XFE_ThreadFrame::commandToString(CommandType cmd,
  936.                                   void *calldata, XFE_CommandInfo*)
  937. {
  938.     if (cmd == xfeCmdToggleLocationToolbar)
  939.     {
  940.         char *res = NULL;
  941.         
  942.         if (m_banner->isShown())
  943.             res = "hideLocationToolbarCmdString";
  944.         else
  945.             res = "showLocationToolbarCmdString";
  946.         
  947.         return stringFromResource(res);
  948.     }
  949.     else
  950.     {
  951.         return XFE_Frame::commandToString(cmd, calldata);
  952.     }
  953. }
  954.  
  955. #undef DEBUG_dora
  956.  
  957. int
  958. XFE_ThreadFrame::getSecurityStatus()
  959. {
  960.  XP_Bool is_signed = False;
  961.  XP_Bool is_encrypted = False;
  962. #ifdef USE_3PANE
  963.  XFE_ThreadView *tview = (XFE_ThreadView*)(
  964.             ((XFE_ThreePaneView*)m_view)->getThreadView());
  965. #else
  966.  XFE_ThreadView *tview = (XFE_ThreadView*)m_view;
  967. #endif
  968.  
  969.  XFE_MailSecurityStatusType status = XFE_UNSECURE_UNSIGNED;  // Choose a safe default.
  970.  
  971. #ifdef DEBUG_dora
  972.  printf("XFE_ThreadFrame::getSecurityStatus\n");
  973. #endif
  974.  
  975.  MIME_GetMessageCryptoState(m_context, 0, 0, &is_signed, &is_encrypted);
  976.  
  977.  if (tview && tview->isDisplayingNews() )
  978.  {
  979.    // If this is displaying news, we decide if a newsgroup is secure(encrypted)
  980.    // or not by checking the security status ...instead of the crypto state
  981.  
  982. #ifdef DEBUG_dora
  983.     printf("News Thread Frame context...\n");
  984. #endif
  985.     is_encrypted = XFE_Frame::getSecurityStatus() == XFE_SECURE;
  986.  }
  987.  
  988.  if (is_encrypted && is_signed )
  989.  {
  990. #ifdef DEBUG_dora
  991.      printf("signed and encrypted %d\n", XFE_SECURE_SIGNED);
  992. #endif
  993.      status = XFE_SECURE_SIGNED;
  994.  }
  995.  else if (!is_encrypted && is_signed)
  996.  {
  997. #ifdef DEBUG_dora
  998.      printf("signed and NO encrypted %d\n", XFE_UNSECURE_SIGNED);
  999. #endif
  1000.      status = XFE_UNSECURE_SIGNED;
  1001.  }
  1002.  else if (is_encrypted && !is_signed)
  1003.  {
  1004. #ifdef DEBUG_dora
  1005.      printf("NO signed and  encrypted %d\n", XFE_SECURE_UNSIGNED);
  1006. #endif
  1007.      status = XFE_SECURE_UNSIGNED;
  1008.  }
  1009.  else if (!is_encrypted && !is_signed )
  1010.  {
  1011. #ifdef DEBUG_dora
  1012.      printf("NO signed and  NO encrypted %d\n", XFE_UNSECURE_UNSIGNED);
  1013. #endif
  1014.      status = XFE_UNSECURE_UNSIGNED;
  1015.  } else {
  1016.      // Error.  Play it safe, go unsecure.
  1017.      XP_ASSERT(0);
  1018.      status = XFE_UNSECURE_UNSIGNED;
  1019.  }
  1020.  
  1021.  return status;
  1022. }
  1023.  
  1024.  
  1025. //////////////////////////////////////////////////////////////////////////
  1026. //
  1027. // Toolbox methods
  1028. //
  1029. //////////////////////////////////////////////////////////////////////////
  1030. void
  1031. XFE_ThreadFrame::toolboxItemSnap(XFE_ToolboxItem * item)
  1032. {
  1033.     XP_ASSERT( item == m_toolbar || item == m_banner );
  1034.  
  1035.     // Navigation
  1036.     fe_globalPrefs.messages_navigation_toolbar_position = m_toolbar->getPosition();
  1037.  
  1038.     // Location
  1039.     fe_globalPrefs.messages_location_toolbar_position = m_banner->getPosition();
  1040. }
  1041. //////////////////////////////////////////////////////////////////////////
  1042. void
  1043. XFE_ThreadFrame::toolboxItemClose(XFE_ToolboxItem * item)
  1044. {
  1045.     XP_ASSERT( item != NULL );
  1046.  
  1047.     // Navigation
  1048.     if (item == m_toolbar)
  1049.     {
  1050.         fe_globalPrefs.messages_navigation_toolbar_open = False;
  1051.     }
  1052.     // Location
  1053.     else if (item == m_banner)
  1054.     {
  1055.         fe_globalPrefs.messages_location_toolbar_open = False;
  1056.     }
  1057. }
  1058. //////////////////////////////////////////////////////////////////////////
  1059. void
  1060. XFE_ThreadFrame::toolboxItemOpen(XFE_ToolboxItem * item)
  1061. {
  1062.     XP_ASSERT( item != NULL );
  1063.  
  1064.     // Navigation
  1065.     if (item == m_toolbar)
  1066.     {
  1067.         fe_globalPrefs.messages_navigation_toolbar_open = True;
  1068.     }
  1069.     // Location
  1070.     else if (item == m_banner)
  1071.     {
  1072.         fe_globalPrefs.messages_location_toolbar_open = True;
  1073.     }
  1074. }
  1075. //////////////////////////////////////////////////////////////////////////
  1076. void
  1077. XFE_ThreadFrame::toolboxItemChangeShowing(XFE_ToolboxItem * item)
  1078. {
  1079.     XP_ASSERT( item != NULL );
  1080.  
  1081.     // Navigation
  1082.     if (item == m_toolbar)
  1083.     {
  1084.         fe_globalPrefs.messages_navigation_toolbar_showing = item->isShown();
  1085.     }
  1086.     // Location
  1087.     else if (item == m_banner)
  1088.     {
  1089.         fe_globalPrefs.messages_location_toolbar_showing = item->isShown();
  1090.     }
  1091. }
  1092. //////////////////////////////////////////////////////////////////////////
  1093. void
  1094. XFE_ThreadFrame::configureToolbox()
  1095. {
  1096.     // If a the frame was constructed with a chromespec, then we ignore
  1097.     // all the preference magic.
  1098.     if (m_chromespec_provided)
  1099.     {
  1100.         return;
  1101.     }
  1102.  
  1103.     // Make sure the toolbox is alive
  1104.     if (!m_toolbox || (m_toolbox && !m_toolbox->isAlive()))
  1105.     {
  1106.         return;
  1107.     }
  1108.  
  1109.     // Navigation
  1110.     if (m_toolbar)
  1111.     {
  1112.         m_toolbar->setShowing(fe_globalPrefs.messages_navigation_toolbar_showing);
  1113.         m_toolbar->setOpen(fe_globalPrefs.messages_navigation_toolbar_open);
  1114.         m_toolbar->setPosition(fe_globalPrefs.messages_navigation_toolbar_position);
  1115.     }
  1116.  
  1117.     // Location
  1118.     if (m_banner)
  1119.     {
  1120.         m_banner->setShowing(fe_globalPrefs.messages_location_toolbar_showing);
  1121.         m_banner->setOpen(fe_globalPrefs.messages_location_toolbar_open);
  1122.         m_banner->setPosition(fe_globalPrefs.messages_location_toolbar_position);
  1123.     }
  1124. }
  1125.  
  1126.  
  1127. XP_Bool
  1128. XFE_ThreadFrame::isOkToClose()
  1129. {
  1130.    Boolean haveQueuedMail = False;
  1131. #ifdef USE_3PANE
  1132.    XFE_ThreadView *tview = (XFE_ThreadView*)(
  1133.             ((XFE_ThreePaneView*)m_view)->getThreadView());
  1134. #else
  1135.    XFE_ThreadView *tview = (XFE_ThreadView*)m_view;
  1136. #endif
  1137.  
  1138.    if ( XFE_MozillaApp::theApp()->mailNewsWindowCount() == 1 )
  1139.    {
  1140.        MSG_CommandStatus(tview->getPane(), MSG_DeliverQueuedMessages, NULL, 0,
  1141.         &haveQueuedMail, NULL, NULL, NULL );
  1142.         
  1143.        if (haveQueuedMail) {
  1144.           void * sendNow = 0;
  1145.           const char *buf =  XP_GetString (XFE_SEND_UNSENTMAIL);
  1146.           sendNow = fe_dialog (CONTEXT_WIDGET(m_context),
  1147.                                  "sendNow", buf, TRUE, 0, TRUE, FALSE, 0);
  1148.           if (sendNow) {
  1149.             MSG_Command (tview->getPane(), MSG_DeliverQueuedMessages, NULL, 0);
  1150.             return False;
  1151.           }
  1152.         }
  1153.  
  1154. #ifdef CLEAN_UP_NEWS
  1155.     // This works, but is commented out because it's annoying:
  1156.     // MSG_CleanupNeeded() always returns true, even if you haven't
  1157.     // read news at all in this session, so the user has to sit
  1158.     // and wait for the cleanup dialog every time he exits.
  1159.  
  1160. #ifdef DEBUG_akkana
  1161.     printf("ThreadFrame: Checking whether cleanup is needed\n");
  1162. #endif
  1163.  
  1164.     // See if we need to clean up based on disk space prefs
  1165.     if (MSG_CleanupNeeded(tview->getMaster()))
  1166.     {
  1167. #ifdef DEBUG_akkana
  1168.         printf("\07Cleaning up\n");
  1169. #endif
  1170.         // create progress pane
  1171.         XFE_MailDownloadFrame* progressFrame = 
  1172.             new XFE_MailDownloadFrame(XfeAncestorFindApplicationShell(getBaseWidget()),
  1173.                                       this,
  1174.                                       tview->getPane());
  1175.         progressFrame->cleanUpNews();
  1176.         return True;
  1177.     }
  1178. #endif /* CLEAN_UP_NEWS */
  1179.    }
  1180.  
  1181.    return True;
  1182. }
  1183.  
  1184. XFE_CALLBACK_DEFN(XFE_ThreadFrame,showFolder)(XFE_NotificationCenter *,
  1185.                                  void *, void* cd)
  1186. {
  1187.   XP_Bool showFolder = (XP_Bool)((int32)cd);
  1188.  
  1189.   XP_ASSERT(m_banner!= NULL);
  1190.  
  1191.   printf("threadframe...showFolder\n");
  1192.   m_banner->setShowFolder(showFolder);
  1193.  
  1194. }
  1195.  
  1196. //////////////////////////////////////////////////////////////////////////
  1197.