Changeset 56654 in vbox for trunk/src/VBox
- Timestamp:
- Jun 26, 2015 8:41:15 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp
r56562 r56654 143 143 144 144 /* The format the guest requests. */ 145 QString format;145 QString strFormat; 146 146 /* Ask the guest for dropping data. */ 147 KDnDAction result = m_dndTarget.Drop(screenID,148 x,149 y,150 toVBoxDnDAction(proposedAction),151 toVBoxDnDActions(possibleActions),152 pMimeData->formats().toVector(), format);147 KDnDAction enmResult = m_dndTarget.Drop(screenID, 148 x, 149 y, 150 toVBoxDnDAction(proposedAction), 151 toVBoxDnDActions(possibleActions), 152 pMimeData->formats().toVector(), strFormat); 153 153 154 154 /* Has the guest accepted the drop event? */ 155 155 if ( m_dndTarget.isOk() 156 && result != KDnDAction_Ignore) 157 { 158 /* Get the actual MIME data in the requested format. */ 156 && enmResult != KDnDAction_Ignore) 157 { 158 LogFlowFunc(("strFormat=%s ...\n", strFormat.toAscii().constData())); 159 160 QByteArray arrBytes; 161 162 /* 163 * Does the host support the format requested by the guest? 164 * Lookup the format in the MIME data object. 165 */ 159 166 AssertPtr(pMimeData); 160 const QByteArray &d = pMimeData->data(format); 161 if ( !d.isEmpty() 162 && !format.isEmpty()) 167 if (pMimeData->formats().indexOf(strFormat) >= 0) 163 168 { 164 /* Convert the actual MIME data to a vector (needed for the COM wrapper). */ 165 QVector<uint8_t> dv(d.size()); 166 memcpy(dv.data(), d.constData(), d.size()); 167 168 CProgress progress = m_dndTarget.SendData(screenID, format, dv); 169 arrBytes = pMimeData->data(strFormat); 170 Assert(!arrBytes.isEmpty()); 171 } 172 /* 173 * The host does not support the format requested by the guest. 174 * This can happen if the host wants to send plan text, for example, but 175 * the guest requested something else, e.g. an URI list. 176 * 177 * In that case dictate the guest to use a fixed format from the host, 178 * so instead returning the requested URI list, return the original 179 * data format from the host. The guest has to try to deal with that then. 180 **/ 181 else 182 { 183 LogRel3(("DnD: Guest requested a different format '%s'\n", strFormat.toAscii().constData())); 184 LogRel3(("DnD: The host offered:\n")); 185 #if 0 186 for (QStringList::iterator itFmt = pMimeData->formats().begin(); 187 itFmt != pMimeData->formats().end(); itFmt++) 188 { 189 QString strTemp = *itFmt; 190 LogRel3(("DnD: \t%s\n", strTemp.toAscii().constData())); 191 } 192 #endif 193 if (pMimeData->hasText()) 194 { 195 LogRel3(("DnD: Converting data to text ...\n")); 196 arrBytes = pMimeData->text().toUtf8(); 197 strFormat = "text/plain;charset=utf-8"; 198 } 199 else 200 { 201 LogRel(("DnD: Error: Could not convert host format to guest format\n")); 202 enmResult = KDnDAction_Ignore; 203 } 204 } 205 206 if (arrBytes.size()) /* Anything to send? */ 207 { 208 /* Convert data to a vector. */ 209 QVector<uint8_t> vecData(arrBytes.size()); /** @todo Can this throw or anything? */ 210 AssertReleaseMsg(vecData.size() == arrBytes.size(), ("Drag and drop format buffer size does not match")); 211 memcpy(vecData.data(), arrBytes.constData(), arrBytes.size()); 212 213 /* Send data to the guest. */ 214 LogRel3(("DnD: Host is sending %d bytes of data as '%s'\n", vecData.size(), strFormat.toAscii().constData())); 215 CProgress progress = m_dndTarget.SendData(screenID, strFormat, vecData); 169 216 170 217 if (m_dndTarget.isOk()) 171 218 { 172 LogFlowFunc(("Transferring data to guest ...\n"));173 174 219 msgCenter().showModalProgressDialog(progress, 175 220 tr("Dropping data ..."), ":/progress_dnd_hg_90px.png", … … 185 230 { 186 231 msgCenter().cannotDropDataToGuest(progress, m_pParent); 187 result = KDnDAction_Ignore;232 enmResult = KDnDAction_Ignore; 188 233 } 189 234 } … … 191 236 { 192 237 msgCenter().cannotDropDataToGuest(m_dndTarget, m_pParent); 193 result = KDnDAction_Ignore;238 enmResult = KDnDAction_Ignore; 194 239 } 195 240 } 241 else /* Error. */ 242 enmResult = KDnDAction_Ignore; 196 243 } 197 244 … … 203 250 setMode(DNDMODE_UNKNOWN); 204 251 205 return toQtDnDAction( result);252 return toQtDnDAction(enmResult); 206 253 } 207 254
Note:
See TracChangeset
for help on using the changeset viewer.