Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

migrated from PackageKit-0.7.6/lib/packagekit-qt2 to Qt5.2.x

  • Loading branch information...
commit a2308b9812935b5ea66fc73c5be8c313d9ff22f4 1 parent c948ee4
@xiangzhai authored
Showing with 2,842 additions and 1,516 deletions.
  1. +1 −0  PackageKit-Qt/AUTHORS
  2. +1 −1  PackageKit-Qt/CMakeLists.txt
  3. +3 −0  PackageKit-Qt/MAINTAINERS
  4. +21 −10 PackageKit-Qt/src/CMakeLists.txt
  5. +1 −0  PackageKit-Qt/src/Eula
  6. +1 −0  PackageKit-Qt/src/Package
  7. +1 −0  PackageKit-Qt/src/Signature
  8. +9 −9 PackageKit-Qt/src/bitfield.cpp
  9. +6 −6 PackageKit-Qt/src/bitfield.h
  10. +2 −1  PackageKit-Qt/src/common.h
  11. +80 −204 PackageKit-Qt/src/daemon.cpp
  12. +41 −179 PackageKit-Qt/src/daemon.h
  13. +4 −4 PackageKit-Qt/src/daemonprivate.cpp
  14. +21 −4 PackageKit-Qt/src/daemonprivate.h
  15. +28 −0 PackageKit-Qt/src/daemonproxy.cpp
  16. +158 −0 PackageKit-Qt/src/daemonproxy.h
  17. +22 −0 PackageKit-Qt/src/eula.cpp
  18. +56 −0 PackageKit-Qt/src/eula.h
  19. +560 −0 PackageKit-Qt/src/package.cpp
  20. +432 −0 PackageKit-Qt/src/package.h
  21. +24 −0 PackageKit-Qt/src/signature.cpp
  22. +86 −0 PackageKit-Qt/src/signature.h
  23. +249 −419 PackageKit-Qt/src/transaction.cpp
  24. +285 −573 PackageKit-Qt/src/transaction.h
  25. +117 −78 PackageKit-Qt/src/transactionprivate.cpp
  26. +22 −28 PackageKit-Qt/src/transactionprivate.h
  27. +28 −0 PackageKit-Qt/src/transactionproxy.cpp
  28. +366 −0 PackageKit-Qt/src/transactionproxy.h
  29. +71 −0 PackageKit-Qt/src/util.cpp
  30. +146 −0 PackageKit-Qt/src/util.h
View
1  PackageKit-Qt/AUTHORS
@@ -3,3 +3,4 @@ Daniel Nicoletti <dantti12@gmail.com>
Matthias Klumpp <matthias@tenstral.net>
Qt5 Port: Martin Grimme <martin.grimme@gmail.com>
+Qt5.2.x Port: Leslie Zhai <xiang.zhai@i-soft.com.cn>
View
2  PackageKit-Qt/CMakeLists.txt
@@ -24,7 +24,7 @@ endif(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
#
# Options
#
-option(USE_QT5 "Build against Qt5 instead of Qt4." OFF)
+option(USE_QT5 "Build against Qt5 instead of Qt4." ON)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
View
3  PackageKit-Qt/MAINTAINERS
@@ -6,3 +6,6 @@ E-mail: matthias@tenstral.net
Richard Hughes
E-mail: richard@hughsie.com
+
+Leslie Zhai
+E-mail: xiang.zhai@i-soft.com.cn
View
31 PackageKit-Qt/src/CMakeLists.txt
@@ -1,4 +1,5 @@
# CMakeLists for PackageKit-Qt library
+# Copyright (C) 2014 Leslie Zhai <xiang.zhai@i-soft.com.cn>
if (USE_QT5)
find_package(Qt5Core REQUIRED)
@@ -33,23 +34,31 @@ include_directories(${CMAKE_BINARY_DIR}
set(packagekitqt_HEADERS
Daemon
Transaction
- common.h
+ Package
+ Signature
+ Eula
+ bitfield.h
daemon.h
transaction.h
- bitfield.h
+ package.h
+ signature.h
+ eula.h
)
set(packagekitqt_HEADERS_PRIVATE
- daemonprivate.h
- transactionprivate.h
+ daemonprivate.h
+ transactionprivate.h
)
set(packagekitqt_SRC
- bitfield.cpp
- daemon.cpp
- daemonprivate.cpp
- transaction.cpp
- transactionprivate.cpp
+ bitfield.cpp
+ daemon.cpp
+ daemonprivate.cpp
+ transaction.cpp
+ transactionprivate.cpp
+ eula.cpp
+ package.cpp
+ signature.cpp
)
find_file(PK_INTERFACE_XML org.freedesktop.PackageKit.xml
@@ -70,7 +79,9 @@ if (Qt5_FOUND)
qt5_add_dbus_interface(packagekitqt_SRC ${PK_TRANSACTION_INTERFACE_XML} transactionproxy)
qt5_generate_moc(daemon.h daemon.moc)
qt5_generate_moc(transaction.h transaction.moc)
- add_custom_target(mocs DEPENDS daemon.moc transaction.moc)
+ qt5_generate_moc(package.h package.moc)
+ qt5_generate_moc(signature.h signature.moc)
+ add_custom_target(mocs DEPENDS daemon.moc transaction.moc package.moc signature.moc)
set(LIBNAME "packagekit-qt5")
elseif (Qt4_FOUND)
View
1  PackageKit-Qt/src/Eula
@@ -0,0 +1 @@
+#include "eula.h"
View
1  PackageKit-Qt/src/Package
@@ -0,0 +1 @@
+#include "package.h"
View
1  PackageKit-Qt/src/Signature
@@ -0,0 +1 @@
+#include "signature.h"
View
18 PackageKit-Qt/src/bitfield.cpp
@@ -6,7 +6,7 @@ Bitfield::Bitfield () : m_val (0)
{
}
-Bitfield::Bitfield (qulonglong val) : m_val (val)
+Bitfield::Bitfield (qint64 val) : m_val (val)
{
}
@@ -14,25 +14,25 @@ Bitfield::~Bitfield ()
{
}
-qulonglong Bitfield::operator& (qulonglong mask) const
+qint64 Bitfield::operator& (qint64 mask) const
{
- return m_val & (1ULL << mask);
+ return m_val & (1 << mask);
}
-qulonglong Bitfield::operator&= (qulonglong mask)
+qint64 Bitfield::operator&= (qint64 mask)
{
- m_val &= (1ULL << mask);
+ m_val &= (1 << mask);
return m_val;
}
-qulonglong Bitfield::operator| (qulonglong mask) const
+qint64 Bitfield::operator| (qint64 mask) const
{
- return m_val | (1ULL << mask);
+ return m_val | (1 << mask);
}
-qulonglong Bitfield::operator|= (qulonglong mask)
+qint64 Bitfield::operator|= (qint64 mask)
{
- m_val |= (1ULL << mask);
+ m_val |= (1 << mask);
return m_val;
}
View
12 PackageKit-Qt/src/bitfield.h
@@ -9,13 +9,13 @@ class Bitfield
{
public:
Bitfield ();
- Bitfield (qulonglong val);
+ Bitfield (qint64 val);
~Bitfield ();
- qulonglong operator& (qulonglong mask) const;
- qulonglong operator&= (qulonglong mask);
- qulonglong operator| (qulonglong mask) const;
- qulonglong operator|= (qulonglong mask);
+ qint64 operator& (qint64 mask) const;
+ qint64 operator&= (qint64 mask);
+ qint64 operator| (qint64 mask) const;
+ qint64 operator|= (qint64 mask);
Bitfield operator& (Bitfield mask) const;
Bitfield operator&= (Bitfield mask);
@@ -25,7 +25,7 @@ class Bitfield
Bitfield& operator= (const Bitfield& other);
private:
- qulonglong m_val;
+ qint64 m_val;
};
} // End namespace PackageKit
View
3  PackageKit-Qt/src/common.h
@@ -18,6 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
+#define PK_TRANSACTION_INTERFACE "org.freedesktop.PackageKit.Transaction"
#define PK_NAME "org.freedesktop.PackageKit"
#define PK_PATH "/org/freedesktop/PackageKit"
@@ -27,9 +28,9 @@
#define AUTH_PACKAGE_EULA_ACCEPT "org.freedesktop.packagekit.package-eula-accept"
#define AUTH_PACKAGE_REMOVE "org.freedesktop.packagekit.package-remove"
#define AUTH_SYSTEM_UPDATE "org.freedesktop.packagekit.system-update"
+#define AUTH_SYSTEM_ROLLBACK "org.freedesktop.packagekit.system-rollback"
#define AUTH_SYSTEM_SOURCES_CONFIGURE "org.freedesktop.packagekit.system-sources-configure"
#define AUTH_SYSTEM_SOURCES_REFRESH "org.freedesktop.packagekit.system-sources-refresh"
#define AUTH_SYSTEM_NETWORK_PROXY_CONFIGURE "org.freedesktop.packagekit.system-network-proxy-configure"
#define AUTH_CANCEL_FOREIGN "org.freedesktop.packagekit.cancel-foreign"
-#define PK_DESKTOP_DEFAULT_DATABASE LOCALSTATEDIR "/lib/PackageKit/desktop-files.db"
View
284 PackageKit-Qt/src/daemon.cpp
@@ -20,19 +20,15 @@
*/
#include <QtSql>
-#include <QDebug>
#include "daemon.h"
#include "daemonprivate.h"
#include "daemonproxy.h"
#include "common.h"
+#include "util.h"
-#define PENDING_CALL(blurb) \
- Q_D(Daemon); \
- QDBusPendingReply<> r = d->daemon->blurb; \
- r.waitForFinished(); \
- d->lastError = r.error(); \
+#define PK_DESKTOP_DEFAULT_DATABASE LOCALSTATEDIR "/lib/PackageKit/desktop-files.db"
using namespace PackageKit;
@@ -52,93 +48,26 @@ Daemon::Daemon(QObject *parent) :
d_ptr(new DaemonPrivate(this))
{
Q_D(Daemon);
- d->daemon = new ::DaemonProxy(QLatin1String(PK_NAME),
- QLatin1String(PK_PATH),
- QDBusConnection::systemBus(),
- this);
+ d->daemon = new ::DaemonProxy(PK_NAME, PK_PATH, QDBusConnection::systemBus(), this);
+
+ connect(d->daemon, SIGNAL(Changed()),
+ this, SIGNAL(changed()));
+ connect(d->daemon, SIGNAL(RepoListChanged()),
+ this, SIGNAL(repoListChanged()));
+ connect(d->daemon, SIGNAL(RestartSchedule()),
+ this, SIGNAL(restartScheduled()));
+ connect(d->daemon, SIGNAL(TransactionListChanged(const QStringList&)),
+ this, SIGNAL(transactionListChanged(const QStringList&)));
+ connect(d->daemon, SIGNAL(UpdatesChanged()),
+ this, SIGNAL(updatesChanged()));
// Set up database for desktop files
QSqlDatabase db;
- db = QSqlDatabase::addDatabase("QSQLITE", PK_DESKTOP_DEFAULT_DATABASE);
- db.setDatabaseName(PK_DESKTOP_DEFAULT_DATABASE);
+ db = QSqlDatabase::addDatabase("QSQLITE");
+ db.setDatabaseName (PK_DESKTOP_DEFAULT_DATABASE);
if (!db.open()) {
qDebug() << "Failed to initialize the desktop files database";
}
-
- qRegisterMetaType<PackageKit::Daemon::Network>("PackageKit::Daemon::Network");
- qRegisterMetaType<PackageKit::Daemon::Authorize>("PackageKit::Daemon::Authorize");
- qRegisterMetaType<PackageKit::Transaction::InternalError>("PackageKit::Transaction::InternalError");
- qRegisterMetaType<PackageKit::Transaction::Role>("PackageKit::Transaction::Role");
- qRegisterMetaType<PackageKit::Transaction::Error>("PackageKit::Transaction::Error");
- qRegisterMetaType<PackageKit::Transaction::Exit>("PackageKit::Transaction::Exit");
- qRegisterMetaType<PackageKit::Transaction::Filter>("PackageKit::Transaction::Filter");
- qRegisterMetaType<PackageKit::Transaction::Message>("PackageKit::Transaction::Message");
- qRegisterMetaType<PackageKit::Transaction::Status>("PackageKit::Transaction::Status");
- qRegisterMetaType<PackageKit::Transaction::MediaType>("PackageKit::Transaction::MediaType");
- qRegisterMetaType<PackageKit::Transaction::Provides>("PackageKit::Transaction::Provides");
- qRegisterMetaType<PackageKit::Transaction::ProvidesFlag>("PackageKit::Transaction::ProvidesFlag");
- qRegisterMetaType<PackageKit::Transaction::DistroUpgrade>("PackageKit::Transaction::DistroUpgrade");
- qRegisterMetaType<PackageKit::Transaction::UpgradeKind>("PackageKit::Transaction::UpgradeKind");
- qRegisterMetaType<PackageKit::Transaction::TransactionFlag>("PackageKit::Transaction::TransactionFlag");
- qRegisterMetaType<PackageKit::Transaction::TransactionFlags>("PackageKit::Transaction::TransactionFlags");
- qRegisterMetaType<PackageKit::Transaction::Restart>("PackageKit::Transaction::Restart");
- qRegisterMetaType<PackageKit::Transaction::UpdateState>("PackageKit::Transaction::UpdateState");
- qRegisterMetaType<PackageKit::Transaction::Group>("PackageKit::Transaction::Group");
- qRegisterMetaType<PackageKit::Transaction::Info>("PackageKit::Transaction::Info");
- qRegisterMetaType<PackageKit::Transaction::SigType>("PackageKit::Transaction::SigType");
-}
-
-void DaemonPrivate::setupSignal(const QString &signal, bool connect)
-{
- Q_Q(Daemon);
-
- const char *signalToConnect = 0;
- const char *memberToConnect = 0;
-
- if (signal == SIGNAL(changed())) {
- signalToConnect = SIGNAL(Changed());
- memberToConnect = SIGNAL(changed());
- } else if (signal == SIGNAL(repoListChanged())) {
- signalToConnect = SIGNAL(RepoListChanged());
- memberToConnect = SIGNAL(repoListChanged());
- } else if (signal == SIGNAL(restartScheduled())) {
- signalToConnect = SIGNAL(RestartSchedule());
- memberToConnect = SIGNAL(restartScheduled());
- } else if (signal == SIGNAL(transactionListChanged(QStringList))) {
- signalToConnect = SIGNAL(TransactionListChanged(QStringList));
- memberToConnect = SIGNAL(transactionListChanged(QStringList));
- } else if (signal == SIGNAL(updatesChanged())) {
- signalToConnect = SIGNAL(UpdatesChanged());
- memberToConnect = SIGNAL(updatesChanged());
- }
-
- if (signalToConnect && memberToConnect) {
- if (connect) {
- q->connect(daemon, signalToConnect, memberToConnect);
- } else {
- daemon->disconnect(signalToConnect, q, memberToConnect);
- }
- }
-}
-
-void Daemon::connectNotify(const char *signal)
-{
- Q_D(Daemon);
- if (!d->connectedSignals.contains(signal) && d->daemon) {
- d->setupSignal(signal, true);
- }
- d->connectedSignals << signal;
-}
-
-void Daemon::disconnectNotify(const char *signal)
-{
- Q_D(Daemon);
- if (d->connectedSignals.contains(signal)) {
- d->connectedSignals.removeOne(signal);
- if (d->daemon && !d->connectedSignals.contains(signal)) {
- d->setupSignal(signal, false);
- }
- }
}
Daemon::~Daemon()
@@ -147,212 +76,159 @@ Daemon::~Daemon()
Transaction::Roles Daemon::actions()
{
- Q_D(const Daemon);
- return d->daemon->roles();
-}
+ QStringList roles = global()->d_ptr->daemon->roles().split(";");
-Transaction::ProvidesFlag Daemon::provides()
-{
- Q_D(const Daemon);
- return static_cast<Transaction::ProvidesFlag>(d->daemon->provides());
+ Transaction::Roles flags;
+ foreach (const QString &role, roles) {
+ flags |= static_cast<Transaction::Role>(Util::enumFromString<Transaction>(role, "Role", "Role"));
+ }
+ return flags;
}
QString Daemon::backendName()
{
- Q_D(const Daemon);
- return d->daemon->backendName();
+ return global()->d_ptr->daemon->backendName();
}
QString Daemon::backendDescription()
{
- Q_D(const Daemon);
- return d->daemon->backendDescription();
+ return global()->d_ptr->daemon->backendDescription();
}
QString Daemon::backendAuthor()
{
- Q_D(const Daemon);
- return d->daemon->backendAuthor();
+ return global()->d_ptr->daemon->backendAuthor();
}
Transaction::Filters Daemon::filters()
{
- Q_D(const Daemon);
- return static_cast<Transaction::Filters>(d->daemon->filters());
+ QStringList filters = global()->d_ptr->daemon->filters().split(";");
+
+ // Adapt a slight difference in the enum
+ if(filters.contains("none")) {
+ filters[filters.indexOf("none")] = "no-filter";
+ }
+
+ Transaction::Filters flags;
+ foreach (const QString &filter, filters) {
+ flags |= static_cast<Transaction::Filter>(Util::enumFromString<Transaction>(filter, "Filter", "Filter"));
+ }
+ return flags;
}
-Transaction::Groups Daemon::groups()
+Package::Groups Daemon::groups()
{
- Q_D(const Daemon);
- return static_cast<Transaction::Groups>(d->daemon->groups());
+ QStringList groups = global()->d_ptr->daemon->groups().split(";");
+
+ Package::Groups flags;
+ foreach (const QString &group, groups) {
+ flags.insert(static_cast<Package::Group>(Util::enumFromString<Package>(group, "Group", "Group")));
+ }
+ return flags;
}
bool Daemon::locked()
{
- Q_D(const Daemon);
- return d->daemon->locked();
+ return global()->d_ptr->daemon->locked();
}
QStringList Daemon::mimeTypes()
{
- Q_D(const Daemon);
- return d->daemon->mimeTypes();
+ return global()->d_ptr->daemon->mimeTypes().split(";");
}
Daemon::Network Daemon::networkState()
{
- Q_D(const Daemon);
- return static_cast<Daemon::Network>(d->daemon->networkState());
+ QString state = global()->d_ptr->daemon->networkState();
+ return static_cast<Daemon::Network>(Util::enumFromString<Daemon>(state, "Network", "Network"));
}
-QString Daemon::distroID()
+QString Daemon::distroId()
{
- Q_D(const Daemon);
- return d->daemon->distroId();
+ return global()->d_ptr->daemon->distroId();
}
Daemon::Authorize Daemon::canAuthorize(const QString &actionId)
{
- Q_D(Daemon);
- QDBusPendingReply<uint> reply = d->daemon->CanAuthorize(actionId);
- reply.waitForFinished();
- d->lastError = reply.error();
- if (reply.isValid()) {
- return static_cast<Daemon::Authorize>(reply.value());
- }
- return Daemon::AuthorizeUnknown;
+ QString result = global()->d_ptr->daemon->CanAuthorize(actionId);
+ return static_cast<Daemon::Authorize>(Util::enumFromString<Daemon>(result, "Authorize", "Authorize"));
}
-QDBusObjectPath Daemon::getTid()
+QString Daemon::getTid()
{
- Q_D(Daemon);
- QDBusPendingReply<QDBusObjectPath> reply = d->daemon->CreateTransaction();
- reply.waitForFinished();
- d->lastError = reply.error();
- if (reply.isValid()) {
- return reply.value();
- }
- return QDBusObjectPath();
+ return global()->d_ptr->daemon->GetTid();
}
uint Daemon::getTimeSinceAction(Transaction::Role role)
{
- Q_D(Daemon);
- QDBusPendingReply<uint> reply = d->daemon->GetTimeSinceAction(role);
- reply.waitForFinished();
- d->lastError = reply.error();
- if (reply.isValid()) {
- return reply.value();
- }
- return 0u;
+ QString roleName = Util::enumToString<Transaction>(role, "Role", "Role");
+ return global()->d_ptr->daemon->GetTimeSinceAction(roleName);
}
-QList<QDBusObjectPath> Daemon::getTransactionList()
+QStringList Daemon::getTransactions()
{
- Q_D(Daemon);
- QDBusPendingReply<QList<QDBusObjectPath> > reply = d->daemon->GetTransactionList();
- reply.waitForFinished();
- d->lastError = reply.error();
- if (reply.isValid()) {
- return reply.value();
- }
- return QList<QDBusObjectPath>();
+ return global()->d_ptr->daemon->GetTransactionList();
}
-QList<Transaction*> Daemon::getTransactionObjects(QObject *parent)
+QList<Transaction*> Daemon::getTransactionsObj(QObject *parent)
{
- Q_D(Daemon);
- return d->transactions(getTransactionList(), parent);
+ return global()->d_ptr->transactions(getTransactions(), parent);
}
-void Daemon::setHints(const QStringList &hints)
+void Daemon::setHints(const QStringList& hints)
{
- Q_D(Daemon);
- d->hints = hints;
+ global()->d_ptr->hints = hints;
}
-void Daemon::setHints(const QString &hints)
+void Daemon::setHints(const QString& hints)
{
- Q_D(Daemon);
- d->hints = QStringList() << hints;
+ global()->d_ptr->hints = QStringList() << hints;
}
QStringList Daemon::hints()
{
- Q_D(const Daemon);
- return d->hints;
+ return global()->d_ptr->hints;
+}
+
+Transaction::InternalError Daemon::setProxy(const QString& http_proxy, const QString& ftp_proxy)
+{
+ return Daemon::setProxy(http_proxy, QString(), ftp_proxy, QString(), QString(), QString());
}
Transaction::InternalError Daemon::setProxy(const QString& http_proxy, const QString& https_proxy, const QString& ftp_proxy, const QString& socks_proxy, const QString& no_proxy, const QString& pac)
{
- Q_D(Daemon);
- QDBusPendingReply<> r = d->daemon->SetProxy(http_proxy, https_proxy, ftp_proxy, socks_proxy, no_proxy, pac);
+ QDBusPendingReply<> r = global()->d_ptr->daemon->SetProxy(http_proxy, https_proxy, ftp_proxy, socks_proxy, no_proxy, pac);
r.waitForFinished();
- d->lastError = r.error();
- if (r.isError()) {
- return Transaction::parseError(r.error().name());
+ if (r.isError ()) {
+ return Util::errorFromString(r.error().name());
} else {
- return Transaction::InternalErrorNone;
+ return Transaction::NoInternalError;
}
}
void Daemon::stateHasChanged(const QString& reason)
{
- PENDING_CALL(StateHasChanged(reason))
+ global()->d_ptr->daemon->StateHasChanged(reason);
}
void Daemon::suggestDaemonQuit()
{
- PENDING_CALL(SuggestDaemonQuit())
-}
-
-QDBusError Daemon::lastError() const
-{
- Q_D(const Daemon);
- return d->lastError;
+ global()->d_ptr->daemon->SuggestDaemonQuit();
}
uint Daemon::versionMajor()
{
- Q_D(const Daemon);
- return d->daemon->versionMajor();
+ return global()->d_ptr->daemon->versionMajor();
}
uint Daemon::versionMinor()
{
- Q_D(const Daemon);
- return d->daemon->versionMinor();
+ return global()->d_ptr->daemon->versionMinor();
}
uint Daemon::versionMicro()
{
- Q_D(const Daemon);
- return d->daemon->versionMicro();
-}
-
-QString Daemon::packageName(const QString &packageID)
-{
- return packageID.section(QLatin1Char(';'), 0, 0);
-}
-
-QString Daemon::packageVersion(const QString &packageID)
-{
- return packageID.section(QLatin1Char(';'), 1, 1);
-}
-
-QString Daemon::packageArch(const QString &packageID)
-{
- return packageID.section(QLatin1Char(';'), 2, 2);
-}
-
-QString Daemon::packageData(const QString &packageID)
-{
- return packageID.section(QLatin1Char(';'), 3, 3);
-}
-
-QString Daemon::packageIcon(const QString &packageID)
-{
- return Transaction::packageIcon(packageID);
+ return global()->d_ptr->daemon->versionMicro();
}
#include "daemon.moc"
View
220 PackageKit-Qt/src/daemon.h
@@ -1,7 +1,7 @@
/*
* This file is part of the QPackageKit project
* Copyright (C) 2008 Adrien Bustany <madcat@mymadcat.com>
- * Copyright (C) 2010-2012 Daniel Nicoletti <dantti12@gmail.com>
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
@pycage
pycage added a note

Looks like reverting to an outdated code base...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,9 +23,8 @@
#define PACKAGEKIT_DAEMON_H
#include <QtCore/QObject>
-#include <QtCore/QMetaEnum>
-#include <QtDBus/QDBusError>
+#include "package.h"
#include "transaction.h"
namespace PackageKit {
@@ -33,7 +32,7 @@ namespace PackageKit {
/**
* \class Daemon daemon.h Daemon
* \author Adrien Bustany \e <madcat@mymadcat.com>
- * \author Daniel Nicoletti \e <dantti12@gmail.com>
+ * \author Daniel Nicoletti \e <dantti85-pk@yahoo.com.br>
*
* \brief Base class used to interact with the PackageKit daemon
*
@@ -51,43 +50,29 @@ class Daemon : public QObject
Q_OBJECT
Q_ENUMS(Network)
Q_ENUMS(Authorize)
- Q_PROPERTY(Transaction::Roles actions READ actions NOTIFY changed)
- Q_PROPERTY(Transaction::ProvidesFlag provides READ provides NOTIFY changed)
- Q_PROPERTY(QString backendName READ backendName NOTIFY changed)
- Q_PROPERTY(QString backendDescription READ backendDescription NOTIFY changed)
- Q_PROPERTY(QString backendAuthor READ backendAuthor NOTIFY changed)
- Q_PROPERTY(Transaction::Filters filters READ filters NOTIFY changed)
- Q_PROPERTY(Transaction::Groups groups READ groups NOTIFY changed)
- Q_PROPERTY(bool locked READ locked NOTIFY changed)
- Q_PROPERTY(QStringList mimeTypes READ mimeTypes NOTIFY changed)
- Q_PROPERTY(Daemon::Network networkState READ networkState NOTIFY changed)
- Q_PROPERTY(QString distroID READ distroID NOTIFY changed)
- Q_PROPERTY(uint versionMajor READ versionMajor NOTIFY changed)
- Q_PROPERTY(uint versionMinor READ versionMinor NOTIFY changed)
- Q_PROPERTY(uint versionMicro READ versionMicro NOTIFY changed)
public:
/**
* Describes the current network state
*/
- enum Network {
- NetworkUnknown,
+ typedef enum {
+ UnknownNetwork,
NetworkOffline,
NetworkOnline,
NetworkWired,
NetworkWifi,
NetworkMobile
- };
+ } Network;
/**
* Describes the authorization result
* \sa canAuthorize()
*/
- enum Authorize {
- AuthorizeUnknown,
+ typedef enum {
+ UnknownAuthorize,
AuthorizeYes,
AuthorizeNo,
AuthorizeInteractive
- };
+ } Authorize;
/**
* \brief Returns an instance of the Daemon
@@ -106,74 +91,54 @@ class Daemon : public QObject
/**
* Returns all the actions supported by the current backend
*/
- Transaction::Roles actions();
-
- /**
- * Returns all the actions supported by the current backend
- */
- Transaction::ProvidesFlag provides();
+ static Transaction::Roles actions();
/**
* The backend name, e.g. "yum".
*/
- QString backendName();
+ static QString backendName();
/**
* The backend description, e.g. "Yellow Dog Update Modifier".
*/
- QString backendDescription();
+ static QString backendDescription();
/**
* The backend author, e.g. "Joe Bloggs <joe@blogs.com>"
*/
- QString backendAuthor();
+ static QString backendAuthor();
/**
* Returns the package filters supported by the current backend
*/
- Transaction::Filters filters();
+ static Transaction::Filters filters();
/**
* Returns the package groups supported by the current backend
*/
- Transaction::Groups groups();
+ static Package::Groups groups();
/**
* Set when the backend is locked and native tools would fail.
*/
- bool locked();
+ static bool locked();
/**
* Returns a list containing the MIME types supported by the current backend
*/
- QStringList mimeTypes();
+ static QStringList mimeTypes();
/**
* Returns the current network state
*/
- Daemon::Network networkState();
+ static Daemon::Network networkState();
/**
* The distribution identifier in the
* distro;version;arch form,
* e.g. "debian;squeeze/sid;x86_64".
*/
- QString distroID();
-
- /**
- * Returns the major version number.
- */
- uint versionMajor();
-
- /**
- * The minor version number.
- */
- uint versionMinor();
-
- /**
- * The micro version number.
- */
- uint versionMicro();
+ static QString distroId();
/**
* Allows a client to find out if it would be allowed to authorize an action.
@@ -181,12 +146,12 @@ class Daemon : public QObject
* specified in \p actionId
* Returm might be either yes, no or interactive \sa Authorize.
*/
- Q_INVOKABLE Authorize canAuthorize(const QString &actionId);
+ static Daemon::Authorize canAuthorize(const QString &actionId);
/**
* Returns the time (in seconds) since the specified \p action
*/
- Q_INVOKABLE uint getTimeSinceAction(PackageKit::Transaction::Role action);
+ static uint getTimeSinceAction(Transaction::Role action);
/**
* \brief creates a new transaction path
@@ -199,12 +164,12 @@ class Daemon : public QObject
* is not useful as simply creating a \c Transaction object will
* automatically create this path.
*/
- Q_INVOKABLE QDBusObjectPath getTid();
+ static QString getTid();
/**
* Returns the list of current transactions
*/
- Q_INVOKABLE QList<QDBusObjectPath> getTransactionList();
+ static QStringList getTransactions();
/**
* Convenience function
@@ -213,7 +178,7 @@ class Daemon : public QObject
* You must delete these yourself or pass a
* \p parent for these comming transactions
*/
- Q_INVOKABLE QList<Transaction*> getTransactionObjects(QObject *parent = 0);
+ static QList<Transaction*> getTransactionsObj(QObject *parent = 0);
/**
* \brief Sets a global hints for all the transactions to be created
@@ -233,141 +198,55 @@ class Daemon : public QObject
*
* \sa Transaction::setHints
*/
- Q_INVOKABLE void setHints(const QStringList &hints);
+ static void setHints(const QStringList &hints);
/**
* Convenience function to set global hints
* \sa setHints(const QStringList &hints)
*/
- Q_INVOKABLE void setHints(const QString &hints);
+ static void setHints(const QString &hints);
/**
* This method returns the current hints
*/
- Q_INVOKABLE QStringList hints();
+ static QStringList hints();
+
+ /**
+ * Sets a proxy to be used for all the network operations
+ */
+ static Transaction::InternalError setProxy(const QString &http_proxy, const QString &ftp_proxy);
/**
* Sets a proxy to be used for all the network operations
*/
- Q_INVOKABLE Transaction::InternalError setProxy(const QString &http_proxy, const QString &https_proxy, const QString &ftp_proxy, const QString &socks_proxy, const QString &no_proxy, const QString &pac);
+ static Transaction::InternalError setProxy(const QString &http_proxy, const QString &https_proxy, const QString &ftp_proxy, const QString &socks_proxy, const QString &no_proxy, const QString &pac);
/**
* \brief Tells the daemon that the system state has changed, to make it reload its cache
*
* \p reason can be resume or posttrans
*/
- Q_INVOKABLE void stateHasChanged(const QString &reason);
+ static void stateHasChanged(const QString &reason);
/**
* Asks PackageKit to quit, for example to let a native package manager operate
*/
- Q_INVOKABLE void suggestDaemonQuit();
-
- /**
- * Get the last call status
- */
- Q_INVOKABLE QDBusError lastError() const;
+ static void suggestDaemonQuit();
/**
- * Returns the package name from the \p packageID
- */
- Q_INVOKABLE static QString packageName(const QString &packageID);
-
- /**
- * Returns the package version from the \p packageID
- */
- Q_INVOKABLE static QString packageVersion(const QString &packageID);
-
- /**
- * Returns the package arch from the \p packageID
+ * Returns the major version number.
*/
- Q_INVOKABLE static QString packageArch(const QString &packageID);
+ static uint versionMajor();
/**
- * Returns the package data from the \p packageID
+ * The minor version number.
*/
- Q_INVOKABLE static QString packageData(const QString &packageID);
+ static uint versionMinor();
/**
- * Returns the package icon from the \p packageID
- */
- Q_INVOKABLE static QString packageIcon(const QString &packageID);
-
- /**
- * Returns the string representing the enum
- * Useful for PackageDetails::Group
+ * The micro version number.
*/
- template<class T> static QString enumToString(int value, const char *enumName)
- {
- QString prefix = enumName;
- int id = T::staticMetaObject.indexOfEnumerator(enumName);
- QMetaEnum e = T::staticMetaObject.enumerator(id);
- if (!e.isValid ()) {
-// qDebug() << "Invalid enum " << prefix;
- return QString();
- }
- QString enumString = e.valueToKey(value);
- if (enumString.isNull()) {
-// qDebug() << "Enum key not found while searching for value" << QString::number(value) << "in enum" << prefix;
- return QString();
- }
-
- // Remove the prefix
- if(!prefix.isNull() && enumString.indexOf(prefix) == 0) {
- enumString.remove(0, prefix.length());
- }
-
- QString pkName;
- for(int i = 0 ; i < enumString.length() - 1 ; ++i) {
- pkName += enumString[i];
- if(enumString[i+1].isUpper())
- pkName += QChar('-');
- }
- pkName += enumString[enumString.length() - 1];
-
- return pkName.toLower();
- }
-
- template<class T> static int enumFromString(const QString &str, const char *enumName)
- {
- QString prefix = enumName;
- QString realName;
- bool lastWasDash = false;
- QChar buf;
-
- for(int i = 0 ; i < str.length() ; ++i) {
- buf = str[i].toLower();
- if(i == 0 || lastWasDash) {
- buf = buf.toUpper();
- }
-
- lastWasDash = false;
- if(buf == QLatin1Char('-')) {
- lastWasDash = true;
- } else if(buf == QLatin1Char('~')) {
- lastWasDash = true;
- realName += "Not";
- } else {
- realName += buf;
- }
- };
-
- if (!prefix.isNull()) {
- realName = prefix + realName;
- }
-
- int id = T::staticMetaObject.indexOfEnumerator(enumName);
- QMetaEnum e = T::staticMetaObject.enumerator(id);
- int enumValue = e.keyToValue(realName.toLatin1().data());
-
- if (enumValue == -1) {
- enumValue = e.keyToValue(prefix.append("Unknown").toLatin1().data());
- if (!QString(enumName).isEmpty()) {
-// qDebug() << "enumFromString (" << enumName << ") : converted" << str << "to" << QString("Unknown").append(enumName) << ", enum id" << id;
- }
- }
- return enumValue;
- }
+ static uint versionMicro();
Q_SIGNALS:
/**
@@ -403,20 +282,6 @@ class Daemon : public QObject
void daemonQuit();
protected:
- /**
- * This method connects to DBus signals
- * \attention Make sure to call this method in inherited classes
- * otherwise no signals will be emitted
- */
- virtual void connectNotify(const char *signal);
-
- /**
- * This method disconnects from DBus signals
- * \attention Make sure to call this method in inherited classes
- * otherwise no signals will be disconnected
- */
- virtual void disconnectNotify(const char *signal);
-
DaemonPrivate * const d_ptr;
private:
@@ -428,7 +293,4 @@ class Daemon : public QObject
} // End namespace PackageKit
-Q_DECLARE_METATYPE(PackageKit::Daemon::Network)
-Q_DECLARE_METATYPE(PackageKit::Daemon::Authorize)
-
#endif
View
8 PackageKit-Qt/src/daemonprivate.cpp
@@ -30,18 +30,18 @@ using namespace PackageKit;
DaemonPrivate::DaemonPrivate(Daemon* parent) :
q_ptr(parent)
{
- m_watcher = new QDBusServiceWatcher(QLatin1String(PK_NAME),
+ m_watcher = new QDBusServiceWatcher(PK_NAME,
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForUnregistration,
q_ptr);
- q_ptr->connect(m_watcher, SIGNAL(serviceUnregistered(QString)),
+ q_ptr->connect(m_watcher, SIGNAL(serviceUnregistered(const QString &)),
SLOT(serviceUnregistered()));
}
-QList<Transaction*> DaemonPrivate::transactions(const QList<QDBusObjectPath> &tids, QObject *parent)
+QList<Transaction*> DaemonPrivate::transactions(const QStringList& tids, QObject *parent)
{
QList<Transaction*> transactionList;
- foreach (const QDBusObjectPath &tid, tids) {
+ foreach (const QString &tid, tids) {
Transaction *transaction = new Transaction(tid, parent);
transactionList << transaction;
}
View
25 PackageKit-Qt/src/daemonprivate.h
@@ -40,12 +40,29 @@ class DaemonPrivate
Daemon *q_ptr;
::DaemonProxy *daemon;
+
QStringList hints;
- QDBusError lastError;
- QStringList connectedSignals;
- QList<Transaction*> transactions(const QList<QDBusObjectPath> &tids, QObject *parent);
- void setupSignal(const QString &signal, bool connect);
+ QList<Transaction*> transactions(const QStringList &tids, QObject *parent);
+
+ /*
+ * Describes the different errors that might happen on the bus
+ *
+ * \sa Daemon::error
+ * \sa Transaction::error
+ */
+ typedef enum {
+ NoError = 0,
+ ErrorFailed,
+ ErrorFailedAuth,
+ ErrorNoTid,
+ ErrorAlreadyTid,
+ ErrorRoleUnkown,
+ ErrorCannotStartDaemon,
+ ErrorInvalidInput,
+ ErrorInvalidFile,
+ ErrorNotSupported
+ } TransactionError;
protected Q_SLOTS:
void serviceUnregistered();
View
28 PackageKit-Qt/src/daemonproxy.cpp
@@ -0,0 +1,28 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -c DaemonProxy -p daemonproxy -m -N ../../src/org.freedesktop.PackageKit.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "daemonproxy.h"
+
+/*
+ * Implementation of interface class DaemonProxy
+ */
+
+DaemonProxy::DaemonProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+DaemonProxy::~DaemonProxy()
+{
+}
+
+
+#include "daemonproxy.moc"
View
158 PackageKit-Qt/src/daemonproxy.h
@@ -0,0 +1,158 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -c DaemonProxy -p daemonproxy -m -N ../../src/org.freedesktop.PackageKit.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef DAEMONPROXY_H_1345558052
+#define DAEMONPROXY_H_1345558052
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.freedesktop.PackageKit
+ */
+class DaemonProxy: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.PackageKit"; }
+
+public:
+ DaemonProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~DaemonProxy();
+
+ Q_PROPERTY(QString BackendAuthor READ backendAuthor)
+ inline QString backendAuthor() const
+ { return qvariant_cast< QString >(property("BackendAuthor")); }
+
+ Q_PROPERTY(QString BackendDescription READ backendDescription)
+ inline QString backendDescription() const
+ { return qvariant_cast< QString >(property("BackendDescription")); }
+
+ Q_PROPERTY(QString BackendName READ backendName)
+ inline QString backendName() const
+ { return qvariant_cast< QString >(property("BackendName")); }
+
+ Q_PROPERTY(QString DistroId READ distroId)
+ inline QString distroId() const
+ { return qvariant_cast< QString >(property("DistroId")); }
+
+ Q_PROPERTY(QString Filters READ filters)
+ inline QString filters() const
+ { return qvariant_cast< QString >(property("Filters")); }
+
+ Q_PROPERTY(QString Groups READ groups)
+ inline QString groups() const
+ { return qvariant_cast< QString >(property("Groups")); }
+
+ Q_PROPERTY(bool Locked READ locked)
+ inline bool locked() const
+ { return qvariant_cast< bool >(property("Locked")); }
+
+ Q_PROPERTY(QString MimeTypes READ mimeTypes)
+ inline QString mimeTypes() const
+ { return qvariant_cast< QString >(property("MimeTypes")); }
+
+ Q_PROPERTY(QString NetworkState READ networkState)
+ inline QString networkState() const
+ { return qvariant_cast< QString >(property("NetworkState")); }
+
+ Q_PROPERTY(QString Roles READ roles)
+ inline QString roles() const
+ { return qvariant_cast< QString >(property("Roles")); }
+
+ Q_PROPERTY(uint VersionMajor READ versionMajor)
+ inline uint versionMajor() const
+ { return qvariant_cast< uint >(property("VersionMajor")); }
+
+ Q_PROPERTY(uint VersionMicro READ versionMicro)
+ inline uint versionMicro() const
+ { return qvariant_cast< uint >(property("VersionMicro")); }
+
+ Q_PROPERTY(uint VersionMinor READ versionMinor)
+ inline uint versionMinor() const
+ { return qvariant_cast< uint >(property("VersionMinor")); }
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QString> CanAuthorize(const QString &action_id)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(action_id);
+ return asyncCallWithArgumentList(QLatin1String("CanAuthorize"), argumentList);
+ }
+
+ inline QDBusPendingReply<QString> GetDaemonState()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetDaemonState"), argumentList);
+ }
+
+ inline QDBusPendingReply<QString> GetTid()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetTid"), argumentList);
+ }
+
+ inline QDBusPendingReply<uint> GetTimeSinceAction(const QString &role)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(role);
+ return asyncCallWithArgumentList(QLatin1String("GetTimeSinceAction"), argumentList);
+ }
+
+ inline QDBusPendingReply<QStringList> GetTransactionList()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetTransactionList"), argumentList);
+ }
+
+ inline QDBusPendingReply<> SetProxy(const QString &proxy_http, const QString &proxy_https, const QString &proxy_ftp, const QString &proxy_socks, const QString &no_proxy, const QString &pac)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(proxy_http) << QVariant::fromValue(proxy_https) << QVariant::fromValue(proxy_ftp) << QVariant::fromValue(proxy_socks) << QVariant::fromValue(no_proxy) << QVariant::fromValue(pac);
+ return asyncCallWithArgumentList(QLatin1String("SetProxy"), argumentList);
+ }
+
+ inline QDBusPendingReply<> SetRoot(const QString &root)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(root);
+ return asyncCallWithArgumentList(QLatin1String("SetRoot"), argumentList);
+ }
+
+ inline QDBusPendingReply<> StateHasChanged(const QString &reason)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(reason);
+ return asyncCallWithArgumentList(QLatin1String("StateHasChanged"), argumentList);
+ }
+
+ inline QDBusPendingReply<> SuggestDaemonQuit()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("SuggestDaemonQuit"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void Changed();
+ void RepoListChanged();
+ void RestartSchedule();
+ void TransactionListChanged(const QStringList &transactions);
+ void UpdatesChanged();
+};
+
+#endif
View
22 PackageKit-Qt/src/eula.cpp
@@ -0,0 +1,22 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2008 Adrien Bustany <madcat@mymadcat.com>
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "eula.h"
View
56 PackageKit-Qt/src/eula.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PACKAGEKIT_EULA_H
+#define PACKAGEKIT_EULA_H
+
+#include <QtCore/QObject>
+
+#include "package.h"
+
+namespace PackageKit {
+
+class Eula
+{
+public:
+ /**
+ * \c repoId is the id of the software repository containing the package
+ */
+ QString id;
+
+ /**
+ * \c package is the package for which an EULA is required
+ */
+ Package package;
+
+ /**
+ * Describes the name of the EULA's vendor
+ */
+ QString vendor;
+
+ /**
+ * Describes the EULA text
+ */
+ QString licenseAgreement;
+};
+
+} // End namespace PackageKit
+
+#endif
View
560 PackageKit-Qt/src/package.cpp
@@ -0,0 +1,560 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2008 Adrien Bustany <madcat@mymadcat.com>
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <QtSql/QSqlQuery>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+#include <QtCore/QVariant>
+#include <QtCore/QStringList>
+#include <QtCore/QMetaEnum>
+
+#include "package.h"
+#include "transaction.h"
+#include "util.h"
+
+namespace PackageKit {
+
+class DetailsPrivate
+{
+public:
+ QString license;
+ Package::Group group;
+ QString description;
+ QString url;
+ uint size;
+};
+
+class UpdateDetailsPrivate {
+public:
+ QList<Package> updates;
+ QList<Package> obsoletes;
+ QString vendorUrl;
+ QString bugzillaUrl;
+ QString cveUrl;
+ Package::Restart restart;
+ QString updateText;
+ QString changelog;
+ Package::UpdateState state;
+ QDateTime issued;
+ QDateTime updated;
+};
+
+class PackagePrivate
+{
+public:
+ QString id;
+ QString name;
+ QString version;
+ QString arch;
+ QString data;
+ QString summary;
+ Package::Info info;
+ DetailsPrivate *details;
+ UpdateDetailsPrivate *updateDetails;
+ QString iconPath;
+};
+
+}
+
+using namespace PackageKit;
+
+Package::Package(const QString &packageId, Info info, const QString &summary)
+ : d_ptr(new PackagePrivate)
+{
+ d_ptr->id = packageId;
+ d_ptr->info = info;
+ d_ptr->summary = summary;
+ d_ptr->details = 0;
+ d_ptr->updateDetails = 0;
+
+ // Break down the packageId
+ QStringList tokens = packageId.split(";");
+ if(tokens.size() == 4) {
+ d_ptr->name = tokens.at(0);
+ d_ptr->version = tokens.at(1);
+ d_ptr->arch = tokens.at(2);
+ d_ptr->data = tokens.at(3);
+ }
+}
+
+Package::Package()
+ : d_ptr(new PackagePrivate)
+{
+ d_ptr->details = 0;
+ d_ptr->updateDetails = 0;
+ d_ptr->info = UnknownInfo;
+}
+
+Package::Package(const Package &other)
+ : d_ptr(new PackagePrivate)
+{
+ d_ptr->details = 0;
+ d_ptr->updateDetails = 0;
+ d_ptr->info = UnknownInfo;
+
+ *this = other;
+}
+
+Package::~Package()
+{
+ Q_D(Package);
+ if (d->details) {
+ delete d->details;
+ }
+ if (d->updateDetails) {
+ delete d->updateDetails;
+ }
+ delete d;
+}
+
+QString Package::id() const
+{
+ Q_D(const Package);
+ return d->id;
+}
+
+QString Package::name() const
+{
+ Q_D(const Package);
+ return d->name;
+}
+
+QString Package::version() const
+{
+ Q_D(const Package);
+ return d->version;
+}
+
+QString Package::arch() const
+{
+ Q_D(const Package);
+ return d->arch;
+}
+
+QString Package::data() const
+{
+ Q_D(const Package);
+ return d->data;
+}
+
+QString Package::summary() const
+{
+ Q_D(const Package);
+ return d->summary;
+}
+
+Package::Info Package::info() const
+{
+ Q_D(const Package);
+ return d->info;
+}
+
+bool Package::hasDetails() const
+{
+ Q_D(const Package);
+ return d->details;
+}
+
+QString Package::iconPath() const
+{
+ Q_D(const Package);
+
+ QString path;
+ QSqlDatabase db = QSqlDatabase::database();
+ if (!db.isOpen()) {
+ qDebug() << "Desktop files database is not open";
+ return path;
+ }
+
+ QSqlQuery q(db);
+ q.prepare("SELECT filename FROM cache WHERE package = :name");
+ q.bindValue(":name", d->name);
+ if (q.exec()) {
+ if (q.next()) {
+ QFile desktopFile (q.value(0).toString());
+ if (desktopFile.open (QIODevice::ReadOnly | QIODevice::Text)) {
+ while (!desktopFile.atEnd ()) {
+ QByteArray line = desktopFile.readLine().trimmed();
+ if (line.startsWith("Icon=")) {
+ path = line.mid(5);
+ break;
+ }
+ }
+ desktopFile.close();
+ } else {
+ qDebug() << "Cannot open desktop file " << q.value(0).toString();
+ }
+ }
+ } else {
+ qDebug() << "Error while running query " << q.executedQuery();
+ }
+
+ return path;
+}
+
+QString Package::license() const
+{
+ Q_D(const Package);
+ if (d->details) {
+ return d->details->license;
+ }
+ return QString();
+}
+
+void Package::setLicense(const QString &license)
+{
+ Q_D(Package);
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->license = license;
+}
+
+Package::Group Package::group() const
+{
+ Q_D(const Package);
+ if (d->details) {
+ return d->details->group;
+ }
+ return UnknownGroup;
+}
+
+void Package::setGroup(Group group)
+{
+ Q_D(Package);
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->group = group;
+}
+
+QString Package::description() const
+{
+ Q_D(const Package);
+ if (d->details) {
+ return d->details->description;
+ }
+ return QString();
+}
+
+void Package::setDescription(const QString &description)
+{
+ Q_D(Package);
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->description = description;
+}
+
+QString Package::url() const
+{
+ Q_D(const Package);
+ if (d->details) {
+ return d->details->url;
+ }
+ return QString();
+}
+
+void Package::setUrl(const QString &url)
+{
+ Q_D(Package);
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->url = url;
+}
+
+qulonglong Package::size() const
+{
+ Q_D(const Package);
+ if (d->details) {
+ return d->details->size;
+ }
+ return 0;
+}
+
+void Package::setSize(qulonglong size)
+{
+ Q_D(Package);
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->size = size;
+}
+
+bool Package::hasUpdateDetails() const
+{
+ Q_D(const Package);
+ return d->updateDetails;
+}
+
+QList<Package> Package::updates() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->updates;
+ }
+ return QList<Package>();
+}
+
+void Package::setUpdates(const QList<Package> &updates)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->updates = updates;
+}
+
+QList<Package> Package::obsoletes() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->obsoletes;
+ }
+ return QList<Package>();
+}
+
+void Package::setObsoletes(const QList<Package> &obsoletes)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->obsoletes = obsoletes;
+}
+
+QString Package::vendorUrl() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->vendorUrl;
+ }
+ return QString();
+}
+
+void Package::setVendorUrl(const QString &vendorUrl)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->vendorUrl = vendorUrl;
+}
+
+QString Package::bugzillaUrl() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->bugzillaUrl;
+ }
+ return QString();
+}
+
+void Package::setBugzillaUrl(const QString &bugzillaUrl)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->bugzillaUrl = bugzillaUrl;
+}
+
+QString Package::cveUrl() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->cveUrl;
+ }
+ return QString();
+}
+
+void Package::setCveUrl(const QString &cveUrl)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->cveUrl = cveUrl;
+}
+
+Package::Restart Package::restart() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->restart;
+ }
+ return Package::UnknownRestart;
+}
+
+void Package::setRestart(Package::Restart restart)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->restart = restart;
+}
+
+QString Package::updateText() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->updateText;
+ }
+ return QString();
+}
+
+void Package::setUpdateText(const QString &updateText)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->updateText = updateText;
+}
+
+QString Package::changelog() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->changelog;
+ }
+ return QString();
+}
+
+void Package::setChangelog(const QString &changelog)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->changelog = changelog;
+}
+
+Package::UpdateState Package::state() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->state;
+ }
+ return UnknownUpdateState;
+}
+
+void Package::setState(UpdateState state)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->state = state;
+}
+
+QDateTime Package::issued() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->issued;
+ }
+ return QDateTime();
+}
+
+void Package::setIssued(const QDateTime &issued)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->issued = issued;
+}
+
+QDateTime Package::updated() const
+{
+ Q_D(const Package);
+ if (d->updateDetails) {
+ return d->updateDetails->updated;
+ }
+ return QDateTime();
+}
+
+void Package::setUpdated(const QDateTime &updated)
+{
+ Q_D(Package);
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->updated = updated;
+}
+
+bool Package::operator==(const Package &package) const
+{
+ Q_D(const Package);
+ return d->id == package.id();
+}
+
+Package& Package::operator=(const Package &package)
+{
+ Q_D(Package);
+
+ if (this != &package) // protect against invalid self-assignment
+ {
+ d->id = package.id();
+ d->name = package.name();
+ d->version = package.version();
+ d->arch = package.arch();
+ d->data = package.data();
+
+ d->summary = package.summary();
+ d->info = package.info();
+
+ if (package.hasDetails()) {
+ if (!d->details) {
+ d->details = new DetailsPrivate;
+ }
+ d->details->license = package.license();
+ d->details->group = package.group();
+ d->details->description = package.description();
+ d->details->url = package.url();
+ d->details->size = package.size();
+ }
+
+ if (package.hasUpdateDetails()) {
+ if (!d->updateDetails) {
+ d->updateDetails = new UpdateDetailsPrivate;
+ }
+ d->updateDetails->updates = package.updates();
+ d->updateDetails->obsoletes = package.obsoletes();
+ d->updateDetails->vendorUrl = package.vendorUrl();
+ d->updateDetails->bugzillaUrl = package.bugzillaUrl();
+ d->updateDetails->cveUrl = package.cveUrl();
+ d->updateDetails->restart = package.restart();
+ d->updateDetails->state = package.state();
+ d->updateDetails->updateText = package.updateText();
+ d->updateDetails->changelog = package.changelog();
+ d->updateDetails->state = package.state();
+ d->updateDetails->issued = package.issued();
+ d->updateDetails->updated = package.updated();
+ }
+ }
+ return *this;
+}
+
+#include "package.moc"
View
432 PackageKit-Qt/src/package.h
@@ -0,0 +1,432 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2008 Adrien Bustany <madcat@mymadcat.com>
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PACKAGEKIT_PACKAGE_H
+#define PACKAGEKIT_PACKAGE_H
+
+#include <QtCore/QString>
+#include <QtCore/QDateTime>
+#include <QtCore/QSet>
+
+namespace PackageKit {
+
+/**
+ * \class Package package.h Package
+ * \author Adrien Bustany \e <madcat@mymadcat.com>
+ * \author Daniel Nicoletti \e <dantti85-pk@yahoo.com.br>
+ *
+ * \brief Represents a software package
+ *
+ * This class represents a software package.
+ *
+ * \note All Package objects should be deleted by the user.
+ */
+class PackagePrivate;
+class Package
+{
+ Q_GADGET
+ Q_ENUMS(Info)
+ Q_ENUMS(Group)
+ Q_ENUMS(UpdateState)
+ Q_ENUMS(Restart)
+public:
+ /**
+ * Describes the state of a package
+ */
+ typedef enum {
+ UnknownInfo,
+ InfoInstalled,
+ InfoAvailable,
+ InfoLow,
+ InfoEnhancement,
+ InfoNormal,
+ InfoBugfix,
+ InfoImportant,
+ InfoSecurity,
+ InfoBlocked,
+ InfoDownloading,
+ InfoUpdating,
+ InfoInstalling,
+ InfoRemoving,
+ InfoCleanup,
+ InfoObsoleting,
+ InfoCollectionInstalled,
+ InfoCollectionAvailable,
+ InfoFinished,
+ InfoReinstalling,
+ InfoDowngrading,
+ InfoPreparing,
+ InfoDecompressing,
+ InfoUntrusted,
+ InfoTrusted
+ } Info;
+
+ /**
+ * Describes the different package groups
+ */
+ typedef enum {
+ UnknownGroup,
+ GroupAccessibility,
+ GroupAccessories,
+ GroupAdminTools,
+ GroupCommunication,
+ GroupDesktopGnome,
+ GroupDesktopKde,
+ GroupDesktopOther,
+ GroupDesktopXfce,
+ GroupEducation,
+ GroupFonts,
+ GroupGames,
+ GroupGraphics,
+ GroupInternet,
+ GroupLegacy,
+ GroupLocalization,
+ GroupMaps,
+ GroupMultimedia,
+ GroupNetwork,
+ GroupOffice,
+ GroupOther,
+ GroupPowerManagement,
+ GroupProgramming,
+ GroupPublishing,
+ GroupRepos,
+ GroupSecurity,
+ GroupServers,
+ GroupSystem,
+ GroupVirtualization,
+ GroupScience,
+ GroupDocumentation,
+ GroupElectronics,
+ GroupCollections,
+ GroupVendor,
+ GroupNewest
+ } Group;
+ typedef QSet<Group> Groups;
+
+ /**
+ * Describes an update's state
+ */
+ typedef enum {
+ UnknownUpdateState,
+ UpdateStateStable,
+ UpdateStateUnstable,
+ UpdateStateTesting,
+ } UpdateState;
+
+ /**
+ * Describes a restart type
+ */
+ typedef enum {
+ UnknownRestart,
+ RestartNone,
+ RestartApplication,
+ RestartSession,
+ RestartSystem,
+ RestartSecuritySession, /* a library that is being used by this package has been updated for security */
+ RestartSecuritySystem
+ } Restart;
+
+ /**
+ * Constructs package
+ */
+ Package(const QString &packageId, Info info = UnknownInfo, const QString &summary = QString());
+
+ /**
+ * Constructs a copy of other.
+ */
+ Package(const Package &other);
+
+ /**
+ * Constructs an invalid package.
+ */
+ Package();
+
+ /**
+ * Destructor
+ */
+ ~Package();
+
+ /**
+ * \brief Returns the package ID
+ *
+ * A PID (package ID) uniquely identifies a package among all software repositories
+ */
+ QString id() const;
+
+ /**
+ * Returns the package name, for example vim
+ */
+ QString name() const;
+
+ /**
+ * Returns the package version, for example 7.0
+ */
+ QString version() const;
+
+ /**
+ * Returns the package's architecture, for example x86_64
+ */
+ QString arch() const;
+
+ /**
+ * Holds additionnal data about the package set by the backend
+ */
+ QString data() const;
+
+ /**
+ * Returns the package's summary. You can get more details by using Client::getDetails
+ */
+ QString summary() const;
+
+ /**
+ * Returns the package's info
+ */
+ Info info() const;
+
+ /**
+ * Checks weither the package has details or not
+ * \sa Transaction::getDetails()
+ */
+ bool hasDetails() const;
+
+ /**
+ * Returns the package's license
+ * \note this will only return a valid value if hasDetails() returns true
+ */
+ QString license() const;
+
+ /**
+ * Define the package's license
+ * \note this will make hasDetails() return true
+ */
+ void setLicense(const QString &license);
+
+ /**
+ * Returns the package's group (for example Multimedia, Editors...)
+ * \note this will only return a valid value if hasDetails() returns true
+ */
+ Group group() const;
+
+ /**
+ * Define the package's group
+ * \note this will make hasDetails() return true
+ */
+ void setGroup(Group group);
+
+ /**
+ * Returns the package's long description
+ * \note this will only return a valid value if hasDetails() returns true
+ */
+ QString description() const;
+
+ /**
+ * Define the package's long description
+ * \note this will make hasDetails() return true
+ */
+ void setDescription(const QString &description);
+
+ /**
+ * Returns the software's homepage url
+ * \note this will only return a valid value if hasDetails() returns true
+ */
+ QString url() const;
+
+ /**
+ * Define the package's url
+ * \note this will make hasDetails() return true
+ */
+ void setUrl(const QString &url);
+
+ /**
+ * Returns the package's size
+ * \note this will only return a valid value if hasDetails() returns true
+ */
+ qulonglong size() const;
+
+ /**
+ * Define the package's size
+ * \note this will make hasDetails() return true
+ */
+ void setSize(qulonglong size);
+
+ /**
+ * Returns if the package has update details
+ */
+ bool hasUpdateDetails() const;
+
+ /**
+ * Returns the package list of packages that will be updated by updating this package
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QList<Package> updates() const;
+
+ /**
+ * Define the list of packages that will be updated by updating this package
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setUpdates(const QList<Package> &updates);
+
+ /**
+ * Returns the package list of packages that will be obsoleted by this update
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QList<Package> obsoletes() const;
+
+ /**
+ * Define the list of packages that will be obsoleted by updating this package
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setObsoletes(const QList<Package> &obsoletes);
+
+ /**
+ * Returns the verdor URL of this update
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QString vendorUrl() const;
+
+ /**
+ * Define the vendor URL
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setVendorUrl(const QString &vendorUrl);
+
+ /**
+ * Returns the bugzilla URL of this update
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QString bugzillaUrl() const;
+
+ /**
+ * Define the bugzilla URL
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setBugzillaUrl(const QString &bugzillaUrl);
+
+ /**
+ * Returns the CVE (Common Vulnerabilities and Exposures) URL of this update
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QString cveUrl() const;
+
+ /**
+ * Define the CVE (Common Vulnerabilities and Exposures) URL
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setCveUrl(const QString &cveUrl);
+
+ /**
+ * Returns the what kind of restart will be required after this update
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ Package::Restart restart() const;
+
+ /**
+ * Define the restart type
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setRestart(Package::Restart restart);
+
+ /**
+ * Returns the update description's
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QString updateText() const;
+
+ /**
+ * Define the update description's
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setUpdateText(const QString &updateText);
+
+ /**
+ * Returns the update changelog's
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QString changelog() const;
+
+ /**
+ * Define the update changelog's
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setChangelog(const QString &changelog);
+
+ /**
+ * Returns the category of the update, eg. stable or testing
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ UpdateState state() const;
+
+ /**
+ * Define the update changelog's
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setState(UpdateState state);
+
+ /**
+ * Returns the date and time when this update was first issued
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QDateTime issued() const;
+
+ /**
+ * Define the date and time when this update was first issued
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setIssued(const QDateTime &issued);
+
+ /**
+ * Returns the date and time when this updated was updated
+ * \note this will only return a valid value if hasUpdateDetails() returns true
+ */
+ QDateTime updated() const;
+
+ /**
+ * Define the date and time when this updated was updated
+ * \note this will make hasUpdateDetails() return true
+ */
+ void setUpdated(const QDateTime &updated);
+
+ /**
+ * Returns the path to the package icon, if known
+ * \return A QString holding the path to the package icon if known, an empty QString else
+ */
+ QString iconPath() const;
+
+ /**
+ * Compares two packages by it's ids
+ */
+ bool operator==(const Package &package) const;
+
+ /**
+ * Copy the other package data
+ */
+ Package& operator=(const Package &package);
+
+private:
+ PackagePrivate * const d_ptr;
+
+private:
+ Q_DECLARE_PRIVATE(Package);
+};
+
+} // End namespace PackageKit
+
+#endif
View
24 PackageKit-Qt/src/signature.cpp
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2008 Adrien Bustany <madcat@mymadcat.com>
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "signature.h"
+
+#include "signature.moc"
View
86 PackageKit-Qt/src/signature.h
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the QPackageKit project
+ * Copyright (C) 2010-2011 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PACKAGEKIT_SIGNATURE_H
+#define PACKAGEKIT_SIGNATURE_H
+
+#include <QtCore/QObject>
+
+#include "package.h"
+
+namespace PackageKit {
+
+class Signature
+{
+ Q_GADGET
+ Q_ENUMS(Type)
+public:
+ /**
+ * Describes a signature type
+ */
+ typedef enum {
+ UnknownType,
+ TypeGpg
+ } Type;
+
+ /**
+ * \c package is the package that needs to be signed
+ */
+ Package package;
+
+ /**
+ * \c repoId is the id of the software repository containing the package
+ */
+ QString repoId;
+