More fixes regarding HAVE_OLD_PACKAGEKIT
[meego-garage:garage-client-services.git] / src / application.h
1 #ifndef APPLICATION_H
2 #define APPLICATION_H
3
4 #include <QObject>
5 #include <QUuid>
6 #include <QPackageKit>
7 #include "baseobject.h"
8
9 #include <stdint.h>
10
11 #ifdef HAVE_OLD_PACKAGEKIT
12
13 namespace PackageKit {
14     namespace Enum {
15         typedef PackageKit::Client::ErrorType Error;
16         //typedef PackageKit::Package::State State;
17         typedef enum {
18                 StateInstalled,
19                 StateAvailable,
20                 StateLow,
21                 StateEnhancement,
22                 StateNormal,
23                 StateBugfix,
24                 StateImportant,
25                 StateSecurity,
26                 StateBlocked,
27                 StateDownloading,
28                 StateUpdating,
29                 StateInstalling,
30                 StateRemoving,
31                 StateCleanup,
32                 StateObsoleting,
33                 StateCollectionInstalled,
34                 StateCollectionAvailable,
35                 StateFinished,
36                 UnknownState
37         } State;
38     };
39 }
40
41 #define InfoInstalled StateInstalled
42 #define InfoCollectionInstalled StateCollectionInstalled
43 #define InfoAvailable StateAvailable
44 #define InfoCollectionAvailable StateCollectionAvailable
45 #define InfoLow StateLow
46 #define InfoEnhancement StateEnhancement
47 #define InfoNormal StateNormal
48 #define InfoBugfix StateBugfix
49 #define InfoImportant StateImportant
50 #define InfoSecurity StateSecurity
51 #define InfoBlocked StateBlocked
52 #define InfoDownloading StateDownloading
53 #define InfoUpdating StateUpdating
54 #define InfoInstalling StateInstalling
55 #define InfoRemoving StateRemoving
56 #define InfoCleanup StateCleanup
57 #define InfoObsoleting StateObsoleting
58 #define InfoFinished StateFinished
59 #define UnknownInfo UnknownState
60
61 #endif
62
63 namespace MeeGoGarage {
64
65 enum ApplicationListSortType {SortByName, SortByRating};
66
67 class Image;
68
69 class Application : public QObject, BaseObject
70 {
71 Q_OBJECT
72 public:
73     enum IconType {SmallIcon, MediumIcon, LargeIcon};
74     
75     const QString &getName () const;
76     const QString &getPackageName () const;
77     const Image* getIconImage (IconType type) const;
78     const QUuid&    getId() const;
79     const QString&  getCategoryName() const;
80     const QString&  getDescription() const;
81     const QString&  getLongDescription() const;
82     const QList<Image *> getScreenshotList() const;
83     const QString& getReleaseNotes() const;
84     const QString& getPublisher() const;
85     const QString& getPublisherURL() const;
86     const QString& getSupportURL() const;
87     const QDate& getPublishDate() const;
88     const QString& getVersion() const;
89     uint64_t getSize() const;
90     const QString& getEULA() const;
91
92
93 #ifdef HAVE_OLD_PACKAGEKIT
94     PackageKit::Package *getPackage() const;
95 #else
96     QSharedPointer<PackageKit::Package> getPackage() const;
97 #endif
98     PackageKit::Transaction * getTransaction() const;
99     void requestResolvePackage();
100     void requestInstallPackage();
101     void requestRemovePackage();
102     void requestUpdatePackage();
103
104     static QList<Application*> sortApplications(QList<Application*>, MeeGoGarage::ApplicationListSortType);
105     void dumpApplication();
106
107     friend class Catalog;
108     friend class Category;
109 signals:
110 #ifdef HAVE_OLD_PACKAGEKIT
111     void errorCode(PackageKit::Client::ErrorType, const QString&);
112 #else
113     void errorCode(PackageKit::Enum::Error, const QString&);
114 #endif
115     void changed();
116 #ifdef HAVE_OLD_PACKAGEKIT
117     void package(PackageKit::Package *);
118 #else
119     void package(QSharedPointer<PackageKit::Package>);
120 #endif
121     void packageResolved();
122
123 public slots:
124     
125 private slots:
126 #ifdef HAVE_OLD_PACKAGEKIT
127     void errorCodeHandler(PackageKit::Client::ErrorType, const QString&);
128 #else
129     void errorCodeHandler(PackageKit::Enum::Error, const QString&);
130 #endif
131     void changedHandler();
132 #ifdef HAVE_OLD_PACKAGEKIT
133     void packageHandler(PackageKit::Package * package);
134 #else
135     void packageHandler(QSharedPointer<PackageKit::Package>);
136 #endif
137
138 private:
139     QUuid applicationID;
140     QString applicationName;
141     QString packageName;
142     QString categoryName;
143     QString description;
144     QString longDescription;
145     QList<Image *> screenshotList;
146     QString releaseNotes;
147     QString publisher;
148     QString publisherURL;
149     QString supportURL;
150     QDate publishDate;
151     QString version;
152     uint64_t size;
153     QString eula;
154
155     Image *applicationIcon[3];
156
157 #ifdef HAVE_OLD_PACKAGEKIT
158     PackageKit::Package *p;
159 #else
160     QSharedPointer<PackageKit::Package> p;
161 #endif
162     PackageKit::Transaction *transaction;
163
164     //Put following for friend class to use
165     //Application (QObject *parent = 0);
166     Application (xmlNodePtr node, QObject *parent = 0);
167
168     //Set properties
169     void setID (const QUuid& id);
170     void setName (const QString& name);
171     void setPackageName (const QString& packageName);
172     void setCategoryName (const QString& categoryName);
173     void setDescription (const QString& description);
174     void setLongDescription (const QString& longdesc);
175
176     //Sorting functions
177     static bool applicationNameLessThan(Application* &a1, Application* &a2);
178 };
179 } //MeeGoGarage namespace
180
181 #endif // APPLICATION_H