[
  {
    "path": ".github/workflows/build.yml",
    "content": "name: FRequest Build\non: [push]\njobs:\n  Build-windows:\n    runs-on: windows-2022\n    steps:\n      - name: Check out FRequest code\n        uses: actions/checkout@v3\n        with:\n          path: 'FRequest'\n      - name: Check out CommonLibs\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonLibs\n          path: 'CommonLibs'\n      - name: Check out CommonUtils\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonUtils\n          path: 'CommonUtils'\n      - name: Download Qt SDK and FRequest binaries\n        run: |\n         $files_url=\"https://github.com/${{ github.event.repository.owner.login }}/Files/releases/download\"\n         Invoke-WebRequest \"$files_url/frequestwindows/Qt5.15.2.7z\" -OutFile Qt5.15.2.7z\n         Invoke-WebRequest \"$files_url/frequestwindows/FRequestBinaries.7z\" -OutFile FRequestBinaries.7z\n         7z.exe x -mmt=4 Qt5.15.2.7z -o\"Qt5.15.2\"\n         7z.exe x -mmt=4 FRequestBinaries.7z -o\"FRequestBinaries\"\n      - name: Set Enviroments variables for SDK\n        run: |\n         # https://stackoverflow.com/a/64831469\n         echo \"${{ github.workspace }}\\Qt5.15.2\\5.15.2\\mingw81_32\\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append\n         echo \"${{ github.workspace }}\\Qt5.15.2\\Tools\\mingw810_32\\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append\n      - name: Compile code\n        run: |\n         mkdir output\n         cd output\n         qmake ../${{ github.event.repository.name }}/FRequest.pro \"CONFIG+=release\"\n         mingw32-make -j\n         cd ..\n      - name: Copy executable / dependencies / readme / license to final folder\n        run: |\n         Invoke-WebRequest \"https://github.com/${{ github.event.repository.owner.login }}/Files/releases/download/common/get_zip_name.py\" -OutFile get_zip_name.py\n         $zip_name=python3 get_zip_name.py ${{ github.event.repository.owner.login }} ${{ github.event.repository.name }}\n         mkdir distributable\n         mkdir distributable\\FRequest\n         cp output\\release\\FRequest.exe distributable\\FRequest\n         xcopy FRequestBinaries distributable\\FRequest /e\n         cp ${{ github.event.repository.name }}\\readme.txt distributable\\FRequest\n         cp ${{ github.event.repository.name }}\\LICENSE distributable\\FRequest\n         7z a -tzip -mmt=4 \"distributable\\$zip_name.zip\" \"${{ github.workspace }}\\distributable\\FRequest\"\n      - name: Archive the final folder\n        uses: actions/upload-artifact@v3\n        with:\n          name: FRequest-windows\n          path: distributable/*.zip\n  Build-macos:\n    runs-on: macos-10.15\n    steps:\n      - name: Check out FRequest code\n        uses: actions/checkout@v3\n        with:\n          path: 'FRequest'\n      - name: Check out CommonLibs\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonLibs\n          path: 'CommonLibs'\n      - name: Check out CommonUtils\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonUtils\n          path: 'CommonUtils'\n      - name: Install Qt\n        uses: jurplel/install-qt-action@v2\n        with:\n          version: 5.15.2\n          target: desktop\n          modules: none\n      # - name: Download and Install Qt SDK (alternative)\n        # # https://superuser.com/a/422785\n        # run: |\n         # brew install qt@5\n         # brew link qt@5\n      - name: Compile code\n        run: |\n         mkdir output\n         cd output\n         qmake ../${{ github.event.repository.name }}/FRequest.pro \"CONFIG+=release\" \n         make -j\n         cd ..\n      - name: Copy app bundle / readme / license to final folder\n        run: |\n         wget \"https://github.com/${{ github.event.repository.owner.login }}/Files/releases/download/common/get_zip_name.py\"\n         zip_name=$(python3 get_zip_name.py ${{ github.event.repository.owner.login }} ${{ github.event.repository.name }})\n         macdeployqt output/FRequest.app\n         mkdir distributable\n         mkdir distributable/FRequest\n         cp -R output/FRequest.app distributable/FRequest\n         cp ${{ github.event.repository.name }}/readme.txt distributable/FRequest\n         cp ${{ github.event.repository.name }}/LICENSE distributable/FRequest\n         7z a -tzip -mmt=4 distributable/$zip_name.zip ${{ github.workspace }}/distributable/FRequest\n      - name: Archive the final folder\n        uses: actions/upload-artifact@v3\n        with:\n          name: FRequest-macos\n          path: distributable/*.zip\n  Build-linux:\n    runs-on: ubuntu-18.04\n    steps:\n      - name: Check out FRequest code\n        uses: actions/checkout@v3\n        with:\n          path: 'FRequest'\n      - name: Check out CommonLibs\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonLibs\n          path: 'CommonLibs'\n      - name: Check out CommonUtils\n        uses: actions/checkout@v3\n        with:\n          repository: ${{ github.event.repository.owner.login }}/CommonUtils\n          path: 'CommonUtils'\n      - name: Install Qt\n        uses: jurplel/install-qt-action@v2\n        with:\n          version: 5.15.2\n          target: desktop\n          modules: none\n      - name: Download and Set linuxdeployqt\n        run: |\n         wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage\n         chmod a+x linuxdeployqt-continuous-x86_64.AppImage\n      - name: Compile code\n        run: |\n         mkdir output\n         cd output\n         qmake ../${{ github.event.repository.name }}/FRequest.pro \"CONFIG+=release\"\n         make -j\n         cd ..\n      - name: Generate AppImage\n        run: |\n         mkdir AppImage\n         cp output/FRequest AppImage\n         cp ${{ github.event.repository.name }}/LinuxAppImageDeployment/*.* AppImage\n         cd AppImage\n         ${{ github.workspace }}/linuxdeployqt-continuous-x86_64.AppImage frequest.desktop -no-translations -appimage\n         cd ..\n      - name: Copy AppImage / readme / license to final folder\n        run: |\n         wget \"https://github.com/${{ github.event.repository.owner.login }}/Files/releases/download/common/get_zip_name.py\"\n         zip_name=$(python3 get_zip_name.py ${{ github.event.repository.owner.login }} ${{ github.event.repository.name }})\n         mkdir distributable\n         mkdir distributable/FRequest\n         cp ${{ github.event.repository.name }}/readme.txt distributable/FRequest\n         cp ${{ github.event.repository.name }}/LICENSE distributable/FRequest\n         cp AppImage/FRequest-x86_64.AppImage distributable/FRequest\n         7z a -tzip -mmt=4 distributable/$zip_name ${{ github.workspace }}/distributable/FRequest\n      - name: Archive the final folder\n        uses: actions/upload-artifact@v3\n        with:\n          name: FRequest-linux\n          path: distributable/*.zip"
  },
  {
    "path": ".gitignore",
    "content": "# ignore QtCreator user files\n*.pro.user*\n\n# ignore MacOS specific files\n*.DS_Store\n"
  },
  {
    "path": "Authentications/basicauthentication.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"basicauthentication.h\"\n\n\nBasicAuthentication::BasicAuthentication\n(\nconst bool saveAuthToConfigFile, \nconst bool retryLoginIfError401, \nconst QString &username, \nconst QString &passwordSalt,\nconst QString &password\n)\n: FRequestAuthentication(saveAuthToConfigFile, retryLoginIfError401, AuthenticationType::BASIC_AUTHENTICATION), \nusername(username), \npasswordSalt(passwordSalt),\npassword(password)\n{\n\t\n}\n"
  },
  {
    "path": "Authentications/basicauthentication.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequestauthentication.h\"\n\n#ifndef BASICAUTHENTICATION_H\n#define BASICAUTHENTICATION_H\n\nclass BasicAuthentication : public FRequestAuthentication\n{\npublic:\n    BasicAuthentication\n\t(\n\tconst bool saveAuthToConfigFile, \n\tconst bool retryLoginIfError401, \n\tconst QString &username, \n\tconst QString &passwordSalt, \n\tconst QString &password\n\t);\n\npublic:\n\tconst QString username;\n\tconst QString passwordSalt;\n\tconst QString password;\n};\n\n#endif // BASICAUTHENTICATION_H\n"
  },
  {
    "path": "Authentications/frequestauthentication.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequestauthentication.h\"\n\n\nFRequestAuthentication::FRequestAuthentication(const bool saveAuthToConfigFile, const bool retryLoginIfError401, const AuthenticationType type)\n    :type(type), saveAuthToConfigFile(saveAuthToConfigFile), retryLoginIfError401(retryLoginIfError401)\n{\n\n}\n\nFRequestAuthentication::AuthenticationType FRequestAuthentication::getAuthenticationTypeByString(const QString &currentAuthenticationTypeText){\n\n    if(currentAuthenticationTypeText == \"Request Authentication\"){\n        return AuthenticationType::REQUEST_AUTHENTICATION;\n    }\n    else if(currentAuthenticationTypeText == \"Basic Authentication\"){\n        return AuthenticationType::BASIC_AUTHENTICATION;\n    }\n    else{\n        QString errorMessage = \"Authentication type unknown: '\" + currentAuthenticationTypeText + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n}\n\nQString FRequestAuthentication::getAuthenticationString(const AuthenticationType currentAuthType){\n\tswitch(currentAuthType){\n    case AuthenticationType::REQUEST_AUTHENTICATION:\n        return \"Request Authentication\";\n    case AuthenticationType::BASIC_AUTHENTICATION:\n        return \"Basic Authentication\";\n    default:\n    {\n        QString errorMessage = \"Invalid authentication type \" + QString::number(static_cast<int>(currentAuthType)) + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n}"
  },
  {
    "path": "Authentications/frequestauthentication.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef FREQUESTAUTHENTICATION_H\n#define FREQUESTAUTHENTICATION_H\n\n#include \"util.h\"\n\n// PLog library (log library)\n// https://github.com/SergiusTheBest/plog\n#include <plog/Log.h>\n\nclass FRequestAuthentication\n{\n\npublic:\n\tenum class AuthenticationType{\n\t\tREQUEST_AUTHENTICATION = 0,\n\t\tBASIC_AUTHENTICATION = 1\n\t};\n\nprotected:\n    FRequestAuthentication(const bool saveAuthToConfigFile, const bool retryLoginIfError401, const AuthenticationType type);\n\npublic:\n    virtual ~FRequestAuthentication() = default; // needed to avoid undefined behaviour https://stackoverflow.com/a/22491471/1499019\n\tstatic AuthenticationType getAuthenticationTypeByString(const QString &currentAuthenticationTypeText);\n\tstatic QString getAuthenticationString(const AuthenticationType currentAuthType);\n\t\npublic:\n\tconst AuthenticationType type;\n\tconst bool saveAuthToConfigFile; // otherwise saves for project file\n\tconst bool retryLoginIfError401; // should we retry on error 401?\n};\n\n#endif // FREQUESTAUTHENTICATION_H\n"
  },
  {
    "path": "Authentications/requestauthentication.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"requestauthentication.h\"\n\nRequestAuthentication::RequestAuthentication\n(\nconst bool saveAuthToConfigFile, \nconst bool retryLoginIfError401, \nconst QString &username, \nconst QString &passwordSalt, \nconst QString &password,\nconst QString requestForAuthenticationUuid\n)\n: FRequestAuthentication(saveAuthToConfigFile, retryLoginIfError401, AuthenticationType::REQUEST_AUTHENTICATION), \n\tusername(username), \n\tpasswordSalt(passwordSalt), \n\tpassword(password),\n\trequestForAuthenticationUuid(requestForAuthenticationUuid)\n{\n\t\n}\n"
  },
  {
    "path": "Authentications/requestauthentication.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef REQUESTAUTHENTICATION_H\n#define REQUESTAUTHENTICATION_H\n\n#include \"frequestauthentication.h\"\n\nclass RequestAuthentication : public FRequestAuthentication\n{\npublic:\n    RequestAuthentication\n\t(\n\tconst bool saveAuthToConfigFile, \n\tconst bool retryLoginIfError401, \n\tconst QString &username, \n\tconst QString &passwordSalt, \n\tconst QString &password, \n\tconst QString requestForAuthenticationUuid\n\t);\n\npublic:\n\tconst QString username;\n\tconst QString passwordSalt;\n\tconst QString password;\n    const QString requestForAuthenticationUuid;\n};\n\n#endif // REQUESTAUTHENTICATION_H\n"
  },
  {
    "path": "FRequest.pro",
    "content": "#-------------------------------------------------\r\n#\r\n# Project created by QtCreator 2017-03-17T15:24:31\r\n#\r\n#-------------------------------------------------\r\n\r\nQT       += core gui network\r\nCONFIG   += c++14\r\nQMAKE_CXXFLAGS += -Wall\r\nQMAKE_CXXFLAGS += -Wextra\r\n\r\ngreaterThan(QT_MAJOR_VERSION, 4): QT += widgets\r\n\r\ninclude(../CommonUtils/CommonUtils.pri)\r\ninclude(../CommonLibs/CommonLibs.pri)\r\n\r\nTARGET = FRequest\r\nTEMPLATE = app\r\n\r\nmacx {\r\nICON = Resources/frequest_icon.icns # mac os icon\r\n}\r\n\r\nwin32 {\r\n    RC_FILE = Resources/icon_resource.rc #for windows explorer icon\r\n}\r\n\r\nSOURCES += main.cpp\\\r\n        mainwindow.cpp \\\r\n    utilfrequest.cpp \\\r\n    about.cpp \\\r\n    preferences.cpp \\\r\n    HttpRequests/deletehttprequest.cpp \\\r\n    HttpRequests/httprequest.cpp \\\r\n    HttpRequests/posthttprequest.cpp \\\r\n    HttpRequests/puthttprequest.cpp \\\r\n    HttpRequests/gethttprequest.cpp \\\r\n    HttpRequests/patchhttprequest.cpp \\\r\n    HttpRequests/headhttprequest.cpp \\\r\n    HttpRequests/tracehttprequest.cpp \\\r\n    HttpRequests/optionshttprequest.cpp \\\r\n    Widgets/frequesttreewidgetitem.cpp \\\r\n    XmlParsers/configfilefrequest.cpp \\\r\n    XmlParsers/projectfilefrequest.cpp \\\r\n    HttpRequests/httprequestwithmultipart.cpp \\\r\n    projectproperties.cpp \\\r\n    Authentications/frequestauthentication.cpp \\\r\n    Authentications/basicauthentication.cpp \\\r\n    Authentications/requestauthentication.cpp \\\r\n    Widgets/frequesttreewidgetprojectitem.cpp \\\r\n    Widgets/frequesttreewidgetrequestitem.cpp \\\r\n    Widgets/frequesttreewidget.cpp \\\r\n    updatechecker.cpp \\\r\n    proxysetup.cpp \\\r\n    SyntaxHighlighters/frequestjsonhighlighter.cpp \\\r\n    SyntaxHighlighters/frequestxmlhighlighter.cpp\r\n\r\n\r\nHEADERS  += mainwindow.h \\\r\n    utilglobalvars.h \\\r\n    utilfrequest.h \\\r\n    about.h \\\r\n    preferences.h \\\r\n    HttpRequests/deletehttprequest.h \\\r\n    HttpRequests/httprequest.h \\\r\n    HttpRequests/posthttprequest.h \\\r\n    HttpRequests/puthttprequest.h \\\r\n    HttpRequests/gethttprequest.h \\\r\n    HttpRequests/patchhttprequest.h \\\r\n    HttpRequests/headhttprequest.h \\\r\n    HttpRequests/tracehttprequest.h \\\r\n    HttpRequests/optionshttprequest.h \\\r\n    Widgets/frequesttreewidgetitem.h \\\r\n    XmlParsers/configfilefrequest.h \\\r\n    XmlParsers/projectfilefrequest.h \\\r\n    HttpRequests/httprequestwithmultipart.h \\\r\n    projectproperties.h \\\r\n    Authentications/frequestauthentication.h \\\r\n    Authentications/basicauthentication.h \\\r\n    Authentications/requestauthentication.h \\\r\n    Widgets/frequesttreewidgetprojectitem.h \\\r\n    Widgets/frequesttreewidgetrequestitem.h \\\r\n    Widgets/frequesttreewidget.h \\\r\n    updatechecker.h \\\r\n    proxysetup.h \\\r\n    SyntaxHighlighters/frequestjsonhighlighter.h \\\r\n    SyntaxHighlighters/frequestxmlhighlighter.h\r\n\r\n\r\nFORMS    += mainwindow.ui \\\r\n    about.ui \\\r\n    preferences.ui \\\r\n    projectproperties.ui\r\n\r\nRESOURCES += \\\r\n    Resources/resources.qrc\r\n\r\nmacx {\r\nRESOURCES += \\\r\n    Resources/macos_resources.qrc\r\n}\r\n"
  },
  {
    "path": "HttpRequests/deletehttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"deletehttprequest.h\"\r\n\r\nDeleteHttpRequest::DeleteHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        const QString &fullPath,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequest(manager, fullPath, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* DeleteHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &){\r\n    return this->manager->deleteResource(request);\r\n}\r\n"
  },
  {
    "path": "HttpRequests/deletehttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef DELETEHTTPREQUEST_H\r\n#define DELETEHTTPREQUEST_H\r\n\r\n#include \"httprequest.h\"\r\n\r\nclass DeleteHttpRequest : public HttpRequest\r\n{\r\npublic:\r\n    DeleteHttpRequest(QNetworkAccessManager * const manager,\r\n            const QString &fullPath,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n};\r\n\r\n#endif // DELETEHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/gethttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"gethttprequest.h\"\r\n\r\nGetHttpRequest::GetHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        const QString &fullPath,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequest(manager, fullPath, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* GetHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &){\r\n    return this->manager->get(request);\r\n}\r\n"
  },
  {
    "path": "HttpRequests/gethttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef GETHTTPREQUEST_H\r\n#define GETHTTPREQUEST_H\r\n\r\n#include \"httprequest.h\"\r\n\r\nclass GetHttpRequest : public HttpRequest\r\n{\r\npublic:\r\n    GetHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            const QString &fullPath,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n};\r\n\r\n#endif // GETHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/headhttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"headhttprequest.h\"\r\n\r\nHeadHttpRequest::HeadHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        const QString &fullPath,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequest(manager, fullPath, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* HeadHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &){\r\n    return this->manager->head(request);\r\n}\r\n"
  },
  {
    "path": "HttpRequests/headhttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef HEADHTTPREQUEST_H\r\n#define HEADHTTPREQUEST_H\r\n\r\n#include \"httprequest.h\"\r\n\r\nclass HeadHttpRequest : public HttpRequest\r\n{\r\npublic:\r\n    HeadHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            const QString &fullPath,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n};\r\n\r\n#endif // HEADHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/httprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"httprequest.h\"\r\n\r\nHttpRequest::HttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        QTableWidget * const twBodyFormKeyValue,\r\n        const QString &fullPath,\r\n        const QString &bodyType,\r\n        const QString &rawRequestBody,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n        )\r\n    :fullPath(fullPath),\r\n      requestHeaders(requestHeaders), rawRequestBody(rawRequestBody), \r\n\t  bodyType(bodyType), manager(manager), twBodyFormKeyValue(twBodyFormKeyValue)\r\n{\r\n\r\n}\r\n\r\nHttpRequest::HttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        const QString &fullPath,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n        )\r\n    :fullPath(fullPath),\r\n      requestHeaders(requestHeaders),\r\n      manager(manager),\r\n      twBodyFormKeyValue(nullptr)\r\n{\r\n\t\r\n}\r\n\r\nQNetworkReply* HttpRequest::processRequest(){\r\n\r\n    QNetworkRequest request(QUrl(this->fullPath));\r\n\r\n    for(const UtilFRequest::HttpHeader &currentHeader : this->requestHeaders){\r\n\t\t// If multipart, don't add the multipart/form-data header, it is added automatically by HttpRequestWithMultiPart subclass\r\n\t\tif(!(currentHeader.name == \"Content-type\" && currentHeader.value == \"multipart/form-data\")){\r\n\t\t\trequest.setRawHeader(currentHeader.name.toUtf8(), currentHeader.value.toUtf8());\r\n\t\t}\r\n    }\r\n\t\r\n    if(!bodyType.isEmpty()){\r\n        if(this->bodyType == \"raw\"){\r\n            return sendRequest(request, this->rawRequestBody.toUtf8());\r\n        }\r\n        else if(this->bodyType == \"form-data\"){\r\n            return sendFormRequest(request);\r\n        }\r\n        else if(this->bodyType == \"x-form-www-urlencoded\"){\r\n            return sendFormRequest(request);\r\n        }\r\n        else{\r\n            QString errorMessage = \"Body type unknown: '\" + this->bodyType + \"'. Application can't proceed.\";\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_FATAL << errorMessage;\r\n            exit(1);\r\n        }\r\n    }\r\n    else{ // Get, delete etc which doesn't have a \"body\"\r\n        return sendRequest(request, QString().toUtf8());\r\n    }\r\n}\r\n\r\nQNetworkReply* HttpRequest::sendFormRequest(QNetworkRequest &request){\r\n\r\n\tQUrlQuery params;\r\n\r\n    for(int i = 0; i < this->twBodyFormKeyValue->rowCount(); i++){\r\n        params.addQueryItem(this->twBodyFormKeyValue->item(i,0)->text(), this->twBodyFormKeyValue->item(i,1)->text());\r\n    }\r\n\r\n    return sendRequest(request, params.toString(QUrl::FullyEncoded).toUtf8());\r\n\r\n}\r\n\r\nQNetworkReply* HttpRequest::sendHttpCustomRequest(const QNetworkRequest &request, const QString &verb, const QByteArray &data){\r\n\t\r\n\t// Based from here:\r\n    // https://stackoverflow.com/a/34065736/1499019\r\n    QBuffer *buffer=new QBuffer();\r\n    if(!data.isNull() && !data.isEmpty()){\r\n        buffer->open((QBuffer::ReadWrite));\r\n        buffer->write(data);\r\n        buffer->seek(0);\r\n    }\r\n\t\r\n    return this->manager->sendCustomRequest(request, verb.toUtf8(), buffer);\r\n}\r\n\r\nQNetworkReply* HttpRequest::sendHttpCustomRequest(const QNetworkRequest &request, const QString &verb, QHttpMultiPart &data){\r\n    return this->manager->sendCustomRequest(request, verb.toUtf8(), &data);\r\n}\r\n"
  },
  {
    "path": "HttpRequests/httprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef HTTPREQUEST_H\r\n#define HTTPREQUEST_H\r\n\r\n#include <QNetworkRequest>\r\n#include <QNetworkAccessManager>\r\n#include <QHttpMultiPart>\r\n#include <QVector>\r\n#include <QUrlQuery>\r\n#include <QNetworkReply>\r\n\r\n#include \"utilfrequest.h\"\r\n#include <QBuffer>\r\n\r\nclass HttpRequest\r\n{\r\npublic:\r\n    HttpRequest\r\n    (\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\n    HttpRequest\r\n    (\r\n            QNetworkAccessManager * const manager,\r\n            const QString &fullPath,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\n    virtual ~HttpRequest() = default; // needed to avoid undefined behaviour https://stackoverflow.com/a/22491471/1499019\r\n\r\n    QNetworkReply* processRequest();\r\nprivate:\r\n    const QString fullPath;\r\n    const QVector<UtilFRequest::HttpHeader> requestHeaders;\r\n    const QString rawRequestBody;\r\nprotected:\r\n\tconst QString bodyType;\r\n    QNetworkAccessManager * const manager;\r\n    QTableWidget * const twBodyFormKeyValue;\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) = 0; // abstract funtion to be filled by subclasses\r\n    virtual QNetworkReply* sendFormRequest(QNetworkRequest &request);\r\n    QNetworkReply* sendHttpCustomRequest(const QNetworkRequest &request, const QString &verb, const QByteArray &data);\r\n    QNetworkReply* sendHttpCustomRequest(const QNetworkRequest &request, const QString &verb, QHttpMultiPart &data);\r\n};\r\n\r\n#endif // HTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/httprequestwithmultipart.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nHttpRequestWithMultiPart::HttpRequestWithMultiPart\r\n(\r\n        QNetworkAccessManager * const manager,\r\n\t\tQTableWidget * const twBodyFormKeyValue,\r\n\t\tconst QString &fullPath,\r\n\t\tconst QString &bodyType,\r\n\t\tconst QString &rawRequestBody,\r\n\t\tconst QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n\t:HttpRequest(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* HttpRequestWithMultiPart::sendFormRequest(QNetworkRequest &request){\r\n\r\n\t// If not form data call default handler\r\n\tif(this->bodyType != \"form-data\"){\r\n\t\treturn HttpRequest::sendFormRequest(request);\r\n\t}\r\n\t\r\n\t// Process multi part (form data) request\r\n\tQHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);\r\n\t\r\n\tfor(int i = 0; i < this->twBodyFormKeyValue->rowCount(); i++){\r\n\t\t\r\n\t\t// TODO create enums to these columns, so we don't have to put the index directly\r\n\t\tconst QString &currKey = this->twBodyFormKeyValue->item(i,0)->text();\r\n\t\tconst QString &currValue = this->twBodyFormKeyValue->item(i,1)->text();\r\n\t\tconst UtilFRequest::FormKeyValueType currFormKeyValueType = UtilFRequest::getFormKeyTypeByString(this->twBodyFormKeyValue->item(i,2)->text());\r\n\t\t\r\n\t\t switch(currFormKeyValueType){\r\n\t\t\tcase UtilFRequest::FormKeyValueType::TEXT:\r\n\t\t\t{\r\n\t\t\t\tQHttpPart textPart;\r\n\t\t\t\ttextPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(\"form-data; name=\\\"\" + currKey + \"\\\"\"));\r\n\t\t\t\ttextPart.setBody(currValue.toUtf8());\r\n\r\n\t\t\t\tmultiPart->append(textPart);\r\n\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase UtilFRequest::FormKeyValueType::FILE:\r\n\t\t\t{\r\n\t\t\t\tQHttpPart filePart;\r\n                filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(UtilFRequest::mimeDatabase.mimeTypeForFile(currValue, QMimeDatabase::MatchMode::MatchExtension).name()));\r\n\t\t\t\tfilePart.setHeader(\r\n\t\t\t\tQNetworkRequest::ContentDispositionHeader, \r\n\t\t\t\tQVariant(\"form-data; name=\\\"\" + Util::FileSystem::cutNameWithoutBackSlash(currKey) + \"\\\"; filename=\\\"\" + Util::FileSystem::cutNameWithoutBackSlash(currValue) + \"\\\"\")\r\n\t\t\t\t);\r\n\t\t\t\t\r\n\t\t\t\tQFile *currFile = new QFile(currValue);\r\n\t\t\t\t\r\n\t\t\t\tcurrFile->open(QIODevice::ReadOnly);\r\n\t\t\t\tfilePart.setBodyDevice(currFile);\r\n\t\t\t\tcurrFile->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart\r\n\t\t\t\t\r\n\t\t\t\tmultiPart->append(filePart);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tdefault:\r\n\t\t\t{\r\n\t\t\t\tQString errorMessage = \"Invalid form key type \" + QString::number(static_cast<int>(currFormKeyValueType)) + \"'. Program can't proceed.\";\r\n\t\t\t\tUtil::Dialogs::showError(errorMessage);\r\n\t\t\t\tLOG_FATAL << errorMessage;\r\n\t\t\t\texit(1);\r\n\t\t\t}\r\n\t\t}\r\n\r\n   }\r\n   \r\n   QNetworkReply *reply = sendRequest(request, *multiPart);\r\n   \r\n   multiPart->setParent(reply);\r\n   \r\n   return reply;\r\n}\r\n"
  },
  {
    "path": "HttpRequests/httprequestwithmultipart.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef HTTPREQUESTWITHMULTIPART_H\r\n#define HTTPREQUESTWITHMULTIPART_H\r\n\r\n#include \"httprequest.h\"\r\n\r\nclass HttpRequestWithMultiPart : public HttpRequest\r\n{\r\npublic:\r\n    HttpRequestWithMultiPart(\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\n\t\t\t\r\n\t// This constructor is not used for HttpRequestWithMultiPart classes\r\n\tHttpRequestWithMultiPart\r\n    (\r\n            QNetworkAccessManager * const manager,\r\n            const QString &fullPath,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            ) = delete;\r\n\t\t\t\r\n\tvirtual ~HttpRequestWithMultiPart() = default; // needed to avoid undefined behaviour https://stackoverflow.com/a/22491471/1499019\r\nprotected:\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) = 0; // abstract funtion to be filled by subclasses\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) = 0; // abstract funtion to be filled by subclasses\r\nprivate:\r\n\tQNetworkReply* sendFormRequest(QNetworkRequest &request);\r\n};\r\n\r\n#endif // HTTPREQUESTWITHMULTIPART_H\r\n"
  },
  {
    "path": "HttpRequests/optionshttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"optionshttprequest.h\"\r\n\r\nOptionsHttpRequest::OptionsHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        QTableWidget * const twBodyFormKeyValue,\r\n        const QString &fullPath,\r\n        const QString &bodyType,\r\n        const QString &rawRequestBody,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequestWithMultiPart(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* OptionsHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &data){\r\n    return sendHttpCustomRequest(request, \"OPTIONS\", data);\r\n}\r\n\r\nQNetworkReply* OptionsHttpRequest::sendRequest(const QNetworkRequest &request, QHttpMultiPart &data){\r\n\treturn sendHttpCustomRequest(request, \"OPTIONS\", data);\r\n}"
  },
  {
    "path": "HttpRequests/optionshttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef OPTIONSHTTPREQUEST_H\r\n#define OPTIONSHTTPREQUEST_H\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nclass OptionsHttpRequest : public HttpRequestWithMultiPart\r\n{\r\npublic:\r\n    OptionsHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) override;\r\n};\r\n\r\n#endif // OPTIONSHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/patchhttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"patchhttprequest.h\"\r\n\r\nPatchHttpRequest::PatchHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        QTableWidget * const twBodyFormKeyValue,\r\n        const QString &fullPath,\r\n        const QString &bodyType,\r\n        const QString &rawRequestBody,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequestWithMultiPart(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* PatchHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &data){\r\n    return sendHttpCustomRequest(request, \"PATCH\", data);\r\n}\r\n\r\nQNetworkReply* PatchHttpRequest::sendRequest(const QNetworkRequest &request, QHttpMultiPart &data){\r\n\treturn sendHttpCustomRequest(request, \"PATCH\", data);\r\n}"
  },
  {
    "path": "HttpRequests/patchhttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef PATCHHTTPREQUEST_H\r\n#define PATCHHTTPREQUEST_H\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nclass PatchHttpRequest : public HttpRequestWithMultiPart\r\n{\r\npublic:\r\n    PatchHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) override;\r\n};\r\n\r\n#endif // PATCHHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/posthttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"posthttprequest.h\"\r\n\r\nPostHttpRequest::PostHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n\t\tQTableWidget * const twBodyFormKeyValue,\r\n\t\tconst QString &fullPath,\r\n\t\tconst QString &bodyType,\r\n\t\tconst QString &rawRequestBody,\r\n\t\tconst QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequestWithMultiPart(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* PostHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &data){\r\n    return this->manager->post(request, data);\r\n}\r\n\r\nQNetworkReply* PostHttpRequest::sendRequest(const QNetworkRequest &request, QHttpMultiPart &data){\r\n    return this->manager->post(request, &data);\r\n}\r\n"
  },
  {
    "path": "HttpRequests/posthttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef POSTHTTPREQUEST_H\r\n#define POSTHTTPREQUEST_H\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nclass PostHttpRequest : public HttpRequestWithMultiPart\r\n{\r\npublic:\r\n    PostHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) override;\r\n};\r\n\r\n#endif // POSTHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/puthttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"puthttprequest.h\"\r\n\r\nPutHttpRequest::PutHttpRequest\r\n(\r\n        QNetworkAccessManager * const manager,\r\n        QTableWidget * const twBodyFormKeyValue,\r\n        const QString &fullPath,\r\n        const QString &bodyType,\r\n        const QString &rawRequestBody,\r\n        const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequestWithMultiPart(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* PutHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &data){\r\n    return this->manager->put(request, data);\r\n}\r\n\r\nQNetworkReply* PutHttpRequest::sendRequest(const QNetworkRequest &request, QHttpMultiPart &data){\r\n    return this->manager->put(request, &data);\r\n}"
  },
  {
    "path": "HttpRequests/puthttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef PUTHTTPREQUEST_H\r\n#define PUTHTTPREQUEST_H\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nclass PutHttpRequest : public HttpRequestWithMultiPart\r\n{\r\npublic:\r\n    PutHttpRequest(\r\n            QNetworkAccessManager * const manager,\r\n            QTableWidget * const twBodyFormKeyValue,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &rawRequestBody,\r\n            const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) override;\r\n};\r\n\r\n#endif // PUTHTTPREQUEST_H\r\n"
  },
  {
    "path": "HttpRequests/tracehttprequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"tracehttprequest.h\"\r\n\r\nTraceHttpRequest::TraceHttpRequest\r\n(\r\n\t    QNetworkAccessManager * const manager,\r\n\t\tQTableWidget * const twBodyFormKeyValue,\r\n\t\tconst QString &fullPath,\r\n\t\tconst QString &bodyType,\r\n\t\tconst QString &rawRequestBody,\r\n\t\tconst QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n )\r\n    :HttpRequestWithMultiPart(manager, twBodyFormKeyValue, fullPath, bodyType, rawRequestBody, requestHeaders)\r\n{\r\n}\r\n\r\nQNetworkReply* TraceHttpRequest::sendRequest(const QNetworkRequest &request, const QByteArray &){\r\n    return sendHttpCustomRequest(request, \"TRACE\", QByteArray());\r\n}\r\n\r\nQNetworkReply* TraceHttpRequest::sendRequest(const QNetworkRequest &request, QHttpMultiPart &data){\r\n\treturn sendHttpCustomRequest(request, \"TRACE\", data);\r\n}"
  },
  {
    "path": "HttpRequests/tracehttprequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef TRACEHTTPREQUEST_H\r\n#define TRACEHTTPREQUEST_H\r\n\r\n#include \"httprequestwithmultipart.h\"\r\n\r\nclass TraceHttpRequest : public HttpRequestWithMultiPart\r\n{\r\npublic:\r\n    TraceHttpRequest(\r\n             QNetworkAccessManager * const manager,\r\n\t\t\t QTableWidget * const twBodyFormKeyValue,\r\n\t\t\t const QString &fullPath,\r\n\t\t\t const QString &bodyType,\r\n\t\t\t const QString &rawRequestBody,\r\n\t\t\t const QVector<UtilFRequest::HttpHeader> &requestHeaders\r\n            );\r\nprotected:\r\n    virtual QNetworkReply* sendRequest(const QNetworkRequest &request, const QByteArray &data) override;\r\n\tvirtual QNetworkReply* sendRequest(const QNetworkRequest &request, QHttpMultiPart &data) override;\r\n};\r\n\r\n#endif // TRACEHTTPREQUEST_H\r\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    {one line to give the program's name and a brief idea of what it does.}\n    Copyright (C) {year}  {name of author}\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    {project}  Copyright (C) {year}  {fullname}\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "LinuxAppImageDeployment/frequest.desktop",
    "content": "[Desktop Entry]\nType=Application\nName=FRequest\nExec=FRequest\nIcon=frequest_icon\nComment=A fast, lightweight and opensource desktop application to make HTTP(s) requests\nCategories=Development;\nTerminal=false\n"
  },
  {
    "path": "README.md",
    "content": "# FRequest\n\n[![Latest](https://img.shields.io/github/release/fabiobento512/frequest.svg?label=latest)](https://github.com/fabiobento512/FRequest/releases)\n\nFRequest - A fast, lightweight and opensource desktop application to make HTTP(s) requests.\n\nAvailable for Windows / macOS / Linux.\n\nCheck FRequest <a href=\"https://fabiobento512.github.io/FRequest/\">website</a> for more information.\n\nTo build FRequest look <a href=\"https://github.com/fabiobento512/FRequest/wiki/Building-FRequest\">here</a>.\n"
  },
  {
    "path": "Resources/icon_resource.rc",
    "content": " IDI_ICON1               ICON    DISCARDABLE     \"frequest_icon.ico\""
  },
  {
    "path": "Resources/macos_resources.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/help\">\r\n        <file>macos_apptrans_workaround.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "Resources/resources.qrc",
    "content": "<RCC>\r\n    <qresource prefix=\"/icons\">\r\n        <file>projects_folder_icon.png</file>\r\n        <file>frequest_icon.png</file>\r\n        <file>send_request_icon.png</file>\r\n        <file>minus.png</file>\r\n        <file>plus.png</file>\r\n        <file>clipboard_icon.png</file>\r\n        <file>plus_file.png</file>\r\n        <file>warning_icon.png</file>\r\n        <file>abort.png</file>\r\n        <file>clone_icon.png</file>\r\n        <file>delete_icon.png</file>\r\n    </qresource>\r\n</RCC>\r\n"
  },
  {
    "path": "SyntaxHighlighters/frequestjsonhighlighter.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequestjsonhighlighter.h\"\n\nFRequestJSONHighlighter::FRequestJSONHighlighter(QTextDocument *parent)\n    : Highlighter(parent)\n{\n\t\n   // Override colors\n   for(HighlightingRule &currRule : this->rules){\n\t   if(currRule.pattern == QRegExp(\"(true|false|null)(?!\\\"[^\\\"]*\\\")\")){\n\t\t   //reserved words\n\t\t   currRule.format.setForeground(QColor(0x0066ff));\n\t\t   break;\n\t   }\n   }\n   \n}\n"
  },
  {
    "path": "SyntaxHighlighters/frequestjsonhighlighter.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef FREQUESTJSONHIGHLIGHTER_H\n#define FREQUESTJSONHIGHLIGHTER_H\n\n#include <jsonhighlighter/highlighter.h>\n\nclass FRequestJSONHighlighter: public Highlighter\n{\n\tQ_OBJECT\npublic:\n     FRequestJSONHighlighter(QTextDocument *parent = 0);\n};\n\n#endif // FREQUESTJSONHIGHLIGHTER_H\n"
  },
  {
    "path": "SyntaxHighlighters/frequestxmlhighlighter.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequestxmlhighlighter.h\"\n\nFRequestXMLHighlighter::FRequestXMLHighlighter(QTextDocument * parent) :\n    BasicXMLSyntaxHighlighter(parent)\n{\n\tm_xmlKeywordFormat.setForeground(QColor(0x0066ff));\n\n    m_xmlElementFormat.setForeground(QColor(0x0066ff));\n}"
  },
  {
    "path": "SyntaxHighlighters/frequestxmlhighlighter.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef FREQUESTXMLHIGHLIGHTER_H\n#define FREQUESTXMLHIGHLIGHTER_H\n\n#include <BasicXMLSyntaxHighlighter/BasicXMLSyntaxHighlighter.h>\n\nclass FRequestXMLHighlighter : public BasicXMLSyntaxHighlighter\n{\n    Q_OBJECT\npublic:\n    FRequestXMLHighlighter(QTextDocument * parent = nullptr);\n};\n\n#endif // FREQUESTXMLHIGHLIGHTER_H\n"
  },
  {
    "path": "Widgets/frequesttreewidget.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"frequesttreewidget.h\"\r\n\r\nFRequestTreeWidget::FRequestTreeWidget(QWidget *parent)\r\n    : CustomTreeWidget(parent)\r\n{\r\n    \r\n}\r\n\r\nvoid FRequestTreeWidget::keyPressEvent(QKeyEvent *event)\r\n{\r\n    CustomTreeWidget::keyPressEvent(event);\r\n\t\r\n    if (event->key() == Qt::Key_Delete)\r\n    {\r\n        event->accept();\r\n        emit deleteKeyPressed();\r\n    }\r\n}"
  },
  {
    "path": "Widgets/frequesttreewidget.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef FREQUESTTREEWIDGET_H\r\n#define FREQUESTTREEWIDGET_H\r\n\r\n#include <CustomTreeWidget/customtreewidget.h>\r\n\r\nclass FRequestTreeWidget : public CustomTreeWidget\r\n{\r\n\tQ_OBJECT\r\n\t\t\r\npublic:\r\n    FRequestTreeWidget(QWidget* parent);\r\nprivate slots:\r\n\tvoid keyPressEvent(QKeyEvent *event);\r\nsignals:\r\n    void deleteKeyPressed();\r\n};\r\n\r\n#endif // FREQUESTTREEWIDGET_H\r\n"
  },
  {
    "path": "Widgets/frequesttreewidgetitem.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"frequesttreewidgetitem.h\"\r\n\r\nFRequestTreeWidgetItem::FRequestTreeWidgetItem(const QStringList &list, const bool isProjectItem)\r\n    :QTreeWidgetItem(list), isProjectItem(isProjectItem)\r\n{\r\n\t\r\n}\r\n\r\nFRequestTreeWidgetItem* FRequestTreeWidgetItem::fromQTreeWidgetItem(QTreeWidgetItem* widget){\r\n    FRequestTreeWidgetItem* result = dynamic_cast<FRequestTreeWidgetItem*>(widget);\r\n\r\n    if(result == nullptr){\r\n        QString errorString = \"Fatal error, failed to convert QTreeWidgetItem* to FRequestTreeWidgetItem*. Widget Text: \" +\r\n        widget->text(0) + \"Widget Position: \" + QString::number(widget->parent()->indexOfChild(widget));\r\n\r\n        LOG_FATAL << errorString;\r\n\r\n        Util::Dialogs::showError(errorString + \"\\n Application can't proceed.\");\r\n\r\n        exit(-1);\r\n    }\r\n\r\n    return result;\r\n}\r\n\r\nbool FRequestTreeWidgetItem::hasEmptyIcon(){\r\n    return this->icon(0).isNull();\r\n}\r\n"
  },
  {
    "path": "Widgets/frequesttreewidgetitem.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef FREQUESTTREEWIDGETITEM_H\r\n#define FREQUESTTREEWIDGETITEM_H\r\n\r\n#include <QTreeWidgetItem>\r\n#include <cpp17optional/optional.hpp>\r\n#include \"utilfrequest.h\"\r\n\r\nclass FRequestTreeWidgetItem : public QTreeWidgetItem\r\n{\r\npublic:\r\n    FRequestTreeWidgetItem(const QStringList &list, const bool isProjectItem);\r\n    static FRequestTreeWidgetItem* fromQTreeWidgetItem(QTreeWidgetItem* widget);\r\n    bool hasEmptyIcon();\r\npublic:\r\n    const bool isProjectItem;\r\n};\r\n\r\n#endif // FREQUESTTREEWIDGETITEM_H\r\n"
  },
  {
    "path": "Widgets/frequesttreewidgetprojectitem.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequesttreewidgetprojectitem.h\"\n\nFRequestTreeWidgetProjectItem::FRequestTreeWidgetProjectItem(const QStringList &list, const QString &uuid)\n    :FRequestTreeWidgetItem(list, true), uuid(uuid)\n{\n}\n\nFRequestTreeWidgetProjectItem* FRequestTreeWidgetProjectItem::fromQTreeWidgetItem(QTreeWidgetItem* widget){\n    FRequestTreeWidgetProjectItem* result = dynamic_cast<FRequestTreeWidgetProjectItem*>(widget);\n\n    if(result == nullptr){\n        QString errorString = \"Fatal error, failed to convert QTreeWidgetItem* to FRequestTreeWidgetProjectItem*. Widget Text: \" +\n        widget->text(0) + \"Widget Position: \" + QString::number(widget->parent()->indexOfChild(widget));\n\n        LOG_FATAL << errorString;\n\n        Util::Dialogs::showError(errorString + \"\\n Application can't proceed.\");\n\n        exit(-1);\n    }\n\n    return result;\n}\n\nQString FRequestTreeWidgetProjectItem::getUuid(){\n\treturn this->uuid;\n}\n\nFRequestTreeWidgetRequestItem * FRequestTreeWidgetProjectItem::getChildRequestByUuid(const QString &requestUuid){\n    if(!this->mapOfChilds_UuidToRequest.contains(requestUuid)){\n        QString errorString = \"Fatal error, failed to get request item for the given uuid '\" + requestUuid + \"'\";\n\n        LOG_FATAL << errorString;\n\n        Util::Dialogs::showError(errorString + \"\\n Application can't proceed.\");\n\n        exit(-1);\n    }\n\n    return this->mapOfChilds_UuidToRequest[requestUuid];\n}\n\nvoid FRequestTreeWidgetProjectItem::addRequestItemChild(FRequestTreeWidgetRequestItem * const child){\n\t\n\t// Add uuid to our child cache\n    this->mapOfChilds_UuidToRequest.insert(child->itemContent.uuid, child);\n\t\n\taddChild(child); // calls QTreeWidgetItem addChild()\n}\n"
  },
  {
    "path": "Widgets/frequesttreewidgetprojectitem.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef FREQUESTTREEWIDGETPROJECTITEM_H\n#define FREQUESTTREEWIDGETPROJECTITEM_H\n\n#include \"frequesttreewidgetrequestitem.h\"\n#include \"utilfrequest.h\"\n\n#include <memory>\n\nclass FRequestTreeWidgetProjectItem : public FRequestTreeWidgetItem\n{\npublic:\n    FRequestTreeWidgetProjectItem(const QStringList &list, const QString &uuid);\n\t\npublic:\n    static FRequestTreeWidgetProjectItem* fromQTreeWidgetItem(QTreeWidgetItem* widget);\n\tQString getUuid();\n\tFRequestTreeWidgetRequestItem * getChildRequestByUuid(const QString &requestUuid);\n    virtual void addRequestItemChild(FRequestTreeWidgetRequestItem * const child);\npublic:\n\tQString projectName;\n\tQString projectMainUrl = \"http://localhost/\";\n\t// can't use optional because it is an abstract base class, using unique_ptr as nullptr as alternative\n    std::shared_ptr<FRequestAuthentication> authData = nullptr;\n    UtilFRequest::IdentCharacter saveIdentCharacter = UtilFRequest::IdentCharacter::SPACE; // space by default\n    QVector<UtilFRequest::HttpHeader> globalHeaders;\nprivate:\n    QString uuid;\n    QHash<QString, FRequestTreeWidgetRequestItem *> mapOfChilds_UuidToRequest;\n};\n\n#endif // FREQUESTTREEWIDGETPROJECTITEM_H\n"
  },
  {
    "path": "Widgets/frequesttreewidgetrequestitem.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"frequesttreewidgetrequestitem.h\"\n\nFRequestTreeWidgetRequestItem::FRequestTreeWidgetRequestItem(const QStringList &list, const QString &uuid)\n    :FRequestTreeWidgetItem(list, false)\n{\n\titemContent.uuid = uuid;\n}\n\nFRequestTreeWidgetRequestItem* FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(QTreeWidgetItem* widget){\n    FRequestTreeWidgetRequestItem* result = dynamic_cast<FRequestTreeWidgetRequestItem*>(widget);\n\n    if(result == nullptr){\n        QString errorString = \"Fatal error, failed to convert QTreeWidgetItem* to FRequestTreeWidgetRequestItem*. Widget Text: \" +\n        widget->text(0) + \"Widget Position: \" + QString::number(widget->parent()->indexOfChild(widget));\n\n        LOG_FATAL << errorString;\n\n        Util::Dialogs::showError(errorString + \"\\n Application can't proceed.\");\n\n        exit(-1);\n    }\n\n    return result;\n}\n"
  },
  {
    "path": "Widgets/frequesttreewidgetrequestitem.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef FREQUESTTREEWIDGETREQUESTITEM_H\n#define FREQUESTTREEWIDGETREQUESTITEM_H\n\n#include \"frequesttreewidgetitem.h\"\n\nclass FRequestTreeWidgetRequestItem : public FRequestTreeWidgetItem\n{\npublic:\n    FRequestTreeWidgetRequestItem(const QStringList &list, const QString &uuid);\n    static FRequestTreeWidgetRequestItem* fromQTreeWidgetItem(QTreeWidgetItem* widget);\npublic:\n    UtilFRequest::RequestInfo itemContent;\n};\n\nQ_DECLARE_METATYPE(FRequestTreeWidgetRequestItem*) // necessary for qvariant_cast\n\n#endif // FREQUESTTREEWIDGETREQUESTITEM_H\n"
  },
  {
    "path": "XmlParsers/configfilefrequest.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"configfilefrequest.h\"\n\nConfigFileFRequest::ConfigFileFRequest(const QString &fileFullPath)\n    :fileFullPath(fileFullPath)\n{\n    if(!QFile::exists(fileFullPath)){\n        createNewConfig();\n        return;\n    }\n\n    readSettingsFromFile();\n}\n\nvoid ConfigFileFRequest::createNewConfig(){\n\n    pugi::xml_document doc;\n\n    pugi::xml_node rootNode = doc.append_child(\"FRequestConfig\");\n    rootNode.append_attribute(\"frequestVersion\").set_value(QSTR_TO_TEMPORARY_CSTR(GlobalVars::LastCompatibleVersionConfig));\n\n    pugi::xml_node generalNode = rootNode.append_child(\"General\");\n\n    generalNode.append_attribute(\"requestTimeout\").set_value(currentSettings.requestTimeout);\n\tgeneralNode.append_attribute(\"maxRequestResponseDataSizeToDisplay\").set_value(currentSettings.maxRequestResponseDataSizeToDisplay);\n    generalNode.append_attribute(\"onStartupOption\").set_value(static_cast<int>(currentSettings.onStartupSelectedOption));\n\tgeneralNode.append_attribute(\"theme\").set_value(static_cast<int>(currentSettings.theme));\n    generalNode.append_attribute(\"lastProjectPath\");\n    generalNode.append_attribute(\"lastResponseFilePath\");\n    generalNode.append_attribute(\"showRequestTypesIcons\");\n    generalNode.append_attribute(\"hideProjectSavedDialog\");\n\n    pugi::xml_node recentProjectsNode = rootNode.append_child(\"RecentProjects\");\n\n    for(int i=1; i<=GlobalVars::AppRecentProjectsMaxSize; i++){\n        recentProjectsNode.append_child(QSTR_TO_TEMPORARY_CSTR(\"RecentProject\" + QString::number(i)));\n    }\n\n    pugi::xml_node proxyNode = rootNode.append_child(\"Proxy\");\n\n    proxyNode.append_attribute(\"useProxy\").set_value(false);\n    proxyNode.append_attribute(\"proxyType\").set_value(0);\n    proxyNode.append_attribute(\"hostName\");\n    proxyNode.append_attribute(\"port\").set_value(0);\n\n    pugi::xml_node windowsGeometryNode = rootNode.append_child(\"WindowsGeometry\");\n\n    windowsGeometryNode.append_attribute(\"saveWindowsGeometryWhenExiting\").set_value(currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting);\n    pugi::xml_node mainWindowNode = windowsGeometryNode.append_child(\"MainWindow\");\n    mainWindowNode.append_child(\"MainWindowGeometry\");\n    mainWindowNode.append_child(\"RequestsSplitterState\");\n    mainWindowNode.append_child(\"RequestResponseSplitterState\");\n\n    pugi::xml_node defaultHeadersNode = rootNode.append_child(\"DefaultHeaders\");\n    defaultHeadersNode.append_attribute(\"useDefaultHeaders\").set_value(currentSettings.defaultHeaders.useDefaultHeaders);\n\n    if(!doc.save_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath), PUGIXML_TEXT(\"\\t\"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n\t\t#ifdef Q_OS_MAC\n\t\t\tQString errorMessage = \"An error ocurred while creating the FRequest config file.<br/>\"\n\t\t\t\"Make sure the application is placed on a writable location.\"\n\t\t\t\"<hr/>\"\n\t\t\t\"This problem can be caused by \\\"App Translocation\\\" more information <a href='https://github.com/fabiobento512/FRequest/issues/5'>here</a>.<br/>\"\n\t\t\t\"As workaround please try to move FRequest.app using finder to another folder with write permission, for instance your \\\"Documents\\\" folder, and then try to open it again.<br/><br/>\"\n\t\t\t\"<img src=':/help/macos_apptrans_workaround.png'/>\"\n\t\t\t\"<hr/>\"\n\t\t\t\"Application needs to abort.\";\n\t\t\tconst bool richError = true;\n\t\t#else\n\t\t\tQString errorMessage = \"An error ocurred while creating the FRequest config file.\\n\"\n\t\t\t\"Make sure the application is placed on a writable location.\\n\"\n\t\t\t\"Application needs to abort.\";\n\t\t\tconst bool richError = false;\n\t\t#endif\n        LOG_FATAL << errorMessage;\n        Util::Dialogs::showError(errorMessage, richError);\n        exit(1);\n    }\n\n    LOG_INFO << \"Couldn't find an FRequest config file. A new config file was created.\";\n\n}\n\nvoid ConfigFileFRequest::saveSettings(ConfigFileFRequest::Settings &newSettings){\n    try\n    {\n        pugi::xml_document doc;\n\n        doc.load_file(QSTR_TO_TEMPORARY_CSTR(this->fileFullPath));\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        generalNode.attribute(\"requestTimeout\").set_value(newSettings.requestTimeout);\n\t\tgeneralNode.attribute(\"maxRequestResponseDataSizeToDisplay\").set_value(newSettings.maxRequestResponseDataSizeToDisplay);\n        generalNode.attribute(\"onStartupOption\").set_value(static_cast<int>(newSettings.onStartupSelectedOption));\n\t\tgeneralNode.attribute(\"theme\").set_value(static_cast<int>(newSettings.theme));\n        generalNode.attribute(\"lastProjectPath\").set_value(QSTR_TO_TEMPORARY_CSTR(newSettings.lastProjectPath));\n        generalNode.attribute(\"lastResponseFilePath\").set_value(QSTR_TO_TEMPORARY_CSTR(newSettings.lastResponseFilePath));\n        generalNode.attribute(\"showRequestTypesIcons\").set_value(newSettings.showRequestTypesIcons);\n        generalNode.attribute(\"hideProjectSavedDialog\").set_value(newSettings.hideProjectSavedDialog);\n\n        pugi::xml_node recentProjectsNode = doc.select_single_node(\"/FRequestConfig/RecentProjects\").node();\n\n        for(int i=1; i<=GlobalVars::AppRecentProjectsMaxSize && newSettings.recentProjectsPaths.size() >= i; i++){\n            recentProjectsNode.child(QSTR_TO_TEMPORARY_CSTR(\"RecentProject\" + QString::number(i))).text().set(QSTR_TO_TEMPORARY_CSTR(newSettings.recentProjectsPaths.at(i-1)));\n        }\n\n        pugi::xml_node proxyNode = doc.select_single_node(\"/FRequestConfig/Proxy\").node();\n\n        proxyNode.attribute(\"useProxy\").set_value(newSettings.useProxy);\n        proxyNode.attribute(\"proxyType\").set_value(static_cast<int>(newSettings.proxySettings.type));\n        proxyNode.attribute(\"hostName\").set_value(QSTR_TO_TEMPORARY_CSTR(newSettings.proxySettings.hostName));\n        proxyNode.attribute(\"port\").set_value(newSettings.proxySettings.portNumber);\n\n        pugi::xml_node windowsGeometryNode = doc.select_single_node(\"/FRequestConfig/WindowsGeometry\").node();\n\n        windowsGeometryNode.attribute(\"saveWindowsGeometryWhenExiting\").set_value(newSettings.windowsGeometry.saveWindowsGeometryWhenExiting);\n\n        pugi::xml_node mainWindowNode = windowsGeometryNode.child(\"MainWindow\");\n\n        mainWindowNode.child(\"MainWindowGeometry\").text().set(QSTR_TO_TEMPORARY_CSTR(QString(newSettings.windowsGeometry.mainWindow_MainWindowGeometry.toBase64())));\n        mainWindowNode.child(\"RequestsSplitterState\").text().set(QSTR_TO_TEMPORARY_CSTR(QString(newSettings.windowsGeometry.mainWindow_RequestsSplitterState.toBase64())));\n        mainWindowNode.child(\"RequestResponseSplitterState\").text().set(QSTR_TO_TEMPORARY_CSTR(QString(newSettings.windowsGeometry.mainWindow_RequestResponseSplitterState.toBase64())));\n\n        pugi::xml_node defaultHeadersNode = doc.select_single_node(\"/FRequestConfig/DefaultHeaders\").node();\n\n        defaultHeadersNode.attribute(\"useDefaultHeaders\").set_value(newSettings.defaultHeaders.useDefaultHeaders);\n\n        auto fUpdateHeaders = [](pugi::xml_node &currentHeaderNode, const QVector<UtilFRequest::HttpHeader> &headers, const char *nodeName){\n\n            // Remove current Headers to update with new ones\n            currentHeaderNode.remove_child(nodeName);\n            pugi::xml_node rawNode = currentHeaderNode.append_child(nodeName);\n\n            for(const UtilFRequest::HttpHeader &currentHeader : headers){\n                pugi::xml_node headerNode = rawNode.append_child(\"Header\");\n                headerNode.append_child(\"Key\").append_child(pugi::xml_node_type::node_cdata).text().set(QSTR_TO_TEMPORARY_CSTR(currentHeader.name));\n                headerNode.append_child(\"Value\").append_child(pugi::xml_node_type::node_cdata).text().set(QSTR_TO_TEMPORARY_CSTR(currentHeader.value));\n            }\n        };\n\n        auto fWriteRequestType = [&fUpdateHeaders, &defaultHeadersNode](const QString &requestText, const std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &requestHeaders, const bool hasBody){\n            if(requestHeaders.has_value()){\n\n                pugi::xml_node currentHeaderNode = defaultHeadersNode.child(QSTR_TO_TEMPORARY_CSTR(requestText));\n\n                if(currentHeaderNode.empty()){\n                    currentHeaderNode = defaultHeadersNode.append_child(QSTR_TO_TEMPORARY_CSTR(requestText));\n                }\n\n                if(requestHeaders.value().headers_Raw.has_value()){\n                    fUpdateHeaders(currentHeaderNode, requestHeaders.value().headers_Raw.value(), \"Raw\");\n                }\n\n                if(hasBody){\n                    if(requestHeaders.value().headers_Form_Data.has_value()){\n                        fUpdateHeaders(currentHeaderNode, requestHeaders.value().headers_Form_Data.value(), \"Form-data\");\n                    }\n\n                    if(requestHeaders.value().headers_X_form_www_urlencoded.has_value()){\n                        fUpdateHeaders(currentHeaderNode, requestHeaders.value().headers_X_form_www_urlencoded.value(), \"X-form-www-urlencoded\");\n                    }\n                }\n\n            }\n        };\n\n        for(const UtilFRequest::RequestType &currentRequestType : UtilFRequest::possibleRequestTypes){\n            QString currentRequestTypeText = UtilFRequest::getRequestTypeString(currentRequestType);\n            bool hasBody = UtilFRequest::requestTypeMayHaveBody(currentRequestType);\n            const std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &requestHeaders = getSettingsHeaderForRequestType(currentRequestType, newSettings);\n\n            fWriteRequestType(currentRequestTypeText, requestHeaders, hasBody);\n        }\n\n        // Remove current config authentications (if they exist), since we will write all of them again\n        doc.select_single_node(\"/FRequestConfig\").node().remove_child(\"ConfigProjectAuthentications\");\n\n        pugi::xml_node configAuthNode = doc.select_single_node(\"/FRequestConfig\").node().append_child(\"ConfigProjectAuthentications\");\n\n        for(const ConfigurationProjectAuthentication &currentConfigAuth : newSettings.mapOfConfigAuths_UuidToConfigAuth){\n\n            const FRequestAuthentication &authData = *currentConfigAuth.authData;\n\n            pugi::xml_node currentAuth = configAuthNode.append_child(\"Authentication\");\n            currentAuth.append_attribute(\"lastProjectName\").set_value(QSTR_TO_TEMPORARY_CSTR(currentConfigAuth.lastProjectName));\n            currentAuth.append_attribute(\"projectUuid\").set_value(QSTR_TO_TEMPORARY_CSTR(currentConfigAuth.projectUuid));\n            currentAuth.append_attribute(\"type\").set_value(static_cast<int>(authData.type));\n            currentAuth.append_attribute(\"bRetryLoginIfError\").set_value(authData.retryLoginIfError401);\n\n            switch(authData.type){\n            case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n            {\n                const RequestAuthentication &requestAuth = static_cast<const RequestAuthentication&>(authData);\n\n                currentAuth.append_attribute(\"requestUuid\").set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.requestForAuthenticationUuid));\n                currentAuth.append_child(\"Username\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.username));\n                currentAuth.append_child(\"PasswordSalt\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.passwordSalt));\n                currentAuth.append_child(\"Password\").append_child(pugi::xml_node_type::node_pcdata).\n                        set_value(QSTR_TO_TEMPORARY_CSTR(QString(UtilFRequest::simpleStringObfuscationDeobfuscation(requestAuth.passwordSalt, requestAuth.password).toBase64())));\n                break;\n            }\n            case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n            {\n                const BasicAuthentication &basicAuth = static_cast<const BasicAuthentication&>(authData);\n                currentAuth.append_child(\"Username\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(basicAuth.username));\n                currentAuth.append_child(\"PasswordSalt\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(basicAuth.passwordSalt));\n                currentAuth.append_child(\"Password\").append_child(pugi::xml_node_type::node_pcdata).\n                        set_value(QSTR_TO_TEMPORARY_CSTR(QString(UtilFRequest::simpleStringObfuscationDeobfuscation(basicAuth.passwordSalt, basicAuth.password).toBase64())));\n\n                break;\n            }\n            default:\n            {\n                QString errorMessage = \"Authentication type unknown: '\" + QString::number(static_cast<int>(authData.type)) + \"'. Program can't proceed.\";\n                Util::Dialogs::showError(errorMessage);\n                LOG_FATAL << errorMessage;\n                exit(1);\n            }\n            }\n        }\n        if(!doc.save_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath), PUGIXML_TEXT(\"\\t\"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n            throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Error while saving: '\" + fileFullPath + \"'\"));\n        }\n    }\n    catch(const std::exception &e)\n    {\n        QString errorMessage = \"An error ocurred while saving the FRequest settings. Settings were not saved.\" + QString(e.what());\n        LOG_ERROR << errorMessage;\n        Util::Dialogs::showError(errorMessage);\n    }\n\n    this->currentSettings = newSettings;\n}\n\nvoid ConfigFileFRequest::readSettingsFromFile(){\n    try\n    {\n        upgradeConfigFileIfNecessary();\n\n        pugi::xml_document doc;\n\n        doc.load_file(QSTR_TO_TEMPORARY_CSTR(this->fileFullPath));\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        this->currentSettings.requestTimeout = generalNode.attribute(\"requestTimeout\").as_uint();\n\t\tthis->currentSettings.maxRequestResponseDataSizeToDisplay = generalNode.attribute(\"maxRequestResponseDataSizeToDisplay\").as_uint();\n        this->currentSettings.onStartupSelectedOption = static_cast<OnStartupOption>(generalNode.attribute(\"onStartupOption\").as_int());\n\t\tthis->currentSettings.theme = static_cast<FRequestTheme>(generalNode.attribute(\"theme\").as_int());\n        this->currentSettings.lastProjectPath = generalNode.attribute(\"lastProjectPath\").as_string();\n        this->currentSettings.lastResponseFilePath = generalNode.attribute(\"lastResponseFilePath\").as_string();\n        this->currentSettings.showRequestTypesIcons = generalNode.attribute(\"showRequestTypesIcons\").as_bool();\n        this->currentSettings.hideProjectSavedDialog = generalNode.attribute(\"hideProjectSavedDialog\").as_bool();\n\n        pugi::xml_node recentProjectsNode = doc.select_single_node(\"/FRequestConfig/RecentProjects\").node();\n\n        this->currentSettings.recentProjectsPaths.clear();\n\n        for(int i=1; i<=GlobalVars::AppRecentProjectsMaxSize; i++){\n            if(!recentProjectsNode.child(QSTR_TO_TEMPORARY_CSTR(\"RecentProject\" + QString::number(i))).empty()){\n                if(!QString(recentProjectsNode.child(QSTR_TO_TEMPORARY_CSTR(\"RecentProject\" + QString::number(i))).text().as_string()).isEmpty()){\n                    this->currentSettings.recentProjectsPaths.append(recentProjectsNode.child(QSTR_TO_TEMPORARY_CSTR(\"RecentProject\" + QString::number(i))).text().as_string());\n                }\n            }\n        }\n\n        pugi::xml_node proxyNode = doc.select_single_node(\"/FRequestConfig/Proxy\").node();\n\n        this->currentSettings.useProxy = proxyNode.attribute(\"useProxy\").as_bool(false);\n        this->currentSettings.proxySettings.type = static_cast<ProxyType>(proxyNode.attribute(\"proxyType\").as_int(0));\n        this->currentSettings.proxySettings.hostName = proxyNode.attribute(\"hostName\").as_string();\n        this->currentSettings.proxySettings.portNumber = proxyNode.attribute(\"port\").as_uint(0);\n\n        pugi::xml_node windowsGeometryNode = doc.select_single_node(\"/FRequestConfig/WindowsGeometry\").node();\n\n        this->currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting = windowsGeometryNode.attribute(\"saveWindowsGeometryWhenExiting\").as_bool();\n\n        pugi::xml_node mainWindowNode = windowsGeometryNode.child(\"MainWindow\");\n\n        auto fReadBase64Setting = [&mainWindowNode](const char * const node) -> QByteArray{\n            QByteArray auxBase64Decode;\n            auxBase64Decode.append(QString(mainWindowNode.child(node).text().as_string()).toUtf8());\n\n            return QByteArray::fromBase64(auxBase64Decode);\n        };\n\n        this->currentSettings.windowsGeometry.mainWindow_MainWindowGeometry = fReadBase64Setting(\"MainWindowGeometry\");\n        this->currentSettings.windowsGeometry.mainWindow_RequestsSplitterState = fReadBase64Setting(\"RequestsSplitterState\");\n        this->currentSettings.windowsGeometry.mainWindow_RequestResponseSplitterState = fReadBase64Setting(\"RequestResponseSplitterState\");\n\n        pugi::xml_node defaultHeadersNode = doc.select_single_node(\"/FRequestConfig/DefaultHeaders\").node();\n\n        this->currentSettings.defaultHeaders.useDefaultHeaders = defaultHeadersNode.attribute(\"useDefaultHeaders\").as_bool();\n\n        auto fReadHeaders = [](UtilFRequest::BodyType bodyType, std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &requestHeaders, pugi::xml_node &currentHeaderNode){\n\n            QString nodeName;\n\n            switch(bodyType){\n            case UtilFRequest::BodyType::RAW:\n                nodeName = \"Raw\";\n                break;\n            case UtilFRequest::BodyType::FORM_DATA:\n                nodeName = \"Form-data\";\n                break;\n            case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\n                nodeName = \"X-form-www-urlencoded\";\n                break;\n            default:\n                throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Unknown body type \" + QString::number(static_cast<int>(bodyType))));\n            }\n\n            for(const pugi::xml_node &currentNode : currentHeaderNode.child(QSTR_TO_TEMPORARY_CSTR(nodeName)).children()){\n\n                if(!requestHeaders.has_value()){\n                    requestHeaders = ProtocolHeader();\n                }\n\n                std::experimental::optional<QVector<UtilFRequest::HttpHeader>> *currentHeaders;\n\n                switch(bodyType){\n                case UtilFRequest::BodyType::RAW:\n                    currentHeaders = &requestHeaders.value().headers_Raw;\n                    break;\n                case UtilFRequest::BodyType::FORM_DATA:\n                    currentHeaders = &requestHeaders.value().headers_Form_Data;\n                    break;\n                case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\n                    currentHeaders = &requestHeaders.value().headers_X_form_www_urlencoded;\n                    break;\n                default:\n                    throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Unknown body type \" + QString::number(static_cast<int>(bodyType))));\n                }\n\n                if(!currentHeaders->has_value()){\n                    (*currentHeaders) = QVector<UtilFRequest::HttpHeader>();\n                }\n\n                UtilFRequest::HttpHeader currentHeader;\n                currentHeader.name = currentNode.child(\"Key\").text().as_string();\n                currentHeader.value = currentNode.child(\"Value\").text().as_string();\n\n                (*currentHeaders).value().append(currentHeader);\n            }\n        };\n\n        auto fReadRequestType = [&defaultHeadersNode, &fReadHeaders](const QString &requestText, std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &requestHeaders, const bool hasBody){\n\n            pugi::xml_node currentHeaderNode = defaultHeadersNode.child(QSTR_TO_TEMPORARY_CSTR(requestText));\n\n            if(!currentHeaderNode.empty()){\n\n                if(!requestHeaders.has_value()){\n                    requestHeaders = ProtocolHeader();\n                }\n\n                if(!currentHeaderNode.child(\"Raw\").empty()){\n                    fReadHeaders(UtilFRequest::BodyType::RAW, requestHeaders, currentHeaderNode);\n                }\n\n                if(hasBody){\n                    if(!currentHeaderNode.child(\"Form-data\").empty()){\n                        fReadHeaders(UtilFRequest::BodyType::FORM_DATA, requestHeaders, currentHeaderNode);\n                    }\n\n                    if(!currentHeaderNode.child(\"X-form-www-urlencoded\").empty()){\n                        fReadHeaders(UtilFRequest::BodyType::X_FORM_WWW_URLENCODED, requestHeaders, currentHeaderNode);\n                    }\n                }\n            }\n        };\n\n        for(const UtilFRequest::RequestType &currentRequestType : UtilFRequest::possibleRequestTypes){\n            QString currentRequestTypeText = UtilFRequest::getRequestTypeString(currentRequestType);\n            bool hasBody = UtilFRequest::requestTypeMayHaveBody(currentRequestType);\n            std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &requestHeaders = getSettingsHeaderForRequestType(currentRequestType, this->currentSettings);\n\n            fReadRequestType(currentRequestTypeText, requestHeaders, hasBody);\n        }\n\n        // Check if there is authentication data and load it\n        pugi::xpath_node_set configAuthNodes = doc.select_nodes(\"/FRequestConfig/ConfigProjectAuthentications/Authentication\");\n\n        for(const pugi::xpath_node &currXPathNode : configAuthNodes){\n\n            pugi::xml_node currAuthNode = currXPathNode.node();\n            ConfigurationProjectAuthentication currProjAuth;\n            currProjAuth.lastProjectName = currAuthNode.attribute(\"lastProjectName\").value();\n            currProjAuth.projectUuid = currAuthNode.attribute(\"projectUuid\").value();\n\n            FRequestAuthentication::AuthenticationType authType =\n                    static_cast<FRequestAuthentication::AuthenticationType>(currAuthNode.attribute(\"type\").as_int());\n\n            const bool retryLoginIfError401 = currAuthNode.attribute(\"bRetryLoginIfError\").as_bool();\n\n            switch(authType){\n            case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n            {\n                QString username = currAuthNode.child(\"Username\").child_value();\n                QString passwordSalt = currAuthNode.child(\"PasswordSalt\").child_value();\n                QString password = QString(UtilFRequest::simpleStringObfuscationDeobfuscation(passwordSalt,\n                                                                                              QByteArray::fromBase64(currAuthNode.child(\"Password\").child_value())));\n                QString requestUuid = currAuthNode.attribute(\"requestUuid\").value();\n\n                currProjAuth.authData = std::make_shared<RequestAuthentication>(RequestAuthentication(true, retryLoginIfError401, username, passwordSalt, password, requestUuid));\n                break;\n            }\n            case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n            {\n                QString username = currAuthNode.child(\"Username\").child_value();\n                QString passwordSalt = currAuthNode.child(\"PasswordSalt\").child_value();\n                QString password = QString(UtilFRequest::simpleStringObfuscationDeobfuscation(passwordSalt,\n                                                                                              QByteArray::fromBase64(currAuthNode.child(\"Password\").child_value())));\n\n                currProjAuth.authData = std::make_shared<BasicAuthentication>(BasicAuthentication(true, retryLoginIfError401, username, passwordSalt, password));\n                break;\n            }\n            default:\n            {\n                QString errorMessage = \"Authentication type unknown: '\" + QString::number(static_cast<int>(authType)) + \"'. Program can't proceed.\";\n                Util::Dialogs::showError(errorMessage);\n                LOG_FATAL << errorMessage;\n                exit(1);\n            }\n            }\n\n            this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.insert(currProjAuth.projectUuid, currProjAuth);\n        }\n\n        if(!doc.save_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath), PUGIXML_TEXT(\"\\t\"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n            throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Error while saving: '\" + fileFullPath + \"'\"));\n        }\n    }\n    catch(const std::exception &e)\n    {\n        QString errorMessage = \"An error ocurred while loading the FRequest settings. Settings were not loaded. \" + QString(e.what());\n        LOG_ERROR << errorMessage;\n        Util::Dialogs::showError(errorMessage);\n    }\n}\n\nConfigFileFRequest::Settings ConfigFileFRequest::getCurrentSettings(){\n    return this->currentSettings;\n}\n\nstd::experimental::optional<ConfigFileFRequest::ProtocolHeader>& ConfigFileFRequest::getSettingsHeaderForRequestType(UtilFRequest::RequestType currentRequestType, Settings &currentSettings){\n\n    std::experimental::optional<ProtocolHeader> *currentProtocolHeader = nullptr;\n\n    switch(currentRequestType){\n    case UtilFRequest::RequestType::GET_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.getHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::POST_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.postHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::PUT_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.putHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::DELETE_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.deleteHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::PATCH_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.patchHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::HEAD_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.headHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::TRACE_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.traceHeaders;\n        break;\n    }\n    case UtilFRequest::RequestType::OPTIONS_OPTION:\n    {\n        currentProtocolHeader = &currentSettings.defaultHeaders.optionsHeaders;\n        break;\n    }\n    default:\n    {\n        QString errorMessage = \"Request type unknown: '\" + QString::number(static_cast<int>(currentRequestType)) + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n\n    return *currentProtocolHeader;\n}\n\nvoid ConfigFileFRequest::upgradeConfigFileIfNecessary(){\n\n    pugi::xml_document doc;\n\n    pugi::xml_parse_result result = doc.load_file(QSTR_TO_TEMPORARY_CSTR(this->fileFullPath));\n\n    if(result.status!=pugi::status_ok){\n        throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(\"An error ocurred while loading project file.\\n\") + result.description()));\n    }\n\n    QString currentConfigVersion = QString(doc.select_single_node(\"/FRequestConfig\").node().attribute(\"frequestVersion\").as_string());\n\n    if(currentConfigVersion != GlobalVars::LastCompatibleVersionConfig){\n        if(!Util::FileSystem::backupFile(this->fileFullPath, this->fileFullPath + UtilFRequest::getDateTimeFormatForFilename(QDateTime::currentDateTime()))){\n            QString errorMessage = \"Couldn't backup the existing config file for version upgrade, program can't proceed.\";\n            Util::Dialogs::showError(errorMessage);\n            LOG_FATAL << errorMessage;\n            exit(1);\n        }\n    }\n\t\n    auto fUpgradeFileIfNecessary = [&doc, fileFullPath = this->fileFullPath, &currentConfigVersion](\n            const QString &oldVersion,\n            const QString &newVersion,\n            std::function<void()> upgradeFunction){\n\n        // Upgrade necessary?\n        if(currentConfigVersion == oldVersion){\n\n            // Update version\n            doc.select_single_node(\"/FRequestConfig\").node().attribute(\"frequestVersion\").set_value(QSTR_TO_TEMPORARY_CSTR(newVersion));\n\n            // do specific upgrade changes\n            upgradeFunction();\n\n            if(!doc.save_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath), PUGIXML_TEXT(\"\\t\"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n                throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Error while saving: '\" + fileFullPath + \"'. After file version upgrade. (to version \" + newVersion + \" )\"));\n            }\n\n            currentConfigVersion = newVersion;\n        }\n\n    };\n\t\n    fUpgradeFileIfNecessary(\"1.0\", \"1.1\", [&](){\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        generalNode.append_attribute(\"showRequestTypesIcons\").set_value(true);\n\n        // Fix proxy node (it should start with upper case instead of lower case\n\n        pugi::xml_node proxyNode = doc.select_single_node(\"/FRequestConfig/proxy\").node();\n\n        if(!proxyNode.empty()){\n            proxyNode.set_name(\"Proxy\");\n        }\n\n    });\n\n    fUpgradeFileIfNecessary(\"1.1\", \"1.1a\", [&](){\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        // Delete old attribute 'askToOpenLastProject'\n        pugi::xml_attribute askToOpenLastProjectAttribute = generalNode.attribute(\"askToOpenLastProject\");\n\n        if(!askToOpenLastProjectAttribute.empty()){\n            generalNode.remove_attribute(askToOpenLastProjectAttribute);\n        }\n\n        // Add new attribute that replaces 'askToOpenLastProject'\n\n        // use ASK_TO_LOAD_LAST_PROJECT as default\n        generalNode.append_attribute(\"onStartupOption\").set_value(\"0\"); // 0 = ASK_TO_LOAD_LAST_PROJECT in 1.1a\n\n        // Add new attribute that specifies the max response size for display in ui\n        generalNode.append_attribute(\"maxRequestResponseDataSizeToDisplay\").set_value(200); // 200 kb default\n\n    });\n\n    fUpgradeFileIfNecessary(\"1.1a\", \"1.1b\", [&](){\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        // Add new attribute for themes\n        generalNode.append_attribute(\"theme\").set_value(\"0\"); // 0 = OS_DEFAULT in 1.1b\n\n    });\n\n    fUpgradeFileIfNecessary(\"1.1b\", \"1.2\", [&](){\n\n        pugi::xml_node generalNode = doc.select_single_node(\"/FRequestConfig/General\").node();\n\n        generalNode.append_attribute(\"hideProjectSavedDialog\").set_value(false);\n\n    });\n\t\n    if(currentConfigVersion != GlobalVars::LastCompatibleVersionConfig){\n        throw std::runtime_error(\"Can't load the config file, it is from an incompatible version. Probably newer?\");\n    }\n}\n\nConfigFileFRequest::FRequestTheme ConfigFileFRequest::geFRequestThemeByString(const QString &currentFRequestThemeText){\n\n    if(currentFRequestThemeText == \"OS Default\"){\n        return FRequestTheme::OS_DEFAULT;\n    }\n    else if(currentFRequestThemeText == \"Jorgen's Dark Theme\"){\n        return FRequestTheme::JORGEN_DARK_THEME;\n    }\n    else{\n        QString errorMessage = \"FRequestTheme unknown: '\" + currentFRequestThemeText + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n}\n\nQString ConfigFileFRequest::getFRequestThemeString(const FRequestTheme currentFRequestTheme){\n\n    switch(currentFRequestTheme){\n    case FRequestTheme::OS_DEFAULT:\n        return \"OS Default\";\n    case FRequestTheme::JORGEN_DARK_THEME:\n        return \"Jorgen's Dark Theme\";\n    default:\n    {\n        QString errorMessage = \"Invalid FRequestTheme \" + QString::number(static_cast<int>(currentFRequestTheme)) + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n}\n"
  },
  {
    "path": "XmlParsers/configfilefrequest.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef CONFIGFILEFREQUEST_H\n#define CONFIGFILEFREQUEST_H\n\n#include \"utilfrequest.h\"\n#include \"Authentications/requestauthentication.h\"\n#include \"Authentications/basicauthentication.h\"\n\n#include <memory>\n\nclass ConfigFileFRequest\n{\npublic:\n\n    enum class ProxyType{\n        AUTOMATIC = 0,\n        HTTP_TRANSPARENT = 1,\n        HTTP = 2,\n        SOCKS5 = 3\n    };\n\n    enum class OnStartupOption{\n        ASK_TO_LOAD_LAST_PROJECT = 0,\n        LOAD_LAST_PROJECT = 1,\n\t\tDO_NOTHING = 100\n    };\n\t\n\tenum class FRequestTheme{\n\t\tOS_DEFAULT = 0,\n\t\tJORGEN_DARK_THEME = 1\n\t};\n\n    struct ProtocolHeader{\n        std::experimental::optional<QVector<UtilFRequest::HttpHeader>> headers_Raw;\n        std::experimental::optional<QVector<UtilFRequest::HttpHeader>> headers_Form_Data;\n        std::experimental::optional<QVector<UtilFRequest::HttpHeader>> headers_X_form_www_urlencoded;\n    };\n\n    struct DefaultHeaders{\n        bool useDefaultHeaders = false;\n        std::experimental::optional<ProtocolHeader> getHeaders;\n        std::experimental::optional<ProtocolHeader> postHeaders;\n        std::experimental::optional<ProtocolHeader> putHeaders;\n        std::experimental::optional<ProtocolHeader> deleteHeaders;\n        std::experimental::optional<ProtocolHeader> patchHeaders;\n        std::experimental::optional<ProtocolHeader> headHeaders;\n        std::experimental::optional<ProtocolHeader> traceHeaders;\n        std::experimental::optional<ProtocolHeader> optionsHeaders;\n    };\n\n    struct WindowsGeometry{\n        bool saveWindowsGeometryWhenExiting = false;\n        QByteArray mainWindow_MainWindowGeometry;\n        QByteArray mainWindow_RequestsSplitterState;\n        QByteArray mainWindow_RequestResponseSplitterState;\n    };\n\n    struct ProxySettings{\n        ProxyType type = ProxyType::AUTOMATIC;\n        QString hostName;\n        unsigned int portNumber = 0;\n    };\n\n\tstruct ConfigurationProjectAuthentication{\n\t\tQString lastProjectName;\n\t\tQString projectUuid;\n        std::shared_ptr<FRequestAuthentication> authData; // using shared ptr just to not be obligated to initialize all members at same time\n\t};\n\t\n    struct Settings{\n        unsigned int requestTimeout = 20;\n\t\tunsigned int maxRequestResponseDataSizeToDisplay = 200;\n        OnStartupOption onStartupSelectedOption = OnStartupOption::ASK_TO_LOAD_LAST_PROJECT;\n\t\tFRequestTheme theme = FRequestTheme::OS_DEFAULT;\n        QString lastProjectPath;\n        QString lastResponseFilePath;\n        bool showRequestTypesIcons = true;\n        QVector<QString> recentProjectsPaths;\n        WindowsGeometry windowsGeometry;\n        DefaultHeaders defaultHeaders;\n        bool useProxy = false;\n        ProxySettings proxySettings;\n\t\t// the hash map below contains the authentication data of the projects that specified it to be saved on config file instead of in project file\n\t\tQHash<QString, ConfigurationProjectAuthentication> mapOfConfigAuths_UuidToConfigAuth;\n        bool hideProjectSavedDialog = false;\n    };\n\npublic:\n    ConfigFileFRequest(const QString &fileFullPath);\n    ConfigFileFRequest::Settings getCurrentSettings();\n    void saveSettings(Settings &newSettings);\n    static std::experimental::optional<ProtocolHeader>& getSettingsHeaderForRequestType(UtilFRequest::RequestType currentRequestType, Settings &currentSettings);\n\tstatic FRequestTheme geFRequestThemeByString(const QString &currentFRequestThemeText);\n\tstatic QString getFRequestThemeString(const FRequestTheme currentFRequestTheme);\nprivate:\n    void createNewConfig();\n    void readSettingsFromFile();\n    void upgradeConfigFileIfNecessary();\nprivate:\n    Settings currentSettings;\n    const QString fileFullPath;\n};\n\n#endif // CONFIGFILEFREQUEST_H\n"
  },
  {
    "path": "XmlParsers/projectfilefrequest.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"projectfilefrequest.h\"\n\nProjectFileFRequest::ProjectData ProjectFileFRequest::readProjectDataFromFile(const QString &fileFullPath){\n\n    ProjectFileFRequest::ProjectData currentProjectData;\n\n    upgradeProjectFileIfNecessary(fileFullPath);\n\n    pugi::xml_document doc;\n\n    pugi::xml_parse_result result = doc.load_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath));\n\n    if(result.status!=pugi::status_ok){\n        throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(\"An error ocurred while loading project file.\\n\") + result.description()));\n    }\n\n    if(QString(doc.root().first_child().name()) != \"FRequestProject\"){\n        throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(doc.root().name()) + \"The file opened is not a valid FRequestProject file. Load aborted.\"));\n    }\n\n    QString projFRequestVersion;\n\n    try{\n        projFRequestVersion = QString(doc.select_node(\"/FRequestProject/@frequestVersion\").attribute().value());\n    }\n    catch (const pugi::xpath_exception& e)\n    {\n        throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(\"Couldn't find the frequestVersion of the current project. Load aborted.\\n\") + e.what()));\n    }\n\n    if(projFRequestVersion != GlobalVars::LastCompatibleVersionProjects){\n        throw std::runtime_error(\"The project that you are trying to load seems it is not compatible with your FRequest Version. Please update FRequest and try again.\");\n    }\n\n    // After the initial validations begin loading the project data\n\n    currentProjectData.mainUrl = doc.select_node(\"/FRequestProject/@mainUrl\").attribute().value();\n    currentProjectData.projectName = doc.select_node(\"/FRequestProject/@name\").attribute().value();\n    currentProjectData.projectUuid = doc.select_node(\"/FRequestProject/@uuid\").attribute().value();\n    currentProjectData.saveIdentCharacter = static_cast<UtilFRequest::IdentCharacter>(doc.select_node(\"/FRequestProject/@saveIdentCharacter\").attribute().as_int());\n\n    // Check if there is authentication data and load it\n    pugi::xml_node authNode = doc.select_node(\"/FRequestProject/Authentication\").node();\n\n    if(!authNode.empty()){\n        FRequestAuthentication::AuthenticationType authType =\n                static_cast<FRequestAuthentication::AuthenticationType>(authNode.attribute(\"type\").as_int());\n\n        const bool retryLoginIfError401 = authNode.attribute(\"bRetryLoginIfError\").as_bool();\n\n        switch(authType){\n        case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n        {\n            QString username = authNode.child(\"Username\").child_value();\n            QString passwordSalt = authNode.child(\"PasswordSalt\").child_value();\n            QString password = QString(UtilFRequest::simpleStringObfuscationDeobfuscation(passwordSalt,\n                                                                                          QByteArray::fromBase64(authNode.child(\"Password\").child_value())));\n            QString requestUuid = authNode.attribute(\"requestUuid\").value();\n\n            currentProjectData.authData = std::make_shared<RequestAuthentication>(RequestAuthentication(false, retryLoginIfError401, username, passwordSalt, password, requestUuid));\n\n            break;\n        }\n        case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n        {\n            QString username = authNode.child(\"Username\").child_value();\n            QString passwordSalt = authNode.child(\"PasswordSalt\").child_value();\n            QString password = QString(UtilFRequest::simpleStringObfuscationDeobfuscation(passwordSalt,\n                                                                                          QByteArray::fromBase64(authNode.child(\"Password\").child_value())));\n\n            currentProjectData.authData = std::make_shared<BasicAuthentication>(BasicAuthentication(false, retryLoginIfError401, username, passwordSalt, password));\n            break;\n        }\n        default:\n        {\n            QString errorMessage = \"Authentication type unknown: '\" + QString::number(static_cast<int>(authType)) + \"'. Program can't proceed.\";\n            Util::Dialogs::showError(errorMessage);\n            LOG_FATAL << errorMessage;\n            exit(1);\n        }\n        }\n    }\n\n    // Fetch request items\n    pugi::xpath_node_set requestNodes = doc.select_nodes(\"/FRequestProject/Request\");\n\n    // Aux lambda to avoid duplicated code for FORM_DATA / X_FORM_WWW_URLENCODED\n    auto fGetBodyForm = [](pugi::xml_node &bodyNode) -> QVector<UtilFRequest::HttpFormKeyValueType>\n    {\n        QVector<UtilFRequest::HttpFormKeyValueType> bodyForm;\n\n        for(const pugi::xml_node &currentFormKeyValueNode : bodyNode.children()){\n            UtilFRequest::HttpFormKeyValueType currentFormKeyValue\n                    (\n                        currentFormKeyValueNode.child(\"Key\").child_value(),\n                        currentFormKeyValueNode.child(\"Value\").child_value(),\n                        static_cast<UtilFRequest::FormKeyValueType>(QString(currentFormKeyValueNode.child(\"Type\").child_value()).toInt()) // TODO check if pugixml has any method do retreive int directly for elements / pcdata\n                        );\n\n            bodyForm.append(currentFormKeyValue);\n        }\n\n        return bodyForm;\n    };\n\n    for(size_t i=0; i < requestNodes.size(); i++){\n\n        pugi::xml_node currNode = requestNodes[i].node();\n\n        UtilFRequest::RequestInfo currentRequestInfo;\n\n        currentRequestInfo.path = currNode.attribute(\"path\").as_string();\n        currentRequestInfo.requestType = static_cast<UtilFRequest::RequestType>(currNode.attribute(\"type\").as_int());\n\n        pugi::xml_node bodyNode = currNode.child(\"Body\");\n\n        currentRequestInfo.bodyType = static_cast<UtilFRequest::BodyType>(bodyNode.attribute(\"type\").as_int());\n\n        switch (currentRequestInfo.bodyType) {\n        case UtilFRequest::BodyType::RAW:\n        {\n            currentRequestInfo.body = bodyNode.child_value();\n            break;\n        }\n        case UtilFRequest::BodyType::FORM_DATA:\n        {\n            currentRequestInfo.bodyForm = fGetBodyForm(bodyNode);\n            break;\n        }\n        case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\n        {\n            currentRequestInfo.bodyForm = fGetBodyForm(bodyNode);\n            break;\n        }\n        default:\n        {\n            break;\n        }\n        }\n\n        QVector<UtilFRequest::HttpHeader> requestHeaders;\n\n        for(const pugi::xml_node &currentHeaderNode : currNode.child(\"Headers\").children()){\n            UtilFRequest::HttpHeader currentRequestHeader;\n\n            currentRequestHeader.name = QString(currentHeaderNode.child(\"Key\").child_value());\n            currentRequestHeader.value = currentHeaderNode.child(\"Value\").child_value();\n\n            requestHeaders.append(currentRequestHeader);\n        }\n\n        currentRequestInfo.headers = requestHeaders;\n\n        currentRequestInfo.bOverridesMainUrl = currNode.attribute(\"bOverridesMainUrl\").as_bool();\n        currentRequestInfo.overrideMainUrl = currNode.attribute(\"overrideMainUrl\").value();\n        currentRequestInfo.bDownloadResponseAsFile = currNode.attribute(\"bDownloadResponseAsFile\").as_bool();\n        currentRequestInfo.name = requestNodes[i].node().attribute(\"name\").value();\n        currentRequestInfo.uuid = requestNodes[i].node().attribute(\"uuid\").value();\n        currentRequestInfo.order = requestNodes[i].node().attribute(\"order\").as_ullong();\n        currentRequestInfo.bDisableGlobalHeaders = currNode.attribute(\"bDisableGlobalHeaders\").as_bool();\n\n        currentProjectData.projectRequests.append(currentRequestInfo);\n    }\n\n    pugi::xml_node globalHeadersNode = doc.select_node(\"/FRequestProject/GlobalHeaders\").node();\n\n    QVector<UtilFRequest::HttpHeader> globalHeaders;\n\n    for(const pugi::xml_node &currentGlobalHeaderNode : globalHeadersNode.children()){\n        UtilFRequest::HttpHeader currentGlobalHeader;\n\n        currentGlobalHeader.name = QString(currentGlobalHeaderNode.child(\"Key\").child_value());\n        currentGlobalHeader.value = currentGlobalHeaderNode.child(\"Value\").child_value();\n\n        globalHeaders.append(currentGlobalHeader);\n    }\n    currentProjectData.globalHeaders = globalHeaders;\n\n    return currentProjectData;\n}\n\nvoid ProjectFileFRequest::saveProjectDataToFile(const QString &fileFullPath, const ProjectFileFRequest::ProjectData &newProjectData, const QVector<QString> &uuidsToCleanUp){\n    pugi::xml_document doc;\n    pugi::xml_node rootNode;\n\n    bool isNewFile = !QFileInfo(fileFullPath).exists();\n\n    // If file already exists try to read the project file\n    if(!isNewFile){\n\n        pugi::xml_parse_result result = doc.load_file(QSTR_TO_TEMPORARY_CSTR(fileFullPath));\n\n        if(result.status!=pugi::status_ok){\n            throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(\"An error ocurred while loading project file.\\n\") + result.description()));\n        }\n\n        // Try to clear deleted items from projects file if they exist\n        for(const QString &currentDeletedItemUuid : uuidsToCleanUp){\n            pugi::xml_node nodeToDelete = doc.select_node(QSTR_TO_TEMPORARY_CSTR(\"/FRequestProject/Request[@uuid='\" + currentDeletedItemUuid + \"']\")).node();\n\n            if(!nodeToDelete.empty()){\n                nodeToDelete.parent().remove_child(nodeToDelete);\n            }\n        }\n\n        rootNode = doc.child(\"FRequestProject\");\n    }\n    else{\n        rootNode = doc.append_child(\"FRequestProject\"); // create\n    }\n\n    createOrGetPugiXmlAttribute(rootNode, \"frequestVersion\").set_value(QSTR_TO_TEMPORARY_CSTR(GlobalVars::LastCompatibleVersionProjects));\n    createOrGetPugiXmlAttribute(rootNode, \"name\").set_value(QSTR_TO_TEMPORARY_CSTR(newProjectData.projectName));\n    createOrGetPugiXmlAttribute(rootNode, \"mainUrl\").set_value(QSTR_TO_TEMPORARY_CSTR(newProjectData.mainUrl));\n    createOrGetPugiXmlAttribute(rootNode, \"uuid\").set_value(QSTR_TO_TEMPORARY_CSTR(newProjectData.projectUuid));\n    createOrGetPugiXmlAttribute(rootNode, \"saveIdentCharacter\").set_value(static_cast<int>(newProjectData.saveIdentCharacter));\n\n    // Delete old auth data if exists (we always need to rebuild it\n    rootNode.remove_child(\"Authentication\");\n\n    // Save authentication data if it exists\n    if(newProjectData.authData != nullptr && !newProjectData.authData->saveAuthToConfigFile){\n        // please add it as the first node, since it is less likely to be removed than some request\n        pugi::xml_node currentAuth = rootNode.prepend_child(\"Authentication\");\n        currentAuth.append_attribute(\"type\").set_value(static_cast<int>(newProjectData.authData->type));\n        currentAuth.append_attribute(\"bRetryLoginIfError\").set_value(newProjectData.authData->retryLoginIfError401);\n\n        switch(newProjectData.authData->type){\n        case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n        {\n            const RequestAuthentication &requestAuth = static_cast<RequestAuthentication&>(*newProjectData.authData.get());\n\n            currentAuth.append_attribute(\"requestUuid\").set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.requestForAuthenticationUuid));\n            currentAuth.append_child(\"Username\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.username));\n            currentAuth.append_child(\"PasswordSalt\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(requestAuth.passwordSalt));\n            currentAuth.append_child(\"Password\").append_child(pugi::xml_node_type::node_pcdata).\n                    set_value(QSTR_TO_TEMPORARY_CSTR(QString(UtilFRequest::simpleStringObfuscationDeobfuscation(requestAuth.passwordSalt, requestAuth.password).toBase64())));\n            break;\n        }\n        case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n        {\n            const BasicAuthentication &basicAuth = static_cast<BasicAuthentication&>(*newProjectData.authData.get());\n            currentAuth.append_child(\"Username\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(basicAuth.username));\n            currentAuth.append_child(\"PasswordSalt\").append_child(pugi::xml_node_type::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(basicAuth.passwordSalt));\n            currentAuth.append_child(\"Password\").append_child(pugi::xml_node_type::node_pcdata).\n                    set_value(QSTR_TO_TEMPORARY_CSTR(QString(UtilFRequest::simpleStringObfuscationDeobfuscation(basicAuth.passwordSalt, basicAuth.password).toBase64())));\n\n            break;\n        }\n        default:\n        {\n            QString errorMessage = \"Authentication type unknown: '\" + QString::number(static_cast<int>(newProjectData.authData->type)) + \"'. Program can't proceed.\";\n            Util::Dialogs::showError(errorMessage);\n            LOG_FATAL << errorMessage;\n            exit(1);\n        }\n        }\n    }\n\n    // Save by the current tree order\n    for(const UtilFRequest::RequestInfo &currentRequest : newProjectData.projectRequests){\n\n        pugi::xml_node requestNode;\n\n        pugi::xpath_node xpathRequestNode = doc.select_node(QSTR_TO_TEMPORARY_CSTR(\"/FRequestProject/Request[@uuid='\" + currentRequest.uuid + \"']\"));\n\n        // if it doesn't exist yet create it\n        if(xpathRequestNode.node().empty()){\n            requestNode = rootNode.append_child(\"Request\");\n        }\n        else{ // otherwise use the existing one\n            requestNode = xpathRequestNode.node();\n        }\n\n        createOrGetPugiXmlAttribute(requestNode, \"name\").set_value(QSTR_TO_TEMPORARY_CSTR(currentRequest.name));\n        createOrGetPugiXmlAttribute(requestNode, \"uuid\").set_value(QSTR_TO_TEMPORARY_CSTR(currentRequest.uuid));\n        createOrGetPugiXmlAttribute(requestNode, \"order\").set_value(currentRequest.order);\n        createOrGetPugiXmlAttribute(requestNode, \"bOverridesMainUrl\").set_value(currentRequest.bOverridesMainUrl);\n        createOrGetPugiXmlAttribute(requestNode, \"overrideMainUrl\").set_value(QSTR_TO_TEMPORARY_CSTR(currentRequest.overrideMainUrl));\n        createOrGetPugiXmlAttribute(requestNode, \"path\").set_value(QSTR_TO_TEMPORARY_CSTR(currentRequest.path));\n        createOrGetPugiXmlAttribute(requestNode, \"type\").set_value(static_cast<int>(currentRequest.requestType));\n        createOrGetPugiXmlAttribute(requestNode, \"bDownloadResponseAsFile\").set_value(currentRequest.bDownloadResponseAsFile);\n        createOrGetPugiXmlAttribute(requestNode, \"bDisableGlobalHeaders\").set_value(currentRequest.bDisableGlobalHeaders);\n\n        // remove body if exists, we will rebuild it\n        requestNode.remove_child(\"Body\");\n\n        pugi::xml_node bodyNode = requestNode.append_child(\"Body\");\n\n        bodyNode.append_attribute(\"type\").set_value(static_cast<int>(currentRequest.bodyType));\n\n        // Aux lambda to avoid duplicated code for FORM_DATA / X_FORM_WWW_URLENCODED\n        auto fSaveFormKeyValues = [](const QVector<UtilFRequest::HttpFormKeyValueType> &bodyForm, pugi::xml_node &bodyNode){\n            for(const UtilFRequest::HttpFormKeyValueType &currentKeyValue : bodyForm){\n                pugi::xml_node currentFormKeyValueNode = bodyNode.append_child(\"FormKeyValue\");\n\n                currentFormKeyValueNode.append_child(\"Key\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentKeyValue.key));\n                currentFormKeyValueNode.append_child(\"Value\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentKeyValue.value));\n                currentFormKeyValueNode.append_child(\"Type\").append_child(pugi::node_pcdata).set_value(QSTR_TO_TEMPORARY_CSTR(QString::number(static_cast<int>(currentKeyValue.type)))); // TODO check if pugixml accepts int directly\n            }\n        };\n\n        switch (currentRequest.bodyType) {\n        case UtilFRequest::BodyType::RAW:\n        {\n            bodyNode.append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentRequest.body));\n            break;\n        }\n        case UtilFRequest::BodyType::FORM_DATA:\n        {\n            fSaveFormKeyValues(currentRequest.bodyForm, bodyNode);\n            break;\n        }\n        case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\n        {\n            fSaveFormKeyValues(currentRequest.bodyForm, bodyNode);\n            break;\n        }\n        default:\n        {\n            break;\n        }\n        }\n\n        // remove headers if they exist, we will rebuild them\n        requestNode.remove_child(\"Headers\");\n\n        pugi::xml_node requestHeadersNode = requestNode.append_child(\"Headers\");\n\n        for(const UtilFRequest::HttpHeader &currentRequestHeader : currentRequest.headers){\n            pugi::xml_node currentRequestHeaderNode = requestHeadersNode.append_child(\"Header\");\n\n            currentRequestHeaderNode.append_child(\"Key\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentRequestHeader.name));\n            currentRequestHeaderNode.append_child(\"Value\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentRequestHeader.value));\n        }\n\n    }\n\n    rootNode.remove_child(\"GlobalHeaders\");\n\n    pugi::xml_node globalHeadersNode = rootNode.append_child(\"GlobalHeaders\");\n    for (const UtilFRequest::HttpHeader &currentGlobalHeader: newProjectData.globalHeaders) {\n        pugi::xml_node currentGlobalHeaderNode = globalHeadersNode.append_child(\"Header\");\n\n        currentGlobalHeaderNode.append_child(\"Key\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentGlobalHeader.name));\n        currentGlobalHeaderNode.append_child(\"Value\").append_child(pugi::xml_node_type::node_cdata).set_value(QSTR_TO_TEMPORARY_CSTR(currentGlobalHeader.value));\n    }\n\n    const pugi::char_t* const identCharacterChar = newProjectData.saveIdentCharacter == UtilFRequest::IdentCharacter::SPACE ? pugiIdentChars::spaceChar : pugiIdentChars::tabChar;\n\n    if(!doc.save_file(fileFullPath.toUtf8().constData(), identCharacterChar, pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n        throw std::runtime_error(\"An error ocurred while trying to save the project file. Please try another path.\");\n    }\n}\n\npugi::xml_attribute ProjectFileFRequest::createOrGetPugiXmlAttribute(pugi::xml_node &mainNode, const char *name){\n    // if attributes doesnt exists create it\n    if(mainNode.attribute(name).empty())\n    {\n        return mainNode.append_attribute(name);\n    }\n    else\n    { // if it already exists return it\n        return mainNode.attribute(name);\n    }\n}\n\nvoid ProjectFileFRequest::upgradeProjectFileIfNecessary(const QString &filePath){\n\n    pugi::xml_document doc;\n\n    pugi::xml_parse_result result = doc.load_file(QSTR_TO_TEMPORARY_CSTR(filePath));\n\n    if(result.status!=pugi::status_ok){\n        throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(QString(\"An error ocurred while loading project file.\\n\") + result.description()));\n    }\n\n    QString currProjectVersion = QString(doc.select_single_node(\"/FRequestProject\").node().attribute(\"frequestVersion\").as_string());\n\n    if(currProjectVersion != GlobalVars::LastCompatibleVersionProjects){\n        if(!Util::FileSystem::backupFile(filePath, filePath + UtilFRequest::getDateTimeFormatForFilename(QDateTime::currentDateTime()))){\n            QString errorMessage = \"Couldn't backup the existing project file for version upgrade, program can't proceed.\";\n            Util::Dialogs::showError(errorMessage);\n            LOG_FATAL << errorMessage;\n            exit(1);\n        }\n    }\n\n    auto fUpgradeFileIfNecessary = [&doc, &filePath, &currProjectVersion](\n            const QString &oldVersion,\n            const QString &newVersion,\n            const pugi::char_t* const identChar,\n            std::function<void()> upgradeFunction){\n\n        // Upgrade necessary?\n        if(currProjectVersion == oldVersion){\n\n            pugi::xml_node projectNode = doc.select_single_node(\"/FRequestProject\").node();\n\n            // Update version\n            projectNode.attribute(\"frequestVersion\").set_value(QSTR_TO_TEMPORARY_CSTR(newVersion));\n\n            // do specific upgrade changes\n            upgradeFunction();\n\n            if(!doc.save_file(QSTR_TO_TEMPORARY_CSTR(filePath), identChar, pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){\n                throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(\"Error while saving: '\" + filePath + \"'. After file version upgrade. (to version \" + newVersion + \" )\"));\n            }\n\n            currProjectVersion = newVersion;\n        }\n\n    };\n\n    fUpgradeFileIfNecessary(\"1.0\", \"1.1\", pugiIdentChars::tabChar, [&](){\n\n        pugi::xml_node projectNode = doc.select_single_node(\"/FRequestProject\").node();\n\n        // Generate an uuid to the project\n        projectNode.append_attribute(\"uuid\").set_value(QSTR_TO_TEMPORARY_CSTR(QUuid::createUuid().toString()));\n\n        // Add types to form rows\n\n        // Get form request bodies nodes to update\n        pugi::xpath_node_set formKeyValuesNodes = doc.select_nodes(\"/FRequestProject/Request/Body/FormKeyValue\");\n\n        for(size_t i=0; i < formKeyValuesNodes.size(); i++){\n            formKeyValuesNodes[i].node().append_child(\"Type\").append_child(pugi::node_pcdata).set_value(\"0\"); // 0 is Text in 1.1\n        }\n\n    });\n\n    fUpgradeFileIfNecessary(\"1.1\", \"1.1c\", pugiIdentChars::tabChar, [&](){\n\n        pugi::xml_node projectNode = doc.select_single_node(\"/FRequestProject\").node();\n\n        // Set the default ident character\n        // Previous to 1.1c all versions use tab as separator, so we want to keep that\n        // until user changes, even though now space is the default\n        projectNode.append_attribute(\"saveIdentCharacter\").set_value(\"1\"); // 0 is tab in 1.1c\n\n    });\n\n    const pugi::char_t* const currSaveIdentCharacter =\n    pugiIdentChars::getIdentCharaterForEnum(static_cast<UtilFRequest::IdentCharacter>(\n                                                doc.select_node(\"/FRequestProject/@saveIdentCharacter\").attribute().as_int()));\n\n    fUpgradeFileIfNecessary(\"1.1c\", \"1.2\", currSaveIdentCharacter, [&](){\n\n        pugi::xml_node projectNode = doc.select_single_node(\"/FrequestProject\").node();\n\n        projectNode.append_child(\"GlobalHeaders\");\n\n    });\n\n    if(currProjectVersion != GlobalVars::LastCompatibleVersionProjects){\n        throw std::runtime_error(\"Can't load the project file, it is from an incompatible version. Probably newer?\");\n    }\n}\n\nnamespace pugiIdentChars {\n\nconst pugi::char_t* getIdentCharaterForEnum(const UtilFRequest::IdentCharacter identEnum){\n    switch(identEnum){\n    case UtilFRequest::IdentCharacter::SPACE:\n    {\n        return pugiIdentChars::spaceChar;\n    }\n    case UtilFRequest::IdentCharacter::TAB:\n    {\n        return pugiIdentChars::tabChar;\n    }\n    default:\n    {\n        QString errorMessage = \"UtilFRequest::IdentCharacter type unknown: '\" + QString::number(static_cast<int>(identEnum)) + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n}\n\n}\n"
  },
  {
    "path": "XmlParsers/projectfilefrequest.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef PROJECTFILEFREQUEST_H\n#define PROJECTFILEFREQUEST_H\n\n#include <QUuid>\n#include <memory>\n\n#include \"utilfrequest.h\"\n#include \"Authentications/requestauthentication.h\"\n#include \"Authentications/basicauthentication.h\"\n\nclass ProjectFileFRequest\n{\npublic:\n\n    struct ProjectData{\n        QString projectName;\n        QString mainUrl;\n        QVector<UtilFRequest::RequestInfo> projectRequests;\n        QString projectUuid;\n        std::shared_ptr<FRequestAuthentication> authData = nullptr;\n        bool retryLoginIfError401 = false;\n        UtilFRequest::IdentCharacter saveIdentCharacter;\n        QVector<UtilFRequest::HttpHeader> globalHeaders;\n    };\n\npublic:\n    ProjectFileFRequest() = delete;\n    static ProjectFileFRequest::ProjectData readProjectDataFromFile(const QString &fileFullPath);\n    static void saveProjectDataToFile(const QString &fileFullPath, const ProjectData &newProjectData, const QVector<QString> &uuidsToCleanUp);\nprivate:\n    static pugi::xml_attribute createOrGetPugiXmlAttribute(pugi::xml_node &mainNode, const char *name);\n    static void upgradeProjectFileIfNecessary(const QString &filePath);\n};\n\nnamespace pugiIdentChars {\n    static constexpr pugi::char_t spaceChar[] = PUGIXML_TEXT(\"    \"); // we use 4 spaces as default\n    static constexpr pugi::char_t tabChar[] = PUGIXML_TEXT(\"\\t\");\n\n    const pugi::char_t* getIdentCharaterForEnum(const UtilFRequest::IdentCharacter identEnum);\n}\n\n#endif // PROJECTFILEFREQUEST_H\n"
  },
  {
    "path": "about.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"about.h\"\r\n#include \"ui_about.h\"\r\n\r\nAbout::About(QWidget *parent) :\r\n    QDialog(parent),\r\n    ui(new Ui::About)\r\n{\r\n    ui->setupUi(this);\r\n    this->setAttribute(Qt::WA_DeleteOnClose,true ); //destroy itself once finished.\r\n\r\n    ui->lbAbout->setText(\"<html>\"\r\n                         \"<p style='font-size:x-large;'><b>\" + GlobalVars::AppName + \" \" + GlobalVars::AppVersion + \"</b></p>\"\r\n                         \"<p style='font-size:large;line-height: 18px;'>\"\r\n                         \"Written by Fábio Bento <a href='https://github.com/fabiobento512'>(fabiobento512)</a><br /><br/>\"\r\n                         \"Build Date \" + __DATE__ + \" \" + __TIME__ + \"<br /><br />\"\r\n                         \"Thanks to:<br/><br/>\"\r\n                         \"<b>Main contributors:</b><br />\"\r\n                         \"Alejandro Valdés (alevalv) for global headers feature<br />\"\r\n                         \"fcolecumberri for scrollable area for request and response areas<br />\"\r\n                         \"<br />\"\r\n                         \"<b>Libraries contributors:</b><br />\"\r\n                         \"Arseny Kapoulkine and the remaining contributors for pugixml library<br />\"\r\n                         \"Andrzej Krzemienski and the remaining contributors for C++14 optional library<br />\"\r\n                         \"Sergey Podobry and the remaining contributors for plog library<br />\"\r\n                         \"Jane G. (isomoar) for the JSON syntax highlighter (from SchemaBasedJSONEditor)<br />\"\r\n                         \"Dmitry Ivanov for the XML syntax highlighter (from SchemaBasedJSONEditor)<br />\"\r\n                         \"<br />\"\r\n                         \"<b>UI contributors:</b><br />\"\r\n                         \"Jürgen Skrotzky (Jorgen-VikingGod) for the Dark Theme<br />\"\r\n                         \"Murakumon for project folder icon (found in findicons.com)<br />\"\r\n                         \"Woothemes for application icon (found in findicons.com)<br />\"\r\n                         \"ana nirwana for send request icon (found in iconfinder.com)<br />\"\r\n                         \"Omercetin for clipboard icon (found in iconfinder.com) <a href='https://creativecommons.org/licenses/by/3.0/'>(license)</a><br />\"\r\n                         \"Icons8 for clone icon (found in <a href='https://icons8.com/'>here</a>) <a href='https://creativecommons.org/licenses/by-nd/3.0/'>(license)</a><br />\"\r\n                         \"Aha-Soft Team for abort icon (found in findicons.com)<br />\"\r\n                         \"FatCow Web Hosting for warning icon (found in iconfinder.com) <a href='http://creativecommons.org/licenses/by/3.0/us/'>(license)</a><br />\"\r\n\t\t\t\t\t\t \"Icons8 for delete icon (found in <a href='https://icons8.com/'>here</a>) <a href='https://creativecommons.org/licenses/by-nd/3.0/'>(license)</a>\"\r\n                         \"<br />\"\r\n                         + R\"(<hr/>\r\n                         This program is free software: you can redistribute it and/or modify\r\n                         it under the terms of the GNU General Public License as published by\r\n                         the Free Software Foundation, either version 3 of the License, or\r\n                         (at your option) any later version.\r\n\r\n                         This program is distributed in the hope that it will be useful,\r\n                         but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n                         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n                         GNU General Public License for more details.\r\n\r\n                         You should have received a copy of the GNU General Public License\r\n                         along with this program.  If not, see <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.\r\n                         )\" +\r\n                         \"</p>\"\r\n                         \"</html>\"); // Don't use rich text in qtdesigner because it generates platform dependent code\r\n\r\n    ui->lbCommunity->setText(\"<html>\"\r\n                                \"<p style='font-size:large;'>\"\r\n                                \"<center>\"\r\n                                \"Visit FRequest <a href='https://fabiobento512.github.io/FRequest/'>website</a><br />\"\r\n                                \"or the <a href='https://github.com/fabiobento512/FRequest'>github project</a><br />\"\r\n                                \"</center>\"\r\n                                \"</p>\"\r\n                                \"</html>\"\r\n                                );\r\n\r\n}\r\n\r\nAbout::~About()\r\n{\r\n    delete ui;\r\n}\r\n\r\nvoid About::on_pushButton_clicked()\r\n{\r\n    this->close();\r\n}\r\n"
  },
  {
    "path": "about.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef ABOUT_H\r\n#define ABOUT_H\r\n\r\n#include <QDialog>\r\n\r\n#include \"utilglobalvars.h\"\r\n\r\nnamespace Ui {\r\nclass About;\r\n}\r\n\r\nclass About : public QDialog\r\n{\r\n    Q_OBJECT\r\n    \r\npublic:\r\n    explicit About(QWidget *parent = 0);\r\n    ~About();\r\n    \r\nprivate slots:\r\n    void on_pushButton_clicked();\r\n\r\nprivate:\r\n    Ui::About *ui;\r\n};\r\n\r\n#endif // ABOUT_H\r\n"
  },
  {
    "path": "about.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>About</class>\r\n <widget class=\"QDialog\" name=\"About\">\r\n  <property name=\"geometry\">\r\n   <rect>\r\n    <x>0</x>\r\n    <y>0</y>\r\n    <width>600</width>\r\n    <height>480</height>\r\n   </rect>\r\n  </property>\r\n  <property name=\"sizePolicy\">\r\n   <sizepolicy hsizetype=\"Preferred\" vsizetype=\"Preferred\">\r\n    <horstretch>0</horstretch>\r\n    <verstretch>0</verstretch>\r\n   </sizepolicy>\r\n  </property>\r\n  <property name=\"windowTitle\">\r\n   <string>About FRequest</string>\r\n  </property>\r\n  <layout class=\"QHBoxLayout\" name=\"horizontalLayout_2\">\r\n   <item>\r\n    <widget class=\"QLabel\" name=\"lbImage\">\r\n     <property name=\"sizePolicy\">\r\n      <sizepolicy hsizetype=\"Fixed\" vsizetype=\"Preferred\">\r\n       <horstretch>0</horstretch>\r\n       <verstretch>0</verstretch>\r\n      </sizepolicy>\r\n     </property>\r\n     <property name=\"minimumSize\">\r\n      <size>\r\n       <width>180</width>\r\n       <height>0</height>\r\n      </size>\r\n     </property>\r\n     <property name=\"text\">\r\n      <string/>\r\n     </property>\r\n     <property name=\"pixmap\">\r\n      <pixmap>:/icons/frequest_icon.png</pixmap>\r\n     </property>\r\n     <property name=\"scaledContents\">\r\n      <bool>true</bool>\r\n     </property>\r\n    </widget>\r\n   </item>\r\n   <item>\r\n    <layout class=\"QVBoxLayout\" name=\"verticalLayout_2\">\r\n     <item>\r\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout\">\r\n       <item>\r\n        <widget class=\"QScrollArea\" name=\"scrollArea\">\r\n         <property name=\"sizePolicy\">\r\n          <sizepolicy hsizetype=\"Preferred\" vsizetype=\"Expanding\">\r\n           <horstretch>0</horstretch>\r\n           <verstretch>0</verstretch>\r\n          </sizepolicy>\r\n         </property>\r\n         <property name=\"widgetResizable\">\r\n          <bool>true</bool>\r\n         </property>\r\n         <widget class=\"QWidget\" name=\"scrollAreaWidgetContents\">\r\n          <property name=\"geometry\">\r\n           <rect>\r\n            <x>0</x>\r\n            <y>0</y>\r\n            <width>390</width>\r\n            <height>363</height>\r\n           </rect>\r\n          </property>\r\n          <property name=\"sizePolicy\">\r\n           <sizepolicy hsizetype=\"Preferred\" vsizetype=\"Expanding\">\r\n            <horstretch>0</horstretch>\r\n            <verstretch>0</verstretch>\r\n           </sizepolicy>\r\n          </property>\r\n          <layout class=\"QVBoxLayout\" name=\"verticalLayout_3\">\r\n           <item>\r\n            <widget class=\"QLabel\" name=\"lbAbout\">\r\n             <property name=\"sizePolicy\">\r\n              <sizepolicy hsizetype=\"Preferred\" vsizetype=\"Expanding\">\r\n               <horstretch>0</horstretch>\r\n               <verstretch>0</verstretch>\r\n              </sizepolicy>\r\n             </property>\r\n             <property name=\"text\">\r\n              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;\r\n&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;\r\np, li { white-space: pre-wrap; }\r\n&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;\r\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;FRequest&lt;/span&gt; &lt;/p&gt;\r\n&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Written by Fábio Bento&lt;br /&gt;&lt;br /&gt;Thanks to:&lt;br /&gt;Edit in About.cpp&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>\r\n             </property>\r\n             <property name=\"alignment\">\r\n              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>\r\n             </property>\r\n             <property name=\"wordWrap\">\r\n              <bool>true</bool>\r\n             </property>\r\n             <property name=\"openExternalLinks\">\r\n              <bool>true</bool>\r\n             </property>\r\n            </widget>\r\n           </item>\r\n          </layout>\r\n         </widget>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <spacer name=\"verticalSpacer_2\">\r\n         <property name=\"orientation\">\r\n          <enum>Qt::Vertical</enum>\r\n         </property>\r\n         <property name=\"sizeType\">\r\n          <enum>QSizePolicy::Fixed</enum>\r\n         </property>\r\n         <property name=\"sizeHint\" stdset=\"0\">\r\n          <size>\r\n           <width>20</width>\r\n           <height>10</height>\r\n          </size>\r\n         </property>\r\n        </spacer>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QLabel\" name=\"lbCommunity\">\r\n         <property name=\"text\">\r\n          <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Github:&lt;br/&gt;&lt;a href=&quot;http://oni.bungie.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;github.com &lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>\r\n         </property>\r\n         <property name=\"wordWrap\">\r\n          <bool>true</bool>\r\n         </property>\r\n         <property name=\"openExternalLinks\">\r\n          <bool>true</bool>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <spacer name=\"verticalSpacer\">\r\n         <property name=\"orientation\">\r\n          <enum>Qt::Vertical</enum>\r\n         </property>\r\n         <property name=\"sizeType\">\r\n          <enum>QSizePolicy::Fixed</enum>\r\n         </property>\r\n         <property name=\"sizeHint\" stdset=\"0\">\r\n          <size>\r\n           <width>20</width>\r\n           <height>10</height>\r\n          </size>\r\n         </property>\r\n        </spacer>\r\n       </item>\r\n      </layout>\r\n     </item>\r\n     <item>\r\n      <layout class=\"QHBoxLayout\" name=\"horizontalLayout\">\r\n       <item>\r\n        <spacer name=\"horizontalSpacer\">\r\n         <property name=\"orientation\">\r\n          <enum>Qt::Horizontal</enum>\r\n         </property>\r\n         <property name=\"sizeHint\" stdset=\"0\">\r\n          <size>\r\n           <width>40</width>\r\n           <height>20</height>\r\n          </size>\r\n         </property>\r\n        </spacer>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QPushButton\" name=\"pushButton\">\r\n         <property name=\"minimumSize\">\r\n          <size>\r\n           <width>100</width>\r\n           <height>0</height>\r\n          </size>\r\n         </property>\r\n         <property name=\"text\">\r\n          <string>Close</string>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n      </layout>\r\n     </item>\r\n    </layout>\r\n   </item>\r\n  </layout>\r\n </widget>\r\n <resources/>\r\n <connections/>\r\n</ui>\r\n"
  },
  {
    "path": "credits.txt",
    "content": "libs:\njson syntax highligher: https://github.com/isomoar/json-editor/blob/master/syntaxhighlightening/highlighter.cpp\npugixml\nc++17 optional\nplog\nbasic xml highlighter (Dmitry Ivanov https://github.com/d1vanov/basic-xml-syntax-highlighter)\n\n-----------\n\nicons:\nproject folder:\nhttp://findicons.com/icon/173045/projects_folder\n\nfrequest icon:\nhttp://findicons.com/icon/69518/web_search\n\nsend icon:\nhttps://www.iconfinder.com/icons/1214637/email_envelope_letter_mail_message_send_sent_icon#size=128\n\ncopy clipboard:\nhttps://www.iconfinder.com/icons/56070/clipboard_icon#size=32\n\nfiles icon (modified):\nhttps://www.iconfinder.com/icons/905572/blanc_documents_file_page_plus_sheet_icon#size=32\n\nwarning icon:\nhttps://www.iconfinder.com/icons/36026/error_hazard_pending_warning_icon#size=32\n\nabort icon (Aha-Soft Team, Freeware):\nhttp://findicons.com/icon/219146/close\n\nclone icon (see license here: https://icons8.com/license/):\nhttps://icons8.com/icon/set/sheep/all\n\ndelete icon (see license here: https://icons8.com/license/):\nhttps://icons8.com/icon/set/delete/all\n\ndark theme:\nJürgen Skrotzky (Jorgen-VikingGod)\nhttps://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle\n\ndark orange theme (currently unused, maybe in the future):\nhttp://discourse.techart.online/t/release-qt-dark-orange-stylesheet/2287"
  },
  {
    "path": "main.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"mainwindow.h\"\r\n#include <QApplication>\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    QApplication a(argc, argv);\r\n    MainWindow w;\r\n    w.show();\r\n    a.setStyleSheet(\"QStatusBar::item { border: 0px; }\"); //hide borders in status bar //http://qt-project.org/forums/viewthread/18743\r\n\r\n    return a.exec();\r\n}\r\n"
  },
  {
    "path": "mainwindow.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"mainwindow.h\"\r\n#include \"ui_mainwindow.h\"\r\n#include \"about.h\"\r\n#include \"preferences.h\"\r\n#include \"utilfrequest.h\"\r\n#include \"Widgets/frequesttreewidgetprojectitem.h\"\r\n#include \"HttpRequests/posthttprequest.h\"\r\n#include \"HttpRequests/puthttprequest.h\"\r\n#include \"HttpRequests/gethttprequest.h\"\r\n#include \"HttpRequests/deletehttprequest.h\"\r\n#include \"HttpRequests/patchhttprequest.h\"\r\n#include \"HttpRequests/headhttprequest.h\"\r\n#include \"HttpRequests/tracehttprequest.h\"\r\n#include \"HttpRequests/optionshttprequest.h\"\r\n#include \"XmlParsers/configfilefrequest.h\"\r\n\r\n#include <QNetworkAccessManager>\r\n#include <QTreeWidgetItem>\r\n#include <QStringBuilder>\r\n#include <QUrlQuery>\r\n#include <QScreen>\r\n#include <QUrl>\r\n#include <QNetworkRequest>\r\n#include <QNetworkReply>\r\n#include <QTimer>\r\n#include <QClipboard>\r\n#include <QUuid>\r\n#include <QPainter>\r\n#include <QMap>\r\n#include <QStyleFactory>\r\n\r\nMainWindow::MainWindow(QWidget *parent) :\r\n    QMainWindow(parent),\r\n    ui(new Ui::MainWindow),\r\n    operatingSystemDefaultStyle(QApplication::style()->objectName())\r\n{\r\n    // We use this appender because it is the native way to have \\r\\n in windows in plog library\r\n    // example: https://github.com/SergiusTheBest/plog/blob/master/samples/NativeEOL/Main.cpp\r\n    static plog::RollingFileAppender<plog::TxtFormatter, plog::NativeEOLConverter<>> fileAppender\r\n            (QSTR_TO_TEMPORARY_CSTR(Util::FileSystem::getAppPath() + \"/\" + GlobalVars::AppLogFileName), 1024*5 /* 5 Mb max log size */, 3);\r\n    plog::init(plog::info, &fileAppender);\r\n\r\n    this->currentSettings = this->configFileManager.getCurrentSettings();\r\n\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n    ui->setupUi(this);\r\n\r\n    // We aren't using this yet, so close it\r\n    ui->mainToolBar->close();\r\n\r\n    // show request types icons or not?\r\n    ui->actionShow_Request_Types_Icons->setChecked(this->currentSettings.showRequestTypesIcons);\r\n\r\n    // Disable drop of items outside of the project folder\r\n    // Thanks to \"p.i.g.\": http://stackoverflow.com/a/30580654\r\n    ui->treeWidget->invisibleRootItem()->setFlags(\r\n                ui->treeWidget->invisibleRootItem()->flags() ^ Qt::ItemIsDropEnabled\r\n                );\r\n\r\n    // Set max icon size in tree widget\r\n    ui->treeWidget->setIconSize(QSize(48,16));\r\n\r\n    setNewProject();\r\n    // Set our desired proportion for the projects tree widget and remaining interface\r\n    // this->width() expands the second widget as much as possible\r\n    ui->splitter->setSizes(QList<int>() << ui->treeWidget->minimumWidth() << this->width());\r\n\r\n    setTheme();\r\n\r\n#ifdef Q_OS_MAC\r\n    ui->pbSendRequest->setToolTip(ui->pbSendRequest->toolTip() + \" (⌘ + Enter)\");\r\n#else\r\n    ui->pbSendRequest->setToolTip(ui->pbSendRequest->toolTip() + \" (Ctrl + Enter)\");\r\n#endif\r\n\r\n    loadRecentProjects();\r\n\r\n    // Hide response warning messages and icons for now\r\n    ui->lbResponseBodyWarningIcon->hide();\r\n    ui->lbResponseBodyWarningMessage->hide();\r\n    ui->lbResponseBodyWarningIcon->setMaximumSize(0,0);\r\n    ui->lbResponseBodyWarningMessage->setMaximumSize(0,0);\r\n\r\n    // Hide key value table for now (the raw textedit is displayed by default)\r\n    ui->twRequestBodyKeyValue->setMaximumSize(0,0);\r\n    ui->tbRequestBodyKeyValueAdd->setMaximumSize(0,0);\r\n    ui->tbRequestBodyFile->setMaximumSize(0,0);\r\n    ui->tbRequestBodyKeyValueRemove->setMaximumSize(0,0);\r\n\r\n    ui->twRequestBodyKeyValue->hide();\r\n    ui->tbRequestBodyKeyValueAdd->hide();\r\n    ui->tbRequestBodyFile->hide();\r\n    ui->tbRequestBodyKeyValueRemove->hide();\r\n\r\n    // We will also set their size to the normal size (we start with size 0 so vertical splitter divide the area in equal space (for header and response), kinda hacky)\r\n    ui->twRequestBodyKeyValue->setMaximumSize(this->auxMaximumSize);\r\n    ui->tbRequestBodyKeyValueAdd->setMaximumSize(this->auxMaximumSize);\r\n    ui->tbRequestBodyFile->setMaximumSize(this->auxMaximumSize);\r\n    ui->tbRequestBodyKeyValueRemove->setMaximumSize(this->auxMaximumSize);\r\n    ui->lbResponseBodyWarningIcon->setMaximumSize(16, 16);\r\n    ui->lbResponseBodyWarningMessage->setMaximumSize(this->auxMaximumSize);\r\n\r\n    // Scretch middle column (value one) for form key value request body\r\n    QHeaderView *twRequestBodyKeyValueHeaderView = ui->twRequestBodyKeyValue->horizontalHeader();\r\n    twRequestBodyKeyValueHeaderView->setSectionResizeMode(1, QHeaderView::Stretch);\r\n\r\n    // Progress indicator and abort button (for the request being made)\r\n    this->pbRequestProgress.setTextVisible(false); //hides text\r\n    this->pbRequestProgress.setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed);\r\n    this->pbRequestProgress.setMinimumWidth(150);\r\n    this->pbRequestProgress.setMaximum(0);\r\n    ui->statusBar->addWidget(&this->lbProjectInfo);\r\n    ui->statusBar->addPermanentWidget(&this->lbRequestInfo);\r\n    ui->statusBar->addPermanentWidget(&this->pbRequestProgress); //this adds automatically in right\r\n    this->tbAbortRequest.setIcon(QIcon(\":/icons/abort.png\"));\r\n    this->tbAbortRequest.setAutoRaise(true);\r\n    this->tbAbortRequest.setToolTip(\"Abort current request\");\r\n    connect(&this->tbAbortRequest , SIGNAL (clicked()), this, SLOT(tbAbortRequest_clicked())); // connect button click to our slot function\r\n    connect(&this->networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));\r\n    connect(ui->treeWidget, SIGNAL(deleteKeyPressed()), this, SLOT(treeWidgetDeleteKeyPressed()));\r\n    ui->statusBar->addPermanentWidget(&this->tbAbortRequest);\r\n    this->lbRequestInfo.hide();\r\n    this->pbRequestProgress.hide();\r\n    this->tbAbortRequest.hide();\r\n\r\n    // Restore geometry if it exists\r\n    if(this->currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting){\r\n        if(!this->currentSettings.windowsGeometry.mainWindow_MainWindowGeometry.isEmpty()){\r\n            if(!this->restoreGeometry(this->currentSettings.windowsGeometry.mainWindow_MainWindowGeometry)){\r\n                const QString errorMessage = \"Couldn't restore saved main window geometry.\";\r\n                Util::Dialogs::showError(errorMessage);\r\n                LOG_ERROR << errorMessage;\r\n                return;\r\n            }\r\n\r\n            if(!ui->splitter->restoreState(this->currentSettings.windowsGeometry.mainWindow_RequestsSplitterState)){\r\n                const QString errorMessage = \"Couldn't restore saved requests splitter state.\";\r\n                Util::Dialogs::showError(errorMessage);\r\n                LOG_ERROR << errorMessage;\r\n                return;\r\n            }\r\n\r\n            if(!ui->splitter_2->restoreState(this->currentSettings.windowsGeometry.mainWindow_RequestResponseSplitterState)){\r\n                const QString errorMessage = \"Couldn't restore saved request response splitter state.\";\r\n                Util::Dialogs::showError(errorMessage);\r\n                LOG_ERROR << errorMessage;\r\n                return;\r\n            }\r\n        }\r\n    }\r\n    else{\r\n        // center window if we are not restoring geometry\r\n        this->setGeometry(QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,this->size(),qApp->primaryScreen()->availableGeometry()));\r\n    }\r\n\r\n    ui->treeWidget->setFocus();\r\n}\r\n\r\nvoid MainWindow::showEvent(QShowEvent *e)\r\n{\r\n    if(!this->applicationIsFullyLoaded)\r\n    {\r\n        // Apparently Qt doesn't contains a slot to when the application was fully load (mainwindow). So we do our own implementation instead.\r\n        connect(this, SIGNAL(signalAppIsLoaded()), this, SLOT(applicationHasLoaded()), Qt::ConnectionType::QueuedConnection);\r\n        emit signalAppIsLoaded();\r\n    }\r\n\r\n    e->accept();\r\n}\r\n\r\n// Called only when the MainWindow was fully loaded and painted on the screen. This slot is only called once.\r\nvoid MainWindow::applicationHasLoaded(){\r\n\r\n    LOG_INFO << GlobalVars::AppName + \" \" + GlobalVars::AppVersion + \" started\";\r\n\r\n    this->applicationIsFullyLoaded = true;\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n\r\n    if(this->currentSettings.recentProjectsPaths.size() > 0){\r\n\r\n        const QString &lastSavedProject = this->currentSettings.recentProjectsPaths[0];\r\n\r\n        if(!lastSavedProject.isEmpty()){\r\n\r\n            if(this->currentSettings.onStartupSelectedOption == ConfigFileFRequest::OnStartupOption::LOAD_LAST_PROJECT){\r\n                loadProjectState(lastSavedProject);\r\n            }\r\n            else if(this->currentSettings.onStartupSelectedOption == ConfigFileFRequest::OnStartupOption::ASK_TO_LOAD_LAST_PROJECT){\r\n                if(Util::Dialogs::showQuestion(this,\"Do you want to load latest project?\\n\\nLatest project was '\" +\r\n                                               Util::FileSystem::cutNameWithoutBackSlash(lastSavedProject) + \"'.\")){\r\n                    loadProjectState(lastSavedProject);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\nMainWindow::~MainWindow()\r\n{\r\n    delete ui;\r\n    LOG_INFO << GlobalVars::AppName + \" \" + GlobalVars::AppVersion + \" exited\";\r\n}\r\n\r\nvoid MainWindow::on_pbSendRequest_clicked()\r\n{\r\n\r\n    if(formKeyValueInBodyIsValid()){\r\n\r\n        QVector<UtilFRequest::HttpHeader> requestFinalHeaders = getRequestHeaders();\r\n\r\n        if(noDuplicatedKeyExistsInRequestHeaders(requestFinalHeaders)) {\r\n\r\n            // Disable until this request is finished\r\n            ui->pbSendRequest->setEnabled(false);\r\n            this->lbRequestInfo.show();\r\n            this->pbRequestProgress.show();\r\n            this->tbAbortRequest.show();\r\n            this->pbRequestProgress.setValue(0);\r\n            ui->gbProject->setEnabled(false);\r\n            ui->gbRequest->setEnabled(false);\r\n\r\n            // Apply proxy type\r\n            ProxySetup::setupProxyForNetworkManager(this->currentSettings, &this->networkAccessManager);\r\n\r\n            // Attempt to authenticate if we have authentication and its the first request in this project\r\n            if(this->currentProjectItem->authData != nullptr){\r\n\r\n                // We only apply the authentication to urls of the project, overriden urls don't have the auth applied\r\n                if(!ui->cbRequestOverrideMainUrl->isChecked()){\r\n                    switch(this->currentProjectItem->authData->type){\r\n                    case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\r\n                    {\r\n                        if(!this->currentProjectAuthenticationWasMade)\r\n                        {\r\n                            this->lbRequestInfo.setText(\"Authenticating using the request provided...\");\r\n\r\n                            applyRequestAuthentication();\r\n\r\n                            // If there was an error with the authorization don't proceed\r\n                            if(!this->currentProjectAuthenticationWasMade){\r\n                                return;\r\n                            }\r\n                        }\r\n                        break;\r\n                    }\r\n                    case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\r\n                    {\r\n                        const RequestAuthentication * const concreteAuthData = static_cast<RequestAuthentication*>(this->currentProjectItem->authData.get());\r\n\r\n                        UtilFRequest::HttpHeader authHeader;\r\n                        authHeader.name = \"Authorization\";\r\n                        authHeader.value = \"Basic \" + QString(concreteAuthData->username + \":\" + concreteAuthData->password).toUtf8().toBase64();\r\n\r\n                        requestFinalHeaders.append(authHeader);\r\n                        break;\r\n                    }\r\n                    default:\r\n                    {\r\n                        const QString errorMessage = \"Invalid authentication type \" + QString::number(static_cast<int>(this->currentProjectItem->authData->type)) + \"'. Program can't proceed.\";\r\n                        Util::Dialogs::showError(errorMessage);\r\n                        LOG_FATAL << errorMessage;\r\n                        exit(1);\r\n                    }\r\n                    }\r\n                }\r\n            }\r\n\r\n            // we always add the global headers, except in case that the user check the disable checkbox\r\n            // this is specially useful if we want to overwrite some existing header\r\n            if (!ui->cbDisableGlobalHeaders->isChecked()) {\r\n                for (const UtilFRequest::HttpHeader &currGlobalHeader : this->currentProjectItem->globalHeaders) {\r\n\r\n                    // Check if there is already a local header with the same key of the current global variable\r\n                    QVector<UtilFRequest::HttpHeader>::iterator itLocalHeader = std::find_if(requestFinalHeaders.begin(), requestFinalHeaders.end(),\r\n                                                                                             [&currGlobalHeader](const UtilFRequest::HttpHeader &h){return h.name == currGlobalHeader.name;});\r\n\r\n                    // It doesn't exist so we are free to add our global header (otherwise we prefer the local\r\n                    // over the global as overriding mechanism)\r\n                    if(itLocalHeader == requestFinalHeaders.end()) {\r\n                        requestFinalHeaders.append(currGlobalHeader);\r\n                    }\r\n\r\n                }\r\n            }\r\n\r\n            this->ignoreAnyChangesToProject.SetCondition();\r\n            formatRequestBody(getRequestCurrentSerializationFormatType());\r\n            this->ignoreAnyChangesToProject.UnsetCondition();\r\n\r\n            // Display info about when request was started\r\n            this->lbRequestInfo.setText(\"Requested started at \" + QDateTime::currentDateTime().toString(\"yyyy-MM-dd hh:mm:ss\"));\r\n\r\n            // Clear previous request data:\r\n            clearOlderResponse();\r\n\r\n            this->currentReply = processHttpRequest\r\n                    (\r\n                        UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText()),\r\n                        ui->leFullPath->text(),\r\n                        ui->cbBodyType->currentText(),\r\n                        ui->pteRequestBody->toPlainText(),\r\n                        requestFinalHeaders\r\n                        );\r\n\r\n            lastStartTime = QDateTime::currentDateTime();\r\n\r\n            checkForQNetworkAccessManagerTimeout(this->currentReply.value());\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::applyRequestAuthentication(){\r\n\r\n    std::shared_ptr<FRequestAuthentication> authData = this->currentProjectItem->authData;\r\n\r\n\r\n    if(authData->type != FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION)\r\n    {\r\n        const QString errorMessage = \"Authentication is not a REQUEST_AUTHENTICATION. Please report this error.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n        return;\r\n    }\r\n\r\n    this->authenticationIsRunning = true;\r\n\r\n    const RequestAuthentication * const concreteAuthData = static_cast<RequestAuthentication*>(authData.get());\r\n\r\n    const FRequestTreeWidgetRequestItem * const authRequestItem =\r\n            this->currentProjectItem->getChildRequestByUuid(concreteAuthData->requestForAuthenticationUuid);\r\n\r\n    QString mainUrl;\r\n\r\n    if(authRequestItem->itemContent.bOverridesMainUrl){\r\n        mainUrl = authRequestItem->itemContent.overrideMainUrl;\r\n    }\r\n    else{\r\n        mainUrl = this->currentProjectItem->projectMainUrl;\r\n    }\r\n\r\n    // Wait for authentication request synchronously\r\n    // https://stackoverflow.com/a/5496468/1499019\r\n    QEventLoop loop;\r\n    connect(this, SIGNAL(signalRequestFinishedAndProcessed()), &loop, SLOT(quit()));\r\n\r\n    QVector<UtilFRequest::HttpHeader> finalAuthRequestHeaders = authRequestItem->itemContent.headers;\r\n\r\n    // Apply auth data to headers if it the placeholder fields are found\r\n    for(UtilFRequest::HttpHeader &currentHeader : finalAuthRequestHeaders){\r\n        currentHeader.name = UtilFRequest::replaceFRequestAuthenticationPlaceholders(currentHeader.name, concreteAuthData->username, concreteAuthData->password);\r\n        currentHeader.value = UtilFRequest::replaceFRequestAuthenticationPlaceholders(currentHeader.value, concreteAuthData->username, concreteAuthData->password);\r\n    }\r\n\r\n    this->currentReply = processHttpRequest(\r\n                authRequestItem->itemContent.requestType,\r\n                getFullPathFromMainUrlAndPath(mainUrl, UtilFRequest::replaceFRequestAuthenticationPlaceholders(authRequestItem->itemContent.path, concreteAuthData->username, concreteAuthData->password)),\r\n                UtilFRequest::getBodyTypeString(authRequestItem->itemContent.bodyType),\r\n                UtilFRequest::replaceFRequestAuthenticationPlaceholders(authRequestItem->itemContent.body, concreteAuthData->username, concreteAuthData->password),\r\n                finalAuthRequestHeaders\r\n                );\r\n\r\n    // checkForQNetworkAccessManagerTimeout(this->currentReply.value()); // TODO: check why this is causing problems\r\n\r\n    loop.exec();\r\n}\r\n\r\n// Since QNetworkReply doesn't have a way to set a timeout we need implement it by ourselves\r\n// http://stackoverflow.com/a/13229926\r\nvoid MainWindow::checkForQNetworkAccessManagerTimeout(QNetworkReply *reply)\r\n{\r\n    QTimer timer;\r\n    timer.setSingleShot(true);\r\n\r\n    QEventLoop loop;\r\n    connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));\r\n    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));\r\n\r\n    timer.start(this->currentSettings.requestTimeout * 1000);\r\n    loop.exec();\r\n\r\n    if(timer.isActive() || timer.interval() == 0) // if request timeout is 0 don't timeout\r\n    {\r\n        timer.stop();\r\n    }\r\n    else\r\n    {\r\n        // timeout\r\n\r\n        const QString errorMessage = \"Timeout after \" + QString::number(this->currentSettings.requestTimeout) + \" seconds\";\r\n\r\n        if(this->authenticationIsRunning){\r\n            Util::Dialogs::showError(errorMessage);\r\n        }\r\n        else{\r\n            ui->lbStatus->setText(\"-1\");\r\n            ui->lbDescription->setText(errorMessage);\r\n            ui->lbTimeElapsed->setText(QString::number(lastStartTime.msecsTo(QDateTime::currentDateTime())) + \" ms\");\r\n        }\r\n\r\n        LOG_ERROR << errorMessage;\r\n\r\n        this->lastReplyStatusError = -1;\r\n\r\n        disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));\r\n\r\n        reply->abort();\r\n    }\r\n}\r\n\r\nvoid MainWindow::replyFinished(QNetworkReply *reply){\r\n\r\n    QString requestReturnCode;\r\n    QString requestReturnMessage;\r\n    bool isError = false;\r\n    bool isToRetryWithAuthentication = false;\r\n\r\n    // -1 means we have set a custom error, we don't want to override that one\r\n    if(this->lastReplyStatusError != -1 && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).isValid()){ // success request\r\n        requestReturnCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString();\r\n        requestReturnMessage = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();\r\n    }\r\n    else if(this->lastReplyStatusError == 0 && reply->error() != QNetworkReply::NoError){\r\n        requestReturnCode = \"N/A\";\r\n        requestReturnMessage = reply->errorString() + \" - Error \" + QString::number(reply->error());\r\n        isError = true;\r\n    }\r\n\r\n    // Don't override if we are authenticating or we have a custom error\r\n    if(!this->authenticationIsRunning && this->lastReplyStatusError != -1){\r\n        ui->lbStatus->setText(requestReturnCode);\r\n        ui->lbDescription->setText(requestReturnMessage);\r\n        ui->lbTimeElapsed->setText(QString::number(lastStartTime.msecsTo(QDateTime::currentDateTime())) + \" ms\");\r\n    }\r\n\r\n    if(reply->error() == QNetworkReply::OperationCanceledError){ /* ignore user aborted */ }\r\n    else{\r\n\r\n        if(!this->authenticationIsRunning){\r\n            // *1024 to get bytes...\r\n            const int maxBytesForBufferAndDisplay = this->currentSettings.maxRequestResponseDataSizeToDisplay*1024;\r\n            QString headersText;\r\n            QByteArray totalLoadedData;\r\n            QByteArray currentData;\r\n\r\n            // Read the bytes to display\r\n            totalLoadedData = reply->read(maxBytesForBufferAndDisplay);\r\n\r\n            for(const QNetworkReply::RawHeaderPair &currentPair : reply->rawHeaderPairs()){\r\n                headersText += currentPair.first + \": \" + currentPair.second + \"\\n\";\r\n            }\r\n\r\n            ui->pteResponseHeaders->document()->setPlainText(headersText);\r\n\r\n            UtilFRequest::SerializationFormatType serializationType = UtilFRequest::getSerializationFormatTypeForString(totalLoadedData);\r\n\r\n            if(ui->actionFormat_Response_Body->isChecked()){\r\n                ui->pteResponseBody->document()->setPlainText(UtilFRequest::getStringFormattedForSerializationType(totalLoadedData, serializationType));\r\n                formatResponseBody(serializationType);\r\n            }\r\n            else{\r\n                ui->pteResponseBody->document()->setPlainText(totalLoadedData);\r\n            }\r\n\r\n            // Check if there are more bytes to read\r\n            // (they will not be displayed on the interface, but they can be saved to a file and a warning in the interface will be displayed)\r\n            currentData = reply->read(maxBytesForBufferAndDisplay);\r\n            if(currentData.size() > 0){\r\n                totalLoadedData.append(currentData);\r\n                ui->lbResponseBodyWarningIcon->show();\r\n                ui->lbResponseBodyWarningMessage->show();\r\n                ui->lbResponseBodyWarningMessage->setText(\"Return data size is greater than \" +\r\n                                                          QString::number(this->currentSettings.maxRequestResponseDataSizeToDisplay) + \" KB, only displaying the first \" +\r\n                                                          QString::number(this->currentSettings.maxRequestResponseDataSizeToDisplay) + \" KB.\");\r\n            }\r\n\r\n            if(ui->cbDownloadResponseAsFile->isChecked())\r\n            {\r\n                downloadResponseAsFile(reply, totalLoadedData, currentData, maxBytesForBufferAndDisplay); // this call handles errors and status bar messages\r\n            }\r\n            else{\r\n                QString successMessage = \"Request performed with success.\";\r\n\r\n                if(this->currentProjectItem->authData != nullptr && ui->cbRequestOverrideMainUrl->isChecked()){\r\n                    successMessage += \" Since this was an url overriden request, the authentication was not applied.\";\r\n                }\r\n\r\n                Util::StatusBar::showSuccess(ui->statusBar, successMessage);\r\n            }\r\n        }\r\n        else{\r\n            Util::StatusBar::showSuccess(ui->statusBar, \"Authenticated with success.\");\r\n        }\r\n\r\n        if(reply->error() != QNetworkReply::NoError){\r\n\r\n            // If we receive 401 and if we have an authentication and if we are allowed to retry to authenticate again, repeat the request\r\n            if\r\n                    (\r\n                     requestReturnCode == \"401\" && this->currentProjectItem->authData != nullptr &&\r\n                     this->currentProjectItem->authData->retryLoginIfError401 &&\r\n                     this->currentProjectItem->authData->type == FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION &&\r\n                     this->currentProjectAuthenticationWasMade\r\n                     ){\r\n                isToRetryWithAuthentication = true;\r\n            }\r\n\r\n            if(!isToRetryWithAuthentication){\r\n\r\n                QString requestType;\r\n                bool overridenRequest = !this->authenticationIsRunning && this->currentProjectItem->authData != nullptr && ui->cbRequestOverrideMainUrl->isChecked();\r\n\r\n                if(this->authenticationIsRunning){\r\n                    requestType = \"Authentication\";\r\n                }\r\n                else{\r\n                    requestType = \"Request\";\r\n                }\r\n\r\n                LOG_ERROR << requestReturnMessage;\r\n\r\n                QString statusErrorMessage = requestType + \" wasn't successful.\" +\r\n                        (overridenRequest ? \" Since this was an url overriden request, the authentication was not applied.\" : \"\");\r\n\r\n                Util::StatusBar::showError(ui->statusBar, statusErrorMessage); // this one is necessary to override any previous message\r\n            }\r\n\r\n            isError = true;\r\n        }\r\n\r\n    }\r\n\r\n    this->lbRequestInfo.hide();\r\n    this->pbRequestProgress.hide();\r\n    this->tbAbortRequest.hide();\r\n    ui->pbSendRequest->setEnabled(true);\r\n    ui->gbRequest->setEnabled(true);\r\n    ui->gbProject->setEnabled(true);\r\n    this->currentReply.reset();\r\n    reply->deleteLater();\r\n\r\n    if(this->authenticationIsRunning){\r\n        this->authenticationIsRunning = false;\r\n\r\n        if(!isError){\r\n            this->currentProjectAuthenticationWasMade = true;\r\n        }\r\n\r\n    }\r\n\r\n    emit signalRequestFinishedAndProcessed();\r\n\r\n    if(isToRetryWithAuthentication){\r\n        this->currentProjectAuthenticationWasMade = false;\r\n        on_pbSendRequest_clicked();\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::downloadResponseAsFile(QNetworkReply *reply, QByteArray &totalLoadedData, QByteArray &currentData, const int maxBytesForBufferAndDisplay){\r\n    QString filePath;\r\n    QString fileName;\r\n\r\n    if(ui->actionUse_Last_Download_Location->isChecked() && !this->lastResponseFileName.isEmpty())\r\n    {\r\n        fileName = this->lastResponseFileName;\r\n        filePath = this->currentSettings.lastResponseFilePath + \"/\" + this->lastResponseFileName;\r\n    }\r\n    else\r\n    {\r\n        fileName = getDownloadFileName(reply);\r\n        filePath = QFileDialog::getSaveFileName(this, tr(\"Save File\"),\r\n                                                this->currentSettings.lastResponseFilePath + \"/\" + fileName);\r\n    }\r\n\r\n    if(!filePath.isEmpty())\r\n    {\r\n        this->currentSettings.lastResponseFilePath = Util::FileSystem::normalizePath(QFileInfo(filePath).absoluteDir().path());\r\n        this->lastResponseFileName = Util::FileSystem::cutNameWithoutBackSlash(Util::FileSystem::normalizePath(filePath));\r\n\r\n        QFile file(filePath);\r\n\r\n        if (file.open(QIODevice::WriteOnly)) {\r\n            file.write(totalLoadedData);\r\n\r\n            // Load remaining data using a buffer\r\n            do{\r\n                currentData = reply->read(maxBytesForBufferAndDisplay);\r\n                file.write(currentData);\r\n            }while(currentData.size() > 0);\r\n\r\n            file.close();\r\n\r\n            if(ui->actionOpen_file_after_download->isChecked()){\r\n                if(!QDesktopServices::openUrl(\"file:///\"+filePath)){\r\n                    const QString errorMessage = \"Could not open downloaded file: \" + filePath;\r\n                    Util::Dialogs::showError(errorMessage);\r\n                    LOG_ERROR << errorMessage;\r\n                    Util::StatusBar::showError(ui->statusBar, errorMessage);\r\n                }\r\n            }\r\n\r\n            Util::StatusBar::showSuccess(ui->statusBar, \"File saved with success.\");\r\n        }\r\n        else{ // use just one exit point so we don't need to duplicate the code to enable the send request button\r\n            const QString errorMessage = \"Could not open file for writing: \" + filePath;\r\n            Util::Dialogs::showError(errorMessage);\r\n            Util::StatusBar::showSuccess(ui->statusBar, errorMessage);\r\n            LOG_ERROR << errorMessage;\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_leRequestOverrideMainUrl_textChanged(const QString &)\r\n{\r\n    setProjectHasChanged();\r\n\r\n    if(ui->cbRequestOverrideMainUrl->isChecked()){\r\n        buildFullPath();\r\n    }\r\n}\r\n\r\nvoid MainWindow::buildFullPath(){\r\n\r\n    QString normalizedMainUrl;\r\n\r\n    if(ui->cbRequestOverrideMainUrl->isChecked()){\r\n        normalizedMainUrl = ui->leRequestOverrideMainUrl->text();\r\n    }\r\n    else{\r\n        if(this->currentProjectItem != nullptr){\r\n            normalizedMainUrl = this->currentProjectItem->projectMainUrl;\r\n        }\r\n    }\r\n\r\n    ui->leFullPath->setText(getFullPathFromMainUrlAndPath(normalizedMainUrl, ui->lePath->text()));\r\n}\r\n\r\nQString MainWindow::getFullPathFromMainUrlAndPath(const QString & mainUrl, const QString & path){\r\n    QString normalizedMainUrl = mainUrl;\r\n\r\n    if(!normalizedMainUrl.endsWith('/') && !path.startsWith('/')){\r\n        normalizedMainUrl += '/';\r\n    }\r\n\r\n    return normalizedMainUrl + path;\r\n}\r\n\r\nvoid MainWindow::on_lePath_textChanged(const QString &)\r\n{\r\n    setProjectHasChanged();\r\n\r\n    buildFullPath();\r\n}\r\n\r\nQNetworkReply* MainWindow::processHttpRequest\r\n(\r\n        const UtilFRequest::RequestType requestType,\r\n        const QString &fullPath,\r\n        const QString &bodyType,\r\n        const QString &requestBody,\r\n        const QVector<UtilFRequest::HttpHeader>& requestHeaders\r\n        )\r\n{\r\n    std::unique_ptr<HttpRequest> httpRequest = nullptr;\r\n\r\n    switch(requestType){\r\n    case UtilFRequest::RequestType::GET_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<GetHttpRequest>(&this->networkAccessManager, fullPath, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::POST_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<PostHttpRequest>(&this->networkAccessManager, ui->twRequestBodyKeyValue, fullPath , bodyType, requestBody, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::PUT_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<PutHttpRequest>(&this->networkAccessManager, ui->twRequestBodyKeyValue, fullPath , bodyType, requestBody, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::DELETE_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<DeleteHttpRequest>(&this->networkAccessManager, fullPath, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::PATCH_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<PatchHttpRequest>(&this->networkAccessManager, ui->twRequestBodyKeyValue, fullPath , bodyType, requestBody, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::HEAD_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<HeadHttpRequest>(&this->networkAccessManager, fullPath, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::TRACE_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<TraceHttpRequest>(&this->networkAccessManager, ui->twRequestBodyKeyValue, fullPath , bodyType, requestBody, requestHeaders);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::OPTIONS_OPTION:\r\n    {\r\n        httpRequest = std::make_unique<OptionsHttpRequest>(&this->networkAccessManager, ui->twRequestBodyKeyValue, fullPath , bodyType, requestBody, requestHeaders);\r\n        break;\r\n    }\r\n    default:{\r\n        const QString errorMessage = \"Request type unknown: '\" + ui->cbRequestType->currentText() + \"'. Application must exit.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n\r\n    return httpRequest->processRequest();\r\n}\r\n\r\nQString MainWindow::getDownloadFileName(const QNetworkReply * const reply)\r\n{\r\n    QString fileFilename;\r\n\r\n    const QString contentDisposition = reply->rawHeader(\"Content-Disposition\");\r\n\r\n    const QString stringToFind = \"filename=\";\r\n\r\n    int fileNameIndex = contentDisposition.indexOf(stringToFind) + stringToFind.size();\r\n\r\n    // If we have the filename in content disposition...\r\n    if(fileNameIndex != -1){\r\n        fileFilename = contentDisposition.mid(fileNameIndex); // assume the name is the remaining string after \"filename=\"\r\n        fileFilename = fileFilename.replace(\"\\\"\",\"\").replace(\";\",\"\"); // remove any \" or ;\r\n    }\r\n\r\n    // use the url filename if content disposition is not available\r\n    if(fileFilename.isEmpty())\r\n    {\r\n        QString path = reply->url().path();\r\n        fileFilename = QFileInfo(path).fileName();\r\n\r\n        if (fileFilename.isEmpty())\r\n            fileFilename = \"download\";\r\n    }\r\n\r\n    return fileFilename;\r\n}\r\n\r\nvoid MainWindow::on_treeWidget_customContextMenuRequested(const QPoint &pos)\r\n{\r\n    QTreeWidget *myTree = ui->treeWidget;\r\n\r\n    QList<int> selectedRows = QList<int>();\r\n\r\n    for(const QModelIndex &rowItem : myTree->selectionModel()->selectedRows()){\r\n        selectedRows << rowItem.row();\r\n    }\r\n\r\n    std::unique_ptr<QMenu> menu = std::make_unique<QMenu>();\r\n\r\n    // Project actions only\r\n    std::unique_ptr<QAction> openProjectLocation = nullptr;\r\n    std::unique_ptr<QAction> projectProperties = nullptr;\r\n\r\n    // Requests actions only\r\n    std::unique_ptr<QAction> cloneRequest = nullptr;\r\n    std::unique_ptr<QAction> moveRequestUp = nullptr;\r\n    std::unique_ptr<QAction> moveRequestDown = nullptr;\r\n    std::unique_ptr<QAction> deleteRequest = nullptr;\r\n\r\n    // Common actions\r\n    std::unique_ptr<QAction> addNewRequest = std::make_unique<QAction>(\"Add new request\", myTree);\r\n    std::unique_ptr<QAction> renameItem = nullptr;\r\n\r\n    if(ui->treeWidget->currentItem() == this->currentProjectItem){ // Project\r\n        renameItem = std::make_unique<QAction>(\"Rename project\", myTree);\r\n        openProjectLocation = std::make_unique<QAction>(\"Open project location\", myTree);\r\n        menu->addAction(openProjectLocation.get());\r\n        menu->addSeparator();\r\n        menu->addAction(addNewRequest.get());\r\n        menu->addAction(renameItem.get());\r\n        menu->addSeparator();\r\n        projectProperties = std::make_unique<QAction>(\"Project properties\", myTree);\r\n        menu->addAction(projectProperties.get());\r\n    }\r\n    else{ // Requests\r\n        renameItem = std::make_unique<QAction>(\"Rename request\", myTree);\r\n        menu->addAction(addNewRequest.get());\r\n        menu->addAction(renameItem.get());\r\n        cloneRequest =  std::make_unique<QAction>(QIcon(\":/icons/clone_icon.png\"), \"Clone request\", myTree);\r\n        menu->addAction(cloneRequest.get());\r\n        menu->addSeparator();\r\n        moveRequestUp =  std::make_unique<QAction>(\"Move up\", myTree);\r\n        menu->addAction(moveRequestUp.get());\r\n        moveRequestDown =  std::make_unique<QAction>(\"Move down\", myTree);\r\n        menu->addAction(moveRequestDown.get());\r\n        menu->addSeparator();\r\n        deleteRequest =  std::make_unique<QAction>(QIcon(\":/icons/delete_icon.png\"), \"Delete request\", myTree);\r\n        menu->addAction(deleteRequest.get());\r\n\r\n        if(this->currentProjectItem->childCount() == 1){\r\n            moveRequestDown->setEnabled(false);\r\n            moveRequestUp->setEnabled(false);\r\n        }\r\n        else if(ui->treeWidget->itemAbove(ui->treeWidget->currentItem()) == this->currentProjectItem){\r\n            moveRequestUp->setEnabled(false);\r\n        }\r\n        else if(ui->treeWidget->itemBelow(ui->treeWidget->currentItem()) == nullptr){\r\n            moveRequestDown->setEnabled(false);\r\n        }\r\n    }\r\n\r\n    // Shortcuts info display for the users\r\n#ifdef Q_OS_MAC\r\n    renameItem->setShortcut(Qt::Key_Return);\r\n#else\r\n    renameItem->setShortcut(Qt::Key_F2);\r\n#endif\r\n    renameItem->setShortcutVisibleInContextMenu(true);\r\n\r\n    if(deleteRequest != nullptr){\r\n        deleteRequest->setShortcut(Qt::Key_Delete);\r\n        deleteRequest->setShortcutVisibleInContextMenu(true);\r\n    }\r\n\r\n    // Disable show in explorer if we don't have any project saved to disk\r\n    if(openProjectLocation != nullptr && this->lastProjectFilePath.isEmpty()){\r\n        openProjectLocation->setEnabled(false);\r\n    }\r\n\r\n    QAction* selectedOption = menu->exec(myTree->viewport()->mapToGlobal(pos));\r\n\r\n    // if none selected just return\r\n    if(selectedOption == nullptr){\r\n        return;\r\n    }\r\n\r\n    // Index delta is the difference between the current index and the new one\r\n    auto fMoveQTreeWidgetItem = [](QTreeWidgetItem *item, int indexDelta){\r\n        // Based from here:\r\n        // http://www.qtcentre.org/threads/56247-Moving-QTreeWidgetItem-Up-and-Down-in-a-QTreeWidget\r\n        QTreeWidgetItem* parent = item->parent();\r\n        int index = parent->indexOfChild(item);\r\n        QTreeWidgetItem* child = parent->takeChild(index);\r\n        parent->insertChild(index+indexDelta, child);\r\n        item->treeWidget()->clearSelection();\r\n        item->setSelected(true);\r\n        item->treeWidget()->setCurrentItem(item);\r\n    };\r\n\r\n    if(selectedOption == addNewRequest.get()){\r\n\r\n        this->ignoreAnyChangesToProject.SetCondition();\r\n        this->unsavedChangesExist = true;\r\n\r\n        FRequestTreeWidgetItem *newRequest = addRequestItem(\"New Request\", getNewUuid(), this->currentProjectItem);\r\n        ui->treeWidget->clearSelection();\r\n        newRequest->setSelected(true);\r\n\r\n        // Necessary in order to currentIndexChanged to work correctly (select it is not enough)\r\n        ui->treeWidget->setCurrentItem(newRequest);\r\n\r\n        // Reset options\r\n        clearRequestAndResponse();\r\n\r\n        ui->treeWidget->editItem(newRequest);\r\n\r\n        addGlobalHeaders();\r\n\r\n        if(this->currentSettings.defaultHeaders.useDefaultHeaders){\r\n            addDefaultHeaders();\r\n        }\r\n\r\n        this->ignoreAnyChangesToProject.UnsetCondition();\r\n    }\r\n    else if(selectedOption == renameItem.get()){\r\n        ui->treeWidget->editItem(ui->treeWidget->currentItem());\r\n    }\r\n    else if(selectedOption == cloneRequest.get()){\r\n        this->unsavedChangesExist = true;\r\n\r\n        const FRequestTreeWidgetRequestItem * const itemToClone = FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(ui->treeWidget->currentItem());\r\n\r\n        FRequestTreeWidgetRequestItem *newRequest = addRequestItem(itemToClone->text(0), getNewUuid(), this->currentProjectItem);\r\n        ui->treeWidget->clearSelection();\r\n        newRequest->setSelected(true);\r\n\r\n        // Necessary in order to currentIndexChanged to work correctly (select it is not enough)\r\n        ui->treeWidget->setCurrentItem(newRequest);\r\n\r\n        this->currentItem = newRequest;\r\n    }\r\n    else if(openProjectLocation != nullptr && selectedOption == openProjectLocation.get()){\r\n        QDesktopServices::openUrl(QUrl(\"file:///\" + QFileInfo(this->lastProjectFilePath).absoluteDir().absolutePath()));\r\n    }\r\n    else if(selectedOption == moveRequestUp.get()){\r\n        fMoveQTreeWidgetItem(ui->treeWidget->currentItem(), -1);\r\n        setProjectHasChanged();\r\n    }\r\n    else if(selectedOption == moveRequestDown.get()){\r\n        fMoveQTreeWidgetItem(ui->treeWidget->currentItem(), 1);\r\n        setProjectHasChanged();\r\n    }\r\n    else if(selectedOption == deleteRequest.get()){\r\n        removeRequest(FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(ui->treeWidget->currentItem()));\r\n    }\r\n    else if(selectedOption == projectProperties.get()){\r\n        openProjectProperties();\r\n    }\r\n}\r\n\r\n// This signal is emitted when the current item changes.\r\n// The current item is specified by current, and this replaces the previous current item.\r\nvoid MainWindow::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)\r\n{\r\n    FRequestTreeWidgetItem* currentFRequestItem = nullptr;\r\n    FRequestTreeWidgetItem* previousFRequestItem = nullptr;\r\n\r\n    if(current != nullptr){\r\n        currentFRequestItem = FRequestTreeWidgetItem::fromQTreeWidgetItem(current);\r\n\r\n        // Add the icon if necessary\r\n        if(ui->actionShow_Request_Types_Icons->isChecked() && !currentFRequestItem->isProjectItem && currentFRequestItem->hasEmptyIcon()){\r\n            setIconForRequest(static_cast<FRequestTreeWidgetRequestItem*>(currentFRequestItem));\r\n        }\r\n    }\r\n\r\n    if(previous != nullptr){\r\n        previousFRequestItem = FRequestTreeWidgetItem::fromQTreeWidgetItem(previous);\r\n    }\r\n\r\n    // Save previous item\r\n    if(previousFRequestItem != nullptr && !previousFRequestItem->isProjectItem)\r\n    {\r\n        updateTreeWidgetItemContent(static_cast<FRequestTreeWidgetRequestItem*>(previousFRequestItem));\r\n    }\r\n\r\n    // Update window for new item\r\n    if(currentFRequestItem != nullptr){\r\n\r\n        if(!currentFRequestItem->isProjectItem){\r\n\r\n            this->currentItem = static_cast<FRequestTreeWidgetRequestItem*>(currentFRequestItem);\r\n\r\n            if(!this->ignoreAnyChangesToProject.ConditionIsSet()){\r\n                reloadRequest(this->currentItem);\r\n            }\r\n\r\n            // Hide project requests number if project item hasn't selected\r\n            if(!this->lbProjectInfo.text().isEmpty()){\r\n                this->lbProjectInfo.setText(QString());\r\n            }\r\n        }\r\n        else{\r\n            // If is the project display the number of requests that this has in status bar\r\n            const int projectRequestsNumber = this->currentProjectItem->childCount();\r\n\r\n            // Singular ? Plural ?\r\n            const QString requestText = projectRequestsNumber == 1 ? \" request\" : \" requests\";\r\n\r\n            this->lbProjectInfo.setText(this->currentProjectItem->projectName + \" has a total of \" + QString::number(projectRequestsNumber) + requestText);\r\n        }\r\n\r\n        updateWindowTitle();\r\n    }\r\n\r\n}\r\n\r\n// This signal is emitted when the contents of the column in the specified item changes.\r\nvoid MainWindow::on_treeWidget_itemChanged(QTreeWidgetItem *item, int)\r\n{\r\n    FRequestTreeWidgetItem *newItem = FRequestTreeWidgetItem::fromQTreeWidgetItem(item);\r\n\r\n    setProjectHasChanged();\r\n\r\n    bool updateInterface = false;\r\n\r\n    // Only necessary to create if the item exists (project requests are only created in on_treeWidget_currentItemChanged)\r\n\r\n    // If name had changed update the project requests\r\n\r\n    if(!newItem->isProjectItem){ // Request\r\n\r\n        FRequestTreeWidgetRequestItem * const newItemRequest = static_cast<FRequestTreeWidgetRequestItem*>(newItem);\r\n\r\n        if(item->text(0) != newItemRequest->itemContent.name){\r\n            updateTreeWidgetItemContent(newItemRequest); // update request content\r\n            updateInterface = true;\r\n        }\r\n    }\r\n    else{ // Project\r\n\r\n        FRequestTreeWidgetProjectItem * const newItemProject = static_cast<FRequestTreeWidgetProjectItem*>(newItem);\r\n\r\n        if(item->text(0) != newItemProject->projectName){\r\n            newItemProject->projectName = item->text(0); // update project name\r\n            updateInterface = true;\r\n        }\r\n\r\n    }\r\n\r\n    if(updateInterface){\r\n        // Set item tooltip (same as text)\r\n        item->setToolTip(0, item->text(0));\r\n\r\n        updateWindowTitle();\r\n    }\r\n}\r\n\r\nvoid MainWindow::updateWindowTitle(){\r\n\r\n    // using QStringBuilder concatenation method:\r\n    // https://wiki.qt.io/Using_QString_Effectively\r\n    QString fRequestTitle;\r\n\r\n    if(this->lastProjectFilePath.isEmpty()){\r\n        fRequestTitle = fRequestTitle % \"Untitled\";\r\n    }\r\n    else{\r\n        fRequestTitle = fRequestTitle % Util::FileSystem::cutNameWithoutBackSlash(this->lastProjectFilePath);\r\n    }\r\n\r\n    fRequestTitle = fRequestTitle % \" - \" % this->currentProjectItem->projectName;\r\n\r\n    if(this->currentItem != nullptr){\r\n        fRequestTitle = fRequestTitle % \"/\" % this->currentItem->text(0);\r\n    }\r\n\r\n    fRequestTitle = fRequestTitle % \" - \" % GlobalVars::AppName % \" \" % GlobalVars::AppVersion;\r\n\r\n    if(this->unsavedChangesExist){\r\n        fRequestTitle = fRequestTitle % \"*\";\r\n    }\r\n\r\n    setWindowTitle(fRequestTitle);\r\n}\r\n\r\nFRequestTreeWidgetProjectItem* MainWindow::addProjectItem(const QString &projectName, const QString &projectUuid){\r\n    FRequestTreeWidgetProjectItem *projectFolder = new FRequestTreeWidgetProjectItem(QStringList() << projectName, projectUuid);\r\n    projectFolder->setIcon(0, QIcon(\":/icons/projects_folder_icon.png\"));\r\n    projectFolder->setToolTip(0, projectFolder->text(0));\r\n    projectFolder->setFlags(projectFolder->flags() | Qt::ItemIsEditable);\r\n    ui->treeWidget->addTopLevelItem(projectFolder);\r\n    projectFolder->setExpanded(true);\r\n\r\n    return projectFolder;\r\n}\r\n\r\nFRequestTreeWidgetRequestItem* MainWindow::addRequestItem(const QString &requestName, const QString &projectUuid, FRequestTreeWidgetProjectItem * const currentProject){\r\n    FRequestTreeWidgetRequestItem *newRequest = new FRequestTreeWidgetRequestItem(QStringList() << requestName, projectUuid);\r\n    newRequest->setToolTip(0, newRequest->text(0));\r\n    newRequest->setFlags((newRequest->flags() | Qt::ItemIsEditable) ^ Qt::ItemIsDropEnabled); // don't allow drop inside another items\r\n    currentProject->addRequestItemChild(newRequest);\r\n\r\n    return newRequest;\r\n}\r\n\r\nvoid MainWindow::setIconForRequest(FRequestTreeWidgetRequestItem * const item){\r\n\r\n    if(this->generatedIconCache.contains(item->itemContent.requestType)){\r\n        item->setIcon(0, this->generatedIconCache.value(item->itemContent.requestType));\r\n    }\r\n    else{ // generate the necessary icon and add it to our cache\r\n        QPixmap myIcon(48,16);\r\n        myIcon.fill(Qt::transparent);\r\n\r\n        QPainter painter( &myIcon );\r\n        painter.setFont(item->font(0));\r\n\r\n        QString textToDraw;\r\n        std::unique_ptr<QPen> colorToDraw;\r\n\r\n        switch(item->itemContent.requestType){\r\n        case UtilFRequest::RequestType::GET_OPTION:{\r\n            textToDraw = \"GET\";\r\n            colorToDraw = std::make_unique<QPen>(0x0066ff);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::POST_OPTION:{\r\n            textToDraw = \"POST\";\r\n            colorToDraw = std::make_unique<QPen>(Qt::darkGreen);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::PUT_OPTION:{\r\n            textToDraw = \"PUT\";\r\n            colorToDraw = std::make_unique<QPen>(0xFFAD00);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::DELETE_OPTION:{\r\n            textToDraw = \"DEL\";\r\n            colorToDraw = std::make_unique<QPen>(Qt::red);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::PATCH_OPTION:{\r\n            textToDraw = \"PTCH\";\r\n            colorToDraw = std::make_unique<QPen>(Qt::magenta);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::HEAD_OPTION:{\r\n            textToDraw = \"HEAD\";\r\n            colorToDraw = std::make_unique<QPen>(0x4EC995);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::TRACE_OPTION:{\r\n            textToDraw = \"TRCE\";\r\n            colorToDraw = std::make_unique<QPen>(Qt::darkYellow);\r\n            break;\r\n        }\r\n        case UtilFRequest::RequestType::OPTIONS_OPTION:{\r\n            textToDraw = \"OPT\";\r\n            colorToDraw = std::make_unique<QPen>(Qt::darkGray);\r\n            break;\r\n        }\r\n        default:{\r\n            const QString errorMessage = \"Couldn't set icon for request \" + item->text(0) +\r\n                    \" unknown request type: \" + QString::number(static_cast<int>(item->itemContent.requestType));\r\n            LOG_ERROR << errorMessage;\r\n            Util::Dialogs::showError(errorMessage);\r\n            return;\r\n        }\r\n        }\r\n\r\n        painter.setPen(*colorToDraw);\r\n        painter.drawText( QRect(0, 0, myIcon.width(), myIcon.height()), Qt::AlignCenter, textToDraw );\r\n\r\n        item->setIcon(0, *this->generatedIconCache.insert(item->itemContent.requestType, QIcon(myIcon)));\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::setNewProject(){\r\n\r\n    if(this->unsavedChangesExist){\r\n        QMessageBox::StandardButton result = askToSaveCurrentProject();\r\n        if(result == QMessageBox::StandardButton::Cancel){\r\n            return;\r\n        }\r\n    }\r\n\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n\r\n    clearEverything();\r\n\r\n    FRequestTreeWidgetProjectItem *projectFolder = addProjectItem(\"New Project\", getNewUuid());\r\n    FRequestTreeWidgetRequestItem *newRequest = addRequestItem(\"New Request\", getNewUuid(), projectFolder);\r\n\r\n    newRequest->setSelected(true);\r\n\r\n    this->currentProjectItem = projectFolder;\r\n    this->currentItem = newRequest;\r\n\r\n    this->currentProjectItem->projectName = projectFolder->text(0);\r\n\r\n    // Necessary in order to currentIndexChanged to work correctly (select it is not enough)\r\n    ui->treeWidget->setCurrentItem(newRequest);\r\n\r\n    this->lastProjectFilePath = QString();\r\n\r\n    if(this->currentSettings.defaultHeaders.useDefaultHeaders){\r\n        addDefaultHeaders();\r\n    }\r\n\r\n    this->unsavedChangesExist = false;\r\n    updateWindowTitle(); // it doesn't get called automatically here\r\n\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n\r\n\r\n}\r\n\r\nQVector<UtilFRequest::HttpHeader> MainWindow::getRequestHeaders(){\r\n\r\n    QVector<UtilFRequest::HttpHeader> requestHeaders;\r\n\r\n    for(int i = 0; i < ui->twRequestHeadersKeyValue->rowCount(); i++){\r\n\r\n        if (!UtilFRequest::isGlobalHeaderTableWidgetRow(ui->twRequestHeadersKeyValue, i)) {\r\n            UtilFRequest::HttpHeader currentHeader;\r\n\r\n            currentHeader.name = ui->twRequestHeadersKeyValue->item(i, 0)->text();\r\n            currentHeader.value = ui->twRequestHeadersKeyValue->item(i, 1)->text();\r\n\r\n            requestHeaders.append(currentHeader);\r\n        }\r\n    }\r\n\r\n    return requestHeaders;\r\n}\r\n\r\nQVector<UtilFRequest::HttpFormKeyValueType> MainWindow::getRequestForm(){\r\n\r\n    QVector<UtilFRequest::HttpFormKeyValueType> requestForm;\r\n\r\n    for(int i = 0; i < ui->twRequestBodyKeyValue->rowCount(); i++){\r\n\r\n        // TODO use enum for index\r\n        UtilFRequest::HttpFormKeyValueType currentFormKeyValue(\r\n                    ui->twRequestBodyKeyValue->item(i, 0)->text(),\r\n                    ui->twRequestBodyKeyValue->item(i, 1)->text(),\r\n                    UtilFRequest::getFormKeyTypeByString(ui->twRequestBodyKeyValue->item(i, 2)->text())\r\n                    );\r\n\r\n        requestForm.append(currentFormKeyValue);\r\n    }\r\n\r\n    return requestForm;\r\n}\r\n\r\n\r\nvoid MainWindow::updateTreeWidgetItemContent(FRequestTreeWidgetRequestItem * const requestItem){\r\n    requestItem->itemContent.name = requestItem->text(0);\r\n    requestItem->itemContent.path = ui->lePath->text();\r\n\r\n    requestItem->itemContent.bOverridesMainUrl = ui->cbRequestOverrideMainUrl->isChecked();\r\n    requestItem->itemContent.overrideMainUrl = ui->leRequestOverrideMainUrl->text();\r\n    requestItem->itemContent.bDisableGlobalHeaders = ui->cbDisableGlobalHeaders->isChecked();\r\n\r\n    requestItem->itemContent.headers = getRequestHeaders();\r\n\r\n    requestItem->itemContent.order = requestItem->parent()->indexOfChild(requestItem);\r\n\r\n    requestItem->itemContent.bodyType = UtilFRequest::getBodyTypeByString(ui->cbBodyType->currentText());\r\n\r\n    switch(requestItem->itemContent.bodyType){\r\n    case UtilFRequest::BodyType::RAW:\r\n    {\r\n        requestItem->itemContent.body = ui->pteRequestBody->toPlainText();\r\n        break;\r\n    }\r\n    case UtilFRequest::BodyType::FORM_DATA:\r\n    {\r\n        requestItem->itemContent.bodyForm = getRequestForm();\r\n        break;\r\n    }\r\n    case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\r\n    {\r\n        requestItem->itemContent.bodyForm = getRequestForm();\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        const QString errorMessage = \"Invalid body type \" + QString::number(static_cast<int>(requestItem->itemContent.bodyType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n\r\n    requestItem->itemContent.requestType = UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText());\r\n\r\n    requestItem->itemContent.bDownloadResponseAsFile = ui->cbDownloadResponseAsFile->isChecked();\r\n}\r\n\r\nvoid MainWindow::saveProjectState(const QString &filePath)\r\n{\r\n\r\n    // Make sure the current request is updated in memory\r\n    if(this->currentItem != nullptr){\r\n        updateTreeWidgetItemContent(this->currentItem);\r\n    }\r\n\r\n    try{\r\n        ProjectFileFRequest::saveProjectDataToFile(filePath, fetchCurrentProjectData(), this->uuidsToCleanUp);\r\n\r\n        this->currentSettings.lastProjectPath = QFileInfo(filePath).absoluteDir().path();\r\n\r\n        this->lastProjectFilePath = filePath;\r\n        this->uuidsToCleanUp.clear();\r\n        this->unsavedChangesExist = false;\r\n        addNewRecentProject(filePath);\r\n\r\n        updateWindowTitle();\r\n\r\n        Util::StatusBar::showSuccess(ui->statusBar, \"Project saved with success!\");\r\n    }\r\n    catch(const std::exception& e){\r\n        const QString errorMessage = QString(\"Couldn't save project file. Save aborted.\\n\") + e.what();\r\n        LOG_ERROR << errorMessage;\r\n        Util::Dialogs::showError(errorMessage);\r\n        Util::StatusBar::showError(ui->statusBar, \"Couldn't save project file.\");\r\n    }\r\n}\r\n\r\nvoid MainWindow::loadProjectState(const QString &filePath)\r\n{\r\n\r\n    if(this->unsavedChangesExist){\r\n        QMessageBox::StandardButton result = askToSaveCurrentProject();\r\n        if(result == QMessageBox::StandardButton::Cancel){\r\n            return;\r\n        }\r\n    }\r\n\r\n    // Prepare for project loading\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n\r\n    try{\r\n        std::unique_ptr<ProjectFileFRequest::ProjectData> projectData =\r\n                std::make_unique<ProjectFileFRequest::ProjectData>(ProjectFileFRequest::readProjectDataFromFile(filePath));\r\n\r\n        clearEverything();\r\n\r\n        this->currentProjectItem = addProjectItem(projectData->projectName, projectData->projectUuid);\r\n        this->currentProjectItem->projectName = projectData->projectName;\r\n        this->currentProjectItem->projectMainUrl = projectData->mainUrl;\r\n        this->currentProjectItem->authData = projectData->authData;\r\n        this->currentProjectItem->saveIdentCharacter = projectData->saveIdentCharacter;\r\n        this->currentProjectItem->globalHeaders = projectData->globalHeaders;\r\n\r\n        // Order them by the correct order\r\n        std::sort(\r\n                    projectData->projectRequests.begin(),\r\n                    projectData->projectRequests.end(),\r\n                    [](const UtilFRequest::RequestInfo &first, const UtilFRequest::RequestInfo &second){ return first.order < second.order; }\r\n        );\r\n\r\n        // Now the items are in the correct order, we can now load them in the interface\r\n        for(int i=0; i<projectData->projectRequests.size(); i++){\r\n\r\n            UtilFRequest::RequestInfo &currentRequestInfo = projectData->projectRequests[i];\r\n\r\n            // fix order\r\n            currentRequestInfo.order = i;\r\n\r\n            FRequestTreeWidgetRequestItem *currRequest = addRequestItem(currentRequestInfo.name, currentRequestInfo.uuid, this->currentProjectItem);\r\n            currRequest->itemContent = currentRequestInfo;\r\n\r\n            if(ui->actionShow_Request_Types_Icons->isChecked()){\r\n                setIconForRequest(currRequest);\r\n            }\r\n\r\n            // Load first request\r\n            if(i==0){\r\n                reloadRequest(currRequest);\r\n                ui->treeWidget->setCurrentItem(currRequest);\r\n                this->currentItem = currRequest;\r\n            }\r\n\r\n        }\r\n\r\n        // All items loaded, finally check if we don't have an authentication yet.\r\n        // If we don't, check if it is present in config file and load it from there\r\n\r\n        if(this->currentProjectItem->authData == nullptr &&\r\n                this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.contains(this->currentProjectItem->getUuid())){\r\n            // Project has auth data in config file, load it\r\n\r\n            this->currentProjectItem->authData = this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.value(this->currentProjectItem->getUuid()).authData;\r\n        }\r\n\r\n        this->currentSettings.lastProjectPath = QFileInfo(filePath).absoluteDir().path();\r\n\r\n        this->lastProjectFilePath = filePath;\r\n        this->unsavedChangesExist = false;\r\n\r\n        this->currentProjectAuthenticationWasMade = false;\r\n\r\n        addNewRecentProject(filePath);\r\n\r\n        updateWindowTitle();\r\n\r\n        Util::StatusBar::showSuccess(ui->statusBar, \"Project loaded successfully.\");\r\n    }\r\n    catch(const std::exception& e){\r\n        const QString errorMessage = \"Couldn't load the FRequest project. Error: \" + QString(e.what());\r\n        LOG_ERROR << errorMessage;\r\n        Util::Dialogs::showError(errorMessage);\r\n        Util::StatusBar::showError(ui->statusBar, \"Couldn't load project.\");\r\n    }\r\n\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n}\r\n\r\nProjectFileFRequest::ProjectData MainWindow::fetchCurrentProjectData(){\r\n    ProjectFileFRequest::ProjectData currentProjectData;\r\n\r\n    currentProjectData.projectName = this->currentProjectItem->projectName;\r\n    currentProjectData.mainUrl = this->currentProjectItem->projectMainUrl;\r\n    currentProjectData.projectUuid = this->currentProjectItem->getUuid();\r\n    currentProjectData.authData = this->currentProjectItem->authData;\r\n    currentProjectData.saveIdentCharacter = this->currentProjectItem->saveIdentCharacter;\r\n    currentProjectData.globalHeaders = this->currentProjectItem->globalHeaders;\r\n\r\n    // Save by the current tree order\r\n    for(int i=0; i<this->currentProjectItem->childCount(); i++){\r\n\r\n        UtilFRequest::RequestInfo &currentRequest = FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(this->currentProjectItem->child(i))->itemContent;\r\n\r\n        currentRequest.order = i;\r\n\r\n        currentProjectData.projectRequests.append(currentRequest);\r\n    }\r\n\r\n    return currentProjectData;\r\n}\r\n\r\nvoid MainWindow::on_actionNew_Project_triggered()\r\n{\r\n    setNewProject();\r\n}\r\n\r\nvoid MainWindow::on_actionSave_Project_triggered()\r\n{\r\n    if(this->lastProjectFilePath.isEmpty()){\r\n        on_actionSave_Project_As_triggered();\r\n        return;\r\n    }\r\n\r\n    saveProjectState(this->lastProjectFilePath);\r\n}\r\n\r\nvoid MainWindow::on_actionSave_Project_As_triggered()\r\n{\r\n    QString filePath = QFileDialog::getSaveFileName(this, tr(\"Save File\"),\r\n                                                    this->currentSettings.lastProjectPath,\r\n                                                    tr(\"FRequest project files (*.frp)\"));\r\n\r\n    if(!filePath.isEmpty()){\r\n        saveProjectState(filePath);\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_actionLoad_Project_triggered()\r\n{\r\n    QString filePath = QFileDialog::getOpenFileName(this, tr(\"Load File\"),\r\n                                                    this->currentSettings.lastProjectPath,\r\n                                                    tr(\"FRequest project files (*.frp)\"));\r\n    if(!filePath.isEmpty()){\r\n        loadProjectState(filePath);\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_actionExit_triggered()\r\n{\r\n    this->close();\r\n}\r\n\r\nvoid MainWindow::on_actionAbout_triggered()\r\n{\r\n    //Show about dialog\r\n    (new About(this))->show(); //it destroys itself when finished.\r\n}\r\n\r\nvoid MainWindow::on_actionProject1_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject1->text());\r\n}\r\n\r\nvoid MainWindow::on_actionProject2_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject2->text());\r\n}\r\n\r\nvoid MainWindow::on_actionProject3_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject3->text());\r\n}\r\n\r\nvoid MainWindow::on_actionProject4_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject4->text());\r\n}\r\n\r\nvoid MainWindow::on_actionProject5_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject5->text());\r\n}\r\n\r\nvoid MainWindow::on_actionProject6_triggered()\r\n{\r\n    loadProjectState(this->ui->actionProject6->text());\r\n}\r\n\r\nvoid MainWindow::on_actionFormat_Response_Body_triggered()\r\n{\r\n    formatResponseBody(getResponseCurrentSerializationFormatType());\r\n}\r\n\r\nvoid MainWindow::on_actionFormat_Request_body_triggered()\r\n{\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n    formatRequestBody(getRequestCurrentSerializationFormatType());\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n}\r\n\r\nvoid MainWindow::reloadRequest(FRequestTreeWidgetRequestItem* const item){\r\n\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n\r\n    UtilFRequest::RequestInfo info = item->itemContent;\r\n\r\n    // Clear old contents\r\n    clearRequestAndResponse();\r\n\r\n    ui->lePath->setText(info.path);\r\n    ui->cbRequestOverrideMainUrl->setChecked(info.bOverridesMainUrl);\r\n    ui->leRequestOverrideMainUrl->setText(info.overrideMainUrl);\r\n    ui->cbDisableGlobalHeaders->setChecked(info.bDisableGlobalHeaders);\r\n\r\n    setRequestType(info.requestType);\r\n\r\n    // Aux lambda to avoid duplicated code for FORM_DATA / X_FORM_WWW_URLENCODED\r\n    auto fFillRequestBodyKeyValueTable = [](const QVector<UtilFRequest::HttpFormKeyValueType> &bodyForm, QTableWidget * const table){\r\n        for(const UtilFRequest::HttpFormKeyValueType &currFormKeyValue : bodyForm){\r\n            UtilFRequest::addRequestFormBodyRow(table, currFormKeyValue.key, currFormKeyValue.value, currFormKeyValue.type);\r\n        }\r\n    };\r\n\r\n    ui->cbBodyType->setCurrentText(UtilFRequest::getBodyTypeString(info.bodyType));\r\n\r\n    switch(info.bodyType){\r\n    case UtilFRequest::BodyType::RAW:\r\n    {\r\n        ui->pteRequestBody->setPlainText(info.body);\r\n        break;\r\n    }\r\n    case UtilFRequest::BodyType::FORM_DATA:\r\n    {\r\n        fFillRequestBodyKeyValueTable(info.bodyForm, ui->twRequestBodyKeyValue);\r\n        break;\r\n    }\r\n    case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\r\n    {\r\n        fFillRequestBodyKeyValueTable(info.bodyForm, ui->twRequestBodyKeyValue);\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        const QString errorMessage = \"Invalid body type \" + QString::number(static_cast<int>(info.bodyType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n\r\n    formatRequestBody(getRequestCurrentSerializationFormatType());\r\n\r\n    addGlobalHeaders();\r\n\r\n    for(const UtilFRequest::HttpHeader &currentHeader : info.headers){\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << currentHeader.name << currentHeader.value);\r\n    }\r\n\r\n    ui->cbDownloadResponseAsFile->setChecked(info.bDownloadResponseAsFile);\r\n\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n}\r\n\r\nvoid MainWindow::clearOlderResponse(){\r\n    this->lastReplyStatusError = 0;\r\n    ui->lbResponseBodyWarningIcon->hide();\r\n    ui->lbResponseBodyWarningMessage->hide();\r\n    ui->pteResponseBody->clear();\r\n    ui->pteResponseHeaders->clear();\r\n    ui->lbStatus->clear();\r\n    ui->lbDescription->clear();\r\n    ui->lbTimeElapsed->clear();\r\n}\r\n\r\nvoid MainWindow::clearRequestAndResponse(){\r\n    ui->leRequestOverrideMainUrl->clear();\r\n    ui->cbRequestOverrideMainUrl->setChecked(false);\r\n    ui->lePath->clear();\r\n    ui->leFullPath->clear();\r\n    ui->cbRequestType->setCurrentText(\"GET\");\r\n    ui->cbBodyType->setCurrentIndex(0);\r\n    ui->cbResponseChooseHeader->setCurrentIndex(0);\r\n    ui->pteRequestBody->clear();\r\n    Util::TableWidget::clearContentsNoPrompt(ui->twRequestBodyKeyValue);\r\n    Util::TableWidget::clearContentsNoPrompt(ui->twRequestHeadersKeyValue);\r\n    ui->cbDownloadResponseAsFile->setChecked(false);\r\n\r\n    clearOlderResponse();\r\n}\r\n\r\nvoid MainWindow::clearEverything(){\r\n    // order is important\r\n    // (we should clear the pointers first, because clearing tree widgets\r\n    // will then call update title that will try to access pointer to unexisting objects)\r\n    this->uuidsInUse.clear();\r\n    this->uuidsToCleanUp.clear();\r\n    this->currentItem = nullptr;\r\n    this->currentProjectItem = nullptr;\r\n    ui->treeWidget->clear();\r\n    ui->leRequestsFilter->clear();\r\n    clearRequestAndResponse();\r\n}\r\n\r\nvoid MainWindow::on_cbResponseChooseHeader_currentIndexChanged(const QString &arg1)\r\n{\r\n\r\n    if(arg1 == \"Content-type: application/json\"){\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << \"Content-type\" << \"application/json\");\r\n    }\r\n    else if(arg1 == \"Content-type: application/xml\"){\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << \"Content-type\" << \"application/xml\");\r\n    }\r\n    else if(arg1 == \"Content-type: multipart/form-data\"){\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << \"Content-type\" << \"multipart/form-data\");\r\n    }\r\n    else if(arg1 == \"Content-type: application/x-www-form-urlencoded\"){\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << \"Content-type\" << \"application/x-www-form-urlencoded\");\r\n    }\r\n\r\n    ui->cbResponseChooseHeader->setCurrentIndex(0);\r\n}\r\n\r\nvoid MainWindow::closeEvent(QCloseEvent *event){\r\n\r\n    if(this->unsavedChangesExist){\r\n        QMessageBox::StandardButton result = askToSaveCurrentProject();\r\n        if(result == QMessageBox::StandardButton::Cancel){\r\n            event->ignore();\r\n            return;\r\n        }\r\n    }\r\n\r\n    if(this->currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting){\r\n        this->currentSettings.windowsGeometry.mainWindow_MainWindowGeometry = this->saveGeometry();\r\n        this->currentSettings.windowsGeometry.mainWindow_RequestsSplitterState = ui->splitter->saveState();\r\n        this->currentSettings.windowsGeometry.mainWindow_RequestResponseSplitterState = ui->splitter_2->saveState();\r\n    }\r\n\r\n    // Save unsaved settings\r\n    saveCurrentSettings();\r\n\r\n    // Exit application (this will also close all other windows which don't have parent)\r\n    QApplication::quit();\r\n}\r\n\r\nvoid MainWindow::loadRecentProjects(){\r\n    for(const QString &currentRecentPath : this->currentSettings.recentProjectsPaths){\r\n        recentProjectsList.append(currentRecentPath);\r\n    }\r\n\r\n    reloadRecentProjectsMenu();\r\n\r\n}\r\n\r\nvoid MainWindow::addNewRecentProject(const QString &filePath){\r\n\r\n    // If the new project is equal to the last one simply ignore\r\n    if(this->currentSettings.recentProjectsPaths.size() > 0 && filePath == this->currentSettings.recentProjectsPaths[0]){\r\n        return;\r\n    }\r\n\r\n    // If the item already exists in our list remove it, so it can go to the top again\r\n    for(auto it = this->recentProjectsList.begin(); it != this->recentProjectsList.end();){\r\n        if(*it == filePath){\r\n            it = this->recentProjectsList.erase(it);\r\n        }\r\n        else{\r\n            it++;\r\n        }\r\n    }\r\n\r\n    // if we gonna overflow our list, remove the older item to reserve space to the new one\r\n    if(this->recentProjectsList.size()==GlobalVars::AppRecentProjectsMaxSize){\r\n        this->recentProjectsList.removeLast();\r\n    }\r\n\r\n    this->currentSettings.lastProjectPath = QFileInfo(filePath).absoluteDir().path();\r\n\r\n    // add new recent file\r\n    this->recentProjectsList.prepend(filePath);\r\n\r\n    reloadRecentProjectsMenu();\r\n\r\n    saveRecentProjects();\r\n}\r\n\r\nvoid MainWindow::reloadRecentProjectsMenu(){\r\n\r\n    ui->menuRecent_Projects->setEnabled(false);\r\n    ui->actionProject1->setVisible(false);\r\n    ui->actionProject2->setVisible(false);\r\n    ui->actionProject3->setVisible(false);\r\n    ui->actionProject4->setVisible(false);\r\n    ui->actionProject5->setVisible(false);\r\n    ui->actionProject6->setVisible(false);\r\n\r\n    {\r\n        QList<QString>::const_iterator it;\r\n        int i;\r\n        for(it = recentProjectsList.cbegin(), i=0; it != recentProjectsList.cend(); it++, i++){\r\n\r\n            QAction* currAction = nullptr;\r\n\r\n            switch (i){\r\n            case 0:\r\n                currAction = ui->actionProject1;\r\n                break;\r\n            case 1:\r\n                currAction = ui->actionProject2;\r\n                break;\r\n            case 2:\r\n                currAction = ui->actionProject3;\r\n                break;\r\n            case 3:\r\n                currAction = ui->actionProject4;\r\n                break;\r\n            case 4:\r\n                currAction = ui->actionProject5;\r\n                break;\r\n            case 5:\r\n                currAction = ui->actionProject6;\r\n                break;\r\n            }\r\n\r\n            if(currAction){\r\n                ui->menuRecent_Projects->setEnabled(true);\r\n                currAction->setText(*it);\r\n                currAction->setVisible(true);\r\n            }\r\n        }\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::saveRecentProjects(){\r\n    this->currentSettings.recentProjectsPaths = recentProjectsList.toVector();\r\n}\r\n\r\nvoid MainWindow::on_tbRequestHeadersKeyValueAdd_clicked()\r\n{\r\n    Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << \"\" << \"\");\r\n}\r\n\r\nvoid MainWindow::on_tbRequestHeadersKeyValueRemove_clicked()\r\n{\r\n    int size = Util::TableWidget::getSelectedRows(ui->twRequestHeadersKeyValue).size();\r\n\r\n    if(size==0){\r\n        Util::Dialogs::showInfo(\"Select a row first!\");\r\n        return;\r\n    }\r\n\r\n    if(Util::Dialogs::showQuestion(this, \"Are you sure you want to remove all selected rows?\")){\r\n        for(int i=0; i < size; i++){\r\n            ui->twRequestHeadersKeyValue->removeRow(Util::TableWidget::getSelectedRows(ui->twRequestHeadersKeyValue).at(size-i-1).row());\r\n        }\r\n\r\n        Util::StatusBar::showSuccess(ui->statusBar, \"Key-Value rows deleted\");\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_twRequestHeadersKeyValue_cellChanged(int row, int column)\r\n{\r\n    setProjectHasChanged();\r\n\r\n    if(!ui->twRequestHeadersKeyValue->item(row, column)->text().trimmed().isEmpty()){\r\n        ui->twRequestHeadersKeyValue->resizeColumnsToContents();\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_tbRequestBodyKeyValueAdd_clicked()\r\n{\r\n    UtilFRequest::addRequestFormBodyRow(ui->twRequestBodyKeyValue, \"\", \"\", UtilFRequest::FormKeyValueType::TEXT);\r\n}\r\n\r\nvoid MainWindow::on_tbRequestBodyFile_clicked()\r\n{\r\n    QString filePath = QFileDialog::getOpenFileName(this, tr(\"Choose a file to upload\"));\r\n\r\n    // Only add a row if a file was selected\r\n    if(!filePath.isEmpty()){\r\n        UtilFRequest::addRequestFormBodyRow(ui->twRequestBodyKeyValue, \"\", filePath, UtilFRequest::FormKeyValueType::FILE);\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_tbRequestBodyKeyValueRemove_clicked()\r\n{\r\n    int size = Util::TableWidget::getSelectedRows(ui->twRequestBodyKeyValue).size();\r\n\r\n    if(size==0){\r\n        Util::Dialogs::showInfo(\"Select a row first!\");\r\n        return;\r\n    }\r\n\r\n    if(Util::Dialogs::showQuestion(this, \"Are you sure you want to remove all selected rows?\")){\r\n        for(int i=0; i < size; i++){\r\n            ui->twRequestBodyKeyValue->removeRow(Util::TableWidget::getSelectedRows(ui->twRequestBodyKeyValue).at(size-i-1).row());\r\n        }\r\n\r\n        Util::StatusBar::showSuccess(ui->statusBar, \"Key-Value rows deleted\");\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_twRequestBodyKeyValue_cellChanged(int row, int column)\r\n{\r\n    setProjectHasChanged();\r\n\r\n    // TODO use column enums\r\n    if(column != 1 && !ui->twRequestBodyKeyValue->item(row, column)->text().trimmed().isEmpty()){\r\n        ui->twRequestBodyKeyValue->resizeColumnToContents(column);\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_cbBodyType_currentIndexChanged(const QString &arg1)\r\n{\r\n    auto fSetBodyKeyValuesTableVisibility = [=](const bool &isVisible){\r\n        ui->twRequestBodyKeyValue->setVisible(isVisible);\r\n        ui->tbRequestBodyKeyValueAdd->setVisible(isVisible);\r\n        ui->tbRequestBodyFile->setVisible(isVisible);\r\n        ui->tbRequestBodyKeyValueRemove->setVisible(isVisible);\r\n    };\r\n\r\n    // Files are only allowed in form-data, so we need to remove them if the user is changing to something else\r\n    // Before removing them ask the user if that is ok\r\n    if(!this->ignoreAnyChangesToProject.ConditionIsSet() && arg1 != \"form-data\" && formKeyValueInBodyHasFiles()){\r\n\r\n        // revert to form data and don't do more anything if user doesn't approve files rows deletion\r\n        if(Util::Dialogs::showQuestionWithCancel(this, \"You have files rows in the form, changing to \" + arg1 + \" will REMOVE these files rows. Proceed?\") != QMessageBox::Yes){\r\n            this->ignoreAnyChangesToProject.SetCondition();\r\n            ui->cbBodyType->setCurrentText(\"form-data\");\r\n            this->ignoreAnyChangesToProject.UnsetCondition();\r\n            return;\r\n        }\r\n        else{\r\n            removeAllFilesRowsFromFormKeyValueInBody(); // if approved remove the files rows\r\n        }\r\n    }\r\n\r\n    ui->pteRequestBody->hide();\r\n    fSetBodyKeyValuesTableVisibility(false);\r\n\r\n    if(arg1 == \"raw\"){\r\n        ui->pteRequestBody->show();\r\n    }\r\n    else if(arg1 == \"form-data\"){\r\n        fSetBodyKeyValuesTableVisibility(true);\r\n    }\r\n    else if(arg1 == \"x-form-www-urlencoded\"){\r\n        fSetBodyKeyValuesTableVisibility(true);\r\n        ui->tbRequestBodyFile->setVisible(false);\r\n    }\r\n\r\n    if(!this->ignoreAnyChangesToProject.ConditionIsSet()){\r\n        if(ui->twRequestHeadersKeyValue->rowCount() > 0 && (QMessageBox::Yes == Util::Dialogs::showQuestionWithCancel(this, \"You have changed the request body type. Delete previous headers?\"))){\r\n            Util::TableWidget::clearContentsNoPrompt(ui->twRequestHeadersKeyValue);\r\n        }\r\n\r\n        if(this->currentSettings.defaultHeaders.useDefaultHeaders){\r\n            addDefaultHeaders();\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_cbRequestType_currentIndexChanged(const QString &)\r\n{\r\n    // Indicates if body can be set or not depending on the given option\r\n    bool toogle = UtilFRequest::requestTypeMayHaveBody(UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText()));\r\n\r\n    setProjectHasChanged();\r\n\r\n    ui->cbBodyType->setEnabled(toogle);\r\n    ui->twRequestBodyKeyValue->setEnabled(toogle);\r\n    ui->pteRequestBody->setEnabled(toogle);\r\n    ui->tbRequestBodyKeyValueAdd->setEnabled(toogle);\r\n    ui->tbRequestBodyFile->setEnabled(toogle);\r\n    ui->tbRequestBodyKeyValueRemove->setEnabled(toogle);\r\n\r\n    // Save previous item (to update icon)\r\n    if(this->currentItem != nullptr && !this->currentItem->isProjectItem)\r\n    {\r\n        updateTreeWidgetItemContent(this->currentItem);\r\n\r\n        // Update icon\r\n        if(ui->actionShow_Request_Types_Icons->isChecked()){\r\n            setIconForRequest(this->currentItem);\r\n        }\r\n    }\r\n\r\n    if(!this->ignoreAnyChangesToProject.ConditionIsSet()){\r\n        if(ui->twRequestHeadersKeyValue->rowCount() > 0 && (QMessageBox::Yes == Util::Dialogs::showQuestionWithCancel(this, \"You have changed the request type. Delete previous headers?\"))){\r\n            Util::TableWidget::clearContentsNoPrompt(ui->twRequestHeadersKeyValue);\r\n        }\r\n\r\n        if(this->currentSettings.defaultHeaders.useDefaultHeaders){\r\n            addDefaultHeaders();\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_cbRequestOverrideMainUrl_toggled(bool checked)\r\n{\r\n    setProjectHasChanged();\r\n\r\n    ui->leRequestOverrideMainUrl->setEnabled(checked);\r\n\r\n    buildFullPath();\r\n}\r\n\r\nvoid MainWindow::on_cbDisableGlobalHeaders_toggled(bool /*checked*/)\r\n{\r\n    setProjectHasChanged();\r\n}\r\n\r\n\r\nvoid MainWindow::on_actionShow_Request_Types_Icons_triggered(bool checked)\r\n{\r\n    this->ignoreAnyChangesToProject.SetCondition();\r\n    setAllRequestIcons(checked);\r\n    this->currentSettings.showRequestTypesIcons = checked;\r\n    this->ignoreAnyChangesToProject.UnsetCondition();\r\n}\r\n\r\nvoid MainWindow::on_actionCheck_for_updates_triggered()\r\n{\r\n    // This deletes itself once finished\r\n    UpdateChecker::startNewInstance(this->currentSettings);\r\n}\r\n\r\nvoid MainWindow::setAllRequestIcons(bool showIcon){\r\n\r\n    if(showIcon){\r\n        // Set request icons\r\n        for(int i=0; i<this->currentProjectItem->childCount(); i++){\r\n            setIconForRequest(FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(this->currentProjectItem->child(i)));\r\n        }\r\n    }\r\n    else{\r\n        // clear request icons\r\n        for(int i=0; i<this->currentProjectItem->childCount(); i++){\r\n            this->currentProjectItem->child(i)->setIcon(0, QIcon());\r\n        }\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::on_pteRequestBody_textChanged()\r\n{\r\n    setProjectHasChanged();\r\n}\r\n\r\nvoid MainWindow::on_cbDownloadResponseAsFile_toggled(bool)\r\n{\r\n    setProjectHasChanged();\r\n}\r\n\r\nvoid MainWindow::tbAbortRequest_clicked()\r\n{\r\n    QString typeRequest;\r\n\r\n    if(this->authenticationIsRunning){\r\n        typeRequest = \"Authentication\";\r\n    }\r\n    else{\r\n        typeRequest = \"Request\";\r\n    }\r\n\r\n    if(Util::Dialogs::showQuestion(this,\"Are you sure you want to abort the current \" + typeRequest + \"?\")){\r\n        if(this->currentReply.has_value()){\r\n            this->currentReply.value()->abort();\r\n            Util::StatusBar::showError(ui->statusBar, typeRequest + \" was aborted.\");\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::setProjectHasChanged(){\r\n\r\n    if(!this->ignoreAnyChangesToProject.ConditionIsSet() && !this->unsavedChangesExist){\r\n        this->unsavedChangesExist = true;\r\n\r\n        updateWindowTitle();\r\n    }\r\n}\r\n\r\nQMessageBox::StandardButton MainWindow::askToSaveCurrentProject(){\r\n    QMessageBox::StandardButton result =\r\n            Util::Dialogs::showQuestionWithCancel(this,\"There are unsaved changes. Do you want to save the current project?\", QMessageBox::StandardButton::Yes);\r\n\r\n    if(result == QMessageBox::StandardButton::Yes){\r\n        on_actionSave_Project_triggered();\r\n    }\r\n\r\n    return result;\r\n}\r\n\r\nvoid MainWindow::on_tbCopyToClipboardRequest_clicked()\r\n{\r\n    QString textToClipboard;\r\n\r\n    auto fRequestFormToString = [](const QVector<UtilFRequest::HttpFormKeyValueType> &requestForm){\r\n\r\n        QString result;\r\n\r\n        for(int i=0; i < requestForm.size(); i++){\r\n            result = requestForm[i].key + \": \" + requestForm[i].value;\r\n\r\n            if(i != requestForm.size()-1){\r\n                result += \"\\n\";\r\n            }\r\n        }\r\n\r\n        return result;\r\n    };\r\n\r\n    auto fRequestHeadersToString = [](const QVector<UtilFRequest::HttpHeader> &requestHeaders){\r\n\r\n        QString result;\r\n\r\n        for(int i=0; i < requestHeaders.size(); i++){\r\n            result = requestHeaders[i].name + \": \" + requestHeaders[i].value;\r\n\r\n            if(i != requestHeaders.size()-1){\r\n                result += \"\\n\";\r\n            }\r\n        }\r\n\r\n        return result;\r\n    };\r\n\r\n    if(ui->twRequest->tabText(ui->twRequest->currentIndex()) == \"Body\"){\r\n        switch(UtilFRequest::getBodyTypeByString(ui->cbBodyType->currentText())){\r\n        case UtilFRequest::BodyType::RAW:\r\n        {\r\n            textToClipboard = ui->pteRequestBody->toPlainText();\r\n            break;\r\n        }\r\n            break;\r\n        case UtilFRequest::BodyType::FORM_DATA:\r\n        {\r\n            textToClipboard = fRequestFormToString(getRequestForm());\r\n            break;\r\n        }\r\n            break;\r\n        case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\r\n        {\r\n            textToClipboard = fRequestFormToString(getRequestForm());\r\n            break;\r\n        }\r\n        default:\r\n        {\r\n            const QString errorMessage = \"Invalid body type \" + QString::number(static_cast<int>(UtilFRequest::getBodyTypeByString(ui->cbBodyType->currentText()))) + \"'. Program can't proceed.\";\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_FATAL << errorMessage;\r\n            exit(1);\r\n        }\r\n        }\r\n    }\r\n    else if(ui->twRequest->tabText(ui->twRequest->currentIndex()) == \"Headers\"){\r\n        textToClipboard = fRequestHeadersToString(getRequestHeaders());\r\n    }\r\n\r\n    QApplication::clipboard()->setText(textToClipboard);\r\n}\r\n\r\nvoid MainWindow::on_tbCopyToClipboardResponse_clicked()\r\n{\r\n    QString textToClipboard;\r\n\r\n    if(ui->twResponse->tabText(ui->twResponse->currentIndex()) == \"Body\"){\r\n        textToClipboard = ui->pteResponseBody->toPlainText();\r\n    }\r\n    else if(ui->twResponse->tabText(ui->twResponse->currentIndex()) == \"Headers\"){\r\n        textToClipboard = ui->pteResponseHeaders->toPlainText();\r\n    }\r\n\r\n    QApplication::clipboard()->setText(textToClipboard);\r\n}\r\n\r\nvoid MainWindow::on_actionPreferences_triggered()\r\n{\r\n    //Show preferences\r\n    Preferences *preferencesWindow = new Preferences(this, this->currentSettings);\r\n    // this is disconnected automatically once preferences object is destroyed:\r\n    // https://stackoverflow.com/a/9264888/1499019\r\n    connect(preferencesWindow, SIGNAL(saveSettings()), this, SLOT(saveCurrentSettings()), Qt::ConnectionType::DirectConnection);\r\n    preferencesWindow->exec(); //it destroys itself when finished.\r\n}\r\n\r\nvoid MainWindow::saveCurrentSettings(){\r\n    this->configFileManager.saveSettings(this->currentSettings);\r\n}\r\n\r\nvoid MainWindow::addDefaultHeaders(){\r\n\r\n    UtilFRequest::RequestType currentRequestType = UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText());\r\n\r\n    std::experimental::optional<ConfigFileFRequest::ProtocolHeader>& currentProtocolHeader = ConfigFileFRequest::getSettingsHeaderForRequestType(currentRequestType, this->currentSettings);\r\n\r\n    if(currentProtocolHeader.has_value()){\r\n        std::experimental::optional<QVector<UtilFRequest::HttpHeader>> *currentHeaders = nullptr;\r\n\r\n        switch(UtilFRequest::getBodyTypeByString(ui->cbBodyType->currentText())){\r\n        case UtilFRequest::BodyType::RAW:\r\n        {\r\n            currentHeaders = &currentProtocolHeader.value().headers_Raw;\r\n            break;\r\n        }\r\n        case UtilFRequest::BodyType::FORM_DATA:\r\n        {\r\n            currentHeaders = &currentProtocolHeader.value().headers_Form_Data;\r\n            break;\r\n        }\r\n        case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\r\n        {\r\n            currentHeaders = &currentProtocolHeader.value().headers_X_form_www_urlencoded;\r\n            break;\r\n        }\r\n        default:\r\n        {\r\n            const QString errorMessage = \"Invalid body type \" + QString::number(static_cast<int>(UtilFRequest::getBodyTypeByString(ui->cbBodyType->currentText()))) + \"'. Program can't proceed.\";\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_FATAL << errorMessage;\r\n            exit(1);\r\n        }\r\n        }\r\n\r\n        if(currentHeaders == nullptr){\r\n            const QString errorMessage = \"An error ocurred while trying to insert the default headers. currentHeaders == nullptr\";\r\n            LOG_ERROR << errorMessage;\r\n            Util::Dialogs::showError(errorMessage);\r\n            return;\r\n        }\r\n\r\n        if(currentHeaders->has_value()){\r\n            for(const UtilFRequest::HttpHeader &currentHeader : currentHeaders->value()){\r\n                Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << currentHeader.name << currentHeader.value);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::setRequestType(UtilFRequest::RequestType requestType){\r\n    ui->cbRequestType->setCurrentText(UtilFRequest::getRequestTypeString(requestType));\r\n}\r\n\r\nvoid MainWindow::formatRequestBody(const UtilFRequest::SerializationFormatType serializationType){\r\n\r\n    this->xmlRequestBodyHighligher.setDocument(nullptr);\r\n    this->jsonRequestBodyHighligher.setDocument(nullptr);\r\n\r\n    if(serializationType != UtilFRequest::SerializationFormatType::UNKNOWN){\r\n\r\n        switch(serializationType){\r\n        case UtilFRequest::SerializationFormatType::JSON:\r\n        {\r\n            this->jsonRequestBodyHighligher.setDocument(ui->pteRequestBody->document());\r\n\r\n            // we re-highlight immediately because we may want to ignore the change in the plain text edit\r\n            // (is just formatting or re-color), this way frequest doesn't think the project was changed\r\n            this->jsonRequestBodyHighligher.rehighlight();\r\n            break;\r\n        }\r\n        case UtilFRequest::SerializationFormatType::XML:\r\n        {\r\n            this->xmlRequestBodyHighligher.setDocument(ui->pteRequestBody->document());\r\n\r\n            // we re-highlight immediately because we may want to ignore the change in the plain text edit\r\n            // (is just formatting or re-color), this way frequest doesn't think the project was changed\r\n            this->xmlRequestBodyHighligher.rehighlight();\r\n            break;\r\n        }\r\n        default:\r\n        {\r\n            const QString errorMessage = \"Invalid serializationType \" + QString::number(static_cast<int>(serializationType)) + \"'. Program can't proceed.\";\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_FATAL << errorMessage;\r\n            exit(1);\r\n        }\r\n        }\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::formatResponseBody(const UtilFRequest::SerializationFormatType serializationType){\r\n\r\n    this->xmlResponseBodyHighligher.setDocument(nullptr);\r\n    this->jsonResponseBodyHighligher.setDocument(nullptr);\r\n\r\n    if(serializationType != UtilFRequest::SerializationFormatType::UNKNOWN){\r\n\r\n        switch(serializationType){\r\n        case UtilFRequest::SerializationFormatType::JSON:\r\n        {\r\n            this->jsonResponseBodyHighligher.setDocument(ui->pteResponseBody->document());\r\n            break;\r\n        }\r\n        case UtilFRequest::SerializationFormatType::XML:\r\n        {\r\n            this->xmlResponseBodyHighligher.setDocument(ui->pteResponseBody->document());\r\n            break;\r\n        }\r\n        default:\r\n        {\r\n            const QString errorMessage = \"Invalid serializationType \" + QString::number(static_cast<int>(serializationType)) + \"'. Program can't proceed.\";\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_FATAL << errorMessage;\r\n            exit(1);\r\n        }\r\n        }\r\n    }\r\n\r\n}\r\n\r\nbool MainWindow::formKeyValueInBodyIsValid(){\r\n    for(int i = 0; i < ui->twRequestBodyKeyValue->rowCount(); i++){\r\n\r\n        // const QString &currKey = ui->twRequestBodyKeyValue->item(i,0)->text(); // ignore\r\n        const QString &currValue = ui->twRequestBodyKeyValue->item(i,1)->text();\r\n        const UtilFRequest::FormKeyValueType currFormKeyValueType = UtilFRequest::getFormKeyTypeByString(ui->twRequestBodyKeyValue->item(i,2)->text());\r\n\r\n        if(currFormKeyValueType == UtilFRequest::FormKeyValueType::FILE){\r\n            if(!QFile::exists(currValue)){\r\n                const QString errorMessage = \"File '\" + currValue + \"' doesn't exist.\\n\\nPlease fix it in your request body form data and try again.\";\r\n                Util::Dialogs::showError(errorMessage);\r\n                LOG_ERROR << errorMessage;\r\n                return false;\r\n            }\r\n        }\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\nbool MainWindow::formKeyValueInBodyHasFiles(){\r\n    for(int i = 0; i < ui->twRequestBodyKeyValue->rowCount(); i++){\r\n\r\n        const UtilFRequest::FormKeyValueType currFormKeyValueType = UtilFRequest::getFormKeyTypeByString(ui->twRequestBodyKeyValue->item(i,2)->text());\r\n\r\n        if(currFormKeyValueType == UtilFRequest::FormKeyValueType::FILE){\r\n            return true;\r\n        }\r\n    }\r\n\r\n    return false;\r\n}\r\n\r\nbool MainWindow::noDuplicatedKeyExistsInRequestHeaders(const QVector<UtilFRequest::HttpHeader> &headers){\r\n\r\n    // Check for duplicated headers (user error as that does not seem to be allowed by RFCs)\r\n    QVector<UtilFRequest::HttpHeader>::const_iterator itDuplicatedHeader =\r\n            std::adjacent_find(headers.begin(), headers.end(),\r\n                               [](const UtilFRequest::HttpHeader &first, const UtilFRequest::HttpHeader &second){return first.name == second.name;});\r\n\r\n    if(itDuplicatedHeader != headers.end()) {\r\n        const QString errorMessage = \"The header '\" + itDuplicatedHeader->name + \"' is duplicated in the request. This is not allowed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n        return false;\r\n    }\r\n\r\n    return true;\r\n}\r\n\r\nvoid MainWindow::removeAllFilesRowsFromFormKeyValueInBody(){\r\n    for(int i = 0; i < ui->twRequestBodyKeyValue->rowCount(); i++){\r\n\r\n        const UtilFRequest::FormKeyValueType currFormKeyValueType = UtilFRequest::getFormKeyTypeByString(ui->twRequestBodyKeyValue->item(i,2)->text());\r\n\r\n        if(currFormKeyValueType == UtilFRequest::FormKeyValueType::FILE){\r\n            ui->twRequestBodyKeyValue->selectRow(i);\r\n        }\r\n    }\r\n\r\n    Util::TableWidget::deleteSelectedRows(ui->twRequestBodyKeyValue);\r\n}\r\n\r\nUtilFRequest::SerializationFormatType MainWindow::getRequestCurrentSerializationFormatType(){\r\n    UtilFRequest::SerializationFormatType serializationType = UtilFRequest::SerializationFormatType::UNKNOWN;\r\n\r\n    if(ui->actionFormat_Request_body->isChecked()){\r\n        serializationType = UtilFRequest::getSerializationFormatTypeForString(ui->pteRequestBody->toPlainText());\r\n    }\r\n\r\n    return serializationType;\r\n}\r\n\r\nUtilFRequest::SerializationFormatType MainWindow::getResponseCurrentSerializationFormatType(){\r\n    UtilFRequest::SerializationFormatType serializationType = UtilFRequest::SerializationFormatType::UNKNOWN;\r\n\r\n    if(ui->actionFormat_Response_Body->isChecked()){\r\n        serializationType = UtilFRequest::getSerializationFormatTypeForString(ui->pteResponseBody->toPlainText());\r\n    }\r\n\r\n    return serializationType;\r\n}\r\n\r\nQString MainWindow::getNewUuid(){\r\n    QString generatedUuid;\r\n\r\n    // make sure we get a unique identifier (while very small, there it is still possible to exist collisions,\r\n    // plus the xml uuid can be edited by hand by anyone)\r\n    do\r\n    {\r\n        generatedUuid = QUuid::createUuid().toString();\r\n    } while( this->uuidsInUse.contains(generatedUuid) );\r\n\r\n    this->uuidsInUse.insert(generatedUuid);\r\n\r\n    return generatedUuid;\r\n}\r\n\r\nvoid MainWindow::saveProjectProperties(){\r\n\r\n    // Project properties changed, we need to save the project file and maybe the configuration file (for the authentications)\r\n    this->unsavedChangesExist = true;\r\n\r\n    updateWindowTitle();\r\n\r\n    buildFullPath(); // project url may have been updated\r\n\r\n    on_actionSave_Project_triggered();\r\n\r\n    // Do we have auth data to save?\r\n    if(this->currentProjectItem->authData != nullptr){\r\n\r\n        // Assume the credentials are new, so a new authentication may need to be done\r\n        this->currentProjectAuthenticationWasMade = false;\r\n\r\n        // Is to save to config file?\r\n        if(this->currentProjectItem->authData->saveAuthToConfigFile){\r\n\r\n            ConfigFileFRequest::ConfigurationProjectAuthentication currConfigProjAuth;\r\n            currConfigProjAuth.lastProjectName = this->currentProjectItem->projectName;\r\n            currConfigProjAuth.projectUuid = this->currentProjectItem->getUuid();\r\n            currConfigProjAuth.authData = this->currentProjectItem->authData;\r\n\r\n            this->currentSettings.mapOfConfigAuths_UuidToConfigAuth[this->currentProjectItem->getUuid()] =\r\n                    currConfigProjAuth; // add or override config proj auth data\r\n\r\n            saveCurrentSettings();\r\n        }\r\n        else{ // Nop! We are saving to project file. In this case make sure we remove the auth data from config file if it exists\r\n            if(this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.contains(this->currentProjectItem->getUuid())){\r\n                this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.remove(this->currentProjectItem->getUuid());\r\n                saveCurrentSettings();\r\n            }\r\n        }\r\n\r\n\r\n    }\r\n\r\n    // necessary because global headers may have changed\r\n    if(this->currentItem != nullptr) {\r\n        reloadRequest(this->currentItem);\r\n    }\r\n\r\n    if (!this->currentSettings.hideProjectSavedDialog) {\r\n        if(!this->unsavedChangesExist){\r\n            Util::Dialogs::showInfo(\"Project properties saved with success!\");\r\n        }\r\n        else{\r\n            Util::Dialogs::showWarning(\"Project properties weren't saved. Please save the project manually from file menu.\");\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::on_leRequestsFilter_textChanged(const QString &arg1)\r\n{\r\n    QString trimmedFilter = arg1.trimmed();\r\n\r\n    setFilterThemePalette();\r\n\r\n    if(trimmedFilter.isEmpty()){ // if filter is empty\r\n        ui->treeWidget->headerItem()->setText(0, \"Requests\");\r\n\r\n        if(this->currentProjectItem != nullptr){\r\n            for(int i=0; i<this->currentProjectItem->childCount(); i++){\r\n                this->currentProjectItem->child(i)->setHidden(false);\r\n            }\r\n        }\r\n    }\r\n    else{\r\n        ui->treeWidget->headerItem()->setText(0, \"Requests (filtred)\");\r\n\r\n        // Show only the ones which the name match the filter\r\n        if(this->currentProjectItem != nullptr){\r\n            for(int i=0; i<this->currentProjectItem->childCount(); i++){\r\n                if(!this->currentProjectItem->child(i)->text(0).contains(trimmedFilter, Qt::CaseInsensitive)){ // TODO change with enum\r\n                    this->currentProjectItem->child(i)->setHidden(true);\r\n                }\r\n                else{\r\n                    this->currentProjectItem->child(i)->setHidden(false);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nvoid MainWindow::openProjectProperties(){\r\n\r\n    // Show project properties\r\n    ProjectProperties *projectPropertiesDialog = new ProjectProperties(this, this->currentProjectItem);\r\n\r\n    // https://stackoverflow.com/a/9264888/1499019\r\n    connect(projectPropertiesDialog, SIGNAL (signalSaveProjectProperties()), this, SLOT(saveProjectProperties()));\r\n    projectPropertiesDialog->exec(); //it destroys itself when finished.\r\n\r\n}\r\n\r\nvoid MainWindow::on_actionProject_Properties_triggered()\r\n{\r\n    openProjectProperties();\r\n}\r\n\r\nvoid MainWindow::removeRequest(FRequestTreeWidgetRequestItem * const itemToDelete){\r\n\r\n    if(Util::Dialogs::showQuestion(this, \"Remove the request '\" + itemToDelete->text(0) + \"'?\")){\r\n\r\n        QString uuidToRemove = itemToDelete->itemContent.uuid;\r\n\r\n        this->currentProjectItem->removeChild(itemToDelete);\r\n\r\n        this->uuidsToCleanUp.append(uuidToRemove);\r\n        this->uuidsInUse.remove(uuidToRemove);\r\n\r\n        if(ui->treeWidget->currentItem() != this->currentProjectItem){\r\n            this->currentItem = FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(ui->treeWidget->currentItem());\r\n        }\r\n        else{\r\n            this->currentItem = nullptr;\r\n        }\r\n\r\n        // We need to call this event manually when a item is removed (it is not called automatically in this case)\r\n        on_treeWidget_currentItemChanged(ui->treeWidget->currentItem(), nullptr);\r\n\r\n        setProjectHasChanged();\r\n    }\r\n}\r\n\r\nvoid MainWindow::treeWidgetDeleteKeyPressed(){\r\n\r\n    if (this->currentItem != nullptr && ui->treeWidget->currentItem() == this->currentItem)\r\n    {\r\n        removeRequest(this->currentItem);\r\n    }\r\n\r\n}\r\n\r\nvoid MainWindow::setThemePaletteForCustomWidgets(){\r\n\r\n    setFilterThemePalette();\r\n\r\n    QPalette palette;\r\n\r\n    switch(this->currentSettings.theme){\r\n    case ConfigFileFRequest::FRequestTheme::OS_DEFAULT:\r\n    {\r\n        palette.setColor(QPalette::Active, QPalette::Base, palette.color(QPalette::Disabled, QPalette::Base));\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::FRequestTheme::JORGEN_DARK_THEME:\r\n    {\r\n        palette.setColor(QPalette::Active, QPalette::Text, palette.color(QPalette::Disabled, QPalette::Text));\r\n        ui->treeWidget->setStyleSheet(\"selection-background-color: rgba(42, 130, 218, 25%)\");\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        const QString errorMessage = \"Unknown theme selected! '\" + QString::number(static_cast<unsigned int>(this->currentSettings.theme)) + \"'. Please report this error.\";\r\n        this->currentSettings.theme = ConfigFileFRequest::FRequestTheme::OS_DEFAULT;\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n    }\r\n    }\r\n\r\n    ui->leFullPath->setPalette(palette); // Set the background color the same as disable\r\n}\r\n\r\nvoid MainWindow::setFilterThemePalette(){\r\n    QPalette palette; // to set filter background color\r\n\r\n    QString trimmedFilter = ui->leRequestsFilter->text().trimmed();\r\n\r\n    if(trimmedFilter.isEmpty()){ // if filter is empty\r\n        palette.setColor(QPalette::Base, ui->lePath->palette().color(QPalette::Base)); // just use another text box to get the default value\r\n    }\r\n    else{\r\n        switch(this->currentSettings.theme){\r\n        case ConfigFileFRequest::FRequestTheme::OS_DEFAULT:\r\n        {\r\n            palette.setColor(QPalette::Base, 0xFFFACD /* \"LemonChiffon\" */);\r\n            break;\r\n        }\r\n        case ConfigFileFRequest::FRequestTheme::JORGEN_DARK_THEME:\r\n        {\r\n            palette.setColor(QPalette::Base, 0x2A82DA /* Light Blue */);\r\n            break;\r\n        }\r\n        default:\r\n        {\r\n            const QString errorMessage = \"Unknown theme selected! '\" + QString::number(static_cast<unsigned int>(this->currentSettings.theme)) + \"'. Please report this error.\";\r\n            this->currentSettings.theme = ConfigFileFRequest::FRequestTheme::OS_DEFAULT;\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_ERROR << errorMessage;\r\n        }\r\n        }\r\n    }\r\n\r\n    ui->leRequestsFilter->setPalette(palette);\r\n}\r\n\r\nvoid MainWindow::setTheme(){\r\n\r\n    switch(this->currentSettings.theme){\r\n    case ConfigFileFRequest::FRequestTheme::OS_DEFAULT:\r\n    {\r\n        // Nothing to do\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::FRequestTheme::JORGEN_DARK_THEME:\r\n    {\r\n        // From here:\r\n        // https://stackoverflow.com/a/45634644/1499019\r\n        // https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle/blob/master/DarkStyle.cpp\r\n        // Just removed font resizing\r\n\r\n        qApp->setStyle(QStyleFactory::create(\"Fusion\"));\r\n\r\n        // modify palette to dark\r\n        QPalette darkPalette;\r\n        darkPalette.setColor(QPalette::Window,QColor(53,53,53));\r\n        darkPalette.setColor(QPalette::WindowText,Qt::white);\r\n        darkPalette.setColor(QPalette::Disabled,QPalette::WindowText,QColor(127,127,127));\r\n        darkPalette.setColor(QPalette::Base,QColor(42,42,42));\r\n        darkPalette.setColor(QPalette::AlternateBase,QColor(66,66,66));\r\n        darkPalette.setColor(QPalette::ToolTipBase,Qt::white);\r\n        darkPalette.setColor(QPalette::ToolTipText,Qt::white);\r\n        darkPalette.setColor(QPalette::Text,Qt::white);\r\n        darkPalette.setColor(QPalette::Disabled,QPalette::Text,QColor(127,127,127));\r\n        darkPalette.setColor(QPalette::Dark,QColor(35,35,35));\r\n        darkPalette.setColor(QPalette::Shadow,QColor(20,20,20));\r\n        darkPalette.setColor(QPalette::Button,QColor(53,53,53));\r\n        darkPalette.setColor(QPalette::ButtonText,Qt::white);\r\n        darkPalette.setColor(QPalette::Disabled,QPalette::ButtonText,QColor(127,127,127));\r\n        darkPalette.setColor(QPalette::BrightText,Qt::red);\r\n        darkPalette.setColor(QPalette::Link,QColor(42,130,218));\r\n        darkPalette.setColor(QPalette::Highlight,QColor(42,130,218));\r\n        darkPalette.setColor(QPalette::Disabled,QPalette::Highlight,QColor(80,80,80));\r\n        darkPalette.setColor(QPalette::HighlightedText,Qt::white);\r\n        darkPalette.setColor(QPalette::Disabled,QPalette::HighlightedText,QColor(127,127,127));\r\n\r\n        qApp->setPalette(darkPalette);\r\n\r\n        // Fix for macos, if we don't do this, tabs of main window doesn't get properly rethemed\r\n        // Fix from here: https://gist.github.com/QuantumCD/9863860, https://forum.qt.io/topic/37154/qpalette-not-inherited-properly/12\r\n        // To apply only to custom themes, the default one doesn't need (it even gets broken by this)\r\n\r\n        for (QWidget* const w : this->findChildren<QWidget*>())\r\n        {\r\n            w->setPalette(darkPalette);\r\n        }\r\n\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        const QString errorMessage = \"Unknown theme selected! '\" + QString::number(static_cast<unsigned int>(this->currentSettings.theme)) + \"'. Please report this error.\";\r\n        this->currentSettings.theme = ConfigFileFRequest::FRequestTheme::OS_DEFAULT;\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n    }\r\n    }\r\n\r\n    setThemePaletteForCustomWidgets();\r\n}\r\n\r\nvoid MainWindow::on_twRequestHeadersKeyValue_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem */*previous*/)\r\n{\r\n    // We can't remove global headers here... (global headers are always disabled)\r\n    if(current != nullptr){\r\n        ui->tbRequestHeadersKeyValueRemove->setEnabled(\r\n                    !UtilFRequest::isGlobalHeaderTableWidgetRow(ui->twRequestHeadersKeyValue, current->row()));\r\n    }\r\n}\r\n\r\nvoid MainWindow::addGlobalHeaders() {\r\n    for (UtilFRequest::HttpHeader const& header : currentProjectItem->globalHeaders) {\r\n        Util::TableWidget::addRow(ui->twRequestHeadersKeyValue, QStringList() << header.name << header.value);\r\n        UtilFRequest::setGlobalHeaderTableWidgetRow(ui->twRequestHeadersKeyValue, ui->twRequestHeadersKeyValue->rowCount()-1);\r\n    }\r\n}\r\n"
  },
  {
    "path": "mainwindow.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef MAINWINDOW_H\r\n#define MAINWINDOW_H\r\n\r\n#include <QMainWindow>\r\n#include <QProgressBar>\r\n#include <QToolButton>\r\n#include <QLabel>\r\n#include <pugixml/pugixml.hpp>\r\n#include <ConditionalSemaphore/conditionalsemaphore.h>\r\n\r\n#include \"projectproperties.h\"\r\n#include \"updatechecker.h\"\r\n#include \"SyntaxHighlighters/frequestjsonhighlighter.h\"\r\n#include \"SyntaxHighlighters/frequestxmlhighlighter.h\"\r\n#include \"XmlParsers/projectfilefrequest.h\"\r\n\r\nnamespace Ui {\r\nclass MainWindow;\r\n}\r\n\r\nclass MainWindow : public QMainWindow\r\n{\r\n    Q_OBJECT\r\n\r\npublic:\r\n    explicit MainWindow(QWidget *parent = 0);\r\n    ~MainWindow();\r\n\r\nprivate slots:\r\n\r\n    void applicationHasLoaded();\r\n\r\n    void saveProjectProperties();\r\n\r\n    void treeWidgetDeleteKeyPressed();\r\n\r\n    void on_pbSendRequest_clicked();\r\n\r\n    void on_lePath_textChanged(const QString &arg1);\r\n\r\n    void replyFinished(QNetworkReply *reply);\r\n\r\n    void on_treeWidget_customContextMenuRequested(const QPoint &pos);\r\n\r\n    void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column);\r\n\r\n    void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);\r\n\r\n    void on_actionSave_Project_triggered();\r\n\r\n    void on_actionNew_Project_triggered();\r\n\r\n    void on_actionSave_Project_As_triggered();\r\n\r\n    void on_actionLoad_Project_triggered();\r\n\r\n    void on_actionExit_triggered();\r\n\r\n    void on_actionAbout_triggered();\r\n\r\n    void on_actionProject1_triggered();\r\n\r\n    void on_actionProject2_triggered();\r\n\r\n    void on_actionProject3_triggered();\r\n\r\n    void on_actionProject4_triggered();\r\n\r\n    void on_actionProject5_triggered();\r\n\r\n    void on_actionProject6_triggered();\r\n\r\n    void on_cbResponseChooseHeader_currentIndexChanged(const QString &arg1);\r\n\r\n    void on_tbRequestBodyKeyValueAdd_clicked();\r\n\r\n    void on_twRequestBodyKeyValue_cellChanged(int row, int column);\r\n\r\n    void on_cbBodyType_currentIndexChanged(const QString &arg1);\r\n\r\n    void on_tbRequestBodyKeyValueRemove_clicked();\r\n\r\n    void on_tbRequestHeadersKeyValueAdd_clicked();\r\n\r\n    void on_tbRequestHeadersKeyValueRemove_clicked();\r\n\r\n    void on_twRequestHeadersKeyValue_cellChanged(int row, int column);\r\n\r\n    void on_cbRequestOverrideMainUrl_toggled(bool checked);\r\n\r\n    void on_leRequestOverrideMainUrl_textChanged(const QString &arg1);\r\n\r\n    void on_pteRequestBody_textChanged();\r\n\r\n    void on_cbDownloadResponseAsFile_toggled(bool checked);\r\n\r\n    void on_tbCopyToClipboardRequest_clicked();\r\n\r\n    void on_tbCopyToClipboardResponse_clicked();\r\n\r\n    void on_actionPreferences_triggered();\r\n\r\n    void saveCurrentSettings();\r\n\r\n    void on_cbRequestType_currentIndexChanged(const QString &arg1);\r\n\r\n    void on_actionFormat_Response_Body_triggered();\r\n\r\n    void on_actionFormat_Request_body_triggered();\r\n\r\n    void on_tbRequestBodyFile_clicked();\r\n\r\n    void tbAbortRequest_clicked();\r\n\r\n    void on_actionShow_Request_Types_Icons_triggered(bool checked);\r\n\r\n    void on_leRequestsFilter_textChanged(const QString &arg1);\r\n\r\n    void on_actionProject_Properties_triggered();\r\n\r\n    void on_actionCheck_for_updates_triggered();\r\n\r\n    void on_cbDisableGlobalHeaders_toggled(bool checked);\r\n\r\n    void on_twRequestHeadersKeyValue_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);\r\n\r\nsignals:\r\n    void signalAppIsLoaded();\r\n    void signalRequestFinishedAndProcessed();\r\n\r\nprivate:\r\n    void showEvent(QShowEvent *e);\r\n    void checkForQNetworkAccessManagerTimeout(QNetworkReply *reply);\r\n    QNetworkReply* processHttpRequest(\r\n            const UtilFRequest::RequestType requestType,\r\n            const QString &fullPath,\r\n            const QString &bodyType,\r\n            const QString &requestBody,\r\n            const QVector<UtilFRequest::HttpHeader>& requestHeaders\r\n            );\r\n    QString getDownloadFileName(const QNetworkReply * const reply);\r\n    void updateWindowTitle();\r\n    void setNewProject();\r\n    void saveProjectState(const QString &filePath);\r\n    void loadProjectState(const QString &filePath);\r\n    void updateTreeWidgetItemContent(FRequestTreeWidgetRequestItem * const requestItem);\r\n    void reloadRequest(FRequestTreeWidgetRequestItem * const item);\r\n    FRequestTreeWidgetProjectItem *addProjectItem(const QString &projectName, const QString &projectUuid);\r\n    FRequestTreeWidgetRequestItem *addRequestItem(const QString &requestName, const QString &projectUuid, FRequestTreeWidgetProjectItem * const currentProject);\r\n    void closeEvent(QCloseEvent *event);\r\n    void loadRecentProjects();\r\n    void addNewRecentProject(const QString &filePath);\r\n    void reloadRecentProjectsMenu();\r\n    void saveRecentProjects();\r\n    QVector<UtilFRequest::HttpHeader> getRequestHeaders();\r\n    QVector<UtilFRequest::HttpFormKeyValueType> getRequestForm();\r\n    void buildFullPath();\r\n    void setProjectHasChanged();\r\n    QMessageBox::StandardButton askToSaveCurrentProject();\r\n    void clearOlderResponse();\r\n    void clearRequestAndResponse();\r\n    void clearEverything();\r\n    void addDefaultHeaders();\r\n    void setRequestType(UtilFRequest::RequestType requestType);\r\n    void formatRequestBody(const UtilFRequest::SerializationFormatType serializationType);\r\n    void formatResponseBody(const UtilFRequest::SerializationFormatType serializationType);\r\n    bool loadAndValidateFRequestProjectFile(const QString &filePath, pugi::xml_document &doc);\r\n    void setIconForRequest(FRequestTreeWidgetRequestItem * const item);\r\n    void setAllRequestIcons(bool showIcon);\r\n    ProjectFileFRequest::ProjectData fetchCurrentProjectData();\r\n    bool formKeyValueInBodyIsValid();\r\n    bool formKeyValueInBodyHasFiles();\r\n    bool noDuplicatedKeyExistsInRequestHeaders(const QVector<UtilFRequest::HttpHeader> &headers);\r\n    void removeAllFilesRowsFromFormKeyValueInBody();\r\n    UtilFRequest::SerializationFormatType getRequestCurrentSerializationFormatType();\r\n    UtilFRequest::SerializationFormatType getResponseCurrentSerializationFormatType();\r\n    QString getNewUuid();\r\n    QString getFullPathFromMainUrlAndPath(const QString & mainUrl, const QString & path);\r\n    void applyRequestAuthentication();\r\n    void openProjectProperties();\r\n    void removeRequest(FRequestTreeWidgetRequestItem * const itemToDelete);\r\n    void setThemePaletteForCustomWidgets();\r\n    void setFilterThemePalette();\r\n    void setTheme();\r\n    void downloadResponseAsFile(QNetworkReply *reply, QByteArray &totalLoadedData, QByteArray &currentData, const int maxBytesForBufferAndDisplay);\r\n    void addGlobalHeaders();\r\n\r\npublic:\r\n    static constexpr int recentProjectsMaxSize=6;\r\n\r\nprivate:\r\n    Ui::MainWindow *ui;\r\n    QDateTime lastStartTime;\r\n    FRequestTreeWidgetProjectItem *currentProjectItem = nullptr;\r\n    FRequestTreeWidgetRequestItem *currentItem = nullptr;\r\n    QSet<QString> uuidsInUse;\r\n    QVector<QString> uuidsToCleanUp; // this vector stores the uuids of deleted items in the application, its used to clean them in the project file\r\n    bool applicationIsFullyLoaded = false;\r\n    bool unsavedChangesExist = false;\r\n    // This conditional semaphore allow us to tell to the interface to ignore changes (not mark project as unsaved) within some time interval\r\n    Cosemaphore::ConditionalSemaphore ignoreAnyChangesToProject;\r\n    QString lastProjectFilePath;\r\n    QList<QString> recentProjectsList;\r\n    QString lastResponseFileName;\r\n    int lastReplyStatusError = 0;\r\n    ConfigFileFRequest configFileManager = ConfigFileFRequest(Util::FileSystem::getAppPath() + \"/\" + GlobalVars::AppConfigFileName);\r\n    ConfigFileFRequest::Settings currentSettings;\r\n    const QSize auxMinimumSize = QSize(0,0);\r\n    const QSize auxMaximumSize = QSize(16777215,16777215);\r\n    QProgressBar pbRequestProgress;\r\n    QToolButton tbAbortRequest;\r\n    QLabel lbRequestInfo;\r\n    QLabel lbProjectInfo;\r\n    std::experimental::optional<QNetworkReply*> currentReply;\r\n    QMap<UtilFRequest::RequestType, QIcon> generatedIconCache;\r\n    QNetworkAccessManager networkAccessManager;\r\n    const QString operatingSystemDefaultStyle;\r\n\r\n    // Requests Highlighters\r\n    FRequestJSONHighlighter jsonRequestBodyHighligher;\r\n    FRequestJSONHighlighter jsonResponseBodyHighligher;\r\n    FRequestXMLHighlighter xmlRequestBodyHighligher;\r\n    FRequestXMLHighlighter xmlResponseBodyHighligher;\r\n    bool currentProjectAuthenticationWasMade = false;\r\n    bool authenticationIsRunning = false;\r\n\r\n};\r\n\r\n#endif // MAINWINDOW_H\r\n"
  },
  {
    "path": "mainwindow.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>MainWindow</class>\n <widget class=\"QMainWindow\" name=\"MainWindow\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>803</width>\n    <height>861</height>\n   </rect>\n  </property>\n  <property name=\"windowTitle\">\n   <string>FRequest</string>\n  </property>\n  <property name=\"windowIcon\">\n   <iconset resource=\"Resources/resources.qrc\">\n    <normaloff>:/icons/frequest_icon.png</normaloff>:/icons/frequest_icon.png</iconset>\n  </property>\n  <widget class=\"QWidget\" name=\"centralWidget\">\n   <layout class=\"QVBoxLayout\" name=\"verticalLayout_11\">\n    <item>\n     <widget class=\"QSplitter\" name=\"splitter\">\n      <property name=\"orientation\">\n       <enum>Qt::Horizontal</enum>\n      </property>\n      <widget class=\"QWidget\" name=\"layoutWidget\">\n       <layout class=\"QVBoxLayout\" name=\"verticalLayout_2\">\n        <item>\n         <widget class=\"QGroupBox\" name=\"gbProject\">\n          <property name=\"title\">\n           <string>Project</string>\n          </property>\n          <layout class=\"QVBoxLayout\" name=\"verticalLayout_12\">\n           <item>\n            <widget class=\"QLineEdit\" name=\"leRequestsFilter\">\n             <property name=\"placeholderText\">\n              <string>Requests Filter</string>\n             </property>\n             <property name=\"clearButtonEnabled\">\n              <bool>true</bool>\n             </property>\n            </widget>\n           </item>\n           <item>\n            <widget class=\"FRequestTreeWidget\" name=\"treeWidget\">\n             <property name=\"sizePolicy\">\n              <sizepolicy hsizetype=\"Expanding\" vsizetype=\"Expanding\">\n               <horstretch>0</horstretch>\n               <verstretch>0</verstretch>\n              </sizepolicy>\n             </property>\n             <property name=\"minimumSize\">\n              <size>\n               <width>150</width>\n               <height>0</height>\n              </size>\n             </property>\n             <property name=\"maximumSize\">\n              <size>\n               <width>16777215</width>\n               <height>16777215</height>\n              </size>\n             </property>\n             <property name=\"sizeIncrement\">\n              <size>\n               <width>0</width>\n               <height>0</height>\n              </size>\n             </property>\n             <property name=\"contextMenuPolicy\">\n              <enum>Qt::CustomContextMenu</enum>\n             </property>\n             <column>\n              <property name=\"text\">\n               <string notr=\"true\">Requests</string>\n              </property>\n             </column>\n            </widget>\n           </item>\n          </layout>\n         </widget>\n        </item>\n       </layout>\n      </widget>\n      <widget class=\"QWidget\" name=\"layoutWidget\">\n       <layout class=\"QVBoxLayout\" name=\"verticalLayout_4\">\n        <item>\n         <widget class=\"QScrollArea\" name=\"scrollArea\">\n          <property name=\"verticalScrollBarPolicy\">\n           <enum>Qt::ScrollBarAsNeeded</enum>\n          </property>\n          <property name=\"widgetResizable\">\n           <bool>true</bool>\n          </property>\n          <widget class=\"QWidget\" name=\"scrollAreaWidgetContents\">\n           <property name=\"geometry\">\n            <rect>\n             <x>0</x>\n             <y>0</y>\n             <width>470</width>\n             <height>780</height>\n            </rect>\n           </property>\n           <layout class=\"QGridLayout\" name=\"gridLayout\">\n            <item row=\"0\" column=\"0\">\n             <widget class=\"QGroupBox\" name=\"gbRequest\">\n              <property name=\"title\">\n               <string>Request</string>\n              </property>\n              <layout class=\"QVBoxLayout\" name=\"verticalLayout\">\n               <item>\n                <layout class=\"QHBoxLayout\" name=\"horizontalLayout_9\">\n                 <item>\n                  <widget class=\"QCheckBox\" name=\"cbRequestOverrideMainUrl\">\n                   <property name=\"text\">\n                    <string>Override Main Url:</string>\n                   </property>\n                  </widget>\n                 </item>\n                 <item>\n                  <widget class=\"QLineEdit\" name=\"leRequestOverrideMainUrl\">\n                   <property name=\"enabled\">\n                    <bool>false</bool>\n                   </property>\n                  </widget>\n                 </item>\n                </layout>\n               </item>\n               <item>\n                <layout class=\"QHBoxLayout\" name=\"horizontalLayout_3\">\n                 <item>\n                  <widget class=\"QLabel\" name=\"label_3\">\n                   <property name=\"text\">\n                    <string>Path:</string>\n                   </property>\n                  </widget>\n                 </item>\n                 <item>\n                  <widget class=\"QLineEdit\" name=\"lePath\">\n                   <property name=\"text\">\n                    <string/>\n                   </property>\n                  </widget>\n                 </item>\n                 <item>\n                  <widget class=\"QLabel\" name=\"lbFullPath\">\n                   <property name=\"text\">\n                    <string>Full Path:</string>\n                   </property>\n                  </widget>\n                 </item>\n                 <item>\n                  <widget class=\"QLineEdit\" name=\"leFullPath\">\n                   <property name=\"text\">\n                    <string/>\n                   </property>\n                   <property name=\"readOnly\">\n                    <bool>true</bool>\n                   </property>\n                  </widget>\n                 </item>\n                </layout>\n               </item>\n               <item>\n                <widget class=\"QGroupBox\" name=\"groupBox_6\">\n                 <property name=\"title\">\n                  <string>Type:</string>\n                 </property>\n                 <layout class=\"QHBoxLayout\" name=\"horizontalLayout_2\">\n                  <item>\n                   <widget class=\"QComboBox\" name=\"cbRequestType\">\n                    <item>\n                     <property name=\"text\">\n                      <string>GET</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>POST</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>PUT</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>DELETE</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>PATCH</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>HEAD</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>TRACE</string>\n                     </property>\n                    </item>\n                    <item>\n                     <property name=\"text\">\n                      <string>OPTIONS</string>\n                     </property>\n                    </item>\n                   </widget>\n                  </item>\n                 </layout>\n                </widget>\n               </item>\n               <item>\n                <widget class=\"QSplitter\" name=\"splitter_2\">\n                 <property name=\"orientation\">\n                  <enum>Qt::Vertical</enum>\n                 </property>\n                 <widget class=\"QWidget\" name=\"layoutWidget\">\n                  <layout class=\"QHBoxLayout\" name=\"horizontalLayout_11\">\n                   <item>\n                    <widget class=\"QTabWidget\" name=\"twRequest\">\n                     <property name=\"currentIndex\">\n                      <number>0</number>\n                     </property>\n                     <widget class=\"QWidget\" name=\"tab_4\">\n                      <attribute name=\"title\">\n                       <string>Body</string>\n                      </attribute>\n                      <layout class=\"QVBoxLayout\" name=\"verticalLayout_9\">\n                       <item>\n                        <layout class=\"QFormLayout\" name=\"formLayout\">\n                         <item row=\"0\" column=\"0\">\n                          <widget class=\"QLabel\" name=\"label_6\">\n                           <property name=\"text\">\n                            <string>Body Type:</string>\n                           </property>\n                          </widget>\n                         </item>\n                         <item row=\"0\" column=\"1\">\n                          <widget class=\"QComboBox\" name=\"cbBodyType\">\n                           <property name=\"enabled\">\n                            <bool>false</bool>\n                           </property>\n                           <item>\n                            <property name=\"text\">\n                             <string>raw</string>\n                            </property>\n                           </item>\n                           <item>\n                            <property name=\"text\">\n                             <string>form-data</string>\n                            </property>\n                           </item>\n                           <item>\n                            <property name=\"text\">\n                             <string>x-form-www-urlencoded</string>\n                            </property>\n                           </item>\n                          </widget>\n                         </item>\n                        </layout>\n                       </item>\n                       <item>\n                        <widget class=\"QPlainTextEdit\" name=\"pteRequestBody\">\n                         <property name=\"enabled\">\n                          <bool>false</bool>\n                         </property>\n                         <property name=\"font\">\n                          <font>\n                           <family>Courier New</family>\n                          </font>\n                         </property>\n                        </widget>\n                       </item>\n                       <item>\n                        <layout class=\"QHBoxLayout\" name=\"horizontalLayout_7\">\n                         <item>\n                          <widget class=\"QTableWidget\" name=\"twRequestBodyKeyValue\">\n                           <property name=\"enabled\">\n                            <bool>false</bool>\n                           </property>\n                           <property name=\"font\">\n                            <font>\n                             <family>Courier New</family>\n                            </font>\n                           </property>\n                           <property name=\"alternatingRowColors\">\n                            <bool>true</bool>\n                           </property>\n                           <attribute name=\"horizontalHeaderStretchLastSection\">\n                            <bool>true</bool>\n                           </attribute>\n                           <column>\n                            <property name=\"text\">\n                             <string>Key</string>\n                            </property>\n                           </column>\n                           <column>\n                            <property name=\"text\">\n                             <string>Value</string>\n                            </property>\n                           </column>\n                           <column>\n                            <property name=\"text\">\n                             <string>Type</string>\n                            </property>\n                           </column>\n                          </widget>\n                         </item>\n                         <item>\n                          <layout class=\"QVBoxLayout\" name=\"verticalLayout_6\">\n                           <item>\n                            <widget class=\"QToolButton\" name=\"tbRequestBodyKeyValueAdd\">\n                             <property name=\"enabled\">\n                              <bool>false</bool>\n                             </property>\n                             <property name=\"toolTip\">\n                              <string>Add row</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>...</string>\n                             </property>\n                             <property name=\"icon\">\n                              <iconset resource=\"Resources/resources.qrc\">\n                               <normaloff>:/icons/plus.png</normaloff>:/icons/plus.png</iconset>\n                             </property>\n                            </widget>\n                           </item>\n                           <item>\n                            <widget class=\"QToolButton\" name=\"tbRequestBodyFile\">\n                             <property name=\"enabled\">\n                              <bool>false</bool>\n                             </property>\n                             <property name=\"toolTip\">\n                              <string>Add file row</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>...</string>\n                             </property>\n                             <property name=\"icon\">\n                              <iconset resource=\"Resources/resources.qrc\">\n                               <normaloff>:/icons/plus_file.png</normaloff>:/icons/plus_file.png</iconset>\n                             </property>\n                            </widget>\n                           </item>\n                           <item>\n                            <widget class=\"QToolButton\" name=\"tbRequestBodyKeyValueRemove\">\n                             <property name=\"enabled\">\n                              <bool>false</bool>\n                             </property>\n                             <property name=\"toolTip\">\n                              <string>Remove selected rows</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>...</string>\n                             </property>\n                             <property name=\"icon\">\n                              <iconset resource=\"Resources/resources.qrc\">\n                               <normaloff>:/icons/minus.png</normaloff>:/icons/minus.png</iconset>\n                             </property>\n                            </widget>\n                           </item>\n                          </layout>\n                         </item>\n                        </layout>\n                       </item>\n                      </layout>\n                     </widget>\n                     <widget class=\"QWidget\" name=\"tab_3\">\n                      <attribute name=\"title\">\n                       <string>Headers</string>\n                      </attribute>\n                      <layout class=\"QVBoxLayout\" name=\"verticalLayout_5\">\n                       <item>\n                        <widget class=\"QComboBox\" name=\"cbResponseChooseHeader\">\n                         <item>\n                          <property name=\"text\">\n                           <string>Select a Header to Add</string>\n                          </property>\n                         </item>\n                         <item>\n                          <property name=\"text\">\n                           <string>Content-type: application/json</string>\n                          </property>\n                         </item>\n                         <item>\n                          <property name=\"text\">\n                           <string>Content-type: application/xml</string>\n                          </property>\n                         </item>\n                         <item>\n                          <property name=\"text\">\n                           <string>Content-type: multipart/form-data</string>\n                          </property>\n                         </item>\n                         <item>\n                          <property name=\"text\">\n                           <string>Content-type: application/x-www-form-urlencoded</string>\n                          </property>\n                         </item>\n                        </widget>\n                       </item>\n                       <item>\n                        <layout class=\"QHBoxLayout\" name=\"horizontalLayout_8\">\n                         <item>\n                          <widget class=\"QTableWidget\" name=\"twRequestHeadersKeyValue\">\n                           <property name=\"font\">\n                            <font>\n                             <family>Courier New</family>\n                            </font>\n                           </property>\n                           <property name=\"alternatingRowColors\">\n                            <bool>true</bool>\n                           </property>\n                           <property name=\"wordWrap\">\n                            <bool>true</bool>\n                           </property>\n                           <attribute name=\"horizontalHeaderStretchLastSection\">\n                            <bool>true</bool>\n                           </attribute>\n                           <column>\n                            <property name=\"text\">\n                             <string>Key</string>\n                            </property>\n                           </column>\n                           <column>\n                            <property name=\"text\">\n                             <string>Value</string>\n                            </property>\n                           </column>\n                          </widget>\n                         </item>\n                         <item>\n                          <layout class=\"QVBoxLayout\" name=\"verticalLayout_10\">\n                           <item>\n                            <widget class=\"QToolButton\" name=\"tbRequestHeadersKeyValueAdd\">\n                             <property name=\"toolTip\">\n                              <string>Add new row</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>...</string>\n                             </property>\n                             <property name=\"icon\">\n                              <iconset resource=\"Resources/resources.qrc\">\n                               <normaloff>:/icons/plus.png</normaloff>:/icons/plus.png</iconset>\n                             </property>\n                            </widget>\n                           </item>\n                           <item>\n                            <widget class=\"QToolButton\" name=\"tbRequestHeadersKeyValueRemove\">\n                             <property name=\"toolTip\">\n                              <string>Remove selected rows</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>...</string>\n                             </property>\n                             <property name=\"icon\">\n                              <iconset resource=\"Resources/resources.qrc\">\n                               <normaloff>:/icons/minus.png</normaloff>:/icons/minus.png</iconset>\n                             </property>\n                            </widget>\n                           </item>\n                          </layout>\n                         </item>\n                        </layout>\n                       </item>\n                       <item>\n                        <widget class=\"QCheckBox\" name=\"cbDisableGlobalHeaders\">\n                         <property name=\"toolTip\">\n                          <string>Click to disable global headers for THIS request. Useful if you do not want to send them.</string>\n                         </property>\n                         <property name=\"text\">\n                          <string>Disable global headers</string>\n                         </property>\n                         <property name=\"checked\">\n                          <bool>true</bool>\n                         </property>\n                        </widget>\n                       </item>\n                      </layout>\n                     </widget>\n                    </widget>\n                   </item>\n                   <item>\n                    <widget class=\"QToolButton\" name=\"tbCopyToClipboardRequest\">\n                     <property name=\"toolTip\">\n                      <string>Copy to clipboard</string>\n                     </property>\n                     <property name=\"text\">\n                      <string>...</string>\n                     </property>\n                     <property name=\"icon\">\n                      <iconset resource=\"Resources/resources.qrc\">\n                       <normaloff>:/icons/clipboard_icon.png</normaloff>:/icons/clipboard_icon.png</iconset>\n                     </property>\n                     <property name=\"autoRaise\">\n                      <bool>true</bool>\n                     </property>\n                    </widget>\n                   </item>\n                  </layout>\n                 </widget>\n                 <widget class=\"QGroupBox\" name=\"gbResponse\">\n                  <property name=\"title\">\n                   <string>Response</string>\n                  </property>\n                  <layout class=\"QVBoxLayout\" name=\"verticalLayout_3\">\n                   <item>\n                    <layout class=\"QHBoxLayout\" name=\"horizontalLayout_4\">\n                     <item>\n                      <layout class=\"QHBoxLayout\" name=\"horizontalLayout_5\">\n                       <item>\n                        <widget class=\"QLabel\" name=\"label_5\">\n                         <property name=\"text\">\n                          <string>Status Code:</string>\n                         </property>\n                        </widget>\n                       </item>\n                       <item>\n                        <widget class=\"QLabel\" name=\"lbStatus\">\n                         <property name=\"text\">\n                          <string/>\n                         </property>\n                        </widget>\n                       </item>\n                      </layout>\n                     </item>\n                     <item>\n                      <layout class=\"QHBoxLayout\" name=\"horizontalLayout\">\n                       <item>\n                        <widget class=\"QLabel\" name=\"label\">\n                         <property name=\"text\">\n                          <string>Description:</string>\n                         </property>\n                        </widget>\n                       </item>\n                       <item>\n                        <widget class=\"QLabel\" name=\"lbDescription\">\n                         <property name=\"text\">\n                          <string/>\n                         </property>\n                        </widget>\n                       </item>\n                      </layout>\n                     </item>\n                     <item>\n                      <layout class=\"QHBoxLayout\" name=\"horizontalLayout_6\">\n                       <item>\n                        <widget class=\"QLabel\" name=\"label_7\">\n                         <property name=\"text\">\n                          <string>Time Elapsed:</string>\n                         </property>\n                        </widget>\n                       </item>\n                       <item>\n                        <widget class=\"QLabel\" name=\"lbTimeElapsed\">\n                         <property name=\"text\">\n                          <string/>\n                         </property>\n                        </widget>\n                       </item>\n                      </layout>\n                     </item>\n                    </layout>\n                   </item>\n                   <item>\n                    <layout class=\"QHBoxLayout\" name=\"horizontalLayout_10\">\n                     <item>\n                      <widget class=\"QTabWidget\" name=\"twResponse\">\n                       <property name=\"currentIndex\">\n                        <number>0</number>\n                       </property>\n                       <widget class=\"QWidget\" name=\"tab_2\">\n                        <attribute name=\"title\">\n                         <string>Body</string>\n                        </attribute>\n                        <layout class=\"QVBoxLayout\" name=\"verticalLayout_7\">\n                         <item>\n                          <layout class=\"QHBoxLayout\" name=\"horizontalLayout_12\">\n                           <item>\n                            <widget class=\"QLabel\" name=\"lbResponseBodyWarningIcon\">\n                             <property name=\"sizePolicy\">\n                              <sizepolicy hsizetype=\"Fixed\" vsizetype=\"Fixed\">\n                               <horstretch>0</horstretch>\n                               <verstretch>0</verstretch>\n                              </sizepolicy>\n                             </property>\n                             <property name=\"maximumSize\">\n                              <size>\n                               <width>16</width>\n                               <height>16</height>\n                              </size>\n                             </property>\n                             <property name=\"toolTip\">\n                              <string>If you pretend to see all the data, increase the value in preferences \nor alternatively just download the response as file.</string>\n                             </property>\n                             <property name=\"pixmap\">\n                              <pixmap resource=\"Resources/resources.qrc\">:/icons/warning_icon.png</pixmap>\n                             </property>\n                             <property name=\"scaledContents\">\n                              <bool>true</bool>\n                             </property>\n                            </widget>\n                           </item>\n                           <item>\n                            <widget class=\"QLabel\" name=\"lbResponseBodyWarningMessage\">\n                             <property name=\"font\">\n                              <font>\n                               <pointsize>7</pointsize>\n                              </font>\n                             </property>\n                             <property name=\"toolTip\">\n                              <string>If you pretend to see all the data, increase the value in preferences \nor alternatively just download the response as file.</string>\n                             </property>\n                             <property name=\"text\">\n                              <string>Return data size is greater than 200 KB, only displaying the first 200 KB.</string>\n                             </property>\n                            </widget>\n                           </item>\n                          </layout>\n                         </item>\n                         <item>\n                          <widget class=\"QPlainTextEdit\" name=\"pteResponseBody\">\n                           <property name=\"font\">\n                            <font>\n                             <family>Courier New</family>\n                            </font>\n                           </property>\n                           <property name=\"readOnly\">\n                            <bool>true</bool>\n                           </property>\n                          </widget>\n                         </item>\n                        </layout>\n                       </widget>\n                       <widget class=\"QWidget\" name=\"tab\">\n                        <attribute name=\"title\">\n                         <string>Headers</string>\n                        </attribute>\n                        <layout class=\"QVBoxLayout\" name=\"verticalLayout_8\">\n                         <item>\n                          <widget class=\"QPlainTextEdit\" name=\"pteResponseHeaders\">\n                           <property name=\"font\">\n                            <font>\n                             <family>Courier New</family>\n                            </font>\n                           </property>\n                           <property name=\"readOnly\">\n                            <bool>true</bool>\n                           </property>\n                          </widget>\n                         </item>\n                        </layout>\n                       </widget>\n                      </widget>\n                     </item>\n                     <item>\n                      <widget class=\"QToolButton\" name=\"tbCopyToClipboardResponse\">\n                       <property name=\"toolTip\">\n                        <string>Copy to clipboard</string>\n                       </property>\n                       <property name=\"text\">\n                        <string>...</string>\n                       </property>\n                       <property name=\"icon\">\n                        <iconset resource=\"Resources/resources.qrc\">\n                         <normaloff>:/icons/clipboard_icon.png</normaloff>:/icons/clipboard_icon.png</iconset>\n                       </property>\n                       <property name=\"autoRaise\">\n                        <bool>true</bool>\n                       </property>\n                      </widget>\n                     </item>\n                    </layout>\n                   </item>\n                   <item>\n                    <widget class=\"QCheckBox\" name=\"cbDownloadResponseAsFile\">\n                     <property name=\"text\">\n                      <string>Download Response as File</string>\n                     </property>\n                    </widget>\n                   </item>\n                  </layout>\n                 </widget>\n                </widget>\n               </item>\n               <item>\n                <widget class=\"Line\" name=\"line\">\n                 <property name=\"orientation\">\n                  <enum>Qt::Horizontal</enum>\n                 </property>\n                </widget>\n               </item>\n               <item>\n                <widget class=\"QPushButton\" name=\"pbSendRequest\">\n                 <property name=\"sizePolicy\">\n                  <sizepolicy hsizetype=\"Minimum\" vsizetype=\"Fixed\">\n                   <horstretch>0</horstretch>\n                   <verstretch>0</verstretch>\n                  </sizepolicy>\n                 </property>\n                 <property name=\"minimumSize\">\n                  <size>\n                   <width>0</width>\n                   <height>50</height>\n                  </size>\n                 </property>\n                 <property name=\"toolTip\">\n                  <string>Send the request</string>\n                 </property>\n                 <property name=\"text\">\n                  <string>Send Request</string>\n                 </property>\n                 <property name=\"icon\">\n                  <iconset resource=\"Resources/resources.qrc\">\n                   <normaloff>:/icons/send_request_icon.png</normaloff>:/icons/send_request_icon.png</iconset>\n                 </property>\n                 <property name=\"iconSize\">\n                  <size>\n                   <width>32</width>\n                   <height>32</height>\n                  </size>\n                 </property>\n                 <property name=\"shortcut\">\n                  <string>Ctrl+Return</string>\n                 </property>\n                </widget>\n               </item>\n              </layout>\n             </widget>\n            </item>\n           </layout>\n          </widget>\n         </widget>\n        </item>\n       </layout>\n      </widget>\n     </widget>\n    </item>\n   </layout>\n  </widget>\n  <widget class=\"QMenuBar\" name=\"menuBar\">\n   <property name=\"geometry\">\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>803</width>\n     <height>20</height>\n    </rect>\n   </property>\n   <widget class=\"QMenu\" name=\"menuFile\">\n    <property name=\"title\">\n     <string>File</string>\n    </property>\n    <widget class=\"QMenu\" name=\"menuRecent_Projects\">\n     <property name=\"title\">\n      <string>Recent Projects</string>\n     </property>\n     <addaction name=\"actionProject1\"/>\n     <addaction name=\"actionProject2\"/>\n     <addaction name=\"actionProject3\"/>\n     <addaction name=\"actionProject4\"/>\n     <addaction name=\"actionProject5\"/>\n     <addaction name=\"actionProject6\"/>\n    </widget>\n    <addaction name=\"actionNew_Project\"/>\n    <addaction name=\"actionSave_Project\"/>\n    <addaction name=\"actionSave_Project_As\"/>\n    <addaction name=\"actionLoad_Project\"/>\n    <addaction name=\"menuRecent_Projects\"/>\n    <addaction name=\"separator\"/>\n    <addaction name=\"actionExit\"/>\n   </widget>\n   <widget class=\"QMenu\" name=\"menuHelp\">\n    <property name=\"title\">\n     <string>Help</string>\n    </property>\n    <addaction name=\"actionCheck_for_updates\"/>\n    <addaction name=\"separator\"/>\n    <addaction name=\"actionAbout\"/>\n   </widget>\n   <widget class=\"QMenu\" name=\"menuOptions\">\n    <property name=\"title\">\n     <string>Options</string>\n    </property>\n    <addaction name=\"actionFormat_Request_body\"/>\n    <addaction name=\"actionFormat_Response_Body\"/>\n    <addaction name=\"actionShow_Request_Types_Icons\"/>\n    <addaction name=\"actionUse_Last_Download_Location\"/>\n    <addaction name=\"actionOpen_file_after_download\"/>\n    <addaction name=\"separator\"/>\n    <addaction name=\"actionPreferences\"/>\n   </widget>\n   <widget class=\"QMenu\" name=\"menuEdit\">\n    <property name=\"title\">\n     <string>Edit</string>\n    </property>\n    <addaction name=\"actionProject_Properties\"/>\n   </widget>\n   <addaction name=\"menuFile\"/>\n   <addaction name=\"menuEdit\"/>\n   <addaction name=\"menuOptions\"/>\n   <addaction name=\"menuHelp\"/>\n  </widget>\n  <widget class=\"QToolBar\" name=\"mainToolBar\">\n   <attribute name=\"toolBarArea\">\n    <enum>TopToolBarArea</enum>\n   </attribute>\n   <attribute name=\"toolBarBreak\">\n    <bool>false</bool>\n   </attribute>\n  </widget>\n  <widget class=\"QStatusBar\" name=\"statusBar\"/>\n  <action name=\"actionExit\">\n   <property name=\"text\">\n    <string>Exit</string>\n   </property>\n  </action>\n  <action name=\"actionAbout\">\n   <property name=\"text\">\n    <string>About</string>\n   </property>\n  </action>\n  <action name=\"actionNew_Project\">\n   <property name=\"text\">\n    <string>New Project</string>\n   </property>\n  </action>\n  <action name=\"actionSave_Project\">\n   <property name=\"text\">\n    <string>Save Project</string>\n   </property>\n   <property name=\"shortcut\">\n    <string>Ctrl+S</string>\n   </property>\n  </action>\n  <action name=\"actionSave_Project_As\">\n   <property name=\"text\">\n    <string>Save Project As...</string>\n   </property>\n  </action>\n  <action name=\"actionLoad_Project\">\n   <property name=\"text\">\n    <string>Load Project...</string>\n   </property>\n  </action>\n  <action name=\"actionProject1\">\n   <property name=\"text\">\n    <string>Project 1</string>\n   </property>\n  </action>\n  <action name=\"actionProject2\">\n   <property name=\"text\">\n    <string>Project 2</string>\n   </property>\n  </action>\n  <action name=\"actionProject3\">\n   <property name=\"text\">\n    <string>Project 3</string>\n   </property>\n  </action>\n  <action name=\"actionProject4\">\n   <property name=\"text\">\n    <string>Project 4</string>\n   </property>\n  </action>\n  <action name=\"actionProject5\">\n   <property name=\"text\">\n    <string>Project 5</string>\n   </property>\n  </action>\n  <action name=\"actionProject6\">\n   <property name=\"text\">\n    <string>Project 6</string>\n   </property>\n  </action>\n  <action name=\"actionFormat_Response_Body\">\n   <property name=\"checkable\">\n    <bool>true</bool>\n   </property>\n   <property name=\"checked\">\n    <bool>true</bool>\n   </property>\n   <property name=\"text\">\n    <string>Format Response Body</string>\n   </property>\n  </action>\n  <action name=\"actionFormat_Request_body\">\n   <property name=\"checkable\">\n    <bool>true</bool>\n   </property>\n   <property name=\"checked\">\n    <bool>true</bool>\n   </property>\n   <property name=\"text\">\n    <string>Format Request Body</string>\n   </property>\n  </action>\n  <action name=\"actionUse_Last_Download_Location\">\n   <property name=\"checkable\">\n    <bool>true</bool>\n   </property>\n   <property name=\"text\">\n    <string>Use Last Download Location</string>\n   </property>\n  </action>\n  <action name=\"actionPreferences\">\n   <property name=\"text\">\n    <string>Preferences</string>\n   </property>\n  </action>\n  <action name=\"actionOpen_file_after_download\">\n   <property name=\"checkable\">\n    <bool>true</bool>\n   </property>\n   <property name=\"text\">\n    <string>Open File After Download</string>\n   </property>\n  </action>\n  <action name=\"actionShow_Request_Types_Icons\">\n   <property name=\"checkable\">\n    <bool>true</bool>\n   </property>\n   <property name=\"checked\">\n    <bool>true</bool>\n   </property>\n   <property name=\"text\">\n    <string>Show Request Types Icons</string>\n   </property>\n  </action>\n  <action name=\"actionProject_Properties\">\n   <property name=\"text\">\n    <string>Project Properties</string>\n   </property>\n  </action>\n  <action name=\"actionCheck_for_updates\">\n   <property name=\"text\">\n    <string>Check for updates</string>\n   </property>\n  </action>\n </widget>\n <layoutdefault spacing=\"6\" margin=\"11\"/>\n <customwidgets>\n  <customwidget>\n   <class>FRequestTreeWidget</class>\n   <extends>QTreeWidget</extends>\n   <header>Widgets/frequesttreewidget.h</header>\n  </customwidget>\n </customwidgets>\n <resources>\n  <include location=\"Resources/resources.qrc\"/>\n </resources>\n <connections/>\n</ui>\n"
  },
  {
    "path": "preferences.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"preferences.h\"\r\n#include \"ui_preferences.h\"\r\n\r\nPreferences::Preferences(QWidget *parent, ConfigFileFRequest::Settings &currentSettings) :\r\n    QDialog(parent),\r\n    ui(new Ui::Preferences),\r\n    currentSettings(currentSettings)\r\n{\r\n    ui->setupUi(this);\r\n    this->setAttribute(Qt::WA_DeleteOnClose,true ); //destroy itself once finished.\r\n\r\n    ui->lbProjAuthDataNote->setText(\r\n                \"<b>Note:</b> These authentications are only the ones that were saved as \\\"FRequest Configuration File\\\", \"\r\n                \"that is the ones saved in your FRequest configuration (the ones saved as \"\r\n                \"\\\"FRequest Project File\\\" are not shown here).<br/><br/>\"\r\n                \"You can see and delete here the authentications for projects that you no longer use.\"\r\n                );\r\n    ui->lbProjAuthDataNote->adjustSize(); // to show all the text (resize label automatically to fit)\r\n\r\n    fillConfigProjAuthDataTable();\r\n\r\n    ui->twConfigProjAuthData->resizeColumnsToContents();\r\n}\r\n\r\nPreferences::~Preferences()\r\n{\r\n    delete ui;\r\n}\r\n\r\nvoid Preferences::showEvent(QShowEvent *e)\r\n{\r\n    if(!this->preferencesAreFullyLoaded)\r\n    {\r\n        // Apparently Qt doesn't contains a slot to when the Preferences was fully load. So we do our own implementation instead.\r\n        connect(this, SIGNAL(signalPreferencesAreLoaded()), this, SLOT(preferencesHaveLoaded()), Qt::ConnectionType::QueuedConnection);\r\n        emit signalPreferencesAreLoaded();\r\n    }\r\n\r\n    e->accept();\r\n}\r\n\r\n// Called only when the Preferences was fully loaded and painted on the screen. This slot is only called once.\r\nvoid Preferences::preferencesHaveLoaded(){\r\n    loadExistingSettings();\r\n\r\n    this->preferencesAreFullyLoaded = true;\r\n}\r\n\r\n// Need to override to do the verification\r\n// http://stackoverflow.com/questions/3261676/how-to-make-qdialogbuttonbox-not-close-its-parent-qdialog\r\nvoid Preferences::accept (){\r\n\r\n    if(ui->cbProxyUseProxy->isChecked()){\r\n        if(ui->cbProxyType->currentText() != \"Automatic\"){\r\n\r\n            QString proxyHostname = ui->leProxyHostname->text();\r\n            QString proxyPortNumber = ui->leProxyPort->text();\r\n\r\n            if(Util::Validation::checkEmptySpaces(QStringList() << proxyHostname << proxyPortNumber)){\r\n                Util::Dialogs::showError(\"Please fill the proxy hostname and port number.\");\r\n                return;\r\n            }\r\n\r\n            if(Util::Validation::checkIfIntegers(QStringList() << proxyPortNumber)){\r\n                Util::Dialogs::showError(\"Proxy port must be a number.\");\r\n                return;\r\n            }\r\n        }\r\n    }\r\n\r\n    // https://stackoverflow.com/a/16487964/1499019\r\n    this->currentSettings.requestTimeout = QTime(0, 0, 0).secsTo(ui->teRequestTimeout->time());\r\n\r\n    this->currentSettings.maxRequestResponseDataSizeToDisplay = ui->sbMaxRequestResponseDataSizeToDisplay->value();\r\n\r\n    if(ui->cbOnStartup->currentText() == \"Load last project\"){\r\n        this->currentSettings.onStartupSelectedOption = ConfigFileFRequest::OnStartupOption::LOAD_LAST_PROJECT;\r\n    }\r\n    else if(ui->cbOnStartup->currentText() == \"Ask to load last project\"){\r\n        this->currentSettings.onStartupSelectedOption = ConfigFileFRequest::OnStartupOption::ASK_TO_LOAD_LAST_PROJECT;\r\n    }\r\n    else if(ui->cbOnStartup->currentText() == \"Do nothing\"){\r\n        this->currentSettings.onStartupSelectedOption = ConfigFileFRequest::OnStartupOption::DO_NOTHING;\r\n    }\r\n    else{\r\n        QString errorMessage = \"Unrecognized cbOnStartup option selected! The On startup option will not be saved!\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n    }\r\n\r\n    this->currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting = ui->cbSaveWindowGeometryWhenExiting->isChecked();\r\n    this->currentSettings.defaultHeaders.useDefaultHeaders = ui->cbUseDefaultHeaders->isChecked();\r\n\r\n    this->currentSettings.useProxy = ui->cbProxyUseProxy->isChecked();\r\n\r\n    bool differentThanAutomaticProxy = true;\r\n\r\n    if(ui->cbProxyType->currentText() == \"Automatic\"){\r\n        this->currentSettings.proxySettings.type = ConfigFileFRequest::ProxyType::AUTOMATIC;\r\n        differentThanAutomaticProxy = false;\r\n    }\r\n    else if(ui->cbProxyType->currentText() == \"Http Transparent Proxy\"){\r\n        this->currentSettings.proxySettings.type = ConfigFileFRequest::ProxyType::HTTP_TRANSPARENT;\r\n    }\r\n    else if(ui->cbProxyType->currentText() == \"Http Proxy\"){\r\n        this->currentSettings.proxySettings.type = ConfigFileFRequest::ProxyType::HTTP;\r\n    }\r\n    else if(ui->cbProxyType->currentText() == \"Socks5 Proxy\"){\r\n        this->currentSettings.proxySettings.type = ConfigFileFRequest::ProxyType::SOCKS5;\r\n    }\r\n    else{\r\n        QString errorMessage = \"Tried to save unreconized proxy type! '\" + QString::number(static_cast<unsigned int>(this->currentSettings.proxySettings.type)) + \"'. Please choose a valid type.\";\r\n        Util::Dialogs::showWarning(errorMessage);\r\n        LOG_ERROR << errorMessage;\r\n        return;\r\n    }\r\n\r\n    if(differentThanAutomaticProxy){\r\n        this->currentSettings.proxySettings.hostName = ui->leProxyHostname->text();\r\n        this->currentSettings.proxySettings.portNumber = ui->leProxyPort->text().toUInt();\r\n    }\r\n\r\n    updateCurrentDefaultHeaders();\r\n\r\n    // Remove the requested config proj authentications\r\n    for(const QString &currProjUuid : this->configProjAuthsToDelete){\r\n        this->currentSettings.mapOfConfigAuths_UuidToConfigAuth.remove(currProjUuid);\r\n    }\r\n\r\n    ConfigFileFRequest::FRequestTheme newTheme = ConfigFileFRequest::geFRequestThemeByString(ui->cbTheme->currentText());\r\n    bool giveThemeWarningToRestart = false;\r\n\r\n    if(this->currentSettings.theme != newTheme){\r\n        giveThemeWarningToRestart = true;\r\n    }\r\n\r\n    this->currentSettings.theme = newTheme;\r\n\r\n    this->currentSettings.hideProjectSavedDialog = ui->cbHideProjectSavedDialog->isChecked();\r\n\r\n    emit saveSettings();\r\n\r\n    QDialog::accept();\r\n\r\n    if(giveThemeWarningToRestart){\r\n        Util::Dialogs::showWarning(\"The theme will only be applied once you restart \" + GlobalVars::AppName + \".\");\r\n    }\r\n\r\n    Util::Dialogs::showInfo(\"Settings saved with success!\");\r\n}\r\n\r\nvoid Preferences::on_buttonBox_rejected()\r\n{\r\n    // nothing todo (it auto closes)\r\n}\r\n\r\nvoid Preferences::on_cbUseDefaultHeaders_toggled(bool checked)\r\n{\r\n    ui->gbRequest->setEnabled(checked);\r\n\r\n    if(checked){\r\n        on_cbRequestType_currentIndexChanged(ui->cbRequestType->currentText());\r\n    }\r\n}\r\n\r\nvoid Preferences::on_cbRequestType_currentIndexChanged(const QString &arg1)\r\n{\r\n    ui->cbRequestBodyType->setEnabled(true);\r\n\r\n    // Indicates if body can be set or not depending on the given option\r\n    switch(UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText())){\r\n    case UtilFRequest::RequestType::GET_OPTION:\r\n    case UtilFRequest::RequestType::DELETE_OPTION:\r\n    case UtilFRequest::RequestType::HEAD_OPTION:\r\n    case UtilFRequest::RequestType::TRACE_OPTION:\r\n    {\r\n        ui->cbRequestBodyType->setEnabled(false);\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::POST_OPTION:\r\n    case UtilFRequest::RequestType::PUT_OPTION:\r\n    case UtilFRequest::RequestType::PATCH_OPTION:\r\n    case UtilFRequest::RequestType::OPTIONS_OPTION:\r\n    {\r\n        ui->cbRequestBodyType->setEnabled(true);\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        QString errorMessage = \"Request type unknown: '\" + arg1 + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n\r\n    if(this->preferencesAreFullyLoaded){\r\n        updateCurrentDefaultHeaders();\r\n        loadCurrentDefaultHeaders();\r\n    }\r\n\r\n    this->previousRequestType = arg1;\r\n}\r\n\r\nvoid Preferences::on_tbRequestBodyKeyValueAdd_clicked()\r\n{\r\n    Util::TableWidget::addRow(ui->twRequestBodyKeyValue, QStringList() << \"\" << \"\");\r\n}\r\n\r\nvoid Preferences::on_tbRequestBodyKeyValueRemove_clicked()\r\n{\r\n    int size = Util::TableWidget::getSelectedRows(ui->twRequestBodyKeyValue).size();\r\n\r\n    if(size==0){\r\n        Util::Dialogs::showInfo(\"Select a row first!\");\r\n        return;\r\n    }\r\n\r\n    if(Util::Dialogs::showQuestion(this, \"Are you sure you want to remove all selected rows?\")){\r\n        for(int i=0; i < size; i++){\r\n            ui->twRequestBodyKeyValue->removeRow(Util::TableWidget::getSelectedRows(ui->twRequestBodyKeyValue).at(size-i-1).row());\r\n        }\r\n\r\n        Util::Dialogs::showInfo(\"Key-Value rows deleted\");\r\n    }\r\n}\r\n\r\nvoid Preferences::loadExistingSettings(){\r\n    ui->teRequestTimeout->setTime(QTime(0,0).addSecs(this->currentSettings.requestTimeout));\r\n    ui->sbMaxRequestResponseDataSizeToDisplay->setValue(this->currentSettings.maxRequestResponseDataSizeToDisplay);\r\n    ui->cbUseDefaultHeaders->setChecked(this->currentSettings.defaultHeaders.useDefaultHeaders);\r\n    ui->cbSaveWindowGeometryWhenExiting->setChecked(this->currentSettings.windowsGeometry.saveWindowsGeometryWhenExiting);\r\n    ui->cbProxyUseProxy->setChecked(this->currentSettings.useProxy);\r\n    ui->cbHideProjectSavedDialog->setChecked(this->currentSettings.hideProjectSavedDialog);\r\n\r\n    // TODO Check if there's a better alternative to do this switches / ifs (maybe using enums??)\r\n    // (without do direct string comparisons), because as it is, it is easy to break if we change any of the strings\r\n    switch(this->currentSettings.onStartupSelectedOption){\r\n    case ConfigFileFRequest::OnStartupOption::LOAD_LAST_PROJECT:\r\n    {\r\n        ui->cbOnStartup->setCurrentText(\"Load last project\");\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::OnStartupOption::ASK_TO_LOAD_LAST_PROJECT:\r\n    {\r\n        ui->cbOnStartup->setCurrentText(\"Ask to load last project\");\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::OnStartupOption::DO_NOTHING:\r\n    {\r\n        ui->cbOnStartup->setCurrentText(\"Do nothing\");\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Ask to load last project\");\r\n        QString warningMessage = \"Unknown on startup option loaded! '\" +\r\n                QString::number(static_cast<unsigned int>(this->currentSettings.onStartupSelectedOption)) + \"'. Using 'Ask to load last project' instead.\";\r\n        Util::Dialogs::showWarning(warningMessage);\r\n        LOG_WARNING << warningMessage;\r\n    }\r\n    }\r\n\r\n    switch(this->currentSettings.proxySettings.type){\r\n    case ConfigFileFRequest::ProxyType::AUTOMATIC:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Automatic\");\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::ProxyType::HTTP_TRANSPARENT:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Http Transparent Proxy\");\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::ProxyType::HTTP:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Http Proxy\");\r\n        break;\r\n    }\r\n    case ConfigFileFRequest::ProxyType::SOCKS5:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Socks5 Proxy\");\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        ui->cbProxyType->setCurrentText(\"Automatic\");\r\n        QString warningMessage = \"Unknown proxy type loaded! '\" + QString::number(static_cast<unsigned int>(this->currentSettings.proxySettings.type)) + \"'. Using 'automatic' instead.\";\r\n        Util::Dialogs::showWarning(warningMessage);\r\n        LOG_WARNING << warningMessage;\r\n    }\r\n    }\r\n\r\n    ui->leProxyHostname->setText(this->currentSettings.proxySettings.hostName);\r\n    ui->leProxyPort->setText(QString::number(this->currentSettings.proxySettings.portNumber));\r\n\r\n    loadCurrentDefaultHeaders();\r\n\r\n    ui->cbTheme->setCurrentText(ConfigFileFRequest::getFRequestThemeString(this->currentSettings.theme));\r\n}\r\n\r\nvoid Preferences::loadCurrentDefaultHeaders(){\r\n\r\n    Util::TableWidget::clearContentsNoPrompt(ui->twRequestBodyKeyValue);\r\n\r\n    UtilFRequest::RequestType currentRequestType = UtilFRequest::getRequestTypeByString(ui->cbRequestType->currentText());\r\n\r\n    std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &currentProtocolHeader = ConfigFileFRequest::getSettingsHeaderForRequestType(currentRequestType, this->currentSettings);\r\n    bool mayHaveBody = UtilFRequest::requestTypeMayHaveBody(currentRequestType);\r\n\r\n    if(!mayHaveBody){\r\n        if(currentProtocolHeader.has_value()){\r\n            if(currentProtocolHeader.value().headers_Raw.has_value()){\r\n                for(const UtilFRequest::HttpHeader &currentHeader : currentProtocolHeader.value().headers_Raw.value())\r\n                {\r\n                    Util::TableWidget::addRow(ui->twRequestBodyKeyValue, QStringList() << currentHeader.name << currentHeader.value);\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else{\r\n        if(currentProtocolHeader.has_value()){\r\n\r\n            std::experimental::optional<QVector<UtilFRequest::HttpHeader>> *currentProtocolHeaders = nullptr;\r\n\r\n            if(ui->cbRequestBodyType->currentText() == \"raw\"){\r\n                currentProtocolHeaders = &currentProtocolHeader.value().headers_Raw;\r\n            }\r\n            else if(ui->cbRequestBodyType->currentText() == \"form-data\"){\r\n                currentProtocolHeaders = &currentProtocolHeader.value().headers_Form_Data;\r\n            }\r\n            else if(ui->cbRequestBodyType->currentText() == \"x-form-www-urlencoded\"){\r\n                currentProtocolHeaders = &currentProtocolHeader.value().headers_X_form_www_urlencoded;\r\n            }\r\n            else{\r\n                QString errorMessage = \"Error loading default headers! The type '\" + ui->cbRequestBodyType->currentText() + \"' is not being handled!\";\r\n                LOG_ERROR << errorMessage;\r\n                Util::Dialogs::showError(errorMessage);\r\n                return;\r\n            }\r\n\r\n            if(currentProtocolHeaders->has_value()){\r\n                for(const UtilFRequest::HttpHeader &currentHeader : currentProtocolHeaders->value())\r\n                {\r\n                    Util::TableWidget::addRow(ui->twRequestBodyKeyValue, QStringList() << currentHeader.name << currentHeader.value);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nstd::experimental::optional<QVector<UtilFRequest::HttpHeader>> Preferences::getRequestHeaders(){\r\n\r\n    std::experimental::optional<QVector<UtilFRequest::HttpHeader>> requestHeaders;\r\n\r\n    if(ui->twRequestBodyKeyValue->rowCount() > 0){\r\n        requestHeaders = QVector<UtilFRequest::HttpHeader>();\r\n    }\r\n\r\n    for(int i = 0; i < ui->twRequestBodyKeyValue->rowCount(); i++){\r\n\r\n        UtilFRequest::HttpHeader currentHeader;\r\n\r\n        currentHeader.name = ui->twRequestBodyKeyValue->item(i, 0)->text();\r\n        currentHeader.value = ui->twRequestBodyKeyValue->item(i, 1)->text();\r\n\r\n        requestHeaders.value().append(currentHeader);\r\n    }\r\n\r\n    return requestHeaders;\r\n}\r\n\r\nvoid Preferences::on_cbRequestBodyType_currentIndexChanged(const QString &arg1)\r\n{\r\n    if(this->preferencesAreFullyLoaded){\r\n        updateCurrentDefaultHeaders();\r\n        loadCurrentDefaultHeaders();\r\n    }\r\n\r\n    this->previousRequestBodyType = arg1;\r\n}\r\n\r\nvoid Preferences::updateCurrentDefaultHeaders(){\r\n    std::experimental::optional<QVector<UtilFRequest::HttpHeader>> currentRequestDefaultHeaders = getRequestHeaders();\r\n    std::experimental::optional<QVector<UtilFRequest::HttpHeader>> *currentHeaders = nullptr;\r\n\r\n    UtilFRequest::RequestType requestType = UtilFRequest::getRequestTypeByString(this->previousRequestType);\r\n\r\n    std::experimental::optional<ConfigFileFRequest::ProtocolHeader> &currentProtocolHeader = ConfigFileFRequest::getSettingsHeaderForRequestType(requestType, this->currentSettings);\r\n    bool mayHaveBody = UtilFRequest::requestTypeMayHaveBody(requestType);\r\n\r\n    if(!mayHaveBody){\r\n        currentProtocolHeader = ConfigFileFRequest::ProtocolHeader();\r\n\r\n        currentHeaders = &currentProtocolHeader.value().headers_Raw;\r\n    }\r\n    else{\r\n        // Create if not exist\r\n        if(!currentProtocolHeader.has_value()){\r\n            currentProtocolHeader = ConfigFileFRequest::ProtocolHeader();\r\n        }\r\n\r\n        if(this->previousRequestBodyType == \"raw\"){\r\n            currentHeaders = &currentProtocolHeader.value().headers_Raw;\r\n        }\r\n        else if(this->previousRequestBodyType == \"form-data\"){\r\n            currentHeaders = &currentProtocolHeader.value().headers_Form_Data;\r\n        }\r\n        else if(this->previousRequestBodyType == \"x-form-www-urlencoded\"){\r\n            currentHeaders = &currentProtocolHeader.value().headers_X_form_www_urlencoded;\r\n        }\r\n        else{\r\n            QString errorMessage = \"Error loading default headers! The type '\" + ui->cbRequestBodyType->currentText() + \"' is not being handled!\";\r\n            LOG_ERROR << errorMessage;\r\n            Util::Dialogs::showError(errorMessage);\r\n            return;\r\n        }\r\n    }\r\n\r\n    (*currentHeaders) = currentRequestDefaultHeaders;\r\n}\r\n\r\nvoid Preferences::on_cbProxyUseProxy_toggled(bool checked)\r\n{\r\n    ui->gbProxy->setEnabled(checked);\r\n}\r\n\r\nvoid Preferences::on_cbProxyType_currentIndexChanged(const QString &arg1)\r\n{\r\n    if(arg1 == \"Automatic\"){\r\n        ui->leProxyHostname->setEnabled(false);\r\n        ui->leProxyPort->setEnabled(false);\r\n    }\r\n    else{\r\n        ui->leProxyHostname->setEnabled(true);\r\n        ui->leProxyPort->setEnabled(true);\r\n    }\r\n}\r\n\r\nvoid Preferences::fillConfigProjAuthDataTable(){\r\n    for(const ConfigFileFRequest::ConfigurationProjectAuthentication &currAuthData :\r\n        this->currentSettings.mapOfConfigAuths_UuidToConfigAuth){\r\n        Util::TableWidget::addRow(ui->twConfigProjAuthData, QStringList() <<\r\n                                  currAuthData.lastProjectName <<\r\n                                  currAuthData.projectUuid <<\r\n                                  FRequestAuthentication::getAuthenticationString(currAuthData.authData->type)\r\n                                  );\r\n    }\r\n\r\n    // Disable editing on our table\r\n    for(int i=0; i<ui->twConfigProjAuthData->rowCount(); i++){\r\n        for(int j=0; j<ui->twConfigProjAuthData->columnCount(); j++){\r\n            ui->twConfigProjAuthData->item(i,j)->setFlags(ui->twConfigProjAuthData->item(i,j)->flags() & (~Qt::ItemIsEditable));\r\n        }\r\n    }\r\n}\r\n\r\nvoid Preferences::on_tbConfigProjDataRemove_clicked()\r\n{\r\n    int size = Util::TableWidget::getSelectedRows(ui->twConfigProjAuthData).size();\r\n\r\n    if(size==0){\r\n        Util::Dialogs::showInfo(\"Select a row first!\");\r\n        return;\r\n    }\r\n\r\n    if(Util::Dialogs::showQuestion(this, \"Are you sure you want to remove all selected rows?\")){\r\n        for(int i=0; i < size; i++){\r\n            this->configProjAuthsToDelete.append(ui->twConfigProjAuthData->item(Util::TableWidget::getSelectedRows(ui->twConfigProjAuthData).at(size-i-1).row(),1)->text()); // TODO: replace 1 by an index enum\r\n            ui->twConfigProjAuthData->removeRow(Util::TableWidget::getSelectedRows(ui->twConfigProjAuthData).at(size-i-1).row());\r\n        }\r\n\r\n        Util::Dialogs::showInfo(\"Authentications rows deleted\");\r\n    }\r\n}\r\n"
  },
  {
    "path": "preferences.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef PREFERENCES_H\r\n#define PREFERENCES_H\r\n\r\n#include <QDialog>\r\n#include <QSettings>\r\n#include <QMessageBox>\r\n#include <QShowEvent>\r\n\r\n#include \"util.h\"\r\n#include \"XmlParsers/configfilefrequest.h\"\r\n\r\nnamespace Ui {\r\nclass Preferences;\r\n}\r\n\r\nclass Preferences : public QDialog\r\n{\r\n    Q_OBJECT\r\n    \r\npublic:\r\n    Preferences(QWidget *parent, ConfigFileFRequest::Settings &currentSettings);\r\n    ~Preferences();\r\n\r\nprivate slots:\r\n\r\n\tvoid accept ();\r\n\r\n    void on_buttonBox_rejected();\r\n\r\n    void on_cbUseDefaultHeaders_toggled(bool checked);\r\n\r\n    void on_cbRequestType_currentIndexChanged(const QString &arg1);\r\n\r\n    void on_tbRequestBodyKeyValueAdd_clicked();\r\n\r\n    void on_tbRequestBodyKeyValueRemove_clicked();\r\n\r\n    void on_cbRequestBodyType_currentIndexChanged(const QString &arg1);\r\n    void preferencesHaveLoaded();\r\n\r\n    void on_cbProxyUseProxy_toggled(bool checked);\r\n\r\n    void on_cbProxyType_currentIndexChanged(const QString &arg1);\r\n\r\n    void on_tbConfigProjDataRemove_clicked();\r\n\r\nsignals:\r\n    void signalPreferencesAreLoaded();\r\n    void saveSettings();\r\n\r\nprivate:\r\n    Ui::Preferences *ui;\r\n    ConfigFileFRequest::Settings &currentSettings;\r\n    QString previousRequestType = \"GET\"; // by default\r\n    QString previousRequestBodyType = \"raw\";\r\n    bool preferencesAreFullyLoaded = false;\r\n    QVector<QString> configProjAuthsToDelete;\r\n\r\nprivate:\r\n    void showEvent(QShowEvent *e);\r\n    void loadExistingSettings();\r\n    std::experimental::optional<QVector<UtilFRequest::HttpHeader> > getRequestHeaders();\r\n    void loadCurrentDefaultHeaders();\r\n    void updateCurrentDefaultHeaders();\r\n    void fillConfigProjAuthDataTable();\r\n};\r\n\r\n#endif // PREFERENCES_H\r\n"
  },
  {
    "path": "preferences.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Preferences</class>\r\n <widget class=\"QDialog\" name=\"Preferences\">\r\n  <property name=\"geometry\">\r\n   <rect>\r\n    <x>0</x>\r\n    <y>0</y>\r\n    <width>800</width>\r\n    <height>600</height>\r\n   </rect>\r\n  </property>\r\n  <property name=\"windowTitle\">\r\n   <string>Preferences</string>\r\n  </property>\r\n  <layout class=\"QVBoxLayout\" name=\"verticalLayout\">\r\n   <item>\r\n    <widget class=\"QTabWidget\" name=\"tabWidget\">\r\n     <property name=\"currentIndex\">\r\n      <number>0</number>\r\n     </property>\r\n     <widget class=\"QWidget\" name=\"tab\">\r\n      <attribute name=\"title\">\r\n       <string>General</string>\r\n      </attribute>\r\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_3\">\r\n       <item>\r\n        <layout class=\"QFormLayout\" name=\"formLayout_2\">\r\n         <item row=\"0\" column=\"0\">\r\n          <widget class=\"QLabel\" name=\"label_2\">\r\n           <property name=\"toolTip\">\r\n            <string>Minutes - Seconds (00:00 means no timeout)</string>\r\n           </property>\r\n           <property name=\"text\">\r\n            <string>Request timeout:</string>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n         <item row=\"0\" column=\"1\">\r\n          <widget class=\"QTimeEdit\" name=\"teRequestTimeout\">\r\n           <property name=\"toolTip\">\r\n            <string>Minutes - Seconds (00:00 means no timeout)</string>\r\n           </property>\r\n           <property name=\"displayFormat\">\r\n            <string>mm:ss</string>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n        </layout>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QCheckBox\" name=\"cbUseDefaultHeaders\">\r\n         <property name=\"text\">\r\n          <string>Use default headers</string>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QGroupBox\" name=\"gbRequest\">\r\n         <property name=\"enabled\">\r\n          <bool>false</bool>\r\n         </property>\r\n         <property name=\"sizePolicy\">\r\n          <sizepolicy hsizetype=\"Preferred\" vsizetype=\"Expanding\">\r\n           <horstretch>0</horstretch>\r\n           <verstretch>0</verstretch>\r\n          </sizepolicy>\r\n         </property>\r\n         <property name=\"title\">\r\n          <string>Request</string>\r\n         </property>\r\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_2\">\r\n          <item>\r\n           <layout class=\"QFormLayout\" name=\"formLayout_3\">\r\n            <item row=\"0\" column=\"0\">\r\n             <widget class=\"QLabel\" name=\"label_4\">\r\n              <property name=\"text\">\r\n               <string>Request type:</string>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n            <item row=\"0\" column=\"1\">\r\n             <widget class=\"QComboBox\" name=\"cbRequestType\">\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>GET</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>POST</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>PUT</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>DELETE</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>PATCH</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>HEAD</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>TRACE</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>OPTIONS</string>\r\n               </property>\r\n              </item>\r\n             </widget>\r\n            </item>\r\n           </layout>\r\n          </item>\r\n          <item>\r\n           <widget class=\"QGroupBox\" name=\"gbHeaders\">\r\n            <property name=\"title\">\r\n             <string>Headers</string>\r\n            </property>\r\n            <layout class=\"QHBoxLayout\" name=\"horizontalLayout_2\">\r\n             <item>\r\n              <layout class=\"QHBoxLayout\" name=\"horizontalLayout\">\r\n               <item>\r\n                <widget class=\"QLabel\" name=\"label_3\">\r\n                 <property name=\"text\">\r\n                  <string>Body Type:</string>\r\n                 </property>\r\n                </widget>\r\n               </item>\r\n               <item>\r\n                <widget class=\"QComboBox\" name=\"cbRequestBodyType\">\r\n                 <item>\r\n                  <property name=\"text\">\r\n                   <string>raw</string>\r\n                  </property>\r\n                 </item>\r\n                 <item>\r\n                  <property name=\"text\">\r\n                   <string>form-data</string>\r\n                  </property>\r\n                 </item>\r\n                 <item>\r\n                  <property name=\"text\">\r\n                   <string>x-form-www-urlencoded</string>\r\n                  </property>\r\n                 </item>\r\n                </widget>\r\n               </item>\r\n              </layout>\r\n             </item>\r\n             <item>\r\n              <layout class=\"QHBoxLayout\" name=\"horizontalLayout_8\">\r\n               <item>\r\n                <widget class=\"QTableWidget\" name=\"twRequestBodyKeyValue\">\r\n                 <property name=\"alternatingRowColors\">\r\n                  <bool>true</bool>\r\n                 </property>\r\n                 <column>\r\n                  <property name=\"text\">\r\n                   <string>Key</string>\r\n                  </property>\r\n                 </column>\r\n                 <column>\r\n                  <property name=\"text\">\r\n                   <string>Value</string>\r\n                  </property>\r\n                 </column>\r\n                </widget>\r\n               </item>\r\n               <item>\r\n                <layout class=\"QVBoxLayout\" name=\"verticalLayout_7\">\r\n                 <item>\r\n                  <widget class=\"QToolButton\" name=\"tbRequestBodyKeyValueAdd\">\r\n                   <property name=\"toolTip\">\r\n                    <string>Add new row</string>\r\n                   </property>\r\n                   <property name=\"text\">\r\n                    <string>...</string>\r\n                   </property>\r\n                   <property name=\"icon\">\r\n                    <iconset resource=\"Resources/resources.qrc\">\r\n                     <normaloff>:/icons/plus.png</normaloff>:/icons/plus.png</iconset>\r\n                   </property>\r\n                  </widget>\r\n                 </item>\r\n                 <item>\r\n                  <widget class=\"QToolButton\" name=\"tbRequestBodyKeyValueRemove\">\r\n                   <property name=\"toolTip\">\r\n                    <string>Remove selected rows</string>\r\n                   </property>\r\n                   <property name=\"text\">\r\n                    <string>...</string>\r\n                   </property>\r\n                   <property name=\"icon\">\r\n                    <iconset resource=\"Resources/resources.qrc\">\r\n                     <normaloff>:/icons/minus.png</normaloff>:/icons/minus.png</iconset>\r\n                   </property>\r\n                  </widget>\r\n                 </item>\r\n                </layout>\r\n               </item>\r\n              </layout>\r\n             </item>\r\n            </layout>\r\n           </widget>\r\n          </item>\r\n         </layout>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <layout class=\"QFormLayout\" name=\"formLayout_4\">\r\n         <item row=\"0\" column=\"0\">\r\n          <widget class=\"QLabel\" name=\"label_8\">\r\n           <property name=\"toolTip\">\r\n            <string>Warning: Setting this value too high can slown down or even crash FRequest (since it parses all the received data). \r\n\r\nAs alternative try to download the response as file (since this way it writes all the data to a file).\r\n\r\n(Default value = 200 KB)</string>\r\n           </property>\r\n           <property name=\"text\">\r\n            <string>Max request response data size to display:</string>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n         <item row=\"1\" column=\"0\">\r\n          <widget class=\"QLabel\" name=\"label_7\">\r\n           <property name=\"text\">\r\n            <string>On startup:</string>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n         <item row=\"1\" column=\"1\">\r\n          <widget class=\"QComboBox\" name=\"cbOnStartup\">\r\n           <item>\r\n            <property name=\"text\">\r\n             <string>Ask to load last project</string>\r\n            </property>\r\n           </item>\r\n           <item>\r\n            <property name=\"text\">\r\n             <string>Load last project</string>\r\n            </property>\r\n           </item>\r\n           <item>\r\n            <property name=\"text\">\r\n             <string>Do nothing</string>\r\n            </property>\r\n           </item>\r\n          </widget>\r\n         </item>\r\n         <item row=\"2\" column=\"0\">\r\n          <widget class=\"QLabel\" name=\"label_9\">\r\n           <property name=\"text\">\r\n            <string>Theme:</string>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n         <item row=\"2\" column=\"1\">\r\n          <widget class=\"QComboBox\" name=\"cbTheme\">\r\n           <item>\r\n            <property name=\"text\">\r\n             <string>OS Default</string>\r\n            </property>\r\n           </item>\r\n           <item>\r\n            <property name=\"text\">\r\n             <string>Jorgen's Dark Theme</string>\r\n            </property>\r\n           </item>\r\n          </widget>\r\n         </item>\r\n         <item row=\"0\" column=\"1\">\r\n          <widget class=\"QSpinBox\" name=\"sbMaxRequestResponseDataSizeToDisplay\">\r\n           <property name=\"toolTip\">\r\n            <string>Warning: Setting this value too high can slown down or even crash FRequest (since it parses all the received data). \r\n\r\nAs alternative try to download the response as file (since this way it writes all the data to a file).\r\n\r\n(Default value = 200 KB)</string>\r\n           </property>\r\n           <property name=\"buttonSymbols\">\r\n            <enum>QAbstractSpinBox::NoButtons</enum>\r\n           </property>\r\n           <property name=\"suffix\">\r\n            <string> KB</string>\r\n           </property>\r\n           <property name=\"minimum\">\r\n            <number>50</number>\r\n           </property>\r\n           <property name=\"maximum\">\r\n            <number>512000</number>\r\n           </property>\r\n           <property name=\"value\">\r\n            <number>200</number>\r\n           </property>\r\n          </widget>\r\n         </item>\r\n        </layout>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QCheckBox\" name=\"cbSaveWindowGeometryWhenExiting\">\r\n         <property name=\"text\">\r\n          <string>Save window geometry when exiting</string>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QCheckBox\" name=\"cbHideProjectSavedDialog\">\r\n         <property name=\"text\">\r\n          <string>Hide confirmation dialog when saving a project</string>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n      </layout>\r\n     </widget>\r\n     <widget class=\"QWidget\" name=\"tab_3\">\r\n      <attribute name=\"title\">\r\n       <string>Network</string>\r\n      </attribute>\r\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_5\">\r\n       <item>\r\n        <widget class=\"QCheckBox\" name=\"cbProxyUseProxy\">\r\n         <property name=\"text\">\r\n          <string>Use proxy</string>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QGroupBox\" name=\"gbProxy\">\r\n         <property name=\"enabled\">\r\n          <bool>false</bool>\r\n         </property>\r\n         <property name=\"title\">\r\n          <string>Proxy</string>\r\n         </property>\r\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_4\">\r\n          <item>\r\n           <layout class=\"QFormLayout\" name=\"formLayout\">\r\n            <item row=\"0\" column=\"0\">\r\n             <widget class=\"QLabel\" name=\"label\">\r\n              <property name=\"text\">\r\n               <string>Proxy Type:</string>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n            <item row=\"0\" column=\"1\">\r\n             <widget class=\"QComboBox\" name=\"cbProxyType\">\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>Automatic</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>Http Transparent Proxy</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>Http Proxy</string>\r\n               </property>\r\n              </item>\r\n              <item>\r\n               <property name=\"text\">\r\n                <string>Socks5 Proxy</string>\r\n               </property>\r\n              </item>\r\n             </widget>\r\n            </item>\r\n            <item row=\"1\" column=\"0\">\r\n             <widget class=\"QLabel\" name=\"label_5\">\r\n              <property name=\"text\">\r\n               <string>Hostname:</string>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n            <item row=\"1\" column=\"1\">\r\n             <widget class=\"QLineEdit\" name=\"leProxyHostname\">\r\n              <property name=\"enabled\">\r\n               <bool>false</bool>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n            <item row=\"2\" column=\"0\">\r\n             <widget class=\"QLabel\" name=\"label_6\">\r\n              <property name=\"text\">\r\n               <string>Port:</string>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n            <item row=\"2\" column=\"1\">\r\n             <widget class=\"QLineEdit\" name=\"leProxyPort\">\r\n              <property name=\"enabled\">\r\n               <bool>false</bool>\r\n              </property>\r\n              <property name=\"text\">\r\n               <string>3128</string>\r\n              </property>\r\n             </widget>\r\n            </item>\r\n           </layout>\r\n          </item>\r\n         </layout>\r\n        </widget>\r\n       </item>\r\n      </layout>\r\n     </widget>\r\n     <widget class=\"QWidget\" name=\"tab_2\">\r\n      <attribute name=\"title\">\r\n       <string>Projects Authentications Data</string>\r\n      </attribute>\r\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_6\">\r\n       <item>\r\n        <widget class=\"QLabel\" name=\"lbProjAuthDataNote\">\r\n         <property name=\"text\">\r\n          <string>Note:</string>\r\n         </property>\r\n         <property name=\"wordWrap\">\r\n          <bool>true</bool>\r\n         </property>\r\n        </widget>\r\n       </item>\r\n       <item>\r\n        <spacer name=\"verticalSpacer\">\r\n         <property name=\"orientation\">\r\n          <enum>Qt::Vertical</enum>\r\n         </property>\r\n         <property name=\"sizeType\">\r\n          <enum>QSizePolicy::Fixed</enum>\r\n         </property>\r\n         <property name=\"sizeHint\" stdset=\"0\">\r\n          <size>\r\n           <width>20</width>\r\n           <height>20</height>\r\n          </size>\r\n         </property>\r\n        </spacer>\r\n       </item>\r\n       <item>\r\n        <widget class=\"QGroupBox\" name=\"groupBox\">\r\n         <property name=\"title\">\r\n          <string>FRequest Configuration Projects Authentications</string>\r\n         </property>\r\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_8\">\r\n          <item>\r\n           <layout class=\"QHBoxLayout\" name=\"horizontalLayout_3\">\r\n            <item>\r\n             <widget class=\"QTableWidget\" name=\"twConfigProjAuthData\">\r\n              <property name=\"alternatingRowColors\">\r\n               <bool>true</bool>\r\n              </property>\r\n              <property name=\"sortingEnabled\">\r\n               <bool>true</bool>\r\n              </property>\r\n              <column>\r\n               <property name=\"text\">\r\n                <string>Project Last Name</string>\r\n               </property>\r\n              </column>\r\n              <column>\r\n               <property name=\"text\">\r\n                <string>Project Uuid</string>\r\n               </property>\r\n              </column>\r\n              <column>\r\n               <property name=\"text\">\r\n                <string>Authentication Type</string>\r\n               </property>\r\n              </column>\r\n             </widget>\r\n            </item>\r\n            <item>\r\n             <layout class=\"QVBoxLayout\" name=\"verticalLayout_10\">\r\n              <item>\r\n               <widget class=\"QToolButton\" name=\"tbConfigProjDataRemove\">\r\n                <property name=\"toolTip\">\r\n                 <string>Remove selected rows</string>\r\n                </property>\r\n                <property name=\"text\">\r\n                 <string>...</string>\r\n                </property>\r\n                <property name=\"icon\">\r\n                 <iconset resource=\"Resources/resources.qrc\">\r\n                  <normaloff>:/icons/minus.png</normaloff>:/icons/minus.png</iconset>\r\n                </property>\r\n               </widget>\r\n              </item>\r\n             </layout>\r\n            </item>\r\n           </layout>\r\n          </item>\r\n         </layout>\r\n        </widget>\r\n       </item>\r\n      </layout>\r\n     </widget>\r\n    </widget>\r\n   </item>\r\n   <item>\r\n    <widget class=\"QDialogButtonBox\" name=\"buttonBox\">\r\n     <property name=\"orientation\">\r\n      <enum>Qt::Horizontal</enum>\r\n     </property>\r\n     <property name=\"standardButtons\">\r\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\r\n     </property>\r\n    </widget>\r\n   </item>\r\n  </layout>\r\n </widget>\r\n <resources>\r\n  <include location=\"Resources/resources.qrc\"/>\r\n </resources>\r\n <connections>\r\n  <connection>\r\n   <sender>buttonBox</sender>\r\n   <signal>accepted()</signal>\r\n   <receiver>Preferences</receiver>\r\n   <slot>accept()</slot>\r\n   <hints>\r\n    <hint type=\"sourcelabel\">\r\n     <x>248</x>\r\n     <y>254</y>\r\n    </hint>\r\n    <hint type=\"destinationlabel\">\r\n     <x>157</x>\r\n     <y>274</y>\r\n    </hint>\r\n   </hints>\r\n  </connection>\r\n  <connection>\r\n   <sender>buttonBox</sender>\r\n   <signal>rejected()</signal>\r\n   <receiver>Preferences</receiver>\r\n   <slot>reject()</slot>\r\n   <hints>\r\n    <hint type=\"sourcelabel\">\r\n     <x>316</x>\r\n     <y>260</y>\r\n    </hint>\r\n    <hint type=\"destinationlabel\">\r\n     <x>286</x>\r\n     <y>274</y>\r\n    </hint>\r\n   </hints>\r\n  </connection>\r\n </connections>\r\n</ui>\r\n"
  },
  {
    "path": "projectproperties.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"projectproperties.h\"\n#include \"ui_projectproperties.h\"\n\nProjectProperties::ProjectProperties(QWidget *parent, FRequestTreeWidgetProjectItem * const projectItem) :\n    QDialog(parent),\n    ui(new Ui::ProjectProperties),\n    projectItem(projectItem)\n{\n    ui->setupUi(this);\n    this->setAttribute(Qt::WA_DeleteOnClose,true); //destroy itself once finished.\n    fillInterface();\n\n    if(this->projectItem->authData != nullptr){\n        fillAuthenticationData(*this->projectItem->authData);\n    }\n\n    if(this->currentPasswordSalt.isEmpty()){\n        // Unix time as sha256\n        this->currentPasswordSalt = QCryptographicHash::hash(QByteArray().setNum(QDateTime::currentDateTime().toSecsSinceEpoch()), QCryptographicHash::Sha256).toHex();\n    }\n\n    setRequestAuthenticationNote();\n\n    ui->lbProjectPropertiesNote->setText(\n                \"<b>Note:</b> Request authentication works by selecting one of your requests as the one for the authentication.<br/><br/>\"\n                \"If you have a website you can find the request that you need by checking in your browser the one that authenticates you \"\n                \"(normally you could find it in a \\\"network\\\" tab), \"\n                \"then just replicate that request in FRequest and select it for the authentication here.<br/><br/>\"\n                \"Currently FRequest can only use a single request for the authentication.<br/><br/>\"\n                \"You should add in your authentication request the FRequest placeholders for the username and password, they are respectively \"\n                \"{{FREQUEST_AUTH_USERNAME}} and {{FREQUEST_AUTH_PASSWORD}}.<br/><br/>\"\n                \"You can add these placeholders either in the body of the request or in the headers. \"\n                \"FRequest will replace them automatically when authenticating by the username and password that you input above.\"\n                );\n}\n\nvoid ProjectProperties::fillInterface(){\n\n    ui->leProjectName->setText(this->projectItem->projectName);\n    ui->leProjectMainUrl->setText(this->projectItem->projectMainUrl);\n\n    // Get all requests name to fill request combobox\n    for(int i=0; i < this->projectItem->childCount(); i++){\n        FRequestTreeWidgetRequestItem* currentRequest = FRequestTreeWidgetRequestItem::fromQTreeWidgetItem(this->projectItem->child(i));\n\n        ui->cbRequestForAuthentication->addItem(getComboBoxNameForRequest(currentRequest), QVariant::fromValue(currentRequest));\n    }\n\n    ui->cbIdentCharacter->setCurrentText(UtilFRequest::getIdentCharacterString(this->projectItem->saveIdentCharacter));\n\n    for (int i = 0; i < this->projectItem->globalHeaders.size(); i++) {\n        const UtilFRequest::HttpHeader &currGlobalHeader = this->projectItem->globalHeaders.at(i);\n\n        Util::TableWidget::addRow(ui->twGlobalHeaderKeyValue, QStringList() << currGlobalHeader.name << currGlobalHeader.value);\n    }\n}\n\nProjectProperties::~ProjectProperties()\n{\n    delete ui;\n}\n\nvoid ProjectProperties::on_cbRequestType_currentIndexChanged(const QString &arg1)\n{\n    ui->cbRequestForAuthentication->setEnabled(false);\n\n    if(arg1 == \"Request Authentication\"){\n        ui->cbRequestForAuthentication->setEnabled(true);\n    }\n\n    setRequestAuthenticationNote();\n}\n\n// Need to override to do the verification\n// http://stackoverflow.com/questions/3261676/how-to-make-qdialogbuttonbox-not-close-its-parent-qdialog\nvoid ProjectProperties::accept (){\n\n    // Validations\n    if(Util::Validation::checkEmptySpaces(\n                QStringList() <<\n                ui->leProjectName->text() <<\n                ui->leProjectMainUrl->text()\n                )){\n        Util::Dialogs::showError(\"Please fill the project name and main url.\");\n        return;\n    }\n\n    if(ui->cbUseAuthentication->isChecked() && Util::Validation::checkEmptySpaces(\n                QStringList() <<\n                ui->leUsername->text()\n                )){\n        Util::Dialogs::showError(\"Please fill the authorization username and authorization password.\");\n        return;\n    }\n\n    this->projectItem->projectName = ui->leProjectName->text();\n    this->projectItem->setText(0, this->projectItem->projectName); // todo replace column with enum\n    this->projectItem->projectMainUrl = ui->leProjectMainUrl->text();\n\n    if(ui->cbUseAuthentication->isChecked()){\n        switch(FRequestAuthentication::getAuthenticationTypeByString(ui->cbRequestType->currentText())){\n        case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n        {\n            this->projectItem->authData = std::make_shared<RequestAuthentication>(\n                        ui->rbSaveProjectAuthToConfigurationFile->isChecked(),\n                        ui->cbRetryLoginIfError401->isChecked(),\n                        ui->leUsername->text(),\n                        this->currentPasswordSalt,\n                        ui->lePassword->text(),\n                        qvariant_cast<FRequestTreeWidgetRequestItem*>(ui->cbRequestForAuthentication->itemData(ui->cbRequestForAuthentication->currentIndex()))->itemContent.uuid\n                        );\n            break;\n        }\n        case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n        {\n            this->projectItem->authData = std::make_shared<BasicAuthentication>(BasicAuthentication(ui->rbSaveProjectAuthToConfigurationFile->isChecked(),\n                                                                                                    ui->cbRetryLoginIfError401->isChecked(),\n                                                                                                    ui->leUsername->text(),\n                                                                                                    this->currentPasswordSalt,\n                                                                                                    ui->lePassword->text()\n                                                                                                    ));\n            break;\n        }\n        default:\n        {\n            QString errorMessage = \"Authentication type unknown: '\" + ui->cbRequestType->currentText() + \"'. Program can't proceed.\";\n            Util::Dialogs::showError(errorMessage);\n            LOG_FATAL << errorMessage;\n            exit(1);\n        }\n        }\n    }\n    else{\n        this->projectItem->authData = nullptr; // clear the old authentication data\n    }\n\n    UtilFRequest::IdentCharacter identCharacter = UtilFRequest::getIdentCharacterByString(ui->cbIdentCharacter->currentText());\n\n    switch(identCharacter){\n    case UtilFRequest::IdentCharacter::SPACE:\n    case UtilFRequest::IdentCharacter::TAB:\n    {\n        this->projectItem->saveIdentCharacter = identCharacter;\n        break;\n    }\n    default:\n    {\n        QString errorMessage = \"Ident character unknown: '\" + ui->cbIdentCharacter->currentText() + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n\n    // Save global headers\n    this->projectItem->globalHeaders.clear();\n    for (int i = 0; i < ui->twGlobalHeaderKeyValue->rowCount(); i++) {\n        UtilFRequest::HttpHeader currentHeader;\n        currentHeader.name =  ui->twGlobalHeaderKeyValue->item(i, 0)->text();\n        currentHeader.value = ui->twGlobalHeaderKeyValue->item(i, 1)->text();\n        this->projectItem->globalHeaders.append(currentHeader);\n    }\n\n    QDialog::accept();\n\n    emit signalSaveProjectProperties();\n}\n\nvoid ProjectProperties::on_cbUseAuthentication_toggled(bool checked)\n{\n    ui->gbAuthentication->setEnabled(checked);\n}\n\nvoid ProjectProperties::on_tbGlobalHeaderKeyValueAdd_clicked()\n{\n    Util::TableWidget::addRow(ui->twGlobalHeaderKeyValue, QStringList() << \"\" << \"\");\n}\n\nvoid ProjectProperties::on_tbGlobalHeaderKeyValueRemove_clicked()\n{\n\n    int size = Util::TableWidget::getSelectedRows(ui->twGlobalHeaderKeyValue).size();\n\n    if(size==0){\n        Util::Dialogs::showInfo(\"Select a row first!\");\n        return;\n    }\n\n    if(Util::Dialogs::showQuestion(this, \"Are you sure you want to remove all selected rows?\")){\n        for(int i=0; i < size; i++){\n            ui->twGlobalHeaderKeyValue->removeRow(Util::TableWidget::getSelectedRows(ui->twGlobalHeaderKeyValue).at(size-i-1).row());\n        }\n        Util::Dialogs::showInfo(\"Key-Value rows deleted\");\n    }\n}\n\nvoid ProjectProperties::fillAuthenticationData(FRequestAuthentication &auth){\n\n    ui->cbUseAuthentication->setChecked(true);\n\n    if(auth.saveAuthToConfigFile){\n        ui->rbSaveProjectAuthToConfigurationFile->setChecked(true);\n    }\n    else{\n        ui->rbSaveProjectAuthToProjectFile->setChecked(true);\n    }\n\n    ui->cbRequestType->setCurrentText(FRequestAuthentication::getAuthenticationString(auth.type));\n\n    switch(auth.type){\n    case FRequestAuthentication::AuthenticationType::REQUEST_AUTHENTICATION:\n    {\n        // https://stackoverflow.com/a/43572369/1499019\n        RequestAuthentication &concreteAuth = static_cast<RequestAuthentication&>(auth);\n\n        ui->leUsername->setText(concreteAuth.username);\n        ui->lePassword->setText(concreteAuth.password);\n        ui->cbRequestForAuthentication->setCurrentIndex(\n                    ui->cbRequestForAuthentication->findData(QVariant::fromValue(this->projectItem->getChildRequestByUuid(concreteAuth.requestForAuthenticationUuid)))\n                    );\n        this->currentPasswordSalt = concreteAuth.passwordSalt;\n        break;\n    }\n    case FRequestAuthentication::AuthenticationType::BASIC_AUTHENTICATION:\n    {\n        BasicAuthentication &concreteAuth = static_cast<BasicAuthentication&>(auth);\n\n        ui->leUsername->setText(concreteAuth.username);\n        ui->lePassword->setText(concreteAuth.password);\n        this->currentPasswordSalt = concreteAuth.passwordSalt;\n        break;\n    }\n    default:\n    {\n        QString errorMessage = \"Invalid authentication type \" + QString::number(static_cast<int>(auth.type)) + \"'. Program can't proceed.\";\n        Util::Dialogs::showError(errorMessage);\n        LOG_FATAL << errorMessage;\n        exit(1);\n    }\n    }\n\n    ui->cbRetryLoginIfError401->setChecked(auth.retryLoginIfError401);\n}\n\nQString ProjectProperties::getComboBoxNameForRequest(const FRequestTreeWidgetRequestItem* const currentRequest){\n    return currentRequest->itemContent.name + \" (\" + UtilFRequest::getRequestTypeString(currentRequest->itemContent.requestType) + \")\";\n}\n\nvoid ProjectProperties::setRequestAuthenticationNote(){\n    if(ui->cbRequestType->currentText() == \"Request Authentication\"){\n        ui->saProjectPropertiesNote->setVisible(true);\n    }\n    else{\n        ui->saProjectPropertiesNote->setVisible(false);\n    }\n}\n"
  },
  {
    "path": "projectproperties.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef PROJECTPROPERTIES_H\n#define PROJECTPROPERTIES_H\n\n#include <QDialog>\n#include <QCryptographicHash>\n\n#include \"customtreewidget.h\"\n#include \"Widgets/frequesttreewidgetprojectitem.h\"\n#include \"Authentications/basicauthentication.h\"\n#include \"Authentications/requestauthentication.h\"\n\nnamespace Ui {\nclass ProjectProperties;\n}\n\nclass ProjectProperties : public QDialog\n{\n    Q_OBJECT\n\npublic:\n    explicit ProjectProperties(QWidget *parent, FRequestTreeWidgetProjectItem * const projectItem);\n    ~ProjectProperties();\n\nsignals:\n\tvoid signalSaveProjectProperties();\n\t\nprivate slots:\n    void on_cbRequestType_currentIndexChanged(const QString &arg1);\n    void accept ();\n\n    void on_cbUseAuthentication_toggled(bool checked);\n    void on_tbGlobalHeaderKeyValueAdd_clicked();\n    void on_tbGlobalHeaderKeyValueRemove_clicked();\n\nprivate:\n    void fillInterface();\n\tvoid fillAuthenticationData(FRequestAuthentication &auth);\n\tQString getComboBoxNameForRequest(const FRequestTreeWidgetRequestItem* const currentRequest);\n    void setRequestAuthenticationNote();\n\t\nprivate:\n    Ui::ProjectProperties *ui;\n\tFRequestTreeWidgetProjectItem* const projectItem; // not const because we can update its name in this class\n\tQString currentPasswordSalt;\n};\n\n#endif // PROJECTPROPERTIES_H\n"
  },
  {
    "path": "projectproperties.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>ProjectProperties</class>\n <widget class=\"QDialog\" name=\"ProjectProperties\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>689</width>\n    <height>675</height>\n   </rect>\n  </property>\n  <property name=\"windowTitle\">\n   <string>Project Properties</string>\n  </property>\n  <layout class=\"QVBoxLayout\" name=\"verticalLayout\">\n   <property name=\"spacing\">\n    <number>0</number>\n   </property>\n   <property name=\"sizeConstraint\">\n    <enum>QLayout::SetMaximumSize</enum>\n   </property>\n   <property name=\"leftMargin\">\n    <number>9</number>\n   </property>\n   <property name=\"topMargin\">\n    <number>9</number>\n   </property>\n   <property name=\"rightMargin\">\n    <number>9</number>\n   </property>\n   <property name=\"bottomMargin\">\n    <number>9</number>\n   </property>\n   <item>\n    <widget class=\"QTabWidget\" name=\"tabWidget\">\n     <property name=\"currentIndex\">\n      <number>0</number>\n     </property>\n     <widget class=\"QWidget\" name=\"tabGeneral\">\n      <attribute name=\"title\">\n       <string>General</string>\n      </attribute>\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_3\">\n       <item>\n        <widget class=\"QGroupBox\" name=\"gbProjectProperties\">\n         <property name=\"sizePolicy\">\n          <sizepolicy hsizetype=\"Expanding\" vsizetype=\"Expanding\">\n           <horstretch>0</horstretch>\n           <verstretch>0</verstretch>\n          </sizepolicy>\n         </property>\n         <property name=\"autoFillBackground\">\n          <bool>true</bool>\n         </property>\n         <property name=\"title\">\n          <string>Project Properties</string>\n         </property>\n         <property name=\"alignment\">\n          <set>Qt::AlignJustify|Qt::AlignVCenter</set>\n         </property>\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_2\">\n          <property name=\"sizeConstraint\">\n           <enum>QLayout::SetMaximumSize</enum>\n          </property>\n          <item>\n           <widget class=\"QGroupBox\" name=\"gbGeneral\">\n            <property name=\"title\">\n             <string>General</string>\n            </property>\n            <layout class=\"QFormLayout\" name=\"formLayout\">\n             <item row=\"0\" column=\"0\">\n              <widget class=\"QLabel\" name=\"lbProjectName\">\n               <property name=\"text\">\n                <string>Project Name:</string>\n               </property>\n              </widget>\n             </item>\n             <item row=\"0\" column=\"1\">\n              <widget class=\"QLineEdit\" name=\"leProjectName\"/>\n             </item>\n             <item row=\"1\" column=\"0\">\n              <widget class=\"QLabel\" name=\"lbProjectMainUrl\">\n               <property name=\"text\">\n                <string>Project Main Url:</string>\n               </property>\n              </widget>\n             </item>\n             <item row=\"1\" column=\"1\">\n              <widget class=\"QLineEdit\" name=\"leProjectMainUrl\"/>\n             </item>\n            </layout>\n           </widget>\n          </item>\n          <item>\n           <widget class=\"QGroupBox\" name=\"groupBox\">\n            <property name=\"title\">\n             <string>On Save</string>\n            </property>\n            <layout class=\"QFormLayout\" name=\"formLayout_3\">\n             <item row=\"0\" column=\"0\">\n              <widget class=\"QLabel\" name=\"lbIdentCharacter\">\n               <property name=\"toolTip\">\n                <string>Specifies the type of white space to use when identing the project xml file (on save).</string>\n               </property>\n               <property name=\"text\">\n                <string>Ident character:</string>\n               </property>\n              </widget>\n             </item>\n             <item row=\"0\" column=\"1\">\n              <widget class=\"QComboBox\" name=\"cbIdentCharacter\">\n               <property name=\"toolTip\">\n                <string>Specifies the type of white space to use when identing the project xml file (on save).</string>\n               </property>\n               <item>\n                <property name=\"text\">\n                 <string>Space</string>\n                </property>\n               </item>\n               <item>\n                <property name=\"text\">\n                 <string>Tab</string>\n                </property>\n               </item>\n              </widget>\n             </item>\n            </layout>\n           </widget>\n          </item>\n          <item>\n           <spacer name=\"verticalSpacer\">\n            <property name=\"orientation\">\n             <enum>Qt::Vertical</enum>\n            </property>\n            <property name=\"sizeHint\" stdset=\"0\">\n             <size>\n              <width>20</width>\n              <height>40</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n     <widget class=\"QWidget\" name=\"tabGlobalHeaders\">\n      <attribute name=\"title\">\n       <string>Global Headers</string>\n      </attribute>\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_5\">\n       <item>\n        <widget class=\"QLabel\" name=\"globalHeadersDescription\">\n         <property name=\"minimumSize\">\n          <size>\n           <width>0</width>\n           <height>20</height>\n          </size>\n         </property>\n         <property name=\"text\">\n          <string>Any header added here will be appended to all requests in this project. They will be shown in the request table as disabled rows. Their values can be overwritten if a header with the same key is added to the specific request headers.</string>\n         </property>\n         <property name=\"wordWrap\">\n          <bool>true</bool>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <layout class=\"QHBoxLayout\" name=\"horizontalLayout_8\">\n         <property name=\"sizeConstraint\">\n          <enum>QLayout::SetMaximumSize</enum>\n         </property>\n         <item>\n          <widget class=\"QTableWidget\" name=\"twGlobalHeaderKeyValue\">\n           <property name=\"sizePolicy\">\n            <sizepolicy hsizetype=\"Expanding\" vsizetype=\"Expanding\">\n             <horstretch>0</horstretch>\n             <verstretch>0</verstretch>\n            </sizepolicy>\n           </property>\n           <property name=\"alternatingRowColors\">\n            <bool>true</bool>\n           </property>\n           <attribute name=\"horizontalHeaderStretchLastSection\">\n            <bool>true</bool>\n           </attribute>\n           <column>\n            <property name=\"text\">\n             <string>Key</string>\n            </property>\n           </column>\n           <column>\n            <property name=\"text\">\n             <string>Value</string>\n            </property>\n           </column>\n          </widget>\n         </item>\n         <item>\n          <layout class=\"QVBoxLayout\" name=\"verticalLayout_7\">\n           <item>\n            <widget class=\"QToolButton\" name=\"tbGlobalHeaderKeyValueAdd\">\n             <property name=\"toolTip\">\n              <string>Add new row</string>\n             </property>\n             <property name=\"text\">\n              <string>...</string>\n             </property>\n             <property name=\"icon\">\n              <iconset resource=\"Resources/resources.qrc\">\n               <normaloff>:/icons/plus.png</normaloff>:/icons/plus.png</iconset>\n             </property>\n            </widget>\n           </item>\n           <item>\n            <widget class=\"QToolButton\" name=\"tbGlobalHeaderKeyValueRemove\">\n             <property name=\"toolTip\">\n              <string>Remove selected rows</string>\n             </property>\n             <property name=\"text\">\n              <string>...</string>\n             </property>\n             <property name=\"icon\">\n              <iconset resource=\"Resources/resources.qrc\">\n               <normaloff>:/icons/minus.png</normaloff>:/icons/minus.png</iconset>\n             </property>\n            </widget>\n           </item>\n          </layout>\n         </item>\n        </layout>\n       </item>\n      </layout>\n     </widget>\n     <widget class=\"QWidget\" name=\"tabAuthentication\">\n      <attribute name=\"title\">\n       <string>Authentication</string>\n      </attribute>\n      <layout class=\"QVBoxLayout\" name=\"verticalLayout_6\">\n       <item>\n        <widget class=\"QCheckBox\" name=\"cbUseAuthentication\">\n         <property name=\"text\">\n          <string>Use Authentication</string>\n         </property>\n        </widget>\n       </item>\n       <item>\n        <widget class=\"QGroupBox\" name=\"gbAuthentication\">\n         <property name=\"enabled\">\n          <bool>false</bool>\n         </property>\n         <property name=\"title\">\n          <string>Authentication</string>\n         </property>\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_4\">\n          <item>\n           <layout class=\"QFormLayout\" name=\"formLayout_2\">\n            <item row=\"0\" column=\"0\">\n             <widget class=\"QLabel\" name=\"lbSaveProjectAuthTo\">\n              <property name=\"text\">\n               <string>Save Project Authentication to:</string>\n              </property>\n             </widget>\n            </item>\n            <item row=\"0\" column=\"1\">\n             <layout class=\"QHBoxLayout\" name=\"horizontalLayout\">\n              <item>\n               <widget class=\"QRadioButton\" name=\"rbSaveProjectAuthToConfigurationFile\">\n                <property name=\"toolTip\">\n                 <string>Saves the authentication data to Frequest configuration file, even if you share the project file the authentication data is not shared</string>\n                </property>\n                <property name=\"text\">\n                 <string>FRequest Configuration File</string>\n                </property>\n                <property name=\"checked\">\n                 <bool>true</bool>\n                </property>\n               </widget>\n              </item>\n              <item>\n               <widget class=\"QRadioButton\" name=\"rbSaveProjectAuthToProjectFile\">\n                <property name=\"toolTip\">\n                 <string>Saves the authentication data to the Frequest project file, so if you share your project file the authentication data is also shared</string>\n                </property>\n                <property name=\"text\">\n                 <string>FRequest Project File</string>\n                </property>\n               </widget>\n              </item>\n             </layout>\n            </item>\n            <item row=\"1\" column=\"0\">\n             <widget class=\"QLabel\" name=\"lbAuthType\">\n              <property name=\"text\">\n               <string>Authentication Type:</string>\n              </property>\n             </widget>\n            </item>\n            <item row=\"1\" column=\"1\">\n             <widget class=\"QComboBox\" name=\"cbRequestType\">\n              <item>\n               <property name=\"text\">\n                <string>Request Authentication</string>\n               </property>\n              </item>\n              <item>\n               <property name=\"text\">\n                <string>Basic Authentication</string>\n               </property>\n              </item>\n             </widget>\n            </item>\n            <item row=\"2\" column=\"0\">\n             <widget class=\"QLabel\" name=\"lbRequestForAuthentication\">\n              <property name=\"text\">\n               <string>Request for Authentication:</string>\n              </property>\n             </widget>\n            </item>\n            <item row=\"2\" column=\"1\">\n             <widget class=\"QComboBox\" name=\"cbRequestForAuthentication\"/>\n            </item>\n            <item row=\"3\" column=\"0\">\n             <widget class=\"QLabel\" name=\"lbUsername\">\n              <property name=\"text\">\n               <string>Username:</string>\n              </property>\n             </widget>\n            </item>\n            <item row=\"3\" column=\"1\">\n             <widget class=\"QLineEdit\" name=\"leUsername\"/>\n            </item>\n            <item row=\"4\" column=\"0\">\n             <widget class=\"QLabel\" name=\"lbPassword\">\n              <property name=\"text\">\n               <string>Password:</string>\n              </property>\n             </widget>\n            </item>\n            <item row=\"4\" column=\"1\">\n             <widget class=\"QLineEdit\" name=\"lePassword\">\n              <property name=\"text\">\n               <string/>\n              </property>\n              <property name=\"echoMode\">\n               <enum>QLineEdit::Password</enum>\n              </property>\n             </widget>\n            </item>\n            <item row=\"5\" column=\"0\" colspan=\"2\">\n             <widget class=\"QCheckBox\" name=\"cbRetryLoginIfError401\">\n              <property name=\"text\">\n               <string>Retry login if the HTTP error 401 (Unauthorized) is received on a request</string>\n              </property>\n              <property name=\"checked\">\n               <bool>true</bool>\n              </property>\n             </widget>\n            </item>\n           </layout>\n          </item>\n          <item>\n           <widget class=\"QScrollArea\" name=\"saProjectPropertiesNote\">\n            <property name=\"widgetResizable\">\n             <bool>true</bool>\n            </property>\n            <widget class=\"QWidget\" name=\"scrollAreaWidgetContents_2\">\n             <property name=\"geometry\">\n              <rect>\n               <x>0</x>\n               <y>0</y>\n               <width>623</width>\n               <height>175</height>\n              </rect>\n             </property>\n             <layout class=\"QVBoxLayout\" name=\"verticalLayout_8\">\n              <item>\n               <widget class=\"QLabel\" name=\"lbProjectPropertiesNote\">\n                <property name=\"text\">\n                 <string>Note:</string>\n                </property>\n                <property name=\"wordWrap\">\n                 <bool>true</bool>\n                </property>\n                <property name=\"textInteractionFlags\">\n                 <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>\n                </property>\n               </widget>\n              </item>\n             </layout>\n            </widget>\n           </widget>\n          </item>\n          <item>\n           <spacer name=\"verticalSpacer_2\">\n            <property name=\"orientation\">\n             <enum>Qt::Vertical</enum>\n            </property>\n            <property name=\"sizeHint\" stdset=\"0\">\n             <size>\n              <width>20</width>\n              <height>40</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </widget>\n       </item>\n      </layout>\n     </widget>\n    </widget>\n   </item>\n   <item>\n    <widget class=\"QDialogButtonBox\" name=\"buttonBox\">\n     <property name=\"orientation\">\n      <enum>Qt::Horizontal</enum>\n     </property>\n     <property name=\"standardButtons\">\n      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n     </property>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <resources>\n  <include location=\"Resources/resources.qrc\"/>\n </resources>\n <connections>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>ProjectProperties</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>ProjectProperties</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n"
  },
  {
    "path": "proxysetup.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"proxysetup.h\"\n\nvoid ProxySetup::setupProxyForNetworkManager(const ConfigFileFRequest::Settings &settings, QNetworkAccessManager * const networkAccessManager){\n\tQNetworkProxy proxy;\n\n\tif(settings.useProxy){\n\t\tswitch (settings.proxySettings.type) {\n\t\tcase ConfigFileFRequest::ProxyType::AUTOMATIC:\n\t\t{\n\t\t\tQNetworkProxyFactory::setUseSystemConfiguration(true);\n\t\t\tbreak;\n\t\t}\n\t\tcase ConfigFileFRequest::ProxyType::HTTP_TRANSPARENT:\n\t\t{\n\t\t\tproxy.setType(QNetworkProxy::HttpProxy);\n\t\t\tbreak;\n\t\t}\n\t\tcase ConfigFileFRequest::ProxyType::HTTP:\n\t\t{\n\t\t\tproxy.setType(QNetworkProxy::HttpCachingProxy);\n\t\t\tbreak;\n\t\t}\n\t\tcase ConfigFileFRequest::ProxyType::SOCKS5:\n\t\t{\n\t\t\tproxy.setType(QNetworkProxy::Socks5Proxy);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tQString errorMessage = \"Unknown proxy type set! '\" + QString::number(static_cast<unsigned int>(settings.proxySettings.type)) + \"'. Check the proxy settings.\";\n\t\t\tUtil::Dialogs::showError(errorMessage);\n\t\t\tLOG_ERROR << errorMessage;\n\t\t\treturn;\n\t\t}\n\t\t}\n\n\t\tif(settings.proxySettings.type != ConfigFileFRequest::ProxyType::AUTOMATIC){\n\t\t\tQNetworkProxyFactory::setUseSystemConfiguration(false);\n\t\t\tproxy.setHostName(settings.proxySettings.hostName);\n\t\t\tproxy.setPort(settings.proxySettings.portNumber);\n\t\t}\n\t}\n\telse{\n\t\tproxy.setType(QNetworkProxy::NoProxy);\n\t}\n\t\n\tnetworkAccessManager->setProxy(proxy);\n}"
  },
  {
    "path": "proxysetup.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef PROXYSETUP_H\n#define PROXYSETUP_H\n\n#include <QNetworkProxyFactory>\n#include <QNetworkAccessManager>\n#include \"XmlParsers/configfilefrequest.h\"\n\nclass ProxySetup \n{\npublic:\n\tstatic void setupProxyForNetworkManager(const ConfigFileFRequest::Settings &settings, QNetworkAccessManager * const networkAccessManager);\n};\n\n#endif // PROXYSETUP_H\n"
  },
  {
    "path": "readme.txt",
    "content": "readme.txt\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nFRequest v1.2a\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n----------------------------------\nDescription:\n----------------------------------\n\nFRequest is a fast, lightweight and opensource Windows / macOS / Linux desktop program to make HTTP(s) requests (e.g. call REST apis). \n\nThe main motivation for the program is to create a similar working software to an IDE but for HTTP(s) apis. It should be fast, \ncross platform, lightweight, practical with a native look. Also it is important that project files can be \neasily shared and work seamless with Version Control System (VCS) for collaborative work.\n\nThe current features of FRequest are:\n\n- Make GET / POST / PUT / DELETE / PATCH / HEAD / TRACE / OPTIONS HTTP(s) requests\n- Make HTTP requests with RAW / Form Data or X-Form-WWW-UrlEncoded body types\n- Send file uploads over the HTTP body type Form Data\n- Analyze the requests response body and headers\n- Requests are contained in a project, this project is then saved in XML file on user's desired location\n- Ability to override a project main url, so you can make requests to different domain name addresses within the same project\n- Ability to download files from the requests\n- Automatically beautify and apply syntax highlighting for JSON and XML\n- Support for authentication (HTTP Basic authentication and Request based authentication) which can be saved either in the\nprogram configuration file (for private use) or the project file itself (for shared use)\n- The FRequest project files are stored in a way which allow easy collaboration via a VCS like Git, Svn or Team Foundation Server\n- Ability to add any kind of custom HTTP headers to the requests (automatically by taking the type in account or adding them \nmanually)\n- Global headers, headers that are applied to every request in the project\n- Network proxy support\n\nFRequest is licensed under GPL 3.0 (https://www.gnu.org/licenses/gpl-3.0.en.html).\n\n----------------------------------\nSupported operating system:\n----------------------------------\n\n- Windows 7 SP1 and above\n- macOS High Sierra (10.13) and above\n- Ubuntu 18.04 and above (other Linux distributions dated similar should likely work but are not tested)\n\n----------------------------------\nInstallation:\n----------------------------------\n\nWindows / macOS:\nJust extract the inner FRequest folder to any place in your computer. Run the executable.\n\nLinux:\nExtract the inner FRequest folder to any place in your computer, make it executable (chmod +x) and run the executable.\n\nYou may need to install openssl 1.1.1 to get the ssl requests to work properly\n(and also to check for updates within the program).\n\nIn ubuntu (18.04) you can do it like this:\nsudo apt-get install openssl\n\n----------------------------------\nUpgrading:\n----------------------------------\n\nWindows / macOS:\nYou should make a backup of your previous installation folder, just in case. After this\nbackup, extract the files from this zip version to your previous FRequest installation\nfolder (replace all files).\n\nLinux:\nYou should make a backup of your previous installation folder, just in case. After this\nbackup, just replace the previous AppImage with the new one.\n\n----------------------------------\nContacts:\n----------------------------------\n\nAuthor:\nfabiobento512 (https://github.com/fabiobento512)\n\nOfficial page:\nhttps://fabiobento512.github.io/FRequest/\n\nGitHub code page:\nhttps://github.com/fabiobento512/FRequest\n\n----------------------------------\nChange Log:\n----------------------------------\n1.2a, 13-03-2022\n- Upgraded Qt version on all platforms to 15.5.2, this fixes the openssl issue for linux users\n(the problem that 1.0.1 is not the repositories anymore) and provides support for TLS 1.3\n- Added github actions builds, which simplifies the building on the three supported operating systems a lot\n- Minor code refactoring\n----------------------------------\n1.2, 18-05-2021\n- Added global headers feature (thanks alevalv)\n- Now request/reponse area is scrollabled (thanks fcolecumberri)\n- Now request/reponse text uses courier new font (monospace) (thanks KaKi87 for the monospace suggestion)\n----------------------------------\n1.1c, 20-01-2019\n- Added official support for Linux (tests are made in Ubuntu LTS and the program is distributed using an appimage)\n- Fixed not showing body/headers response when an HTTP status code error is received like (500) (issue #7)\n- Fixed timeout status code/message, when the internal FRequest timeout for a request is reached (issue #8)\n- Added option in project settings to specify the type of character identation to use (space or tab) in the \nproject xml file (issue #9)\n----------------------------------\n1.1b, 04-03-2018\n- Added dark theme (thanks Jorgen-VikingGod!)\n- Added a clear button for the filter text box\n- Fixed possible system implementation of passwords obfuscation (you may need to re-enter your project passwords)\n- Some code refactoring (using now override C++ keyword for instance)\n----------------------------------\n1.1a, 03-02-2018\n- Added rename request / project to requests tree context menu (thanks pingzing!)\n- Added shortcut to delete requests (DEL)\n- Added an icon to delete request context menu\n- Improved config/project files upgrade code\n- Now it is possible to set the maximum response data size for display\n- Fixed bug: on a new project, after saving the project properties \nthe body data of the selected request may be cleared\n- Now macOS users are warned about \"App Translocation\" when the application\ncan't create its .config file\n- Added check for updates option in help menu\n----------------------------------\n1.1, 28-01-2018\n- Morphed the QTextEdits to QPlainTextEdits in order to increase render performance for requests and responses data\n- Now when the data is bigger than 200 kb only the first 200 kb are displayed in the interface, the remaining data is \nwritten to the disk if the request is marked to download (avoids slowdowns and possible crashes)\n- Fixed bug where if the first request being loaded had overridden url the url didn't loaded\n- Fixed bug where timeout 0 instead of mean no timeout, meant instant timeout\n- Fixed bug where the first item loaded, if changed and then the project was saved, it wouldn't get properly saved\n- Fixed bug where form-data were sending data in the format of x-www-form-urlencoded instead of form-data\n- Now it is possible to cancel a running request\n- Added icons for request types\n- Some code refactoring\n- Added icon to clone context menu\n- Now when the project is selected in the requests tree the number of the requests for that project is displayed in \nthe status bar\n- Added support for file uploads\n- Upgraded to Qt 5.10.0\n- Now TRACE method should allow send of form and raw content\n- Added support for XML highlighting\n- Now cookies received by each request are saved by default (so they may be sent in next requests)\n- Added requests filter so you can quickly find your requests\n- Added authentication support (starting with Request authentication and HTTP Basic Authentication)\n- Fixed the save of proxy settings\n- Hide toolbar since it is unused\n----------------------------------\n1.0, 18-08-2017\n- Initial Version"
  },
  {
    "path": "updatechecker.cpp",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#include \"updatechecker.h\"\n\nUpdateChecker::UpdateChecker(const ConfigFileFRequest::Settings &settings)\n    :settings(settings)\n{\n    this->networkRequest.setUrl(QUrl(this->updateCheckApiUrl));\n}\n\nvoid UpdateChecker::startNewInstance(const ConfigFileFRequest::Settings &settings){\n    UpdateChecker *newInstance = new UpdateChecker(settings);\n    newInstance->checkForUpdates(); // this deletes itself once finished\n}\n\nvoid UpdateChecker::checkForUpdates(){\n    // Apply proxy type\n    ProxySetup::setupProxyForNetworkManager(this->settings, &this->networkAccessManager);\n\n    connect(&this->networkAccessManager, &QNetworkAccessManager::finished, this, &UpdateChecker::replyFinished);\n\n    // do the request and also check for timeout\n    checkForQNetworkAccessManagerTimeout(this->networkAccessManager.get(this->networkRequest));\n\n    this->deleteLater(); // delete when signal / slots are finished\n}\n\nvoid UpdateChecker::replyFinished(QNetworkReply *reply){\n\n    try{\n        if(!this->replyHasFinished){\n            if (reply->error()) {\n                throw std::runtime_error(QSTR_TO_TEMPORARY_CSTR(reply->errorString()));\n            }\n\n            QString answer = reply->readAll();\n\n            QJsonDocument doc = QJsonDocument::fromJson(answer.toUtf8());\n\n            if(!doc.isObject()){\n                throw std::runtime_error(\"(http api error) json is not an object.\");\n            }\n\n            QJsonObject jsonObj = doc.object();\n\n            QJsonValue jsonProgramLastVersion = jsonObj.value(\"tag_name\");\n\n            if(jsonProgramLastVersion.isUndefined()){\n                throw std::runtime_error(\"(http api error) json tag_name doesn't exist.\");\n            }\n\n            QString newVersion = jsonProgramLastVersion.toString();\n\n            // remove v (from v1.0 for example) if it exists\n            if(newVersion.startsWith(\"v\")){\n                newVersion.remove(0,1); // remove first character\n            }\n\n            if(newVersion != GlobalVars::AppVersion){\n                Util::Dialogs::showInfo\n                        (\n                            \"There's a new version of \" + GlobalVars::AppName + \"! (v\" + newVersion + \")<br/><br/>\"+\n                            \"You can download it <a href='\" + this->releasesUrl + \"'>here</a>.\", true\n                            );\n            }\n            else{\n                Util::Dialogs::showInfo(\"You are using last version.\");\n            }\n        }\n    }\n    catch(const std::exception& e){\n        QString errorMessage = \"An error ocurred while checking for updates: \" + QString(e.what());\n        LOG_ERROR << errorMessage;\n        Util::Dialogs::showError(errorMessage);\n    }\n\n    this->replyHasFinished = true;\n}\n\n// Since QNetworkReply doesn't have a way to set a timeout we need implement it by ourselves\n// http://stackoverflow.com/a/13229926\nvoid UpdateChecker::checkForQNetworkAccessManagerTimeout(QNetworkReply *reply)\n{\n    QTimer timer;\n    timer.setSingleShot(true);\n\n    QEventLoop loop;\n    connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));\n    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));\n\n    timer.start(10 * 1000); // 10 seconds hardcoded timeout\n    loop.exec();\n\n    if(timer.isActive()) // request didn't timeout\n    {\n        timer.stop();\n    }\n    else if(!this->replyHasFinished)\n    {\n        // timeout\n\n        // TODO this class is a bit confusing,\n        // especially when we are using a boolean to check if the reply has already finished\n        // (we are doing that because if user doesn't close success dialog, a second call is emitted to replyFinished function\n        // after 10 secs (timeout)\n        // If possible this should be refactored to a simpler method\n        this->replyHasFinished = true;\n\n        disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));\n\n        reply->abort();\n\n        QString errorMessage = \"Timeout while checking for updates.<br/><br/>You still can check manually, by clicking <a href='\" + this->releasesUrl + \"'>here</a>.\";\n        Util::Dialogs::showError(errorMessage, true);\n        LOG_ERROR << errorMessage;\n    }\n\n    reply->deleteLater();\n\n}\n"
  },
  {
    "path": "updatechecker.h",
    "content": "/*\n *\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n*\n*/\n\n#ifndef UPDATECHECKER_H\n#define UPDATECHECKER_H\n\n#include <QJsonDocument>\n#include <QJsonObject>\n#include <QNetworkReply>\n#include <QTimer>\n\n#include <util.h>\n\n#include \"utilglobalvars.h\"\n#include \"proxysetup.h\"\n\nclass UpdateChecker: public QObject /* inheritance needed for signal / slots */\n{\n\tQ_OBJECT /* Q_OBJECT needed for signal / slots */\npublic:\n\tstatic void startNewInstance(const ConfigFileFRequest::Settings &settings);\nprivate:\n\t// not meant to be instantiated directly, use startNewInstance instead\n\tUpdateChecker(const ConfigFileFRequest::Settings &settings);\nprivate:\n\tvoid checkForUpdates();\n\tvoid replyFinished(QNetworkReply *reply);\n\tvoid checkForQNetworkAccessManagerTimeout(QNetworkReply *reply);\nprivate:\n\tQNetworkAccessManager networkAccessManager;\n\tQNetworkRequest networkRequest;\n\tconst ConfigFileFRequest::Settings settings;\n\tconst QString updateCheckApiUrl = \"https://api.github.com/repos/fabiobento512/FRequest/releases/latest\";\n\tconst QString releasesUrl = \"https://github.com/fabiobento512/FRequest/releases\";\n    bool replyHasFinished = false;\n};\n\n#endif // UPDATECHECKER_H\n"
  },
  {
    "path": "utilfrequest.cpp",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#include \"utilfrequest.h\"\r\n\r\nnamespace UtilFRequest{\r\n\r\nQString getDocumentsFolder(){\r\n\r\n    QString result = Util::FileSystem::normalizePath(QStandardPaths::locate(QStandardPaths::DocumentsLocation, QString(), QStandardPaths::LocateDirectory));\r\n\r\n    if(result.endsWith(\"/\")){\r\n        result = result.remove(result.size()-1,1);\r\n    }\r\n\r\n    return result;\r\n}\r\n\r\n\r\nRequestType getRequestTypeByString(const QString &currentRequestText){\r\n\r\n    if(currentRequestText == \"GET\"){\r\n        return RequestType::GET_OPTION;\r\n    }\r\n    else if(currentRequestText == \"POST\"){\r\n        return RequestType::POST_OPTION;\r\n    }\r\n    else if(currentRequestText == \"PUT\"){\r\n        return RequestType::PUT_OPTION;\r\n    }\r\n    else if(currentRequestText == \"DELETE\"){\r\n        return RequestType::DELETE_OPTION;\r\n    }\r\n    else if(currentRequestText == \"PATCH\"){\r\n        return RequestType::PATCH_OPTION;\r\n    }\r\n    else if(currentRequestText == \"HEAD\"){\r\n        return RequestType::HEAD_OPTION;\r\n    }\r\n    else if(currentRequestText == \"TRACE\"){\r\n        return RequestType::TRACE_OPTION;\r\n    }\r\n    else if(currentRequestText == \"OPTIONS\"){\r\n        return RequestType::OPTIONS_OPTION;\r\n    }\r\n    else{\r\n        QString errorMessage = \"Request type unknown: '\" + currentRequestText + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n}\r\n\r\nQString getRequestTypeString(const RequestType currentRequestType){\r\n\r\n    switch(currentRequestType){\r\n    case UtilFRequest::RequestType::GET_OPTION:\r\n        return \"GET\";\r\n    case UtilFRequest::RequestType::POST_OPTION:\r\n        return \"POST\";\r\n    case UtilFRequest::RequestType::PUT_OPTION:\r\n        return \"PUT\";\r\n    case UtilFRequest::RequestType::DELETE_OPTION:\r\n        return \"DELETE\";\r\n    case UtilFRequest::RequestType::PATCH_OPTION:\r\n        return \"PATCH\";\r\n    case UtilFRequest::RequestType::HEAD_OPTION:\r\n        return \"HEAD\";\r\n    case UtilFRequest::RequestType::TRACE_OPTION:\r\n        return \"TRACE\";\r\n    case UtilFRequest::RequestType::OPTIONS_OPTION:\r\n        return \"OPTIONS\";\r\n    default:\r\n    {\r\n        QString errorMessage = \"Invalid request type \" + QString::number(static_cast<int>(currentRequestType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n}\r\n\r\n\r\nbool requestTypeMayHaveBody(RequestType currentRequestType){\r\n\r\n    bool mayHaveBody = false;\r\n\r\n    switch(currentRequestType){\r\n    case UtilFRequest::RequestType::GET_OPTION:\r\n    case UtilFRequest::RequestType::DELETE_OPTION:\r\n    case UtilFRequest::RequestType::HEAD_OPTION:\r\n    {\r\n        mayHaveBody = false;\r\n        break;\r\n    }\r\n    case UtilFRequest::RequestType::POST_OPTION:\r\n    case UtilFRequest::RequestType::PUT_OPTION:\r\n    case UtilFRequest::RequestType::PATCH_OPTION:\r\n    case UtilFRequest::RequestType::OPTIONS_OPTION:\r\n    case UtilFRequest::RequestType::TRACE_OPTION:\r\n    {\r\n        mayHaveBody = true;\r\n        break;\r\n    }\r\n    default:\r\n    {\r\n        QString errorMessage = \"Request type unknown: '\" + QString::number(static_cast<int>(currentRequestType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n\r\n    return mayHaveBody;\r\n}\r\n\r\nQString getDateTimeFormatForFilename(const QDateTime &currentDateTime){\r\n    return currentDateTime.toString(\"yyyy-MM-dd_hh-mm-ss\");\r\n}\r\n\r\nFormKeyValueType getFormKeyTypeByString(const QString &currentFormKeyValueString){\r\n\r\n    if(currentFormKeyValueString == \"Text\"){\r\n        return FormKeyValueType::TEXT;\r\n    }\r\n    else if(currentFormKeyValueString == \"File\"){\r\n        return FormKeyValueType::FILE;\r\n    }\r\n    else{\r\n        QString errorMessage = \"FormKeyValue type unknown: '\" + currentFormKeyValueString + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n}\r\n\r\nQString getFormKeyTypeString(const FormKeyValueType currentFormKeyValueType){\r\n\r\n    switch(currentFormKeyValueType){\r\n    case UtilFRequest::FormKeyValueType::TEXT:\r\n        return \"Text\";\r\n    case UtilFRequest::FormKeyValueType::FILE:\r\n        return \"File\";\r\n    default:\r\n    {\r\n        QString errorMessage = \"Invalid form key type \" + QString::number(static_cast<int>(currentFormKeyValueType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n}\r\n\r\nBodyType getBodyTypeByString(const QString &currentBodyTypeText){\r\n    if(currentBodyTypeText == \"raw\"){\r\n        return BodyType::RAW;\r\n    }\r\n    else if(currentBodyTypeText == \"form-data\"){\r\n        return BodyType::FORM_DATA;\r\n    }\r\n    else if(currentBodyTypeText == \"x-form-www-urlencoded\"){\r\n        return BodyType::X_FORM_WWW_URLENCODED;\r\n    }\r\n    else{\r\n        QString errorMessage = \"BodyType type unknown: '\" + currentBodyTypeText + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n}\r\n\r\nQString getBodyTypeString(const BodyType currentBodyType){\r\n    switch(currentBodyType){\r\n    case UtilFRequest::BodyType::RAW:\r\n    {\r\n        return \"raw\";\r\n    }\r\n    case UtilFRequest::BodyType::FORM_DATA:\r\n    {\r\n        return \"form-data\";\r\n    }\r\n    case UtilFRequest::BodyType::X_FORM_WWW_URLENCODED:\r\n    {\r\n        return \"x-form-www-urlencoded\";\r\n    }\r\n    default:\r\n    {\r\n        QString errorMessage = \"Invalid body type \" + QString::number(static_cast<int>(currentBodyType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n}\r\n\r\nIdentCharacter getIdentCharacterByString(const QString &currentIdentCharacterText){\r\n\r\n    if(currentIdentCharacterText == \"Space\"){\r\n        return IdentCharacter::SPACE;\r\n    }\r\n    else if(currentIdentCharacterText == \"Tab\"){\r\n        return IdentCharacter::TAB;\r\n    }\r\n    else{\r\n        QString errorMessage = \"Ident character unknown: '\" + currentIdentCharacterText + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n}\r\n\r\nQString getIdentCharacterString(const IdentCharacter currentIdentCharacter){\r\n    switch(currentIdentCharacter){\r\n    case IdentCharacter::SPACE:\r\n        return \"Space\";\r\n    case IdentCharacter::TAB:\r\n        return \"Tab\";\r\n    default:\r\n    {\r\n        QString errorMessage = \"Invalid ident character \" + QString::number(static_cast<int>(currentIdentCharacter)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n}\r\n\r\n\r\nvoid addRequestFormBodyRow(QTableWidget * const myTable, const QString &key, const QString &value, const UtilFRequest::FormKeyValueType type){\r\n    Util::TableWidget::addRow(myTable, QStringList() << key << value << UtilFRequest::getFormKeyTypeString(type));\r\n\r\n    // Set type as not editable\r\n    int tableSize = myTable->rowCount();\r\n    QTableWidgetItem* const addedRowTypeItem = myTable->item(tableSize-1, 2);\r\n    addedRowTypeItem->setFlags(addedRowTypeItem->flags() & (~Qt::ItemIsEditable));\r\n\r\n    // If it is a file, change the row color to blue in order to differentiate\r\n    if(type == UtilFRequest::FormKeyValueType::FILE){\r\n        myTable->item(tableSize-1, 0)->setForeground(Qt::blue);\r\n        myTable->item(tableSize-1, 1)->setForeground(Qt::blue);\r\n        addedRowTypeItem->setForeground(Qt::blue);\r\n    }\r\n}\r\n\r\n// Return original content in case of error\r\nQString getStringFormattedForSerializationType(const QString &content, const SerializationFormatType serializationType){\r\n    switch(serializationType){\r\n    case UtilFRequest::SerializationFormatType::JSON:\r\n    {\r\n        QJsonParseError parseError;\r\n\r\n        QJsonDocument auxJsonDoc = QJsonDocument::fromJson(content.toUtf8(), &parseError);\r\n\r\n        if(parseError.error != QJsonParseError::NoError){\r\n            QString errorMessage = \"An error occurred while formatting the content as Json: \" + content.left(10);\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_ERROR << errorMessage;\r\n            return content;\r\n        }\r\n\r\n        return auxJsonDoc.toJson();\r\n    }\r\n    case UtilFRequest::SerializationFormatType::XML:\r\n    {\r\n        pugi::xml_document doc;\r\n        pugi::xml_parse_result result = doc.load_string(QSTR_TO_TEMPORARY_CSTR(content));\r\n\r\n        if(result.status != pugi::xml_parse_status::status_ok){\r\n            QString errorMessage = \"An error occurred while formatting the content as XML: \" + content.left(10);\r\n            Util::Dialogs::showError(errorMessage);\r\n            LOG_ERROR << errorMessage;\r\n            return content;\r\n        }\r\n\r\n        std::stringstream xmlFormattedText;\r\n        doc.save(xmlFormattedText);\r\n\r\n        return QString::fromStdString(xmlFormattedText.str());\r\n    }\r\n    case UtilFRequest::SerializationFormatType::UNKNOWN:\r\n    {\r\n        return content;\r\n    }\r\n    default:\r\n    {\r\n        QString errorMessage = \"Invalid currRequestFormatType \" + QString::number(static_cast<int>(serializationType)) + \"'. Program can't proceed.\";\r\n        Util::Dialogs::showError(errorMessage);\r\n        LOG_FATAL << errorMessage;\r\n        exit(1);\r\n    }\r\n    }\r\n}\r\n\r\nSerializationFormatType getSerializationFormatTypeForString(const QString &content){\r\n    // Try to parse the response as json, if it fails try xml, otherwise return unknown\r\n    QJsonParseError parseError;\r\n\r\n    QJsonDocument auxJsonDoc = QJsonDocument::fromJson(content.toUtf8(), &parseError);\r\n\r\n    if(parseError.error == QJsonParseError::NoError){\r\n        return UtilFRequest::SerializationFormatType::JSON;\r\n    }\r\n\r\n    pugi::xml_document doc;\r\n    pugi::xml_parse_result result = doc.load_string(QSTR_TO_TEMPORARY_CSTR(content));\r\n\r\n    if(result.status == pugi::xml_parse_status::status_ok){\r\n        return UtilFRequest::SerializationFormatType::XML;\r\n    }\r\n\r\n    return\tUtilFRequest::SerializationFormatType::UNKNOWN;\r\n}\r\n\r\nQByteArray simpleStringObfuscationDeobfuscation(const QString& ofuscationSalt, const QString &input){\r\n\r\n    QByteArray saltByteArray = ofuscationSalt.toUtf8();\r\n    QByteArray inputByteArray = input.toUtf8();\r\n\r\n    // Using unsigned types as they have a defined truncation in iso c++:\r\n    // https://stackoverflow.com/a/34886065\r\n    // (so the static_cast<unsigned char> below works the same in all different systems)\r\n    uint32_t saltByteArraySize = static_cast<uint32_t>(saltByteArray.size());\r\n    uint32_t inputByteArraySize = static_cast<uint32_t>(inputByteArray.size());\r\n\r\n    for(uint32_t i=0; i< inputByteArraySize; i++){\r\n        inputByteArray[i] = inputByteArray[i] ^ (i < saltByteArraySize ? saltByteArray[i] : static_cast<unsigned char>(i));\r\n    }\r\n\r\n    return inputByteArray;\r\n}\r\n\r\nQString replaceFRequestAuthenticationPlaceholders(const QString &textToReplace, const QString &username, const QString &password){\r\n    return QString(textToReplace).\r\n            replace(GlobalVars::FRequestAuthenticationPlaceholderUsername, username).\r\n            replace(GlobalVars::FRequestAuthenticationPlaceholderPassword, password);\r\n}\r\n\r\nvoid setGlobalHeaderTableWidgetRow(QTableWidget *myTable, const int rowNumber){\r\n\r\n    for(int i=0; i<myTable->columnCount(); i++){\r\n        QTableWidgetItem * const currentItem = myTable->item(rowNumber, i);\r\n\r\n        currentItem->setFlags(currentItem->flags() & ~Qt::ItemIsEditable);\r\n\r\n        currentItem->setBackground(getTableWidgetRowDisabledBackStyle());\r\n        currentItem->setForeground(getTableWidgetRowDisabledTextStyle());\r\n\r\n        // Add tooltip to make clear that it is a global header\r\n        currentItem->setToolTip(\"[global header] \" + currentItem->toolTip());\r\n    }\r\n\r\n}\r\n\r\n//Reset a item to its initial style\r\nvoid resetGlobalTableWidgetRow(QTableWidget *myTable, const int rowNumber){\r\n\r\n    for(int i=0; i<myTable->columnCount(); i++){\r\n\r\n        QTableWidgetItem * const currentItem = myTable->item(rowNumber, i);\r\n\r\n        currentItem->setFlags(currentItem->flags() & Qt::ItemIsEditable);\r\n\r\n        if((currentItem->row()+1)%2==0){ //if the row number is par it use the alternate color scheme\r\n            currentItem->setBackground(QPalette().brush(QPalette::Normal,QPalette::AlternateBase));\r\n        }\r\n        else{\r\n            currentItem->setBackground(QPalette().brush(QPalette::Normal,QPalette::Base));\r\n        }\r\n\r\n        currentItem->setForeground(QPalette().brush(QPalette::Normal,QPalette::WindowText));\r\n\r\n    }\r\n\r\n}\r\n\r\nbool isGlobalHeaderTableWidgetRow(QTableWidget *myTable, const int rowNumber){\r\n\r\n    if(myTable->columnCount() <= 0){\r\n        return true;\r\n    }\r\n\r\n    const QTableWidgetItem * const currItem = myTable->item(rowNumber, 0);\r\n\r\n    return currItem->background() == getTableWidgetRowDisabledBackStyle() &&\r\n            currItem->foreground() == getTableWidgetRowDisabledTextStyle();\r\n}\r\n\r\nQBrush getTableWidgetRowDisabledBackStyle(){\r\n    return QTableWidget().palette().brush(QPalette::Disabled,QPalette::Base);\r\n}\r\n\r\nQBrush getTableWidgetRowDisabledTextStyle(){\r\n    return QTableWidget().palette().brush(QPalette::Disabled,QPalette::WindowText);\r\n}\r\n\r\n}\r\n"
  },
  {
    "path": "utilfrequest.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef UTILFREQUEST_H\r\n#define UTILFREQUEST_H\r\n\r\n#include \"util.h\"\r\n\r\n// PLog library (log library)\r\n// https://github.com/SergiusTheBest/plog\r\n#include <plog/Log.h>\r\n#include <plog/Converters/NativeEOLConverter.h>\r\n#include <pugixml/pugixml.hpp>\r\n#include <cpp17optional/optional.hpp>\r\n#include <cstdint>\r\n\r\n#include <QComboBox>\r\n#include <QDateTime>\r\n#include <QMimeDatabase>\r\n#include <QJsonDocument>\r\n\r\n#include \"Authentications/frequestauthentication.h\"\r\n#include \"utilglobalvars.h\"\r\n\r\nnamespace UtilFRequest{\r\n\r\nstruct HttpHeader{\r\n    QString name;\r\n    QString value;\r\n};\r\n\r\n// Update the vector bellow always that you update this enum\r\nenum class RequestType{\r\n    GET_OPTION = 0,\r\n    POST_OPTION = 1,\r\n    PUT_OPTION = 2,\r\n    DELETE_OPTION = 3,\r\n    PATCH_OPTION = 4,\r\n    HEAD_OPTION = 5,\r\n    TRACE_OPTION = 6,\r\n    OPTIONS_OPTION = 7\r\n};\r\n\r\nconst QVector<RequestType> possibleRequestTypes = {\r\n    UtilFRequest::RequestType::GET_OPTION,\r\n    UtilFRequest::RequestType::POST_OPTION,\r\n    UtilFRequest::RequestType::PUT_OPTION,\r\n    UtilFRequest::RequestType::DELETE_OPTION,\r\n    UtilFRequest::RequestType::PATCH_OPTION,\r\n    UtilFRequest::RequestType::HEAD_OPTION,\r\n    UtilFRequest::RequestType::TRACE_OPTION,\r\n    UtilFRequest::RequestType::OPTIONS_OPTION\r\n};\r\n\r\nenum class BodyType{\r\n    RAW = 0,\r\n    FORM_DATA = 1,\r\n    X_FORM_WWW_URLENCODED = 2\r\n};\r\n\r\nenum class FormKeyValueType{\r\n    TEXT = 0,\r\n    FILE = 1\r\n};\r\n\r\nenum class SerializationFormatType{\r\n\tUNKNOWN = 0,\r\n\tJSON = 1,\r\n\tXML = 2\r\n};\r\n\r\nenum class IdentCharacter{\r\n    SPACE = 0,\r\n    TAB = 1\r\n};\r\n\r\nstruct HttpFormKeyValueType{\r\n\t\r\n\tQString key;\r\n    QString value;\r\n\tFormKeyValueType type;\r\n\t\r\n\tHttpFormKeyValueType(){}\r\n\t\r\n\tHttpFormKeyValueType(const QString &key, const QString &value, const FormKeyValueType type){\r\n\t\tthis->key = key;\r\n\t\tthis->value = value;\r\n\t\tthis->type = type;\r\n\t}\r\n\t\r\n};\r\n\r\nstruct RequestInfo{\r\n\tbool bOverridesMainUrl = false;\r\n\tQString overrideMainUrl;\r\n\tQString name;\r\n\tQString path;\r\n\tRequestType requestType = RequestType::GET_OPTION;\r\n\tBodyType bodyType = BodyType::RAW;\r\n\tQString body;\r\n\tQVector<HttpFormKeyValueType> bodyForm;\r\n\tQVector<HttpHeader> headers;\r\n\tbool bDownloadResponseAsFile = false;\r\n\tQString uuid;\r\n\tunsigned long long int order = 0;\r\n    bool bDisableGlobalHeaders = true;\r\n};\r\n\r\nstatic QMimeDatabase mimeDatabase;\r\n\r\nQString getDocumentsFolder();\r\nbool requestTypeMayHaveBody(RequestType currentRequestType);\r\nRequestType getRequestTypeByString(const QString &currentRequestText);\r\nQString getRequestTypeString(const RequestType currentRequestType);\r\n\r\nFormKeyValueType getFormKeyTypeByString(const QString &currentFormKeyValueString);\r\nQString getFormKeyTypeString(const FormKeyValueType currentFormKeyValueType);\r\n\r\nBodyType getBodyTypeByString(const QString &currentBodyTypeText);\r\nQString getBodyTypeString(const BodyType currentBodyType);\r\n\r\nIdentCharacter getIdentCharacterByString(const QString &currentIdentCharacterText);\r\nQString getIdentCharacterString(const IdentCharacter currentIdentCharacter);\r\n\r\nQString getDateTimeFormatForFilename(const QDateTime &currentDateTime);\r\n\r\nvoid addRequestFormBodyRow(QTableWidget * const myTable, const QString &key, const QString &value, const UtilFRequest::FormKeyValueType type);\r\n\r\n// Return original content in case of error\r\nQString getStringFormattedForSerializationType(const QString &content, const SerializationFormatType serializationType);\r\nSerializationFormatType getSerializationFormatTypeForString(const QString &content);\r\n\r\n// Simply ofuscation just to not store password string as plain text in project / configuration files\r\n// (it does not protect the password, just obfuscates so can't be read directly)\r\n//  Applies a simple xor with the given salt\r\nQByteArray simpleStringObfuscationDeobfuscation(const QString& ofuscationSalt, const QString &input);\r\n\r\n// Replaces the textToReplace string with the actual username and password given (uses the FRequest Auth Placeholders for the replace)\r\nQString replaceFRequestAuthenticationPlaceholders(const QString &textToReplace, const QString &username, const QString &password);\r\n\r\nvoid setGlobalHeaderTableWidgetRow(QTableWidget *myTable, const int rowNumber);\r\nvoid resetGlobalTableWidgetRow(QTableWidget *myTable, const int rowNumber);\r\nbool isGlobalHeaderTableWidgetRow(QTableWidget *myTable, const int rowNumber);\r\n// we can't use a static object for this because we will receive an error:\r\n// \"QWidget: Must construct a QApplication before a QWidget\"\r\nQBrush getTableWidgetRowDisabledBackStyle();\r\nQBrush getTableWidgetRowDisabledTextStyle();\r\n}\r\n\r\n#endif // UTILFREQUEST_H\r\n"
  },
  {
    "path": "utilglobalvars.h",
    "content": "/*\r\n *\r\nCopyright (C) 2017-2019  Fábio Bento (fabiobento512)\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\r\n*\r\n*/\r\n\r\n#ifndef UTILGLOBALVARS_H\r\n#define UTILGLOBALVARS_H\r\n\r\nnamespace GlobalVars{\r\n\r\nstatic const QString AppName = \"FRequest\";\r\nstatic const QString AppVersion = \"1.2a\";\r\nstatic const QString LastCompatibleVersionConfig = \"1.2\";\r\nstatic const QString LastCompatibleVersionProjects= \"1.2\";\r\nstatic const QString AppConfigFileName = AppName + \".cfg\";\r\nstatic const QString AppLogFileName = AppName.toLower() + \".log\";\r\nstatic const QString FRequestAuthenticationPlaceholderUsername = \"{{FREQUEST_AUTH_USERNAME}}\";\r\nstatic const QString FRequestAuthenticationPlaceholderPassword = \"{{FREQUEST_AUTH_PASSWORD}}\";\r\nstatic constexpr int AppRecentProjectsMaxSize=6;\r\n\r\n}\r\n\r\n#endif // UTILGLOBALVARS_H\r\n"
  }
]