Changeset 2774 for trunk/synergy/lib/platform/CPMClipboard.cpp
- Timestamp:
- Aug 20, 2006, 9:50:11 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/synergy/lib/platform/CPMClipboard.cpp
r2770 r2774 43 43 44 44 bool 45 CPMClipboard::empty Unowned()45 CPMClipboard::empty() 46 46 { 47 47 LOG((CLOG_DEBUG "empty clipboard")); 48 49 // empty the clipboard (and take ownership)50 48 if (!WinEmptyClipbrd(CPMUtil::getHAB())) { 51 LOG((CLOG_DEBUG "failed to grab clipboard")); 52 return false; 53 } 54 55 return true; 56 } 57 58 bool 59 CPMClipboard::empty() 60 { 61 if (!emptyUnowned()) { 49 LOG((CLOG_ERR "failed to empty the clipboard")); 62 50 return false; 63 51 } … … 70 58 return false; 71 59 } 72 return !!WinSetClipbrdData(CPMUtil::getHAB(), (ULONG)pv, getOwnershipFormat(), CFI_POINTER); 60 if (!WinSetClipbrdData(CPMUtil::getHAB(), (ULONG)pv, getOwnershipFormat(), CFI_POINTER)) { 61 LOG((CLOG_ERR "failed to set dummy clipboard data. %#x", WinGetLastError(CPMUtil::getHAB()))); 62 DosFreeMem(pv); 63 return false; 64 } 65 return true; 73 66 } 74 67 … … 92 85 if (!WinSetClipbrdData(CPMUtil::getHAB(), ulPMData, ulPMFormat, ulPMFormatInfo)) { 93 86 // free converted data if we couldn't put it on the clipboard 87 LOG((CLOG_ERR "failed to set clipboard data ulPMData=%#lx ulPMFormat=%#lx ulPMFormatInfo=%#lx. %#x", 88 ulPMData, ulPMFormat, ulPMFormatInfo, WinGetLastError(CPMUtil::getHAB()))); 94 89 converter->freePMData(ulPMData); 95 90 } … … 108 103 return false; 109 104 } 110 111 105 m_time = time; 112 113 106 return true; 114 107 } … … 118 111 { 119 112 LOG((CLOG_DEBUG "close clipboard")); 120 WinCloseClipbrd(CPMUtil::getHAB()); 113 if (!WinCloseClipbrd(CPMUtil::getHAB())) { 114 LOG((CLOG_WARN "failed to close the clipboard. %#x", WinGetLastError(CPMUtil::getHAB()))); 115 } 121 116 } 122 117 … … 130 125 CPMClipboard::has(EFormat format) const 131 126 { 127 LOG((CLOG_DEBUG "has clipboard format=%d?", format)); 132 128 for (ConverterList::const_iterator index = m_converters.begin(); 133 129 index != m_converters.end(); 134 130 ++index) { 135 131 IPMClipboardConverter* converter = *index; 132 LOG((CLOG_DEBUG2 "CPMClipboard::has: format=%d convert->getFormat()->%d (pmformat=%d)", format, converter->getFormat(), converter->getPMFormat())); 136 133 if (converter->getFormat() == format) { 137 134 ULONG fFmtInfo; 138 if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)) { 135 if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), converter->getPMFormat(), &fFmtInfo)) { 136 LOG((CLOG_DEBUG "yes, we have format %d!", format)); 139 137 return true; 140 138 } 141 139 } 142 140 } 141 LOG((CLOG_DEBUG "sorry, no we haven't.")); 143 142 return false; 144 143 } … … 147 146 CPMClipboard::get(EFormat format) const 148 147 { 148 LOG((CLOG_DEBUG "get clipboard format=%d?", format)); 149 149 150 // find the converter for the first clipboard format we can handle 150 151 IPMClipboardConverter* converter = NULL; … … 155 156 ++index) { 156 157 converter = *index; 158 LOG((CLOG_DEBUG2 "CPMClipboard::get: pmFormat=%d format=%d ?=? %d:%d", pmFormat, format, converter->getPMFormat(), converter->getFormat())); 157 159 if (converter->getPMFormat() == pmFormat && 158 160 converter->getFormat() == format) { … … 172 174 ULONG ulData = WinQueryClipbrdData(CPMUtil::getHAB(), converter->getPMFormat()); 173 175 if (ulData == 0) { 176 LOG((CLOG_DEBUG "CPMClipboard::get: ulData=%#x\n", ulData)); 174 177 return CString(); 175 178 } 176 179 177 180 // convert 178 return converter->toIClipboard(ulData); 181 CString str = converter->toIClipboard(ulData); 182 LOG((CLOG_DEBUG2 "CPMClipboard::get: converted ulData=%lx to '%s'\n", ulData, str.c_str())); 183 return str; 179 184 } 180 185 … … 194 199 { 195 200 ULONG fFmtInfo; 196 return (!!WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)); 201 if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)) { 202 LOG((CLOG_DEBUG "isOwnedBySynergy: yes")); 203 return true; 204 } 205 LOG((CLOG_DEBUG "isOwnedBySynergy: no")); 206 return false; 197 207 } 198 208
Note:
See TracChangeset
for help on using the changeset viewer.