/usr/include/KF5/Attica/attica/provider.h is in libkf5attica-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | /*
This file is part of KDE.
Copyright (c) 2008 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ATTICA_PROVIDER_H
#define ATTICA_PROVIDER_H
#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include "achievement.h"
#include "attica_export.h"
#include "category.h"
#include "forum.h"
#include "itemjob.h"
#include "listjob.h"
#include "message.h"
#include "comment.h"
#include "distribution.h"
#include "license.h"
class QDate;
class QUrl;
namespace Attica
{
class PlatformDependent;
class PostJobStatus;
class AccountBalance;
class Activity;
class BuildServiceJobOutput;
class BuildServiceJob;
class BuildService;
class PrivateData;
class Content;
class DownloadItem;
class Distribution;
class Event;
class Folder;
class HomePageType;
class KnowledgeBaseEntry;
class License;
class Person;
class PostJob;
class Project;
class Provider;
class Publisher;
class PublisherField;
class RemoteAccount;
/**
* The Provider class represents one Open Collaboration Service provider.
* Use the ProviderManager to instantiate a Provider.
*
* Accessing functions of the Provider returns a Job class that
* takes care of accessing the server and parsing the result.
*
* Provider files are xml of the form:
<pre>
<provider>
<id>opendesktop</id>
<location>https://api.opendesktop.org/v1/</location>
<name>openDesktop.org</name>
<icon></icon>
<termsofuse>https://opendesktop.org/terms/</termsofuse>
<register>https://opendesktop.org/usermanager/new.php</register>
<services>
<person ocsversion="1.3" />
<friend ocsversion="1.3" />
<message ocsversion="1.3" />
<activity ocsversion="1.3" />
<content ocsversion="1.3" />
<fan ocsversion="1.3" />
<knowledgebase ocsversion="1.3" />
<event ocsversion="1.3" />
<comment ocsversion="1.2" />
</services>
</provider>
</pre>
* The server provides the services specified in the services section, not necessarily all of them.
*/
class ATTICA_EXPORT Provider
{
public:
Provider();
Provider(const Provider &other);
Provider &operator=(const Provider &other);
~Provider();
/**
Returns true if the provider has been set up and can be used.
*/
bool isValid() const;
/**
Test if the provider is enabled by the settings.
The application can choose to ignore this, but the user settings should be respected.
*/
bool isEnabled() const;
void setEnabled(bool enabled);
/**
A url that identifies this provider.
This should be used as identifier when referring to this provider but you don't want to use the full provider object.
*/
QUrl baseUrl() const;
/**
A name for the provider that can be displayed to the user
*/
QString name() const;
enum SortMode {
Newest,
Alphabetical,
Rating,
Downloads
};
/**
Test if the server supports the person part of the API
*/
bool hasPersonService() const;
/**
Version of the person part of the API
*/
QString personServiceVersion() const;
/**
Test if the server supports the friend part of the API
*/
bool hasFriendService() const;
/**
Version of the friend part of the API
*/
QString friendServiceVersion() const;
/**
Test if the server supports the message part of the API
*/
bool hasMessageService() const;
/**
Version of the message part of the API
*/
QString messageServiceVersion() const;
/**
Test if the server supports the achievement part of the API
*/
bool hasAchievementService() const;
/**
Version of the achievement part of the API
*/
QString achievementServiceVersion() const;
/**
Test if the server supports the activity part of the API
*/
bool hasActivityService() const;
/**
Version of the activity part of the API
*/
QString activityServiceVersion() const;
/**
Test if the server supports the content part of the API
*/
bool hasContentService() const;
/**
Version of the content part of the API
*/
QString contentServiceVersion() const;
/**
Test if the server supports the fan part of the API
*/
bool hasFanService() const;
/**
Version of the fan part of the API
*/
QString fanServiceVersion() const;
/**
Test if the server supports the forum part of the API
*/
bool hasForumService() const;
/**
Version of the forum part of the API
*/
QString forumServiceVersion() const;
/**
*
Test if the server supports the knowledgebase part of the API
*/
bool hasKnowledgebaseService() const;
/**
Version of the knowledgebase part of the API
*/
QString knowledgebaseServiceVersion() const;
/**
Test if the server supports the comments part of the API
*/
bool hasCommentService() const;
/**
Version of the comments part of the API
*/
QString commentServiceVersion() const;
/**
Test if the provider has user name/password available.
This does not yet open kwallet in case the KDE plugin is used.
@return true if the provider has login information
*/
bool hasCredentials() const;
bool hasCredentials();
/**
Load user name and password from the store.
Attica will remember the loaded values and use them from this point on.
@param user reference that returns the user name
@param password reference that returns the password
@return if credentials could be loaded
*/
bool loadCredentials(QString &user, QString &password);
/**
Sets (and remembers) user name and password for this provider.
To remove the data an empty username should be passed.
@param user the user (login) name
@param password the password
@return if credentials could be saved
*/
bool saveCredentials(const QString &user, const QString &password);
/**
Test if the server accepts the login/password.
This function does not actually set the credentials. Use saveCredentials for that purpose.
@param user the user (login) name
@param password the password
@return the job that will contain the success of the login as metadata
*/
PostJob *checkLogin(const QString &user, const QString &password);
// Person part of OCS
PostJob *registerAccount(const QString &id, const QString &password, const QString &mail, const QString &firstName, const QString &lastName);
ItemJob<Person> *requestPerson(const QString &id);
ItemJob<Person> *requestPersonSelf();
ItemJob<AccountBalance> *requestAccountBalance();
ListJob<Person> *requestPersonSearchByName(const QString &name);
ListJob<Person> *requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance = 0.0, int page = 0, int pageSize = 20);
PostJob *postLocation(qreal latitude, qreal longitude, const QString &city = QString(), const QString &country = QString());
//////////////////////////
// PrivateData part of OCS
/**
* Fetches the a given attribute from an OCS-compliant server.
* @param app The application name
* @param key The key of the attribute to fetch (optional)
* @return The job that is responsible for fetching the data
*/
ItemJob<PrivateData> *requestPrivateData(const QString &app, const QString &key = QString());
/**
* Fetches all stored private data.
* @return The job responsible for fetching data
*/
ItemJob<PrivateData> *requestPrivateData()
{
return requestPrivateData(QString(), QString());
}
/**
* Sets the value of an attribute.
* @param app The application name
* @param key The key of the attribute
* @param value The new value of the attribute
* @return The job responsible for setting data
*/
PostJob *setPrivateData(const QString &app, const QString &key, const QString &value);
// Friend part of OCS
ListJob<Person> *requestFriends(const QString &id, int page = 0, int pageSize = 20);
PostJob *postFriendInvitation(const QString &to, const QString &message);
ListJob<Person> *requestSentInvitations(int page = 0, int pageSize = 20);
ListJob<Person> *requestReceivedInvitations(int page = 0, int pageSize = 20);
PostJob *inviteFriend(const QString &to, const QString &message);
PostJob *approveFriendship(const QString &to);
PostJob *declineFriendship(const QString &to);
PostJob *cancelFriendship(const QString &to);
// Message part of OCS
ListJob<Folder> *requestFolders();
ListJob<Message> *requestMessages(const Folder &folder);
ListJob<Message> *requestMessages(const Folder &folder, Message::Status status);
ItemJob<Message> *requestMessage(const Folder &folder, const QString &id);
PostJob *postMessage(const Message &message);
// Achievement part of OCS
/**
* Get a list of achievements
* @return ListJob listing Achievements
*/
ListJob<Achievement> *requestAchievements(const QString &contentId, const QString &achievementId, const QString &userId);
/** Add a new achievement.
* @param id id of the achievement entry
* @param achievement The new Achievement added
* @return item post job for adding the new achievement
*/
ItemPostJob<Achievement> *addNewAchievement(const QString &id, const Achievement &newAchievement);
/**
* Post modifications to an Achievement on the server
* @param achievement Achievement to update on the server
*/
PutJob *editAchievement(const QString &contentId, const QString &achievementId, const Achievement &achievement);
/**
* Deletes an achievement on the server. The achievement passed as an argument doesn't need complete
* information as just the id() is used.
* @param achievement Achievement to delete on the server.
*/
DeleteJob *deleteAchievement(const QString &contentId, const QString &achievementId);
// PostJob* postAchievement(const Achievement& achievement);
PostJob *setAchievementProgress(const QString &id, const QVariant &progress, const QDateTime ×tamp);
DeleteJob *resetAchievementProgress(const QString &id);
// Activity part of OCS
ListJob<Activity> *requestActivities();
PostJob *postActivity(const QString &message);
// Project part of OCS
/**
* Get a list of build service projects
* @return ListJob listing Projects
*/
ListJob<Project> *requestProjects();
/**
* Get a Project's data
* @return ItemJob receiving data
*/
ItemJob<Project> *requestProject(const QString &id);
/**
* Post modifications to a Project on the server. The resulting project ID can be found in
* the Attica::MetaData of the finished() PostJob. You can retrieve it using
* Attica::MetaData::resultingProjectId().
* @param project Project to create on the server
*/
PostJob *createProject(const Project &project);
/**
* Deletes a project on the server. The project passed as an argument doesn't need complete
* information as just the id() is used.
* @param project Project to delete on the server.
*/
PostJob *deleteProject(const Project &project);
/**
* Post modifications to a Project on the server
* @param project Project to update on the server
*/
PostJob *editProject(const Project &project);
// Buildservice part of OCS
/**
* Get the information for a specific build service instance.
* @return ItemJob receiving data
*/
ItemJob<BuildService> *requestBuildService(const QString &id);
/**
* Get the information for a specific publisher.
* @return ItemJob receiving data
*/
ItemJob<Publisher> *requestPublisher(const QString &id);
/**
* Save the value of a single publishing field
* @return PostJob*
*/
PostJob *savePublisherField(const Project &project, const PublisherField &field);
/**
* Publish the result of a completed build job to a publisher.
* @return ItemJob receiving data
*/
PostJob *publishBuildJob(const BuildServiceJob &buildjob, const Publisher &publisher);
/**
* Get the build output for a specific build service job
* @return ItemJob receiving and containing the output data
*/
ItemJob<BuildServiceJobOutput> *requestBuildServiceJobOutput(const QString &id);
/**
* Get the information for a specific build service job, such as status and progress.
* @return ItemJob receiving and containing the data
*/
ItemJob<BuildServiceJob> *requestBuildServiceJob(const QString &id);
/**
* Get a list of build service build services
* @return ListJob listing BuildServices
*/
ListJob<BuildService> *requestBuildServices();
/**
* Get a list of publishers
* @return ListJob listing Publishers
*/
ListJob<Publisher> *requestPublishers();
/**
* Get a list of build service projects
* @return ListJob listing BuildServiceJobs
*/
ListJob<BuildServiceJob> *requestBuildServiceJobs(const Project &project);
/**
* Create a new job for a given project on a given buildservice for a given target.
* Those three items are mandatory for the job to succeed.
* @param job Buildservicejob to create on the server
*/
PostJob *createBuildServiceJob(const BuildServiceJob &job);
/**
* Cancel a job.
* Setting the ID on the build service parameter is enough for it to work.
* @param job Buildservicejob to cancel on the server, needs at least id set.
*/
PostJob *cancelBuildServiceJob(const BuildServiceJob &job);
/**
* Get a list of remote accounts, account for a build service instance
* which is stored in the OCS service in order to authenticate with the
* build service instance.
* @return ListJob listing RemoteAccounts
*/
ListJob<RemoteAccount> *requestRemoteAccounts();
/**
* Deletes a remote account stored on the OCS server.
* @param id The ID of the remote account on the OCS instance.
*/
PostJob *deleteRemoteAccount(const QString &id);
/**
* Create a new remote account, an account for a build service instance
* which is stored in the OCS service in order to authenticate with the
* build service instance.
* Type, Type ID, login and password are mandatory.
* @param account RemoteAccount to create on the server
*/
PostJob *createRemoteAccount(const RemoteAccount &account);
/**
* Edit an existing remote account.
* @param account RemoteAccount to create on the server
*/
PostJob *editRemoteAccount(const RemoteAccount &account);
/** Get a remote account by its ID.
* @param id The ID of the remote account
*/
ItemJob<RemoteAccount> *requestRemoteAccount(const QString &id);
/** Upload a tarball to the buildservice.
* @param projectId The ID of the project this source file belongs to
* @param payload A reference tothe complete file data
* @return A postjob to keep keep track of the upload
*/
Attica::PostJob *uploadTarballToBuildService(const QString &projectId, const QString &fileName, const QByteArray &payload);
// Content part of OCS
/**
* Get a list of categories (such as wallpaper)
* @return the categories of the server
*/
ListJob<Category> *requestCategories();
/**
* Get a list of licenses (such as GPL)
* @return the licenses available from the server
*/
ListJob<License> *requestLicenses();
/**
* Get a list of distributions (such as Ark, Debian)
* @return the licenses available from the server
*/
ListJob<Distribution> *requestDistributions();
/**
* Get a list of home page types (such as blog, Facebook)
* @return the licenses available from the server
*/
ListJob<HomePageType> *requestHomePageTypes();
/**
Request a list of Contents.
Note that @p categories is not optional. If left empty, no results will be returned.
An empty search string @p search returns the top n items.
@param categories categories to search in
@param search optional search string (in name/description of the content)
@param mode sorting mode
@param page request nth page in the list of results
@param pageSize requested size of pages when calculating the list of results
@return list job for the search results
*/
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.
Like @see searchContents, but only contents created by one person.
@param person the person-id that created the contents.
*/
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. More complete version.
Note that @p categories is not optional. If left empty, no results will be returned.
An empty search string @p search returns the top n items.
@param categories categories to search in
@param person the person-id that created the contents
@param distributions list of distributions to filter by, if empty no filtering by distribution is done
@param licenses list of licenses to filter by, if empty no filtering by license is done
@param search optional search string (in name/description of the content)
@param mode sorting mode
@param page request nth page in the list of results
@param pageSize requested size of pages when calculating the list of results
@return list job for the search results
*/
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);
/**
Retrieve a single content.
@param contentId the id of the content
@return job that retrieves the content object
*/
ItemJob<Content> *requestContent(const QString &contentId);
ItemJob<DownloadItem> *downloadLink(const QString &contentId, const QString &itemId = QLatin1String("1"));
/** Vote for a content item
* This version is for the old OCS API < 1.6
* @param contentId the content which this voting is for
* @param positiveVote whether the voting is positive or negative
* @return the post job for this voting
*/
Q_DECL_DEPRECATED PostJob *voteForContent(const QString &contentId, bool positiveVote);
/** Vote for a content item
* @param contentId the content which this voting is for
* @param rating - the rating, must be between 0 (bad) and 100 (good)
* @return the post job for this voting
*/
PostJob *voteForContent(const QString &contentId, uint rating);
ItemPostJob<Content> *addNewContent(const Category &category, const Content &newContent);
ItemPostJob<Content> *editContent(const Category &updatedCategory, const QString &contentId, const Content &updatedContent);
PostJob *deleteContent(const QString &contentId);
PostJob *setDownloadFile(const QString &contentId, const QString &fileName, QIODevice *payload);
PostJob *setDownloadFile(const QString &contentId, const QString &fileName, const QByteArray &payload);
PostJob *deleteDownloadFile(const QString &contentId);
/**
* Upload an image file as preview for the content
* @param contentId
* @param previewId each content can have previews with the id 1,2 or 3
* @param payload the image file
*/
PostJob *setPreviewImage(const QString &contentId, const QString &previewId, const QString &fileName, const QByteArray &image);
PostJob *deletePreviewImage(const QString &contentId, const QString &previewId);
// KnowledgeBase part of OCS
ItemJob<KnowledgeBaseEntry> *requestKnowledgeBaseEntry(const QString &id);
ListJob<KnowledgeBaseEntry> *searchKnowledgeBase(const Content &content, const QString &search, SortMode, int page, int pageSize);
// Event part of OCS
ItemJob<Event> *requestEvent(const QString &id);
ListJob<Event> *requestEvent(const QString &country, const QString &search, const QDate &startAt, SortMode mode, int page, int pageSize);
// Comment part of OCS
/** Request a list of comments for a content / forum / knowledgebase / event.
* @param comment::Type type of the comment @see Comment::Type (content / forum / knowledgebase / event)
* @param id id of the content entry where you want to get the comments is from
* @param id2 id of the content entry where you want to get the comments is from
* @param page request nth page in the list of results
* @param pageSize requested size of pages when calculating the list of results
* @return list job for the comments results
*/
ListJob<Comment> *requestComments(const Comment::Type commentType, const QString &id, const QString &id2, int page, int pageSize);
/** Add a new comment.
* @param commentType type of the comment @see CommentType (content / forum / knowledgebase / event)
* @param id id of the content entry where you want to get the comments is from
* @param id2 id of the sub content entry where you want to get the comments is from
* @param parentId the id of the parent comment if the new comment is a reply
* @param subject title of the comment
* @param message text of the comment
* @return item post job for adding the new comment
*/
ItemPostJob<Comment> *addNewComment(const Comment::Type commentType, const QString &id, const QString &id2, const QString &parentId, const QString &subject, const QString &message);
/** Vote a comment item
* @param id the comment id which this voting is for
* @param rating the rating, must be between 0 (bad) and 100 (good)
* @return the post job for this voting
*/
PostJob *voteForComment(const QString &id, uint rating);
// Fan part of OCS
PostJob *becomeFan(const QString &contentId);
ListJob<Person> *requestFans(const QString &contentId, uint page = 0, uint pageSize = 10);
// Forum part of OCS
ListJob<Forum> *requestForums(uint page = 0, uint pageSize = 10);
ListJob<Topic> *requestTopics(const QString &forum, const QString &search, const QString &description, SortMode mode, int page, int pageSize);
PostJob *postTopic(const QString &forumId, const QString &subject, const QString &content);
const QString &getRegisterAccountUrl() const;
protected:
QUrl createUrl(const QString &path);
QNetworkRequest createRequest(const QUrl &url);
// Convenience overload
QNetworkRequest createRequest(const QString &path);
ItemJob<Person> *doRequestPerson(const QUrl &url);
ItemJob<AccountBalance> *doRequestAccountBalance(const QUrl &url);
ListJob<Person> *doRequestPersonList(const QUrl &url);
ListJob<Achievement> *doRequestAchievementList(const QUrl &url);
ListJob<Activity> *doRequestActivityList(const QUrl &url);
ListJob<Folder> *doRequestFolderList(const QUrl &url);
ListJob<Forum> *doRequestForumList(const QUrl &url);
ListJob<Topic> *doRequestTopicList(const QUrl &url);
ListJob<Message> *doRequestMessageList(const QUrl &url);
private:
class Private;
QExplicitlySharedDataPointer<Private> d;
Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon = QUrl());
Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
const QString &person, const QString &friendV, const QString &message, const QString &achievements,
const QString &activity, const QString &content, const QString &fan, const QString &forum,
const QString &knowledgebase, const QString &event, const QString &comment);
// kde-SC5: merge with the constructor above (i.e. remove the above one)
Provider(PlatformDependent *internals, const QUrl &baseUrl, const QString &name, const QUrl &icon,
const QString &person, const QString &friendV, const QString &message, const QString &achievements,
const QString &activity, const QString &content, const QString &fan, const QString &forum,
const QString &knowledgebase, const QString &event, const QString &comment, const QString ®isterUrl);
friend class ProviderManager;
};
}
QDebug operator<<(QDebug s, const Attica::Provider& prov);
#endif
|