home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / prefs / MailNewsMediators.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  10.6 KB  |  389 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. #include "CPrefsMediator.h"
  22.  
  23. #include "MPreference.h"
  24.  
  25. #include <LGADialogBox.h>
  26.  
  27. class CTSMEditField;
  28. class LGACheckbox;
  29. class MSG_IMAPHost;
  30. class MSG_Host;
  31. class CDragOrderTextList;
  32.  
  33. //======================================
  34. #pragma mark
  35. class CMailNewsIdentityMediator : public CPrefsMediator
  36. //======================================
  37. {
  38.     private:
  39.         typedef CPrefsMediator Inherited;
  40.         
  41.     public:
  42.  
  43.         enum { class_ID = PrefPaneID::eMailNews_Identity };
  44.         CMailNewsIdentityMediator(LStream*);
  45.         virtual    ~CMailNewsIdentityMediator() {};
  46.  
  47.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  48.  
  49. //        virtual    void    UpdateFromIC();    // don't need this because the IC checkbox is on
  50.                                         // this pane
  51.         virtual    void    LoadPrefs();
  52. };
  53.  
  54. #ifdef MOZ_MAIL_NEWS
  55.  
  56. //======================================
  57. #pragma mark
  58. class CMailNewsMessagesMediator : public CPrefsMediator
  59. //======================================
  60. {
  61.     private:
  62.         typedef CPrefsMediator Inherited;
  63.         
  64.     public:
  65.  
  66.         enum { class_ID = PrefPaneID::eMailNews_Messages };
  67.         CMailNewsMessagesMediator(LStream*);
  68.         virtual    ~CMailNewsMessagesMediator() {}
  69.  
  70.         virtual    void    LoadMainPane();
  71.  
  72.         static Boolean WrapLinesValidationFunc(CValidEditField *wrapLines);
  73. };
  74.  
  75. //======================================
  76. #pragma mark
  77. class CMailNewsOutgoingMediator : public CPrefsMediator
  78. //======================================
  79. {
  80.     private:
  81.         typedef CPrefsMediator Inherited;
  82.         
  83.     public:
  84.  
  85.         enum { class_ID = PrefPaneID::eMailNews_Outgoing };
  86.         CMailNewsOutgoingMediator(LStream*);
  87.         virtual    ~CMailNewsOutgoingMediator();
  88.         virtual    void    LoadPrefs();
  89.         virtual    void    WritePrefs();
  90.         virtual void    ListenToMessage(MessageT inMessage, void* ioParam);
  91.     protected:
  92. #define kNumFolderKinds 4
  93.         char*            mFolderURL[kNumFolderKinds];
  94. }; // class CMailNewsOutgoingMediator
  95.  
  96. //======================================
  97. #pragma mark
  98. class MServerListMediatorMixin
  99. // Common code for a pane containing a list of servers
  100. //======================================
  101. {
  102. protected:
  103.     MServerListMediatorMixin(CPrefsMediator* inMediatorSelf)
  104.     :    mMediatorSelf(inMediatorSelf)
  105.     ,    mServerTable(nil)
  106.     ,    mServersLocked(false)
  107.     ,    mServersDirty(false)
  108.      {}
  109.  
  110.         struct CellContents
  111.         {
  112.             CellContents(const char* inName = nil);
  113.             Str255            description;
  114.         };
  115.  
  116.                 Boolean GetHostFromRow(
  117.                             TableIndexT inRow,
  118.                             CellContents& outCellData,
  119.                             UInt32 inDataSize) const;
  120.                 Boolean GetHostFromSelectedRow(
  121.                             CellContents& outCellData,
  122.                             UInt32 inDataSize) const;
  123.         virtual    void    UpdateButtons();
  124.         virtual    void    AddButton() = 0;
  125.         virtual    void    EditButton() = 0;
  126.         virtual    void    DeleteButton() = 0;
  127.                 void    ClearList();
  128.         virtual    void    LoadList() = 0;
  129.         virtual    void    WriteList() = 0;
  130.         virtual Boolean    Listen(MessageT inMessage, void *ioParam);
  131.                 void    LoadMainPane();
  132.  
  133.     CPrefsMediator*     mMediatorSelf;
  134.     CDragOrderTextList*    mServerTable;
  135.     Boolean                mServersLocked;
  136.     Boolean                mServersDirty;
  137. }; // class MServerListMediatorMixin
  138.  
  139. //======================================
  140. #pragma mark
  141. class CServerListMediator
  142. //======================================
  143. :    public CPrefsMediator
  144. ,    public MServerListMediatorMixin
  145. {
  146.     public:
  147.                         CServerListMediator(PaneIDT inMainPaneID);
  148.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  149.         virtual    void    LoadMainPane();
  150. };
  151.  
  152. //======================================
  153. #pragma mark
  154. class CMailNewsMailServerMediator
  155. //======================================
  156. :    public CServerListMediator
  157. {
  158.     private:
  159.         typedef CServerListMediator Inherited;
  160.         
  161.     public:
  162.  
  163.         enum { class_ID = PrefPaneID::eMailNews_MailServer };
  164.         CMailNewsMailServerMediator(LStream*);
  165.         virtual    ~CMailNewsMailServerMediator();
  166.  
  167.         virtual    void    UpdateFromIC();
  168.         virtual    void    LoadMainPane();
  169.         virtual    void    LoadPrefs();
  170.         virtual    void    WritePrefs();
  171.  
  172.         static Boolean NoAtSignValidationFunc(CValidEditField *noAtSign);
  173.  
  174.     private:
  175.         enum ServerType
  176.         {
  177.             eUnknownServerType = -1,
  178.             ePOPServer = 0,
  179.             eIMAPServer = 1
  180.         };
  181.                 MSG_IMAPHost*    FindMSG_Host(const char* inHostName);
  182.                 Boolean    UsingPop() const; // Hope this goes away.
  183.  
  184.     // MServerListMediatorMixin overrides
  185.         virtual    void    AddButton();
  186.         virtual    void    EditButton();
  187.         virtual    void    DeleteButton();
  188.         virtual    void    LoadList();
  189.         virtual    void    WriteList();
  190.  
  191.     // Data
  192.     protected:
  193.         ServerType        mServerType;
  194.         char*            mPopServerName;
  195. }; // class CMailNewsMailServerMediator
  196.  
  197. #pragma mark
  198. //======================================
  199. class CMailNewsNewsServerMediator
  200. //======================================
  201. :    public CServerListMediator
  202. {
  203.     private:
  204.         typedef CServerListMediator Inherited;
  205.         
  206.     public:
  207.  
  208.         enum { class_ID = PrefPaneID::eMailNews_NewsServer };
  209.         CMailNewsNewsServerMediator(LStream*);
  210.         virtual    ~CMailNewsNewsServerMediator() {};
  211.  
  212.         virtual    void    UpdateFromIC();
  213.         virtual    void    LoadPrefs();
  214.         virtual    void    WritePrefs();
  215.         static Boolean    PortNumberValidationFunc(CValidEditField *portNumber);
  216.  
  217.     // MServerListMediatorMixin overrides
  218.         struct CellContents : public MServerListMediatorMixin::CellContents
  219.         {
  220.             CellContents() {}
  221.             CellContents(const char* inName, MSG_Host* inHost)
  222.             :    MServerListMediatorMixin::CellContents(inName)
  223.             ,    serverData(inHost) {}
  224.             MSG_Host*    serverData;
  225.         };
  226.         virtual    void    AddButton();
  227.         virtual    void    EditButton();
  228.         virtual    void    DeleteButton();
  229.         virtual    void    LoadList();
  230.         virtual    void    WriteList();
  231.  
  232.     enum
  233.     {
  234.         eNNTPStandardPort    = 119,
  235.         eNNTPSecurePort    = 563
  236.     };
  237.  
  238.     private:
  239.         Boolean    mNewsServerPortLocked;
  240. }; // class CMailNewsNewsServerMediator
  241.  
  242. struct DIR_Server;
  243. class LTextColumn;
  244. //======================================
  245. #pragma mark
  246. class CMailNewsDirectoryMediator
  247. //======================================
  248. :    public CServerListMediator
  249. {
  250.     private:
  251.         typedef CServerListMediator Inherited;
  252.         
  253.     public:
  254.  
  255.         enum { class_ID = PrefPaneID::eMailNews_Directory };
  256.         CMailNewsDirectoryMediator(LStream*);
  257.         virtual    ~CMailNewsDirectoryMediator() {};
  258.  
  259.         virtual    void    LoadMainPane();
  260.         virtual    void    LoadPrefs();
  261.         virtual    void    WritePrefs();
  262.  
  263.         virtual Boolean    ObeyCommand ( CommandT inCommand, void* ioParam );
  264.         
  265.     private:
  266.     // MServerListMediatorMixin overrides
  267.         virtual    void    AddButton();
  268.         virtual    void    EditButton();
  269.         virtual    void    DeleteButton();
  270.         virtual    void    LoadList();
  271.         virtual    void    WriteList();
  272.  
  273.         virtual    void    UpdateButtons();
  274.                 Boolean    IsPABServerSelected(LTextColumn *serverTable = nil);
  275.                 Boolean    IsPABServerSelected(DIR_Server *server);
  276.         struct CellContents : public MServerListMediatorMixin::CellContents
  277.         {
  278.             CellContents(const char* inName = nil)
  279.             :    MServerListMediatorMixin::CellContents(inName)
  280.             ,    serverData(nil) {}
  281.             DIR_Server    *serverData;
  282.         };
  283.         XP_List    *mDeletedServerList;
  284. }; // class CMailNewsDirectoryMediator
  285.  
  286. //======================================
  287. #pragma mark
  288. class COfflineNewsMediator : public CPrefsMediator
  289. //======================================
  290. {
  291.     private:
  292.         typedef CPrefsMediator Inherited;
  293.         
  294.     public:
  295.  
  296.         enum { class_ID = PrefPaneID::eOffline_News };
  297.         COfflineNewsMediator(LStream*);
  298.         virtual    ~COfflineNewsMediator() {};
  299.  
  300.         virtual    void    LoadMainPane();
  301.         virtual    void    WritePrefs();
  302.  
  303.         static Boolean    SinceDaysValidationFunc(CValidEditField *sinceDays);
  304. }; // class COfflineNewsMediator
  305.  
  306. //======================================
  307. class CLDAPServerPropDialog : public LGADialogBox
  308. // This class brings up a dialog for editing the LDAP Server properties (duh). This has 
  309. // to be a derivative of LGADialogBox and not just a normal stack-based dialog because
  310. // we want NetHelp to actually get the message to load the help URL while the dialog is up,
  311. // not after you close it, and the stack-based dialogs never returned to the event loop
  312. // to allow the url processing.
  313. //
  314. // The dialog passes the OK/Cancel messages through to the preference pane so the pane can
  315. // handle doing the right thing and close out the dialog. They should be handled in 
  316. // ObeyCommand()
  317. //======================================
  318. {
  319.     typedef LGADialogBox Inherited;
  320.  
  321.     public:
  322.         
  323.         // PUBLIC CONSTANTS
  324.         
  325.         enum {
  326.             class_ID = 'LDSP',
  327.             eLDAPServerPropertiesDialogResID = 12002,
  328.             cmd_OKButton = -128,
  329.             cmd_CancelButton = -129,
  330.             cmd_HelpButton = 3
  331.         };
  332.         
  333.         enum { eEditServer = false, eNewServer = true } ;
  334.  
  335.         // PUBLIC METHODS
  336.         
  337.         CLDAPServerPropDialog ( LStream* inStream );
  338.         virtual ~CLDAPServerPropDialog() ;
  339.         
  340.         virtual void FinishCreateSelf();
  341.         virtual void ListenToMessage ( MessageT inMessage, void* ioParam );
  342.         
  343.         void SetUpDialog( DIR_Server* inServer, Boolean inNew, Boolean inIsPAB, 
  344.                             Boolean inIsAllLocked );
  345.         DIR_Server* GetServer ( ) { return mServer; } ;
  346.         Boolean IsEditingNewServer ( ) { return mNewServer; } ;
  347.         
  348.     protected:
  349.     
  350.         // Port ID's
  351.         enum {
  352.             eLDAPStandardPort = 389,
  353.             eLDAPSecurePort = 636
  354.         };
  355.  
  356.         // Pane ID's for dialog
  357.         enum {
  358.             eDescriptionEditField = 10,
  359.             eLDAPServerEditField,
  360.             eSearchRootEditField,
  361.             ePortNumberEditField,
  362.             eMaxHitsEditField,
  363.             eSecureBox = 20,
  364.             eSaveLDAPServerPasswordBox = 21,
  365.             eUpdateButton = 22,
  366.             eDownloadCheckBox = 23
  367.         };
  368.         
  369.         static Boolean MaxHitsValidationFunc(CValidEditField *maxHits) ;
  370.         static Boolean PortNumberValidationFunc(CValidEditField *portNumber) ;
  371.  
  372.         const char* mHelpTopic;            // help string for NetHelp
  373.         DIR_Server* mServer;        // the LDAP server
  374.         Boolean mNewServer;            // true if a new entry, false if editing existing
  375.         Boolean mIsPAB;                // ???
  376.         
  377.         CTSMEditField* mDescription;        // Items in dialog
  378.         LEditField* mLdapServer;
  379.         LEditField* mSearchRoot;
  380.         CValidEditField* mPortNumber;
  381.         CValidEditField* mMaxHits;
  382.         LGACheckbox* mSecureBox;
  383.         LGACheckbox* mSavePasswordBox;
  384.         LGACheckbox* mDownloadCheckBox;
  385.         
  386. }; // class CLDAPServerPropDialog
  387.  
  388. #endif // MOZ_MAIL_NEWS
  389.