Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CClipboard.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #include "CClipboard.h"
00016 
00017 //
00018 // CClipboard
00019 //
00020 
00021 CClipboard::CClipboard() :
00022     m_open(false),
00023     m_owner(false)
00024 {
00025     open(0);
00026     empty();
00027     close();
00028 }
00029 
00030 CClipboard::~CClipboard()
00031 {
00032     // do nothing
00033 }
00034 
00035 bool
00036 CClipboard::empty()
00037 {
00038     assert(m_open);
00039 
00040     // clear all data
00041     for (SInt32 index = 0; index < kNumFormats; ++index) {
00042         m_data[index]  = "";
00043         m_added[index] = false;
00044     }
00045 
00046     // save time
00047     m_timeOwned = m_time;
00048 
00049     // we're the owner now
00050     m_owner = true;
00051 
00052     return true;
00053 }
00054 
00055 void
00056 CClipboard::add(EFormat format, const CString& data)
00057 {
00058     assert(m_open);
00059     assert(m_owner);
00060 
00061     m_data[format]  = data;
00062     m_added[format] = true;
00063 }
00064 
00065 bool
00066 CClipboard::open(Time time) const
00067 {
00068     assert(!m_open);
00069 
00070     m_open = true;
00071     m_time = time;
00072 
00073     return true;
00074 }
00075 
00076 void
00077 CClipboard::close() const
00078 {
00079     assert(m_open);
00080 
00081     m_open = false;
00082 }
00083 
00084 CClipboard::Time
00085 CClipboard::getTime() const
00086 {
00087     return m_timeOwned;
00088 }
00089 
00090 bool
00091 CClipboard::has(EFormat format) const
00092 {
00093     assert(m_open);
00094     return m_added[format];
00095 }
00096 
00097 CString
00098 CClipboard::get(EFormat format) const
00099 {
00100     assert(m_open);
00101     return m_data[format];
00102 }
00103 
00104 void
00105 CClipboard::unmarshall(const CString& data, Time time)
00106 {
00107     IClipboard::unmarshall(this, data, time);
00108 }
00109 
00110 CString
00111 CClipboard::marshall() const
00112 {
00113     return IClipboard::marshall(this);
00114 }

Generated on Fri Nov 6 00:21:13 2009 for synergy-plus by  doxygen 1.3.9.1