summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpServer.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-08-02 10:37:41 -0400
committerMike Lockwood <lockwood@android.com>2010-08-02 10:37:41 -0400
commit9c04c4cc038f924d9cb98798e1c07fe6017e85d0 (patch)
tree9cf6d88d73c6c16ca7712820c5586a77de1c1d17 /media/mtp/MtpServer.cpp
parent99b4de92430fe42f9d1493c8a4c3d27de89d3549 (diff)
downloadframeworks_av-9c04c4cc038f924d9cb98798e1c07fe6017e85d0.zip
frameworks_av-9c04c4cc038f924d9cb98798e1c07fe6017e85d0.tar.gz
frameworks_av-9c04c4cc038f924d9cb98798e1c07fe6017e85d0.tar.bz2
Clean up MtpDatabase API.
Return MTP response codes instead of booleans for success or failure. Remove some unused code. Change-Id: I82ce80a4d7779233264e3caf139ebd0cece12f5c Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpServer.cpp')
-rw-r--r--media/mtp/MtpServer.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index adfe3a9..1e41407 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -470,10 +470,11 @@ MtpResponseCode MtpServer::doGetObject() {
MtpObjectHandle handle = mRequest.getParameter(1);
MtpString pathBuf;
int64_t fileLength;
- if (!mDatabase->getObjectFilePath(handle, pathBuf, fileLength))
- return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
- const char* filePath = (const char *)pathBuf;
+ int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength);
+ if (result != MTP_RESPONSE_OK)
+ return result;
+ const char* filePath = (const char *)pathBuf;
mtp_file_range mfr;
mfr.fd = open(filePath, O_RDONLY);
if (mfr.fd < 0) {
@@ -513,8 +514,9 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
parent = 0;
} else {
int64_t dummy;
- if (!mDatabase->getObjectFilePath(parent, path, dummy))
- return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
+ int result = mDatabase->getObjectFilePath(parent, path, dummy);
+ if (result != MTP_RESPONSE_OK)
+ return result;
}
// read only the fields we need
@@ -547,14 +549,11 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
path += "/";
path += (const char *)name;
- mDatabase->beginTransaction();
MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path,
format, parent, storageID, mSendObjectFileSize, modifiedTime);
if (handle == kInvalidObjectHandle) {
- mDatabase->rollbackTransaction();
return MTP_RESPONSE_GENERAL_ERROR;
}
- mDatabase->commitTransaction();
if (format == MTP_FORMAT_ASSOCIATION) {
mode_t mask = umask(0);
@@ -641,17 +640,16 @@ MtpResponseCode MtpServer::doDeleteObject() {
MtpString filePath;
int64_t fileLength;
- if (!mDatabase->getObjectFilePath(handle, filePath, fileLength))
- return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
-
- LOGV("deleting %s", (const char *)filePath);
- // one of these should work
- rmdir((const char *)filePath);
- unlink((const char *)filePath);
-
- mDatabase->deleteFile(handle);
-
- return MTP_RESPONSE_OK;
+ int result = mDatabase->getObjectFilePath(handle, filePath, fileLength);
+ if (result == MTP_RESPONSE_OK) {
+ LOGV("deleting %s", (const char *)filePath);
+ // one of these should work
+ rmdir((const char *)filePath);
+ unlink((const char *)filePath);
+ return mDatabase->deleteFile(handle);
+ } else {
+ return result;
+ }
}
MtpResponseCode MtpServer::doGetObjectPropDesc() {