/*
* Author:
* Ted Gould <ted@gould.cx>
*
* Copyright (C) 2006 Johan Engelen, johan@shouraizou.nl
* Copyright (C) 2004 Author
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include "config.h"
#include "path-prefix.h"
#include "dependency.h"
#include "db.h"
#include "extension.h"
namespace Inkscape {
namespace Extension {
// These strings are for XML attribute comparisons and should not be translated
"executable",
"file",
"extension",
};
// These strings are for XML attribute comparisons and should not be translated
"path",
"extensions",
"absolute",
};
/**
\brief Create a dependency using an XML definition
\param in_repr XML definition of the dependency
This function mostly looks for the 'location' and 'type' attributes
and turns them into the enums of the same name. This makes things
a little bit easier to use later. Also, a pointer to the core
content is pulled out -- also to make things easier.
*/
{
_description = NULL;
_location = (location_t)i;
break;
}
}
_location = (location_t)i;
break;
}
}
}
break;
}
}
if (_description == NULL)
return;
}
/**
\brief This depenency is not longer needed
Unreference the XML structure.
*/
Dependency::~Dependency (void)
{
}
/**
\brief Check if the dependency passes.
\return Whether or not the dependency passes.
This function depends largely on all of the enums. The first level
that is evaluted is the \c _type.
If the type is \c TYPE_EXTENSION then the id for the extension is
looked up in the database. If the extension is found, and it is
not deactivated, the dependency passes.
If the type is \c TYPE_EXECUTABLE or \c TYPE_FILE things are getting
even more interesting because now the \c _location variable is also
taken into account. First, the difference between the two is that
the file test for \c TYPE_EXECUTABLE also tests to make sure the
file is executable, besides checking that it exists.
If the \c _location is \c LOCATION_EXTENSIONS then the \c INKSCAPE_EXTENSIONDIR
is put on the front of the string with \c build_filename. Then the
appopriate filetest is run.
If the \c _location is \c LOCATION_ABSOLUTE then the file test is
run directly on the string.
If the \c _location is \c LOCATION_PATH or not specified then the
path is used to find the file. Each entry in the path is stepped
through, attached to the string, and then tested. If the file is
found then a TRUE is returned. If we get all the way through the
path then a FALSE is returned, the command could not be found.
*/
{
// std::cout << "Checking: " << *this << std::endl;
switch (_type) {
case TYPE_EXTENSION: {
break;
}
case TYPE_EXECUTABLE:
case TYPE_FILE: {
if (_type == TYPE_EXECUTABLE) {
}
switch (_location) {
case LOCATION_EXTENSIONS: {
std::string temploc = Glib::build_filename(Inkscape::Extension::Extension::search_path[i], location);
break;
}
}
} /* PASS THROUGH!!! */
case LOCATION_ABSOLUTE: {
// std::cout << "Failing on location: " << location << std::endl;
return FALSE;
}
break;
}
/* The default case is to look in the path */
case LOCATION_PATH:
default: {
/* There is no `PATH' in the environment.
The default search path is the current directory */
}
local_path = path;
/* Not sure whether this is UTF8 happy, but it would seem
like it considering that I'm searching (and finding)
the ':' character */
path[0] = '\0';
path++;
}
if (*local_path == '\0') {
} else {
}
return TRUE;
}
// give it a 2nd try with ".exe" added
return TRUE;
}
// and a 3rd try with ".cmd" added (mainly for UniConvertor)
return TRUE;
}
}
return FALSE; /* Reverse logic in this one */
}
} /* switch _location */
break;
} /* TYPE_FILE, TYPE_EXECUTABLE */
default:
return FALSE;
} /* switch _type */
return TRUE;
}
/**
\brief Accessor to the name attribute.
\return A string containing the name of the dependency.
Returns the name of the dependency as found in the configuration file.
*/
{
return _string;
}
/**
\brief Print out a dependency to a string.
*/
{
}
return out_file;
}
} } /* namespace Inkscape, Extension */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :