1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2004 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef COSXCLIPBOARD_H
|
---|
16 | #define COSXCLIPBOARD_H
|
---|
17 |
|
---|
18 | #include "IClipboard.h"
|
---|
19 | #include <vector>
|
---|
20 | #include <Carbon/Carbon.h>
|
---|
21 |
|
---|
22 | class IOSXClipboardConverter;
|
---|
23 |
|
---|
24 | //! OS X clipboard implementation
|
---|
25 | class COSXClipboard : public IClipboard {
|
---|
26 | public:
|
---|
27 | COSXClipboard();
|
---|
28 | virtual ~COSXClipboard();
|
---|
29 |
|
---|
30 | //! Test if clipboard is owned by synergy
|
---|
31 | static bool isOwnedBySynergy();
|
---|
32 |
|
---|
33 | // IClipboard overrides
|
---|
34 | virtual bool empty();
|
---|
35 | virtual void add(EFormat, const CString& data);
|
---|
36 | virtual bool open(Time) const;
|
---|
37 | virtual void close() const;
|
---|
38 | virtual Time getTime() const;
|
---|
39 | virtual bool has(EFormat) const;
|
---|
40 | virtual CString get(EFormat) const;
|
---|
41 |
|
---|
42 | private:
|
---|
43 | void clearConverters();
|
---|
44 | static ScrapFlavorType
|
---|
45 | getOwnershipFlavor();
|
---|
46 |
|
---|
47 | private:
|
---|
48 | typedef std::vector<IOSXClipboardConverter*> ConverterList;
|
---|
49 |
|
---|
50 | mutable Time m_time;
|
---|
51 | ConverterList m_converters;
|
---|
52 | mutable ScrapRef m_scrap;
|
---|
53 | };
|
---|
54 |
|
---|
55 | //! Clipboard format converter interface
|
---|
56 | /*!
|
---|
57 | This interface defines the methods common to all Scrap book format
|
---|
58 | */
|
---|
59 | class IOSXClipboardConverter : public IInterface {
|
---|
60 | public:
|
---|
61 | //! @name accessors
|
---|
62 | //@{
|
---|
63 |
|
---|
64 | //! Get clipboard format
|
---|
65 | /*!
|
---|
66 | Return the clipboard format this object converts from/to.
|
---|
67 | */
|
---|
68 | virtual IClipboard::EFormat
|
---|
69 | getFormat() const = 0;
|
---|
70 |
|
---|
71 | //! returns the scrap flavor type that this object converts from/to
|
---|
72 | virtual ScrapFlavorType
|
---|
73 | getOSXFormat() const = 0;
|
---|
74 |
|
---|
75 | //! Convert from IClipboard format
|
---|
76 | /*!
|
---|
77 | Convert from the IClipboard format to the Carbon scrap format.
|
---|
78 | The input data must be in the IClipboard format returned by
|
---|
79 | getFormat(). The return data will be in the scrap
|
---|
80 | format returned by getOSXFormat().
|
---|
81 | */
|
---|
82 | virtual CString fromIClipboard(const CString&) const = 0;
|
---|
83 |
|
---|
84 | //! Convert to IClipboard format
|
---|
85 | /*!
|
---|
86 | Convert from the carbon scrap format to the IClipboard format
|
---|
87 | (i.e., the reverse of fromIClipboard()).
|
---|
88 | */
|
---|
89 | virtual CString toIClipboard(const CString&) const = 0;
|
---|
90 |
|
---|
91 | //@}
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif
|
---|