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  ListJob<Person> *requestSentInvitations(int page = 0, int pageSize = 20);
336  ListJob<Person> *requestReceivedInvitations(int page = 0, int pageSize = 20);
337  PostJob *inviteFriend(const QString &to, const QString &message);
338  PostJob *approveFriendship(const QString &to);
339  PostJob *declineFriendship(const QString &to);
340  PostJob *cancelFriendship(const QString &to);
341 
342  // Message part of OCS
343 
344  ListJob<Folder> *requestFolders();
345  ListJob<Message> *requestMessages(const Folder &folder);
346  ListJob<Message> *requestMessages(const Folder &folder, Message::Status status);
347  ItemJob<Message> *requestMessage(const Folder &folder, const QString &id);
348  PostJob *postMessage(const Message &message);
349 
350  // Achievement part of OCS
355  ListJob<Achievement> *requestAchievements(const QString &contentId, const QString &achievementId, const QString &userId);
356 
362  ItemPostJob<Achievement> *addNewAchievement(const QString &id, const Achievement &newAchievement);
363 
368  PutJob *editAchievement(const QString &contentId, const QString &achievementId, const Achievement &achievement);
369 
375  DeleteJob *deleteAchievement(const QString &contentId, const QString &achievementId);
376 
377  // PostJob* postAchievement(const Achievement& achievement);
378  PostJob *setAchievementProgress(const QString &id, const QVariant &progress, const QDateTime &timestamp);
379  DeleteJob *resetAchievementProgress(const QString &id);
380 
381  // Activity part of OCS
382 
383  ListJob<Activity> *requestActivities();
384  PostJob *postActivity(const QString &message);
385 
386  // Project part of OCS
391  ListJob<Project> *requestProjects();
392 
397  ItemJob<Project> *requestProject(const QString &id);
398 
405  PostJob *createProject(const Project &project);
406 
412  PostJob *deleteProject(const Project &project);
413 
418  PostJob *editProject(const Project &project);
419 
420  // Buildservice part of OCS
421 
426  ItemJob<BuildService> *requestBuildService(const QString &id);
427 
432  ItemJob<Publisher> *requestPublisher(const QString &id);
433 
438  PostJob *savePublisherField(const Project &project, const PublisherField &field);
439 
444  PostJob *publishBuildJob(const BuildServiceJob &buildjob, const Publisher &publisher);
445 
450  ItemJob<BuildServiceJobOutput> *requestBuildServiceJobOutput(const QString &id);
451 
456  ItemJob<BuildServiceJob> *requestBuildServiceJob(const QString &id);
457 
462  ListJob<BuildService> *requestBuildServices();
463 
468  ListJob<Publisher> *requestPublishers();
469 
474  ListJob<BuildServiceJob> *requestBuildServiceJobs(const Project &project);
475 
481  PostJob *createBuildServiceJob(const BuildServiceJob &job);
482 
488  PostJob *cancelBuildServiceJob(const BuildServiceJob &job);
489 
496  ListJob<RemoteAccount> *requestRemoteAccounts();
497 
502  PostJob *deleteRemoteAccount(const QString &id);
503 
511  PostJob *createRemoteAccount(const RemoteAccount &account);
512 
517  PostJob *editRemoteAccount(const RemoteAccount &account);
518 
522  ItemJob<RemoteAccount> *requestRemoteAccount(const QString &id);
523 
529  Attica::PostJob *uploadTarballToBuildService(const QString &projectId, const QString &fileName, const QByteArray &payload);
530 
531  // Content part of OCS
532 
537  ListJob<Category> *requestCategories();
538 
543  ListJob<License> *requestLicenses();
544 
549  ListJob<Distribution> *requestDistributions();
550 
555  ListJob<HomePageType> *requestHomePageTypes();
556 
568  ListJob<Content> *searchContents(const Category::List &categories, const QString &search = QString(), SortMode mode = Rating, uint page = 0, uint pageSize = 10);
569 
575  ListJob<Content> *searchContentsByPerson(const Category::List &categories, const QString &person, const QString &search = QString(), SortMode mode = Rating, uint page = 0, uint pageSize = 10);
576 
591  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);
592 
598  ItemJob<Content> *requestContent(const QString &contentId);
599 
600  ItemJob<DownloadItem> *downloadLink(const QString &contentId, const QString &itemId = QStringLiteral("1"));
601 
602 #if ATTICA_ENABLE_DEPRECATED_SINCE(0, 2)
603 
610  ATTICA_DEPRECATED_VERSION(0, 2, "Use Provider::voteForContent(const QString &, uint)")
611  PostJob *voteForContent(const QString &contentId, bool positiveVote);
612 #endif
613 
619  PostJob *voteForContent(const QString &contentId, uint rating);
620 
621  ItemPostJob<Content> *addNewContent(const Category &category, const Content &newContent);
622  ItemPostJob<Content> *editContent(const Category &updatedCategory, const QString &contentId, const Content &updatedContent);
623  PostJob *deleteContent(const QString &contentId);
624 
625  PostJob *setDownloadFile(const QString &contentId, const QString &fileName, QIODevice *payload);
626  PostJob *setDownloadFile(const QString &contentId, const QString &fileName, const QByteArray &payload);
627  PostJob *deleteDownloadFile(const QString &contentId);
628 
635  PostJob *setPreviewImage(const QString &contentId, const QString &previewId, const QString &fileName, const QByteArray &image);
636  PostJob *deletePreviewImage(const QString &contentId, const QString &previewId);
637 
638  // KnowledgeBase part of OCS
639 
640  ItemJob<KnowledgeBaseEntry> *requestKnowledgeBaseEntry(const QString &id);
641  ListJob<KnowledgeBaseEntry> *searchKnowledgeBase(const Content &content, const QString &search, SortMode, int page, int pageSize);
642 
643  // Event part of OCS
644 
645  ItemJob<Event> *requestEvent(const QString &id);
646  ListJob<Event> *requestEvent(const QString &country, const QString &search, const QDate &startAt, SortMode mode, int page, int pageSize);
647 
648  // Comment part of OCS
657  ListJob<Comment> *requestComments(const Comment::Type commentType, const QString &id, const QString &id2, int page, int pageSize);
658 
668  ItemPostJob<Comment> *addNewComment(const Comment::Type commentType, const QString &id, const QString &id2, const QString &parentId, const QString &subject, const QString &message);
669 
675  PostJob *voteForComment(const QString &id, uint rating);
676 
677  // Fan part of OCS
678 
679  PostJob *becomeFan(const QString &contentId);
680  ListJob<Person> *requestFans(const QString &contentId, uint page = 0, uint pageSize = 10);
681 
682  // Forum part of OCS
683  ListJob<Forum> *requestForums(uint page = 0, uint pageSize = 10);
684  ListJob<Topic> *requestTopics(const QString &forum, const QString &search, const QString &description, SortMode mode, int page, int pageSize);
685  PostJob *postTopic(const QString &forumId, const QString &subject, const QString &content);
686 
687  const QString &getRegisterAccountUrl() const;
688 
689 protected:
690  QUrl createUrl(const QString &path);
691  QNetworkRequest createRequest(const QUrl &url);
692  // Convenience overload
693  QNetworkRequest createRequest(const QString &path);
694 
695  ItemJob<Config> *doRequestConfig(const QUrl &url);
696  ItemJob<Person> *doRequestPerson(const QUrl &url);
697  ItemJob<AccountBalance> *doRequestAccountBalance(const QUrl &url);
698  ListJob<Person> *doRequestPersonList(const QUrl &url);
699  ListJob<Achievement> *doRequestAchievementList(const QUrl &url);
700  ListJob<Activity> *doRequestActivityList(const QUrl &url);
701  ListJob<Folder> *doRequestFolderList(const QUrl &url);
702  ListJob<Forum> *doRequestForumList(const QUrl &url);
703  ListJob<Topic> *doRequestTopicList(const QUrl &url);
704  ListJob<Message> *doRequestMessageList(const QUrl &url);
705 
706 private:
707  class Private;
709 
710  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon = QUrl());
711  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
712  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
713  const QString &activity, const QString &content, const QString &fan, const QString &forum,
714  const QString &knowledgebase, const QString &event, const QString &comment);
715  // kde-SC5: merge with the constructor above (i.e. remove the above one)
716  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
717  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
718  const QString &activity, const QString &content, const QString &fan, const QString &forum,
719  const QString &knowledgebase, const QString &event, const QString &comment, const QString &registerUrl);
720  // TODO KF6: merge with the constructor above (i.e. remove the above one - and actually do it this time :P )
721  Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
722  const QString &person, const QString &friendV, const QString &message, const QString &achievements,
723  const QString &activity, const QString &content, const QString &fan, const QString &forum,
724  const QString &knowledgebase, const QString &event, const QString &comment, const QString &registerUrl,
725  const QString &additionalAgentInformation);
726 
727  friend class ProviderManager;
728 };
729 }
730 
731 QDebug operator<<(QDebug s, const Attica::Provider& prov);
732 
733 #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-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:03:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.