Added extra call to ask for applications details
[meego-garage:garage-client-services.git] / src / packagekitapplication.cpp
1 #include "packagekitapplication.h"
2 #include "image.h"
3 #include "packagekitapplicationdetailsjob.h"
4 #include "category.h"
5
6 using namespace MeeGoGarage;
7
8 PackageKitApplication::PackageKitApplication (Catalog* cat, Category *category, QSharedPointer<PackageKit::Package> p, QObject *parent) :
9     Application(cat, category, parent)
10 {
11     setPackage(p);
12
13     setId(package()->id());
14     setName(package()->name());
15     setPackageName(package()->name());
16     setVersion(package()->version());
17     setDescription(package()->summary());
18     setLongDescription(package()->summary());
19     setStatus(toStatus(package()->info(),status()));
20     if (!package()->iconPath().isEmpty()) {
21         m_applicationIcon[Image::SmallIconImage] = Image::NewImage(this, package()->iconPath(), Image::SmallIconImage);
22         m_applicationIcon[Image::MediumIconImage] = m_applicationIcon[Image::SmallIconImage];
23         m_applicationIcon[Image::LargeIconImage] = m_applicationIcon[Image::SmallIconImage];
24     }
25
26     onRequestDetailsOver();
27 }
28
29 void PackageKitApplication::requestDetails()
30 {
31     if (!package()->hasDetails()) {
32         PackageKitApplicationDetailsJob * job = new PackageKitApplicationDetailsJob(package());
33         if (job) {
34             connect(job, SIGNAL(jobOver()), SLOT(onRequestDetailsOver()));
35             job->start();
36         }
37     }
38 }
39
40 void PackageKitApplication::onRequestDetailsOver()
41 {
42     if (package()->hasDetails()) {
43         PackageKit::Package::Details * details = package()->details();
44
45         gcsDebug() << "long description" << details->description();
46         gcsDebug() << "license" << details->license();
47         gcsDebug() << "size" << details->size();
48         gcsDebug() << "support url" << details->url();
49         gcsDebug() << "group" << details->group();
50
51         m_licenseName = details->license();
52         setLongDescription(details->description());
53         m_size = details->size();
54         m_supportURL = details->url();
55         m_category = catalog()->findCategoryById(QString::number(details->group()));
56         if (m_category) {
57             m_categoryName = m_category->name();
58         }
59
60         emit detailsUpdated();
61     }
62 }
63
64 bool PackageKitApplication::setUserRating(int /*rating*/)
65 {
66     return false;
67 }
68
69 ReviewListJob *PackageKitApplication::requestReviews(int /*pageNumber*/, int /*itemsPerPage*/)
70 {
71     return 0;
72 }
73
74 bool PackageKitApplication::addReview(const Review & /*review*/)
75 {
76     return false;
77 }
78
79 bool PackageKitApplication::canRate() const
80 {
81     return false;
82 }
83
84 bool PackageKitApplication::canReview() const
85 {
86     return false;
87 }