akabeibackend.h 2.05 KB
Newer Older
Dario Freddi's avatar
Dario Freddi committed
1 2 3 4 5 6 7 8 9 10
/* This file is part of the Chakra project

   Copyright (C) 2010 Dario Freddi <drf@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.
*/

11 12 13
#ifndef AKABEIBACKEND_H
#define AKABEIBACKEND_H

14 15
#include <QtCore/QObject>

16 17
#include "akabeicore_global.h"

Dario Freddi's avatar
Dario Freddi committed
18
class QUuid;
19
namespace Akabei {
20
class Delta;
21
class OperationRunner;
22 23
class Group;
class Package;
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
class Database;

class BackendPrivate;
class AKABEICORESHARED_EXPORT Backend : public QObject
{
    Q_OBJECT
    Q_DISABLE_COPY(Backend)
    Q_DECLARE_PRIVATE(Backend)
    public:
        enum Status {
            StatusBare = 0,
            StatusInitializing = 1,
            StatusWaitingForLock = 2,
            StatusReady = 3,
            StatusOnTransaction = 4,
            StatusBroken = 5
        };

        static Backend *instance();
        virtual ~Backend();

        Status status() const;

        Database *localDatabase();
        QList<Database*> databases();

50 51 52 53 54 55 56 57 58
        QUuid packages();
        QUuid searchPackages(const QString &token);

        QUuid groups();
        QUuid searchGroups(const QString &token);

        QUuid queryPackages(const QString &sql);
        QUuid queryGroups(const QString &sql);

59 60
        OperationRunner *operationRunner();

61
        Package *loadPackageFromFile(const QString &path);
62
        Delta *loadDeltaFromFile(const QString &path);
63

Dario Freddi's avatar
Dario Freddi committed
64 65 66
    public Q_SLOTS:
        void initialize();

67 68
    Q_SIGNALS:
        void statusChanged(Akabei::Backend::Status status);
69 70
        void queryPackagesCompleted(const QUuid &id, const QList<Akabei::Package*> &result);
        void queryGroupCompleted(const QUuid &id, const QList<Akabei::Group*> &result);
71 72 73 74 75 76 77

    private:
        Backend(QObject* parent = 0);

        BackendPrivate * const d_ptr;

        Q_PRIVATE_SLOT(d_func(), void __k__initializationFinished())
78 79

        friend class DatabasePrivate;
80 81
};

82 83
}

84
#endif // AKABEIBACKEND_H