public PhotoshopHandler( PhotoshopProtocol photoshopProtocol, BackBufferHandler backBufferHandler, LUTWriter lutWriter, ToolSettings settings, CameraCollection cameraCollection ) { _photoshopProtocol = photoshopProtocol; _backBufferHandler = backBufferHandler; _lutWriter = lutWriter; _settings = settings; _cameraCollection = cameraCollection; }
public PhotoshopHandler(PhotoshopProtocol photoshopProtocol, BackBufferHandler backBufferHandler, LUTWriter lutWriter, ToolSettings settings, CameraCollection cameraCollection) { _photoshopProtocol = photoshopProtocol; _backBufferHandler = backBufferHandler; _lutWriter = lutWriter; _settings = settings; _cameraCollection = cameraCollection; }
public void TestConnection() { if (string.IsNullOrEmpty(ToolSettings.Instance.Host)) { ToolSettings.Instance.Message = "Host can't be empty"; return; } try { if (!Connect()) { ToolSettings.Instance.Message = "There was an error. Check if the host is available to this machine."; return; } var pp = new PhotoshopProtocol(this); //string result = pp.SendJSCommand("scriptingVersion"); string result = SendTestImage(pp); /* * while ( _stream.DataAvailable ) * { * var buf = new byte[ 4 ]; * _stream.Read( buf, 0, 4); * int inLength = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 ); * _stream.Read( buf, 0, 4); * int inComStatus = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 ); * * Debug.Log("Reading length: " + inLength); * Debug.Log("Reading com status: " + inComStatus); * * var skip = new byte[ inLength ]; * _stream.Read( skip, 0, inLength ); * * result += Encoding.UTF8.GetString( skip ); * } */ if (result.ToLowerInvariant().Contains("error")) { ToolSettings.Instance.Message = "There was an error. Try checking the password."; CleanConnection(); } else { ToolSettings.Instance.Message = "Test successfull"; } } catch (Exception) { ToolSettings.Instance.Message = "Connection could not be established"; } }
void OnEnable() { Connection = new PhotoshopConnection(); PhotoshopProtocol = new PhotoshopProtocol( Connection ); Cameras = new CameraCollection(); BackBufferHandler = new BackBufferHandler( Cameras ); LUTWriter = new LUTWriter(); PhotoshopHandler = new PhotoshopHandler( PhotoshopProtocol, BackBufferHandler, LUTWriter, Settings, Cameras ); FileHandler = new FileHandler( BackBufferHandler, LUTWriter, Settings, Cameras ); Cameras.GenerateCameraList(); }
void OnEnable() { Connection = new PhotoshopConnection(); PhotoshopProtocol = new PhotoshopProtocol(Connection); Cameras = new CameraCollection(); BackBufferHandler = new BackBufferHandler(Cameras); LUTWriter = new LUTWriter(); PhotoshopHandler = new PhotoshopHandler(PhotoshopProtocol, BackBufferHandler, LUTWriter, Settings, Cameras); FileHandler = new FileHandler(BackBufferHandler, LUTWriter, Settings, Cameras); Cameras.GenerateCameraList(); }
string SendTestImage(PhotoshopProtocol pp) { string result = ""; result += FlushRead(); byte[] image = { 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x08, 0xff, 0x00, 0x00 }; MemoryStream temp_stream = new MemoryStream(); BinaryWriter bw = new BinaryWriter(temp_stream); bw.Write(SwapEndian(PhotoshopProtocol.ProtocolVersion)); // Protocol version bw.Write(SwapEndian(pp._transactionId++)); // Transaction ID bw.Write(SwapEndian(3)); // Content Type bw.Write(image); // Image data bw.Flush(); long len = temp_stream.Length; temp_stream.Seek(0, SeekOrigin.Begin); BinaryReader br = new BinaryReader(temp_stream); var message = new byte[len]; br.Read(message, 0, ( int )len); string password = EditorPrefs.GetString("AmplifyColor.NetworkPassword", "password"); EncryptDecrypt encryptDecrypt = new EncryptDecrypt(password); var encryptedMessage = encryptDecrypt.encrypt(message); //string str = ""; //for (int i = 0; i < message.Length; i++) //{ // str += ( ( message[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " "; // if (i > 0 && (((i+1) % 8) == 0)) // str += "\n"; //} //Debug.Log( str ); //str = ""; //for (int i = 0; i < encryptedMessage.Length; i++) //{ // str += ( ( encryptedMessage[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " "; // if (i > 0 && (((i+1) % 8) == 0)) // str += "\n"; //} //Debug.Log( str ); int messageLength = PhotoshopProtocol.CommLength + encryptedMessage.Length; _stream.Write(BitConverter.GetBytes(messageLength).Reverse().ToArray(), 0, 4); _stream.Write(BitConverter.GetBytes(PhotoshopProtocol.NoCommError).Reverse().ToArray(), 0, 4); _stream.Write(encryptedMessage, 0, encryptedMessage.Length); _stream.Flush(); System.Threading.Thread.Sleep(1000); result += FlushRead(); return(result); }
string SendTestImage( PhotoshopProtocol pp ) { string result = ""; result += FlushRead(); byte[] image = { 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x08, 0xff, 0x00, 0x00 }; MemoryStream temp_stream = new MemoryStream(); BinaryWriter bw = new BinaryWriter( temp_stream ); bw.Write( SwapEndian( PhotoshopProtocol.ProtocolVersion ) ); // Protocol version bw.Write( SwapEndian( pp._transactionId++ ) ); // Transaction ID bw.Write( SwapEndian( 3 ) ); // Content Type bw.Write( image ); // Image data bw.Flush(); long len = temp_stream.Length; temp_stream.Seek( 0, SeekOrigin.Begin ); BinaryReader br = new BinaryReader( temp_stream ); var message = new byte[ len ]; br.Read( message, 0, ( int ) len ); string password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" ); EncryptDecrypt encryptDecrypt = new EncryptDecrypt( password ); var encryptedMessage = encryptDecrypt.encrypt( message ); //string str = ""; //for (int i = 0; i < message.Length; i++) //{ // str += ( ( message[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " "; // if (i > 0 && (((i+1) % 8) == 0)) // str += "\n"; //} //Debug.Log( str ); //str = ""; //for (int i = 0; i < encryptedMessage.Length; i++) //{ // str += ( ( encryptedMessage[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " "; // if (i > 0 && (((i+1) % 8) == 0)) // str += "\n"; //} //Debug.Log( str ); int messageLength = PhotoshopProtocol.CommLength + encryptedMessage.Length; _stream.Write( BitConverter.GetBytes( messageLength ).Reverse().ToArray(), 0, 4 ); _stream.Write( BitConverter.GetBytes( PhotoshopProtocol.NoCommError ).Reverse().ToArray(), 0, 4 ); _stream.Write( encryptedMessage, 0, encryptedMessage.Length ); _stream.Flush(); System.Threading.Thread.Sleep( 1000 ); result += FlushRead(); return result; }
public void TestConnection() { if ( string.IsNullOrEmpty( ToolSettings.Instance.Host ) ) { ToolSettings.Instance.Message = "Host can't be empty"; return; } try { if ( !Connect() ) { ToolSettings.Instance.Message = "There was an error. Check if the host is available to this machine."; return; } var pp = new PhotoshopProtocol( this ); //string result = pp.SendJSCommand("scriptingVersion"); string result = SendTestImage( pp ); /* while ( _stream.DataAvailable ) { var buf = new byte[ 4 ]; _stream.Read( buf, 0, 4); int inLength = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 ); _stream.Read( buf, 0, 4); int inComStatus = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 ); Debug.Log("Reading length: " + inLength); Debug.Log("Reading com status: " + inComStatus); var skip = new byte[ inLength ]; _stream.Read( skip, 0, inLength ); result += Encoding.UTF8.GetString( skip ); } */ if ( result.ToLowerInvariant().Contains( "error" ) ) { ToolSettings.Instance.Message = "There was an error. Try checking the password."; CleanConnection(); } else { ToolSettings.Instance.Message = "Test successfull"; } } catch ( Exception ) { ToolSettings.Instance.Message = "Connection could not be established"; } }