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