home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / prefs / CMailNewsMainMediator.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  4.1 KB  |  148 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 MOZ_LITE
  20.  
  21. #include "CMailNewsMainMediator.h"
  22.  
  23. #include "xp_help.h"
  24. #include "prefapi.h"
  25. #include "macgui.h"
  26.  
  27. #include "PascalString.h"
  28. #include "StSetBroadcasting.h"
  29. #include <LGACheckbox.h>
  30.  
  31. enum
  32. {
  33.     eQuoteStylePopup                = 12601
  34. ,    eQuoteSizePopup
  35. ,    eQuoteColorButton
  36. ,    eFixedRButton
  37. ,    eVariableRButton
  38.  
  39. ,    eLocalMailDirFilePicker            = 12910
  40. ,    eCheckForMailBox                = 12912
  41. ,    eCheckForMailIntervalEditField    = 12913
  42. ,    eNotificatonSoundPopup            = 12914
  43. ,    eRememberPasswordBox            = 12915
  44. };
  45.  
  46. //-----------------------------------
  47. CMailNewsMainMediator::CMailNewsMainMediator(LStream*)
  48. //-----------------------------------
  49. :    CPrefsMediator(class_ID)
  50. {
  51. }
  52.  
  53. //-----------------------------------
  54. CMailNewsMainMediator::~CMailNewsMainMediator()
  55. //-----------------------------------
  56. {
  57. }
  58.  
  59. //-----------------------------------
  60. void CMailNewsMainMediator::ListenToMessage(MessageT inMessage, void *ioParam)
  61. //-----------------------------------
  62. {
  63.     switch (inMessage)
  64.     {
  65.         case eNotificatonSoundPopup:
  66.             LGAPopup *soundMenu =
  67.                     (LGAPopup *)FindPaneByID(eNotificatonSoundPopup);
  68.             int    menuItem = soundMenu->GetValue();
  69.             MenuHandle    soundMenuH = soundMenu->GetMacMenuH();
  70.             CStr255    stringResName;
  71.             if (menuItem > 2)
  72.                 GetMenuItemText(soundMenuH, menuItem, stringResName);
  73.             if (stringResName[0])
  74.             {
  75.                 SndListHandle soundH =
  76.                     (SndListHandle)GetNamedResource('snd ', stringResName);
  77.                 if (soundH)
  78.                 {
  79.                     ::DetachResource((Handle)soundH);
  80.                     SndPlay(nil, soundH, false);
  81.                     DisposeHandle((Handle)soundH);
  82.                 }
  83.             }
  84.             break;
  85.         default:
  86.             CPrefsMediator::ListenToMessage(inMessage, ioParam);
  87.             break;
  88.     }
  89. }
  90.  
  91. //-----------------------------------
  92. void CMailNewsMainMediator::WritePrefs()
  93. //-----------------------------------
  94. {
  95.     if (!PaneHasLockedPref(eNotificatonSoundPopup) && !PREF_PrefIsLocked("mail.play_sound"))
  96.     {
  97.         char* soundName = nil;
  98.         LControl* popup = (LControl*)FindPaneByID(eNotificatonSoundPopup);
  99.         XP_Bool    playSound = popup->GetValue() != 0;
  100.         PREF_SetBoolPref("mail.play_sound", playSound);
  101.     }
  102. } // CMailNewsMainMediator::WritePrefs
  103.  
  104. //-----------------------------------
  105. Boolean CMailNewsMainMediator::BiffIntervalValidationFunc(CValidEditField *biffInterval)
  106. //-----------------------------------
  107. {
  108.     // If the checkbox isn't set then this value is really
  109.     // ignored, so I will only put up the alert if the checkbox
  110.     // is set, but I will force a valid value in any case.
  111.  
  112.     Boolean        result = true;
  113.  
  114.     // force valid value
  115.     if (1 > biffInterval->GetValue())
  116.     {
  117.         int32    newInterval = 10;
  118.         PREF_GetDefaultIntPref("mail.check_time", &newInterval);
  119.         biffInterval->SetValue(newInterval);
  120.         biffInterval->SelectAll();
  121.         result = false;
  122.     }
  123.     if (!result)    // if the value is within the range, who cares
  124.     {
  125.         // Check for the check box...
  126.         // We are assuming that the checkbox is a sub of the field's superview.
  127.         LView    *superView = biffInterval->GetSuperView();
  128.         XP_ASSERT(superView);
  129.         LGACheckbox    *checkbox =
  130.                 (LGACheckbox *)superView->FindPaneByID(eCheckForMailBox);
  131.         XP_ASSERT(checkbox);
  132.         if (checkbox->GetValue())
  133.         {
  134.             StPrepareForDialog    prepare;
  135.             ::StopAlert(1067, NULL);
  136.         }
  137.         else
  138.         {
  139.             result = true;    // go ahead and let them switch (after correcting the value)
  140.                             // if the checkbox isn't set
  141.         }
  142.     }
  143.     return result;
  144. }
  145.  
  146. #endif // MOZ_LITE
  147.  
  148.