Debian Codegraph @

src/backend/uploader/UploadHandler.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "UploadHandler.h"
21
22 UploadHandler::UploadHandler(
23 const QSharedPointer<IConfig> &config,
24 const QSharedPointer<IFtpUploader> &ftpUploader,
25 const QSharedPointer<IScriptUploader> &scriptUploader,
26 const QSharedPointer<IImgurUploader> &imgurUploader) :
27 mConfig(config)
28 {
29 insertUploader(imgurUploader);
30 insertUploader(scriptUploader);
31 insertUploader(ftpUploader);
32 }
33
34 void UploadHandler::upload(const QImage &image)
35 {
36 mTypeToUploaderMap[type()]->upload(image);
37 }
38
39 UploaderType UploadHandler::type() const
40 {
41 return mConfig->uploaderType();
42 }
43
44 void UploadHandler::insertUploader(const QSharedPointer<IUploader> &uploader)
45 {
46 mTypeToUploaderMap[uploader->type()] = uploader;
47 connect(uploader.data(), &IUploader::finished, this, &IUploader::finished);
48 }