コード例 #1
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;
}
コード例 #2
0
ファイル: PmpPimProtocol.cpp プロジェクト: Luxoft/iviLink
bool PmpPimProtocol::createProfile(iviLink::Profile::Uid const& profileUid,
        iviLink::Profile::IUid const& piuid,
        iviLink::Service::Uid const& sid)
{
    UInt32 size = sizeof(PMPFrame);
    size += stringInBufSize(profileUid.value());
    size += stringInBufSize(piuid.value());
    size += stringInBufSize(sid.value());

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

    stringToBuffer(profileUid.value(),pReq->data,true);
    unsigned int pos = stringInBufSize(profileUid.value());
    stringToBuffer(piuid.value(),pReq->data + pos,true);
    pos += stringInBufSize(piuid.value());
    stringToBuffer(sid.value(),pReq->data + pos,true);

    bool res = mPmpProtocol->makePimRequest(*pReq);
    delete [] pReq;

    return res;
}
コード例 #3
0
 void CProfileRepoServerClb::addProfileImplementation(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    UID uid(bufferToString(req->data));
    int pos = stringInBufSize(uid.value);
    iviLink::LibDescriptor ld;
    ld.libPath = bufferToString(req->data + pos);
    pos += stringInBufSize(ld.libPath);
    ld.platform = bufferToString(req->data + pos);
    CError err = mProfileDB.addProfileImplementation(uid,ld);
    UInt32 code = err.getCode();
    memcpy (pResponseBuffer, &code, 4);
    bufferSize = 4;
 }
コード例 #4
0
ファイル: PmpPimProtocol.cpp プロジェクト: Luxoft/iviLink
void PmpPimProtocol::onCreateProfile(PMPFrame * pFrame)
{
    assert(pFrame);
    assert(mEventFactory);

    std::string str = bufferToString(pFrame->data,true);
    unsigned int pos = stringInBufSize(str);
    iviLink::Profile::Uid profileUid(str);
    str = bufferToString(pFrame->data + pos,true);
    pos += stringInBufSize(str);
    iviLink::Profile::IUid piuid(str);
    str = bufferToString(pFrame->data + pos,true);
    iviLink::Service::Uid sid(str);

    mEventFactory->pimProtocolCreateProfile(profileUid, piuid, sid);
}
コード例 #5
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();
      }
コード例 #6
0
      CError CPmpCoreProtocol::disableByClient(iviLink::CUid id)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         LOG4CPLUS_INFO(msLogger, "id: " + id.value());
         UInt32 reqSize = sizeof(PMPFrame);
         reqSize += stringInBufSize(id.value());
         PMPFrame * pReq = reinterpret_cast<PMPFrame*>(new UInt8[reqSize]);
         pReq->size = reqSize;
         pReq->reqType = PMP_REQ_CORE_DIS_BY_CLIENT;
         stringToBuffer(id.value(),pReq->data,true);

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

         LOG4CPLUS_INFO(msLogger, "after pReq deleting");

         if (!pResp)
         {
            return CPmpError(CPmpError::ERROR_NETWORK);
         }

         bool res = pResp->data[0];
         delete[] pResp;
         return res ? CPmpError::NoPmpError() : CPmpError(CPmpError::ERROR_FUNCTION_FAILED);
      }
コード例 #7
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);
}
コード例 #8
0
 void CProfileRepoServerClb::getManifest(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    UID uid(bufferToString(req->data));
    std::string strRes = mProfileDB.getManifest(uid);
    stringToBuffer(strRes,pResponseBuffer);
    bufferSize = stringInBufSize(strRes);
 }
コード例 #9
0
 void CProfileRepoServerClb::removeProfileImplementationPl(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    UID uid(bufferToString(req->data));
    int pos = stringInBufSize(uid.value);
    std::string platform = bufferToString(req->data + pos);
    CError err = mProfileDB.removeProfileImplementation(uid,platform);
    UInt32 code = err.getCode();
    memcpy (pResponseBuffer, &code, 4);
    bufferSize = 4;
 }
コード例 #10
0
 CError CAppManPmpIpcClient::applicationRequest(iviLink::Service::SessionUid session, iviLink::Service::Uid service)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    UInt32 type = 0;
    UInt32 size = sizeof(type) + sizeof(size);
    size += stringInBufSize(session.value());
    size += stringInBufSize(service.value());
    UInt8 * buf = new UInt8[size];
    memcpy(buf,&size,sizeof(size));
    UInt32 pos = sizeof(size);
    memcpy(buf+pos,&type,sizeof(type));
    pos += sizeof(type);
    stringToBuffer(session.value(),buf+pos,false);
    pos += stringInBufSize(session.value());
    stringToBuffer(service.value(),buf+pos,false);
    UInt8 * resp = new UInt8[1];
    UInt32 rSize;
    CError err = mpIpc->request(genId(),buf,size,resp,rSize);
    delete [] buf;
    delete [] resp;
    return err;
 }
コード例 #11
0
      void CPmpPimClbCtrl::onCreateProfile(PMPFrame * pFrame)
      {
         std::string str = bufferToString(pFrame->data,true);
         unsigned int pos = stringInBufSize(str);
         iviLink::Profile::Uid profileUid(str);
         str = bufferToString(pFrame->data + pos,true);
         pos += stringInBufSize(str);
         iviLink::Profile::IUid piuid(str);
         str = bufferToString(pFrame->data + pos,true);
         iviLink::Service::Uid sid(str);

         mpPimClb->onCreateProfile(profileUid,piuid,sid);

         PMPFrame pResp;
         pResp.size = sizeof(PMPFrame);
         pResp.frameType = PMP_FRAME_TYPE_RESPONSE;
         pResp.id = pFrame->id;
         pResp.client = pFrame->client;
         pResp.reqType = pFrame->reqType;

         mpProtocol->makeResponse(pResp);
      }
コード例 #12
0
      void CProfileRepoServerClb::getProfilesList(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         std::list<UID> list = mProfileDB.getProfilesList();
         UInt32 count = list.size();

         memcpy (pResponseBuffer, &count, 4);
         int pos = 4;
         for (std::list<UID>::const_iterator it = list.begin(); list.end() != it; ++it)
         {
            stringToBuffer(it->value, pResponseBuffer+pos);
            pos += stringInBufSize(it->value);
         }
         bufferSize = pos;
      }
コード例 #13
0
      void CPmpCoreClbCtrl::onGetAvailableProfileComplements(PMPFrame * pFrame)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         std::list<Profile::Uid> complements;
         mpCoreClb->onGetAvailableProfileComplements(complements);

         UInt32 size = sizeof(PMPFrame) + 4;
         for (std::list<Profile::Uid>::iterator it = complements.begin();
               complements.end() != it; ++it)
         {
            size += stringInBufSize(it->value());
         }

         PMPFrame * pResp = reinterpret_cast<PMPFrame*>(new UInt8[size]);
         pResp->size = size;
         pResp->frameType = PMP_FRAME_TYPE_RESPONSE;
         pResp->id = pFrame->id;
         pResp->client = pFrame->client;
         pResp->reqType = pFrame->reqType;

         UInt32 count = complements.size();
         LOG4CPLUS_INFO(msLogger, "count: " + convertIntegerToString(count));
         count = ByteOrder::hton32(count);
         memcpy(pResp->data,&count,4);
         UInt32 pos = 4;
         for (std::list<Profile::Uid>::iterator it = complements.begin();
               complements.end() != it; ++it)
         {
            stringToBuffer(it->value(),pResp->data + pos,true);
            pos += stringInBufSize(it->value());
         }

         assert(pos == size-sizeof(PMPFrame));
         mpProtocol->makeResponse(*pResp);
         delete [] pResp;
      }
コード例 #14
0
      void CProfileRepoServerClb::findProfiles(const RepoRequest * req, UInt32 payloadSize, UInt8* const pResponseBuffer, UInt32& bufferSize)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
         UID uid(bufferToString(req->data));
         int pos = stringInBufSize(uid.value);
         std::string platform = bufferToString(req->data + pos);
         pos += stringInBufSize(platform);
         UInt32 count;
         memcpy (&count,req->data+pos, 4);
         pos += 4;
         std::map <std::string, std::string> args;

         for (UInt32 i=0; i<count; ++i)
         {
            std::string key = bufferToString(req->data+pos);
            pos += stringInBufSize(key);
            std::string val = bufferToString(req->data+pos);
            pos += stringInBufSize(val);
            args[key] = val;
         }

         std::list<LibInfo> inf = mProfileDB.findProfiles(uid,args,platform);

         UInt32 rCount = inf.size();
         memcpy (pResponseBuffer,&rCount,sizeof(rCount));
         int outPos = sizeof(rCount);

         for (std::list<LibInfo>::const_iterator it = inf.begin(); inf.end() != it; ++it)
         {
            LOG4CPLUS_INFO(msLogger, "CProfileRepoServerClb::findProfiles() : FoundLib : " +
                  it->path);
            stringToBuffer(it->uid.value,pResponseBuffer + outPos);
            outPos += stringInBufSize(it->uid.value);
            stringToBuffer(it->platform,pResponseBuffer + outPos);
            outPos += stringInBufSize(it->platform);
            stringToBuffer(it->path,pResponseBuffer + outPos);
            outPos += stringInBufSize(it->path);
            memcpy (pResponseBuffer + outPos, &it->relevance,4);
            outPos += 4;
         }
         bufferSize = outPos;
      }