Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
void CPIM::incomingProfileInternal(iviLink::Profile::Uid const& profileUid,
      iviLink::Profile::ApiUid const& papiUid,
      iviLink::Profile::IUid const& piuid,
      iviLink::Service::Uid const& serviceUID)
{
   LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__ + (" uid " + profileUid.value() + " piuid" + piuid.value() + " sid " + serviceUID.value()));

   CPMALComponentMgr* mgr = CPMALComponentMgr::getInstance();
   if (!mgr)
   {
      LOG4CPLUS_ERROR(logger, "!mgr");
      return;
   }

   IProfileManagerCallbacks* clb = mgr->getProfileManagerCallbacks();
   if (!clb)
   {
      LOG4CPLUS_ERROR(logger, "!clb");
      return;
   }

   CError err = clb->serviceRequestCallback(serviceUID);
   if (!err.isNoError())
   {
      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
      return;
   }

   mIncomingPrfMapMutex.lock();
   {
      mIncomingPrfMap.insert(std::make_pair(std::make_pair(serviceUID, profileUid), piuid));
   }
   mIncomingPrfMapMutex.unlock();

   clb->incomingProfile(serviceUID, profileUid, papiUid);
}
Ejemplo n.º 3
0
CPMALError CPIM::loadProfile(iviLink::Profile::Uid const& profileUid,
            iviLink::Service::Uid const& sid,
            iviLink::Profile::IProfileCallbackProxy* const pProxy,
            Profile::CProfile*& pProfile)
{
   LOG4CPLUS_TRACE_METHOD(logger, __PRETTY_FUNCTION__ + (" uid" + profileUid.value()));

   Profile::CProfile* pProf = NULL;

   std::string path;

   // prepearing

   CPMALComponentMgr* pMgr = CPMALComponentMgr::getInstance();
   if (!pMgr)
   {
      return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "no instance of CPMALComponentMgr. Something is very wrong");
   }

   IPMALCoreToPIM* pCore = pMgr->getCoreToPIM();
   if (!pCore)
   {
      return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "no instance of PMAL Core");
   }

   bool profileEnabled = false;
   CError err = pCore->isEnabledProfile(profileUid, profileEnabled);
   if (!err.isNoError())
   {
      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
      return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "unable to get state of profile");
   }

   if (!profileEnabled)
   {
      LOG4CPLUS_ERROR(logger, "profile is disabled");
      return CPMALError(CPMALError::ERROR_UNKNOWN_PROFILE_UID, gModuleName, "profile is disabled or unknown");
   }

   err = pCore->getProfileLibPath(profileUid, path);
   if (!err.isNoError())
   {
      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
      return CPMALError(CPMALError::ERROR_UNKNOWN_PROFILE_UID, gModuleName, "no profile library path");
   }

   Profile::IUid piuid;
   {
      CPMALError err = generatePIUID(profileUid, sid, piuid);
      if (!err.isNoError())
         return err;
   }

   // creating
   LOG4CPLUS_INFO(logger, "creating profile '" + path + "'with piuid '" + piuid.value() + "'");
   Profile::CProfileInternal* pProfInt = NULL;
   PIM::ProfileInitData initData(piuid, sid, pProxy);
   err = PIM::createProfileImpl(path.c_str(), initData, pProfInt);

   if (!err.isNoError())
   {
      PIM::releasePIUID(piuid);

      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
      return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "unable to create profile object");
   }

   assert(pProfInt);

   err = pProfInt->getError();
   if (!err.isNoError())
   {
      PIM::releasePIUID(piuid);
      err = pProfInt->getError();
      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));

      PIM::CProfileDestroyer::destroy(pProfInt);
      return CPMALError(CPMALError::ERROR_PROFILE_INIT, gModuleName, "profile implementation init error");
   }

   // registering

   pProf = static_cast<Profile::CProfile*>(pProfInt);
   err = mInstanceMap.registerProfile(piuid, pProf);
   if (!err.isNoError())
   {
      PIM::CProfileDestroyer::destroy(pProf);

      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));

      return CPMALError(CPMALError::ERROR_PIM_INTERNAL, gModuleName, "unable to register profile object");
   }

   // messaging
   IPMALIpcToPIM* ipc = pMgr->getIpcToPIM();
   assert(ipc);
   err = ipc->createProfile(profileUid, piuid, sid);
   if (!err.isNoError())
   {
      /// @todo what error handling can be here?
      LOG4CPLUS_INFO(logger, "todo what error handling can be here?");

      LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
   }

   // enabling

   PIM::CProfileEnabler::enable(pProf);

   pProfile = pProf;

   return CPMALError::NoPMALError(gModuleName);
}