mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1118163 - Restore received file for small size (1-packet) file, r=shuang
This commit is contained in:
parent
08e33eb586
commit
3fcb4bc500
@ -481,8 +481,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
|
||||
|
||||
if (success && mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
ReplyToPut(mPutFinalFlag, success);
|
||||
@ -551,7 +551,8 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
mReadFileThread->Shutdown();
|
||||
mReadFileThread = nullptr;
|
||||
}
|
||||
// Release the Mount lock if file transfer completed
|
||||
|
||||
// Release the mount lock if file transfer completed
|
||||
if (mMountLock) {
|
||||
// The mount lock will be implicitly unlocked
|
||||
mMountLock = nullptr;
|
||||
@ -559,8 +560,14 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::RecoverFileName()
|
||||
BluetoothOppManager::RestoreReceivedFileAndNotify()
|
||||
{
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
|
||||
// Remove the trailing ".part" file name from mDsFile by two steps
|
||||
// 1. mDsFile->SetPath() so that the notification sent to Gaia will carry
|
||||
// correct information of the file.
|
||||
@ -574,16 +581,9 @@ BluetoothOppManager::RecoverFileName()
|
||||
mDsFile->SetPath(path);
|
||||
mDsFile->mFile->RenameTo(nullptr, mFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::DeleteDummyFile()
|
||||
{
|
||||
// Remove the empty temp file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
// Notify about change of received file
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -599,7 +599,11 @@ BluetoothOppManager::DeleteReceivedFile()
|
||||
mDsFile = nullptr;
|
||||
}
|
||||
|
||||
DeleteDummyFile();
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -956,12 +960,8 @@ BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage)
|
||||
// Success to receive a file and notify completion
|
||||
if (mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
|
||||
DeleteDummyFile();
|
||||
RecoverFileName();
|
||||
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
} else if (opCode == ObexRequestCode::Get ||
|
||||
opCode == ObexRequestCode::GetFinal ||
|
||||
|
@ -85,8 +85,7 @@ private:
|
||||
void ReceivingFileConfirmation();
|
||||
bool CreateFile();
|
||||
bool WriteToFile(const uint8_t* aData, int aDataLength);
|
||||
void RecoverFileName();
|
||||
void DeleteDummyFile();
|
||||
void RestoreReceivedFileAndNotify();
|
||||
void DeleteReceivedFile();
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnectOrAbort();
|
||||
|
@ -503,8 +503,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
|
||||
|
||||
if (success && mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
ReplyToPut(mPutFinalFlag, success);
|
||||
@ -573,7 +573,8 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
mReadFileThread->Shutdown();
|
||||
mReadFileThread = nullptr;
|
||||
}
|
||||
// Release the Mount lock if file transfer completed
|
||||
|
||||
// Release the mount lock if file transfer completed
|
||||
if (mMountLock) {
|
||||
// The mount lock will be implicitly unlocked
|
||||
mMountLock = nullptr;
|
||||
@ -581,8 +582,14 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::RecoverFileName()
|
||||
BluetoothOppManager::RestoreReceivedFileAndNotify()
|
||||
{
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
|
||||
// Remove the trailing ".part" file name from mDsFile by two steps
|
||||
// 1. mDsFile->SetPath() so that the notification sent to Gaia will carry
|
||||
// correct information of the file.
|
||||
@ -596,16 +603,9 @@ BluetoothOppManager::RecoverFileName()
|
||||
mDsFile->SetPath(path);
|
||||
mDsFile->mFile->RenameTo(nullptr, mFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::DeleteDummyFile()
|
||||
{
|
||||
// Remove the empty temp file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
// Notify about change of received file
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -621,7 +621,11 @@ BluetoothOppManager::DeleteReceivedFile()
|
||||
mDsFile = nullptr;
|
||||
}
|
||||
|
||||
DeleteDummyFile();
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -977,12 +981,8 @@ BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage)
|
||||
// Success to receive a file and notify completion
|
||||
if (mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
|
||||
DeleteDummyFile();
|
||||
RecoverFileName();
|
||||
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
} else if (opCode == ObexRequestCode::Get ||
|
||||
opCode == ObexRequestCode::GetFinal ||
|
||||
|
@ -85,8 +85,7 @@ private:
|
||||
void ReceivingFileConfirmation();
|
||||
bool CreateFile();
|
||||
bool WriteToFile(const uint8_t* aData, int aDataLength);
|
||||
void RecoverFileName();
|
||||
void DeleteDummyFile();
|
||||
void RestoreReceivedFileAndNotify();
|
||||
void DeleteReceivedFile();
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnectOrAbort();
|
||||
|
@ -481,8 +481,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
|
||||
|
||||
if (success && mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
ReplyToPut(mPutFinalFlag, success);
|
||||
@ -551,7 +551,8 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
mReadFileThread->Shutdown();
|
||||
mReadFileThread = nullptr;
|
||||
}
|
||||
// Release the Mount lock if file transfer completed
|
||||
|
||||
// Release the mount lock if file transfer completed
|
||||
if (mMountLock) {
|
||||
// The mount lock will be implicitly unlocked
|
||||
mMountLock = nullptr;
|
||||
@ -559,8 +560,14 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::RecoverFileName()
|
||||
BluetoothOppManager::RestoreReceivedFileAndNotify()
|
||||
{
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
|
||||
// Remove the trailing ".part" file name from mDsFile by two steps
|
||||
// 1. mDsFile->SetPath() so that the notification sent to Gaia will carry
|
||||
// correct information of the file.
|
||||
@ -574,16 +581,9 @@ BluetoothOppManager::RecoverFileName()
|
||||
mDsFile->SetPath(path);
|
||||
mDsFile->mFile->RenameTo(nullptr, mFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::DeleteDummyFile()
|
||||
{
|
||||
// Remove the empty temp file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
// Notify about change of received file
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -599,7 +599,11 @@ BluetoothOppManager::DeleteReceivedFile()
|
||||
mDsFile = nullptr;
|
||||
}
|
||||
|
||||
DeleteDummyFile();
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -956,12 +960,8 @@ BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage)
|
||||
// Success to receive a file and notify completion
|
||||
if (mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
|
||||
DeleteDummyFile();
|
||||
RecoverFileName();
|
||||
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
} else if (opCode == ObexRequestCode::Get ||
|
||||
opCode == ObexRequestCode::GetFinal ||
|
||||
|
@ -85,8 +85,7 @@ private:
|
||||
void ReceivingFileConfirmation();
|
||||
bool CreateFile();
|
||||
bool WriteToFile(const uint8_t* aData, int aDataLength);
|
||||
void RecoverFileName();
|
||||
void DeleteDummyFile();
|
||||
void RestoreReceivedFileAndNotify();
|
||||
void DeleteReceivedFile();
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnectOrAbort();
|
||||
|
@ -503,8 +503,8 @@ BluetoothOppManager::ConfirmReceivingFile(bool aConfirm)
|
||||
|
||||
if (success && mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
ReplyToPut(mPutFinalFlag, success);
|
||||
@ -573,7 +573,8 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
mReadFileThread->Shutdown();
|
||||
mReadFileThread = nullptr;
|
||||
}
|
||||
// Release the Mount lock if file transfer completed
|
||||
|
||||
// Release the mount lock if file transfer completed
|
||||
if (mMountLock) {
|
||||
// The mount lock will be implicitly unlocked
|
||||
mMountLock = nullptr;
|
||||
@ -581,8 +582,14 @@ BluetoothOppManager::AfterOppDisconnected()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::RecoverFileName()
|
||||
BluetoothOppManager::RestoreReceivedFileAndNotify()
|
||||
{
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
|
||||
// Remove the trailing ".part" file name from mDsFile by two steps
|
||||
// 1. mDsFile->SetPath() so that the notification sent to Gaia will carry
|
||||
// correct information of the file.
|
||||
@ -596,16 +603,9 @@ BluetoothOppManager::RecoverFileName()
|
||||
mDsFile->SetPath(path);
|
||||
mDsFile->mFile->RenameTo(nullptr, mFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothOppManager::DeleteDummyFile()
|
||||
{
|
||||
// Remove the empty temp file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
// Notify about change of received file
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -621,7 +621,11 @@ BluetoothOppManager::DeleteReceivedFile()
|
||||
mDsFile = nullptr;
|
||||
}
|
||||
|
||||
DeleteDummyFile();
|
||||
// Remove the empty dummy file
|
||||
if (mDummyDsFile && mDummyDsFile->mFile) {
|
||||
mDummyDsFile->mFile->Remove(false);
|
||||
mDummyDsFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -977,12 +981,8 @@ BluetoothOppManager::ServerDataHandler(UnixSocketRawData* aMessage)
|
||||
// Success to receive a file and notify completion
|
||||
if (mPutFinalFlag) {
|
||||
mSuccessFlag = true;
|
||||
|
||||
DeleteDummyFile();
|
||||
RecoverFileName();
|
||||
|
||||
RestoreReceivedFileAndNotify();
|
||||
FileTransferComplete();
|
||||
NotifyAboutFileChange();
|
||||
}
|
||||
} else if (opCode == ObexRequestCode::Get ||
|
||||
opCode == ObexRequestCode::GetFinal ||
|
||||
|
@ -85,8 +85,7 @@ private:
|
||||
void ReceivingFileConfirmation();
|
||||
bool CreateFile();
|
||||
bool WriteToFile(const uint8_t* aData, int aDataLength);
|
||||
void RecoverFileName();
|
||||
void DeleteDummyFile();
|
||||
void RestoreReceivedFileAndNotify();
|
||||
void DeleteReceivedFile();
|
||||
void ReplyToConnect();
|
||||
void ReplyToDisconnectOrAbort();
|
||||
|
Loading…
Reference in New Issue
Block a user