LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mysql - YUsers.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 36 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "mysql/YUsers.hxx"
      21             : #include "mysql/YUser.hxx"
      22             : #include "mysql/YTable.hxx"
      23             : #include <com/sun/star/sdbc/XRow.hpp>
      24             : #include <com/sun/star/sdbc/XResultSet.hpp>
      25             : #include <connectivity/sdbcx/IRefreshable.hxx>
      26             : #include <comphelper/types.hxx>
      27             : #include <connectivity/dbexception.hxx>
      28             : #include <connectivity/dbtools.hxx>
      29             : #include "TConnection.hxx"
      30             : 
      31             : using namespace ::comphelper;
      32             : using namespace connectivity;
      33             : using namespace connectivity::mysql;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::sdbc;
      37             : using namespace ::com::sun::star::container;
      38             : using namespace ::com::sun::star::lang;
      39             : 
      40           0 : OUsers::OUsers( ::cppu::OWeakObject& _rParent,
      41             :                 ::osl::Mutex& _rMutex,
      42             :                 const TStringVector &_rVector,
      43             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
      44             :                 connectivity::sdbcx::IRefreshableUsers* _pParent)
      45             :     : sdbcx::OCollection(_rParent, true, _rMutex, _rVector)
      46             :     ,m_xConnection(_xConnection)
      47           0 :     ,m_pParent(_pParent)
      48             : {
      49           0 : }
      50             : 
      51             : 
      52           0 : sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
      53             : {
      54           0 :     return new OMySQLUser(m_xConnection,_rName);
      55             : }
      56             : 
      57           0 : void OUsers::impl_refresh() throw(RuntimeException)
      58             : {
      59           0 :     m_pParent->refreshUsers();
      60           0 : }
      61             : 
      62           0 : Reference< XPropertySet > OUsers::createDescriptor()
      63             : {
      64           0 :     OUserExtend* pNew = new OUserExtend(m_xConnection);
      65           0 :     return pNew;
      66             : }
      67             : 
      68             : // XAppend
      69           0 : sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
      70             : {
      71           0 :     OUString aSql(  "GRANT USAGE ON * TO " );
      72           0 :     OUString aQuote  = m_xConnection->getMetaData()->getIdentifierQuoteString(  );
      73           0 :     OUString sUserName( _rForName );
      74             :     aSql += ::dbtools::quoteName(aQuote,sUserName)
      75           0 :                 + " @\"%\" ";
      76           0 :     OUString sPassword;
      77           0 :     descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPassword;
      78           0 :     if ( !sPassword.isEmpty() )
      79             :     {
      80           0 :         aSql += " IDENTIFIED BY '";
      81           0 :         aSql += sPassword;
      82           0 :         aSql += "'";
      83             :     }
      84             : 
      85           0 :     Reference< XStatement > xStmt = m_xConnection->createStatement(  );
      86           0 :     if(xStmt.is())
      87           0 :         xStmt->execute(aSql);
      88           0 :     ::comphelper::disposeComponent(xStmt);
      89             : 
      90           0 :     return createObject( _rForName );
      91             : }
      92             : 
      93             : // XDrop
      94           0 : void OUsers::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
      95             : {
      96           0 :     OUString aSql(  "DROP USER " );
      97           0 :     OUString aQuote  = m_xConnection->getMetaData()->getIdentifierQuoteString(  );
      98           0 :     aSql += ::dbtools::quoteName(aQuote,_sElementName);
      99             : 
     100           0 :     Reference< XStatement > xStmt = m_xConnection->createStatement(  );
     101           0 :     if(xStmt.is())
     102           0 :         xStmt->execute(aSql);
     103           0 :     ::comphelper::disposeComponent(xStmt);
     104           0 : }
     105             : 
     106             : 
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11