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