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.
23 #include "ProviderHelper.h"
24 #include "ByteArray.h"
30 namespace smartcard_service_api
32 class EXPORT FileObject : public ProviderHelper
39 int _select(const ByteArray &command);
42 ByteArray selectResponse;
43 bool setSelectResponse(const ByteArray &response);
46 static const int SUCCESS = 0;
47 static const int ERROR_ILLEGAL_STATE = -1;
48 static const int ERROR_ILLEGAL_REFERENCE = -2;
49 static const int ERROR_ILLEGAL_PARAMETER = -3;
50 static const int ERROR_SECURITY = -4;
51 static const int ERROR_OPERATION_NOT_SUPPORT = -5;
52 static const int ERROR_IO = -6;
53 static const int ERROR_UNKNOWN = -99;
55 static const unsigned int MF_FID = 0x003F;
57 FileObject(Channel *channel);
58 FileObject(Channel *channel, const ByteArray &selectResponse);
62 inline bool isClosed() const { return (opened == false); }
63 int select(const ByteArray &aid);
64 int select(const ByteArray &path, bool fromCurrentDF);
65 int select(unsigned int fid);
68 inline const ByteArray getSelectResponse() const { return selectResponse; }
70 const FCI *getFCI() const;
71 const FCP *getFCP() const;
73 int readRecord(unsigned int sfi, unsigned int recordId, Record &result);
74 int writeRecord(unsigned int sfi, const Record &record);
76 int searchRecord(unsigned int sfi, const ByteArray &searchParam, vector<int> &result);
78 int readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result);
79 int writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length);
82 } /* namespace smartcard_service_api */
83 #endif /* FILEOBJECT_H_ */