Psi.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Java Package psi is a proxy for talking to a Go program.
  2. // gobind -lang=java github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary/psi
  3. //
  4. // File is generated by gobind. Do not edit.
  5. package go.psi;
  6. import go.Seq;
  7. public abstract class Psi {
  8. private Psi() {} // uninstantiable
  9. public interface PsiphonProvider extends go.Seq.Object {
  10. public void BindToDevice(long fileDescriptor) throws Exception;
  11. public String GetDnsServer();
  12. public long HasNetworkConnectivity();
  13. public void Notice(String noticeJSON);
  14. public static abstract class Stub implements PsiphonProvider {
  15. static final String DESCRIPTOR = "go.psi.PsiphonProvider";
  16. private final go.Seq.Ref ref;
  17. public Stub() {
  18. ref = go.Seq.createRef(this);
  19. }
  20. public go.Seq.Ref ref() { return ref; }
  21. public void call(int code, go.Seq in, go.Seq out) {
  22. switch (code) {
  23. case Proxy.CALL_BindToDevice: {
  24. long param_fileDescriptor = in.readInt();
  25. try {
  26. this.BindToDevice(param_fileDescriptor);
  27. out.writeUTF16(null);
  28. } catch (Exception e) {
  29. out.writeUTF16(e.getMessage());
  30. }
  31. return;
  32. }
  33. case Proxy.CALL_GetDnsServer: {
  34. String result = this.GetDnsServer();
  35. out.writeUTF16(result);
  36. return;
  37. }
  38. case Proxy.CALL_HasNetworkConnectivity: {
  39. long result = this.HasNetworkConnectivity();
  40. out.writeInt(result);
  41. return;
  42. }
  43. case Proxy.CALL_Notice: {
  44. String param_noticeJSON = in.readUTF16();
  45. this.Notice(param_noticeJSON);
  46. return;
  47. }
  48. default:
  49. throw new RuntimeException("unknown code: "+ code);
  50. }
  51. }
  52. }
  53. static final class Proxy implements PsiphonProvider {
  54. static final String DESCRIPTOR = Stub.DESCRIPTOR;
  55. private go.Seq.Ref ref;
  56. Proxy(go.Seq.Ref ref) { this.ref = ref; }
  57. public go.Seq.Ref ref() { return ref; }
  58. public void call(int code, go.Seq in, go.Seq out) {
  59. throw new RuntimeException("cycle: cannot call proxy");
  60. }
  61. public void BindToDevice(long fileDescriptor) throws Exception {
  62. go.Seq _in = new go.Seq();
  63. go.Seq _out = new go.Seq();
  64. _in.writeRef(ref);
  65. _in.writeInt(fileDescriptor);
  66. Seq.send(DESCRIPTOR, CALL_BindToDevice, _in, _out);
  67. String _err = _out.readUTF16();
  68. if (_err != null) {
  69. throw new Exception(_err);
  70. }
  71. }
  72. public String GetDnsServer() {
  73. go.Seq _in = new go.Seq();
  74. go.Seq _out = new go.Seq();
  75. String _result;
  76. _in.writeRef(ref);
  77. Seq.send(DESCRIPTOR, CALL_GetDnsServer, _in, _out);
  78. _result = _out.readUTF16();
  79. return _result;
  80. }
  81. public long HasNetworkConnectivity() {
  82. go.Seq _in = new go.Seq();
  83. go.Seq _out = new go.Seq();
  84. long _result;
  85. _in.writeRef(ref);
  86. Seq.send(DESCRIPTOR, CALL_HasNetworkConnectivity, _in, _out);
  87. _result = _out.readInt();
  88. return _result;
  89. }
  90. public void Notice(String noticeJSON) {
  91. go.Seq _in = new go.Seq();
  92. go.Seq _out = new go.Seq();
  93. _in.writeRef(ref);
  94. _in.writeUTF16(noticeJSON);
  95. Seq.send(DESCRIPTOR, CALL_Notice, _in, _out);
  96. }
  97. static final int CALL_BindToDevice = 0x10a;
  98. static final int CALL_GetDnsServer = 0x20a;
  99. static final int CALL_HasNetworkConnectivity = 0x30a;
  100. static final int CALL_Notice = 0x40a;
  101. }
  102. }
  103. public static void Start(String configJson, String embeddedServerEntryList, PsiphonProvider provider) throws Exception {
  104. go.Seq _in = new go.Seq();
  105. go.Seq _out = new go.Seq();
  106. _in.writeUTF16(configJson);
  107. _in.writeUTF16(embeddedServerEntryList);
  108. _in.writeRef(provider.ref());
  109. Seq.send(DESCRIPTOR, CALL_Start, _in, _out);
  110. String _err = _out.readUTF16();
  111. if (_err != null) {
  112. throw new Exception(_err);
  113. }
  114. }
  115. public static void Stop() {
  116. go.Seq _in = new go.Seq();
  117. go.Seq _out = new go.Seq();
  118. Seq.send(DESCRIPTOR, CALL_Stop, _in, _out);
  119. }
  120. private static final int CALL_Start = 1;
  121. private static final int CALL_Stop = 2;
  122. private static final String DESCRIPTOR = "psi";
  123. }