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