1 #ifndef CONFLUENCEAGENT_H
2 #define CONFLUENCEAGENT_H
6 #include <QNetworkAccessManager>
10 #include "confluence-user.h"
15 //////////////////////////////////////////////////////////////////////////
17 class ConfluenceAgent : public QObject {
23 CopyPagenameToHeading,
30 static bool available();
33 ConfluenceAgent(BranchItem *bi);
36 void setJobType(JobType jt);
37 void setBranch(BranchItem *bi);
38 void setModelID(uint id);
39 void setPageURL(const QString &u);
40 void setNewPageName(const QString &t);
41 void setUploadPagePath(const QString &fp);
42 void addUploadAttachmentPath(const QString &fp);
47 void continueJob(int nextStep = -1);
49 void unknownStepWarningFinishJob();
52 void foundUsers(QList <ConfluenceUser>);
55 void getUsers(const QString &name); //! Convenience function to get user data
57 private: QNetworkRequest createRequest(const QUrl &url);
58 private: void startGetPageSourceRequest(QUrl requestedUrl);
59 private slots: void pageSourceReceived(QNetworkReply *reply);
61 private: void startGetPageDetailsRequest();
62 private slots: void pageDetailsReceived(QNetworkReply *reply);
64 private: void startCreatePageRequest();
65 private: void startUpdatePageRequest();
66 private slots: void pageUploaded(QNetworkReply *reply);
69 private: void startGetUserInfoRequest();
70 private slots: void userInfoReceived(QNetworkReply *reply);
72 private: void startGetAttachmentsInfoRequest();
73 private slots: void attachmentsInfoReceived(QNetworkReply *reply);
75 private: void startCreateAttachmentRequest();
76 private slots: void attachmentCreated(QNetworkReply *reply);
78 private: void startUpdateAttachmentRequest();
79 private slots: void attachmentUpdated(QNetworkReply *reply);
82 void attachmentsSuccess();
83 void attachmentsFailure();
86 void attachmentsUploadSuccess();
87 void attachmentsUploadFailure();
89 private: bool wasRequestSuccessful(
91 const QString &requestDesc,
92 const QByteArray &fullReply);
95 private slots: void timeout();
98 void sslErrors(QNetworkReply *, const QList<QSslError> &errors);
106 bool abortJob; // Flag to abort during initialization of job
109 QNetworkAccessManager *networkManager;
111 QJsonObject attachmentObj;
113 // Settings: Credentials to access Confluence
115 QString personalAccessToken;
119 // Settings: Where to find Confluggence
123 // Backreferences to take action in calling model
131 QString uploadPagePath;
134 // Page details received from Confluence
138 // Child agent for attachments
139 ConfluenceAgent *attachmentsAgent;
141 // Attachments found in page
142 QStringList attachmentsTitles;
143 QStringList attachmentsIds;
145 // Current attachments queued for upload
146 QStringList uploadAttachmentPaths;
147 int currentUploadAttachmentIndex;
148 QString currentAttachmentPath; // set with basename(..) from path
149 QString currentAttachmentTitle; // set with basename(..) from path
150 QString currentAttachmentId; // copied from attachmentsIds
152 // User info received from Confluence
153 QList <ConfluenceUser> userList;