14#include <glibmm/i18n.h>
15#include <glibmm/fileutils.h>
16#include <glibmm/miscutils.h>
56 , _extension(extension)
62 for (
int i = 0; i <
LOCATION_CNT && location !=
nullptr; i++) {
69 for (
int i = 0; i <
LOCATION_CNT && location !=
nullptr; i++) {
78 for (
int i = 0; i <
TYPE_CNT && type !=
nullptr; i++) {
145 if (myext ==
nullptr)
return false;
146 if (myext->deactivated())
return false;
151 Glib::FileTest filetest = Glib::FileTest::EXISTS;
156 std::string extension;
157 size_t index = location.find_last_of(
".");
158 if (
index != std::string::npos) {
159 extension = location.substr(
index);
163 static const std::vector<std::string> interpreted = {
".py",
".pl",
".rb"};
164 if (!extension.empty() &&
165 std::find(interpreted.begin(), interpreted.end(), extension) != interpreted.end())
175 filetest = Glib::FileTest::IS_EXECUTABLE;
184 std::string temploc =
186 if (!temploc.empty()) {
192 auto deprloc = g_build_filename(
"inkex",
"deprecated-simple", location.c_str(),
nullptr);
193 std::string tempdepr =
196 if (!tempdepr.empty()) {
207 if (base_directory.empty()) {
208 g_warning(
"Dependency '%s' requests location relative to .inx file, "
211 std::string absolute_location = Glib::build_filename(base_directory, location);
212 if (!Glib::file_test(absolute_location, filetest)) {
220 if (!Glib::file_test(location, filetest)) {
231 gchar * path = g_strdup(g_getenv(
"PATH"));
233 if (path ==
nullptr) {
236 path = g_strdup(G_SEARCHPATH_SEPARATOR_S);
239 gchar * orig_path = path;
241 for (; path !=
nullptr;) {
243 std::string final_name;
246 path = g_utf8_strchr(path, -1, G_SEARCHPATH_SEPARATOR);
250 if (path !=
nullptr) {
255 if (*local_path ==
'\0') {
258 final_name = Glib::build_filename(local_path,
_string);
261 if (Glib::file_test(final_name, filetest)) {
273 static const std::vector<std::string> extensions = {
".exe",
".cmd",
".bat",
".com"};
274 if (extension.empty() ||
275 std::find(extensions.begin(), extensions.end(), extension) == extensions.end())
277 for (
auto extension : extensions) {
278 if (Glib::file_test(final_name + extension, filetest)) {
325 g_warning(
"Requested absolute path of dependency '%s' which is of 'extension' type.",
_string);
329 g_warning(
"Requested absolute path of dependency '%s' which is unchecked.",
_string);
341 Glib::ustring str = Glib::ustring::compose(
"%1:\n\t%2: %3\n\t%4: %5\n\t%6: %7",
348 str += Glib::ustring::compose(
"\n\t%1: %2\n", _(
" description: "), _(
_description));
Extension * get(const gchar *key) const
This function looks up a Inkscape::Extension::Extension by using its unique id. It then returns a ref...
bool check()
Check if the dependency passes.
Inkscape::XML::Node * _repr
The XML representation of the dependency.
Dependency(Inkscape::XML::Node *in_repr, const Extension *extension, type_t type=TYPE_FILE)
Create a dependency using an XML definition.
virtual ~Dependency()
This dependency is not longer needed.
const gchar * _description
The description of the dependency for the users.
const Extension * _extension
Reference to the extension requesting this dependency.
const gchar * _string
The string that is in the XML tags pulled out.
static constexpr const char * UNCHECKED
static gchar const * _type_str[TYPE_CNT]
Strings to represent the different enum values in type_t in the XML.
const gchar * get_name()
Accessor to the name attribute.
std::string get_path()
Path of this dependency.
std::string _absolute_location
The absolute path to the dependency file determined while checking this dependency.
location_t _location
The location to look for this particular dependency.
type_t _type
Storing the type of this particular dependency.
Glib::ustring info_string()
Print out a dependency to a string.
static gchar const * _location_str[LOCATION_CNT]
Strings to represent the different enum values in location_t in the XML.
location_t
All of the possible locations to look for the dependency.
@ LOCATION_CNT
Number of locations to look.
@ LOCATION_EXTENSIONS
Look in the extensions directory (note: this can be in both, user and system locations!...
@ LOCATION_ABSOLUTE
This dependency is already defined in absolute terms.
@ LOCATION_INX
Look relative to the inx file's location.
@ LOCATION_PATH
Look in the PATH for this dependency - historically this is the default (it's a bit odd for interpret...
type_t
All the possible types of dependencies.
@ TYPE_CNT
Number of types.
@ TYPE_EXTENSION
Make sure a specific extension is loaded and functional.
@ TYPE_FILE
Look to make sure a file exists.
@ TYPE_EXECUTABLE
Look for an executable.
The object that is the basis for the Extension system.
char const * get_id() const
Get the ID of this extension - not a copy don't delete!
auto const & get_base_directory() const
Interface for refcounted XML nodes.
virtual Node * firstChild()=0
Get the first child of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual char const * content() const =0
Get the content of a text or comment node.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
DB db
This is the actual database object.
static R & anchor(R &r)
Increments the reference count of a anchored object.
static R & release(R &r)
Decrements the reference count of a anchored object.
std::string get_filename(Type type, char const *filename, bool localized, bool silent)
Helper class to stream background task notifications as a series of messages.
Inkscape::IO::Resource - simple resource API.