OW_NPIPolledProviderProxy.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 #include "OW_config.h"
00031 #include "OW_NPIPolledProviderProxy.hpp"
00032 #include "NPIExternal.hpp"
00033 #include "OW_CIMClass.hpp"
00034 #include "OW_CIMException.hpp"
00035 #include "OW_Format.hpp"
00036 #include "OW_NPIProviderIFCUtils.hpp"
00037 #include "OW_CIMValue.hpp"
00038 #include "OW_CIMObjectPath.hpp"
00039 #include "OW_CIMParamValue.hpp"
00040 #include "OW_Logger.hpp"
00041 
00042 namespace OW_NAMESPACE
00043 {
00044 
00045 namespace
00046 {
00047    const String COMPONENT_NAME("ow.provider.npi.ifc");
00048 }
00049 
00051 NPIPolledProviderProxy::~NPIPolledProviderProxy()
00052 {
00053 }
00055 Int32
00056 NPIPolledProviderProxy::getInitialPollingInterval(
00057      const ProviderEnvironmentIFCRef& env)
00058 {
00059       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "NPIPolledProviderIFC::getInitialPollingInterval()");
00060    return 1;
00061 }
00062 Int32
00063 NPIPolledProviderProxy::poll(const ProviderEnvironmentIFCRef &env)
00064 {
00065    CIMValue rval(CIMNULL);
00066    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "NPIPolledProviderIFC::poll()");
00067    if (m_ftable->fp_mustPoll != NULL)
00068    {
00069       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00070       NPIHandleFreer nhf(_npiHandle);
00071       ProviderEnvironmentIFCRef env2(env);
00072       _npiHandle.thisObject = static_cast<void *>(&env2);
00073       char * expo = const_cast<char*>("SourceInstance.PercentageSpaceUse 80");
00074       SelectExp exp = {expo};
00075       ::CIMObjectPath cop = {NULL};
00076       m_ftable->fp_mustPoll( &_npiHandle, exp, expo, cop);
00077       if (_npiHandle.errorOccurred)
00078       {
00079          OW_THROWCIMMSG(CIMException::FAILED,
00080             _npiHandle.providerError);
00081       }
00082    }
00083    return 0;
00084 }
00085 void NPIPolledProviderProxy::activateFilter(
00086    const ProviderEnvironmentIFCRef& env, const String& query,
00087    const String& Type)
00088 {
00089    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "activateFilter");
00090    if (m_ftable->fp_activateFilter != NULL)
00091    {
00092       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "activateFilter2");
00093       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00094       NPIHandleFreer nhf(_npiHandle);
00095       ProviderEnvironmentIFCRef env2(env);
00096       _npiHandle.thisObject = static_cast<void *>(&env2);
00097       char * expo = query.allocateCString();
00098       char * _type = Type.allocateCString();
00099       SelectExp exp = {expo};
00100       ::CIMObjectPath cop = {NULL};
00101          m_ftable->fp_activateFilter( &_npiHandle, exp, _type, cop, 0);
00102       free(expo);
00103       free(_type);
00104       if (_npiHandle.errorOccurred)
00105       {
00106          OW_THROWCIMMSG(CIMException::FAILED,
00107             _npiHandle.providerError);
00108       }
00109    }
00110 }
00111 void NPIPolledProviderProxy::deactivateFilter(
00112    const ProviderEnvironmentIFCRef& env, const String& query,
00113    const String& Type)
00114 {
00115    OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter");
00116    if (m_ftable->fp_deActivateFilter != NULL)
00117    {
00118       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00119       NPIHandleFreer nhf(_npiHandle);
00120       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "deactivateFilter2");
00121       ProviderEnvironmentIFCRef env2(env);
00122       _npiHandle.thisObject = static_cast<void *>(&env2);
00123       char * expo = query.allocateCString();
00124       char * _type = Type.allocateCString();
00125       SelectExp exp = {expo};
00126       ::CIMObjectPath cop = {NULL};
00127       char * type = NULL;
00128          m_ftable->fp_deActivateFilter( &_npiHandle, exp, _type, cop, 0);
00129       free(type);
00130       free(expo);
00131       if (_npiHandle.errorOccurred)
00132       {
00133          OW_THROWCIMMSG(CIMException::FAILED,
00134             _npiHandle.providerError);
00135       }
00136    }
00137 }
00138 
00139 } // end namespace OW_NAMESPACE
00140 

Generated on Thu Feb 9 08:48:07 2006 for openwbem by  doxygen 1.4.6