3 public class MoiraConnect {
4 boolean connected = false;
5 boolean isauth = false;
12 public MoiraConnect(String server, Object lock) {
17 public void connect() throws MoiraException {
19 MoiraConnectInternal.connect(server);
24 public void auth() throws MoiraException {
27 MoiraConnectInternal.auth();
33 public void proxy(String user) throws MoiraException {
34 MoiraConnectInternal.proxy(user);
37 public void disconnect() {
39 MoiraConnectInternal.disconnect();
45 public ListInfo get_list_info(String list) throws MoiraException {
46 if (!connected) throw new MoiraException("Not Connected");
47 String [] args = new String[1];
49 Object [] retinternal = MoiraConnectInternal.mr_query("get_list_info", args);
50 if (retinternal == null) return (null);
51 if (retinternal.length == 0) return (null);
52 if (retinternal.length != 1) throw new MoiraException("get_list_info returned more then one list!");
53 String [] entry = (String []) retinternal[0];
54 return (new ListInfo(entry[0], entry[1], entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], entry[8], entry[9], entry[10], entry[11], entry[12]));
57 void update_list_info(String list, ListInfo info) throws MoiraException {
58 if (!connected) throw new MoiraException("Not Connected");
59 String [] args = new String[11];
62 args[2] = info.active ? "1" : "0";
63 args[3] = info.bpublic ? "1" : "0";
64 args[4] = info.hidden ? "1" : "0";
65 args[5] = info.maillist ? "1" : "0";
66 args[6] = info.grouplist ? "1" : "0";
67 args[7] = info.gid_original;
68 args[8] = info.ace_type;
69 args[9] = info.ace_name;
70 args[10] = info.description;
71 Object [] retinternal = MoiraConnectInternal.mr_query("update_list", args);
75 void delete_member_from_list(String list, String type, String member) throws MoiraException {
76 if (!connected) throw new MoiraException("Not Connected");
77 String [] args = new String[3];
81 Object [] retinternal = MoiraConnectInternal.mr_query("delete_member_from_list", args);
85 void add_member_to_list(String list, String type, String member) throws MoiraException {
86 if (!connected) throw new MoiraException("Not Connected");
87 String [] args = new String[3];
91 Object [] retinternal = MoiraConnectInternal.mr_query("add_member_to_list", args);
95 public Member [] get_members_of_list(String list) throws MoiraException {
96 if (!connected) throw new MoiraException("Not Connected");
97 String [] args = new String[1];
99 Object [] retinternal = MoiraConnectInternal.mr_query("get_members_of_list", args);
100 if (retinternal == null) return (null);
101 Member [] retval = new Member[retinternal.length];
102 for (int i = 0; i < retinternal.length; i++) {
103 String [] entry = (String []) retinternal[i];
104 retval[i] = new Member(entry[0], entry[1]);
110 class MoiraConnectInternal {
111 static native void connect(String server) throws MoiraException;
112 static native void auth() throws MoiraException;
113 static native void proxy(String user) throws MoiraException;
114 static native void disconnect();
115 static native Object [] mr_query(String command, String [] args) throws MoiraException;
117 System.loadLibrary("moirajava");