LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/config - mailconfigpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 236 0.0 %
Date: 2013-07-09 Functions: 0 33 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <swtypes.hxx>
      21             : #include <mailconfigpage.hxx>
      22             : #include <svtools/svmedit.hxx>
      23             : #include <svtools/stdctrl.hxx>
      24             : #include <svtools/svtabbx.hxx>
      25             : #include <svtools/headbar.hxx>
      26             : #include <mmconfigitem.hxx>
      27             : #include <mailmergehelper.hxx>
      28             : #include <cmdid.h>
      29             : #include <vcl/svapp.hxx>
      30             : #include <comphelper/processfactory.hxx>
      31             : #include "com/sun/star/mail/MailServiceType.hpp"
      32             : #include "com/sun/star/mail/XMailService.hpp"
      33             : #include "com/sun/star/mail/MailServiceProvider.hpp"
      34             : #include <vcl/msgbox.hxx>
      35             : #include <globals.hrc>
      36             : #include <mailconfigpage.hrc>
      37             : #include <config.hrc>
      38             : #include <helpid.h>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::lang;
      42             : using namespace ::com::sun::star::mail;
      43             : using namespace ::com::sun::star::beans;
      44             : 
      45             : class SwTestAccountSettingsDialog : public SfxModalDialog
      46             : {
      47             :     FixedInfo           m_aInfoFI;
      48             : 
      49             :     HeaderBar           m_aStatusHB;
      50             :     SvTabListBox        m_aStatusLB;
      51             : 
      52             :     FixedInfo           m_aErrorFI;
      53             :     MultiLineEdit       m_eErrorsED;
      54             : 
      55             :     FixedLine           m_aSeparatorFL;
      56             :     PushButton          m_aStopPB;
      57             :     CancelButton        m_aCancelPB;
      58             :     HelpButton          m_aHelpPB;
      59             : 
      60             :     ImageList           m_aImageList;
      61             : 
      62             :     String              m_sTask        ;
      63             :     String              m_sStatus      ;
      64             :     String              m_sEstablish   ;
      65             :     String              m_sFindServer  ;
      66             :     String              m_sCompleted   ;
      67             :     String              m_sFailed      ;
      68             :     String              m_sErrorNetwork;
      69             :     String              m_sErrorServer ;
      70             : 
      71             :     SwMailConfigPage*   m_pParent;
      72             : 
      73             :     bool                m_bStop;
      74             : 
      75             :     void                Test();
      76             :     DECL_LINK(StopHdl, void *);
      77             :     DECL_STATIC_LINK(SwTestAccountSettingsDialog, TestHdl, void*);
      78             : public:
      79             :     SwTestAccountSettingsDialog(SwMailConfigPage* pParent);
      80             :     ~SwTestAccountSettingsDialog();
      81             : };
      82             : 
      83             : class SwAuthenticationSettingsDialog : public SfxModalDialog
      84             : {
      85             :     CheckBox        m_aAuthenticationCB;
      86             : 
      87             :     RadioButton     m_aSeparateAuthenticationRB;
      88             :     RadioButton     m_aSMTPAfterPOPRB;
      89             : 
      90             :     FixedInfo       m_aOutgoingServerFT;
      91             :     FixedText       m_aUserNameFT;
      92             :     Edit            m_aUserNameED;
      93             :     FixedText       m_aOutPasswordFT;
      94             :     Edit            m_aOutPasswordED;
      95             : 
      96             :     FixedInfo       m_aIncomingServerFT;
      97             :     FixedText       m_aServerFT;
      98             :     Edit            m_aServerED;
      99             :     FixedText       m_aPortFT;
     100             :     NumericField    m_aPortNF;
     101             :     FixedText       m_aProtocolFT;
     102             :     RadioButton     m_aPOP3RB;
     103             :     RadioButton     m_aIMAPRB;
     104             :     FixedText       m_aInUsernameFT;
     105             :     Edit            m_aInUsernameED;
     106             :     FixedText       m_aInPasswordFT;
     107             :     Edit            m_aInPasswordED;
     108             : 
     109             :     FixedLine       m_aSeparatorFL;
     110             : 
     111             :     OKButton        m_aOKPB;
     112             :     CancelButton    m_aCancelPB;
     113             :     HelpButton      m_aHelpPB;
     114             : 
     115             :     SwMailMergeConfigItem& rConfigItem;
     116             : 
     117             :     DECL_LINK(OKHdl_Impl, void *);
     118             :     DECL_LINK( CheckBoxHdl_Impl, CheckBox*);
     119             :     DECL_LINK(RadioButtonHdl_Impl, void *);
     120             : 
     121             : 
     122             : public:
     123             :     SwAuthenticationSettingsDialog(SwMailConfigPage* pParent, SwMailMergeConfigItem& rItem);
     124             :     ~SwAuthenticationSettingsDialog();
     125             : };
     126             : 
     127           0 : SwMailConfigPage::SwMailConfigPage( Window* pParent, const SfxItemSet& rSet ) :
     128             :     SfxTabPage(pParent, SW_RES(TP_MAILCONFIG), rSet),
     129             : #ifdef _MSC_VER
     130             : #pragma warning (disable : 4355)
     131             : #endif
     132             :     m_aIdentityFL( this, SW_RES(       FL_IDENTITY)),
     133             :     m_aDisplayNameFT( this, SW_RES(    FT_DISPLAYNAME)),
     134             :     m_aDisplayNameED( this, SW_RES(    ED_DISPLAYNAME)),
     135             :     m_aAddressFT( this, SW_RES(        FT_ADDRESS)),
     136             :     m_aAddressED( this, SW_RES(        ED_ADDRESS)),
     137             :     m_aReplyToCB( this, SW_RES(        CB_REPLYTO)),
     138             :     m_aReplyToFT( this, SW_RES(        FT_REPLYTO)),
     139             :     m_aReplyToED( this, SW_RES(        ED_REPLYTO)),
     140             :     m_aSMTPFL( this, SW_RES(           FL_SMTP)),
     141             :     m_aServerFT( this, SW_RES(         FT_SERVER)),
     142             :     m_aServerED( this, SW_RES(         ED_SERVER)),
     143             :     m_aPortFT( this, SW_RES(           FT_PORT)),
     144             :     m_aPortNF( this, SW_RES(           NF_PORT)),
     145             :     m_aSecureCB( this, SW_RES(         CB_SECURE)),
     146             :     m_aServerAuthenticationPB( this, SW_RES( PB_AUTHENTICATION )),
     147             :     m_aSeparatorFL( this,            SW_RES( FL_SEPARATOR      )),
     148             :     m_aTestPB( this, SW_RES(           PB_TEST)),
     149             : #ifdef _MSC_VER
     150             : #pragma warning (default : 4355)
     151             : #endif
     152           0 :     m_pConfigItem( new SwMailMergeConfigItem )
     153             : {
     154           0 :     FreeResource();
     155           0 :     m_aReplyToCB.SetClickHdl(LINK(this, SwMailConfigPage, ReplyToHdl));
     156           0 :     m_aServerAuthenticationPB.SetClickHdl(LINK(this, SwMailConfigPage, AuthenticationHdl));
     157           0 :     m_aTestPB.SetClickHdl(LINK(this, SwMailConfigPage, TestHdl));
     158           0 : }
     159             : 
     160           0 : SwMailConfigPage::~SwMailConfigPage()
     161             : {
     162           0 :     delete m_pConfigItem;
     163           0 : }
     164             : 
     165           0 : SfxTabPage*  SwMailConfigPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
     166             : {
     167           0 :     return new SwMailConfigPage(pParent, rAttrSet);
     168             : }
     169             : 
     170           0 : sal_Bool SwMailConfigPage::FillItemSet( SfxItemSet& /*rSet*/ )
     171             : {
     172           0 :     if(m_aDisplayNameED.GetText() != m_aDisplayNameED.GetSavedValue())
     173           0 :         m_pConfigItem->SetMailDisplayName(m_aDisplayNameED.GetText());
     174           0 :     if(m_aAddressED.GetText() != m_aAddressED.GetSavedValue())
     175           0 :         m_pConfigItem->SetMailAddress(m_aAddressED.GetText());
     176           0 :     if( m_aReplyToCB.GetSavedValue() != m_aReplyToCB.IsChecked())
     177           0 :         m_pConfigItem->SetMailReplyTo(m_aReplyToCB.IsChecked());
     178           0 :     if(m_aReplyToED.GetText() != m_aReplyToED.GetSavedValue())
     179           0 :         m_pConfigItem->SetMailReplyTo(m_aReplyToED.GetText());
     180           0 :     if(m_aServerED.GetText() != m_aServerED.GetSavedValue())
     181           0 :         m_pConfigItem->SetMailServer(m_aServerED.GetText());
     182             : 
     183           0 :     if(m_aPortNF.IsModified())
     184           0 :         m_pConfigItem->SetMailPort((sal_Int16)m_aPortNF.GetValue());
     185             : 
     186           0 :     m_pConfigItem->SetSecureConnection(m_aSecureCB.IsChecked());
     187             : 
     188           0 :     m_pConfigItem->Commit();
     189           0 :     return sal_True;
     190             : }
     191             : 
     192           0 : void SwMailConfigPage::Reset( const SfxItemSet& /*rSet*/ )
     193             : {
     194           0 :     m_aDisplayNameED.SetText(m_pConfigItem->GetMailDisplayName());
     195           0 :     m_aAddressED.SetText(m_pConfigItem->GetMailAddress());
     196             : 
     197           0 :     m_aReplyToED.SetText(m_pConfigItem->GetMailReplyTo()) ;
     198           0 :     m_aReplyToCB.Check(m_pConfigItem->IsMailReplyTo());
     199           0 :     m_aReplyToCB.GetClickHdl().Call(&m_aReplyToCB);
     200             : 
     201           0 :     m_aServerED.SetText(m_pConfigItem->GetMailServer());
     202           0 :     m_aPortNF.SetValue(m_pConfigItem->GetMailPort());
     203             : 
     204           0 :     m_aSecureCB.Check(m_pConfigItem->IsSecureConnection());
     205             : 
     206           0 :     m_aDisplayNameED.SaveValue();
     207           0 :     m_aAddressED    .SaveValue();
     208           0 :     m_aReplyToCB    .SaveValue();
     209           0 :     m_aReplyToED    .SaveValue();
     210           0 :     m_aServerED     .SaveValue();
     211           0 :     m_aPortNF       .SaveValue();
     212           0 :     m_aSecureCB     .SaveValue();
     213           0 : }
     214             : 
     215           0 : IMPL_LINK(SwMailConfigPage, ReplyToHdl, CheckBox*, pBox)
     216             : {
     217           0 :     sal_Bool bEnable = pBox->IsChecked();
     218           0 :     m_aReplyToFT.Enable(bEnable);
     219           0 :     m_aReplyToED.Enable(bEnable);
     220           0 :     return 0;
     221             : }
     222             : 
     223           0 : IMPL_LINK_NOARG(SwMailConfigPage, AuthenticationHdl)
     224             : {
     225           0 :     SwAuthenticationSettingsDialog aDlg(this, *m_pConfigItem);
     226           0 :     aDlg.Execute();
     227           0 :     return 0;
     228             : }
     229             : 
     230           0 : IMPL_LINK_NOARG(SwMailConfigPage, TestHdl)
     231             : {
     232           0 :     SwTestAccountSettingsDialog(this).Execute();
     233           0 :     return 0;
     234             : }
     235             : 
     236           0 : SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pParent) :
     237             :     SfxModalDialog(pParent, SW_RES(DLG_MM_TESTACCOUNTSETTINGS)),
     238             : #ifdef _MSC_VER
     239             : #pragma warning (disable : 4355)
     240             : #endif
     241             :     m_aInfoFI( this, SW_RES(         FI_INFO )),
     242             :     m_aStatusHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
     243             :     m_aStatusLB( this, SW_RES(       LB_STATUS )),
     244             :     m_aErrorFI( this, SW_RES(        FI_ERROR  )),
     245             :     m_eErrorsED( this, SW_RES(       ED_ERROR  )),
     246             :     m_aSeparatorFL( this, SW_RES(    FL_SEPAPARATOR )),
     247             :     m_aStopPB( this, SW_RES(         PB_STOP   )),
     248             :     m_aCancelPB( this, SW_RES(       PB_CANCEL )),
     249             :     m_aHelpPB( this, SW_RES(         PB_HELP   )),
     250             : #ifdef _MSC_VER
     251             : #pragma warning (default : 4355)
     252             : #endif
     253             :     m_aImageList( SW_RES(ILIST) ),
     254             :     m_sTask( SW_RES(        ST_TASK          )),
     255             :     m_sStatus( SW_RES(      ST_STATUS        )),
     256             :     m_sEstablish( SW_RES(   ST_ESTABLISH     )),
     257             :     m_sFindServer( SW_RES(  ST_FINDSERVER    )),
     258             :     m_sCompleted( SW_RES(   ST_COMPLETED     )),
     259             :     m_sFailed( SW_RES(      ST_FAILED        )),
     260             :     m_sErrorServer( SW_RES( ST_ERROR_SERVER )),
     261             :     m_pParent(pParent),
     262           0 :     m_bStop(false)
     263             : {
     264           0 :     FreeResource();
     265           0 :     m_aStopPB.SetClickHdl(LINK(this, SwTestAccountSettingsDialog, StopHdl));
     266             : 
     267           0 :     Size aLBSize(m_aStatusLB.GetOutputSizePixel());
     268           0 :     m_aStatusHB.SetSizePixel(aLBSize);
     269           0 :     Size aHeadSize(m_aStatusHB.CalcWindowSizePixel());
     270           0 :     aHeadSize.Width() = aLBSize.Width();
     271           0 :     m_aStatusHB.SetSizePixel(aHeadSize);
     272           0 :     Point aLBPos(m_aStatusLB.GetPosPixel());
     273           0 :     m_aStatusHB.SetPosPixel(aLBPos);
     274           0 :     aLBPos.Y() += aHeadSize.Height();
     275           0 :     aLBSize.Height() -= aHeadSize.Height();
     276           0 :     m_aStatusLB.SetPosSizePixel(aLBPos, aLBSize);
     277             : 
     278           0 :     Size aSz(m_aStatusHB.GetOutputSizePixel());
     279             :     m_aStatusHB.InsertItem( 1, m_sTask,
     280           0 :                             aSz.Width()/2,
     281           0 :                             HIB_LEFT | HIB_VCENTER );
     282             :     m_aStatusHB.InsertItem( 2, m_sStatus,
     283           0 :                             aSz.Width()/2,
     284           0 :                             HIB_LEFT | HIB_VCENTER );
     285             : 
     286           0 :     m_aStatusHB.SetHelpId(HID_MM_TESTACCOUNTSETTINGS_HB  );
     287           0 :     m_aStatusHB.Show();
     288             : 
     289           0 :     m_aStatusLB.SetHelpId(HID_MM_TESTACCOUNTSETTINGS_TLB);
     290           0 :     static long nTabs[] = {2, 0, aSz.Width()/2 };
     291           0 :     m_aStatusLB.SetStyle( m_aStatusLB.GetStyle() | WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
     292           0 :     m_aStatusLB.SetSelectionMode( SINGLE_SELECTION );
     293           0 :     m_aStatusLB.SetTabs(&nTabs[0], MAP_PIXEL);
     294           0 :     short nEntryHeight = m_aStatusLB.GetEntryHeight();
     295           0 :     m_aStatusLB.SetEntryHeight( nEntryHeight * 15 / 10 );
     296             : 
     297           0 :     Application::PostUserEvent( STATIC_LINK( this, SwTestAccountSettingsDialog, TestHdl ), this );
     298           0 : }
     299             : 
     300           0 : SwTestAccountSettingsDialog::~SwTestAccountSettingsDialog()
     301             : {
     302           0 : }
     303             : 
     304           0 : IMPL_LINK_NOARG(SwTestAccountSettingsDialog, StopHdl)
     305             : {
     306           0 :     m_bStop = true;
     307           0 :     return 0;
     308             : }
     309             : 
     310           0 : IMPL_STATIC_LINK(SwTestAccountSettingsDialog, TestHdl, void*, EMPTYARG)
     311             : {
     312           0 :     pThis->EnterWait();
     313           0 :     pThis->Test();
     314           0 :     pThis->LeaveWait();
     315           0 :     return 0;
     316             : }
     317             : 
     318           0 : void SwTestAccountSettingsDialog::Test()
     319             : {
     320           0 :     uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
     321             : 
     322           0 :     OUString sException;
     323             : 
     324           0 :     bool bIsLoggedIn = false;
     325           0 :     bool bIsServer = false;
     326             :     try
     327             :     {
     328           0 :         uno::Reference< mail::XMailService > xInMailService;
     329             :         uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
     330           0 :             mail::MailServiceProvider::create(xContext) );
     331             :         uno::Reference< mail::XMailService > xMailService =
     332           0 :                 xMailServiceProvider->create(
     333           0 :                 mail::MailServiceType_SMTP);
     334           0 :         if(m_bStop)
     335           0 :             return;
     336           0 :         uno::Reference<XConnectionListener> xConnectionListener(new SwConnectionListener());
     337             : 
     338           0 :         if(m_pParent->m_pConfigItem->IsAuthentication() &&
     339           0 :                 m_pParent->m_pConfigItem->IsSMTPAfterPOP())
     340             :         {
     341           0 :             xInMailService = xMailServiceProvider->create(
     342           0 :                     m_pParent->m_pConfigItem->IsInServerPOP() ?
     343           0 :                         mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
     344           0 :             if(m_bStop)
     345           0 :                 return;
     346             :             //authenticate at the POP or IMAP server first
     347             :             uno::Reference<XAuthenticator> xAuthenticator =
     348             :                 new SwAuthenticator(
     349             :                     m_pParent->m_pConfigItem->GetInServerUserName(),
     350             :                     m_pParent->m_pConfigItem->GetInServerPassword(),
     351           0 :                     this);
     352             : 
     353           0 :             xInMailService->addConnectionListener(xConnectionListener);
     354             :             //check connection
     355             :             uno::Reference< uno::XCurrentContext> xConnectionContext =
     356             :                     new SwConnectionContext(
     357             :                         m_pParent->m_pConfigItem->GetInServerName(),
     358           0 :                         m_pParent->m_pConfigItem->GetInServerPort(),
     359           0 :                         OUString("Insecure"));
     360           0 :             xInMailService->connect(xConnectionContext, xAuthenticator);
     361             :         }
     362           0 :         if(m_bStop)
     363           0 :             return;
     364           0 :         uno::Reference<XAuthenticator> xAuthenticator;
     365           0 :         if(m_pParent->m_pConfigItem->IsAuthentication() &&
     366           0 :                 !m_pParent->m_pConfigItem->IsSMTPAfterPOP() &&
     367           0 :                 !m_pParent->m_pConfigItem->GetMailUserName().isEmpty())
     368           0 :             xAuthenticator =
     369             :                 new SwAuthenticator(
     370             :                     m_pParent->m_pConfigItem->GetMailUserName(),
     371             :                     m_pParent->m_pConfigItem->GetMailPassword(),
     372           0 :                     this);
     373             :         else
     374           0 :             xAuthenticator =  new SwAuthenticator();
     375             : 
     376           0 :         xMailService->addConnectionListener(xConnectionListener);
     377           0 :         if(m_bStop)
     378           0 :             return;
     379             :         //just to check if the server exists
     380           0 :         xMailService->getSupportedConnectionTypes();
     381           0 :         if(m_bStop)
     382           0 :             return;
     383           0 :         bIsServer = true;
     384             :         //check connection
     385             :         uno::Reference< uno::XCurrentContext> xConnectionContext =
     386             :                 new SwConnectionContext(
     387             :                     m_pParent->m_aServerED.GetText(),
     388           0 :                     sal::static_int_cast< sal_Int16, sal_Int64 >(m_pParent->m_aPortNF.GetValue()),
     389           0 :                     m_pParent->m_aSecureCB.IsChecked() ? OUString("Ssl") : OUString("Insecure"));
     390           0 :         xMailService->connect(xConnectionContext, xAuthenticator);
     391           0 :         bIsLoggedIn = xMailService->isConnected();
     392           0 :         if( xInMailService.is() )
     393           0 :             xInMailService->disconnect();
     394           0 :         if( xMailService->isConnected())
     395           0 :             xMailService->disconnect();
     396             :     }
     397           0 :     catch (const uno::Exception& e)
     398             :     {
     399           0 :         sException = e.Message;
     400             :     }
     401             : 
     402           0 :     Image aFailedImg =   m_aImageList.GetImage( FN_FORMULA_CANCEL );
     403           0 :     Image aCompletedImg = m_aImageList.GetImage( FN_FORMULA_APPLY );
     404             : 
     405           0 :     String sTmp(m_sEstablish);
     406           0 :     sTmp += '\t';
     407           0 :     sTmp += bIsServer ? m_sCompleted : m_sFailed;
     408             :     m_aStatusLB.InsertEntry(sTmp,
     409             :             bIsServer ? aCompletedImg : aFailedImg,
     410           0 :             bIsServer ? aCompletedImg : aFailedImg);
     411             : 
     412           0 :     sTmp = m_sFindServer;
     413           0 :     sTmp += '\t';
     414           0 :     sTmp += bIsLoggedIn ? m_sCompleted : m_sFailed;
     415             :     m_aStatusLB.InsertEntry(sTmp,
     416             :             bIsLoggedIn ? aCompletedImg : aFailedImg,
     417           0 :             bIsLoggedIn ? aCompletedImg : aFailedImg);
     418             : 
     419           0 :     if(!bIsServer || !bIsLoggedIn )
     420             :     {
     421           0 :         OUStringBuffer aErrorMessage(m_sErrorServer);
     422           0 :         if (!sException.isEmpty())
     423           0 :             aErrorMessage.appendAscii(RTL_CONSTASCII_STRINGPARAM("\n--\n")).append(sException);
     424           0 :         m_eErrorsED.SetText(aErrorMessage.makeStringAndClear());
     425           0 :     }
     426             : }
     427             : 
     428           0 : SwMailConfigDlg::SwMailConfigDlg(Window* pParent, SfxItemSet& rSet ) :
     429           0 :     SfxNoLayoutSingleTabDialog(pParent, rSet, 0)
     430             : {
     431             :     // create TabPage
     432           0 :     SetTabPage(SwMailConfigPage::Create( this, rSet ));
     433           0 : }
     434             : 
     435           0 : SwMailConfigDlg::~SwMailConfigDlg()
     436             : {
     437           0 : }
     438             : 
     439           0 : SwAuthenticationSettingsDialog::SwAuthenticationSettingsDialog(
     440             :         SwMailConfigPage* pParent, SwMailMergeConfigItem& rItem) :
     441             :     SfxModalDialog(pParent, SW_RES(DLG_MM_SERVERAUTHENTICATION)),
     442             : #ifdef _MSC_VER
     443             : #pragma warning (disable : 4355)
     444             : #endif
     445             :         m_aAuthenticationCB( this,          SW_RES( CB_AUTHENTICATION        )),
     446             :         m_aSeparateAuthenticationRB( this,  SW_RES( RB_SEP_AUTHENTICATION   )),
     447             :         m_aSMTPAfterPOPRB( this,            SW_RES( RB_SMPTAFTERPOP         )),
     448             :         m_aOutgoingServerFT( this,          SW_RES( FT_OUTGOINGSERVER        )),
     449             :         m_aUserNameFT( this,                SW_RES( FT_USERNAME             )),
     450             :         m_aUserNameED( this,                SW_RES( ED_USERNAME             )),
     451             :         m_aOutPasswordFT( this,             SW_RES( FT_OUTPASSWORD          )),
     452             :         m_aOutPasswordED( this,             SW_RES( ED_OUTPASSWORD          )),
     453             :         m_aIncomingServerFT( this,          SW_RES( FT_INCOMINGSERVER       )),
     454             :         m_aServerFT( this,                  SW_RES( FT_SERVER               )),
     455             :         m_aServerED( this,                  SW_RES( ED_SERVER               )),
     456             :         m_aPortFT( this,                    SW_RES( FT_PORT                 )),
     457             :         m_aPortNF( this,                    SW_RES( NF_PORT                 )),
     458             :         m_aProtocolFT( this,                SW_RES( FT_PROTOCOL      )),
     459             :         m_aPOP3RB( this,                    SW_RES( RB_POP3          )),
     460             :         m_aIMAPRB( this,                    SW_RES( RB_IMAP          )),
     461             :         m_aInUsernameFT( this,              SW_RES( FT_INUSERNAME            )),
     462             :         m_aInUsernameED( this,              SW_RES( ED_INUSERNAME           )),
     463             :         m_aInPasswordFT( this,              SW_RES( FT_INPASSWORD           )),
     464             :         m_aInPasswordED( this,              SW_RES( ED_INPASSWORD           )),
     465             :         m_aSeparatorFL( this,               SW_RES( FL_SEPARATOR            )),
     466             :         m_aOKPB( this,                      SW_RES( PB_OK                   )),
     467             :         m_aCancelPB( this,                  SW_RES( PB_CANCEL               )),
     468             :         m_aHelpPB( this,                    SW_RES( PB_HELP                 )),
     469             : #ifdef _MSC_VER
     470             : #pragma warning (default : 4355)
     471             : #endif
     472           0 :         rConfigItem( rItem )
     473             : {
     474           0 :     FreeResource();
     475             : 
     476           0 :     m_aAuthenticationCB.SetClickHdl( LINK( this, SwAuthenticationSettingsDialog, CheckBoxHdl_Impl));
     477           0 :     Link aRBLink = LINK( this, SwAuthenticationSettingsDialog, RadioButtonHdl_Impl );
     478           0 :     m_aSeparateAuthenticationRB.SetClickHdl( aRBLink );
     479           0 :     m_aSMTPAfterPOPRB.SetClickHdl( aRBLink );
     480           0 :     m_aOKPB.SetClickHdl( LINK( this, SwAuthenticationSettingsDialog, OKHdl_Impl));
     481             : 
     482           0 :     m_aAuthenticationCB.Check( rConfigItem.IsAuthentication() );
     483           0 :     if(rConfigItem.IsSMTPAfterPOP())
     484           0 :         m_aSMTPAfterPOPRB.Check();
     485             :     else
     486           0 :         m_aSeparateAuthenticationRB.Check();
     487           0 :     m_aUserNameED.SetText( rConfigItem.GetMailUserName() );
     488           0 :     m_aOutPasswordED.SetText( rConfigItem.GetMailPassword() );
     489             : 
     490           0 :     m_aServerED.SetText( rConfigItem.GetInServerName() );
     491           0 :     m_aPortNF.SetValue( rConfigItem.GetInServerPort() );
     492           0 :     if(rConfigItem.IsInServerPOP())
     493           0 :         m_aPOP3RB.Check();
     494             :     else
     495           0 :         m_aIMAPRB.Check();
     496           0 :     m_aInUsernameED.SetText( rConfigItem.GetInServerUserName());
     497           0 :     m_aInPasswordED.SetText( rConfigItem.GetInServerPassword() );
     498             : 
     499           0 :     CheckBoxHdl_Impl( &m_aAuthenticationCB );
     500           0 : }
     501             : 
     502           0 : SwAuthenticationSettingsDialog::~SwAuthenticationSettingsDialog()
     503             : {
     504           0 : }
     505             : 
     506           0 : IMPL_LINK_NOARG(SwAuthenticationSettingsDialog, OKHdl_Impl)
     507             : {
     508           0 :     rConfigItem.SetAuthentication( m_aAuthenticationCB.IsChecked() );
     509           0 :     rConfigItem.SetSMTPAfterPOP(m_aSMTPAfterPOPRB.IsChecked());
     510           0 :     rConfigItem.SetMailUserName(m_aUserNameED.GetText());
     511           0 :     rConfigItem.SetMailPassword(m_aOutPasswordED.GetText());
     512           0 :     rConfigItem.SetInServerName(m_aServerED.GetText());
     513           0 :     rConfigItem.SetInServerPort(sal::static_int_cast< sal_Int16, sal_Int64 >(m_aPortNF.GetValue( ) ));
     514           0 :     rConfigItem.SetInServerPOP(m_aPOP3RB.IsChecked());
     515           0 :     rConfigItem.SetInServerUserName(m_aInUsernameED.GetText());
     516             : 
     517           0 :     rConfigItem.SetInServerPassword(m_aInPasswordED.GetText());
     518           0 :     EndDialog(RET_OK);
     519           0 :     return 0;
     520             : }
     521             : 
     522           0 : IMPL_LINK( SwAuthenticationSettingsDialog, CheckBoxHdl_Impl, CheckBox*, pBox)
     523             : {
     524           0 :     sal_Bool bChecked = pBox->IsChecked();
     525           0 :     m_aSeparateAuthenticationRB.Enable(bChecked);
     526           0 :     m_aSMTPAfterPOPRB.Enable(bChecked);
     527           0 :     RadioButtonHdl_Impl( 0 );
     528             : 
     529           0 :     return 0;
     530             : }
     531             : 
     532           0 : IMPL_LINK_NOARG(SwAuthenticationSettingsDialog, RadioButtonHdl_Impl)
     533             : {
     534           0 :     sal_Bool bSeparate = m_aSeparateAuthenticationRB.IsChecked();
     535           0 :     sal_Bool bIsEnabled = m_aSeparateAuthenticationRB.IsEnabled();
     536           0 :     sal_Bool bNotSeparate = !bSeparate && bIsEnabled;
     537           0 :     bSeparate &= bIsEnabled;
     538             : 
     539           0 :     m_aOutgoingServerFT.Enable(bSeparate);
     540           0 :     m_aUserNameFT.Enable(bSeparate);
     541           0 :     m_aUserNameED.Enable(bSeparate);
     542           0 :     m_aOutPasswordFT.Enable(bSeparate);
     543           0 :     m_aOutPasswordED.Enable(bSeparate);
     544             : 
     545           0 :     m_aIncomingServerFT.Enable(bNotSeparate);
     546           0 :     m_aServerFT.Enable(bNotSeparate);
     547           0 :     m_aServerED.Enable(bNotSeparate);
     548           0 :     m_aPortFT.Enable(bNotSeparate);
     549           0 :     m_aPortNF.Enable(bNotSeparate);
     550           0 :     m_aInUsernameFT.Enable(bNotSeparate);
     551           0 :     m_aInUsernameED.Enable(bNotSeparate);
     552           0 :     m_aProtocolFT.Enable(bNotSeparate);
     553           0 :     m_aPOP3RB.Enable(bNotSeparate);
     554           0 :     m_aIMAPRB.Enable(bNotSeparate);
     555           0 :     m_aInPasswordFT.Enable(bNotSeparate);
     556           0 :     m_aInPasswordED.Enable(bNotSeparate);
     557             : 
     558           0 :     return 0;
     559           0 : }
     560             : 
     561             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10