Skip to content

Commit 1a47fc8

Browse files
metsmamrts
authored andcommitted
Fix Safari cancel message
WE2-571 Signed-off-by: Raul Metsma <[email protected]>
1 parent f82e14c commit 1a47fc8

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

src/controller/controller.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@
3030
#include "utils.hpp"
3131
#include "inputoutputmode.hpp"
3232
#include "writeresponse.hpp"
33-
#include "logging.hpp"
34-
35-
#include "magic_enum/magic_enum.hpp"
3633

3734
#include <QApplication>
38-
#include <QScopedPointer>
39-
#include <QVariantMap>
4035

4136
using namespace pcsc_cpp;
4237
using namespace electronic_id;
@@ -77,6 +72,7 @@ void Controller::run()
7772
<< (isInStdinMode ? "stdin/stdout" : "command-line") << "mode";
7873

7974
try {
75+
// TODO: cut out stdin mode separate class to avoid bugs in safari mode
8076
if (isInStdinMode) {
8177
// In stdin/stdout mode we first output the version as required by the WebExtension
8278
// and then wait for the actual command.
@@ -327,25 +323,20 @@ void Controller::onDialogOK(const CardCertificateAndPinInfo& cardCertAndPinInfo)
327323
void Controller::onDialogCancel()
328324
{
329325
qDebug() << "User cancelled";
330-
326+
_result = makeErrorObject(RESP_USER_CANCEL, QStringLiteral("User cancelled"));
327+
writeResponseToStdOut(isInStdinMode, _result, commandType());
331328
disposeUI();
332-
333-
writeResponseToStdOut(isInStdinMode,
334-
makeErrorObject(RESP_USER_CANCEL, QStringLiteral("User cancelled")),
335-
commandType());
336329
exit();
337330
}
338331

339332
void Controller::onCriticalFailure(const QString& error)
340333
{
341334
qCritical() << "Exiting due to command" << std::string(commandType())
342335
<< "fatal error:" << error;
343-
writeResponseToStdOut(isInStdinMode, makeErrorObject(RESP_TECH_ERROR, error), commandType());
344-
336+
_result = makeErrorObject(RESP_TECH_ERROR, error);
337+
writeResponseToStdOut(isInStdinMode, _result, commandType());
345338
disposeUI();
346-
347339
WebEidUI::showFatalError();
348-
349340
exit();
350341
}
351342

src/controller/controller.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@
2424

2525
#include "commandhandler.hpp"
2626

27-
#include "ui.hpp"
28-
29-
#include "pcsc-cpp/pcsc-cpp.hpp"
30-
31-
#include "observer_ptr.hpp"
32-
3327
#include <unordered_map>
34-
#include <cstdint>
3528

3629
class ControllerChildThread;
3730
class CardEventMonitorThread;
@@ -42,7 +35,7 @@ class Controller : public QObject
4235
Q_OBJECT
4336

4437
public:
45-
explicit Controller(CommandWithArgumentsPtr cmd) : QObject(nullptr), command(std::move(cmd)) {}
38+
explicit Controller(CommandWithArgumentsPtr cmd) : command(std::move(cmd)) {}
4639

4740
const QVariantMap& result() const { return _result; }
4841

src/mac/safari-extension.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ @implementation SafariWebExtensionHandler
3535

3636
- (id)init {
3737
if (self = [super init]) {
38+
NSLog(@"web-eid-safari-extension: starting");
3839
contexts = [[NSMutableDictionary<NSString *, NSExtensionContext *> alloc] init];
3940
[NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(notificationEvent:) name:WebEidExtension object:nil];
4041
}
@@ -43,6 +44,7 @@ - (id)init {
4344

4445
- (void)dealloc
4546
{
47+
NSLog(@"web-eid-safari-extension: stopping");
4648
[NSDistributedNotificationCenter.defaultCenter removeObserver:self name:WebEidExtension object:nil];
4749
}
4850

0 commit comments

Comments
 (0)