27#include <com/sun/star/mail/MailServiceType.hpp>
28#include <com/sun/star/mail/XMailService.hpp>
29#include <com/sun/star/mail/MailServiceProvider.hpp>
70 std::unique_ptr<weld::CheckButton> m_xAuthenticationCB;
71 std::unique_ptr<weld::RadioButton> m_xSeparateAuthenticationRB;
72 std::unique_ptr<weld::RadioButton> m_xSMTPAfterPOPRB;
73 std::unique_ptr<weld::Label> m_xOutgoingServerFT;
74 std::unique_ptr<weld::Label> m_xUserNameFT;
75 std::unique_ptr<weld::Entry> m_xUserNameED;
76 std::unique_ptr<weld::Label> m_xOutPasswordFT;
77 std::unique_ptr<weld::Entry> m_xOutPasswordED;
78 std::unique_ptr<weld::Label> m_xIncomingServerFT;
79 std::unique_ptr<weld::Label> m_xServerFT;
80 std::unique_ptr<weld::Entry> m_xServerED;
81 std::unique_ptr<weld::Label> m_xPortFT;
82 std::unique_ptr<weld::SpinButton> m_xPortNF;
83 std::unique_ptr<weld::Label> m_xProtocolFT;
84 std::unique_ptr<weld::RadioButton> m_xPOP3RB;
85 std::unique_ptr<weld::RadioButton> m_xIMAPRB;
86 std::unique_ptr<weld::Label> m_xInUsernameFT;
87 std::unique_ptr<weld::Entry> m_xInUsernameED;
88 std::unique_ptr<weld::Label> m_xInPasswordFT;
89 std::unique_ptr<weld::Entry> m_xInPasswordED;
90 std::unique_ptr<weld::Button> m_xOKPB;
104 :
SfxTabPage(pPage, pController,
"modules/swriter/ui/mailconfigpage.ui",
"MailConfigPage", &
rSet)
106 , m_xDisplayNameED(m_xBuilder->weld_entry(
"displayname"))
107 , m_xAddressED(m_xBuilder->weld_entry(
"address"))
108 , m_xReplyToCB(m_xBuilder->weld_check_button(
"replytocb"))
109 , m_xReplyToFT(m_xBuilder->weld_label(
"replyto_label"))
110 , m_xReplyToED(m_xBuilder->weld_entry(
"replyto"))
111 , m_xServerED(m_xBuilder->weld_entry(
"server"))
112 , m_xPortNF(m_xBuilder->weld_spin_button(
"port"))
113 , m_xSecureCB(m_xBuilder->weld_check_button(
"secure"))
114 , m_xServerAuthenticationPB(m_xBuilder->weld_button(
"serverauthentication"))
115 , m_xTestPB(m_xBuilder->weld_button(
"test"))
130 return std::make_unique<SwMailConfigPage>(pPage, pController, *rAttrSet);
178 bool bEnable = rBox.get_active();
179 m_xReplyToFT->set_sensitive(bEnable);
180 m_xReplyToED->set_sensitive(bEnable);
185 m_pConfigItem->SetMailAddress(m_xAddressED->get_text());
187 SwAuthenticationSettingsDialog aDlg(
GetFrameWeld(), *m_pConfigItem);
199 bool bEnable = rBox.get_active();
200 m_pConfigItem->SetSecureConnection(bEnable);
201 m_pConfigItem->SetMailPort(m_xPortNF->get_value());
202 m_xPortNF->set_value(m_pConfigItem->GetMailPort());
209 , m_xStopPB(m_xBuilder->weld_button(
"stop"))
210 , m_xErrorsED(m_xBuilder->weld_text_view(
"errors"))
211 , m_xResult1(m_xBuilder->weld_label(
"result1"))
212 , m_xResult2(m_xBuilder->weld_label(
"result2"))
213 , m_xImage1(m_xBuilder->weld_image(
"image1"))
214 , m_xImage2(m_xBuilder->weld_image(
"image2"))
215 , m_xImage3(m_xBuilder->weld_image(
"image3"))
216 , m_xImage4(m_xBuilder->weld_image(
"image4"))
245 m_pPostedEvent =
nullptr;
252 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
256 bool bIsLoggedIn =
false;
257 bool bIsServer =
false;
260 uno::Reference< mail::XMailService > xInMailService;
261 uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
262 mail::MailServiceProvider::create(xContext) );
263 uno::Reference< mail::XMailService > xMailService =
264 xMailServiceProvider->create(
265 mail::MailServiceType_SMTP);
273 xInMailService = xMailServiceProvider->create(
275 mail::MailServiceType_POP3 : mail::MailServiceType_IMAP);
279 uno::Reference<XAuthenticator> xAuthenticator =
285 xInMailService->addConnectionListener(xConnectionListener);
287 uno::Reference< uno::XCurrentContext> xConnectionContext =
292 xInMailService->connect(xConnectionContext, xAuthenticator);
296 uno::Reference<XAuthenticator> xAuthenticator;
308 xMailService->addConnectionListener(xConnectionListener);
312 xMailService->getSupportedConnectionTypes();
317 uno::Reference< uno::XCurrentContext> xConnectionContext =
322 xMailService->connect(xConnectionContext, xAuthenticator);
323 bIsLoggedIn = xMailService->isConnected();
324 if( xInMailService.is() )
325 xInMailService->disconnect();
326 if( xMailService->isConnected())
327 xMailService->disconnect();
329 catch (
const uno::Exception& e)
331 sException = e.Message;
342 if (!bIsServer || !bIsLoggedIn)
345 if (!sException.isEmpty())
346 aErrorMessage +=
"\n--\n" + sException;
359SwAuthenticationSettingsDialog::SwAuthenticationSettingsDialog(
361 :
SfxDialogController(pParent,
"modules/swriter/ui/authenticationsettingsdialog.ui",
"AuthenticationSettingsDialog")
362 , m_rConfigItem(rItem)
363 , m_xAuthenticationCB(m_xBuilder->weld_check_button(
"authentication"))
364 , m_xSeparateAuthenticationRB(m_xBuilder->weld_radio_button(
"separateauthentication"))
365 , m_xSMTPAfterPOPRB(m_xBuilder->weld_radio_button(
"smtpafterpop"))
366 , m_xOutgoingServerFT(m_xBuilder->weld_label(
"label1"))
367 , m_xUserNameFT(m_xBuilder->weld_label(
"username_label"))
368 , m_xUserNameED(m_xBuilder->weld_entry(
"username"))
369 , m_xOutPasswordFT(m_xBuilder->weld_label(
"outpassword_label"))
370 , m_xOutPasswordED(m_xBuilder->weld_entry(
"outpassword"))
371 , m_xIncomingServerFT(m_xBuilder->weld_label(
"label2"))
372 , m_xServerFT(m_xBuilder->weld_label(
"server_label"))
373 , m_xServerED(m_xBuilder->weld_entry(
"server"))
374 , m_xPortFT(m_xBuilder->weld_label(
"port_label"))
375 , m_xPortNF(m_xBuilder->weld_spin_button(
"port"))
376 , m_xProtocolFT(m_xBuilder->weld_label(
"label3"))
377 , m_xPOP3RB(m_xBuilder->weld_radio_button(
"pop3"))
378 , m_xIMAPRB(m_xBuilder->weld_radio_button(
"imap"))
379 , m_xInUsernameFT(m_xBuilder->weld_label(
"inusername_label"))
380 , m_xInUsernameED(m_xBuilder->weld_entry(
"inusername"))
381 , m_xInPasswordFT(m_xBuilder->weld_label(
"inpassword_label"))
382 , m_xInPasswordED(m_xBuilder->weld_entry(
"inpassword"))
383 , m_xOKPB(m_xBuilder->weld_button(
"ok"))
385 m_xAuthenticationCB->connect_toggled(
LINK(
this, SwAuthenticationSettingsDialog, CheckBoxHdl_Impl));
387 m_xSeparateAuthenticationRB->connect_toggled( aRBLink );
388 m_xSMTPAfterPOPRB->connect_toggled( aRBLink );
389 m_xOKPB->connect_clicked(
LINK(
this, SwAuthenticationSettingsDialog, OKHdl_Impl));
390 m_xPOP3RB->connect_toggled(
LINK(
this, SwAuthenticationSettingsDialog, InServerHdl_Impl));
392 m_xAuthenticationCB->set_active(m_rConfigItem.IsAuthentication());
393 if (m_rConfigItem.IsSMTPAfterPOP())
394 m_xSMTPAfterPOPRB->set_active(
true);
396 m_xSeparateAuthenticationRB->set_active(
true);
397 m_xUserNameED->set_text(m_rConfigItem.GetMailUserName());
398 m_xOutPasswordED->set_text(m_rConfigItem.GetMailPassword());
400 m_xServerED->set_text(m_rConfigItem.GetInServerName());
401 m_xPortNF->set_value(m_rConfigItem.GetInServerPort());
402 if (m_rConfigItem.IsInServerPOP())
403 m_xPOP3RB->set_active(
true);
405 m_xIMAPRB->set_active(
true);
406 m_xInUsernameED->set_text(m_rConfigItem.GetInServerUserName());
407 m_xInPasswordED->set_text(m_rConfigItem.GetInServerPassword());
409 CheckBoxHdl_Impl(*m_xAuthenticationCB);
414 m_rConfigItem.SetAuthentication( m_xAuthenticationCB->get_active() );
415 m_rConfigItem.SetSMTPAfterPOP(m_xSMTPAfterPOPRB->get_active());
416 m_rConfigItem.SetMailUserName(m_xUserNameED->get_text());
417 m_rConfigItem.SetMailPassword(m_xOutPasswordED->get_text());
418 m_rConfigItem.SetInServerName(m_xServerED->get_text());
419 m_rConfigItem.SetInServerPort(m_xPortNF->get_value());
420 m_rConfigItem.SetInServerPOP(m_xPOP3RB->get_active());
421 m_rConfigItem.SetInServerUserName(m_xInUsernameED->get_text());
422 m_rConfigItem.SetInServerPassword(m_xInPasswordED->get_text());
428 bool bChecked = rBox.get_active();
429 m_xSeparateAuthenticationRB->set_sensitive(bChecked);
430 m_xSMTPAfterPOPRB->set_sensitive(bChecked);
431 RadioButtonHdl_Impl(*m_xSeparateAuthenticationRB);
436 bool bSeparate = m_xSeparateAuthenticationRB->get_active();
437 bool bIsEnabled = m_xSeparateAuthenticationRB->get_sensitive();
441 if (bSeparate && m_xUserNameED->get_text().isEmpty())
442 m_xUserNameED->set_text(m_rConfigItem.GetMailAddress());
443 else if (!bSeparate && m_xUserNameED->get_text() == m_rConfigItem.GetMailAddress())
444 m_xUserNameED->set_text(
"");
446 if (bNotSeparate && m_xInUsernameED->get_text().isEmpty())
447 m_xInUsernameED->set_text(m_rConfigItem.GetMailAddress());
448 else if (!bNotSeparate && m_xInUsernameED->get_text() == m_rConfigItem.GetMailAddress())
449 m_xInUsernameED->set_text(
"");
451 m_xOutgoingServerFT->set_sensitive(bSeparate);
452 m_xUserNameFT->set_sensitive(bSeparate);
453 m_xUserNameED->set_sensitive(bSeparate);
454 m_xOutPasswordFT->set_sensitive(bSeparate);
455 m_xOutPasswordED->set_sensitive(bSeparate);
457 m_xIncomingServerFT->set_sensitive(bNotSeparate);
458 m_xServerFT->set_sensitive(bNotSeparate);
459 m_xServerED->set_sensitive(bNotSeparate);
460 m_xPortFT->set_sensitive(bNotSeparate);
461 m_xPortNF->set_sensitive(bNotSeparate);
462 m_xInUsernameFT->set_sensitive(bNotSeparate);
463 m_xInUsernameED->set_sensitive(bNotSeparate);
464 m_xProtocolFT->set_sensitive(bNotSeparate);
465 m_xPOP3RB->set_sensitive(bNotSeparate);
466 m_xIMAPRB->set_sensitive(bNotSeparate);
467 m_xInPasswordFT->set_sensitive(bNotSeparate);
468 m_xInPasswordED->set_sensitive(bNotSeparate);
473 bool bPOP = m_xPOP3RB->get_active();
474 m_rConfigItem.SetInServerPOP(bPOP);
475 m_xPortNF->set_value(m_rConfigItem.GetInServerPort());
Reference< XExecutableDialog > m_xDialog
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
weld::Container * get_content_area()
SwMailConfigDlg(weld::Window *pParent, const SfxItemSet &rSet)
std::unique_ptr< weld::Entry > m_xReplyToED
std::unique_ptr< weld::Entry > m_xDisplayNameED
std::unique_ptr< weld::CheckButton > m_xReplyToCB
std::unique_ptr< weld::Button > m_xServerAuthenticationPB
std::unique_ptr< weld::CheckButton > m_xSecureCB
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::Entry > m_xServerED
virtual ~SwMailConfigPage() override
std::unique_ptr< weld::SpinButton > m_xPortNF
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::Entry > m_xAddressED
SwMailConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< SwMailMergeConfigItem > m_pConfigItem
std::unique_ptr< weld::Button > m_xTestPB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Image > m_xImage4
ImplSVEvent * m_pPostedEvent
std::unique_ptr< weld::Image > m_xImage2
std::unique_ptr< weld::Button > m_xStopPB
SwTestAccountSettingsDialog(SwMailConfigPage *pParent)
std::unique_ptr< weld::Image > m_xImage1
std::unique_ptr< weld::Label > m_xResult1
SwMailConfigPage * m_pParent
virtual ~SwTestAccountSettingsDialog() override
DECL_LINK(StopHdl, weld::Button &, void)
std::unique_ptr< weld::Label > m_xResult2
std::unique_ptr< weld::Image > m_xImage3
DECL_LINK(TestHdl, void *, void)
std::unique_ptr< weld::TextView > m_xErrorsED
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(SwMailConfigPage, AuthenticationHdl, weld::Button &, void)
IMPL_LINK(SwMailConfigPage, ReplyToHdl, weld::Toggleable &, rBox, void)
OUString SwResId(TranslateId aId)