summaryrefslogtreecommitdiff
path: root/sw/source/ui/config/mailconfigpage.cxx
blob: 62a81d4a53594eff99fc09b6ec3b92e951ba3c46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
#ifdef SW_DLLIMPLEMENTATION
#undef SW_DLLIMPLEMENTATION
#endif


#include <swtypes.hxx>
#include <mailconfigpage.hxx>
#include <svtools/svmedit.hxx>
#include <svtools/stdctrl.hxx>
#include <svtools/svtabbx.hxx>
#include <svtools/headbar.hxx>
#include <mmconfigitem.hxx>
#include <mailmergehelper.hxx>
#ifndef _CMDID_H
#include <cmdid.h>
#endif
#include <vcl/svapp.hxx>
#include <comphelper/processfactory.hxx>
#include "com/sun/star/mail/MailServiceType.hpp"
#include "com/sun/star/mail/XMailService.hpp"
#include "com/sun/star/mail/MailServiceProvider.hpp"
#include <vcl/msgbox.hxx>
#include <globals.hrc>
#include <mailconfigpage.hrc>
#include <config.hrc>
#include <helpid.h>

using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::mail;
using namespace ::com::sun::star::beans;
using ::rtl::OUString;
/*-- 06.05.2004 12:04:11---------------------------------------------------

  -----------------------------------------------------------------------*/
class SwTestAccountSettingsDialog : public SfxModalDialog
{
    FixedInfo           m_aInfoFI;

    HeaderBar           m_aStatusHB;
    SvTabListBox        m_aStatusLB;

    FixedInfo           m_aErrorFI;
    MultiLineEdit       m_eErrorsED;

    FixedLine           m_aSeparatorFL;
    PushButton          m_aStopPB;
    CancelButton        m_aCancelPB;
    HelpButton          m_aHelpPB;

    ImageList           m_aImageList;

    String              m_sTask        ;
    String              m_sStatus      ;
    String              m_sEstablish   ;
    String              m_sFindServer  ;
    String              m_sCompleted   ;
    String              m_sFailed      ;
    String              m_sErrorNetwork;
    String              m_sErrorServer ;

    SwMailConfigPage*   m_pParent;

    bool                m_bStop;

    void                Test();
    DECL_LINK(StopHdl, PushButton*);
    DECL_STATIC_LINK(SwTestAccountSettingsDialog, TestHdl, void*);
public:
    SwTestAccountSettingsDialog(SwMailConfigPage* pParent);
    ~SwTestAccountSettingsDialog();
};
/*-- 19.08.2004 14:27:33---------------------------------------------------

  -----------------------------------------------------------------------*/
class SwAuthenticationSettingsDialog : public SfxModalDialog
{
    CheckBox        m_aAuthenticationCB;

    RadioButton     m_aSeparateAuthenticationRB;
    RadioButton     m_aSMTPAfterPOPRB;

    FixedInfo       m_aOutgoingServerFT;
    FixedText       m_aUserNameFT;
    Edit            m_aUserNameED;
    FixedText       m_aOutPasswordFT;
    Edit            m_aOutPasswordED;

    FixedInfo       m_aIncomingServerFT;
    FixedText       m_aServerFT;
    Edit            m_aServerED;
    FixedText       m_aPortFT;
    NumericField    m_aPortNF;
    FixedText       m_aProtocolFT;
    RadioButton     m_aPOP3RB;
    RadioButton     m_aIMAPRB;
    FixedText       m_aInUsernameFT;
    Edit            m_aInUsernameED;
    FixedText       m_aInPasswordFT;
    Edit            m_aInPasswordED;

    FixedLine       m_aSeparatorFL;

    OKButton        m_aOKPB;
    CancelButton    m_aCancelPB;
    HelpButton      m_aHelpPB;

    SwMailMergeConfigItem& rConfigItem;

    DECL_LINK( OKHdl_Impl, OKButton*);
    DECL_LINK( CheckBoxHdl_Impl, CheckBox*);
    DECL_LINK( RadioButtonHdl_Impl, RadioButton*);


public:
    SwAuthenticationSettingsDialog(SwMailConfigPage* pParent, SwMailMergeConfigItem& rItem);
    ~SwAuthenticationSettingsDialog();
};

/*-- 06.05.2004 10:59:40---------------------------------------------------

  -----------------------------------------------------------------------*/
SwMailConfigPage::SwMailConfigPage( Window* pParent, const SfxItemSet& rSet ) :
    SfxTabPage(pParent, SW_RES(TP_MAILCONFIG), rSet),
#ifdef MSC
#pragma warning (disable : 4355)
#endif
    m_aIdentityFL( this, SW_RES(       FL_IDENTITY)),
    m_aDisplayNameFT( this, SW_RES(    FT_DISPLAYNAME)),
    m_aDisplayNameED( this, SW_RES(    ED_DISPLAYNAME)),
    m_aAddressFT( this, SW_RES(        FT_ADDRESS)),
    m_aAddressED( this, SW_RES(        ED_ADDRESS)),
    m_aReplyToCB( this, SW_RES(        CB_REPLYTO)),
    m_aReplyToFT( this, SW_RES(        FT_REPLYTO)),
    m_aReplyToED( this, SW_RES(        ED_REPLYTO)),
    m_aSMTPFL( this, SW_RES(           FL_SMTP)),
    m_aServerFT( this, SW_RES(         FT_SERVER)),
    m_aServerED( this, SW_RES(         ED_SERVER)),
    m_aPortFT( this, SW_RES(           FT_PORT)),
    m_aPortNF( this, SW_RES(           NF_PORT)),
    m_aSecureCB( this, SW_RES(         CB_SECURE)),
    m_aServerAuthenticationPB( this, SW_RES( PB_AUTHENTICATION )),
    m_aSeparatorFL( this,            SW_RES( FL_SEPARATOR      )),
    m_aTestPB( this, SW_RES(           PB_TEST)),
#ifdef MSC
#pragma warning (default : 4355)
#endif
    m_pConfigItem( new SwMailMergeConfigItem )
{
    FreeResource();
    m_aReplyToCB.SetClickHdl(LINK(this, SwMailConfigPage, ReplyToHdl));
    m_aServerAuthenticationPB.SetClickHdl(LINK(this, SwMailConfigPage, AuthenticationHdl));
    m_aTestPB.SetClickHdl(LINK(this, SwMailConfigPage, TestHdl));
}
/*-- 06.05.2004 10:59:40---------------------------------------------------

  -----------------------------------------------------------------------*/
SwMailConfigPage::~SwMailConfigPage()
{
    delete m_pConfigItem;
}
/*-- 06.05.2004 10:59:40---------------------------------------------------

  -----------------------------------------------------------------------*/
SfxTabPage*  SwMailConfigPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
{
    return new SwMailConfigPage(pParent, rAttrSet);
}
/*-- 06.05.2004 10:59:41---------------------------------------------------

  -----------------------------------------------------------------------*/
BOOL SwMailConfigPage::FillItemSet( SfxItemSet& /*rSet*/ )
{
    if(m_aDisplayNameED.GetText() != m_aDisplayNameED.GetSavedValue())
        m_pConfigItem->SetMailDisplayName(m_aDisplayNameED.GetText());
    if(m_aAddressED.GetText() != m_aAddressED.GetSavedValue())
        m_pConfigItem->SetMailAddress(m_aAddressED.GetText());
    String sReplyTo;
    if( m_aReplyToCB.GetSavedValue() != m_aReplyToCB.IsChecked())
        m_pConfigItem->SetMailReplyTo(m_aReplyToCB.IsChecked());
    if(m_aReplyToED.GetText() != m_aReplyToED.GetSavedValue())
        m_pConfigItem->SetMailReplyTo(m_aReplyToED.GetText());
    if(m_aServerED.GetText() != m_aServerED.GetSavedValue())
        m_pConfigItem->SetMailServer(m_aServerED.GetText());

    if(m_aPortNF.IsModified())
        m_pConfigItem->SetMailPort((sal_Int16)m_aPortNF.GetValue());

    m_pConfigItem->SetSecureConnection(m_aSecureCB.IsChecked());

    m_pConfigItem->Commit();
    return sal_True;
}
/*-- 06.05.2004 10:59:41---------------------------------------------------

  -----------------------------------------------------------------------*/
void SwMailConfigPage::Reset( const SfxItemSet& /*rSet*/ )
{
    m_aDisplayNameED.SetText(m_pConfigItem->GetMailDisplayName());
    m_aAddressED.SetText(m_pConfigItem->GetMailAddress());

    m_aReplyToED.SetText(m_pConfigItem->GetMailReplyTo()) ;
    m_aReplyToCB.Check(m_pConfigItem->IsMailReplyTo());
    m_aReplyToCB.GetClickHdl().Call(&m_aReplyToCB);

    m_aServerED.SetText(m_pConfigItem->GetMailServer());
    m_aPortNF.SetValue(m_pConfigItem->GetMailPort());

    m_aSecureCB.Check(m_pConfigItem->IsSecureConnection());

    m_aDisplayNameED.SaveValue();
    m_aAddressED    .SaveValue();
    m_aReplyToCB    .SaveValue();
    m_aReplyToED    .SaveValue();
    m_aServerED     .SaveValue();
    m_aPortNF       .SaveValue();
    m_aSecureCB     .SaveValue();
}
/*-- 06.05.2004 10:59:41---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK(SwMailConfigPage, ReplyToHdl, CheckBox*, pBox)
{
    sal_Bool bEnable = pBox->IsChecked();
    m_aReplyToFT.Enable(bEnable);
    m_aReplyToED.Enable(bEnable);
    return 0;
}
/*-- 06.05.2004 10:59:41---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK(SwMailConfigPage, AuthenticationHdl, PushButton*, EMPTYARG)
{
    SwAuthenticationSettingsDialog aDlg(this, *m_pConfigItem);
    aDlg.Execute();
    return 0;
}
/*-- 06.05.2004 10:59:42---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK(SwMailConfigPage, TestHdl, PushButton*, EMPTYARG)
{
    SwTestAccountSettingsDialog(this).Execute();
    return 0;
}
/*-- 06.05.2004 12:11:13---------------------------------------------------

  -----------------------------------------------------------------------*/
SwTestAccountSettingsDialog::SwTestAccountSettingsDialog(SwMailConfigPage* pParent) :
    SfxModalDialog(pParent, SW_RES(DLG_MM_TESTACCOUNTSETTINGS)),
#ifdef MSC
#pragma warning (disable : 4355)
#endif
    m_aInfoFI( this, SW_RES(         FI_INFO )),
    m_aStatusHB( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER),
    m_aStatusLB( this, SW_RES(       LB_STATUS )),
    m_aErrorFI( this, SW_RES(        FI_ERROR  )),
    m_eErrorsED( this, SW_RES(       ED_ERROR  )),
    m_aSeparatorFL( this, SW_RES(    FL_SEPAPARATOR )),
    m_aStopPB( this, SW_RES(         PB_STOP   )),
    m_aCancelPB( this, SW_RES(       PB_CANCEL )),
    m_aHelpPB( this, SW_RES(         PB_HELP   )),
#ifdef MSC
#pragma warning (default : 4355)
#endif
    m_aImageList( SW_RES( GetSettings().GetStyleSettings().GetWindowColor().IsDark() ? ILIST_HC : ILIST) ),
    m_sTask( SW_RES(        ST_TASK          )),
    m_sStatus( SW_RES(      ST_STATUS        )),
    m_sEstablish( SW_RES(   ST_ESTABLISH     )),
    m_sFindServer( SW_RES(  ST_FINDSERVER    )),
    m_sCompleted( SW_RES(   ST_COMPLETED     )),
    m_sFailed( SW_RES(      ST_FAILED        )),
    m_sErrorServer( SW_RES( ST_ERROR_SERVER )),
    m_pParent(pParent),
    m_bStop(false)
{
    FreeResource();
    m_aStopPB.SetClickHdl(LINK(this, SwTestAccountSettingsDialog, StopHdl));

    Size aLBSize(m_aStatusLB.GetOutputSizePixel());
    m_aStatusHB.SetSizePixel(aLBSize);
    Size aHeadSize(m_aStatusHB.CalcWindowSizePixel());
    aHeadSize.Width() = aLBSize.Width();
    m_aStatusHB.SetSizePixel(aHeadSize);
    Point aLBPos(m_aStatusLB.GetPosPixel());
    m_aStatusHB.SetPosPixel(aLBPos);
    aLBPos.Y() += aHeadSize.Height();
    aLBSize.Height() -= aHeadSize.Height();
    m_aStatusLB.SetPosSizePixel(aLBPos, aLBSize);

    Size aSz(m_aStatusHB.GetOutputSizePixel());
    m_aStatusHB.InsertItem( 1, m_sTask,
                            aSz.Width()/2,
                            HIB_LEFT | HIB_VCENTER );
    m_aStatusHB.InsertItem( 2, m_sStatus,
                            aSz.Width()/2,
                            HIB_LEFT | HIB_VCENTER );

    m_aStatusHB.SetHelpId(HID_MM_TESTACCOUNTSETTINGS_HB  );
    m_aStatusHB.Show();

    m_aStatusLB.SetHelpId(HID_MM_TESTACCOUNTSETTINGS_TLB);
    static long nTabs[] = {2, 0, aSz.Width()/2 };
    m_aStatusLB.SetWindowBits( WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
    m_aStatusLB.SetSelectionMode( SINGLE_SELECTION );
    m_aStatusLB.SetTabs(&nTabs[0], MAP_PIXEL);
    short nEntryHeight = m_aStatusLB.GetEntryHeight();
    m_aStatusLB.SetEntryHeight( nEntryHeight * 15 / 10 );

    Application::PostUserEvent( STATIC_LINK( this, SwTestAccountSettingsDialog, TestHdl ), this );
}
/*-- 06.05.2004 12:11:13---------------------------------------------------

  -----------------------------------------------------------------------*/
SwTestAccountSettingsDialog::~SwTestAccountSettingsDialog()
{
}
/*-- 06.05.2004 12:15:43---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK(SwTestAccountSettingsDialog, StopHdl, PushButton*, EMPTYARG)
{
    m_bStop = true;
    return 0;
}
/*-- 07.06.2004 12:44:50---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_STATIC_LINK(SwTestAccountSettingsDialog, TestHdl, void*, EMPTYARG)
{
    pThis->EnterWait();
    pThis->Test();
    pThis->LeaveWait();
    return 0;
}
/*-- 07.06.2004 12:45:45---------------------------------------------------

  -----------------------------------------------------------------------*/
void SwTestAccountSettingsDialog::Test()
{
    uno::Reference<XMultiServiceFactory> rMgr = ::comphelper::getProcessServiceFactory();

    bool bIsLoggedIn = false;
    bool bIsServer = false;
    if (rMgr.is())
    {
        try
        {
            uno::Reference< mail::XMailService > xInMailService;
            uno::Reference< mail::XMailServiceProvider > xMailServiceProvider =
                    mail::MailServiceProvider::create(getCurrentCmpCtx(rMgr));
            uno::Reference< mail::XMailService > xMailService =
                    xMailServiceProvider->create(
                    mail::MailServiceType_SMTP);
            if(m_bStop)
                return;
            uno::Reference<XConnectionListener> xConnectionListener(new SwConnectionListener());

            if(m_pParent->m_pConfigItem->IsAuthentication() &&
                    m_pParent->m_pConfigItem->IsSMTPAfterPOP())
            {
                xInMailService = xMailServiceProvider->create(
                        m_pParent->m_pConfigItem->IsInServerPOP() ?
                            mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
                if(m_bStop)
                    return;
                //authenticate at the POP or IMAP server first
                uno::Reference<XAuthenticator> xAuthenticator =
                    new SwAuthenticator(
                        m_pParent->m_pConfigItem->GetInServerUserName(),
                        m_pParent->m_pConfigItem->GetInServerPassword(),
                        this);

                xInMailService->addConnectionListener(xConnectionListener);
                //check connection
                uno::Reference< uno::XCurrentContext> xConnectionContext =
                        new SwConnectionContext(
                            m_pParent->m_pConfigItem->GetInServerName(),
                            m_pParent->m_pConfigItem->GetInServerPort(),
                            ::rtl::OUString::createFromAscii( "Insecure" ));
                xInMailService->connect(xConnectionContext, xAuthenticator);
            }
            if(m_bStop)
                return;
            uno::Reference<XAuthenticator> xAuthenticator;
            if(m_pParent->m_pConfigItem->IsAuthentication() &&
                    !m_pParent->m_pConfigItem->IsSMTPAfterPOP() &&
                    m_pParent->m_pConfigItem->GetMailUserName().getLength())
                xAuthenticator =
                    new SwAuthenticator(
                        m_pParent->m_pConfigItem->GetMailUserName(),
                        m_pParent->m_pConfigItem->GetMailPassword(),
                        this);
            else
                xAuthenticator =  new SwAuthenticator();

            xMailService->addConnectionListener(xConnectionListener);
            if(m_bStop)
                return;
            //just to check if the server exists
            xMailService->getSupportedConnectionTypes();
            if(m_bStop)
                return;
            bIsServer = true;
            //check connection
            uno::Reference< uno::XCurrentContext> xConnectionContext =
                    new SwConnectionContext(
                        m_pParent->m_aServerED.GetText(),
                        sal::static_int_cast< sal_Int16, sal_Int64 >(m_pParent->m_aPortNF.GetValue()),
                        ::rtl::OUString::createFromAscii(
                                m_pParent->m_aSecureCB.IsChecked() ? "Ssl" : "Insecure"));
            xMailService->connect(xConnectionContext, xAuthenticator);
            bIsLoggedIn = xMailService->isConnected();
            if( xInMailService.is() )
                xInMailService->disconnect();
            if( xMailService->isConnected())
                xMailService->disconnect();
        }
        catch(uno::Exception&)
        {
            DBG_ERROR("exception caught");
        }
    }

    Image aFailedImg =   m_aImageList.GetImage( FN_FORMULA_CANCEL );
    Image aCompletedImg = m_aImageList.GetImage( FN_FORMULA_APPLY );

    String sTmp(m_sEstablish);
    sTmp += '\t';
    sTmp += bIsServer ? m_sCompleted : m_sFailed;
    m_aStatusLB.InsertEntry(sTmp,
            bIsServer ? aCompletedImg : aFailedImg,
            bIsServer ? aCompletedImg : aFailedImg);

    sTmp = m_sFindServer;
    sTmp += '\t';
    sTmp += bIsLoggedIn ? m_sCompleted : m_sFailed;
    m_aStatusLB.InsertEntry(sTmp,
            bIsLoggedIn ? aCompletedImg : aFailedImg,
            bIsLoggedIn ? aCompletedImg : aFailedImg);

    if(!bIsServer || !bIsLoggedIn )
    {
        m_eErrorsED.SetText( m_sErrorServer );
    }
}
/*-- 18.08.2004 12:18:38---------------------------------------------------

  -----------------------------------------------------------------------*/
SwMailConfigDlg::SwMailConfigDlg(Window* pParent, SfxItemSet& rSet ) :
    SfxSingleTabDialog(pParent, rSet, 0)
{
    // TabPage erzeugen
    SetTabPage(SwMailConfigPage::Create( this, rSet ));
}
/*-- 18.08.2004 12:18:38---------------------------------------------------

  -----------------------------------------------------------------------*/
SwMailConfigDlg::~SwMailConfigDlg()
{
}
/*-- 19.08.2004 14:33:58---------------------------------------------------

  -----------------------------------------------------------------------*/
SwAuthenticationSettingsDialog::SwAuthenticationSettingsDialog(
        SwMailConfigPage* pParent, SwMailMergeConfigItem& rItem) :
    SfxModalDialog(pParent, SW_RES(DLG_MM_SERVERAUTHENTICATION)),
#ifdef MSC
#pragma warning (disable : 4355)
#endif
        m_aAuthenticationCB( this,          SW_RES( CB_AUTHENTICATION        )),
        m_aSeparateAuthenticationRB( this,  SW_RES( RB_SEP_AUTHENTICATION   )),
        m_aSMTPAfterPOPRB( this,            SW_RES( RB_SMPTAFTERPOP         )),
        m_aOutgoingServerFT( this,          SW_RES( FT_OUTGOINGSERVER        )),
        m_aUserNameFT( this,                SW_RES( FT_USERNAME             )),
        m_aUserNameED( this,                SW_RES( ED_USERNAME             )),
        m_aOutPasswordFT( this,             SW_RES( FT_OUTPASSWORD          )),
        m_aOutPasswordED( this,             SW_RES( ED_OUTPASSWORD          )),
        m_aIncomingServerFT( this,          SW_RES( FT_INCOMINGSERVER       )),
        m_aServerFT( this,                  SW_RES( FT_SERVER               )),
        m_aServerED( this,                  SW_RES( ED_SERVER               )),
        m_aPortFT( this,                    SW_RES( FT_PORT                 )),
        m_aPortNF( this,                    SW_RES( NF_PORT                 )),
        m_aProtocolFT( this,                SW_RES( FT_PROTOCOL      )),
        m_aPOP3RB( this,                    SW_RES( RB_POP3          )),
        m_aIMAPRB( this,                    SW_RES( RB_IMAP          )),
        m_aInUsernameFT( this,              SW_RES( FT_INUSERNAME            )),
        m_aInUsernameED( this,              SW_RES( ED_INUSERNAME           )),
        m_aInPasswordFT( this,              SW_RES( FT_INPASSWORD           )),
        m_aInPasswordED( this,              SW_RES( ED_INPASSWORD           )),
        m_aSeparatorFL( this,               SW_RES( FL_SEPARATOR            )),
        m_aOKPB( this,                      SW_RES( PB_OK                   )),
        m_aCancelPB( this,                  SW_RES( PB_CANCEL               )),
        m_aHelpPB( this,                    SW_RES( PB_HELP                 )),
#ifdef MSC
#pragma warning (default : 4355)
#endif
        rConfigItem( rItem )
{
    FreeResource();

    m_aAuthenticationCB.SetClickHdl( LINK( this, SwAuthenticationSettingsDialog, CheckBoxHdl_Impl));
    Link aRBLink = LINK( this, SwAuthenticationSettingsDialog, RadioButtonHdl_Impl );
    m_aSeparateAuthenticationRB.SetClickHdl( aRBLink );
    m_aSMTPAfterPOPRB.SetClickHdl( aRBLink );
    m_aOKPB.SetClickHdl( LINK( this, SwAuthenticationSettingsDialog, OKHdl_Impl));

    m_aAuthenticationCB.Check( rConfigItem.IsAuthentication() );
    if(rConfigItem.IsSMTPAfterPOP())
        m_aSMTPAfterPOPRB.Check();
    else
        m_aSeparateAuthenticationRB.Check();
    m_aUserNameED.SetText( rConfigItem.GetMailUserName() );
    m_aOutPasswordED.SetText( rConfigItem.GetMailPassword() );

    m_aServerED.SetText( rConfigItem.GetInServerName() );
    m_aPortNF.SetValue( rConfigItem.GetInServerPort() );
    if(rConfigItem.IsInServerPOP())
        m_aPOP3RB.Check();
    else
        m_aIMAPRB.Check();
    m_aInUsernameED.SetText( rConfigItem.GetInServerUserName());
    m_aInPasswordED.SetText( rConfigItem.GetInServerPassword() );

    CheckBoxHdl_Impl( &m_aAuthenticationCB );
}
/*-- 19.08.2004 14:33:58---------------------------------------------------

  -----------------------------------------------------------------------*/
SwAuthenticationSettingsDialog::~SwAuthenticationSettingsDialog()
{
}
/*-- 19.08.2004 14:33:59---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK( SwAuthenticationSettingsDialog, OKHdl_Impl, OKButton*, EMPTYARG)
{
    rConfigItem.SetAuthentication( m_aAuthenticationCB.IsChecked() );
    rConfigItem.SetSMTPAfterPOP(m_aSMTPAfterPOPRB.IsChecked());
    rConfigItem.SetMailUserName(m_aUserNameED.GetText());
    rConfigItem.SetMailPassword(m_aOutPasswordED.GetText());
    rConfigItem.SetInServerName(m_aServerED.GetText());
    rConfigItem.SetInServerPort(sal::static_int_cast< sal_Int16, sal_Int64 >(m_aPortNF.GetValue( ) ));
    rConfigItem.SetInServerPOP(m_aPOP3RB.IsChecked());
    rConfigItem.SetInServerUserName(m_aInUsernameED.GetText());

    rConfigItem.SetInServerPassword(m_aInPasswordED.GetText());
    EndDialog(RET_OK);
    return 0;
}
/*-- 19.08.2004 14:33:59---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK( SwAuthenticationSettingsDialog, CheckBoxHdl_Impl, CheckBox*, pBox)
{
    sal_Bool bChecked = pBox->IsChecked();
    m_aSeparateAuthenticationRB.Enable(bChecked);
    m_aSMTPAfterPOPRB.Enable(bChecked);
    RadioButtonHdl_Impl( 0 );

    return 0;
}
/*-- 19.08.2004 14:33:59---------------------------------------------------

  -----------------------------------------------------------------------*/
IMPL_LINK( SwAuthenticationSettingsDialog, RadioButtonHdl_Impl, RadioButton*, EMPTYARG)
{
    sal_Bool bSeparate = m_aSeparateAuthenticationRB.IsChecked();
    sal_Bool bIsEnabled = m_aSeparateAuthenticationRB.IsEnabled();
    sal_Bool bNotSeparate = !bSeparate & bIsEnabled;
    bSeparate &= bIsEnabled;

    m_aOutgoingServerFT.Enable(bSeparate);
    m_aUserNameFT.Enable(bSeparate);
    m_aUserNameED.Enable(bSeparate);
    m_aOutPasswordFT.Enable(bSeparate);
    m_aOutPasswordED.Enable(bSeparate);

    m_aIncomingServerFT.Enable(bNotSeparate);
    m_aServerFT.Enable(bNotSeparate);
    m_aServerED.Enable(bNotSeparate);
    m_aPortFT.Enable(bNotSeparate);
    m_aPortNF.Enable(bNotSeparate);
    m_aInUsernameFT.Enable(bNotSeparate);
    m_aInUsernameED.Enable(bNotSeparate);
    m_aProtocolFT.Enable(bNotSeparate);
    m_aPOP3RB.Enable(bNotSeparate);
    m_aIMAPRB.Enable(bNotSeparate);
    m_aInPasswordFT.Enable(bNotSeparate);
    m_aInPasswordED.Enable(bNotSeparate);

    return 0;
}