- System.err.println("Failed to receive message (Assertion): " + e.getMessage());
- System.err.println(e.getStackTrace());
- System.err.println("If you use an Oracle JRE please check if you have unlimited strength crypto enabled, see README");
+ handleAssertionError(e);
+ }
+ break;
+ case "quitGroup":
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+
+ try {
+ m.sendQuitGroupMessage(decodeGroupId(ns.getString("group")));
+ } catch (IOException e) {
+ handleIOException(e);
+ } catch (EncapsulatedExceptions e) {
+ handleEncapsulatedExceptions(e);
+ } catch (AssertionError e) {
+ handleAssertionError(e);
+ } catch (GroupNotFoundException e) {
+ handleGroupNotFoundException(e);
+ }
+
+ break;
+ case "updateGroup":
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+
+ try {
+ byte[] groupId = null;
+ if (ns.getString("group") != null) {
+ groupId = decodeGroupId(ns.getString("group"));
+ }
+ byte[] newGroupId = m.sendUpdateGroupMessage(groupId, ns.getString("name"), ns.<String>getList("member"), ns.getString("avatar"));
+ if (groupId == null) {
+ System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\" …");
+ }
+ } catch (IOException e) {
+ handleIOException(e);
+ } catch (AttachmentInvalidException e) {
+ System.err.println("Failed to add avatar attachment (\"" + e.getAttachment() + ") for group\": " + e.getMessage());
+ System.err.println("Aborting sending.");