Ejemplo n.º 1
0
void CMediaSourceServerProfile::sendTrackList(std::string const& trackList)
{
   LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
   static const int packetSize = MEDIA_TRACKLIST_PACKET_SIZE;
   div_t divresult = div(trackList.size(), packetSize);
   int packetsNumber = divresult.quot + (divresult.rem == 0 ? 0 : 1);
   LOG4CPLUS_INFO(msLogger, "sendTrackList() total packets number = " + convertIntegerToString(packetsNumber));
   LOG4CPLUS_INFO(msLogger, "sendTrackList() full packets number = " + convertIntegerToString(divresult.quot));
   prepareRequest(DECLARE_TRACKLIST_PACKETS_NUMBER, true, convertIntegerToString(packetsNumber));
   int offset = 0;
   for (int i = 0; i < divresult.quot; i++) 
   {
      LOG4CPLUS_INFO(msLogger, "sendTrackList() sending packet number: " + convertIntegerToString(i));
      offset = i * packetSize;
      LOG4CPLUS_INFO(msLogger, "sendTrackList() sending packet, offset is: " + convertIntegerToString(offset));
      LOG4CPLUS_INFO(msLogger, "sendTrackList() sending packet, content is: " + trackList.substr(offset, packetSize));
      prepareRequest(SENDTRACKLIST, true, trackList.substr(offset, packetSize));
   }
   offset = packetSize * divresult.quot;
   if (divresult.rem != 0)
   {
      LOG4CPLUS_INFO(msLogger, "sendTrackList() sending last packet: " + trackList.substr(offset));
      prepareRequest(SENDTRACKLIST, true, trackList.substr(offset));
   }
}
Ejemplo n.º 2
0
ERROR_CODE CUnixSocket::send(const UInt8* pData, UInt32 data_size)
{
   LOG4CPLUS_INFO(logger, "CUnixSocket::send data = " + convertIntegerToString(*pData)
                        + ", data_size = " + convertIntegerToString(data_size));
   LOG4CPLUS_INFO(logger, "+++++++++++++++++++++++++++++++++SEND DATA++++++++++++++++++++++++++++++++");
   //_hex_print(pData,data_size );
   LOG4CPLUS_INFO(logger, "+++++++++++++++++++++++++++++++++SEND DATA END++++++++++++++++++++++++++++++++");
   ssize_t n = ::send(mSock, pData, data_size, MSG_NOSIGNAL);

   if (n < 0)
   {
      LOG4CPLUS_ERROR(logger, "CUnixSocket::sendPrepearedArray() - "
                    + string(CThread::getName())
                    + " connection lost: " + strerror(errno));

      //mSocketMutex.lockWrite();
      mSock = -1; // TODO : do it more beautiful in future
      //mSocketMutex.unlock();

      //mWriteMutex.unlock();

      assert(mpSubscriber);
      mpSubscriber->onConnectionLost(this);

      return ERR_CONNECTION_LOST;
   }
   else
   {
      LOG4CPLUS_INFO(logger, "CUnixSocket::sendPrepearedArray() - "
         "array is sent (number of bytes: " + convertIntegerToString(n)
         + ") error " + strerror(errno));
      //mWriteMutex.unlock();
      return ERR_OK;
   }
}
Ejemplo n.º 3
0
   virtual void dataReceivedCallback(const UInt32 channel_id, const UInt32 read_size)//, const UInt32 free_size)
   {
      LOG4CPLUS_TRACE(msLogger, std::string("Test::bufferOverflowCallback ") + 
         "channel_id = " + convertIntegerToString(channel_id) +
         "read_size = "  + convertIntegerToString(read_size));
//         "free_size = "  + convertIntegerToString(free_size));
   }
Ejemplo n.º 4
0
int CSignalSemaphoreInterproc::tryWait (void)
{
   if (sem_trywait(mpSem) == 0)
   {
      return 0;
   }
   else
   {
      int saved_errno = errno;
      switch (saved_errno)
      {
      case EAGAIN:
            break;
      case EDEADLK:
      case EINTR:
      case EINVAL:
         {
            LOG4CPLUS_WARN(logger, "tryWait(): sem_trywait failed: " + convertIntegerToString(saved_errno)
                                 + " - " + std::string(strerror(saved_errno)));
            break;
         }
         /* // all other cases must wait again */
      default :
         {
             LOG4CPLUS_WARN(logger, "tryWait(): sem_trywait failed: " + convertIntegerToString(saved_errno)
                                  + " - " + std::string(strerror(saved_errno)));
             break;
         }
      }
      return -1;
   }
}
Ejemplo n.º 5
0
void PmpComponentManager::onNegotiateRole(UInt32 number)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );
    LOG4CPLUS_INFO(mLogger, "mRoleNumber:" +  convertIntegerToString(mRoleNubmer) +
            " number: " + convertIntegerToString(number));
    if (-1 == mRoleNubmer)
    {
    	LOG4CPLUS_INFO(mLogger, "RoleNegotiationBackOrder");
    	mOtherRoleNumber = number;
    }
    else if (mRoleNubmer == number)
    {
        negotiateRole();
    }
    else
    {
        if (mRoleNubmer > number)
        {
            mRole = PMP_ROLE_MASTER;
        }
        else
        {
            mRole = PMP_ROLE_SLAVE;
        }
        checkWaitingServices();
    }
}
Ejemplo n.º 6
0
/**
 * Method adds message being waited to the Waiter
 * @param message - message to be waited
 * @return message being waited in case message received, otherwise returns TIMEOUT_MSG which means timeout
 */
InterAppMessage Waiter::waitMessage(InterAppMessage message, int timeout)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);

    InterAppMessage msg = ERROR_MSG;

    //cleaning-up the previously stored messages if there are any and adding message to be waited
    mMessageMap.clear();
    mMessageMap.insert(std::make_pair(message, false));  //map because someday it will be possible to wait several messages

    //wait for timeout
    LOG4CPLUS_INFO(mLogger, "start waiting for message " + convertIntegerToString((int) message));
    if (mTimeoutSema.waitTimeout(timeout))
    {
        LOG4CPLUS_WARN(mLogger, "Timeout occurred ");
        msg = TIMEOUT_MSG;
    }
    else
    {
        msg = message;
    }

    LOG4CPLUS_INFO(mLogger, "wait result: " + convertIntegerToString((int) msg));

    return msg;
}
Ejemplo n.º 7
0
   virtual void dataReceivedCallback(const UInt32 channel_id, const UInt32 read_size)
   {
      LOG4CPLUS_TRACE(msLogger, std::string("DataLostAfterChannelAlloc::bufferOverflowCallback ") + 
         "channel_id = " + convertIntegerToString(channel_id) +
         "read_size = "  + convertIntegerToString(read_size));

      data_sem.signal();
   }
Ejemplo n.º 8
0
	void dataReceivedCallback(const UInt32 channel_id, const UInt32 read_size)
	{
		LOG4CPLUS_TRACE_METHOD(logger,
				"ChannelObserver::dataReceivedCallback()=> channel"
						+ convertIntegerToString(channel_id) + "size"
						+ convertIntegerToString(read_size));
		if (m_tubeObserver)
		{
			MutexLocker lock(*mMutex);
			m_tubeObserver->onDataReceived(channel_id, read_size);
		}
	}
Ejemplo n.º 9
0
void WaitingServiceManager::startWaitingServiceRequest(bool master)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );
    if (!master)
    {
        LOG4CPLUS_INFO(mLogger, "startWaitingServiceRequest: !master");
        std::list<Service::Uid> pairServices;
        for (std::list<Service::Uid>::iterator it = mLocalWaitingServices.begin();
                mLocalWaitingServices.end() != it; ++it)
        {
            LOG4CPLUS_INFO(mLogger, "local service: " + it->value());
            pairServices.push_back(mServiceRepository->getServiceInfo(*it)->pairUid());
        }
        mSessionProtocol->sendWaitingServicesList(pairServices);
    }
    else // master
    {
        LOG4CPLUS_INFO(mLogger, "startWaitingServiceRequest: master");
        UInt32 minPrio = UINT_MAX;
        Service::Uid service;
        for (std::list<Service::Uid>::iterator it = mLocalWaitingServices.begin();
                mLocalWaitingServices.end() != it; ++it)
        {
            LOG4CPLUS_INFO(mLogger, "local service: " + it->value());
            UInt32 itPrio = mServiceRepository->getServiceInfo(*it)->priority();
            LOG4CPLUS_INFO(mLogger, "local service " + it->value() + " prio " + convertIntegerToString(itPrio));
            if (itPrio < minPrio && 0 != itPrio)
            {
                LOG4CPLUS_INFO(mLogger, "Min local service: " + it->value());
                service = *it;
                minPrio = itPrio;
            }
        }

        for (std::list<Service::Uid>::iterator it = mRemoteWaitingServices.begin();
                mRemoteWaitingServices.end() != it; ++it)
        {
            LOG4CPLUS_INFO(mLogger, "remote service " + it->value());
            UInt32 itPrio = mServiceRepository->getServiceInfo(*it)->priority();
            LOG4CPLUS_INFO(mLogger, "remote service " + it->value() + " prio " + convertIntegerToString(itPrio));
            if (itPrio < minPrio && 0 != itPrio)
            {
                LOG4CPLUS_INFO(mLogger, "Min remote service: " + it->value());
                service = *it;
                minPrio = itPrio;
            }
        }

        mStartRequest = true;
        mServiceToStart = service;
        startWaitingServiceInAppLib();
    }
}
Ejemplo n.º 10
0
 void CRunApp::print() const
 {
    LOG4CPLUS_INFO(msLogger, "  AppID: " + convertIntegerToString(mAppId) +
          " PID: " + convertIntegerToString(mPid) + " Session: " + mSession.value());
    std::string services;
    for (std::set<Service::Uid>::const_iterator it = mServices.begin();
          mServices.end() != it; ++it)
    {
       services += " ";
       services += it->value();
    }
    LOG4CPLUS_INFO(msLogger, "   Services:" + services);
 }
Ejemplo n.º 11
0
      void UbuntuLauncher::onSIGCHLD(int signal_number)
      {
         LOG4CPLUS_TRACE(sLogger, "onSIGCHLD(" + convertIntegerToString(signal_number) + ")");

         pid_t pid = -1;
         int status;

         while((pid = waitpid(-1, &status, WNOHANG)) > 0)
         {
            LOG4CPLUS_INFO(sLogger, "Child with PID " + convertIntegerToString(pid) + "exited with status "
          		                                   + convertIntegerToString((int)WEXITSTATUS(status)));
         }
      }
Ejemplo n.º 12
0
 void setCookieFromJson(const Json::Value root)
 {
     LOG4CPLUS_TRACE_METHOD(Logger::getInstance("samples.state"), __PRETTY_FUNCTION__);
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "mCookie = " + convertIntegerToString(mCookie));
     mCookie = root.get(STATE_COOKIE_TAG, mCookie).asInt();
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "after set from json mCookie = " + convertIntegerToString(mCookie));
 }
Ejemplo n.º 13
0
//from CChannelHandler
void CMediaSourceServerProfile::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::Buffer const& buffer)
{
  LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
   if (mChannelID != channel)
   {
      LOG4CPLUS_ERROR(msLogger, "mChannelID != channel_id");
      return;
   }
   else
   {
      LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id");
   }
   
   UInt8 *incomingData = buffer.getBuffer();
   int read_size = buffer.getSize();

   LOG4CPLUS_INFO(msLogger, "Procedure ID = " + convertIntegerToString(incomingData[0]));

   if(incomingData[0] == REQUESTTRACKLIST)
   {
         LOG4CPLUS_INFO(msLogger, "case REQUESTTRACKLIST");
         mpAppCallbacks->onRequestTrackList(true);
   }
   else
   {
        LOG4CPLUS_INFO(msLogger, "unknown procedure ID");
   }

}
Ejemplo n.º 14
0
void Waiter::tryMessage(InterAppMessage message)
{

    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);

    LOG4CPLUS_INFO(mLogger, "Try message: " + convertIntegerToString((int) message));

    MessageMap::iterator iterator;

    for (iterator = mMessageMap.begin(); iterator != mMessageMap.end(); ++iterator)
    {
        if ((*iterator).first == message)
        {
            (*iterator).second = true;

            //check all the messages are received
            if (checkWaitComplete())
            {
                LOG4CPLUS_INFO(mLogger, "Signaling Sema");
                mTimeoutSema.signal();
            }
            break;
        }
    }
    return;
}
Ejemplo n.º 15
0
 void CAppManPmpIpcClient::loop()
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    mBe = true;
    CError err = CError::NoError("","");
    for (int i = 1;mBe ; ++i)
    {
       LOG4CPLUS_INFO(msLogger, "loop() : connect trying number : " + convertIntegerToString(i));
       err = mpIpc->connect();
       LOG4CPLUS_INFO(msLogger, "loop() : connect ended");
       if (mBe && err.isNoError())
       {
          mNoConnection = false;
          mConLostSem.wait();
          mNoConnection = true;
       }
       if (!mBe)
       {
          LOG4CPLUS_INFO(msLogger, "loop() :: mBe == false");
          break;
       }
       LOG4CPLUS_WARN(msLogger, "loop() :: connection failed");
       usleep(250000);
    }
 }
Ejemplo n.º 16
0
      BaseError CServiceManager::incomingProfile(Service::Uid const& service,
            Profile::Uid const& profile, Profile::ApiUid const& api)
      {
         LOG4CPLUS_TRACE(msLogger, "CServiceManager::incomingProfileRequest()=> requested  profile "
            + profile.value() +"for service"+service.value() );

         mActiveServicesMutex.lock();
         tServiceMap::iterator it = mActiveServices.find(service);
         if (mActiveServices.end() == it)
         {
            mActiveServicesMutex.unlock();
            return BaseError(1,"ServiceManager",BaseError::IVILINK_ERROR,"Can't load incoming profile");
         }
         ERROR_CODE err = it->second->incomingProfileRequest(profile,api);
         bool allLoaded = it->second->allLoaded();
         mActiveServicesMutex.unlock();

         if (ERR_OK != err)
         {
            if (mpClient)
            {
                LOG4CPLUS_ERROR(msLogger, service.value() + ": error " + convertIntegerToString(int(err)) +
                                "in incomingProfileRequest(" + profile.value() + ","+ api.value() + ")");
               mpClient->serviceLoadError(service);
            }
            unload(service);
            return BaseError(1,gModuleName, BaseError::IVILINK_ERROR, "incomingProfile-Error");
         }
         if (allLoaded && mpClient)
         {
            mpClient->serviceLoaded(service);
         }
         return BaseError::NoError(gModuleName, "incomingProfile-No_Error");
      }
Ejemplo n.º 17
0
void PmpComponentManager::genRandomNumber()
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );

    mRoleNubmer = abs(rand()+1);
    LOG4CPLUS_INFO(mLogger, "Generated random number: " + convertIntegerToString(mRoleNubmer));
}
void CMediaStreamingClientProfile::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::Buffer const& buffer) 
{
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    if (mChannelID != channel) {
        LOG4CPLUS_INFO(msLogger, "mChannelID != channel_id");
        return;
    } else {
        LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id");
    }

 
   UInt8 *incomingData = buffer.getBuffer();
   int read_size = buffer.getSize();

   LOG4CPLUS_INFO(msLogger, "Procedure ID = " + convertIntegerToString(incomingData[0]));


   if(incomingData[0] == SENDSTREAMINGINFO)
   {
        LOG4CPLUS_INFO(msLogger, "case SENDSTREAMINGINFO");
        std::string info((char*)(incomingData + 1), read_size - 1);
        LOG4CPLUS_INFO(msLogger, "info  = " + info);
        procInfo(info);
   }
   else
   {
        LOG4CPLUS_INFO(msLogger, "unknown procedure ID");
   }

}
Ejemplo n.º 19
0
      void CPmpProtocol::connect()
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         while (mBe)
         {
            LOG4CPLUS_INFO(msLogger, "connect attempt");
            UInt32 chid = 0;
            CError err = iviLink::ChannelSupervisor::allocateChannel(this,mTag.c_str(), chid);
            if (err.isNoError())
            {
               mChannelIdCond.lock();
               LOG4CPLUS_INFO(msLogger, "ok chid = " +
                     convertIntegerToString(static_cast<int>(chid)));
               mChannelId = chid;
               mChannelIdCond.broadcast();
               mChannelIdCond.unlock();

               mConnectionLostSem.wait();
            }
            else
            {
               LOG4CPLUS_INFO(msLogger, static_cast<std::string>(err));
               sleep(1);
            }
         }
      }
Ejemplo n.º 20
0
 void setCookie(const int cookie)
 {
     LOG4CPLUS_TRACE_METHOD(Logger::getInstance("samples.state"), __PRETTY_FUNCTION__);
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "mCookie = " + convertIntegerToString(mCookie) + " cookie = " + convertIntegerToString(cookie));
     mCookie = cookie;
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "after set mCookie = " + convertIntegerToString(mCookie));
 }
Ejemplo n.º 21
0
IpcServer::IpcServer(const std::string& connectionName, int clientsNumber)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);
    mClientsNumber = clientsNumber;
    LOG4CPLUS_INFO(mLogger, "Clients number: " + convertIntegerToString(mClientsNumber));
    mIpc = new CIpc(connectionName, *this);
}
Ejemplo n.º 22
0
void IpcServer::testCaseShutdownOnRequest()
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);
    mIpc->beginWaitForConnection();
    for (int i = 0; i < mClientsNumber; i++)
    {
        mConnectionSema.wait();
    }
    mIpc->endWaitForConnection();
    assert (mIpc->isConnected());
    assert (mClients.size() == mClientsNumber);
    LOG4CPLUS_INFO(mLogger, "Established connection with all expected clients: " + convertIntegerToString(mClientsNumber));
    if (mClientsNumber == 1)
    {
        sendPing();
        sendKill();
    }
    else
    {
        for (int i = 0; i < mClientsNumber; i++)
        {
            sendPing(&mClients.at(i));
        }
        for (int i = 0; i < mClientsNumber; i++)
        {
            sendKill(&mClients.at(i));
        }

    }
    LOG4CPLUS_INFO(mLogger, "Test passed successfully!");
}
void CMediaStreamingServerProfile::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::Buffer const& buffer) {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    if (mChannelID != channel) {
        LOG4CPLUS_INFO(msLogger, "mChannelID != channel_id");
        return;
    } else {
        LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id");
    }

    UInt8 *incomingData = buffer.getBuffer();

    LOG4CPLUS_INFO(msLogger, "Procedure ID = " + convertIntegerToString(incomingData[0]));


    if(incomingData[0] == STREAMINGACCEPTED)
    {
        LOG4CPLUS_INFO(msLogger, "case STREAMINGACCEPTED");
        mpAppCallbacks->onStreamingServerAccepted(true);

    }
    else if(incomingData[0] == STREAMINGUNACCEPTED)
    {
        LOG4CPLUS_INFO(msLogger, "case STREAMINGUNACCEPTED");
        mpAppCallbacks->onStreamingServerUnaccepted(true);
    }
    else
    {
        LOG4CPLUS_INFO(msLogger, "unknown procedure ID");
    }

}
Ejemplo n.º 24
0
void PmpSessionProtocol::onReceivedServicesList(PMPFrame * frame)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );
    assert(mEventFactory);

    if (!frame)
    {
        LOG4CPLUS_ERROR(mLogger, "No frame");
        return;
    }

    UInt32 count;
    memcpy(&count,frame->data,sizeof(count));
    count = ByteOrder::ntoh32(count);
    int pos = sizeof(count);
    LOG4CPLUS_INFO(mLogger, "RES COUNT : " + convertIntegerToString(count));
    std::list<Service::Uid> services;

    for (UInt32 i = 0; i<count; ++i)
    {
        std::string str = bufferToString(frame->data+pos,true);
        services.push_back(Service::Uid(str));
        pos += stringInBufSize(str);
    }
    mEventFactory->receiveRemoteWaitingServiceList(services);
}
Ejemplo n.º 25
0
 void touchCookie()
 {
     LOG4CPLUS_TRACE_METHOD(Logger::getInstance("samples.state"), __PRETTY_FUNCTION__);
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "mCookie = " + convertIntegerToString(mCookie));
     mCookie ++;
     LOG4CPLUS_INFO(Logger::getInstance("samples.state"), "after touch mCookie = " + convertIntegerToString(mCookie));
 }
Ejemplo n.º 26
0
bool PmpSessionProtocol::sendWaitingServicesList(const std::list<Service::Uid> & services)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );

    assert(mPmpProtocol);

    UInt32 count = services.size();
    UInt32 size = sizeof(PMPFrame) + sizeof(count);
    for (std::list<Service::Uid>::const_iterator it = services.begin();
    services.end() != it; ++it)
    {
        size += stringInBufSize(it->value());
    }

    PMPFrame * pReq = reinterpret_cast<PMPFrame*>(new UInt8[size]);
    pReq->size = size;
    pReq->reqType = PMP_REQ_SESSION_SEND_WAITING_SERVICES;

    LOG4CPLUS_INFO(mLogger, "count: " + convertIntegerToString(count));
    count = ByteOrder::hton32(count);
    memcpy(pReq->data, &count, sizeof(count));
    UInt32 pos = sizeof(count);
    for (std::list<Profile::Uid>::const_iterator it = services.begin();
            services.end() != it; ++it)
    {
        stringToBuffer(it->value(),pReq->data + pos,true);
        pos += stringInBufSize(it->value());
    }

    assert(pos == size-sizeof(PMPFrame));
    bool res = mPmpProtocol->makeSessionRequest(*pReq);
    delete [] pReq;
    return res;
}
Ejemplo n.º 27
0
   virtual void go()
   {
      LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);

      pthread_barrier_t bar;
      if (int err = pthread_barrier_init(&bar, NULL, count))
      {
         LOG4CPLUS_ERROR(msLogger, "pthread_barrier_init err = " + convertIntegerToString(err) + strerror(err));
         assert(false && "pthread_barrier_init err");
      }

      mpPool = new CThreadPool(count);
      CSignalSemaphore sem;

      for (UInt32 i = 0; i < count; ++i)
      {
         JobBarrierData* jbd = new JobBarrierData;
         jbd->pBar = &bar;
         jbd->pSem = &sem;
         CThreadPoolJob job(MultipleOpenCloseMultithreadTest::job, jbd);
         mpPool->addJob(job);
      }
      
      LOG4CPLUS_INFO(msLogger, "sem wait");
      sem.wait();
      LOG4CPLUS_INFO(msLogger, "sem wait done");

      delete mpPool;
   }
Ejemplo n.º 28
0
      CError CPmpCoreProtocol::getAvailableProfileComplements(std::list<Profile::Uid> & complements)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         PMPFrame * pReq = new PMPFrame;
         pReq->size = sizeof(PMPFrame);
         pReq->reqType = PMP_REQ_CORE_GET_COMPLEMENTS;

         PMPFrame * pResp = mpPmpProtocol->makeCoreRequest(*pReq);
         delete pReq;

         if (!pResp)
         {
            LOG4CPLUS_ERROR(msLogger, "Network error");
            return CPmpError(CPmpError::ERROR_NETWORK);
         }

         UInt32 count;
         memcpy(&count,pResp->data,4);
         count = ByteOrder::ntoh32(count);
         int pos = 4;
         LOG4CPLUS_INFO(msLogger, "RES COUNT : " + convertIntegerToString(count));
         for (UInt32 i = 0; i<count; ++i)
         {
            std::string str = bufferToString(pResp->data+pos,true);
            complements.push_back(Profile::Uid(str));
            pos += stringInBufSize(str);
         }

         delete[] pResp;
         return CPmpError::NoPmpError();
      }
Ejemplo n.º 29
0
 int CProfileRepoServerClb::loop()
 {
    CError err = CError::NoError("ProfileRepository","loop");
    for (int i = 1; ; ++i)
    {
       LOG4CPLUS_INFO(msLogger, "CProfileRepoServerClb::loop() : connection try number: "+
             convertIntegerToString(i));
       err = mpIpc->waitForConnection();
       LOG4CPLUS_INFO(msLogger, "CProfileRepoServerClb::loop() : waitForConnectionEnded()");
       if (err.isNoError())
       {
          LOG4CPLUS_INFO(msLogger,"CProfileRepoServerClb::loop() :: *** client connected to server ***");
          mConLostSem.wait();
          LOG4CPLUS_INFO(msLogger,"CProfileRepoServerClb::loop() :: *** connection lost, exiting ***");
          return 0;
       }
       else
       {
          LOG4CPLUS_INFO(msLogger, static_cast<std::string>(err));
       }
       LOG4CPLUS_INFO(msLogger, "failed connection");
       usleep (250000);
    }
    return 0;
 }
Ejemplo n.º 30
0
SystemControllerMsg::SystemControllerMsg()
    : SystemControllerMsgProxy("SysCtrl_PrflMngr")
    , mEventFactory(NULL)
    , mLogger(Logger::getInstance(LOG4CPLUS_TEXT("profileManager.PMP.SystemControllerMsg")))
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__ );

    bool noError = false;
    for (int i = 0; i < 5; ++i)
    {
        LOG4CPLUS_INFO(mLogger, "Try to connect to System Controller number " + convertIntegerToString(i));
        if (connect().isNoError())
        {
            noError = true;
            break;
        }
        usleep(250000);
    }

    if (!noError)
    {
        LOG4CPLUS_FATAL(mLogger, "Can't connect to system controller");
        killProcess(1);
    }
}