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