2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 /* standard library header */
23 /* SLP library header */
26 #include "ProviderHelper.h"
27 #include "ByteArray.h"
33 namespace smartcard_service_api
35 class FileObject : public ProviderHelper
42 int _select(const ByteArray &command);
45 ByteArray selectResponse;
46 bool setSelectResponse(const ByteArray &response);
49 static const int SUCCESS = 0;
50 static const int ERROR_ILLEGAL_STATE = -1;
51 static const int ERROR_ILLEGAL_REFERENCE = -2;
52 static const int ERROR_ILLEGAL_PARAMETER = -3;
53 static const int ERROR_SECURITY = -4;
54 static const int ERROR_OPERATION_NOT_SUPPORT = -5;
55 static const int ERROR_IO = -6;
56 static const int ERROR_UNKNOWN = -99;
58 static const unsigned int MF_FID = 0x003F;
60 FileObject(Channel *channel);
61 FileObject(Channel *channel, const ByteArray &selectResponse);
65 inline bool isClosed() const { return (opened == false); }
66 int select(const ByteArray &aid);
67 int select(const ByteArray &path, bool fromCurrentDF);
68 int select(unsigned int fid);
71 inline const ByteArray getSelectResponse() const { return selectResponse; }
73 const FCI *getFCI() const;
74 const FCP *getFCP() const;
76 int readRecord(unsigned int sfi, unsigned int recordId, Record &result);
77 int writeRecord(unsigned int sfi, const Record &record);
79 int searchRecord(unsigned int sfi, const ByteArray &searchParam, vector<int> &result);
81 int readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result);
82 int readBinary(unsigned int sfi, unsigned int length, ByteArray &result);
83 int writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length);
84 int writeBinary(unsigned int sfi, const ByteArray &data);
86 int readBinaryAll(unsigned int sfi, ByteArray &result);
89 } /* namespace smartcard_service_api */
90 #endif /* FILEOBJECT_H_ */