// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
// 
//     private List<ITorBundleStatusListener> mTorListenersList = null;
// 
//     public TorBundleListenerManager() {
//         mTorListenersList = new ArrayList<>();
//     }
// 
//     public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
//         mTorListenersList.add(iTorBundleStatusListener);
//     }
// 
//     public void statusMessageReceived(String torLogMessage) {
//         for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
//             torStatusListener.tellStatusMessage(torLogMessage);
//         }
//     }
// 
//     public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
//         if (mTorListenersList.contains(iTorBundleStatusListener)) {
//             mTorListenersList.remove(mTorListenersList);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
// 
//     private String mStatusMessage = "";
// 
//     @Override
//     public void tellStatusMessage(String torLogMessage) {
//         mStatusMessage = torLogMessage;
//     }
// 
//     public String getStatusMessage() {
//         return mStatusMessage;
//     }
// }


import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
                mTorProcessCommanderThread = Executors.newSingleThreadScheduledExecutor();
                mTorProcessCommanderThread.submit(mTorProcessCommander);

                updateTorBundleStatus();
            }

        } else {
            //TODO: Show a message that TOR Bundle is already running
            //Do nothing for now
            /*
             if (mTorBundleStatusListener.getStatusMessage().equals(TorConstants.TOR_READY_STATUS_MESSAGE)) {
             ..... which is, then show the needed pop-up
             */

            Log.i(TOR_PROCESS_MANAGER_TAG, "TOR Bundle already started");
        }

        Log.i(TOR_PROCESS_MANAGER_TAG, "LEAVE -> startTorBundle");
    }

    private String createTorProcessStartingPrerequisites() {
        Log.i(TOR_PROCESS_MANAGER_TAG, "createTorProcessStartingPrerequisites -> ENTER");

        CopyTorResource copyTorResource = new CopyTorResource();
        mTorResourceLocation = copyTorResource.provideTorResource(mMainActivity.getFilesDir().toString(), mAssetManager, TOR_PROCESS_MANAGER_TAG);
        Log.i(TOR_PROCESS_MANAGER_TAG, "tor resources successfully copied to ::: torResourceLocation = " + mTorResourceLocation);

        Log.i(TOR_PROCESS_MANAGER_TAG, "starting tor bundle ::: ");

        File torFile = new File(mTorResourceLocation + "/tor");
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleListenerManager.java
// public class TorBundleListenerManager {
// 
//     private List<ITorBundleStatusListener> mTorListenersList = null;
// 
//     public TorBundleListenerManager() {
//         mTorListenersList = new ArrayList<>();
//     }
// 
//     public void addTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
//         mTorListenersList.add(iTorBundleStatusListener);
//     }
// 
//     public void statusMessageReceived(String torLogMessage) {
//         for (ITorBundleStatusListener torStatusListener : mTorListenersList) {
//             torStatusListener.tellStatusMessage(torLogMessage);
//         }
//     }
// 
//     public void removeTorBundleListener(ITorBundleStatusListener iTorBundleStatusListener) {
//         if (mTorListenersList.contains(iTorBundleStatusListener)) {
//             mTorListenersList.remove(mTorListenersList);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/batsw/anonimitychat/tor/listener/TorBundleStatusListenerImpl.java
// public class TorBundleStatusListenerImpl implements ITorBundleStatusListener {
// 
//     private String mStatusMessage = "";
// 
//     @Override
//     public void tellStatusMessage(String torLogMessage) {
//         mStatusMessage = torLogMessage;
//     }
// 
//     public String getStatusMessage() {
//         return mStatusMessage;
//     }
// }


// Path: app/src/main/java/com/batsw/anonimitychat/tor/bundle/TorProcessManager.java
import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.batsw.anonimitychat.R;
import com.batsw.anonimitychat.tor.listener.TorBundleListenerManager;
import com.batsw.anonimitychat.tor.listener.TorBundleStatusListenerImpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

                mTorProcessCommanderThread = Executors.newSingleThreadScheduledExecutor();
                mTorProcessCommanderThread.submit(mTorProcessCommander);

                updateTorBundleStatus();
            }

        } else {
            //TODO: Show a message that TOR Bundle is already running
            //Do nothing for now
            /*
             if (mTorBundleStatusListener.getStatusMessage().equals(TorConstants.TOR_READY_STATUS_MESSAGE)) {
             ..... which is, then show the needed pop-up
             */

            Log.i(TOR_PROCESS_MANAGER_TAG, "TOR Bundle already started");
        }

        Log.i(TOR_PROCESS_MANAGER_TAG, "LEAVE -> startTorBundle");
    }

    private String createTorProcessStartingPrerequisites() {
        Log.i(TOR_PROCESS_MANAGER_TAG, "createTorProcessStartingPrerequisites -> ENTER");

        CopyTorResource copyTorResource = new CopyTorResource();
        mTorResourceLocation = copyTorResource.provideTorResource(mMainActivity.getFilesDir().toString(), mAssetManager, TOR_PROCESS_MANAGER_TAG);
        Log.i(TOR_PROCESS_MANAGER_TAG, "tor resources successfully copied to ::: torResourceLocation = " + mTorResourceLocation);

        Log.i(TOR_PROCESS_MANAGER_TAG, "starting tor bundle ::: ");

        File torFile = new File(mTorResourceLocation + "/tor");
        File torrcFile = new File(mTorResourceLocation + "/torrc");