2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
#include "deskflow/IClipboard.h"
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
class IOSXClipboardConverter;
|
|
|
|
|
|
|
|
|
|
//! OS X clipboard implementation
|
2024-10-17 18:04:35 +00:00
|
|
|
class OSXClipboard : public IClipboard
|
|
|
|
|
{
|
2012-06-10 16:50:54 +00:00
|
|
|
public:
|
2024-07-02 19:07:06 +00:00
|
|
|
OSXClipboard();
|
|
|
|
|
virtual ~OSXClipboard();
|
|
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
//! Test if clipboard is owned by deskflow
|
|
|
|
|
static bool isOwnedByDeskflow();
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
// IClipboard overrides
|
2025-05-02 19:45:22 +00:00
|
|
|
bool empty() override;
|
2025-07-30 12:19:15 +00:00
|
|
|
void add(Format, const std::string &data) override;
|
2025-05-02 19:45:22 +00:00
|
|
|
bool open(Time) const override;
|
|
|
|
|
void close() const override;
|
|
|
|
|
Time getTime() const override;
|
2025-07-30 12:19:15 +00:00
|
|
|
bool has(Format) const override;
|
|
|
|
|
std::string get(Format) const override;
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
bool synchronize();
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
private:
|
2024-07-02 19:07:06 +00:00
|
|
|
void clearConverters();
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
private:
|
2024-11-27 16:51:48 +00:00
|
|
|
using ConverterList = std::vector<IOSXClipboardConverter *>;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
mutable Time m_time;
|
|
|
|
|
ConverterList m_converters;
|
|
|
|
|
PasteboardRef m_pboard;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//! Clipboard format converter interface
|
|
|
|
|
/*!
|
|
|
|
|
This interface defines the methods common to all Scrap book format
|
|
|
|
|
*/
|
2024-10-17 18:04:35 +00:00
|
|
|
class IOSXClipboardConverter : public IInterface
|
|
|
|
|
{
|
2012-06-10 16:50:54 +00:00
|
|
|
public:
|
2024-07-02 19:07:06 +00:00
|
|
|
//! @name accessors
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
//! Get clipboard format
|
|
|
|
|
/*!
|
|
|
|
|
Return the clipboard format this object converts from/to.
|
|
|
|
|
*/
|
2025-07-30 12:19:15 +00:00
|
|
|
virtual IClipboard::Format getFormat() const = 0;
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
//! returns the scrap flavor type that this object converts from/to
|
|
|
|
|
virtual CFStringRef getOSXFormat() const = 0;
|
|
|
|
|
|
|
|
|
|
//! Convert from IClipboard format
|
|
|
|
|
/*!
|
|
|
|
|
Convert from the IClipboard format to the Carbon scrap format.
|
|
|
|
|
The input data must be in the IClipboard format returned by
|
|
|
|
|
getFormat(). The return data will be in the scrap
|
|
|
|
|
format returned by getOSXFormat().
|
|
|
|
|
*/
|
2025-01-06 00:55:07 +00:00
|
|
|
virtual std::string fromIClipboard(const std::string &) const = 0;
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
//! Convert to IClipboard format
|
|
|
|
|
/*!
|
|
|
|
|
Convert from the carbon scrap format to the IClipboard format
|
|
|
|
|
(i.e., the reverse of fromIClipboard()).
|
|
|
|
|
*/
|
2025-01-06 00:55:07 +00:00
|
|
|
virtual std::string toIClipboard(const std::string &) const = 0;
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
//@}
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|