1*06b3ce53SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06b3ce53SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06b3ce53SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06b3ce53SAndrew Rist  * distributed with this work for additional information
6*06b3ce53SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06b3ce53SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06b3ce53SAndrew Rist  * "License"); you may not use this file except in compliance
9*06b3ce53SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06b3ce53SAndrew Rist  *
11*06b3ce53SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06b3ce53SAndrew Rist  *
13*06b3ce53SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06b3ce53SAndrew Rist  * software distributed under the License is distributed on an
15*06b3ce53SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06b3ce53SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06b3ce53SAndrew Rist  * specific language governing permissions and limitations
18*06b3ce53SAndrew Rist  * under the License.
19*06b3ce53SAndrew Rist  *
20*06b3ce53SAndrew Rist  *************************************************************/
21*06b3ce53SAndrew Rist 
22*06b3ce53SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <xmlsecurity/warnings.hxx>
28cdf0e10cSrcweir #include <xmlsecurity/certificateviewer.hxx>
29cdf0e10cSrcweir #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
30cdf0e10cSrcweir #include <comphelper/sequence.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // MM : added for password exception
33cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34cdf0e10cSrcweir #include <com/sun/star/security/NoPasswordException.hpp>
35cdf0e10cSrcweir using namespace ::com::sun::star::security;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "dialogs.hrc"
39cdf0e10cSrcweir #include "resourcemanager.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /* HACK: disable some warnings for MS-C */
42cdf0e10cSrcweir #ifdef _MSC_VER
43cdf0e10cSrcweir #pragma warning (disable : 4355)	// 4355: this used in initializer-list
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir using namespace ::com::sun::star;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
MacroWarning(Window * _pParent,uno::Reference<dcss::xml::crypto::XSecurityEnvironment> & _rxSecurityEnvironment,cssu::Reference<dcss::security::XCertificate> & _rxCert)50cdf0e10cSrcweir MacroWarning::MacroWarning( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, cssu::Reference< dcss::security::XCertificate >& _rxCert )
51cdf0e10cSrcweir 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
52cdf0e10cSrcweir 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
53cdf0e10cSrcweir 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
54cdf0e10cSrcweir 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
55cdf0e10cSrcweir 	,maSignsFI			( this, ResId( FI_SIGNS ) )
56cdf0e10cSrcweir 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
57cdf0e10cSrcweir 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
58cdf0e10cSrcweir 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
59cdf0e10cSrcweir 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
60cdf0e10cSrcweir 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
61cdf0e10cSrcweir 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
62cdf0e10cSrcweir 	,maHelpBtn			( this, ResId( BTN_HELP ) )
63cdf0e10cSrcweir 	,mbSignedMode		( true )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	FreeResource();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	mxSecurityEnvironment = _rxSecurityEnvironment;
68cdf0e10cSrcweir 	mxCert = _rxCert;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	// hide unused parts
71cdf0e10cSrcweir 	maDescr1bFI.Hide();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
74cdf0e10cSrcweir 	maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
75cdf0e10cSrcweir //	maDisableBtn.SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	if( mxCert.is() )
78cdf0e10cSrcweir         maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
79cdf0e10cSrcweir 	else
80cdf0e10cSrcweir 		// nothing to view!
81cdf0e10cSrcweir 		maViewSignsBtn.Disable();
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
MacroWarning(Window * _pParent)84cdf0e10cSrcweir MacroWarning::MacroWarning( Window* _pParent )
85cdf0e10cSrcweir 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
86cdf0e10cSrcweir 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
87cdf0e10cSrcweir 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
88cdf0e10cSrcweir 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
89cdf0e10cSrcweir 	,maSignsFI			( this, ResId( FI_SIGNS ) )
90cdf0e10cSrcweir 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
91cdf0e10cSrcweir 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
92cdf0e10cSrcweir 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
93cdf0e10cSrcweir 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
94cdf0e10cSrcweir 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
95cdf0e10cSrcweir 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
96cdf0e10cSrcweir 	,maHelpBtn			( this, ResId( BTN_HELP ) )
97cdf0e10cSrcweir 	,mbSignedMode		( false )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	FreeResource();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	// hide unused parts
102cdf0e10cSrcweir 	maDescr1aFI.Hide();
103cdf0e10cSrcweir 	maSignsFI.Hide();
104cdf0e10cSrcweir 	maViewSignsBtn.Hide();
105cdf0e10cSrcweir 	maAlwaysTrustCB.Hide();
106cdf0e10cSrcweir 	maDescr2FI.Hide();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	// move hint up to position of signer list
109cdf0e10cSrcweir 	maDescr1bFI.SetPosPixel( maSignsFI.GetPosPixel() );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
~MacroWarning()112cdf0e10cSrcweir MacroWarning::~MacroWarning()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
IMPL_LINK(MacroWarning,ViewSignsBtnHdl,void *,EMPTYARG)116cdf0e10cSrcweir IMPL_LINK( MacroWarning, ViewSignsBtnHdl, void*, EMPTYARG )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	CertificateViewer	aViewer( this, mxSecurityEnvironment, mxCert );
121cdf0e10cSrcweir 	aViewer.Execute();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     return 0;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
IMPL_LINK(MacroWarning,EnableBtnHdl,void *,EMPTYARG)126cdf0e10cSrcweir IMPL_LINK( MacroWarning, EnableBtnHdl, void*, EMPTYARG )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
129cdf0e10cSrcweir 	{	// insert path into trusted path list
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	EndDialog( RET_OK );
134cdf0e10cSrcweir     return 0;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*IMPL_LINK( MacroWarning, DisableBtnHdl, void*, EMPTYARG )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     return 0;
140cdf0e10cSrcweir }*/
141cdf0e10cSrcweir 
142