Dbus listGroups and listContacts

This commit is contained in:
Adimarantis 2021-02-16 23:21:36 +01:00
parent d3c153ba32
commit dfb299297a
2 changed files with 28 additions and 0 deletions

View file

@ -41,6 +41,10 @@ public interface Signal extends DBusInterface {
List<byte[]> getGroupIds();
List<String> listGroups();
List<String> listContacts();
String getGroupName(byte[] groupId);
List<String> getGroupMembers(byte[] groupId);

View file

@ -14,6 +14,7 @@ import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.libsignal.util.guava.Optional;
import org.asamk.signal.manager.storage.contacts.ContactInfo;
import java.io.File;
import java.io.IOException;
@ -264,4 +265,27 @@ public class DbusSignalImpl implements Signal {
throw new Error.Failure(e.getMessage());
}
}
@Override
public List<String> listGroups() {
List<GroupInfo> groups = m.getGroups();
List<String> gr = new ArrayList<>(groups.size());
for (GroupInfo group : groups) {
String entry="group="+group.getTitle()+" active:"+group.isMember(m.getSelfAddress())+" blocked:"+group.isBlocked();
gr.add(entry);
}
return gr;
}
@Override
public List<String> listContacts() {
List<ContactInfo> contacts = m.getContacts();
List<String> cc = new ArrayList<>(contacts.size());
for (ContactInfo c : contacts) {
String entry="number:"+c.number+" name:"+c.name+" blocked:"+c.blocked;
cc.add(entry);
}
return cc;
}
}