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