nss: upgrade to release 3.73
[LibreOffice.git] / dbaccess / source / filter / xml / xmlLogin.cxx
bloba309880985956f0d96a4623ca99275665d53ff0d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "xmlLogin.hxx"
21 #include "xmlfilter.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include <strings.hxx>
24 #include <tools/diagnose_ex.h>
25 #include <com/sun/star/sdbc/XDataSource.hpp>
27 namespace dbaxml
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::sdbc;
31 using namespace ::com::sun::star::xml::sax;
33 OXMLLogin::OXMLLogin( ODBFilter& rImport,
34 const Reference< XFastAttributeList > & _xAttrList ) :
35 SvXMLImportContext( rImport )
37 Reference<XPropertySet> xDataSource(rImport.getDataSource());
39 static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
40 bool bUserFound = false;
41 if (!xDataSource.is())
42 return;
44 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
46 OUString sValue = aIter.toString();
48 try
50 switch( aIter.getToken() & TOKEN_MASK )
52 case XML_USER_NAME:
53 if ( !bUserFound )
55 bUserFound = true;
56 try
58 xDataSource->setPropertyValue(PROPERTY_USER,makeAny(sValue));
60 catch(const Exception&)
62 DBG_UNHANDLED_EXCEPTION("dbaccess");
65 break;
66 case XML_IS_PASSWORD_REQUIRED:
67 try
69 xDataSource->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED,makeAny(sValue == s_sTRUE));
71 catch(const Exception&)
73 DBG_UNHANDLED_EXCEPTION("dbaccess");
75 break;
76 case XML_USE_SYSTEM_USER:
77 if ( !bUserFound )
79 bUserFound = true;
80 PropertyValue aProperty;
81 aProperty.Name = "UseSystemUser";
82 aProperty.Value <<= (sValue == s_sTRUE);
83 rImport.addInfo(aProperty);
85 break;
86 case XML_LOGIN_TIMEOUT:
87 try
89 Reference< XDataSource>(xDataSource,UNO_QUERY_THROW)->setLoginTimeout(sValue.toInt32());
91 catch(const Exception&)
93 DBG_UNHANDLED_EXCEPTION("dbaccess");
95 break;
96 default:
97 XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
100 catch(const Exception&)
102 DBG_UNHANDLED_EXCEPTION("dbaccess");
107 OXMLLogin::~OXMLLogin()
112 } // namespace dbaxml
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */