From 8d3257a7dc10e1b3fda03e00f40d1b65d699ff23 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Fri, 14 May 2010 10:10:36 -0400 Subject: [PATCH] Move MTP code to the android namespace Change-Id: I5da48038fd5e4cdeefaeba42cdc74eb588b3448d Signed-off-by: Mike Lockwood --- media/mtp/MtpClient.cpp | 3 +++ media/mtp/MtpClient.h | 4 ++++ media/mtp/MtpDataPacket.cpp | 4 ++++ media/mtp/MtpDataPacket.h | 4 ++++ media/mtp/MtpDatabase.cpp | 5 ++++- media/mtp/MtpDatabase.h | 4 ++++ media/mtp/MtpDebug.cpp | 3 +++ media/mtp/MtpDebug.h | 4 ++++ media/mtp/MtpPacket.cpp | 4 ++++ media/mtp/MtpPacket.h | 10 ++++++++-- media/mtp/MtpRequestPacket.cpp | 4 ++++ media/mtp/MtpRequestPacket.h | 4 ++++ media/mtp/MtpResponsePacket.cpp | 3 +++ media/mtp/MtpResponsePacket.h | 4 ++++ media/mtp/MtpServer.cpp | 4 ++++ media/mtp/MtpServer.h | 4 ++++ media/mtp/MtpStorage.cpp | 3 +++ media/mtp/MtpStorage.h | 4 ++++ media/mtp/MtpStringBuffer.cpp | 3 +++ media/mtp/MtpStringBuffer.h | 4 ++++ media/mtp/MtpUtils.cpp | 4 +++- media/mtp/MtpUtils.h | 4 ++++ media/mtp/SqliteDatabase.cpp | 4 ++++ media/mtp/SqliteDatabase.h | 5 ++++- media/mtp/SqliteStatement.cpp | 4 ++++ media/mtp/SqliteStatement.h | 9 +++++++-- media/mtp/mtptest.cpp | 1 + media/mtp/ptptest.cpp | 4 +++- 28 files changed, 109 insertions(+), 8 deletions(-) diff --git a/media/mtp/MtpClient.cpp b/media/mtp/MtpClient.cpp index 5e4adb44edfdb..c0aacac4202d4 100644 --- a/media/mtp/MtpClient.cpp +++ b/media/mtp/MtpClient.cpp @@ -28,6 +28,8 @@ #include "MtpDebug.h" #include "MtpStringBuffer.h" +namespace android { + MtpClient::MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out, struct usb_endpoint *ep_intr) : mEndpointIn(ep_in), @@ -134,3 +136,4 @@ MtpResponseCode MtpClient::readResponse() { } } +} // namespace android diff --git a/media/mtp/MtpClient.h b/media/mtp/MtpClient.h index fbbd388e89e75..8e2d979df4ac1 100644 --- a/media/mtp/MtpClient.h +++ b/media/mtp/MtpClient.h @@ -24,6 +24,8 @@ #include "MtpUtils.h" +namespace android { + class MtpClient { private: struct usb_endpoint *mEndpointIn; @@ -56,4 +58,6 @@ private: }; +}; // namespace android + #endif // _MTP_CLIENT_H diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp index 8e7ea6e78659e..71dcaee716e04 100644 --- a/media/mtp/MtpDataPacket.cpp +++ b/media/mtp/MtpDataPacket.cpp @@ -21,6 +21,8 @@ #include "MtpDataPacket.h" #include "MtpStringBuffer.h" +namespace android { + MtpDataPacket::MtpDataPacket() : MtpPacket(512), mOffset(MTP_CONTAINER_HEADER_SIZE) @@ -294,3 +296,5 @@ int MtpDataPacket::write(struct usb_endpoint *ep) { } #endif // MTP_HOST + +} // namespace android diff --git a/media/mtp/MtpDataPacket.h b/media/mtp/MtpDataPacket.h index 3b18e4e4a1206..825ff45343910 100644 --- a/media/mtp/MtpDataPacket.h +++ b/media/mtp/MtpDataPacket.h @@ -20,6 +20,8 @@ #include "MtpPacket.h" #include "mtp.h" +namespace android { + class MtpDataPacket : public MtpPacket { private: // current offset for get/put methods @@ -86,4 +88,6 @@ public: inline bool hasData() const { return mPacketSize > MTP_CONTAINER_HEADER_SIZE; } }; +}; // namespace android + #endif // _MTP_DATA_PACKET_H diff --git a/media/mtp/MtpDatabase.cpp b/media/mtp/MtpDatabase.cpp index bb44ab622aec5..8f6c75d98c527 100644 --- a/media/mtp/MtpDatabase.cpp +++ b/media/mtp/MtpDatabase.cpp @@ -22,6 +22,8 @@ #include #include +namespace android { + #define ID_COLUMN 1 #define PATH_COLUMN 2 #define FORMAT_COLUMN 3 @@ -51,7 +53,6 @@ #define FILE_INSERT "INSERT INTO files VALUES(?,?,?,?,?,?,?,?);" #define FILE_DELETE "DELETE FROM files WHERE path = ?;" - struct PropertyTableEntry { MtpObjectProperty property; int type; @@ -384,3 +385,5 @@ printf("deleteFile %d\n", handle); packet.putUInt8(formFlag); // form, variable */ + +} // namespace android diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h index 66f70bdca9518..2a48155e4c725 100644 --- a/media/mtp/MtpDatabase.h +++ b/media/mtp/MtpDatabase.h @@ -21,6 +21,8 @@ #include "SqliteDatabase.h" #include "mtp.h" +namespace android { + class MtpDataPacket; class SqliteStatement; @@ -62,4 +64,6 @@ public: bool deleteFile(MtpObjectHandle handle); }; +}; // namespace android + #endif // _MTP_DATABASE_H diff --git a/media/mtp/MtpDebug.cpp b/media/mtp/MtpDebug.cpp index 6d0273df0ac1f..9ded6e2e4085c 100644 --- a/media/mtp/MtpDebug.cpp +++ b/media/mtp/MtpDebug.cpp @@ -16,6 +16,7 @@ #include "MtpDebug.h" +namespace android { struct OperationCodeEntry { const char* name; @@ -71,3 +72,5 @@ const char* MtpDebug::getOperationCodeName(MtpOperationCode code) { } return "*** UNKNOWN OPERATION ***"; } + +} // namespace android diff --git a/media/mtp/MtpDebug.h b/media/mtp/MtpDebug.h index bab79e97da1e6..289f5c7a14a27 100644 --- a/media/mtp/MtpDebug.h +++ b/media/mtp/MtpDebug.h @@ -19,9 +19,13 @@ #include "mtp.h" +namespace android { + class MtpDebug { public: static const char* getOperationCodeName(MtpOperationCode code); }; +}; // namespace android + #endif // _MTP_DEBUG_H diff --git a/media/mtp/MtpPacket.cpp b/media/mtp/MtpPacket.cpp index 26a946010d7aa..5b3e2af82e938 100644 --- a/media/mtp/MtpPacket.cpp +++ b/media/mtp/MtpPacket.cpp @@ -22,6 +22,8 @@ #include "MtpPacket.h" +namespace android { + MtpPacket::MtpPacket(int bufferSize) : mBuffer(NULL), mBufferSize(bufferSize), @@ -134,3 +136,5 @@ int MtpPacket::transfer(struct usb_endpoint *ep, void* buffer, int length) { return usb_endpoint_wait(usb_endpoint_get_device(ep), &ep_num); } #endif + +} // namespace android diff --git a/media/mtp/MtpPacket.h b/media/mtp/MtpPacket.h index 26a3c2489e2a7..6632c6e043224 100644 --- a/media/mtp/MtpPacket.h +++ b/media/mtp/MtpPacket.h @@ -17,13 +17,17 @@ #ifndef _MTP_PACKET_H #define _MTP_PACKET_H -class MtpStringBuffer; - #include "mtp.h" #include "MtpUtils.h" #include +struct usb_endpoint; + +namespace android { + +class MtpStringBuffer; + class MtpPacket { protected: @@ -65,4 +69,6 @@ protected: void putUInt32(int offset, uint32_t value); }; +}; // namespace android + #endif // _MTP_PACKET_H diff --git a/media/mtp/MtpRequestPacket.cpp b/media/mtp/MtpRequestPacket.cpp index ed4cc9da60b6e..e3a720cede85c 100644 --- a/media/mtp/MtpRequestPacket.cpp +++ b/media/mtp/MtpRequestPacket.cpp @@ -20,6 +20,8 @@ #include "MtpRequestPacket.h" +namespace android { + MtpRequestPacket::MtpRequestPacket() : MtpPacket(512) { @@ -48,3 +50,5 @@ int MtpRequestPacket::write(struct usb_endpoint *ep) return transfer(ep, mBuffer, mPacketSize); } #endif + +} // namespace android diff --git a/media/mtp/MtpRequestPacket.h b/media/mtp/MtpRequestPacket.h index d44d1dc9e534f..df518f267f4a9 100644 --- a/media/mtp/MtpRequestPacket.h +++ b/media/mtp/MtpRequestPacket.h @@ -20,6 +20,8 @@ #include "MtpPacket.h" #include "mtp.h" +namespace android { + class MtpRequestPacket : public MtpPacket { public: @@ -41,4 +43,6 @@ public: { return setContainerCode(code); } }; +}; // namespace android + #endif // _MTP_REQUEST_PACKET_H diff --git a/media/mtp/MtpResponsePacket.cpp b/media/mtp/MtpResponsePacket.cpp index 6ebac9e2fe7bd..a1979d7aa5bf1 100644 --- a/media/mtp/MtpResponsePacket.cpp +++ b/media/mtp/MtpResponsePacket.cpp @@ -20,6 +20,8 @@ #include "MtpResponsePacket.h" +namespace android { + MtpResponsePacket::MtpResponsePacket() : MtpPacket(512) { @@ -49,4 +51,5 @@ int MtpResponsePacket::read(struct usb_endpoint *ep) { } #endif +} // namespace android diff --git a/media/mtp/MtpResponsePacket.h b/media/mtp/MtpResponsePacket.h index 84c302496369f..373f8f9aca293 100644 --- a/media/mtp/MtpResponsePacket.h +++ b/media/mtp/MtpResponsePacket.h @@ -20,6 +20,8 @@ #include "MtpPacket.h" #include "mtp.h" +namespace android { + class MtpResponsePacket : public MtpPacket { public: @@ -41,4 +43,6 @@ public: { return setContainerCode(code); } }; +}; // namespace android + #endif // _MTP_RESPONSE_PACKET_H diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index 57b84ac390cdc..d8689262cf8da 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -30,6 +30,8 @@ #include "f_mtp.h" +namespace android { + static const MtpOperationCode kSupportedOperationCodes[] = { MTP_OPERATION_GET_DEVICE_INFO, MTP_OPERATION_OPEN_SESSION, @@ -514,3 +516,5 @@ MtpResponseCode MtpServer::doGetObjectPropDesc() { return -1; } + +} // namespace android diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h index 81b1c81b403d4..ca570f02deff6 100644 --- a/media/mtp/MtpServer.h +++ b/media/mtp/MtpServer.h @@ -24,6 +24,8 @@ #include "MtpUtils.h" +namespace android { + class MtpStorage; class MtpDatabase; @@ -83,4 +85,6 @@ private: MtpResponseCode doGetObjectPropDesc(); }; +}; // namespace android + #endif // _MTP_SERVER_H diff --git a/media/mtp/MtpStorage.cpp b/media/mtp/MtpStorage.cpp index bbdef51504677..d4de81957b31e 100644 --- a/media/mtp/MtpStorage.cpp +++ b/media/mtp/MtpStorage.cpp @@ -27,6 +27,7 @@ #include #include +namespace android { MtpStorage::MtpStorage(MtpStorageID id, const char* filePath, MtpDatabase* db) : mStorageID(id), @@ -133,3 +134,5 @@ int MtpStorage::scanDirectory(const char* path, MtpObjectHandle parent) closedir(dir); return 0; } + +} // namespace android diff --git a/media/mtp/MtpStorage.h b/media/mtp/MtpStorage.h index 011cb81c44554..b1d4408c4877a 100644 --- a/media/mtp/MtpStorage.h +++ b/media/mtp/MtpStorage.h @@ -19,6 +19,8 @@ #include "mtp.h" +namespace android { + class MtpDatabase; class SqliteStatement; @@ -49,4 +51,6 @@ private: int scanDirectory(const char* path, MtpObjectHandle parent); }; +}; // namespace android + #endif // _MTP_STORAGE_H diff --git a/media/mtp/MtpStringBuffer.cpp b/media/mtp/MtpStringBuffer.cpp index 6b55c44be8806..8694575e51381 100644 --- a/media/mtp/MtpStringBuffer.cpp +++ b/media/mtp/MtpStringBuffer.cpp @@ -19,6 +19,7 @@ #include "MtpDataPacket.h" #include "MtpStringBuffer.h" +namespace android { MtpStringBuffer::MtpStringBuffer() : mCharCount(0), @@ -131,3 +132,5 @@ void MtpStringBuffer::writeToPacket(MtpDataPacket* packet) const { packet->putUInt16(ch); } } + +} // namespace android diff --git a/media/mtp/MtpStringBuffer.h b/media/mtp/MtpStringBuffer.h index 46138d2e60491..4641c3f7fa79e 100644 --- a/media/mtp/MtpStringBuffer.h +++ b/media/mtp/MtpStringBuffer.h @@ -19,6 +19,8 @@ #include +namespace android { + class MtpDataPacket; // Represents a utf8 string, with a maximum of 255 characters @@ -47,4 +49,6 @@ public: inline operator const char*() const { return (const char *)mBuffer; } }; +}; // namespace android + #endif // _MTP_STRING_BUFFER_H diff --git a/media/mtp/MtpUtils.cpp b/media/mtp/MtpUtils.cpp index a472781982d8c..77692cd6ea6be 100644 --- a/media/mtp/MtpUtils.cpp +++ b/media/mtp/MtpUtils.cpp @@ -19,6 +19,8 @@ #include #include "MtpUtils.h" +namespace android { + /* DateTime strings follow a compatible subset of the definition found in ISO 8601, and take the form of a Unicode string formatted as: "YYYYMMDDThhmmss.s". In this @@ -70,4 +72,4 @@ void formatDateTime(time_t seconds, char* buffer, int bufferLength) { tm.tm_year + 1900, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } - +} // namespace android diff --git a/media/mtp/MtpUtils.h b/media/mtp/MtpUtils.h index 2e80762ab2777..edd78cb238b35 100644 --- a/media/mtp/MtpUtils.h +++ b/media/mtp/MtpUtils.h @@ -20,6 +20,8 @@ #include "utils/String8.h" #include "utils/Vector.h" +namespace android { + class MtpStorage; typedef android::Vector MtpStorageList; @@ -31,4 +33,6 @@ typedef android::String8 MtpString; bool parseDateTime(const char* dateTime, time_t& outSeconds); void formatDateTime(time_t seconds, char* buffer, int bufferLength); +}; // namespace android + #endif // _MTP_UTILS_H diff --git a/media/mtp/SqliteDatabase.cpp b/media/mtp/SqliteDatabase.cpp index 5a70dfe753b47..e1156301406a4 100644 --- a/media/mtp/SqliteDatabase.cpp +++ b/media/mtp/SqliteDatabase.cpp @@ -20,6 +20,8 @@ #include #include +namespace android { + SqliteDatabase::SqliteDatabase() : mDatabaseHandle(NULL) { @@ -79,3 +81,5 @@ void SqliteDatabase::setVersion(int version) { snprintf(buffer, sizeof(buffer), "PRAGMA user_version = %d", version); exec(buffer); } + +} // namespace android diff --git a/media/mtp/SqliteDatabase.h b/media/mtp/SqliteDatabase.h index 841b2b79518bf..56dd9dd86647b 100644 --- a/media/mtp/SqliteDatabase.h +++ b/media/mtp/SqliteDatabase.h @@ -19,6 +19,8 @@ typedef struct sqlite3 sqlite3; +namespace android { + class SqliteDatabase { private: sqlite3* mDatabaseHandle; @@ -41,7 +43,8 @@ public: void setVersion(int version); inline sqlite3* getDatabaseHandle() const { return mDatabaseHandle; } - }; +}; // namespace android + #endif // _SQLITE_DATABASE_H diff --git a/media/mtp/SqliteStatement.cpp b/media/mtp/SqliteStatement.cpp index e568928f57785..e1300b6d76f05 100644 --- a/media/mtp/SqliteStatement.cpp +++ b/media/mtp/SqliteStatement.cpp @@ -20,6 +20,8 @@ #include #include +namespace android { + SqliteStatement::SqliteStatement(SqliteDatabase* db) : mDatabaseHandle(db->getDatabaseHandle()), mStatement(NULL), @@ -75,3 +77,5 @@ int64_t SqliteStatement::getColumnInt64(int column) { const char* SqliteStatement::getColumnString(int column) { return (const char *)sqlite3_column_text(mStatement, column); } + +} // namespace android diff --git a/media/mtp/SqliteStatement.h b/media/mtp/SqliteStatement.h index 0fd8a1ecaea4d..c0ebfff2ec4d0 100644 --- a/media/mtp/SqliteStatement.h +++ b/media/mtp/SqliteStatement.h @@ -17,11 +17,14 @@ #ifndef _SQLITE_STATEMENT_H #define _SQLITE_STATEMENT_H +#include + typedef struct sqlite3 sqlite3; typedef struct sqlite3_stmt sqlite3_stmt; -class SqliteDatabase; -#include +namespace android { + +class SqliteDatabase; class SqliteStatement { private: @@ -48,4 +51,6 @@ public: inline bool isDone() const { return mDone; } }; +}; // namespace android + #endif // _SQLITE_STATEMENT_H diff --git a/media/mtp/mtptest.cpp b/media/mtp/mtptest.cpp index 899645847798e..89aa622e244a9 100644 --- a/media/mtp/mtptest.cpp +++ b/media/mtp/mtptest.cpp @@ -25,6 +25,7 @@ #include "MtpServer.h" #include "MtpStorage.h" +using namespace android; static void enable_usb_function(const char* name, bool enable) { char path[PATH_MAX]; diff --git a/media/mtp/ptptest.cpp b/media/mtp/ptptest.cpp index 1218fa6e6fc09..3922b61967e73 100644 --- a/media/mtp/ptptest.cpp +++ b/media/mtp/ptptest.cpp @@ -23,6 +23,8 @@ #include "MtpClient.h" +using namespace android; + static struct usb_device *sCameraDevice = NULL; static int sCameraInterface = 0; static MtpClient *sClient = NULL; @@ -131,4 +133,4 @@ int main(int argc, char* argv[]) } return 0; -} \ No newline at end of file +}