blob: a2b8ca2a1ea602aae737e10b3a3fd2827edf2a38 [file] [log] [blame]
bigbiff bigbiffc7eee6f2014-09-02 18:59:01 -04001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
17 */
18
19#include "MtpDebug.h"
20#include "MtpDataPacket.h"
21#include "MtpStorageInfo.h"
22#include "MtpStringBuffer.h"
23
24MtpStorageInfo::MtpStorageInfo(MtpStorageID id)
25 : mStorageID(id),
26 mStorageType(0),
27 mFileSystemType(0),
28 mAccessCapability(0),
29 mMaxCapacity(0),
30 mFreeSpaceBytes(0),
31 mFreeSpaceObjects(0),
32 mStorageDescription(NULL),
33 mVolumeIdentifier(NULL)
34{
35}
36
37MtpStorageInfo::~MtpStorageInfo() {
38 if (mStorageDescription)
39 free(mStorageDescription);
40 if (mVolumeIdentifier)
41 free(mVolumeIdentifier);
42}
43
44void MtpStorageInfo::read(MtpDataPacket& packet) {
45 MtpStringBuffer string;
46
47 // read the device info
48 mStorageType = packet.getUInt16();
49 mFileSystemType = packet.getUInt16();
50 mAccessCapability = packet.getUInt16();
51 mMaxCapacity = packet.getUInt64();
52 mFreeSpaceBytes = packet.getUInt64();
53 mFreeSpaceObjects = packet.getUInt32();
54
55 packet.getString(string);
56 mStorageDescription = strdup((const char *)string);
57 packet.getString(string);
58 mVolumeIdentifier = strdup((const char *)string);
59}
60
61void MtpStorageInfo::print() {
62 MTPI("Storage Info %08X:\n\tmStorageType: %d\n\tmFileSystemType: %d\n\tmAccessCapability: %d\n",
63 mStorageID, mStorageType, mFileSystemType, mAccessCapability);
64 MTPI("\tmMaxCapacity: %lld\n\tmFreeSpaceBytes: %lld\n\tmFreeSpaceObjects: %d\n",
65 mMaxCapacity, mFreeSpaceBytes, mFreeSpaceObjects);
66 MTPI("\tmStorageDescription: %s\n\tmVolumeIdentifier: %s\n",
67 mStorageDescription, mVolumeIdentifier);
68}
69