mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 805724 - patch 5: sent correct file name to Gaia and removed received incomplete file, r=qdot
This commit is contained in:
parent
8b005928a8
commit
b701e28abf
@ -298,6 +298,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
|
||||
if (aConfirm) {
|
||||
StartFileTransfer(mConnectedDeviceAddress, true,
|
||||
sFileName, sFileLength, sContentType);
|
||||
} else {
|
||||
DeleteReceivedFile();
|
||||
}
|
||||
|
||||
if (mPutFinal || !aConfirm) {
|
||||
@ -348,6 +350,28 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
mConnectedDeviceAddress.AssignLiteral("00:00:00:00:00:00");
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::DeleteReceivedFile()
|
||||
{
|
||||
nsString path;
|
||||
path.AssignLiteral(TARGET_FOLDER);
|
||||
path += sFileName;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
nsresult rv = NS_NewLocalFile(path + sFileName, false, getter_AddRefs(f));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Couldn't find received file, nothing to delete.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mOutputStream) {
|
||||
mOutputStream->Close();
|
||||
mOutputStream = nullptr;
|
||||
}
|
||||
|
||||
f->Remove(false);
|
||||
}
|
||||
|
||||
// Virtual function of class SocketConsumer
|
||||
void
|
||||
BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
@ -521,10 +545,9 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
pktHeaders.GetContentType(sContentType);
|
||||
pktHeaders.GetLength(&sFileLength);
|
||||
|
||||
path += sFileName;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
nsresult rv = NS_NewLocalFile(path, false, getter_AddRefs(f));
|
||||
nsresult rv;
|
||||
rv = NS_NewLocalFile(path + sFileName, false, getter_AddRefs(f));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Couldn't new a local file");
|
||||
}
|
||||
@ -534,6 +557,13 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
NS_WARNING("Couldn't create the file");
|
||||
}
|
||||
|
||||
/*
|
||||
* The function CreateUnique() may create a file with a different file
|
||||
* name from the original sFileName. Therefore we have to retrieve
|
||||
* the file name again.
|
||||
*/
|
||||
f->GetLeafName(sFileName);
|
||||
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(mOutputStream), f);
|
||||
if (!mOutputStream) {
|
||||
NS_WARNING("Couldn't new an output stream");
|
||||
@ -607,6 +637,7 @@ BluetoothOppManager::ReceiveSocketData(UnixSocketRawData* aMessage)
|
||||
mReceiving = false;
|
||||
FileTransferComplete(mConnectedDeviceAddress, false, true,
|
||||
sFileName, sSentFileLength, sContentType);
|
||||
DeleteReceivedFile();
|
||||
} else if (mPutFinal) {
|
||||
mReceiving = false;
|
||||
FileTransferComplete(mConnectedDeviceAddress, true, true,
|
||||
|
@ -83,6 +83,7 @@ private:
|
||||
const nsString& aFileName,
|
||||
uint32_t aFileLength,
|
||||
const nsString& aContentType);
|
||||
void DeleteReceivedFile();
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnect();
|
||||
void ReplyToPut(bool aFinal, bool aContinue);
|
||||
|
Loading…
Reference in New Issue
Block a user