34 #include "chiasmuslibrary.h"
36 #include "chiasmusbackend.h"
38 #include "kleo/cryptoconfig.h"
40 #include <klibloader.h>
42 #include <tdelocale.h>
55 Kleo::ChiasmusLibrary::ChiasmusLibrary() : mXiaLibrary( 0 ) {
59 Kleo::ChiasmusLibrary::~ChiasmusLibrary() {
63 Kleo::ChiasmusLibrary::main_func Kleo::ChiasmusLibrary::chiasmus( TQString * reason )
const {
64 assert( ChiasmusBackend::instance() );
65 assert( ChiasmusBackend::instance()->config() );
66 const CryptoConfigEntry * lib = ChiasmusBackend::instance()->config()->entry(
"Chiasmus",
"General",
"lib" );
68 const TQString libfile = lib->urlValue().path();
70 mXiaLibrary = KLibLoader::self()->library( TQFile::encodeName( libfile ) );
73 *reason = i18n(
"Failed to load %1: %2" )
74 .arg( libfile,KLibLoader::self()->lastErrorMessage() );
75 kdDebug(5150) <<
"ChiasmusLibrary: loading \"" << libfile
76 <<
"\" failed: " << KLibLoader::self()->lastErrorMessage() << endl;
79 if ( !mXiaLibrary->hasSymbol(
"Chiasmus" ) ) {
81 *reason = i18n(
"Failed to load %1: %2" )
82 .arg( libfile, i18n(
"Library does not contain the symbol \"Chiasmus\"." ) );
83 kdDebug(5150) <<
"ChiasmusLibrary: loading \"" << libfile
84 <<
"\" failed: " <<
"Library does not contain the symbol \"Chiasmus\"." << endl;
87 void * symbol = mXiaLibrary->symbol(
"Chiasmus" );
89 return ( main_func )symbol;
97 ArgvProvider(
const TQValueVector<TQCString> & args ) {
98 mArgv =
new char * [args.size()];
99 for (
unsigned int i = 0 ; i < args.size() ; ++i )
100 mArgv[i] = strdup( args[i].data() );
103 std::for_each( mArgv, mArgv + mArgc, std::free );
106 char ** argv()
const {
return mArgv; }
110 int Kleo::ChiasmusLibrary::perform(
const TQValueVector<TQCString> & args )
const {
111 if ( main_func func = chiasmus() )
112 return func( args.size(), ArgvProvider( args ).argv() );
small helper class to load xia.o through xia.so and make the functionality available.