Attica

provider.h
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2008 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2011 Laszlo Papp <[email protected]>
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 "forum.h"
24 #include "itemjob.h"
25 #include "listjob.h"
26 #include "message.h"
27 #include "comment.h"
28 #include "distribution.h"
29 #include "license.h"
30 
31 class QDate;
32 class QUrl;
33 
34 namespace Attica
35 {
36 
37 class PlatformDependent;
38 
39 class PostJobStatus;
40 
41 class AccountBalance;
42 class Activity;
43 class BuildServiceJobOutput;
44 class BuildServiceJob;
45 class BuildService;
46 class PrivateData;
47 class Config;
48 class Content;
49 class DownloadItem;
50 class Distribution;
51 class Event;
52 class Folder;
53 class HomePageType;
54 class KnowledgeBaseEntry;
55 class License;
56 class Person;
57 class PostJob;
58 class Project;
59 class Provider;
60 class Publisher;
61 class PublisherField;
62 class RemoteAccount;
63 
95 class ATTICA_EXPORT Provider
96 {
97 public:
98  Provider();
99  Provider(const Provider &other);
100  Provider &operator=(const Provider &other);
101  ~Provider();
102 
106  bool isValid() const;
107 
112  bool isEnabled() const;
113  void setEnabled(bool enabled);
114 
132  void setAdditionalAgentInformation(const QString& additionalInformation);
140  QString additionalAgentInformation() const;
141 
146  QUrl baseUrl() const;
147 
151  QString name() const;
152 
153  enum SortMode {
154  Newest,
155  Alphabetical,
156  Rating,
157  Downloads
158  };
159 
163  bool hasPersonService() const;
167  QString personServiceVersion() const;
168 
172  bool hasFriendService() const;
173 
177  QString friendServiceVersion() const;
178 
182  bool hasMessageService() const;
186  QString messageServiceVersion() const;
187 
191  bool hasAchievementService() const;
195  QString achievementServiceVersion() const;
196 
200  bool hasActivityService() const;
204  QString activityServiceVersion() const;
205 
209  bool hasContentService() const;
213  QString contentServiceVersion() const;
214 
218  bool hasFanService() const;
222  QString fanServiceVersion() const;
223 
227  bool hasForumService() const;
231  QString forumServiceVersion() const;
232 
237  bool hasKnowledgebaseService() const;
241  QString knowledgebaseServiceVersion() const;
242 
246  bool hasCommentService() const;
250  QString commentServiceVersion() const;
251 
257  bool hasCredentials() const;
258  bool hasCredentials();
259 
267  bool loadCredentials(QString &user, QString &password);
268 
276  bool saveCredentials(const QString &user, const QString &password);
277 
285  PostJob *checkLogin(const QString &user, const QString &password);
286 
291  ItemJob<Config> *requestConfig();
292 
293  // Person part of OCS
294 
295  PostJob *registerAccount(const QString &id, const QString &password, const QString &mail, const QString &firstName, const QString &lastName);
296  ItemJob<Person> *requestPerson(const QString &id);
297  ItemJob<Person> *requestPersonSelf();
298  ItemJob<AccountBalance> *requestAccountBalance();
299  ListJob<Person> *requestPersonSearchByName(const QString &name);
300  ListJob<Person> *requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance = 0.0, int page = 0, int pageSize = 20);
301  PostJob *postLocation(qreal latitude, qreal longitude, const QString &city = QString(), const QString &country = QString());
302 
304  // PrivateData part of OCS
305 
312  ItemJob<PrivateData> *requestPrivateData(const QString &app, const QString &key = QString());
313 
318  ItemJob<PrivateData> *requestPrivateData()
319  {
320  return requestPrivateData(QString(), QString());
321  }
322 
330  PostJob *setPrivateData(const QString &app, const QString &key, const QString &value);
331 
332  // Friend part of OCS
333 
334  ListJob<Person> *requestFriends(const QString &id, int page = 0, int pageSize = 20);
335  PostJob *postFriendInvitation(const QString &to, const QString &message);
336  ListJob<Person> *requestSentInvitations(int page = 0, int pageSize = 20);
337  ListJob<Person> *requestReceivedInvitations(int page = 0, int pageSize = 20);
338  PostJob *inviteFriend(const QString &to, const QString &message);
339  PostJob *approveFriendship(const QString &to);
340  PostJob *declineFriendship(const QString &to);
341  PostJob *cancelFriendship(const QString &to);
342 
343  // Message part of OCS
344 
345  ListJob<Folder> *requestFolders();
346  ListJob<Message> *requestMessages(const Folder &folder);
347  ListJob<Message> *requestMessages(const Folder &folder, Message::Status status);
348  ItemJob<Message> *requestMessage(const Folder &folder, const QString &id);
349  PostJob *postMessage(const Message &message);
350 
351  // Achievement part of OCS
356  ListJob<Achievement> *requestAchievements(const QString &contentId, const QString &achievementId, const QString &userId);
357 
363  ItemPostJob<Achievement> *addNewAchievement(const QString &id, const Achievement &newAchievement);
364 
369  PutJob *editAchievement(const QString &contentId, const QString &achievementId, const Achievement &achievement);
370 
376  DeleteJob *deleteAchievement(const QString &contentId, const QString &achievementId);
377 
378  // PostJob* postAchievement(const Achievement& achievement);
379  PostJob *setAchievementProgress(const QString &id, const QVariant &progress, const QDateTime &timestamp);
380  DeleteJob *resetAchievementProgress(const QString &id);
381 
382  // Activity part of OCS
383 
384  ListJob<Activity> *requestActivities();
385  PostJob *postActivity(const QString &message);
386 
387  // Project part of OCS
392  ListJob<Project> *requestProjects();
393 
398  ItemJob<Project> *requestProject(const QString &id);
399 
406  PostJob *createProject(const Project &project);
407 
413  PostJob *deleteProject(const Project &project);
414 
419  PostJob *editProject(const Project &project);
420 
421  // Buildservice part of OCS
422 
427  ItemJob<BuildService> *requestBuildService(const QString &id);
428 
433  ItemJob<Publisher> *requestPublisher(const QString &id);
434 
439  PostJob *savePublisherField(const Project &project, const PublisherField &field);
440 
445  PostJob *publishBuildJob(const BuildServiceJob &buildjob, const Publisher &publisher);
446 
451  ItemJob<BuildServiceJobOutput> *requestBuildServiceJobOutput(const QString &id);
452 
457  ItemJob<BuildServiceJob> *requestBuildServiceJob(const QString &id);
458 
463  ListJob<BuildService> *requestBuildServices();
464 
469  ListJob<Publisher> *requestPublishers();
470 
475  ListJob<BuildServiceJob> *requestBuildServiceJobs(const Project &project);
476 
482  PostJob *createBuildServiceJob(const BuildServiceJob &job);
483 
489  PostJob *cancelBuildServiceJob(const BuildServiceJob &job);
490 
497  ListJob<RemoteAccount> *requestRemoteAccounts();
498 
503  PostJob *deleteRemoteAccount(const QString &id);
504 
512  PostJob *createRemoteAccount(const RemoteAccount &account);
513 
518  PostJob *editRemoteAccount(const RemoteAccount &account);
519 
523  ItemJob<RemoteAccount> *requestRemoteAccount(const QString &id);
524 
530  Attica::PostJob *uploadTarballToBuildService(const QString &projectId, const QString &fileName, const QByteArray &payload);
531 
532  // Content part of OCS
533 
538  ListJob<Category> *requestCategories();
539 
544  ListJob<License> *requestLicenses();
545 
550  ListJob<Distribution> *requestDistributions();
551 
556  ListJob<HomePageType> *requestHomePageTypes();
557 
569  ListJob<Content> *searchContents(const Category::List &categories, const QString &search = QString(), SortMode mode = Rating, uint page = 0, uint pageSize = 10);
570 
576  ListJob<Content> *searchContentsByPerson(const Category::List &categories, const QString &person, const QString &search = QString(), SortMode mode = Rating, uint page = 0, uint pageSize = 10);
577 
592  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);
593 
599  ItemJob<Content> *requestContent(const QString &contentId);
600 
601  ItemJob<DownloadItem> *downloadLink(const QString &contentId, const QString &itemId = QStringLiteral("1"));
602 
603 #if ATTICA_ENABLE_DEPRECATED_SINCE(0, 2)
604 
611  ATTICA_DEPRECATED_VERSION(0, 2, "Use Provider::voteForContent(const QString &, uint)")
612  PostJob *voteForContent(const QString &contentId, bool positiveVote);
613 #endif
614 
620  PostJob *voteForContent(const QString &contentId, uint rating);
621 
622  ItemPostJob<Content> *addNewContent(const Category &category, const Content &newContent);
623  ItemPostJob<Content> *editContent(const Category &updatedCategory, const QString &contentId, const Content &updatedContent);
624  PostJob *deleteContent(const QString &contentId);
625 
626  PostJob *setDownloadFile(const QString &contentId, const QString &fileName, QIODevice *payload);
627  PostJob *setDownloadFile(const QString &contentId, const QString &fileName, const QByteArray &payload);
628  PostJob *deleteDownloadFile(const QString &contentId);
629 
636  PostJob *setPreviewImage(const QString &contentId, const QString &previewId, const QString &fileName, const QByteArray &image);
637  PostJob *deletePreviewImage(const QString &contentId, const QString &previewId);
638 
639  // KnowledgeBase part of OCS
640 
641  ItemJob<KnowledgeBaseEntry> *requestKnowledgeBaseEntry(const QString &id);
642  ListJob<KnowledgeBaseEntry> *searchKnowledgeBase(const Content &content, const QString &search, SortMode, int page, int pageSize);
643 
644  // Event part of OCS
645 
646  ItemJob<Event> *requestEvent(const QString &id);
647  ListJob<Event> *requestEvent(const QString &country, const QString &search, const QDate &startAt, SortMode mode, int page, int pageSize);
648 
649  // Comment part of OCS
658  ListJob<Comment> *requestComments(const Comment::Type commentType, const QString &id, const QString &id2, int page, int pageSize);
659 
669  ItemPostJob<Comment> *addNewComment(const Comment::Type commentType, const QString &id, const QString &id2, const QString &parentId, const QString &subject, const QString &message);
670 
676  PostJob *voteForComment(const QString &id, uint rating);
677 
678  // Fan part of OCS
679 
680  PostJob *becomeFan(const QString &contentId);
681  ListJob<Person> *requestFans(const QString &contentId, uint page = 0, uint pageSize = 10);
682 
683  // Forum part of OCS
684  ListJob<Forum> *requestForums(uint page = 0, uint pageSize = 10);
685  ListJob<Topic> *requestTopics(const QString &forum, const QString &search, const QString &description, SortMode mode, int page, int pageSize);
686  PostJob *postTopic(const QString &forumId, const QString &subject, const QString &content);
687 
688  const QString &getRegisterAccountUrl() const;
689 
690 protected:
691  QUrl createUrl(const QString &path);
692  QNetworkRequest createRequest(const QUrl &url);
693  // Convenience overload
694  QNetworkRequest createRequest(const QString &path);
695 
696  ItemJob<Config> *doRequestConfig(const QUrl &url);
697  ItemJob<Person> *doRequestPerson(const QUrl &url);
698  ItemJob<AccountBalance> *doRequestAccountBalance(const QUrl &url);
699  ListJob<Person> *doRequestPersonList(const QUrl &url);
700  ListJob<Achievement> *doRequestAchievementList(const QUrl &url);
701  ListJob<Activity> *doRequestActivityList(const QUrl &url);
702  ListJob<Folder> *doRequestFolderList(const QUrl &url);
703  ListJob<Forum> *doRequestForumList(const QUrl &url);
704  ListJob<Topic> *doRequestTopicList(const QUrl &url);
705  ListJob<Message> *doRequestMessageList(const QUrl &url);
706 
707 private:
708  class Private;
710 
711  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon = QUrl());
712  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
713  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
714  const QString &activity, const QString &content, const QString &fan, const QString &forum,
715  const QString &knowledgebase, const QString &event, const QString &comment);
716  // kde-SC5: merge with the constructor above (i.e. remove the above one)
717  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
718  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
719  const QString &activity, const QString &content, const QString &fan, const QString &forum,
720  const QString &knowledgebase, const QString &event, const QString &comment, const QString &registerUrl);
721  // TODO KF6: merge with the constructor above (i.e. remove the above one - and actually do it this time :P )
722  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
723  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
724  const QString &activity, const QString &content, const QString &fan, const QString &forum,
725  const QString &knowledgebase, const QString &event, const QString &comment, const QString &registerUrl,
726  const QString &additionalAgentInformation);
727 
728  friend class ProviderManager;
729 };
730 }
731 
732 QDebug operator<<(QDebug s, const Attica::Provider& prov);
733 
734 #endif
Represents a single content.
Definition: content.h:31
Rating
Represents a single content category.
Definition: category.h:22
License
Publisher
Attica ProviderManager.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
The Provider class represents one Open Collaboration Service provider.
Definition: provider.h:95
ItemJob< PrivateData > * requestPrivateData()
Fetches all stored private data.
Definition: provider.h:318
Represents a single mail folder.
Definition: folder.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 23:01:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.