1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <xmlsecurity/warnings.hxx>
32*cdf0e10cSrcweir #include <xmlsecurity/certificateviewer.hxx>
33*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
34*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir // MM : added for password exception
37*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38*cdf0e10cSrcweir #include <com/sun/star/security/NoPasswordException.hpp>
39*cdf0e10cSrcweir using namespace ::com::sun::star::security;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include "dialogs.hrc"
43*cdf0e10cSrcweir #include "resourcemanager.hxx"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir /* HACK: disable some warnings for MS-C */
46*cdf0e10cSrcweir #ifdef _MSC_VER
47*cdf0e10cSrcweir #pragma warning (disable : 4355)	// 4355: this used in initializer-list
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace ::com::sun::star;
51*cdf0e10cSrcweir using namespace ::com::sun::star;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir MacroWarning::MacroWarning( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, cssu::Reference< dcss::security::XCertificate >& _rxCert )
55*cdf0e10cSrcweir 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
56*cdf0e10cSrcweir 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
57*cdf0e10cSrcweir 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
58*cdf0e10cSrcweir 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
59*cdf0e10cSrcweir 	,maSignsFI			( this, ResId( FI_SIGNS ) )
60*cdf0e10cSrcweir 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
61*cdf0e10cSrcweir 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
62*cdf0e10cSrcweir 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
63*cdf0e10cSrcweir 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
64*cdf0e10cSrcweir 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
65*cdf0e10cSrcweir 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
66*cdf0e10cSrcweir 	,maHelpBtn			( this, ResId( BTN_HELP ) )
67*cdf0e10cSrcweir 	,mbSignedMode		( true )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	FreeResource();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	mxSecurityEnvironment = _rxSecurityEnvironment;
72*cdf0e10cSrcweir 	mxCert = _rxCert;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	// hide unused parts
75*cdf0e10cSrcweir 	maDescr1bFI.Hide();
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
78*cdf0e10cSrcweir 	maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
79*cdf0e10cSrcweir //	maDisableBtn.SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	if( mxCert.is() )
82*cdf0e10cSrcweir         maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
83*cdf0e10cSrcweir 	else
84*cdf0e10cSrcweir 		// nothing to view!
85*cdf0e10cSrcweir 		maViewSignsBtn.Disable();
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir MacroWarning::MacroWarning( Window* _pParent )
89*cdf0e10cSrcweir 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
90*cdf0e10cSrcweir 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
91*cdf0e10cSrcweir 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
92*cdf0e10cSrcweir 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
93*cdf0e10cSrcweir 	,maSignsFI			( this, ResId( FI_SIGNS ) )
94*cdf0e10cSrcweir 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
95*cdf0e10cSrcweir 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
96*cdf0e10cSrcweir 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
97*cdf0e10cSrcweir 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
98*cdf0e10cSrcweir 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
99*cdf0e10cSrcweir 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
100*cdf0e10cSrcweir 	,maHelpBtn			( this, ResId( BTN_HELP ) )
101*cdf0e10cSrcweir 	,mbSignedMode		( false )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	FreeResource();
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	// hide unused parts
106*cdf0e10cSrcweir 	maDescr1aFI.Hide();
107*cdf0e10cSrcweir 	maSignsFI.Hide();
108*cdf0e10cSrcweir 	maViewSignsBtn.Hide();
109*cdf0e10cSrcweir 	maAlwaysTrustCB.Hide();
110*cdf0e10cSrcweir 	maDescr2FI.Hide();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	// move hint up to position of signer list
113*cdf0e10cSrcweir 	maDescr1bFI.SetPosPixel( maSignsFI.GetPosPixel() );
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir MacroWarning::~MacroWarning()
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir IMPL_LINK( MacroWarning, ViewSignsBtnHdl, void*, EMPTYARG )
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	CertificateViewer	aViewer( this, mxSecurityEnvironment, mxCert );
125*cdf0e10cSrcweir 	aViewer.Execute();
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     return 0;
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir IMPL_LINK( MacroWarning, EnableBtnHdl, void*, EMPTYARG )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
133*cdf0e10cSrcweir 	{	// insert path into trusted path list
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	}
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	EndDialog( RET_OK );
138*cdf0e10cSrcweir     return 0;
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir /*IMPL_LINK( MacroWarning, DisableBtnHdl, void*, EMPTYARG )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     return 0;
144*cdf0e10cSrcweir }*/
145*cdf0e10cSrcweir 
146