-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
282 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
80 changes: 80 additions & 0 deletions
80
...in/java/com/lucaoonk/Virt_Commander/Backend/Controllers/VNCConnection/ConnectionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.lucaoonk.Virt_Commander.Backend.Controllers.VNCConnection; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.Calendar; | ||
import java.util.UUID; | ||
|
||
public class ConnectionData { | ||
|
||
private String FriendlyName; | ||
private String ip; | ||
private Enum<connectionTypes> connectionType; | ||
|
||
|
||
public enum connectionTypes{ | ||
TCP, | ||
UDP | ||
} | ||
|
||
public ConnectionData(){ | ||
this.connectionType = connectionTypes.TCP; | ||
} | ||
|
||
public void setFriendlyName(String friendlyName){ | ||
this.FriendlyName = friendlyName; | ||
} | ||
|
||
public void setIP(String ip){ | ||
this.ip = ip; | ||
} | ||
|
||
public void setConnectionType(Enum<connectionTypes> connectionType){ | ||
this.connectionType = connectionType; | ||
} | ||
|
||
public String getFriendlyName(){ | ||
return this.FriendlyName; | ||
} | ||
public String getIP(){ | ||
return this.ip; | ||
} | ||
public Enum<connectionTypes> getConnectionType(){ | ||
return this.connectionType; | ||
} | ||
|
||
public void export(String location) throws IOException { | ||
|
||
StringBuilder connection = new StringBuilder(); | ||
FileWriter connectionFile; | ||
try{ | ||
connectionFile= new FileWriter(location); | ||
if(this.getConnectionType().equals(ConnectionData.connectionTypes.TCP)){ | ||
|
||
connection.append("ConnMethod=tcp\n"); | ||
|
||
}else{ | ||
if(this.getConnectionType().equals(ConnectionData.connectionTypes.UDP)){ | ||
|
||
connection.append("ConnMethod=udp\n"); | ||
|
||
} | ||
} | ||
|
||
connection.append("ConnTime="+Calendar.getInstance().getTime()+"\n"); | ||
|
||
connection.append("FriendlyName="+this.getFriendlyName()+"\n"); | ||
connection.append("Host="+this.getIP()+"\n"); | ||
connection.append("RelativePtr=0\n"); | ||
connection.append("Uuid="+UUID.randomUUID()+"\n"); | ||
|
||
connectionFile.write(connection.toString()); | ||
connectionFile.close(); | ||
} catch (Exception e) { | ||
//TODO: handle exception | ||
} | ||
|
||
|
||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
.../com/lucaoonk/Virt_Commander/Backend/Controllers/VNCConnection/ConnectionFileHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.lucaoonk.Virt_Commander.Backend.Controllers.VNCConnection; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.Calendar; | ||
import java.util.UUID; | ||
|
||
public class ConnectionFileHandler { | ||
|
||
private ConnectionData connectionData; | ||
|
||
public ConnectionFileHandler(ConnectionData connectionData) { | ||
|
||
this.connectionData = connectionData; | ||
|
||
} | ||
|
||
public void export(String location) throws IOException { | ||
|
||
StringBuilder connection = new StringBuilder(); | ||
FileWriter connectionFile; | ||
try{ | ||
connectionFile= new FileWriter(location); | ||
if(connectionData.getConnectionType().equals(ConnectionData.connectionTypes.TCP)){ | ||
|
||
connection.append("ConnMethod=tcp\n"); | ||
|
||
}else{ | ||
if(connectionData.getConnectionType().equals(ConnectionData.connectionTypes.UDP)){ | ||
|
||
connection.append("ConnMethod=udp\n"); | ||
|
||
} | ||
} | ||
|
||
connection.append("ConnTime="+Calendar.getInstance().getTime()+"\n"); | ||
|
||
connection.append("FriendlyName="+connectionData.getFriendlyName()+"\n"); | ||
connection.append("Host="+connectionData.getIP()+"\n"); | ||
connection.append("RelativePtr=0\n"); | ||
connection.append("Uuid="+UUID.randomUUID()+"\n"); | ||
|
||
connectionFile.write(connection.toString()); | ||
connectionFile.close(); | ||
} catch (Exception e) { | ||
//TODO: handle exception | ||
} | ||
|
||
|
||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...ain/java/com/lucaoonk/Virt_Commander/Backend/Controllers/VNCConnection/VNCConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.lucaoonk.Virt_Commander.Backend.Controllers.VNCConnection; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import com.lucaoonk.Virt_Commander.Backend.Objects.VM; | ||
|
||
public class VNCConnection { | ||
|
||
private VM vm; | ||
|
||
public VNCConnection(VM vm){ | ||
this.vm = vm; | ||
} | ||
|
||
public void connect(){ | ||
|
||
System.out.println("Triggerd VNC connect"); | ||
|
||
String location = System.getProperty("user.home") + "/Desktop/Virt_Commander-VNC/"; | ||
String vncConnectFile = location+vm.getDomain()+".vnc"; | ||
ConnectionData data = new ConnectionData(); | ||
data.setFriendlyName(vm.getDomain()); | ||
data.setIP(vm.vncIP+":"+vm.vncPort); | ||
|
||
try { | ||
File file = new File(vncConnectFile); | ||
file.getParentFile().mkdirs(); | ||
|
||
data.export(vncConnectFile); | ||
System.out.println("VNC file: "+vncConnectFile); | ||
|
||
|
||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.