diff options
| author | 2010-05-14 10:10:36 -0400 | |
|---|---|---|
| committer | 2010-05-14 10:10:36 -0400 | |
| commit | 8d3257a7dc10e1b3fda03e00f40d1b65d699ff23 (patch) | |
| tree | 8a84411c35a1c47348786f5e034a365f51647d42 | |
| parent | 77b8e6149e497cedbd98c7fae83886be0d6fb215 (diff) | |
Move MTP code to the android namespace
Change-Id: I5da48038fd5e4cdeefaeba42cdc74eb588b3448d
Signed-off-by: Mike Lockwood <lockwood@android.com>
28 files changed, 109 insertions, 8 deletions
diff --git a/media/mtp/MtpClient.cpp b/media/mtp/MtpClient.cpp index 5e4adb44edfd..c0aacac4202d 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 fbbd388e89e7..8e2d979df4ac 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 8e7ea6e78659..71dcaee716e0 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 3b18e4e4a120..825ff4534391 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 bb44ab622aec..8f6c75d98c52 100644 --- a/media/mtp/MtpDatabase.cpp +++ b/media/mtp/MtpDatabase.cpp @@ -22,6 +22,8 @@  #include <stdio.h>  #include <sqlite3.h> +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 66f70bdca951..2a48155e4c72 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 6d0273df0ac1..9ded6e2e4085 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 bab79e97da1e..289f5c7a14a2 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 26a946010d7a..5b3e2af82e93 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 26a3c2489e2a..6632c6e04322 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 <stdint.h> +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 ed4cc9da60b6..e3a720cede85 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 d44d1dc9e534..df518f267f4a 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 6ebac9e2fe7b..a1979d7aa5bf 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 84c302496369..373f8f9aca29 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 57b84ac390cd..d8689262cf8d 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 81b1c81b403d..ca570f02deff 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 bbdef5150467..d4de81957b31 100644 --- a/media/mtp/MtpStorage.cpp +++ b/media/mtp/MtpStorage.cpp @@ -27,6 +27,7 @@  #include <stdio.h>  #include <limits.h> +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 011cb81c4455..b1d4408c4877 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 6b55c44be880..8694575e5138 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 46138d2e6049..4641c3f7fa79 100644 --- a/media/mtp/MtpStringBuffer.h +++ b/media/mtp/MtpStringBuffer.h @@ -19,6 +19,8 @@  #include <stdint.h> +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 a472781982d8..77692cd6ea6b 100644 --- a/media/mtp/MtpUtils.cpp +++ b/media/mtp/MtpUtils.cpp @@ -19,6 +19,8 @@  #include <cutils/tztime.h>  #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 2e80762ab277..edd78cb238b3 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<MtpStorage *> 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 5a70dfe753b4..e1156301406a 100644 --- a/media/mtp/SqliteDatabase.cpp +++ b/media/mtp/SqliteDatabase.cpp @@ -20,6 +20,8 @@  #include <stdio.h>  #include <sqlite3.h> +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 841b2b79518b..56dd9dd86647 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 e568928f5778..e1300b6d76f0 100644 --- a/media/mtp/SqliteStatement.cpp +++ b/media/mtp/SqliteStatement.cpp @@ -20,6 +20,8 @@  #include <stdio.h>  #include <sqlite3.h> +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 0fd8a1ecaea4..c0ebfff2ec4d 100644 --- a/media/mtp/SqliteStatement.h +++ b/media/mtp/SqliteStatement.h @@ -17,11 +17,14 @@  #ifndef _SQLITE_STATEMENT_H  #define _SQLITE_STATEMENT_H +#include <stdint.h> +  typedef struct sqlite3 sqlite3;  typedef struct sqlite3_stmt sqlite3_stmt; -class SqliteDatabase; -#include <stdint.h> +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 899645847798..89aa622e244a 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 1218fa6e6fc0..3922b61967e7 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 +}  |