/*
 * DRM Manager class.
 *
 * @copyright:
 * Copyright (c) 2009-2016 NexStreaming Corporation, all rights reserved.
 */

package com.nexstreaming.httpretrievestoresample;

import java.io.File;

import android.util.Log;

/**
 * \brief This class allows NexPlayer&trade;&nbsp;to support and handle offline HLS and Smooth Streaming content.
 * 
 * \since version 6.3
 */

public class HTTPStoreDataManager {
	private static final String TAG = "HTTPStoreDataManager";

	/**
	 * HTTPStoreDataManager constructor
	 */
    public HTTPStoreDataManager() {
    }

    /**
     * Initializes and registers the HTTPStoreDataManager.
     * 
     * \param strEngineLibName	The relevant engine library name as a string.
     * \param cachFolder  The folder to be used for the cache, as a string.
     */

    public static native int initManager(String strEngineLibName, String cachFolder);

   /** 
    * \For internal use only. Please do not use.
    */
    public static native int initManagerMulti(Object nexPlayerHandle, String strEngineLibName, String cachFolder);

    static {
        System.loadLibrary("HttpRetrieveStoreDataCallbackSample_jni");
    }
    
    
    //public static native int deleteAllCachData(String cachFolder);
    
    public static int deleteAllCachData(String cachFolder)
    {
    	File cachDir = new File(cachFolder);
    	if(cachDir.isDirectory())
    	{
    		File arrFile[] = cachDir.listFiles();
    		
    		Log.d("OLP", "Included file number : " + arrFile.length);
    		int i;
    		for(i=0; i<arrFile.length; i++)
    		{
    			Log.d("OLP", "File["+i+"] " + arrFile[i].getName() + " is deleted.");
    			arrFile[i].delete();
    		}
    	}
    	else
    	{
    		Log.e("OLP", "CacheFolder:" + cachFolder + " is not exist or not folder.");
    	}
    	
    	return 0;
    }
    
}
