//
//  HancomProductAuth.h
//  HancomProductAuth
//
//  Created by Lee Jong Gyu on 2013. 11. 20..
//  Copyright (c) 2013년 hancom. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
	HancomProductAuthOK					= 1000,
	HancomProductAuthError				= 1001,	/* Request Error */
	HancomProductAuthTimeOverError		= 1002,	/* Request Error - Time Over */
	HancomProductAuthInvalidDataError	= 1003,	/* Request Error - Invalid Data */
	HancomProductAuthDuplicateAuthError = 1004,	/* Request Error - Duplicate auth for day*/
	HancomProductAuthNoMatchError		= 1005,	/* Request Error - no match serial and user's input serial */
	HancomProductAuthDbConnectionError	= 1006,	/* Database Connection Error */
	HancomProductAuthDbInsertError		= 1007,	/* Database Insert Error */
	HancomProductAuthDbSelectError		= 1008,	/* Database Select Error */
	HancomProductAuthNoConnectError		= 1009	/* Can't connect server */
} HancomProductAuthResult;

@protocol HancomProductAuthDelegate;

@interface HancomProductAuth : NSObject {
	id<HancomProductAuthDelegate> _delegate;
}

- (id)initWithDelegate:(id<HancomProductAuthDelegate>)delegate;
- (void)authWithServer:(NSString*)server serialNumber:(NSString*)sn;
- (void)authWithServer:(NSString*)server serialNumber:(NSString*)sn systemSn:(NSString*)systemSn;

+ (bool)isValidAuthKey:(NSString*)authKey;
+ (bool)isValidAuthKey:(NSString*)authKey systemSn:(NSString*)systemSn;
+ (NSString*)loadAuthKey;
+ (bool)saveAuthKey:(NSString*)authKey;
+ (NSString*)getSerialNumberFromAuthKey:(NSString*)authKey;
+ (NSString*)getInstallInfoFromSerialNumber:(NSString*)sn;
+ (NSString*)getAuthKeyFromSerialNumber:(NSString*)sn;

@end

@protocol HancomProductAuthDelegate <NSObject>
- (void)productAuth:(HancomProductAuth*)productAuth
		  didFinish:(HancomProductAuthResult)result
			authKey:(NSString*)key
	   createdCount:(int)count;
@end
