コード例 #1
0
ファイル: CPmalCore.cpp プロジェクト: Vanuan/iviLink
 CPMALError CPmalCore::getProfileLibPath(Profile::Uid id, std::string& path)
 {
    CPMALError err = mpIpc->getProfileLibPath(id,path);
    if (!err.isNoError())
    {
       LOG4CPLUS_ERROR(logger, static_cast<std::string>(err));
       path = "";
    }
    return err;
 }
コード例 #2
0
ファイル: CPmalCore.cpp プロジェクト: Vanuan/iviLink
      CPMALError CPmalCore::getProfileInfo(iviLink::Profile::Uid id, ProfileInfo & profInfo)
      {
         std::string profileManifest;
         CPMALError err = mpIpc->getManifest(id, profileManifest);
         profInfo.params.clear();
         if (err.getCode())
         {
            profInfo.apiUid = CUid("");
            profInfo.complement = CUid("");
            profInfo.name = "";
            profInfo.uid = CUid("");
            profInfo.version = 0;
            return err;
         }

         pugi::xml_document doc;
         pugi::xml_parse_result res = doc.load(profileManifest.c_str());
         if(pugi::status_ok != res.status)
         {
            LOG4CPLUS_ERROR(logger, "CPmpCoreProfileInfo::parseXml() :: Error while parsing Profile manifest");
            return CPMALError(CPMALError::ERROR_MANIFEST_PARSING);
         }

         pugi::xml_node prof = doc.child("profile");
         profInfo.uid = iviLink::Profile::Uid(prof.child_value("uid"));
         profInfo.apiUid = iviLink::Profile::ApiUid(prof.child("api").attribute("uid").value());
         profInfo.name = prof.child_value("name");
         profInfo.version =  atoi(prof.child_value("version"));
         profInfo.complement = iviLink::Profile::Uid(prof.child_value("complement"));

         pugi::xml_node attrs = prof.child("attributes");

         for (pugi::xml_node_iterator it = attrs.begin(); it != attrs.end(); ++it)
         {
            if (it->name() == std::string("attribute"))
            {
               std::string atr = it->attribute("name").value();
               if (atr != "")
               {
                  profInfo.params[atr] = it->attribute("value").value();
               }
            }
         }

         return err;
      }
コード例 #3
0
ファイル: CComponentMgr.cpp プロジェクト: Luxoft/iviLink
CPMALError CPMALComponentMgr::create(IProfileManagerCallbacks* pClbs, conf::Configurator* pConf/* = NULL*/)
{
   if (mpInstance)
      return CPMALError(CPMALError::ERROR_PMAL_ALREADY_INITIALIZED, gModuleName, "already created");

   mpInstance = new CPMALComponentMgr();
   if (!mpInstance)
      return CPMALError(CPMALError::ERROR_OTHER, gModuleName, "memory error");

   CPMALError err = mpInstance->mpImpl->init(pClbs, pConf);
   if (!err.isNoError())
   {
      delete mpInstance;
      mpInstance = NULL;
   }

   return err;
}
コード例 #4
0
ファイル: CPmalCore.cpp プロジェクト: Vanuan/iviLink
      CPMALError CPmalCore::isEnabledProfile(Profile::Uid id, bool& enabled)
      {
         std::map<std::string, std::string> params;
         std::list<iviLink::Profile::Uid> profiles;

         CPMALError err = findProfiles(id, params, profiles, true);
         if (err.isNoError())
         {
            LOG4CPLUS_INFO(logger,
                  "todo: here we cannot distinguish whether profile "
                  "is really disabled or just unknown. "
                  "So the method does not what its name suggests");
            /// @todo: here we cannot distinguish whether profile is really 
            /// disabled or just unknown
            /// So the method does not what its name suggests.

            enabled = !profiles.empty();
         }

         return err;
      }
コード例 #5
0
ファイル: CPIM.cpp プロジェクト: Vanuan/iviLink
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);
}