/***************************************************************************
                    Sync Manager Header ( sycnmanager.h )
                -----------------------------------------
	begin      : 2011/02/16
	copyright  : (C) 2005 SolutionBox Inc.
	author     : Service 1 Team
	email      : svc1@solbox.com
	version    : 3.0.1

	CopyRight(C) 2005 SolutionBox Inc. All Rights reserved.
	Redistribution and use in source and binary forms, with or with out
	modification, are not permitted in outside of SolutionBox Inc.
***************************************************************************/

#ifndef __SYNC_MANAGER_H__
#define __SYNC_MANAGER_H__

class CSyncManager 
{
public:
	CSyncManager();
	~CSyncManager();

	bool sync( DataBase &db, RCUDINFOLIST &infolist );

private:
	int	savedata( int64_t userseq, int64_t tranid,  int caldepth, int depth, const char *uri, int64_t length, SYNCDATAMAP &data );

	int getsyncdata( DataBase &db, int64_t userseq, int64_t tranid, int caldepth, SYNCDATAMAP &data );
	int getrootsum( DataBase &db, int64_t userseq, int64_t tranid, SYNCDATAMAP &data );
	int getdepthsum( DataBase &db, int64_t userseq, int64_t tranid, int caldepth, SYNCDATAMAP &data );

	bool deloverdepth(DataBase &db, int64_t userseq, int64_t tranid, int caldepth);
	bool deldeleteddir(DataBase &db, int64_t userseq, int64_t tranid, int caldepth);
	bool delnotfouddir(DataBase &db, int64_t userseq, int64_t tranid, int caldepth);
	bool insertroot(DataBase &db, int64_t userseq, int64_t tranid);
	bool insertdir(DataBase &db, int64_t userseq, int64_t tranid, int caldepth);
		
	bool syndata( DataBase &db, SYNCDATAMAP &data );

	// 2014.06.07 dadamin
	// 형상(9.3) 변경으로 테이블 변경 지원
	bool targettblmode( DataBase &db );
	string gettablename(int64_t tranid);

private:
	// 2014.06.07 dadamin
	// -1: unset,  0: t_dav_resource, 1: t_meta_[sp_svc_tran_id]
	int	m_tblmode;
};

#endif // __SYNC_MANAGER_H__
