/***************************************************************************
                Protocol Header ( Protocol.h )
                -----------------------------------------
	begin      : 2013/02/23
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
	email      : dev1@solbox.com
	version    : 3.2.0

    CopyRight(C) 2011 Solbox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#ifndef	__RC_MMNGD_PROTOCOL_H__
#define	__RC_MMNGD_PROTOCOL_H__

// protocol
#define ID_DELIMITER	"@"
/// Client <-> rc_mngd
//// XML
typedef struct _s_message_header_xml 
{
	uint32_t	ulBodyLength;
	_s_message_header_xml ()
		:  ulBodyLength(-1)	{};
} MgeHeaderXML;

///// XML name
#define XML_STR_ROOT							"CloudStorage"
#define XML_STR_JOB								"Job"
#define XML_STR_JOB_TYPE						"Type"
#define XML_STR_JOB_TYPE_LIST					"List"
#define XML_STR_USER_ID							"UserID"
#define XML_STR_USER_SEQ						"USER_SEQ"
#define XML_STR_USER_PASSWORD					"Password"
#define XML_STR_SVC_ID							"ServiceID"
#define XML_STR_SVC_SEQ							"SVC_SEQ"
#define XML_STR_SVC_STGSIZE						"StgSize"
#define XML_STR_SVC_SERVICEDATE					"ServiceDate"
#define XML_STR_SVC_START_DATE					"StartDate"
#define XML_STR_SVC_END_DATE					"EndDate"
#define XML_STR_SVC_AUTHSTRING					"SvcAuthString"
#define XML_STR_SVC_PRIVATEKEY					"SvcPrivatekey"
#define XML_STR_SVC_REPLICA						"Replica"
#define XML_STR_SVC_URIIGNORECASE				"UriIgnoreCase"
#define XML_STR_SVC_URIIGNORECASEFRORCE			"UriIgnoreCaseForce"
#define XML_STR_SVC_DELFILEKEEPTIME				"DelFileKeepTime"
#define XML_STR_SVC_USEDSIZECALCDEPTH			"UsedSizeCalcDepth"
#define XML_STR_SVC_MASTERSERVICEID				"MasterServiceID"
#define XML_STR_SVC_DOMAIN						"Service_Domain"
#define XML_STR_SVC_SYNC_LINK					"SyncLink"
#define XML_STR_SVC_MOVE_REQ					"MoveRequest"
#define XML_STR_SVC_MOVE_COPM					"MoveComplete"
#define XML_STR_ETC								"Etc"
#define XML_STR_VOLUME_ID						"VolumeID"
#define XML_STR_VOLUME_SEQ						"VolumeSEQ"
#define XML_STR_TRAFFICLIMIT_YN					"TrafficLimit_YN"
#define XML_STR_TRAFFICLIMIT					"TrafficLimit"
#define XML_STR_SVC_CUSTOMAUTH					"CustomAuth"
#define XML_STR_CUSTOMAUTH_YN					"CustomAuth_YN"
#define XML_STR_CUSTOMAUTH_MODE					"CustomAuth_Mode"
#define XML_STR_AUTHSERVER						"AuthServer"
#define XML_STR_AUTHPATH						"AuthPath"
#define XML_STR_AUTHPORT						"AuthPort"
#define XML_STR_AUTHTIMEOUT						"AuthTimeOut"
#define XML_STR_BILLSERVER						"BillServer"
#define XML_STR_BILLPATH						"BillPath"
#define XML_STR_BILLPORT						"BillPort"
#define XML_STR_BILLTIMEOUT						"BillTimeOut"
#define XML_STR_SVC_STATUS						"ServiceStatus"	
#define XML_STR_STATUSCODE						"StatusCode"
#define XML_STR_RESULT							"Result"
#define XML_STR_RESULT_CODE						"ResultCode"
#define XML_STR_SELF_RCTS						"SelfRCTS"
#define XML_STR_LINK_MASTER_YN					"Master_YN"
#define XML_STR_LINK_USER_SEQ					"LinkUserSeq"
#define XML_STR_LINK_SERVICE_SEQ				"LinkServiceSeq"
#define XML_STR_LINK_RCTS						"LinkRCTS"
#define XML_STR_LINK_CODE						"LinkCode"
#define XML_STR_LINK_ONE_WAY					"LinkOneWay"
#define XML_STR_MOVE_NOW_RCTS					"NowRCTS"
#define XML_STR_MOVE_NEW_RCTS					"NewRCTS"
#define XML_STR_FILE_EXIST						"Exist"
#define XML_STR_FILE_MKDIR						"mkdir"
#define XML_STR_FILE_FRONT_10M_MD5				"Front_10M_MD5"
#define XML_STR_FILE_TOTO_EXTRACT				"TotoExtract"
#define XML_STR_FILE_TOTO_EXTRACT_WITHPLATFORM	XML_STR_FILE_TOTO_EXTRACT"_withplatform"
#define XML_STR_FILE_URI						"URI"
#define XML_STR_FILE_SIZE						"FileSize"
#define XML_STR_FILE_10M_MD5					"10M_MD5"
#define XML_STR_TOTO_MD5						"Toto_MD5"
#define XML_STR_TOTO_FILECHECKSUM				"Toto_fileChecksum"
#define XML_STR_TOTO_DNACHKKEY					"Toto_DnaCheckKey"


///// XML type
#define XML_STR_TYPE_OPEN						"Open"
#define XML_STR_TYPE_OPEN_N_SYNC				"OpenS"
#define XML_STR_TYPE_MOVE						"Move"
#define XML_STR_TYPE_MOVE_N_SYNC				"MoveS"
#define XML_STR_TYPE_CHANGE						"Change"
#define XML_STR_TYPE_FILE						"File"


//// SDK
#define MaxSizeOfTID          52
#define MaxSizeOfIssuer       128
#define MaxSizeOfSID          128

#define SDK_DELIMITER		0x1b

typedef struct _s_message_header_sdk 
{
	char		szTransactionID[MaxSizeOfTID];
	uint32_t	ulMode;
	char		szIssuer[MaxSizeOfIssuer];
	char		szServiceID[MaxSizeOfSID];
	uint32_t	ulResult;
	uint32_t	ulBodyLength;
	_s_message_header_sdk ()
		: ulMode(-1), ulResult(-1), ulBodyLength(-1)
	{ 
		memset(szTransactionID, 0, sizeof szTransactionID);	
		memset(szIssuer, 0, sizeof szIssuer); 
		memset(szServiceID, 0, sizeof szServiceID);
	};
} MgeHeaderSDK;

typedef struct _s_req_sdk_sp_info_t
{
	char szSpUserSeq[16];
	char szSpUserId[32];
	char szSpUserPassword[33];
	char szSpSvcTranId[32];
	char szSpSvcId[32];
	char szSpSvcBeginDate[32];
	char szSpSvcEndDate[32];
	char szInitialVector[28];
	char szPrivateKey[28];
	char szMaxBandwidth[38];
	char szVolQuota[52];
	char szSyncYN[2];
	_s_req_sdk_sp_info_t()
	{
		memset(szSpUserSeq, 0, sizeof szSpUserSeq); memset(szSpUserId, 0, sizeof szSpUserId); 
		memset(szSpUserPassword, 0, sizeof szSpUserPassword); memset(szSpSvcTranId, 0, sizeof szSpSvcTranId); 
		memset(szSpSvcId, 0, sizeof szSpSvcId); memset(szSpSvcBeginDate, 0, sizeof szSpSvcBeginDate); 
		memset(szSpSvcEndDate, 0, sizeof szSpSvcEndDate); memset(szInitialVector, 0, sizeof szInitialVector); 
		memset(szPrivateKey, 0, sizeof szPrivateKey); memset(szMaxBandwidth, 0, sizeof szMaxBandwidth); 
		memset(szVolQuota, 0, sizeof szVolQuota); memset(szSyncYN, 0, sizeof szSyncYN); 
	}

} SDKReqBodySpInfo;

///// body tyep
#define SDK_REQ_OPEN_SERVICE				0x0002 // old : MSG_MODE_CCSYNC_RCSYNC_DATA_INPUT
#define SDK_REQ_CHG_USER_INFO				0x001a // old : MSG_MODE_CCSYNC_RCSYNC_CHANGE_USER_DATA
#define SDK_REQ_CHG_STORAGE					0x0201 // old : MSG_MODE_CCSYNC_RCSYNC_CHANGE_STORAGE
#define SDK_REQ_CHG_BANDWIDTH				0x0204 // old : MSG_MODE_CCSYNC_RCSYNC_CHANGE_BANDWIDTH
#define SDK_REQ_CHG_PERIOD					0x0207 // old : MSG_MODE_CCSYNC_RCSYNC_CHANGE_PERIOD
#define SDK_REQ_CHG_AUTHINFO				0x020a // old : MSG_MODE_CCSYNC_RCSYNC_CHANGE_AUTHINFO
#define SDK_REQ_VOLUME_INFO					0x0012 // old : MSG_MODE_SPCONS_RCTRAN_VOLUME_SIZE
#define SDK_REQ_SET_ANONY_DIR				0x0014 // old : MSG_MODE_SPCONS_RCTRAN_SET_ANONY				
#define SDK_REQ_UNSET_ANONY_DIR				0x0018 // old : MSG_MODE_SPCONS_RCTRAN_UNSET_ANONY
#define SDK_REQ_ANONY_DIR					0x0030 // old : MSG_MODE_SPCONS_RCTRAN_RETRIVE_ANONY

/////	Response code	
#define SDK_RES_OK_ALL_PASSED				0x1000 // old : OK_ALL_PASSED
#define SDK_RES_SERVER_ERR					0x9000 // old : INT_ODINARY_STATE

//// ETC
#define MAX_SIZE_OF_USERID		64
#define MAX_SIZE_OF_FILENAME	2048
#define MAX_SIZE_OF_FILESIZE	64
#define MAX_SIZE_OF_HASH		128

typedef struct _s_message_header_etc 
{
	uint32_t op_num;
	uint32_t op_ret_code;	// 요청시 0 세팅
	_s_message_header_etc ()
		: op_num(-1), op_ret_code(-1)	{};
} MgeHeaderEtc;

////// body type
#define ETC_REQ_GETFILE_HASH_MD5_10MB		100	// old : REQ_GETFILE_HASH_MD5_10MB

typedef struct _s_etc_body_md5_10
{
	char userid[MAX_SIZE_OF_USERID];		// 요청 userid
	char uri[MAX_SIZE_OF_FILENAME];			// 요청 uri
	char filesize[MAX_SIZE_OF_FILESIZE];	// 요청 컨텐츠의 파일 크기

	_s_etc_body_md5_10 () 
	{ 
		memset(userid, 0, sizeof userid); 
		memset(uri, 0, sizeof userid); 
		memset(filesize, 0, sizeof filesize); 
	};
} EtcReqBodyMD5_10MB;

/////	Response code
#define ETC_RES_SUCCESS				0 // old : RESP_SUCCESS

/////	Response  type
typedef struct _s_etc_md5_10_res {
	char userid[MAX_SIZE_OF_USERID];		// 요청 userid 그대로
	char uri[MAX_SIZE_OF_FILENAME];			// 요청 uri 그대로
	char hash[MAX_SIZE_OF_HASH];			// 추출 해쉬 값

	_s_etc_md5_10_res() 
	{ 
		memset(userid, 0, sizeof userid);
		memset(uri, 0, sizeof uri);
		memset(hash, 0, sizeof hash);
	};
} EtcResBodyMD5_10MB;

/// RCTS <-> FHS
//// RCTS -> vmasd
///// body tyep
#define		BROADCAST_MKDIR_SERVICE_ROOT	0x0005 // old : MSG_MODE_RCTRAN_VMA_SUBROOT_CREATE

///// code
#define OK_ALL_PASSED					SDK_RES_OK_ALL_PASSED

//// RCTS -> opendav-listener
///// body tyep
#define		BROADCAST_ANONY_SET				0x0015 // old : MSG_MODE_RCTRAN_APACHE_SET_ANONY
#define		BROADCAST_ANONY_UNSET			0x0019 // old : MSG_MODE_RCTRAN_APACHE_UNSET_ANONY

#define MaxSizeOfRCID         32
typedef struct _s_broadcast_message_header 
{
	char		szTransactionID[MaxSizeOfTID];
	uint32_t	ulMode;
	char		szIssuer[MaxSizeOfIssuer];
	char		szServiceID[MaxSizeOfSID];
	char		szRCID[MaxSizeOfRCID];
	uint32_t	ulResult;
	uint32_t	ulBodyLength;
	_s_broadcast_message_header() 
		: ulMode(0), ulResult(0), ulBodyLength(0)
	{
		memset(szTransactionID, 0, sizeof szTransactionID); 
		memset(szIssuer, 0, sizeof szIssuer); 
		memset(szServiceID, 0, sizeof szServiceID); 
	}
} MsgHeaderBoardCast;

#endif // ___RC_MMNGD_PROTOCOL_H__
