67 QString responceFilePath =
"";
80 virtual bool login(
const QByteArray& token) = 0;
85 virtual void logout();
103 virtual bool deleteMessage(
const QVariant& chatId,
const QVariant& messageId) = 0;
114 virtual QFuture<QByteArray>
getFile(
const QString& fileId,
FileType fileType = Ram) = 0;
123 virtual bool sendFile(
const QFileInfo& file,
const QVariant& chatId) = 0;
132 virtual bool sendFile(
const QByteArray& file,
const QString& fileName,
const QVariant& chatId) = 0;
138 const QByteArray &token()
const;
144 const QString& name()
const;
150 void setName(
const QString &newName);
156 QSharedPointer<iUpdate> takeNextUnreadUpdate();
162 QSet<unsigned long long> processed()
const;
168 virtual void setProcessed(
const QSet<unsigned long long> &newProcessed);
174 int reqestLimitPerSecond()
const;
180 void setReqestLimitPerSecond(
int newReqestLimitPerSecond);
186 int parallelActiveNetworkThreads()
const;
192 void setParallelActiveNetworkThreads(
int newParallelActiveNetworkThreads);
199 unsigned long long totalSentRequests()
const;
205 QDateTime startTime()
const;
215 template<
class MessageType,
class ... Args>
216 static QSharedPointer<MessageType>
makeMesasge(
const QByteArray& data, Args&& ...args) {
217 auto&& ptr = QSharedPointer<MessageType>(
new MessageType(std::forward<Args>(args)...));
218 ptr->setRawData(data);
229 template<
class MessageType,
class ... Args>
230 static QSharedPointer<MessageType>
makeMesasge(
const QJsonObject& data, Args&& ...args) {
231 auto&& ptr = QSharedPointer<MessageType>(
new MessageType(std::forward<Args>(args)...));
232 ptr->setRawJson(data);
242 virtual QString
makeUrl(
const QSharedPointer<iRequest>& request)
const = 0;
250 sendRequest(
const QSharedPointer<iRequest>& rquest);
260 sendRequest(
const QSharedPointer<iRequest>& rquest,
const QString& pathToResult);
266 void setToken(
const QByteArray &newToken);
271 void incomeNewUpdate(
const QSharedPointer<iUpdate>& message);
277 void markUpdateAsProcessed(
const QSharedPointer<iUpdate>& message);
284 void markUpdateAsUnprocessed(
const QSharedPointer<iUpdate>& message);
291 void markUpdateAsUnprocessed(
unsigned long long messageID);
297 virtual QString defaultFileStorageLocation()
const;
303 virtual void handleIncomeNewUpdate(
const QSharedPointer<iUpdate>& );
316 void handleEcxecuteRequest();
319 void setCurrentParallelActiveNetworkThreads(
int newParallelActiveNetworkThreads);
321 void sendRequestPrivate(
const QSharedPointer<iRequest>& rquest,
322 const QSharedPointer<QPromise<QByteArray>> & promiseResult);
324 void sendRequestPrivate(
const QSharedPointer<iRequest>& rquest,
325 const QString& pathToResult,
326 const QSharedPointer<QPromise<QByteArray> > &promiseResult);
328 QNetworkReply *sendRquestImpl(
const QSharedPointer<iRequest> &rquest);
332 QMap<unsigned long long, QSharedPointer<iUpdate>> _notProcessedUpdates;
333 QSet<unsigned long long> _processed;
334 QNetworkAccessManager *_manager =
nullptr;
335 QTimer* _requestExecutor =
nullptr;
336 unsigned long long _totalRequest = 0;
337 QDateTime _startTime;
338 QMap<unsigned long long, RequestData> _requestQueue;
339 int _currentParallelActiveNetworkThreads = 0;
340 int _parallelActiveNetworkThreads = 5;
virtual bool sendFile(const QByteArray &file, const QString &fileName, const QVariant &chatId)=0
sendFile This method setns a file that saved as a bytearray.
virtual bool sendMessage(const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority)=0
sendMessage This method sents text to the selected chat.