Skip to content

Commit

Permalink
Merge pull request #299 from Krakonos/oauth2
Browse files Browse the repository at this point in the history
OAuth2
  • Loading branch information
Krakonos authored Aug 27, 2024
2 parents 5bd9cf7 + ea79311 commit da76627
Show file tree
Hide file tree
Showing 28 changed files with 1,076 additions and 407 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get -y install gdb libgdal-dev libproj-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential libgl1-mesa-dev cmake git libexiv2-dev libqt6svg* libqt6core5compat* qt6-l10n-tools qt6-tools-dev-tools protobuf-compiler
sudo apt-get -y install gdb libgdal-dev libproj-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential libgl1-mesa-dev cmake git libexiv2-dev libqt6svg* libqt6networkauth* libqt6core5compat* qt6-l10n-tools qt6-tools-dev-tools protobuf-compiler
- name: Build
run: |
./ci/travis-linux-script.sh
Expand All @@ -117,7 +117,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get -y install gdb libgdal-dev libproj-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential libgl1-mesa-dev cmake git libexiv2-dev libqt6svg* libqt6core5compat* qt6-l10n-tools qt6-tools-dev-tools protobuf-compiler
sudo apt-get -y install gdb libgdal-dev libproj-dev qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential libgl1-mesa-dev cmake git libexiv2-dev libqt6svg* libqt6networkauth* libqt6core5compat* qt6-l10n-tools qt6-tools-dev-tools protobuf-compiler
sudo apt-get -y install python3-pip libglib2.0-dev bash dash squashfs-tools zsync fakeroot
sudo pip install git+https://github.com/AppImageCrafters/appimage-builder.git
- name: Build
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set(CMAKE_AUTORCC ON)
##############################################
# Find Qt dependencies
##############################################
set(MERKAARTOR_QT_LIBS Svg Network Xml Core Gui Concurrent PrintSupport Widgets Test)
set(MERKAARTOR_QT_LIBS Svg Network NetworkAuth Xml Core Gui Concurrent PrintSupport Widgets Test)
set(MERKAARTOR_QT_TOOLS LinguistTools)
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
message(STATUS " * Qt version found: ${QT_VERSION}")
Expand Down Expand Up @@ -264,6 +264,10 @@ src/Utils/SlippyMapWidget.cpp
src/Utils/SlippyMapWidget.h
src/Utils/Utils.h
src/Utils/OsmLink.cpp
src/Utils/OsmServer.cpp
src/Utils/OsmOAuth2Flow.cpp
src/Utils/OAuth2OOBDialog.ui
src/Utils/OAuth2OOBDialog.cpp
src/Utils/ShortcutOverrideFilter.cpp
src/Utils/LineF.h
src/Utils/SelectionDialog.ui
Expand Down
12 changes: 12 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,16 @@ The TCL framework also had the convention of "I" for second-level
initialisation of objects after creation (possibly due to limitations in the
compiler support of C++ features - I don't remember).

## Logging

Some of the (newer) classes use QLoggingCategory for log filtering. Debug logs are disabled by default, but can be enabled at runtime using environment variable:

```
QT_LOGGING_RULES="merk.<ClassName>.debug=true"
```

Or for all classes:

```
QT_LOGGING_RULES="merk.*.debug=true"
```
2 changes: 1 addition & 1 deletion ci/travis-linux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sudo echo "deb http://archive.ubuntu.com/ubuntu ${TRAVIS_DIST} main universe res
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main'
sudo apt-add-repository -y ${QT_REPO}
sudo apt-get update -qq
sudo apt-get -y install gdb libgdal-dev libproj-dev qt${QT_PREFIX}base qt${QT_PREFIX}tools qt${QT_PREFIX}svg build-essential libgl1-mesa-dev cmake git libexiv2-dev protobuf-compiler
sudo apt-get -y install gdb libgdal-dev libproj-dev qt${QT_PREFIX}base qt${QT_PREFIX}tools qt${QT_PREFIX}svg qt${QT_PREFIX}networkauth-no-lgpl build-essential libgl1-mesa-dev cmake git libexiv2-dev protobuf-compiler
2 changes: 2 additions & 0 deletions cmake/AppImageBuilder.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ AppDir:
- libqt6dbus6
- libqt6svg6
- libqt6core5compat6
- libqt6networkauth6
- qt6-qpa-plugins

files:
Expand All @@ -49,5 +50,6 @@ AppDir:
AppImage:
update-information: None
sign-key: None
comp: xz
arch: x86_64
comp: xz
2 changes: 1 addition & 1 deletion src/Docks/InfoDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void InfoDock::on_anchorClicked(const QUrl & link)
// } else {
// QMessageBox::warning(Main,QApplication::translate("Downloader","Download failed"),QApplication::translate("Downloader","Unexpected http status code (%1)").arg(theDownloader.resultCode()));
// }
QUrl theUrl(M_PREFS->getOsmWebsite()+link.path());
QUrl theUrl(M_PREFS->getOsmServer()->getServerInfo().Url+link.path());
QDesktopServices::openUrl(theUrl);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ImportExport/ImportOSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static bool downloadToResolve(const QList<Feature*>& Resolution, QWidget* aParen

for (int i=0; i<Resolution.size(); i++ )
{
QUrl URL = M_PREFS->getOsmApiUrl()+theDownloader->getURLToFetchFull(Resolution[i]);
QUrl URL = theDownloader->getURLToFetchFull(Resolution[i]);
Lbl->setText(QApplication::translate("Downloader","Downloading unresolved %1 of %2").arg(i+1).arg(Resolution.size()));
if (theDownloader->go(URL))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ LayerWidget* SpecialLayer::newWidget(void)
void SpecialLayer::refreshLayer()
{
if (m_type == Layer::MapDustLayer) {
g_Merk_MainWindow->on_layersMapdustAction_triggered();
/* FIXME: Remove mapdust type */
}
}

Expand Down
35 changes: 9 additions & 26 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#include "gdal_version.h"

#include "Utils/SlippyMapWidget.h"
#include "Utils/OsmServer.h"

namespace {

Expand Down Expand Up @@ -2018,6 +2019,8 @@ void MainWindow::on_fileUploadAction_triggered()
return;
}

/* TODO: Check if the server list is empty? */
/*
while (M_PREFS->getOsmUser().isEmpty()) {
int ret = QMessageBox::warning(this, tr("Upload OSM"), tr("You don't seem to have specified your\n"
"OpenStreetMap username and password.\nDo you want to do this now?"), QMessageBox::Yes | QMessageBox::No);
Expand All @@ -2026,8 +2029,10 @@ void MainWindow::on_fileUploadAction_triggered()
} else
return;
}
*/
on_editPropertiesAction_triggered();
syncOSM(M_PREFS->getOsmApiUrl(), M_PREFS->getOsmUser(), M_PREFS->getOsmPassword());
// TODO: Replace this call to use a the OsmServer object instead of individual parameters.
syncOSM(M_PREFS->getOsmServer());

theDocument->history().updateActions();
theDirty->updateList();
Expand Down Expand Up @@ -2067,28 +2072,6 @@ void MainWindow::on_fileDownloadMoreAction_triggered()
emit content_changed();
}

void MainWindow::on_layersMapdustAction_triggered()
{
SpecialLayer* sl = NULL;
for (int i=0; i<theDocument->layerSize(); ++i) {
if (theDocument->getLayer(i)->classType() == Layer::MapDustLayer) {
sl = dynamic_cast<SpecialLayer*>(theDocument->getLayer(i));
while (sl->size())
{
sl->deleteFeature(sl->get(0));
}
}
}

createProgressDialog();

if (!::downloadMapdust(this, theView->viewport(), theDocument, sl)) {
QMessageBox::warning(this, tr("Error downloading MapDust"), tr("The MapDust bugs could not be downloaded"));
}

deleteProgressDialog();
}

void MainWindow::downloadFeatures(const QList<Feature*>& aDownloadList)
{
createProgressDialog();
Expand Down Expand Up @@ -4294,7 +4277,7 @@ bool MainWindow::hasUnsavedChanges()
return true;
}

void MainWindow::syncOSM(const QString& aWeb, const QString& aUser, const QString& aPwd)
void MainWindow::syncOSM(OsmServer server)
{
#ifndef FRISIUS_BUILD
if (checkForConflicts(theDocument)) {
Expand All @@ -4305,10 +4288,10 @@ void MainWindow::syncOSM(const QString& aWeb, const QString& aUser, const QStrin
DirtyListBuild Future;
theDocument->history().buildDirtyList(Future);
DirtyListDescriber Describer(theDocument,Future);
ChangesetInfo changesetInfo = {aWeb, "", ""};
ChangesetInfo changesetInfo = {server->getServerInfo().Url, "", ""};
if (Describer.showChanges(this, changesetInfo) && Describer.tasks()) {
Future.resetUpdates();
DirtyListExecutorOSC Exec(theDocument,Future,changesetInfo,aWeb,aUser,aPwd,Describer.tasks());
DirtyListExecutorOSC Exec(theDocument,Future,changesetInfo,server,Describer.tasks());
if (Exec.executeChanges(this)) {
if (M_PREFS->getAutoHistoryCleanup() && !theDocument->getDirtyOrOriginLayer()->getDirtySize())
theDocument->history().cleanup();
Expand Down
5 changes: 3 additions & 2 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <QProgressBar>
#include <QLabel>

#include "OsmServer.h"

namespace Ui {
class MainWindow;
}
Expand Down Expand Up @@ -77,7 +79,6 @@ public slots:
virtual void on_layersNewImageAction_triggered();
virtual void on_layersNewDrawingAction_triggered();
virtual void on_layersNewFilterAction_triggered();
virtual void on_layersMapdustAction_triggered();

virtual void on_fileNewAction_triggered();
virtual void on_fileDownloadAction_triggered();
Expand Down Expand Up @@ -340,7 +341,7 @@ private slots:
void startBusyCursor();
void endBusyCursor();

void syncOSM(const QString &aWeb, const QString &aUser, const QString &aPwd);
void syncOSM(OsmServer srv);
protected:
void closeEvent(QCloseEvent * event);
virtual QMenu * createPopupMenu ();
Expand Down
Loading

0 comments on commit da76627

Please sign in to comment.