Menu

[efa3d9]: / src / confluence-agent.h  Maximize  Restore  History

Download this file

174 lines (133 with data), 4.5 kB

  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
#ifndef CONFLUENCEAGENT_H
#define CONFLUENCEAGENT_H
#include <QHash>
#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QObject>
#include <QTimer>
#include "confluence-user.h"
class BranchItem;
class VymModel;
//////////////////////////////////////////////////////////////////////////
class ConfluenceAgent : public QObject {
Q_OBJECT
public:
enum JobType {
Undefined,
GetPageDetails,
GetPageDetailsRecursively,
DeletePageLabel,
CreatePage,
UpdatePage,
UploadAttachments,
GetUserInfo
};
static bool available();
ConfluenceAgent();
ConfluenceAgent(BranchItem *bi);
~ConfluenceAgent();
void init();
void setJobType(JobType jt);
void setBranch(BranchItem *bi);
void setModelID(uint id);
void setPageURL(const QString &u);
void setPageID(const QString &id);
private:
int originalPageIndexInt;
public:
void setOriginalPageIndex(const int &i);
private:
QString labelNameInt;
public:
void setLabelName(const QString &labelName);
void setNewPageName(const QString &t);
void setUploadPagePath(const QString &fp);
void addUploadAttachmentPath(const QString &fp);
void startJob();
private:
void continueJob(int nextStep = -1);
void finishJob();
void unknownStepWarningFinishJob();
signals:
void foundUsers(QList <ConfluenceUser>);
public:
void getUsers(const QString &name); //! Convenience function to get user data
private: QNetworkRequest createRequest(const QUrl &url);
private: void startGetPageSourceRequest(QUrl requestedUrl);
private slots: void pageSourceReceived(QNetworkReply *reply);
private: void startGetPageDetailsRequest();
private slots: void pageDetailsReceived(QNetworkReply *reply);
private: void startGetPageChildrenRequest();
private slots: void pageChildrenReceived(QNetworkReply *reply);
private: void startDeleteLabelRequest();
private slots: void deleteLabelResponseReceived(QNetworkReply *reply);
private: void startCreatePageRequest();
private: void startUpdatePageRequest();
private slots: void pageUploaded(QNetworkReply *reply);
private: void startGetUserInfoRequest();
private slots: void userInfoReceived(QNetworkReply *reply);
private: void startGetAttachmentsInfoRequest();
private slots: void attachmentsInfoReceived(QNetworkReply *reply);
private: void startCreateAttachmentRequest();
private slots: void attachmentCreated(QNetworkReply *reply);
private: void startUpdateAttachmentRequest();
private slots: void attachmentUpdated(QNetworkReply *reply);
signals:
void attachmentsSuccess();
void attachmentsFailure();
public slots:
void attachmentsUploadSuccess();
void attachmentsUploadFailure();
private: bool wasRequestSuccessful(
QNetworkReply *reply,
const QString &requestDesc,
const QByteArray &fullReply);
private slots: void timeout();
#ifndef QT_NO_SSL
void sslErrors(QNetworkReply *, const QList<QSslError> &errors);
#endif
private:
// Job related
QTimer *killTimer;
JobType jobType;
int jobStep;
bool abortJob; // Flag to abort during initialization of job
// Network handling
QNetworkAccessManager *networkManager;
QJsonObject pageObj;
QJsonObject attachmentObj;
// Settings: Credentials to access Confluence
bool authUsingPAT;
QString personalAccessToken;
QString username;
QString password;
// Settings: Where to find Confluggence
QString baseURL;
QString apiURL;
// Backreferences to take action in calling model
uint branchID;
uint modelID;
private:
// Parameters
QString pageURL;
QString newPageName;
QString uploadPagePath;
QString userQuery;
// Page details received from Confluence or set as parameter
QString pageID;
QString spaceKey;
// Child agent for attachments
ConfluenceAgent *attachmentsAgent;
// Attachments found in page
QStringList attachmentsTitles;
QStringList attachmentsIds;
// Current attachments queued for upload
QStringList uploadAttachmentPaths;
int currentUploadAttachmentIndex;
QString currentAttachmentPath; // set with basename(..) from path
QString currentAttachmentTitle; // set with basename(..) from path
QString currentAttachmentId; // copied from attachmentsIds
// User info received from Confluence
QList <ConfluenceUser> userList;
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.