namespace {
-int getValueCstr(std::string &value,
- const std::function<int(const char **)> &getfunc)
+int getValueCstr(std::string &value, const std::function<int(const char **)> &getfunc)
{
const char *cvalue = nullptr;
auto retval = getfunc(&cvalue);
} // namespace anonymous
+void CsLoader::checkEngineActivated(csre_cs_context_h c)
+{
+ csre_cs_activated_e a = CSRE_CS_NOT_ACTIVATED;
+
+ int ret = this->getEngineActivated(c, &a);
+
+ if (ret != CSRE_ERROR_NONE)
+ toException(ret);
+
+ if (a == CSRE_CS_NOT_ACTIVATED)
+ ThrowExc(EngineNotActivated, "engine is not activated yet");
+}
+
int CsLoader::contextCreate(csre_cs_context_h &c)
{
return this->m_pc.fpContextCreate(&c);
if (c == nullptr || data.empty() || pdetected == nullptr)
throw std::invalid_argument("cs loader scan data");
+ this->checkEngineActivated(c);
+
return this->m_pc.fpScanData(c, data.data(), data.size(), pdetected);
}
if (c == nullptr || filepath.empty() || pdetected == nullptr)
throw std::invalid_argument("cs loader scan file");
+ this->checkEngineActivated(c);
+
return this->m_pc.fpScanFile(c, filepath.c_str(), pdetected);
}
if (c == nullptr || appdir.empty() || pdetected == nullptr)
throw std::invalid_argument("cs loader scan app on cloud");
+ this->checkEngineActivated(c);
+
return this->m_pc.fpScanAppOnCloud(c, appdir.c_str(), pdetected);
}
return this->m_pc.fpGetEngineLatestUpdateTime(c, ptime);
}
-int CsLoader::getEngineActivated(csre_cs_context_h c,
- csre_cs_activated_e *pactivated)
+int CsLoader::getEngineActivated(csre_cs_context_h c, csre_cs_activated_e *pactivated)
{
if (c == nullptr || pactivated == nullptr)
throw std::invalid_argument("cs loader get engine activated");
- return this->m_pc.fpGetEngineActivated(c, pactivated);
+ auto ret = this->m_pc.fpGetEngineActivated(c, pactivated);
+
+ if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED) {
+ *pactivated = CSRE_CS_NOT_ACTIVATED;
+ return CSRE_ERROR_NONE;
+ } else {
+ return ret;
+ }
}
-int CsLoader::getEngineVendorLogo(csre_cs_context_h c,
- std::vector<unsigned char> &value)
+int CsLoader::getEngineVendorLogo(csre_cs_context_h c, std::vector<unsigned char> &value)
{
if (c == nullptr)
throw std::invalid_argument("cs loader get engine vendor logo");
namespace {
-int getValueCstr(std::string &value,
- const std::function<int(const char **)> &getfunc)
+int getValueCstr(std::string &value, const std::function<int(const char **)> &getfunc)
{
const char *cvalue = nullptr;
auto retval = getfunc(&cvalue);
} // namespace anonymous
+void WpLoader::checkEngineActivated(csre_wp_context_h c)
+{
+ csre_wp_activated_e a = CSRE_WP_NOT_ACTIVATED;
+
+ int ret = this->getEngineActivated(c, &a);
+
+ if (ret != CSRE_ERROR_NONE)
+ toException(ret);
+
+ if (a == CSRE_WP_NOT_ACTIVATED)
+ ThrowExc(EngineNotActivated, "engine is not activated yet");
+}
+
int WpLoader::contextCreate(csre_wp_context_h &c)
{
return this->m_pc.fpContextCreate(&c);
if (c == nullptr || url.empty() || presult == nullptr)
throw std::invalid_argument("wp loader check url error");
+ this->checkEngineActivated(c);
+
return this->m_pc.fpCheckUrl(c, (const char *)url.c_str(), presult);
}
if (c == nullptr || pactivated == nullptr)
throw std::invalid_argument("wp loader get engine activated");
- return this->m_pc.fpGetEngineActivated(c, pactivated);
+ auto ret = this->m_pc.fpGetEngineActivated(c, pactivated);
+
+ if (ret == CSRE_ERROR_ENGINE_NOT_ACTIVATED) {
+ *pactivated = CSRE_WP_NOT_ACTIVATED;
+ return CSRE_ERROR_NONE;
+ } else {
+ return ret;
+ }
}
-int WpLoader::getEngineVendorLogo(csre_wp_context_h c,
- std::vector<unsigned char> &value)
+int WpLoader::getEngineVendorLogo(csre_wp_context_h c, std::vector<unsigned char> &value)
{
if (c == nullptr)
throw std::invalid_argument("wp loader get engine vendor logo");