revise exported headers and cleanup headers
[platform/core/connectivity/smartcard-service.git] / common / include / APDUHelper.h
index 6a591d3..94ffd0a 100644 (file)
 #ifndef APDUHELPER_H_
 #define APDUHELPER_H_
 
-/* standard library header */
-
-/* SLP library header */
-
-/* local header */
+#include "Debug.h"
 #include "ByteArray.h"
 
 namespace smartcard_service_api
 {
-       class ResponseHelper
+       class EXPORT ResponseHelper
        {
        private:
                ByteArray response;
@@ -34,26 +30,48 @@ namespace smartcard_service_api
                int status;
                ByteArray dataField;
 
-               static int parseStatusWord(unsigned char *sw);
+               static int parseStatusWord(const unsigned char *sw);
+
        public:
+               static const int SUCCESS = 0;
+
+               static const int ERROR_UNKNOWN = -1;
+
+               static const int ERROR_NO_INFORMATION = -(0x6900);
+               static const int ERROR_COMMAND_INCOMPATIBLE = -(0x6981);
+               static const int ERROR_SECURITY_NOT_SATISFIED = -(0x6982);
+               static const int ERROR_AUTH_PIN_BLOCKED = -(0x6983);
+               static const int ERROR_REF_DATA_INVALID = -(0x6984);
+               static const int ERROR_CONDITION_NOT_SATIFIED = -(0x6985);
+               static const int ERROR_COMMAND_NOT_ALLOW = -(0x6986);
+
+               static const int ERROR_INCORRECT_PARAMETER = -(0x6a80);
+               static const int ERROR_FUNCTION_NOT_SUPPORT = -(0x6a81);
+               static const int ERROR_FILE_NOT_FOUND = -(0x6a82);
+               static const int ERROR_RECORD_NOT_FOUND = -(0x6a83);
+               static const int ERROR_NOT_ENOUGH_MEMORY = -(0x6a84);
+               static const int ERROR_INCORRECT_P1_P2 = -(0x6a86);
+               static const int ERROR_LC_INCONSISTENT = -(0x6a87);
+               static const int ERROR_REF_DATA_NOT_FOUND = -(0x6a88);
+
                ResponseHelper();
                ResponseHelper(const ByteArray &response);
                ~ResponseHelper();
 
                bool setResponse(const ByteArray &response);
-               int getStatus();
-               unsigned char getSW1();
-               unsigned char getSW2();
+               inline int getStatus() const { return status; }
+               inline unsigned char getSW1() const { return sw[0]; }
+               inline unsigned char getSW2() const { return sw[1]; }
 
 //             char *getErrorString();
-               ByteArray getDataField();
+               inline const ByteArray getDataField() const { return dataField; }
 
                static int getStatus(const ByteArray &response);
-               static ByteArray getDataField(const ByteArray &response);
+               static const ByteArray getDataField(const ByteArray &response);
 //             static char *getErrorString();
        };
 
-       class APDUCommand
+       class EXPORT APDUCommand
        {
        private:
                typedef struct _command_header_t
@@ -117,36 +135,39 @@ namespace smartcard_service_api
                static const unsigned char CLA_CHANNEL_STANDARD = (unsigned char)0x00;
                static const unsigned char CLA_CHANNEL_EXTENDED = (unsigned char)0x01;
 
+               static const unsigned int LE_MAX = -1;
+
                APDUCommand();
                ~APDUCommand();
 
-               bool setCommand(unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, ByteArray commandData, unsigned int maxResponseSize);
+               bool setCommand(unsigned char cla, unsigned char ins, unsigned char p1,
+                       unsigned char p2, const ByteArray &commandData, unsigned int maxResponseSize);
                bool setCommand(const ByteArray &command);
 
                bool setChannel(int type, int channelNum);
 
                void setCLA(unsigned char cla);
-               unsigned char getCLA();
+               unsigned char getCLA() const;
 
                void setINS(unsigned char ins);
-               unsigned char getINS();
+               unsigned char getINS() const;
 
                void setP1(unsigned char p1);
-               unsigned char getP1();
+               unsigned char getP1() const;
 
                void setP2(unsigned char p2);
-               unsigned char getP2();
+               unsigned char getP2() const;
 
                void setCommandData(const ByteArray &data);
-               ByteArray getCommandData();
+               const ByteArray getCommandData() const;
 
                void setMaxResponseSize(unsigned int maxResponseSize);
-               unsigned int setMaxResponseSize();
+               unsigned int getMaxResponseSize() const;
 
-               bool getBuffer(ByteArray &array);
+               bool getBuffer(ByteArray &array) const;
        };
 
-       class APDUHelper
+       class EXPORT APDUHelper
        {
        public:
                static const int COMMAND_OPEN_LOGICAL_CHANNEL = 1;
@@ -161,7 +182,8 @@ namespace smartcard_service_api
                static const int COMMAND_WRITE_BINARY = 10;
                static const int COMMAND_WRITE_RECORD = 11;
 
-               static ByteArray generateAPDU(int command, int channel, ByteArray data);
+               static const ByteArray generateAPDU(int command,
+                       int channel, const ByteArray &data);
        };
 
 } /* namespace smartcard_service_api */