mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-19 12:22:16 +03:00
bfcfdeec64
This prepares the switch to the official FinderSync API on Yosemite which requires the extension to run in a sandbox. This complicates the usage of a local socket to communicate with a non-sandboxed GUI client. An NSConnection is easier to use in this case, which we can use as long as the server name (i.e. Mach port registered name) is prefixed with the code signing Team Identifier. A placeholder server implementation is also added to the client's SocketApi which basically reproduces the interface of a QLocalSocket. Most of the references to individual sockets we're only using QIODevice methods so the type was simply reduced. A typedef to replace the QLocalServer was the only other part needed.
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
/*
|
|
* Copyright (C) by Jocelyn Turcotte <jturcotte@woboq.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.
|
|
*/
|
|
|
|
#ifndef SOCKETAPISOCKET_OSX_H
|
|
#define SOCKETAPISOCKET_OSX_H
|
|
|
|
#include <QAbstractSocket>
|
|
#include <QIODevice>
|
|
|
|
class SocketApiServerPrivate;
|
|
class SocketApiSocketPrivate;
|
|
|
|
class SocketApiSocket : public QIODevice
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
SocketApiSocket(QObject *parent, SocketApiSocketPrivate *p);
|
|
~SocketApiSocket();
|
|
|
|
qint64 readData(char *data, qint64 maxlen) override;
|
|
qint64 writeData(const char *data, qint64 len) override;
|
|
|
|
bool isSequential() const override { return true; }
|
|
qint64 bytesAvailable() const override;
|
|
bool canReadLine() const override;
|
|
|
|
signals:
|
|
void disconnected();
|
|
|
|
private:
|
|
// Use Qt's p-impl system to hide objective-c types from C++ code including this file
|
|
Q_DECLARE_PRIVATE(SocketApiSocket)
|
|
QScopedPointer<SocketApiSocketPrivate> d_ptr;
|
|
friend class SocketApiServerPrivate;
|
|
};
|
|
|
|
class SocketApiServer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
SocketApiServer();
|
|
~SocketApiServer();
|
|
|
|
void close();
|
|
bool listen(const QString &name);
|
|
SocketApiSocket *nextPendingConnection();
|
|
|
|
static bool removeServer(const QString &) { return false; }
|
|
|
|
signals:
|
|
void newConnection();
|
|
|
|
private:
|
|
Q_DECLARE_PRIVATE(SocketApiServer)
|
|
QScopedPointer<SocketApiServerPrivate> d_ptr;
|
|
};
|
|
|
|
#endif // SOCKETAPISOCKET_OSX_H
|