Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | #include "MtpDebug.h" |
| 18 | |
| 19 | |
| 20 | struct OperationCodeEntry { |
| 21 | const char* name; |
| 22 | MtpOperationCode code; |
| 23 | }; |
| 24 | |
| 25 | static const OperationCodeEntry sOperationCodes[] = { |
| 26 | { "MTP_OPERATION_GET_DEVICE_INFO", 0x1001 }, |
| 27 | { "MTP_OPERATION_OPEN_SESSION", 0x1002 }, |
| 28 | { "MTP_OPERATION_CLOSE_SESSION", 0x1003 }, |
| 29 | { "MTP_OPERATION_GET_STORAGE_IDS", 0x1004 }, |
| 30 | { "MTP_OPERATION_GET_STORAGE_INFO", 0x1005 }, |
| 31 | { "MTP_OPERATION_GET_NUM_OBJECTS", 0x1006 }, |
| 32 | { "MTP_OPERATION_GET_OBJECT_HANDLES", 0x1007 }, |
| 33 | { "MTP_OPERATION_GET_OBJECT_INFO", 0x1008 }, |
| 34 | { "MTP_OPERATION_GET_OBJECT", 0x1009 }, |
| 35 | { "MTP_OPERATION_GET_THUMB", 0x100A }, |
| 36 | { "MTP_OPERATION_DELETE_OBJECT", 0x100B }, |
| 37 | { "MTP_OPERATION_SEND_OBJECT_INFO", 0x100C }, |
| 38 | { "MTP_OPERATION_SEND_OBJECT", 0x100D }, |
| 39 | { "MTP_OPERATION_INITIATE_CAPTURE", 0x100E }, |
| 40 | { "MTP_OPERATION_FORMAT_STORE", 0x100F }, |
| 41 | { "MTP_OPERATION_RESET_DEVICE", 0x1010 }, |
| 42 | { "MTP_OPERATION_SELF_TEST", 0x1011 }, |
| 43 | { "MTP_OPERATION_SET_OBJECT_PROTECTION", 0x1012 }, |
| 44 | { "MTP_OPERATION_POWER_DOWN", 0x1013 }, |
| 45 | { "MTP_OPERATION_GET_DEVICE_PROP_DESC", 0x1014 }, |
| 46 | { "MTP_OPERATION_GET_DEVICE_PROP_VALUE", 0x1015 }, |
| 47 | { "MTP_OPERATION_SET_DEVICE_PROP_VALUE", 0x1016 }, |
| 48 | { "MTP_OPERATION_RESET_DEVICE_PROP_VALUE", 0x1017 }, |
| 49 | { "MTP_OPERATION_TERMINATE_OPEN_CAPTURE", 0x1018 }, |
| 50 | { "MTP_OPERATION_MOVE_OBJECT", 0x1019 }, |
| 51 | { "MTP_OPERATION_COPY_OBJECT", 0x101A }, |
| 52 | { "MTP_OPERATION_GET_PARTIAL_OBJECT", 0x101B }, |
| 53 | { "MTP_OPERATION_INITIATE_OPEN_CAPTURE", 0x101C }, |
| 54 | { "MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED", 0x9801 }, |
| 55 | { "MTP_OPERATION_GET_OBJECT_PROP_DESC", 0x9802 }, |
| 56 | { "MTP_OPERATION_GET_OBJECT_PROP_VALUE", 0x9803 }, |
| 57 | { "MTP_OPERATION_SET_OBJECT_PROP_VALUE", 0x9804 }, |
| 58 | { "MTP_OPERATION_GET_OBJECT_REFERENCES", 0x9810 }, |
| 59 | { "MTP_OPERATION_SET_OBJECT_REFERENCES", 0x9811 }, |
| 60 | { "MTP_OPERATION_SKIP", 0x9820 }, |
| 61 | { 0, 0 }, |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | const char* MtpDebug::getOperationCodeName(MtpOperationCode code) { |
| 66 | const OperationCodeEntry* entry = sOperationCodes; |
| 67 | while (entry->name) { |
| 68 | if (entry->code == code) |
| 69 | return entry->name; |
| 70 | entry++; |
| 71 | } |
| 72 | return "*** UNKNOWN OPERATION ***"; |
| 73 | } |