CIMDateTime CIMHelper::getInstallDate(String path)
{
	struct tm* clock;			// create a time structure
	struct stat attrib;			// create a file attribute structure
	stat(path.getCString(), &attrib);		// get the attributes mnt
	clock = gmtime(&(attrib.st_birthtime));	// Get the last modified time and put it into the time structure
	return CIMDateTime(
		clock->tm_year + 1900,
		clock->tm_mon + 1,
		clock->tm_mday,
		clock->tm_hour,
		clock->tm_min,
		clock->tm_sec,
		0,0,
		clock->tm_gmtoff);
}
PEGASUS_NAMESPACE_BEGIN


CIMOperationRequestEncoder::CIMOperationRequestEncoder(
    MessageQueue* outputQueue,
    const String& hostName,
    ClientAuthenticator* authenticator,
    Uint32 showOutput)
    :
    MessageQueue(PEGASUS_QUEUENAME_OPREQENCODER),
    _outputQueue(outputQueue),
    _hostName(hostName.getCString()),
    _authenticator(authenticator),
    _showOutput(showOutput)
{
}
Example #3
0
//添加ufo
void UfoLayer::addUfo(float dt)
{
	int isaddufo = (int)(CCRANDOM_0_1()*2);
	do
	{
	  CC_BREAK_IF(isaddufo);
	  //随机生成ufo
	  int type = (int)(CCRANDOM_0_1()*2+1);
	  String* ufoName = String::createWithFormat("ufo%d.png", type);
	  auto ufoSprite = Sprite::createWithSpriteFrameName(ufoName->getCString());
	  this->addChild(ufoSprite, 5, type);
	  this->ufoMove(ufoSprite, getRandomPosition(ufoSprite->getContentSize()));
	  //添加到ufo管理容器中去
	  _ufoVector.pushBack(ufoSprite);
	}while(0);
}
CIMClientConnection::CIMClientConnection(const String& host, const String& port, const String& userid, const String& passwd)
{
	_hostname = String(host);
	_port = String(port);
	_userid = String(userid);
	_passwd = String(passwd);
	
    _connectionHandle.reset(new CIMClientRep());
	_resolvedIP = System::_acquireIP((const char*)host.getCString());
	if (_resolvedIP == 0x7F000001)
	{
		// localhost or ip address of 127.0.0.1
		// still for compare we need the real ip address
		_resolvedIP = System::_acquireIP((const char *) System::getHostName().getCString());
	}
}
Example #5
0
static double
Stof(const String &val) {
    unsigned int end = val.size();
    String s;
    for (unsigned int i = 0; i < end; i++) {
        switch(val[i]) {
        case '1':
            s.append("1");
            break;
        case '2':
            s.append("2");
            break;
        case '3':
            s.append("3");
            break;
        case '4':
            s.append("4");
            break;
        case '5':
            s.append("5");
            break;
        case '6':
            s.append("6");
            break;
        case '7':
            s.append("7");
            break;
        case '8':
            s.append("8");
            break;
        case '9':
            s.append("9");
            break;
        case '0':
            s.append("0");
            break;
        case '.':
            s.append(".");
            break;
        case 'E':
        case 'e':
            s.append("E");
            break;
        }
    }
    return atof(s.getCString());
}
Example #6
0
//------------------------------------------------------------------------------
// FUNCTION: getHostAddress
//
// REMARKS: Resolves address servers
//
// PARAMETERS:  [IN] serverName     -> string containing the name server
//                [OUT] serverAddress -> string that will contain the IP server
//
// RETURN: TRUE if valid host name, FALSE otherwise
//------------------------------------------------------------------------------
Boolean NTPService::getHostAddress(String serverName, String & serverAddress)
{
    Boolean ok = false;
    String strValue;
    struct hostent *host;
    struct in_addr ia;

    serverAddress.clear();
    host = gethostbyname(serverName.getCString());
    if(host != NULL)
    {
        ia = *(struct in_addr *)(host->h_addr);
        serverAddress.assign(inet_ntoa(ia));
        ok = true;
    }
    return ok;
}
Uint32 _getReceivedTrapCount(Uint16 snmpVersion, const String& logFile)
{
    String trap1 = "Trap Info: TRAP, SNMP v1, community public";
    String trap2 = "Trap Info: TRAP2, SNMP v2c, community public";

    Uint32 receivedTrap1Count = 0;
    Uint32 receivedTrap2Count = 0;

    ifstream ifs(logFile.getCString());
    if (!ifs)
    {
        return (0);
    }

    String line;
    while (GetLine(ifs, line))
    {
        if (String::compare(line, trap1) == 0)
        {
            receivedTrap1Count++;
        }
        if (String::compare(line, trap2) == 0)
        {
            receivedTrap2Count++;
        }
    }

    ifs.close();

    switch (snmpVersion)
    {
    case _SNMPV1_TRAP:
    {
        return (receivedTrap1Count);
    }
    case _SNMPV2C_TRAP:
    {
        return (receivedTrap2Count);
    }
    default:
    {
        return (0);
    }
    }

}
Example #8
0
void ParserTestProvider::getInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    InstanceResponseHandler & handler)
{
    String Value;
    char csname[256];
    int cnum;
    char badstrname[256];

    cout << "ParserTestProvider::getInstance" << endl;

    CIMName className = instanceReference.getClassName();
    CIMNamespaceName nameSpace = instanceReference.getNameSpace();

    Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();

    for (int i = 0; i < (int)keys.size(); i++)
    {
        CIMName cimName = keys[i].getName();
        Value = keys[i].getValue();

        if (cimName.equal("BadStringName")) {
                strncpy(badstrname, Value.getCString(), 256);
        }
    }
    CIMInstance instance(CLASS_NAME);
    instance.setPath(CIMObjectPath(String::EMPTY, // hostname
                                      nameSpace,
                                      CLASS_NAME,
                                      keys));
    instance.addProperty(CIMProperty("CName",
                         String(CLASS_NAME)));
    instance.addProperty(CIMProperty("BadStringName",
                         String(badstrname)));
    
    //begin processing the request
    handler.processing();

    handler.deliver(instance);
    // complete processing the request
    handler.complete();
}
Example #9
0
bool VersionTable::updateVersion(const VersionInfo& versionInfo)
{
	String sql = "update Versions Set";
	sql.appendWithFormat(" VersionSync=%d,", versionInfo.iVersionSync);
	sql.appendWithFormat(" VersionDatabase=%d", versionInfo.iVersionDatabase);
	sql.appendWithFormat(" where VersionId=%d", versionInfo.iVersionId);

	int iResult = sqlite3_exec(InitDatabase::getInstance()->getDatabseSqlite(), sql.getCString(), NULL, NULL, NULL);
	if(iResult != SQLITE_OK)
		return false;

	m_VersionInfo = versionInfo;

	this->fetchVersion();

	return true;
}
/**
   _shutdown method for Solaris implementation of OS Provider

   Finds executable in /sbin, /usr/bin, or /usr/local/sbin and invokes.

   Don't we want to add some more cleanup - especially since we know
   the CIMOM is running - this could cause things to be set into a
   'Stopping' state while the OS cleans up before actually invoking
   the poweroff command.
   */
Uint32 OperatingSystem::_shutdown()
{
/*
******************************************************
ATTN: At the time of implementation the Provider Manager will not call
this function. The code is defined out becasue it is not clear that all
users would want this supportted. If it were to be supported then at a
minimum the user must be athenticated or the code should run switch and
run on behalf of the caller rather than as the CIMOM and then let the
system validate the users credentials and permissions to determine if
the calling user has the authority to invoke a shutdown or a reboot.
******************************************************
*/

   return false;

#ifdef NOTDEF
   const char *poweroff[] = { "poweroff", NULL };
   const char *paths[] = { "/sbin", "/usr/sbin", "/usr/local/sbin", NULL };
   struct stat sbuf;
   String fname;
   CString p;
   Uint32 result;

   result = 1;
   for (int ii = 0; paths[ii] != NULL; ii++)
   {
      for (int jj = 0; poweroff[jj]; jj++)
      {
         fname = paths[ii];
         fname.append("/");
         fname.append(poweroff[jj]);
         p = fname.getCString();
         if (stat(p, &sbuf) == 0 && (sbuf.st_mode & S_IXUSR))
         {
            result = 2;
            if (system(p) == 0)
               result = 0;

            return result;
         }
      }
   }
   return result;
#endif //NOTDEF
}
Example #11
0
//タイマー処理
void PuzzleScene::timerUpdate(float delta){
	if(timeswitch){
		nowTime -= delta;
        for(int i=0;i<homuns;i++){
            nowSkillEffectTime[i] -= delta;
        }
	}
	int timeM = int(nowTime)/60;
	int timeS = int(nowTime)%60;
	
	String *timestr = String::createWithFormat("%2.2d:%2.2d",timeM,timeS);
	timerlabel->setString(timestr->getCString());
	
	// タイマーの色
	if(nowTime < 60){
		timeColorChange();
	}
}
Example #12
0
static MessageLoaderParms _formMessage(
    Uint32 code,
    Uint32 line,
    const String& message)
{
    String dftMsg = _xmlMessages[Uint32(code) - 1];
    const char* key = _xmlKeys[Uint32(code) - 1];
    String msg = message;

    dftMsg.append(": on line $0");
    if (message.size())
    {
        msg = ": " + msg;
        dftMsg.append("$1");
    }

    return MessageLoaderParms(key, dftMsg.getCString(), line ,msg);
}
Example #13
0
int HTTPSessionList::_getSessionTimeout()
{
    PEG_METHOD_ENTER(TRC_AUTHENTICATION, "HTTPSessionList::_getSessionTimeout");
    // load httpSessionTimeout configuration value
    ConfigManager* configManager = ConfigManager::getInstance();
    String strTimeout = configManager->getCurrentValue("httpSessionTimeout");


    Uint64 timeout;
    StringConversion::decimalStringToUint64(strTimeout.getCString(),
            timeout, false);

    PEG_TRACE((TRC_AUTHENTICATION, Tracer::LEVEL3,
            "Session timeout is %d", (int)timeout));

    PEG_METHOD_EXIT();
    return timeout;
}
//
// Perform pegasus sepcific local authentication
//
AuthenticationStatus AuthenticationManager::performPegasusAuthentication(
    const String& authHeader,
    AuthenticationInfo* authInfo)
{
    PEG_METHOD_ENTER(TRC_AUTHENTICATION,
        "AuthenticationManager::performPegasusAuthentication()");

    AuthenticationStatus authStatus(AUTHSC_UNAUTHORIZED);

    String authType;
    String userName;
    String cookie;

    //
    // Parse the pegasus authentication header authentication information
    //
    if ( !HTTPMessage::parseLocalAuthHeader(authHeader,
              authType, userName, cookie) )
    {
        PEG_TRACE((
            TRC_DISCARDED_DATA,
            Tracer::LEVEL1,
            "PegasusAuthentication failed. "
                "Malformed Pegasus authentication header: %s",
            (const char*)authHeader.getCString()));
        PEG_METHOD_EXIT();
        return AuthenticationStatus(AUTHSC_UNAUTHORIZED);
    }

    // The HTTPAuthenticatorDelegator ensures only local authentication
    // requests get here.
    PEGASUS_ASSERT(authType == "Local");

    authStatus = _localAuthHandler->authenticate(cookie, authInfo);

    if ( authStatus.isSuccess() )
    {
        authInfo->setAuthType(authType);
    }

    PEG_METHOD_EXIT();

    return authStatus;
}
Example #15
0
bool PlaneEnemy::init(int planetype)
{
	Sprite::init();

	m_planeType = planetype;
	m_live = true;
	
	//初始化纹理图,战机速度,生命,分值
	String framename;
	switch (planetype)
	{
	case EnemyPlaneType::Enemy1:
		framename = "enemy1.png";
		m_velocity = random(0.5, 1.5) * Enemy1_Vec; //设置一个随机速度
		m_life = Enemy1_Life;
		m_points = Enemy1_Points;
		break;
	case EnemyPlaneType::Enemy2:
		framename = "enemy2.png";
		m_velocity = random(0.5, 1.5) * Enemy2_Vec;
		m_life = Enemy2_Life;
		m_points = Enemy2_Points;
		break;
	case EnemyPlaneType::Enemy3:
		framename = "enemy3_n1.png";
		m_velocity =  random(0.5, 1.5) * Enemy3_Vec;
		m_life = Enemy3_Life;
		m_points = Enemy3_Points;
		break;
	case EnemyPlaneType::Enemy4:
		framename = "enemy3_n2.png";
		m_velocity = random(0.5, 1.5) * Enemy4_Vec;
		m_life = Enemy4_Life;
		m_points = Enemy4_Points;
		break;
	}
	initWithSpriteFrameName(framename.getCString());

	//加载敌人爆炸精灵帧集合
	initEnemyBlowUpFrames(planetype);

	return true;
}
Example #16
0
void LayerGameMain::boomMenuCallback(cocos2d::Ref * ref)
{
	_bigBoomCount--;
	String strBoomCount;
	strBoomCount.initWithFormat("X %d",_bigBoomCount);
	LabelBMFont * labelCount = (LabelBMFont *)this->getChildByTag(TAG_BIGBOOMCOUNT);
	labelCount->setString(strBoomCount.getCString());

	_score += _enemyLayer->_smallVec.size()*SMALL_SCORE;
	_score += _enemyLayer->_midVec.size()*MID_SCORE;
	_score += _enemyLayer->_bigVec.size()*BIG_SCORE;
	_controlLayer->updateScore(_score);
	_enemyLayer->removeAllEnemy();
	if (_bigBoomCount == 0)
	{
		this->removeChildByTag(TAG_BIGBOOM);
		this->removeChildByTag(TAG_BIGBOOMCOUNT);
	}
}
Example #17
0
bool LabelAtlas::initWithString(const std::string& theString, const std::string& fntFile)
{
    std::string pathStr = FileUtils::getInstance()->fullPathForFilename(fntFile);
    std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
    Dictionary *dict = Dictionary::createWithContentsOfFile(pathStr.c_str());

    CCASSERT(((String*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version");

    std::string texturePathStr = relPathStr + ((String*)dict->objectForKey("textureFilename"))->getCString();
    String *textureFilename = String::create(texturePathStr);
    unsigned int width = ((String*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR();
    unsigned int height = ((String*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR();
    unsigned int startChar = ((String*)dict->objectForKey("firstChar"))->intValue();


    this->initWithString(theString, textureFilename->getCString(), width, height, startChar);

    return true;
}
Example #18
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::createQualifier  creates a qualifiers 
//									  
/////////////////////////////////////////////////////////////////////////////
void WMIClassProvider::createQualifier (const WMIQualifier &qualifier, 
										IWbemQualifierSet *pQual)
{
	HRESULT hr;
	
	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WmiClassProvider::createQualifier()");

	String sName = qualifier.getName().getString(); 
	CComBSTR bs = sName.getCString();
	WMIValue value(qualifier.getValue());
	WMIFlavor flavor(qualifier.getFlavor());
	
	CComVariant v;
	value.getAsVariant(&v);

	// key is created using a special call to wmi
	//if (!stricmp("key", ))
	if (String::equalNoCase("key", sName))
	{
		hr = pQual->Put(bs, &v, NULL);
	}
	else
	{
		hr = pQual->Put(bs, &v, flavor.getAsWMIValue());
	}
	v.Clear();
	bs.Empty();

	if (FAILED(hr))
	{
		CMyString msg;
		msg.Format("It is not possible to add the qualifier [%s] to the object! Error: 0x%X", 255, sName.getCString(), hr);
		
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, "WmiClassProvider::createQualifier() - %s", (LPCTSTR)msg);

		throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
	}

	PEG_METHOD_EXIT();

	return;
}
/**
    Checks to see if the given value is valid or not.
*/
Boolean ShutdownPropertyOwner::isValid(
    const String& name,
    const String& value) const
{
    //
    // convert timeout string to integer
    //
    long timeoutValue = strtol(value.getCString(), (char **)0, 10);

    if (String::equal(_shutdownTimeout->propertyName, name))
    {
        // Check if the timeout value is greater than the minimum allowed
        //
        return  timeoutValue >= MIN_SHUTDOWN_TIMEOUT;
    }
    else
    {
        throw UnrecognizedConfigProperty(name);
    }
}
void
clientRepositoryInterface::init(_repositoryType type, 
                                const String &location)
{
  String message;
  // _ot = ot;
  if (type == REPOSITORY_INTERFACE_LOCAL)
  {
      _repository = new CIMRepository(location);
      // test to find if repository exists.
  }
  else if (type == REPOSITORY_INTERFACE_CLIENT) 
  {
    // create a CIMClient object and put it in _client
    try
    {
        Uint32 index = location.find (':');
        String host = location.subString (0, index);
        Uint32 portNumber = 0;
        if (index != PEG_NOT_FOUND)
        {
            String portStr = location.subString (index + 1, location.size ());
            sscanf (portStr.getCString (), "%u", &portNumber);
        }
        cout << "open " << host << " port " << portNumber << endl;
        _client = new CIMClient();
        _client->connect (host, portNumber, String::EMPTY, String::EMPTY);
    } 
    
    catch(Exception &e) 
    {
	  cerr << "Internal Error:" << e.getMessage() << endl;
      delete _client;
      _client = 0;
    }
  }
  else 
  {
	  throw IndexOutOfBoundsException();
  }
}
Example #21
0
void TableSetUp::onHttpRequestCompleted(HttpClient *sender, HttpResponse *response)
{
	if (!response)
	{
		return;
	}

	// You can get original request type from: response->request->reqType
	if (0 != strlen(response->getHttpRequest()->getTag()))
	{
		CCLOG("%s completed", response->getHttpRequest()->getTag());
	}

	std::string strFile = FileUtils::getInstance()->getWritablePath() ;
	const char* pTag = response->getHttpRequest()->getTag() ;
	unsigned int nTag = atoi(pTag);
	String *pPicName = String::createWithFormat("res/PictureRes/%d.png",nTag);
	strFile = strFile + pPicName->getCString() ;

	SendChangeAvatar(true,nTag);
}
Example #22
0
void MapManager::debug(const char * temp)
{
	String str;
	str.appendWithFormat("%s\n", temp);

	for (int i = 0; i < SIZE_X; i++)
	{
		for (int j = 0; j < SIZE_Y; j++)
		{
//			str.appendWithFormat("%d ", map[i][j].type);
//			str.appendWithFormat("%d%d%d%d ", map[i][j].type, map[i][j].exp, map[i][j].lock, map[i][j].visible);
//			str.appendWithFormat("%d%d%d ", map[i][j].type, map[i][j].cnt_sideroom, map[i][j].priority);
			str.appendWithFormat("%d%s ", map[i][j].type, map[i][j].lock ? "t" : "f");
//			str.appendWithFormat("count room : %d ", _cntRoom);
//			str.appendWithFormat("count celar room : %d ", _clearCntRoom);
		}
		str.appendWithFormat("\n");
	}

	CCLOG(str.getCString());
}
Example #23
0
//------------------------------------------------------------------------------
// FUNCTION: getHostName
//
// REMARKS: Resolves name servers
//
// PARAMETERS:  [IN] serverAddress -> string containing the IP address
//                [OUT] hostName -> string that will contain the name server
//
// RETURN: TRUE if valid host IP, FALSE otherwise
//------------------------------------------------------------------------------
Boolean NTPService::getHostName(String serverAddress, String & hostName)
{
    Boolean ok = false;
    String strValue;
    struct hostent *host;
    struct in_addr ia;

    hostName.clear();
    if ((ia.s_addr = inet_addr(serverAddress.getCString())) != INADDR_NONE)
    {
        host = gethostbyaddr((const char *)&ia,
                              sizeof(struct in_addr),
                               AF_INET);
        if(host != NULL)
        {
            hostName.assign(host->h_name);
            ok = true;
        }
   }
   return ok;
}
Example #24
0
ModuleController::client_handle *test_module::get_client_handle(void)
{
   if(_client_handle == NULL)
   {
      CString temp = _controller_name.getCString();
      if( temp )
      {
	 try 
	 {
	    _controller = &(ModuleController::get_client_handle(temp, _id, &_client_handle));
	 }
	 catch(IncompatibleTypesException &)
	 {
	    ;
	 }
	 delete temp;
      }
   }
   
   return _client_handle;
}
PEGASUS_NAMESPACE_BEGIN


CIMOperationRequestEncoder::CIMOperationRequestEncoder(
    MessageQueue* outputQueue,
    const String& hostName,
    ClientAuthenticator* authenticator,
    Uint32 showOutput,
    bool binaryRequest,
    bool binaryResponse)
    :
    MessageQueue(PEGASUS_QUEUENAME_OPREQENCODER),
    _outputQueue(outputQueue),
    _hostName(hostName.getCString()),
    _authenticator(authenticator),
    _showOutput(showOutput),
    _binaryRequest(binaryRequest),
    _binaryResponse(binaryResponse)
{
    dataStore_prt=NULL;
}
Example #26
0
//触摸到某个cell的事件
void TaskListLayer::tableCellTouched(cocos2d::extension::TableView* table, cocos2d::extension::TableViewCell* cell)
{
	int i = cell->getIdx();
	if (i < 3 && cell->getChildByTag(777)->getChildByTag(888))
	{
		DialogLayer* d = DialogLayer::create(Sprite::createWithSpriteFrameName("tipsbase.png"));
		d->setContentSize(Size(500, 200));
		//d->setPosition(0, -100);
		String* title = String::createWithFormat("task_get_text_%d", i + 1);
		d->setTitle(AppStringFile::getInstance()->getStringForKey(title->getCString()).c_str());
		d->addButton("ok", 
			Sprite::createWithSpriteFrameName("button_0.png"),
			Sprite::createWithSpriteFrameName("button_2.png"),
			Sprite::createWithSpriteFrameName("button_2.png"),
			[d](Ref* pSender){
				d->removeFromParent();
			},0);
		Director::getInstance()->getRunningScene()->addChild(d);
		cell->getChildByTag(777)->removeChildByTag(888);
	}
}
Example #27
0
// Stop snmptrapd process if it is running and remove
// procIdFile file if it exists
//
void _stopSnmptrapd(const String& processIdFile)
{
    Uint32 receiverPid;
    FILE *fd;
    if ((fd = fopen(processIdFile.getCString(), "r")) != NULL)
    {
        if (fscanf(fd, "%d\n", &receiverPid) != 1)
        {
            throw Exception("Failed to read trapd pid from procIdFile.");
        }

        kill(receiverPid, SIGTERM);

        fclose(fd);
    }

    if (FileSystem::exists(processIdFile))
    {
        FileSystem::removeFile(processIdFile);
    }
}
Example #28
0
bool AlienLayer::initWithPlist(const char* plist, const char* frameName)
{
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plist);
	
	if(sprtfrm_Alien = SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName))
	{
		sprt_Alien = Sprite::createWithSpriteFrame(sprtfrm_Alien);
		addChild(sprt_Alien, 1);

		// Alien's Animation
		Array* animFrames = Array::createWithCapacity(3);

		for(int i = 1; i < 4; i++) 
		{
			String* strAlien = String::createWithFormat("chorogging%d.png", i);
			SpriteFrame* frame = SpriteFrameCache::getInstance()->getSpriteFrameByName( strAlien->getCString() );
			animFrames->addObject(frame);
		}

		auto animation = Animation::createWithSpriteFrames(animFrames, 0.3f);
		sprt_Alien->runAction( RepeatForever::create( Animate::create(animation) ) );

		// Get random x,y pos
		//posX = UtilFunc::getRandomRangeValue(cAlienGenPosXMin, cAlienGenPosXMax);
		int randXIdx = (rand() % 6);
		posX = cAlienGenPosX[randXIdx];

		int yPos = UtilFunc::getRandomRangeValue(cAlienGenPosY-100, cAlienGenPosY);
		setPosition(Point(posX, yPos));

		// Get random actualDuration
		//float actualDuration = UtilFunc::getRandomRangeValue(0.4f, 6.4f);
		float actualDuration = cAlienMoveSpeed[randXIdx];

		// Action
		actionSequenceTopToBottom(this, actualDuration);
	}

	return true;
}
Example #29
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::classAlreadyExists
//
// ///////////////////////////////////////////////////////////////////////////
Boolean WMIClassProvider::classAlreadyExists (const String& className)
{
    PEG_METHOD_ENTER(TRC_WMIPROVIDER,
        "WmiClassProvider::classAlreadyExists()");
    
    CComPtr<IWbemClassObject> pClass;
    
    try
    {
        if (_collector->getObject(&pClass, className))
        {
            PEG_TRACE((TRC_WMIPROVIDER, Tracer::LEVEL2,
                "WMIClassProvider::classAlreadyExists() - the class %s "
                "already exists", className.getCString()));

            if (pClass)
                pClass.Release();

            return true;
        }
    }
    catch(CIMException &e)
    {
        if (pClass)
            pClass.Release();

        switch(e.getCode())
        {
            case CIM_ERR_NOT_FOUND: return false; break;
            default: throw;
        }
    }

    if (pClass)
        pClass.Release();

    PEG_METHOD_EXIT();

    return false;
}
Example #30
0
Boolean Cimservera::performAcctMgmt (const String& userName)
{
    Boolean authenticated = false;
    struct pam_conv pconv;
    pam_handle_t *phandle;
    char *name;
    APP_DATA mydata;

    const char *service = "wbem";
    pconv.conv = PAMBasicAuthenticator::pamValidateUserCallback;
    pconv.appdata_ptr = &mydata;

    //
    // Call pam_start since you need to before making any other PAM calls
    //
    if ( pam_start(service,
        (const char *)userName.getCString(), &pconv, &phandle) != PAM_SUCCESS)
    {
        return (authenticated);
    }

    //
    // Call pam_acct_mgmt, to check if the user account is valid. This include s
    // checking for account expiration, as well as verifying access
    // hour restrictions.
    //
    if ( pam_acct_mgmt(phandle, 0) == PAM_SUCCESS )
    {
         authenticated = true;
    }

    //
    //Call pam_end to end our PAM work
    //
    pam_end(phandle, 0);

    return (authenticated);
}