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