Skip to content

Commit

Permalink
Fixed imgbb.com API key; directupload.net -> directupload.eu
Browse files Browse the repository at this point in the history
Remove unused win32.cmake
  • Loading branch information
zenden2k committed Apr 10, 2024
1 parent ab21221 commit 9f197d8
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 82 deletions.
54 changes: 0 additions & 54 deletions CMake/win32.cmake

This file was deleted.

10 changes: 7 additions & 3 deletions Data/Scripts/imgbb.nut
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ function _ObtainToken() {

function _UploadToAccount(FileName, options) {
nm.enableResponseCodeChecking(true);
local apiKey = ServerParams.getParam("Login");
local apiKey = ServerParams.getParam("Password");
if (apiKey == "") {
WriteLog("error", "[imgbb.com] Cannot upload to account without API key");
return 0;
}
nm.addQueryParam("key", apiKey);
nm.addQueryParamFile("image", FileName, ExtractFileName(FileName), "");
nm.setUrl("https://api.imgbb.com/1/upload");
Expand All @@ -40,9 +44,9 @@ function _UploadToAccount(FileName, options) {

function UploadFile(FileName, options) {
nm.enableResponseCodeChecking(false);
local apiKey = ServerParams.getParam("Login");
local login = ServerParams.getParam("Login");

if (apiKey != "") {
if (login != "") {
return _UploadToAccount(FileName, options);
}

Expand Down
6 changes: 3 additions & 3 deletions Data/servers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</Server>
<Server Name="directupload.net" Authorize="1" MaxFileSize="4000000" DefaultForTypes="image">
<Actions>
<Action Type="login" Url="https://www.directupload.net/index.php?mode=login" PostParams="username=$(_LOGIN);passwort=$(_PASSWORD);autologin=1;" OnlyOnce="1" Description="Authorization on directupload.net"/>
<Action Type="upload" Url="https://www.directupload.net/index.php?mode=upload" PostParams="bilddatei=%filename%;image_link=Die Bild-URL bitte hier einfügen;image_comment=;image_tags=;image_mail=" RegExp='\[IMG\](.*?)\[\/IMG\]([\s\S]*?)\[IMG\](.*?)\[\/IMG\]' AssignVars="Image:2;Thumb:0"/>
<Action Type="login" Url="https://www.directupload.eu/index.php?mode=login" PostParams="username=$(_LOGIN);passwort=$(_PASSWORD);autologin=1;" OnlyOnce="1" Description="Authorization on directupload.net"/>
<Action Type="upload" Url="https://www.directupload.eu/index.php?mode=upload" PostParams="bilddatei=%filename%;image_link=Die Bild-URL bitte hier einfügen;image_comment=;image_tags=;image_mail=" RegExp='\[IMG\](.*?)\[\/IMG\]([\s\S]*?)\[IMG\](.*?)\[\/IMG\]' AssignVars="Image:2;Thumb:0"/>
</Actions>
<Result ImageUrlTemplate="$(Image)" ThumbUrlTemplate="$(Thumb)"/>
</Server>
Expand Down Expand Up @@ -222,7 +222,7 @@
</Actions>
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
</Server>-->
<Server Name="imgbb.com" MaxFileSize="32000000" Plugin="imgbb" Authorize="1" LoginLabel="API key" NeedPassword="0">
<Server Name="imgbb.com" MaxFileSize="32000000" Plugin="imgbb" Authorize="1" PasswordLabel="API key">
<Actions>
</Actions>
<Result ImageUrlTemplate="stub" ThumbUrlTemplate="stub"/>
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/BackgroundTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ void BackgroundTask::run() {
BackgroundTaskResult result = BackgroundTaskResult::Failed;
defer<void> d([&] { // Run at function exit
isRunning_ = false;
onTaskFinished(this, result);
onTaskFinished(this, result);
});
if (isCanceled_) {
result = BackgroundTaskResult::Canceled;
return;
}
isRunning_ = true;
result = doJob();
}
}
7 changes: 4 additions & 3 deletions Source/Core/BackgroundTask.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef IU_CORE_BACKGROUNDTASK
#define IU_CORE_BACKGROUNDTASK

#include <boost/signals2.hpp>
#include <atomic>
#include <string>
#include <boost/signals2.hpp>

#include "TaskDispatcher.h"
#include "Utils/CoreTypes.h"
Expand All @@ -21,8 +22,8 @@ class BackgroundTask: public CancellableTask {
bool isInProgress() override;
DISALLOW_COPY_AND_ASSIGN(BackgroundTask);
protected:
bool isRunning_ = false;
bool isCanceled_ = false;
std::atomic<bool> isRunning_ = false;
std::atomic<bool> isCanceled_ = false;
};

#endif
8 changes: 6 additions & 2 deletions Source/Core/ScreenCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ std::shared_ptr<Gdiplus::Bitmap> CRectRegion::GetImage(HDC src)
RECT regionBoundingRect;
CRgn screenRegion = CloneRegion(m_ScreenRegion);
RECT screenBounds;

GuiTools::GetScreenBounds(screenBounds);
CRgn FullScreenRgn;
FullScreenRgn.CreateRectRgnIndirect(&screenBounds);
Expand All @@ -217,7 +216,12 @@ std::shared_ptr<Gdiplus::Bitmap> CRectRegion::GetImage(HDC src)
screenRegion.GetRgnBox(&regionBoundingRect);
int bmWidth = regionBoundingRect.right - regionBoundingRect.left;
int bmHeight = regionBoundingRect.bottom - regionBoundingRect.top;


if (bmWidth <= 0 || bmHeight <=0) {
LOG(WARNING) << "Cannot make screenshot of empty region";
return {};
}

CBitmap tempBm; // Temporary bitmap and device context
CDC tempDC; // which were added to avoid artifacts with BitBlt
HDC dc = GetDC( 0 );
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/SearchGoogleImages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Utils/CryptoUtils.h"
#include "Core/Utils/DesktopUtils.h"

SearchGoogleImages::SearchGoogleImages(std::shared_ptr<INetworkClientFactory> networkClientFactory, const std::string& fileName): SearchByImageTask(fileName),
SearchGoogleImages::SearchGoogleImages(std::shared_ptr<INetworkClientFactory> networkClientFactory, std::string fileName): SearchByImageTask(std::move(fileName)),
networkClientFactory_(std::move(networkClientFactory))
{
}
Expand Down Expand Up @@ -74,4 +74,4 @@ bool SearchGoogleImages::base64EncodeCompat(const std::string& file, std::string
}
}
return true;
}
}
6 changes: 2 additions & 4 deletions Source/Core/SearchGoogleImages.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
#include "SearchByImage.h"
#include "Network/INetworkClient.h"

class NetworkClient;

class SearchGoogleImages: public SearchByImageTask {
public:
explicit SearchGoogleImages(std::shared_ptr<INetworkClientFactory> networkClientFactory, const std::string& fileName);
explicit SearchGoogleImages(std::shared_ptr<INetworkClientFactory> networkClientFactory, std::string fileName);
protected:
BackgroundTaskResult doJob() override;
static bool base64EncodeCompat(const std::string& file, std::string& output);
std::shared_ptr<INetworkClientFactory> networkClientFactory_;
};

#endif
#endif
10 changes: 7 additions & 3 deletions Source/Core/TempFileDeleter.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "TempFileDeleter.h"
#include "TempFileDeleter.h"

#include "Core/Utils/CoreUtils.h"

TempFileDeleter::~TempFileDeleter()
{
cleanup();
try {
cleanup();
} catch (const std::exception& ex) {
LOG(ERROR) << ex.what();
}
}

void TempFileDeleter::addFile(const std::string& fileName)
Expand All @@ -21,4 +25,4 @@ bool TempFileDeleter::cleanup()
}
m_files.clear();
return result;
}
}
8 changes: 7 additions & 1 deletion Source/Core/Utils/CoreUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ class defer {
defer(const defer&) = delete;

defer(std::function<T()> functor) : mFunctor(functor) {}
~defer() { mFunctor(); }
~defer() {
try {
mFunctor();
} catch (const std::exception& ex) {
LOG(ERROR) << ex.what();
}
}
};

namespace IuCoreUtils
Expand Down
8 changes: 4 additions & 4 deletions Source/Gui/Dialogs/WizardDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ LRESULT CWizardDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
LoadUploadEngines(userServersFolder + list[i], ErrorStr);
}
}
} catch ( std::exception& ex) {
} catch (const std::exception& ex) {
LOG(ERROR) << ex.what();
}

Expand Down Expand Up @@ -1038,10 +1038,10 @@ STDMETHODIMP CWizardDlg::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POI
ReleaseStgMedium(&ddd);
}
}
}

if (!enableDragndropOverlay_) {
queryDropFiledescriptors(pDataObj, &enableDragndropOverlay_);
if (!enableDragndropOverlay_) {
queryDropFiledescriptors(pDataObj, &enableDragndropOverlay_);
}
}

if (enableDragndropOverlay_) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Image Uploader.rc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0xCC
BEGIN
LISTBOX IDC_COMMANDBOX,-2,-1,198,165,LBS_SORT | LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP
LTEXT "#��������:",IDC_DELAYLABEL,12,175,47,8
EDITTEXT IDC_DELAYEDIT,79,173,27,13,ES_AUTOHSCROLL
EDITTEXT IDC_DELAYEDIT,79,173,27,13,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_DELAYSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,97,172,11,14
LTEXT "#�",IDC_SECLABEL,114,176,26,8
CONTROL "#Open screenshot in editor",IDC_OPENSCREENSHOTINEDITORCHECKBOX,
Expand Down

0 comments on commit 9f197d8

Please sign in to comment.