Attica 5.109.0
provider.h
1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
5 SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8*/
9
10#ifndef ATTICA_PROVIDER_H
11#define ATTICA_PROVIDER_H
12
13#include <QExplicitlySharedDataPointer>
14#include <QSharedPointer>
15#include <QString>
16#include <QStringList>
17
18#include <QUrl>
19
20#include "achievement.h"
21#include "attica_export.h"
22#include "category.h"
23#include "comment.h"
24#include "distribution.h"
25#include "forum.h"
26#include "itemjob.h"
27#include "license.h"
28#include "listjob.h"
29#include "message.h"
30
31class QDate;
32class QUrl;
33
34namespace Attica
35{
36class PlatformDependent;
37
38class PostJobStatus;
39
40class AccountBalance;
41class Activity;
42class BuildServiceJobOutput;
43class BuildServiceJob;
44class BuildService;
45class PrivateData;
46class Config;
47class Content;
48class DownloadItem;
49class Distribution;
50class Event;
51class Folder;
52class HomePageType;
53class KnowledgeBaseEntry;
54class License;
55class Person;
56class PostJob;
57class Project;
58class Provider;
59class Publisher;
60class PublisherField;
61class RemoteAccount;
62
96class ATTICA_EXPORT Provider
97{
98public:
99 Provider();
100 Provider(const Provider &other);
101 Provider &operator=(const Provider &other);
102 ~Provider();
103
107 bool isValid() const;
108
113 bool isEnabled() const;
114 void setEnabled(bool enabled);
115
133 void setAdditionalAgentInformation(const QString &additionalInformation);
142
147 QUrl baseUrl() const;
148
152 QString name() const;
153
159 QUrl icon() const;
160
161 enum SortMode {
162 Newest,
163 Alphabetical,
164 Rating,
165 Downloads,
166 };
167
171 bool hasPersonService() const;
175 QString personServiceVersion() const;
176
180 bool hasFriendService() const;
181
185 QString friendServiceVersion() const;
186
190 bool hasMessageService() const;
194 QString messageServiceVersion() const;
195
204
208 bool hasActivityService() const;
212 QString activityServiceVersion() const;
213
217 bool hasContentService() const;
221 QString contentServiceVersion() const;
222
226 bool hasFanService() const;
230 QString fanServiceVersion() const;
231
235 bool hasForumService() const;
239 QString forumServiceVersion() const;
240
250
254 bool hasCommentService() const;
258 QString commentServiceVersion() const;
259
265 bool hasCredentials() const;
266 bool hasCredentials();
267
275 bool loadCredentials(QString &user, QString &password);
276
284 bool saveCredentials(const QString &user, const QString &password);
285
293 PostJob *checkLogin(const QString &user, const QString &password);
294
300
301 // Person part of OCS
302
303 PostJob *registerAccount(const QString &id, const QString &password, const QString &mail, const QString &firstName, const QString &lastName);
304 ItemJob<Person> *requestPerson(const QString &id);
305 ItemJob<Person> *requestPersonSelf();
306 ItemJob<AccountBalance> *requestAccountBalance();
307 ListJob<Person> *requestPersonSearchByName(const QString &name);
308 ListJob<Person> *requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance = 0.0, int page = 0, int pageSize = 20);
309 PostJob *postLocation(qreal latitude, qreal longitude, const QString &city = QString(), const QString &country = QString());
310
312 // PrivateData part of OCS
313
320 ItemJob<PrivateData> *requestPrivateData(const QString &app, const QString &key = QString());
321
327 {
328 return requestPrivateData(QString(), QString());
329 }
330
338 PostJob *setPrivateData(const QString &app, const QString &key, const QString &value);
339
340 // Friend part of OCS
341
342 ListJob<Person> *requestFriends(const QString &id, int page = 0, int pageSize = 20);
343 ListJob<Person> *requestSentInvitations(int page = 0, int pageSize = 20);
344 ListJob<Person> *requestReceivedInvitations(int page = 0, int pageSize = 20);
345 PostJob *inviteFriend(const QString &to, const QString &message);
346 PostJob *approveFriendship(const QString &to);
347 PostJob *declineFriendship(const QString &to);
348 PostJob *cancelFriendship(const QString &to);
349
350 // Message part of OCS
351
352 ListJob<Folder> *requestFolders();
353 ListJob<Message> *requestMessages(const Folder &folder);
354 ListJob<Message> *requestMessages(const Folder &folder, Message::Status status);
355 ItemJob<Message> *requestMessage(const Folder &folder, const QString &id);
356 PostJob *postMessage(const Message &message);
357
358 // Achievement part of OCS
363 ListJob<Achievement> *requestAchievements(const QString &contentId, const QString &achievementId, const QString &userId);
364
370 ItemPostJob<Achievement> *addNewAchievement(const QString &id, const Achievement &newAchievement);
371
376 PutJob *editAchievement(const QString &contentId, const QString &achievementId, const Achievement &achievement);
377
383 DeleteJob *deleteAchievement(const QString &contentId, const QString &achievementId);
384
385 // PostJob* postAchievement(const Achievement& achievement);
386 PostJob *setAchievementProgress(const QString &id, const QVariant &progress, const QDateTime &timestamp);
387 DeleteJob *resetAchievementProgress(const QString &id);
388
389 // Activity part of OCS
390
391 ListJob<Activity> *requestActivities();
392 PostJob *postActivity(const QString &message);
393
394 // Project part of OCS
400
405 ItemJob<Project> *requestProject(const QString &id);
406
413 PostJob *createProject(const Project &project);
414
420 PostJob *deleteProject(const Project &project);
421
426 PostJob *editProject(const Project &project);
427
428 // Buildservice part of OCS
429
435
441
446 PostJob *savePublisherField(const Project &project, const PublisherField &field);
447
452 PostJob *publishBuildJob(const BuildServiceJob &buildjob, const Publisher &publisher);
453
459
465
471
477
483
490
497
505
510 PostJob *deleteRemoteAccount(const QString &id);
511
520
526
531
537 Attica::PostJob *uploadTarballToBuildService(const QString &projectId, const QString &fileName, const QByteArray &payload);
538
539 // Content part of OCS
540
546
552
558
564
577 searchContents(const Category::List &categories, const QString &search = QString(), SortMode mode = Rating, uint page = 0, uint pageSize = 10);
578
584 ListJob<Content> *searchContentsByPerson(const Category::List &categories,
585 const QString &person,
586 const QString &search = QString(),
587 SortMode mode = Rating,
588 uint page = 0,
589 uint pageSize = 10);
590
605 ListJob<Content> *searchContents(const Category::List &categories,
606 const QString &person,
607 const Distribution::List &distributions,
608 const License::List &licenses,
609 const QString &search = QString(),
610 SortMode sortMode = Rating,
611 uint page = 0,
612 uint pageSize = 10);
613
619 ItemJob<Content> *requestContent(const QString &contentId);
620
621 ItemJob<DownloadItem> *downloadLink(const QString &contentId, const QString &itemId = QStringLiteral("1"));
622
623#if ATTICA_ENABLE_DEPRECATED_SINCE(0, 2)
631 ATTICA_DEPRECATED_VERSION(0, 2, "Use Provider::voteForContent(const QString &, uint)")
632 PostJob *voteForContent(const QString &contentId, bool positiveVote);
633#endif
634
640 PostJob *voteForContent(const QString &contentId, uint rating);
641
642 ItemPostJob<Content> *addNewContent(const Category &category, const Content &newContent);
643 ItemPostJob<Content> *editContent(const Category &updatedCategory, const QString &contentId, const Content &updatedContent);
644 PostJob *deleteContent(const QString &contentId);
645
646 PostJob *setDownloadFile(const QString &contentId, const QString &fileName, QIODevice *payload);
647 PostJob *setDownloadFile(const QString &contentId, const QString &fileName, const QByteArray &payload);
648 PostJob *deleteDownloadFile(const QString &contentId);
649
656 PostJob *setPreviewImage(const QString &contentId, const QString &previewId, const QString &fileName, const QByteArray &image);
657 PostJob *deletePreviewImage(const QString &contentId, const QString &previewId);
658
659 // KnowledgeBase part of OCS
660
661 ItemJob<KnowledgeBaseEntry> *requestKnowledgeBaseEntry(const QString &id);
662 ListJob<KnowledgeBaseEntry> *searchKnowledgeBase(const Content &content, const QString &search, SortMode, int page, int pageSize);
663
664 // Event part of OCS
665
666 ItemJob<Event> *requestEvent(const QString &id);
667 ListJob<Event> *requestEvent(const QString &country, const QString &search, const QDate &startAt, SortMode mode, int page, int pageSize);
668
669 // Comment part of OCS
678 ListJob<Comment> *requestComments(const Comment::Type commentType, const QString &id, const QString &id2, int page, int pageSize);
679
689 ItemPostJob<Comment> *addNewComment(const Comment::Type commentType,
690 const QString &id,
691 const QString &id2,
692 const QString &parentId,
693 const QString &subject,
694 const QString &message);
695
701 PostJob *voteForComment(const QString &id, uint rating);
702
703 // Fan part of OCS
704
705 PostJob *becomeFan(const QString &contentId);
706 ListJob<Person> *requestFans(const QString &contentId, uint page = 0, uint pageSize = 10);
707
708 // Forum part of OCS
709 ListJob<Forum> *requestForums(uint page = 0, uint pageSize = 10);
710 ListJob<Topic> *requestTopics(const QString &forum, const QString &search, const QString &description, SortMode mode, int page, int pageSize);
711 PostJob *postTopic(const QString &forumId, const QString &subject, const QString &content);
712
713 const QString &getRegisterAccountUrl() const;
714
715protected:
716 QUrl createUrl(const QString &path);
717 QNetworkRequest createRequest(const QUrl &url);
718 // Convenience overload
719 QNetworkRequest createRequest(const QString &path);
720
721 ItemJob<Config> *doRequestConfig(const QUrl &url);
722 ItemJob<Person> *doRequestPerson(const QUrl &url);
723 ItemJob<AccountBalance> *doRequestAccountBalance(const QUrl &url);
724 ListJob<Person> *doRequestPersonList(const QUrl &url);
725 ListJob<Achievement> *doRequestAchievementList(const QUrl &url);
726 ListJob<Activity> *doRequestActivityList(const QUrl &url);
727 ListJob<Folder> *doRequestFolderList(const QUrl &url);
728 ListJob<Forum> *doRequestForumList(const QUrl &url);
729 ListJob<Topic> *doRequestTopicList(const QUrl &url);
730 ListJob<Message> *doRequestMessageList(const QUrl &url);
731
732private:
733 class Private;
734 QExplicitlySharedDataPointer<Private> d;
735
736 Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon = QUrl());
737 Provider(PlatformDependent *internals,
738 const QUrl &baseUrl,
739 const QString &name,
740 const QUrl &icon,
741 const QString &person,
742 const QString &friendV,
743 const QString &message,
744 const QString &achievements,
745 const QString &activity,
746 const QString &content,
747 const QString &fan,
748 const QString &forum,
749 const QString &knowledgebase,
750 const QString &event,
751 const QString &comment);
752 // kde-SC5: merge with the constructor above (i.e. remove the above one)
753 Provider(PlatformDependent *internals,
754 const QUrl &baseUrl,
755 const QString &name,
756 const QUrl &icon,
757 const QString &person,
758 const QString &friendV,
759 const QString &message,
760 const QString &achievements,
761 const QString &activity,
762 const QString &content,
763 const QString &fan,
764 const QString &forum,
765 const QString &knowledgebase,
766 const QString &event,
767 const QString &comment,
768 const QString &registerUrl);
769 // TODO KF6: merge with the constructor above (i.e. remove the above one - and actually do it this time :P )
770 Provider(PlatformDependent *internals,
771 const QUrl &baseUrl,
772 const QString &name,
773 const QUrl &icon,
774 const QString &person,
775 const QString &friendV,
776 const QString &message,
777 const QString &achievements,
778 const QString &activity,
779 const QString &content,
780 const QString &fan,
781 const QString &forum,
782 const QString &knowledgebase,
783 const QString &event,
784 const QString &comment,
785 const QString &registerUrl,
786 const QString &additionalAgentInformation);
787
788 friend class ProviderManager;
789};
790}
791
792#endif
Represents an achievement.
Definition achievement.h:28
Represents a build service job.
Definition buildservicejob.h:29
Represents a single content category.
Definition category.h:24
Represents a single content.
Definition content.h:33
Represents a delete job.
Definition deletejob.h:26
Represents a single mail folder.
Definition folder.h:25
Represents an item get job.
Definition itemjob.h:30
Represents an item post job.
Definition itemjob.h:66
Represents a list job.
Definition listjob.h:28
Represents a message.
Definition message.h:27
Represents a post job.
Definition postjob.h:30
Represents a project.
Definition project.h:30
Attica ProviderManager.
Definition providermanager.h:60
The Provider class represents one Open Collaboration Service provider.
Definition provider.h:97
PostJob * savePublisherField(const Project &project, const PublisherField &field)
Save the value of a single publishing field.
ListJob< RemoteAccount > * requestRemoteAccounts()
Get a list of remote accounts, account for a build service instance which is stored in the OCS servic...
ItemPostJob< Comment > * addNewComment(const Comment::Type commentType, const QString &id, const QString &id2, const QString &parentId, const QString &subject, const QString &message)
Add a new comment.
Attica::PostJob * uploadTarballToBuildService(const QString &projectId, const QString &fileName, const QByteArray &payload)
Upload a tarball to the buildservice.
bool hasCredentials() const
Test if the provider has user name/password available.
ListJob< HomePageType > * requestHomePageTypes()
Get a list of home page types (such as blog, Facebook)
QString achievementServiceVersion() const
Version of the achievement part of the API.
bool hasAchievementService() const
Test if the server supports the achievement part of the API.
ListJob< Content > * searchContents(const Category::List &categories, const QString &person, const Distribution::List &distributions, const License::List &licenses, const QString &search=QString(), SortMode sortMode=Rating, uint page=0, uint pageSize=10)
Request a list of Contents.
PostJob * publishBuildJob(const BuildServiceJob &buildjob, const Publisher &publisher)
Publish the result of a completed build job to a publisher.
bool hasFriendService() const
Test if the server supports the friend part of the API.
ListJob< Content > * searchContents(const Category::List &categories, const QString &search=QString(), SortMode mode=Rating, uint page=0, uint pageSize=10)
Request a list of Contents.
bool hasActivityService() const
Test if the server supports the activity part of the API.
void setAdditionalAgentInformation(const QString &additionalInformation)
Set a custom identifier for your application (sent along with the requests as the http agent header i...
QString messageServiceVersion() const
Version of the message part of the API.
QString friendServiceVersion() const
Version of the friend part of the API.
bool loadCredentials(QString &user, QString &password)
Load user name and password from the store.
bool hasCommentService() const
Test if the server supports the comments part of the API.
QString fanServiceVersion() const
Version of the fan part of the API.
bool hasKnowledgebaseService() const
Test if the server supports the knowledgebase part of the API.
bool saveCredentials(const QString &user, const QString &password)
Sets (and remembers) user name and password for this provider.
bool hasFanService() const
Test if the server supports the fan part of the API.
PutJob * editAchievement(const QString &contentId, const QString &achievementId, const Achievement &achievement)
Post modifications to an Achievement on the server.
DeleteJob * deleteAchievement(const QString &contentId, const QString &achievementId)
Deletes an achievement on the server.
bool hasContentService() const
Test if the server supports the content part of the API.
ListJob< Achievement > * requestAchievements(const QString &contentId, const QString &achievementId, const QString &userId)
Get a list of achievements.
QString forumServiceVersion() const
Version of the forum part of the API.
PostJob * checkLogin(const QString &user, const QString &password)
Test if the server accepts the login/password.
ListJob< Project > * requestProjects()
Get a list of build service projects.
ItemJob< BuildServiceJob > * requestBuildServiceJob(const QString &id)
Get the information for a specific build service job, such as status and progress.
ItemJob< BuildService > * requestBuildService(const QString &id)
Get the information for a specific build service instance.
ListJob< License > * requestLicenses()
Get a list of licenses (such as GPL)
PostJob * createRemoteAccount(const RemoteAccount &account)
Create a new remote account, an account for a build service instance which is stored in the OCS servi...
QString name() const
A name for the provider that can be displayed to the user.
bool hasForumService() const
Test if the server supports the forum part of the API.
ItemJob< BuildServiceJobOutput > * requestBuildServiceJobOutput(const QString &id)
Get the build output for a specific build service job.
QString personServiceVersion() const
Version of the person part of the API.
ItemJob< Config > * requestConfig()
Fetches server config.
bool hasMessageService() const
Test if the server supports the message part of the API.
QUrl baseUrl() const
A url that identifies this provider.
QString additionalAgentInformation() const
The custom identifier sent along with requests.
ListJob< Content > * searchContentsByPerson(const Category::List &categories, const QString &person, const QString &search=QString(), SortMode mode=Rating, uint page=0, uint pageSize=10)
Request a list of Contents.
ListJob< Distribution > * requestDistributions()
Get a list of distributions (such as Ark, Debian)
PostJob * cancelBuildServiceJob(const BuildServiceJob &job)
Cancel a job.
ListJob< Category > * requestCategories()
Get a list of categories (such as wallpaper)
PostJob * createBuildServiceJob(const BuildServiceJob &job)
Create a new job for a given project on a given buildservice for a given target.
PostJob * editProject(const Project &project)
Post modifications to a Project on the server.
PostJob * createProject(const Project &project)
Post modifications to a Project on the server.
ListJob< BuildService > * requestBuildServices()
Get a list of build service build services.
PostJob * deleteProject(const Project &project)
Deletes a project on the server.
PostJob * editRemoteAccount(const RemoteAccount &account)
Edit an existing remote account.
bool isEnabled() const
Test if the provider is enabled by the settings.
ListJob< Comment > * requestComments(const Comment::Type commentType, const QString &id, const QString &id2, int page, int pageSize)
Request a list of comments for a content / forum / knowledgebase / event.
ItemJob< Content > * requestContent(const QString &contentId)
Retrieve a single content.
PostJob * setPrivateData(const QString &app, const QString &key, const QString &value)
Sets the value of an attribute.
bool isValid() const
Returns true if the provider has been set up and can be used.
ItemJob< PrivateData > * requestPrivateData(const QString &app, const QString &key=QString())
Fetches the a given attribute from an OCS-compliant server.
ItemPostJob< Achievement > * addNewAchievement(const QString &id, const Achievement &newAchievement)
Add a new achievement.
bool hasPersonService() const
Test if the server supports the person part of the API.
QString knowledgebaseServiceVersion() const
Version of the knowledgebase part of the API.
PostJob * voteForComment(const QString &id, uint rating)
Vote a comment item.
QString contentServiceVersion() const
Version of the content part of the API.
PostJob * deleteRemoteAccount(const QString &id)
Deletes a remote account stored on the OCS server.
ListJob< BuildServiceJob > * requestBuildServiceJobs(const Project &project)
Get a list of build service projects.
ItemJob< PrivateData > * requestPrivateData()
Fetches all stored private data.
Definition provider.h:326
ItemJob< Publisher > * requestPublisher(const QString &id)
Get the information for a specific publisher.
PostJob * voteForContent(const QString &contentId, uint rating)
Vote for a content item.
PostJob * setPreviewImage(const QString &contentId, const QString &previewId, const QString &fileName, const QByteArray &image)
Upload an image file as preview for the content.
ItemJob< Project > * requestProject(const QString &id)
Get a Project's data.
ListJob< Publisher > * requestPublishers()
Get a list of publishers.
QString commentServiceVersion() const
Version of the comments part of the API.
QString activityServiceVersion() const
Version of the activity part of the API.
ItemJob< RemoteAccount > * requestRemoteAccount(const QString &id)
Get a remote account by its ID.
QUrl icon() const
An icon used to visually identify this provider.
Represents a publisher field.
Definition publisherfield.h:24
Represents a publisher.
Definition publisher.h:44
Represents a put job.
Definition putjob.h:30
Represents a remote account.
Definition remoteaccount.h:30
The Attica namespace,.
Definition activity.h:21