Exemplo n.º 1
0
static const char* GetMimeType(const std::string& path)
{
  size_t dot = path.find_last_of('.');

  std::string extension = (dot == std::string::npos) ? "" : path.substr(dot);
  std::transform(extension.begin(), extension.end(), extension.begin(), tolower);

  if (extension == ".html")
  {
    return "text/html";
  }
  else if (extension == ".css")
  {
    return "text/css";
  }
  else if (extension == ".js")
  {
    return "application/javascript";
  }
  else if (extension == ".gif")
  {
    return "image/gif";
  }
  else if (extension == ".json")
  {
    return "application/json";
  }
  else if (extension == ".xml")
  {
    return "application/xml";
  }
  else if (extension == ".png")
  {
    return "image/png";
  }
  else if (extension == ".jpg" || extension == ".jpeg")
  {
    return "image/jpeg";
  }
  else
  {
    std::string s = "Unknown MIME type for extension: " + extension;
    OrthancPluginLogWarning(context, s.c_str());
    return "application/octet-stream";
  }
}
Exemplo n.º 2
0
 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
 {
   OrthancPluginLogWarning(context_, "Sample worklist plugin is finalizing");
 }
Exemplo n.º 3
0
void OrthancContext::LogWarning(const std::string& s)
{
    Check();
    OrthancPluginLogWarning(context_, s.c_str());
}
Exemplo n.º 4
0
  ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
  {
    context_ = c;
    OrthancPluginLogWarning(context_, "Sample worklist plugin is initializing");
    OrthancPluginSetDescription(context_, "Serve DICOM modality worklists from a folder with Orthanc.");

    /* Check the version of the Orthanc core */
    if (OrthancPluginCheckVersion(c) == 0)
    {
      char info[1024];
      sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin",
              context_->orthancVersion,
              ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
              ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
      OrthancPluginLogError(context_, info);
      return -1;
    }

    Json::Value configuration;
    if (!ConvertToJson(configuration, OrthancPluginGetConfiguration(context_)))
    {
      OrthancPluginLogError(context_, "Cannot access the configuration of the worklist server");
      return -1;
    }

    bool enabled = false;

    if (configuration.isMember("Worklists"))
    {
      const Json::Value& config = configuration["Worklists"];
      if (!config.isMember("Enable") ||
          config["Enable"].type() != Json::booleanValue)
      {
        OrthancPluginLogError(context_, "The configuration option \"Worklists.Enable\" must contain a Boolean");
        return -1;
      }
      else
      {
        enabled = config["Enable"].asBool();
        if (enabled)
        {
          if (!config.isMember("Database") ||
              config["Database"].type() != Json::stringValue)
          {
            OrthancPluginLogError(context_, "The configuration option \"Worklists.Database\" must contain a path");
            return -1;
          }

          folder_ = config["Database"].asString();
        }
        else
        {
          OrthancPluginLogWarning(context_, "Worklists server is disabled by the configuration file");
        }
      }
    }
    else
    {
      OrthancPluginLogWarning(context_, "Worklists server is disabled, no suitable configuration section was provided");
    }

    if (enabled)
    {
      std::string message = "The database of worklists will be read from folder: " + folder_;
      OrthancPluginLogWarning(context_, message.c_str());

      OrthancPluginRegisterWorklistCallback(context_, Callback);
    }

    return 0;
  }