Move MTP code to the android namespace

Change-Id: I5da48038fd5e4cdeefaeba42cdc74eb588b3448d
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-05-14 10:10:36 -04:00
parent 77b8e6149e
commit 8d3257a7dc
28 changed files with 109 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -19,9 +19,13 @@
#include "mtp.h"
namespace android {
class MtpDebug {
public:
static const char* getOperationCodeName(MtpOperationCode code);
};
}; // namespace android
#endif // _MTP_DEBUG_H

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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];

View File

@@ -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;
}
}