Psi.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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);
  11. public void Notice(String noticeJSON);
  12. public static abstract class Stub implements PsiphonProvider {
  13. static final String DESCRIPTOR = "go.psi.PsiphonProvider";
  14. private final go.Seq.Ref ref;
  15. public Stub() {
  16. ref = go.Seq.createRef(this);
  17. }
  18. public go.Seq.Ref ref() { return ref; }
  19. public void call(int code, go.Seq in, go.Seq out) {
  20. switch (code) {
  21. case Proxy.CALL_BindToDevice: {
  22. long param_fileDescriptor = in.readInt();
  23. this.BindToDevice(param_fileDescriptor);
  24. return;
  25. }
  26. case Proxy.CALL_Notice: {
  27. String param_noticeJSON = in.readUTF16();
  28. this.Notice(param_noticeJSON);
  29. return;
  30. }
  31. default:
  32. throw new RuntimeException("unknown code: "+ code);
  33. }
  34. }
  35. }
  36. static final class Proxy implements PsiphonProvider {
  37. static final String DESCRIPTOR = Stub.DESCRIPTOR;
  38. private go.Seq.Ref ref;
  39. Proxy(go.Seq.Ref ref) { this.ref = ref; }
  40. public go.Seq.Ref ref() { return ref; }
  41. public void call(int code, go.Seq in, go.Seq out) {
  42. throw new RuntimeException("cycle: cannot call proxy");
  43. }
  44. public void BindToDevice(long fileDescriptor) {
  45. go.Seq _in = new go.Seq();
  46. go.Seq _out = new go.Seq();
  47. _in.writeRef(ref);
  48. _in.writeInt(fileDescriptor);
  49. Seq.send(DESCRIPTOR, CALL_BindToDevice, _in, _out);
  50. }
  51. public void Notice(String noticeJSON) {
  52. go.Seq _in = new go.Seq();
  53. go.Seq _out = new go.Seq();
  54. _in.writeRef(ref);
  55. _in.writeUTF16(noticeJSON);
  56. Seq.send(DESCRIPTOR, CALL_Notice, _in, _out);
  57. }
  58. static final int CALL_BindToDevice = 0x10a;
  59. static final int CALL_Notice = 0x20a;
  60. }
  61. }
  62. public static void Start(String configJson, String embeddedServerEntryList, PsiphonProvider provider) throws Exception {
  63. go.Seq _in = new go.Seq();
  64. go.Seq _out = new go.Seq();
  65. _in.writeUTF16(configJson);
  66. _in.writeUTF16(embeddedServerEntryList);
  67. _in.writeRef(provider.ref());
  68. Seq.send(DESCRIPTOR, CALL_Start, _in, _out);
  69. String _err = _out.readUTF16();
  70. if (_err != null) {
  71. throw new Exception(_err);
  72. }
  73. }
  74. public static void Stop() {
  75. go.Seq _in = new go.Seq();
  76. go.Seq _out = new go.Seq();
  77. Seq.send(DESCRIPTOR, CALL_Stop, _in, _out);
  78. }
  79. private static final int CALL_Start = 1;
  80. private static final int CALL_Stop = 2;
  81. private static final String DESCRIPTOR = "psi";
  82. }