Commit 524ab293 authored by Lisa's avatar Lisa

Removing kde dependencies from akabei

parent ad9b8a18
......@@ -10,19 +10,24 @@ if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS_DEBUG "-ggdb")
endif(CMAKE_COMPILER_IS_GNUCC)
find_package(KDE4 REQUIRED)
find_package(AkabeiCore REQUIRED)
find_package(AkabeiClient REQUIRED)
find_package(MSGFMT REQUIRED)
include (KDE4Defaults)
include (MacroLibrary)
find_package(Qt4 REQUIRED)
# This header adds a macro to make the licenses accessible to akabei independently of the install prefix
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/akabeilicensepath.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/akabeilicensepath.h"
IMMEDIATE @ONLY
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
include_directories(BEFORE SYSTEM
${QT_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${KDE4_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
${AKABEICLIENT_INCLUDE_DIR}
${AKABEICORE_INCLUDE_DIR})
......@@ -41,18 +46,29 @@ akabeioptions.cpp
parser.cpp
akabeiparser.cpp
pakabeiparser.cpp
akabeiaboutdata.cpp
main.cpp)
add_subdirectory(tools)
add_subdirectory(scripts)
add_subdirectory(translations)
add_subdirectory(docs)
add_subdirectory(licenses)
# qt4_automoc() doesn't recognize our operation files, so I use this safer version instead
QT4_WRAP_CPP(MISSING_MOCS
queryoperation.h
queueoperation.h
removeoperation.h
upgradeoperation.h
syncoperation.h)
#qt4_automoc(${guzuta_SRCS})
kde4_add_executable(akabei ${apm_SRCS})
target_link_libraries(akabei ${KDE4_KDECORE_LIBRARY} ${AKABEICORE_LIBRARIES} ${AKABEICLIENT_LIBRARIES})
install(TARGETS akabei ${INSTALL_TARGETS_DEFAULT_ARGS})
add_executable(akabei ${apm_SRCS} ${MISSING_MOCS})
target_link_libraries(akabei ${QT_QTCORE_LIBRARY} ${AKABEICORE_LIBRARIES} ${AKABEICLIENT_LIBRARIES})
install(TARGETS akabei
RUNTIME DESTINATION bin)
kde4_add_executable(pakabei ${apm_SRCS})
target_link_libraries(pakabei ${KDE4_KDECORE_LIBRARY} ${AKABEICORE_LIBRARIES} ${AKABEICLIENT_LIBRARIES})
install(TARGETS pakabei ${INSTALL_TARGETS_DEFAULT_ARGS})
add_executable(pakabei ${apm_SRCS} ${MISSING_MOCS})
target_link_libraries(pakabei ${QT_QTCORE_LIBRARY} ${AKABEICORE_LIBRARIES} ${AKABEICLIENT_LIBRARIES})
install(TARGETS pakabei
RUNTIME DESTINATION bin)
/*
* This file is part of the Chakra project
*
* This class reproduces a subset of KAboutData's functionalities, so we avoid
* KDE dependencies.
Copyright (C) 2013 Lisa Vitolo <shainer@chakra-project.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include <akabeiaboutdata.h>
#include <akabeilicensepath.h>
#include <QFile>
AkabeiAuthor::AkabeiAuthor(const QString& name, const QString& task, const QByteArray& email)
: m_name(name)
, m_task(task)
, m_email(email)
{}
AkabeiAuthor::~AkabeiAuthor()
{}
QString AkabeiAuthor::name() const
{
return m_name;
}
QByteArray AkabeiAuthor::emailAddress() const
{
return m_email;
}
QString AkabeiAuthor::task() const
{
return m_task;
}
/*
* Reads the license text from the correct file, or leaves an empty text
* if the file cannot be read.
*/
AkabeiLicense::AkabeiLicense(AkabeiLicense::LicenseType type)
: m_type(type)
{}
AkabeiLicense::~AkabeiLicense()
{}
AkabeiLicense::LicenseType AkabeiLicense::type() const
{
return m_type;
}
/*
* Since we don't usually call this method over and over again, it just
* reads the license file on-the-fly
*/
QString AkabeiLicense::text() const
{
QFile* licenseFile(0);
QString licensePath( LICENSE_DIR ); /* base path for all license files, set by cmake */
switch(m_type) {
case AkabeiLicense::License_GPL_V2: {
licensePath += "GPL_V2";
licenseFile = new QFile(licensePath);
break;
}
default:
return QString();
}
if ( !licenseFile->open(QIODevice::ReadOnly) ) {
return QString();
}
QByteArray license = licenseFile->readAll();
licenseFile->close();
delete licenseFile;
return license;
}
AkabeiAboutData::AkabeiAboutData(const QByteArray& appName,
const QByteArray& catalogName,
const QString& programName,
const QByteArray& version,
const QString& shortDesc,
AkabeiLicense::LicenseType licenseType,
const QString& copyright,
const QString& text,
const QByteArray& homePage,
const QByteArray& bugsEmail)
: m_appName(appName)
, m_catalogName(catalogName)
, m_programName(programName)
, m_version(version)
, m_shortDesc(shortDesc)
, m_copyright(copyright)
, m_text(text)
, m_homePage(homePage)
, m_bugsEmail(bugsEmail)
{
m_licenses.append( AkabeiLicense(licenseType) );
}
AkabeiAboutData::~AkabeiAboutData()
{}
void AkabeiAboutData::addAuthor(const QString& name, const QString& task, const QByteArray& email)
{
m_authors.append( AkabeiAuthor(name, task, email) );
}
QByteArray AkabeiAboutData::appName() const
{
return m_appName;
}
QByteArray AkabeiAboutData::catalogName() const
{
return m_catalogName;
}
QByteArray AkabeiAboutData::version() const
{
return m_version;
}
QString AkabeiAboutData::shortDescription() const
{
return m_shortDesc;
}
QByteArray AkabeiAboutData::bugAddress() const
{
return m_bugsEmail;
}
AkabeiAuthor::List AkabeiAboutData::authors() const
{
return m_authors;
}
QStringList AkabeiAboutData::licenses() const
{
QStringList textes;
foreach (AkabeiLicense license, m_licenses) {
if ( !license.text().isEmpty() ) {
textes.append( license.text() );
}
}
/* Falls back to an error text if no license has been found */
if ( textes.isEmpty() ) {
QString fallBack = QObject::tr("No licensing terms for this program have been specified.\n"
"Please check the documentation or the source for any\n"
"licensing terms.\n");
textes.append(fallBack);
}
return textes;
}
void AkabeiAboutData::addLicense(AkabeiLicense::LicenseType license)
{
m_licenses.append(license);
}
/*
* This file is part of the Chakra project
*
* This class reproduces a subset of KAboutData's functionalities, so we avoid
* KDE dependencies.
Copyright (C) 2013 Lisa Vitolo <shainer@chakra-project.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef AKABEIABOUTDATA_H
#define AKABEIABOUTDATA_H
#include <QByteArray>
#include <QString>
#include <QList>
#include <QStringList>
class AkabeiAuthor
{
public:
typedef QList<AkabeiAuthor> List;
AkabeiAuthor(const QString &, const QString &, const QByteArray &);
~AkabeiAuthor();
QString name() const;
QString task() const;
QByteArray emailAddress() const;
private:
QString m_name;
QString m_task;
QByteArray m_email;
};
class AkabeiLicense
{
public:
typedef QList<AkabeiLicense> List;
enum LicenseType {
/*
* For now we only need this license: we may support more types in the future
*/
License_GPL_V2 = 1
};
AkabeiLicense(LicenseType);
~AkabeiLicense();
QString text() const;
LicenseType type() const;
private:
LicenseType m_type;
};
class AkabeiAboutData
{
public:
AkabeiAboutData(const QByteArray& appName,
const QByteArray& catalogName,
const QString& programName,
const QByteArray& version,
const QString& shortDesc,
AkabeiLicense::LicenseType licenseType,
const QString& copyright,
const QString& text,
const QByteArray& homePage,
const QByteArray& bugsEmail);
~AkabeiAboutData();
QByteArray appName() const;
QByteArray catalogName() const;
QByteArray version() const;
QString shortDescription() const;
QByteArray bugAddress() const;
QStringList licenses() const;
AkabeiAuthor::List authors() const;
void addAuthor(const QString &, const QString &, const QByteArray &);
void addLicense(AkabeiLicense::LicenseType);
private:
QByteArray m_appName;
QByteArray m_catalogName;
QString m_programName;
QByteArray m_version;
QString m_shortDesc;
QString m_copyright;
QString m_text;
QByteArray m_homePage;
QByteArray m_bugsEmail;
AkabeiAuthor::List m_authors;
AkabeiLicense::List m_licenses;
};
#endif
\ No newline at end of file
#define LICENSE_DIR "@DATA_INSTALL_DIR@/licenses/"
......@@ -12,7 +12,7 @@
#include "akabeioptions.h"
AkabeiOption::AkabeiOption(APM::OptionName n, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, QString const& argname)
AkabeiOption::AkabeiOption(APM::OptionName n, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname)
: m_name(n)
, m_commandShort(cmdShort)
, m_commandLong(cmdLong)
......@@ -35,7 +35,7 @@ QString AkabeiOption::commandLong() const
return m_commandLong;
}
KLocalizedString AkabeiOption::description() const
QString AkabeiOption::description() const
{
return m_description;
}
......@@ -99,7 +99,7 @@ AkabeiOperation::AkabeiOperation()
: m_name(APM::None)
{}
AkabeiOperation::AkabeiOperation(APM::OperationType t, APM::OperationName n, QString const& cmd, QString const& cmdLong, KLocalizedString const& desc, bool a)
AkabeiOperation::AkabeiOperation(APM::OperationType t, APM::OperationName n, QString const& cmd, QString const& cmdLong, QString const& desc, bool a)
: m_type(t)
, m_name(n)
, m_commandShort(cmd)
......@@ -145,7 +145,7 @@ void AkabeiOperation::setCommandLong(QString const& cmdLong)
m_commandLong = cmdLong;
}
KLocalizedString AkabeiOperation::description() const
QString AkabeiOperation::description() const
{
return m_description;
}
......
......@@ -15,7 +15,6 @@
#include <QStringList>
#include <QHash>
#include <klocalizedstring.h>
#include <akabeienums.h>
/*
......@@ -37,12 +36,12 @@ class AkabeiOption
APM::OptionName m_name;
QString m_commandShort;
QString m_commandLong;
KLocalizedString m_description;
QString m_description;
QString m_argname;
QStringList m_args;
public:
AkabeiOption(APM::OptionName n, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, QString const& argname = QString());
AkabeiOption(APM::OptionName n, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname = QString());
AkabeiOption() {}
/**
......@@ -63,7 +62,7 @@ public:
/**
* @returns a localized description of this option
*/
KLocalizedString description() const;
QString description() const;
/**
* @returns an explanatory string for the argument: used in the help message
......@@ -114,13 +113,13 @@ private:
APM::OperationName m_name;
QString m_commandShort;
QString m_commandLong;
KLocalizedString m_description;
QString m_description;
bool m_freeArgs;
QList<APM::OptionName> m_options;
public:
AkabeiOperation();
AkabeiOperation(APM::OperationType, APM::OperationName, QString const&, QString const&, KLocalizedString const&, bool a = false);
AkabeiOperation(APM::OperationType, APM::OperationName, QString const&, QString const&, QString const&, bool a = false);
/**
* @returns the operation type
......@@ -152,7 +151,7 @@ public:
/**
* @returns a localized description
*/
KLocalizedString description() const;
QString description() const;
/**
* @returns whether this operation admits arguments
......
......@@ -12,14 +12,14 @@
#include <akabeiparser.h>
AkabeiParser::AkabeiParser(int argc, char **argv, const KAboutData& about)
AkabeiParser::AkabeiParser(int argc, char **argv, const AkabeiAboutData& about)
: CommandLineParser(argc, argv, about)
{
/* Special operations */
AkabeiOperation help(APM::NoType, APM::Help, "", "help", ki18n("Show an help message"));
AkabeiOperation version(APM::NoType, APM::Version, "", "version", ki18n("Show version information"));
AkabeiOperation license(APM::NoType, APM::License, "", "license", ki18n("Show license information"));
AkabeiOperation authors(APM::NoType, APM::Authors, "", "authors", ki18n("Show information about the authors"));
AkabeiOperation help(APM::NoType, APM::Help, "", "help", QObject::tr("Show a help message"));
AkabeiOperation version(APM::NoType, APM::Version, "", "version", QObject::tr("Show version information"));
AkabeiOperation license(APM::NoType, APM::License, "", "license", QObject::tr("Show license information"));
AkabeiOperation authors(APM::NoType, APM::Authors, "", "authors", QObject::tr("Show information about the authors"));
m_acceptedOperations.insert("help", help);
m_acceptedOperations.insert("version", version);
......@@ -36,9 +36,9 @@ void AkabeiParser::addOperation(AkabeiOperation &op)
m_acceptedOperations.insert(op.commandLong(), op);
}
void AkabeiParser::addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, KLocalizedString const& argname)
void AkabeiParser::addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname)
{
AkabeiOption option(name, cmdShort, cmdLong, desc, argname.toString());
AkabeiOption option(name, cmdShort, cmdLong, desc, argname);
m_acceptedOptions.insert(cmdShort, option);
m_acceptedOptions.insert(cmdLong, option);
......
......@@ -22,10 +22,10 @@
class AkabeiParser : public CommandLineParser
{
public:
AkabeiParser(int, char**, const KAboutData&);
AkabeiParser(int, char**, const AkabeiAboutData &);
void addOperation(AkabeiOperation &);
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, KLocalizedString const& argname = KLocalizedString());
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname = QString());
void connectOptionWithEverything(APM::OptionName name);
void parse();
......
......@@ -74,18 +74,18 @@ void OperationManager::statusChanged(Akabei::Backend::Status status)
case Akabei::Backend::StatusWaitingForLock: {
QTextStream out(stdout);
out << i18n("Another instance of akabei is currently running. When it finishes, we will continue!") << endl;
out << QObject::tr("Another instance of akabei is currently running. When it finishes, we will continue!") << endl;
break;
}
case Akabei::Backend::StatusBroken: {
QTextStream err(stderr);
err << Akabei::errorPrefix << i18n("The backend seems to be in a broken state. ");
err << Akabei::errorPrefix << QObject::tr("The backend seems to be in a broken state. ");
if (Akabei::Backend::instance()->initError().type() == Akabei::Error::BackendInitializationError) {
QString description = Akabei::Backend::instance()->initError().description();
err << i18n(description.toUtf8().data()) << endl;
err << Akabei::errorPrefix << i18n("This often means that you don't have enough permissions to perform this operation.");
err << description << endl;
err << Akabei::errorPrefix << QObject::tr("This often means that you don't have enough permissions to perform this operation.");
}
err << endl;
......
......@@ -9,7 +9,6 @@
*/
#include <fieldnames.h>
#include <klocale.h>
FieldNames::FieldNames()
: maxFieldLength( 0 )
......@@ -41,7 +40,7 @@ FieldNames::FieldNames()
QHash< QString, QString >::iterator FieldNames::insert(QString const& key)
{
// get translated string
QString value( i18n(key.toUtf8().constData()) );//FIXME: This won't work I fear!!! need to use I18N_NOOP
QString value(key);
// compute the new maximum length
maxFieldLength = qMax(static_cast<unsigned int>( value.length() ), maxFieldLength);
......
install(FILES GPL_V2 DESTINATION ${DATA_INSTALL_DIR}/licenses)
This diff is collapsed.
This diff is collapsed.
......@@ -101,7 +101,7 @@ void CommandLine::emptyCheck()
/*
* Build our database of accepted operations and options with the right properties and associations
*/
PakabeiParser::PakabeiParser(int argc, char **argv, KAboutData& about)
PakabeiParser::PakabeiParser(int argc, char **argv, const AkabeiAboutData& about)
: CommandLineParser(argc, argv, about)
{
typechars.insert("Q", APM::QueryOperationType);
......@@ -128,9 +128,9 @@ void PakabeiParser::addOperation(AkabeiOperation& op)
acceptedOperations.insertMulti(op.type(), op);
}
void PakabeiParser::addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, KLocalizedString const& argname)
void PakabeiParser::addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname)
{
AkabeiOption opt(name, cmdShort, cmdLong, desc, argname.toString());
AkabeiOption opt(name, cmdShort, cmdLong, desc, argname);
acceptedOptions.push_front(opt);
}
......
......@@ -81,10 +81,10 @@ private:
bool areArgsRequired();
public:
PakabeiParser(int argc, char **argv, KAboutData &);
PakabeiParser(int argc, char **argv, const AkabeiAboutData &);
void addOperation(AkabeiOperation &);
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, KLocalizedString const& desc, KLocalizedString const& argname = KLocalizedString());
void addOption(APM::OptionName name, QString const& cmdShort, QString const& cmdLong, QString const& desc, QString const& argname = QString());
void connectOptionWithEverything(APM::OptionName name);
void parse();
......
......@@ -12,7 +12,7 @@
#include <parser.h>
CommandLineParser::CommandLineParser(int argc, char **argv, const KAboutData& data)
CommandLineParser::CommandLineParser(int argc, char **argv, const AkabeiAboutData& data)
: m_data(data)
{
QStringList optionWithArg;
......@@ -51,7 +51,7 @@ CommandLineParser::CommandLineParser(int argc, char **argv, const KAboutData& da
void CommandLineUtils::printHelpMessage(QMultiHash<APM::OperationType, AkabeiOperation> const& m_acceptedOperations,
QList<AkabeiOption> const& m_acceptedOptions,
KAboutData &m_data
AkabeiAboutData &m_data
)
{
......@@ -104,7 +104,7 @@ void CommandLineUtils::printHelpMessage(QMultiHash<APM::OperationType, AkabeiOpe
out << " ";
}
out << op.description().toString() << endl;
out << op.description() << endl;
}
out << endl;
......@@ -135,7 +135,7 @@ void CommandLineUtils::printHelpMessage(QMultiHash<APM::OperationType, AkabeiOpe
out << " ";
}
out << opt.description().toString() << endl;
out << opt.description() << endl;
}
exit(0);
......@@ -169,19 +169,19 @@ int CommandLineUtils::getSpacingDistance(QList<AkabeiOperation> const& m_accepte
return maxLength+1;
}
void CommandLineUtils::printVersion(KAboutData &m_data)
void CommandLineUtils::printVersion(AkabeiAboutData &m_data)
{
QTextStream out(stdout);
out << m_data.appName() << ": " << m_data.version() << endl;
exit(0);
}
void CommandLineUtils::printAuthors(KAboutData &m_data)
void CommandLineUtils::printAuthors(AkabeiAboutData &m_data)
{
QTextStream out(stdout);
out << m_data.appName() << " was written by" << endl;
foreach (const KAboutPerson& dev, m_data.authors()) {
foreach (const AkabeiAuthor& dev, m_data.authors()) {
out << " " << dev.name() << " " << dev.emailAddress() << endl;
}
......@@ -189,12 +189,12 @@ void CommandLineUtils::printAuthors(KAboutData &m_data)
exit(0);
}
void CommandLineUtils::printLicenses(KAboutData &m_data)
void CommandLineUtils::printLicenses(AkabeiAboutData &m_data)
{
QTextStream out(stdout);
foreach (const KAboutLicense& license, m_data.licenses()) {
out << license.text() << endl;
foreach (const QString& license, m_data.licenses()) {
out << license << endl;
}
exit(0);
}
......@@ -16,7 +16,7 @@
#include <akabeienums.h>
#include <akabeioptions.h>
#include <parsingexceptions.h>
#include <kaboutdata.h>
#include "akabeiaboutdata.h"
/**
* \class CommandLineParser
......@@ -33,7 +33,7 @@ public:
* @param data some information about the program
* @throws CommandParsingException if some option is repeated twice (currently not allowed).
*/
CommandLineParser(int, char **, const KAboutData&);
CommandLineParser(int, char **, const AkabeiAboutData&);
virtual ~CommandLineParser() {}
/**
......@@ -52,7 +52,7 @@ public:
* @param desc a description
* @param argname a printable name of the arguments requested (empty if no arguments)
*/
virtual void addOption(APM::OptionName, QString const&, QString const&, KLocalizedString const&, KLocalizedString const& argname = KLocalizedString()) = 0;
virtual void addOption(APM::OptionName, QString const&, QString const&, QString const&, QString const& argname = QString()) = 0;
/**
* Some special options can be associated to every operation.
......@@ -90,7 +90,7 @@ public:
protected:
QStringList m_argv;
KAboutData m_data;
AkabeiAboutData m_data;
};
/**
......@@ -103,10 +103,10 @@ private:
static int getSpacingDistance(QList<AkabeiOperation> const&, QList<AkabeiOption> const&);
public:
static void printHelpMessage(QMultiHash<APM::OperationType, AkabeiOperation> const&, QList<AkabeiOption> const&, KAboutData &);
static void printVersion(KAboutData &);
static void printAuthors(KAboutData &);
static void printLicenses(KAboutData&);
static void printHelpMessage(QMultiHash<APM::OperationType, AkabeiOperation> const&, QList<AkabeiOption> const&, AkabeiAboutData &);
static void printVersion(AkabeiAboutData &);
static void printAuthors(AkabeiAboutData &);
static void printLicenses(AkabeiAboutData &);
};
#endif
\ No newline at end of file
......@@ -9,13 +9,13 @@
*/
#include "performoperation.h"
#include "utils.h"
#include <iostream>
#include <QTextStream>
#include <QList>
#include <QCoreApplication>
#include <QDebug>
#include <klocalizedstring.h>
PerformOperation::PerformOperation(QObject* parent)
: QObject(parent)
......@@ -34,7 +34,7 @@ void PerformOperation::start(QHash<APM::OptionName, QStringList> options, QStrin
removePkgs << pkg.remove(pkg.size() - 1, pkg.size());
} else {
QTextStream err(stderr);
err << Akabei::errorPrefix << i18n("Invalid package argument supplied: ") << pkg << endl;
err << Akabei::errorPrefix << QObject::tr("Invalid package argument supplied: %1").arg(pkg) << endl;
QCoreApplication::instance()->quit();
return;
}
......
......@@ -14,8 +14,6 @@
#include <sys/ioctl.h>
#include <QTime>
#include <klocale.h>
int getcols()
{
struct winsize ws;
......@@ -69,7 +67,7 @@ QString ProgressBar::line() //FIXME: Make all the magic numbers here variables
QString eta;
if (m_columns & Eta) {//Only check at the beginning of the phase whether to show it or not
eta = "| " + m_eta.toString("m:ss") + i18n(" remaining");
eta = QObject::tr("| %1 remaining").arg( m_eta.toString("m:ss") );
}
length += progress.length();
......