2022-12-22 15:30:08 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QLocalSocket>
|
|
|
|
|
2022-12-29 00:28:30 +03:00
|
|
|
#include "accountstate.h"
|
|
|
|
|
2022-12-22 16:37:30 +03:00
|
|
|
namespace OCC {
|
2022-12-22 15:30:08 +03:00
|
|
|
|
2022-12-22 16:37:30 +03:00
|
|
|
namespace Mac {
|
2022-12-22 15:30:08 +03:00
|
|
|
|
|
|
|
class FileProviderSocketController : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-03-11 03:56:20 +03:00
|
|
|
explicit FileProviderSocketController(QLocalSocket * const socket, QObject * const parent = nullptr);
|
2022-12-22 15:30:08 +03:00
|
|
|
|
2022-12-22 16:37:30 +03:00
|
|
|
signals:
|
|
|
|
void socketDestroyed(const QLocalSocket * const socket);
|
|
|
|
|
2022-12-28 19:46:12 +03:00
|
|
|
public slots:
|
|
|
|
void sendMessage(const QString &message) const;
|
2022-12-29 00:28:30 +03:00
|
|
|
void start();
|
2022-12-28 19:46:12 +03:00
|
|
|
|
2022-12-22 16:37:30 +03:00
|
|
|
private slots:
|
|
|
|
void slotOnDisconnected();
|
2023-03-11 03:56:20 +03:00
|
|
|
void slotSocketDestroyed(const QObject * const object);
|
2022-12-28 17:10:43 +03:00
|
|
|
void slotReadyRead();
|
2022-12-22 16:37:30 +03:00
|
|
|
|
2023-03-11 17:40:56 +03:00
|
|
|
void slotAccountStateChanged(const AccountState::State state);
|
|
|
|
|
2022-12-29 00:28:30 +03:00
|
|
|
void parseReceivedLine(const QString &receivedLine);
|
|
|
|
void requestFileProviderDomainInfo() const;
|
2023-01-27 01:01:31 +03:00
|
|
|
void sendAccountDetails() const;
|
2023-03-11 17:55:46 +03:00
|
|
|
void sendNotAuthenticated() const;
|
2022-12-29 00:28:30 +03:00
|
|
|
|
2022-12-22 15:30:08 +03:00
|
|
|
private:
|
2022-12-29 00:28:30 +03:00
|
|
|
static AccountStatePtr accountStateFromFileProviderDomainIdentifier(const QString &domainIdentifier);
|
|
|
|
|
2022-12-22 15:30:08 +03:00
|
|
|
QPointer<QLocalSocket> _socket;
|
2022-12-29 00:28:30 +03:00
|
|
|
AccountStatePtr _accountState;
|
2022-12-22 15:30:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Mac
|
|
|
|
|
|
|
|
} // namespace OCC
|