// Path: Android mirroring app/app/src/main/Networking/TCPClient.java
// public class TCPClient {
// 
//     public interface SocketImageCallback {
//         void didReceiveMessage(byte[] frameMessage);
//     }
// 
//     static boolean shouldFetch = true;
// 
// 
//     public static void start(SocketImageCallback socketImageCallback) {
//         try {
//             int serverPort = 6880;
//             ServerSocket listenSocket = new ServerSocket(serverPort);
// 
//             System.out.println("server start listening... ... ...");
// 
//             while (true) {
//                 Socket clientSocket = listenSocket.accept();
//                 if(shouldFetch == true){
//                     Connection c = new Connection(clientSocket, socketImageCallback);
//                 }
//             }
//         } catch (IOException e) {
//             System.out.println("Listen :" + e.getMessage());
//         }
//     }
// }
// 
// Path: Android mirroring app/app/src/main/Networking/TCPServer.java
// public class TCPServer {
// 
//     public static void start(byte[] d) {// arguments supply message and hostname of destination
//         Socket s = null;
//         try {
//             //htc 10.10.19.196
//             int serverPort = 6880;
//             String ip = "10.10.19.196"; //"10.0.2.2";//"192.168.5.5";//"10.10.19.228"; //"localhost";
//             //String data = "Hello, How are you?";
// //            byte[] data;
// //            byte[] ints = new byte[1184 * 768];
// //
// //            for (int i = 0; i < 1184 * 768; i++) {
// //                ints[i] = (byte) Color.RED; //0x00FF0000;
// //            }
// //            data = ints;
// 
//             s = new Socket(ip, serverPort);
//             DataInputStream input = new DataInputStream(s.getInputStream());
//             DataOutputStream output = new DataOutputStream(s.getOutputStream());
// 
//             //Step 1 send length
//             System.out.println("Length" + d.length);
//             output.writeInt(d.length);
//             //Step 2 send length
//             System.out.println("Writing.......");
//             //output.writeBytes(data); // UTF is a string encoding
//             output.write(d);
//             System.out.println("Written");
// 
//             /*
//             //Step 1 read length
//             int nb = input.readInt();
//             byte[] digit = new byte[nb];
// 
//             //Step 2 read byte
//             for (int i = 0; i < nb; i++) {
//                 digit[i] = input.readByte();
//             }
// 
//             String st = new String(digit);
//             System.out.println("Received: " + st);
//             */
//         } catch (UnknownHostException e) {
//             System.out.println("Sock:" + e.getMessage());
//         } catch (EOFException e) {
//             System.out.println("EOF:" + e.getMessage());
//         } catch (IOException e) {
//             System.out.println("IO:" + e.getMessage());
//         } finally {
//             if (s != null) {
//                 try {
//                     s.close();
//                 } catch (IOException e) {/*close failed*/
// 
//                 }
//             }
//         }
//     }
// }
// 
// Path: Android mirroring app/app/src/main/VNCServerJNIWrapper/VNCAndroidServer.java
// public class VNCAndroidServer {
// 
//     public native String getStringFromJNI();
// 
//     public native void newScreenAvailable(ByteBuffer buffer);
//     public native void newFrameAvailable(byte[] frameData, int len);
//     public static native void sendTextMessage(String msg, int len);
//     public static native void newScreenAvailable2(byte[] frameData, int len);
//     public static native void setNewScreen(byte[] frameData, int len);
// 
//     public static native void startSharedMemServer();
//     public static native void startSharedMemClient();
// 
// 
//     public static void start(){
//         Thread t = new Thread(new Runnable() {
//             @Override
//             public void run() {
//                 VNCAndroidServer.newScreenAvailable2(null, 0);
//             }
//         });
//         t.start();
//     }
// 
//     static {
//         System.loadLibrary("JNIDummy");
//     }
// 
// }
// 
// Path: Android mirroring app/app/src/main/Bindings/Server.java
// public class Server {
// 
//     public static native long getInstance();
// 
//     static {
//         System.loadLibrary("j");
//     }
// 
// }
// 
// Path: Android mirroring app/app/src/main/java/com/vnc/oeo/mediaprojectiontest1/VNCUtility.java
// public static int getIntFromColor(int Red, int Green, int Blue){
//     Red = (Red << 16) & 0x00FF0000; //Shift red 16-bits and mask out other stuff
//     Green = (Green << 8) & 0x0000FF00; //Shift Green 8-bits and mask out other stuff
//     Blue = Blue & 0x000000FF; //Mask out anything not blue.
// 
//     return 0xFF000000 | Red | Green | Blue; //0xFF000000 for 100% Alpha. Bitwise OR everything together.
// }


import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.vnc.oeo.mediaprojectiontest1.R;
import java.io.ByteArrayOutputStream;
import main.Networking.TCPClient;
import main.Networking.TCPServer;
import main.VNCServerJNIWrapper.VNCAndroidServer;
import main.Bindings.Server;
import static main.java.com.vnc.oeo.mediaprojectiontest1.VNCUtility.getIntFromColor;
package main.java.com.vnc.oeo.mediaprojectiontest1;







public class HomeActivity extends Activity {

    private static final String TAG = ServerActivity.class.getName();
    private Activity mActivity;
    private ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        // Store Context
        mActivity = this;

        //VNCAndroidServer.start();




        // Server
// Path: Android mirroring app/app/src/main/Networking/TCPClient.java
// public class TCPClient {
// 
//     public interface SocketImageCallback {
//         void didReceiveMessage(byte[] frameMessage);
//     }
// 
//     static boolean shouldFetch = true;
// 
// 
//     public static void start(SocketImageCallback socketImageCallback) {
//         try {
//             int serverPort = 6880;
//             ServerSocket listenSocket = new ServerSocket(serverPort);
// 
//             System.out.println("server start listening... ... ...");
// 
//             while (true) {
//                 Socket clientSocket = listenSocket.accept();
//                 if(shouldFetch == true){
//                     Connection c = new Connection(clientSocket, socketImageCallback);
//                 }
//             }
//         } catch (IOException e) {
//             System.out.println("Listen :" + e.getMessage());
//         }
//     }
// }
// 
// Path: Android mirroring app/app/src/main/Networking/TCPServer.java
// public class TCPServer {
// 
//     public static void start(byte[] d) {// arguments supply message and hostname of destination
//         Socket s = null;
//         try {
//             //htc 10.10.19.196
//             int serverPort = 6880;
//             String ip = "10.10.19.196"; //"10.0.2.2";//"192.168.5.5";//"10.10.19.228"; //"localhost";
//             //String data = "Hello, How are you?";
// //            byte[] data;
// //            byte[] ints = new byte[1184 * 768];
// //
// //            for (int i = 0; i < 1184 * 768; i++) {
// //                ints[i] = (byte) Color.RED; //0x00FF0000;
// //            }
// //            data = ints;
// 
//             s = new Socket(ip, serverPort);
//             DataInputStream input = new DataInputStream(s.getInputStream());
//             DataOutputStream output = new DataOutputStream(s.getOutputStream());
// 
//             //Step 1 send length
//             System.out.println("Length" + d.length);
//             output.writeInt(d.length);
//             //Step 2 send length
//             System.out.println("Writing.......");
//             //output.writeBytes(data); // UTF is a string encoding
//             output.write(d);
//             System.out.println("Written");
// 
//             /*
//             //Step 1 read length
//             int nb = input.readInt();
//             byte[] digit = new byte[nb];
// 
//             //Step 2 read byte
//             for (int i = 0; i < nb; i++) {
//                 digit[i] = input.readByte();
//             }
// 
//             String st = new String(digit);
//             System.out.println("Received: " + st);
//             */
//         } catch (UnknownHostException e) {
//             System.out.println("Sock:" + e.getMessage());
//         } catch (EOFException e) {
//             System.out.println("EOF:" + e.getMessage());
//         } catch (IOException e) {
//             System.out.println("IO:" + e.getMessage());
//         } finally {
//             if (s != null) {
//                 try {
//                     s.close();
//                 } catch (IOException e) {/*close failed*/
// 
//                 }
//             }
//         }
//     }
// }
// 
// Path: Android mirroring app/app/src/main/VNCServerJNIWrapper/VNCAndroidServer.java
// public class VNCAndroidServer {
// 
//     public native String getStringFromJNI();
// 
//     public native void newScreenAvailable(ByteBuffer buffer);
//     public native void newFrameAvailable(byte[] frameData, int len);
//     public static native void sendTextMessage(String msg, int len);
//     public static native void newScreenAvailable2(byte[] frameData, int len);
//     public static native void setNewScreen(byte[] frameData, int len);
// 
//     public static native void startSharedMemServer();
//     public static native void startSharedMemClient();
// 
// 
//     public static void start(){
//         Thread t = new Thread(new Runnable() {
//             @Override
//             public void run() {
//                 VNCAndroidServer.newScreenAvailable2(null, 0);
//             }
//         });
//         t.start();
//     }
// 
//     static {
//         System.loadLibrary("JNIDummy");
//     }
// 
// }
// 
// Path: Android mirroring app/app/src/main/Bindings/Server.java
// public class Server {
// 
//     public static native long getInstance();
// 
//     static {
//         System.loadLibrary("j");
//     }
// 
// }
// 
// Path: Android mirroring app/app/src/main/java/com/vnc/oeo/mediaprojectiontest1/VNCUtility.java
// public static int getIntFromColor(int Red, int Green, int Blue){
//     Red = (Red << 16) & 0x00FF0000; //Shift red 16-bits and mask out other stuff
//     Green = (Green << 8) & 0x0000FF00; //Shift Green 8-bits and mask out other stuff
//     Blue = Blue & 0x000000FF; //Mask out anything not blue.
// 
//     return 0xFF000000 | Red | Green | Blue; //0xFF000000 for 100% Alpha. Bitwise OR everything together.
// }


// Path: Android mirroring app/app/src/main/java/com/vnc/oeo/mediaprojectiontest1/HomeActivity.java
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.vnc.oeo.mediaprojectiontest1.R;
import java.io.ByteArrayOutputStream;
import main.Networking.TCPClient;
import main.Networking.TCPServer;
import main.VNCServerJNIWrapper.VNCAndroidServer;
import main.Bindings.Server;
import static main.java.com.vnc.oeo.mediaprojectiontest1.VNCUtility.getIntFromColor;

package main.java.com.vnc.oeo.mediaprojectiontest1;







public class HomeActivity extends Activity {

    private static final String TAG = ServerActivity.class.getName();
    private Activity mActivity;
    private ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        // Store Context
        mActivity = this;

        //VNCAndroidServer.start();




        // Server
        final VNCAndroidServer server = new VNCAndroidServer();