1 package org
.asamk
.signal
.dbus
;
3 import org
.asamk
.Signal
;
4 import org
.asamk
.signal
.BaseConfig
;
5 import org
.asamk
.signal
.manager
.AttachmentInvalidException
;
6 import org
.asamk
.signal
.manager
.Manager
;
7 import org
.asamk
.signal
.manager
.NotMasterDeviceException
;
8 import org
.asamk
.signal
.manager
.StickerPackInvalidException
;
9 import org
.asamk
.signal
.manager
.UntrustedIdentityException
;
10 import org
.asamk
.signal
.manager
.api
.Device
;
11 import org
.asamk
.signal
.manager
.api
.Identity
;
12 import org
.asamk
.signal
.manager
.api
.Message
;
13 import org
.asamk
.signal
.manager
.api
.RecipientIdentifier
;
14 import org
.asamk
.signal
.manager
.api
.TypingAction
;
15 import org
.asamk
.signal
.manager
.groups
.GroupId
;
16 import org
.asamk
.signal
.manager
.groups
.GroupInviteLinkUrl
;
17 import org
.asamk
.signal
.manager
.groups
.GroupNotFoundException
;
18 import org
.asamk
.signal
.manager
.groups
.GroupSendingNotAllowedException
;
19 import org
.asamk
.signal
.manager
.groups
.LastGroupAdminException
;
20 import org
.asamk
.signal
.manager
.groups
.NotAGroupMemberException
;
21 import org
.asamk
.signal
.manager
.storage
.recipients
.Profile
;
22 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientAddress
;
23 import org
.asamk
.signal
.util
.ErrorUtils
;
24 import org
.freedesktop
.dbus
.exceptions
.DBusExecutionException
;
25 import org
.whispersystems
.libsignal
.InvalidKeyException
;
26 import org
.whispersystems
.libsignal
.util
.Pair
;
27 import org
.whispersystems
.libsignal
.util
.guava
.Optional
;
28 import org
.whispersystems
.signalservice
.api
.groupsv2
.GroupLinkNotActiveException
;
29 import org
.whispersystems
.signalservice
.api
.messages
.SendMessageResult
;
30 import org
.whispersystems
.signalservice
.api
.push
.exceptions
.UnregisteredUserException
;
31 import org
.whispersystems
.signalservice
.api
.util
.InvalidNumberException
;
32 import org
.whispersystems
.signalservice
.internal
.contacts
.crypto
.UnauthenticatedResponseException
;
35 import java
.io
.IOException
;
37 import java
.net
.URISyntaxException
;
38 import java
.util
.ArrayList
;
39 import java
.util
.Collection
;
40 import java
.util
.HashSet
;
41 import java
.util
.List
;
43 import java
.util
.Objects
;
45 import java
.util
.UUID
;
46 import java
.util
.stream
.Collectors
;
47 import java
.util
.stream
.Stream
;
49 public class DbusSignalImpl
implements Signal
{
51 private final Manager m
;
52 private final String objectPath
;
54 public DbusSignalImpl(final Manager m
, final String objectPath
) {
56 this.objectPath
= objectPath
;
60 public boolean isRemote() {
65 public String
getObjectPath() {
70 public String
getSelfNumber() {
71 return m
.getSelfNumber();
75 public void addDevice(String uri
) {
77 m
.addDeviceLink(new URI(uri
));
78 } catch (IOException
| InvalidKeyException e
) {
79 throw new Error
.Failure(e
.getClass().getSimpleName() + " Add device link failed. " + e
.getMessage());
80 } catch (URISyntaxException e
) {
81 throw new Error
.InvalidUri(e
.getClass().getSimpleName()
82 + " Device link uri has invalid format: "
88 public void removeDevice(int deviceId
) {
90 m
.removeLinkedDevices(deviceId
);
91 } catch (IOException e
) {
92 throw new Error
.Failure(e
.getClass().getSimpleName() + ": Error while removing device: " + e
.getMessage());
97 public List
<String
> listDevices() {
100 devices
= m
.getLinkedDevices();
101 } catch (IOException
| Error
.Failure e
) {
102 throw new Error
.Failure("Failed to get linked devices: " + e
.getMessage());
105 return devices
.stream().map(d
-> d
.getName() == null ?
"" : d
.getName()).collect(Collectors
.toList());
109 public void updateDeviceName(String deviceName
) {
111 m
.updateAccountAttributes(deviceName
);
112 } catch (IOException
| Signal
.Error
.Failure e
) {
113 throw new Error
.Failure("UpdateAccount error: " + e
.getMessage());
118 public long sendMessage(final String message
, final List
<String
> attachments
, final String recipient
) {
119 var recipients
= new ArrayList
<String
>(1);
120 recipients
.add(recipient
);
121 return sendMessage(message
, attachments
, recipients
);
125 public long sendMessage(final String message
, final List
<String
> attachments
, final List
<String
> recipients
) {
127 final var results
= m
.sendMessage(new Message(message
, attachments
),
128 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
129 .map(RecipientIdentifier
.class::cast
)
130 .collect(Collectors
.toSet()));
132 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
133 return results
.getTimestamp();
134 } catch (AttachmentInvalidException e
) {
135 throw new Error
.AttachmentInvalid(e
.getMessage());
136 } catch (IOException e
) {
137 throw new Error
.Failure(e
.getMessage());
138 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
139 throw new Error
.GroupNotFound(e
.getMessage());
144 public long sendRemoteDeleteMessage(
145 final long targetSentTimestamp
, final String recipient
147 var recipients
= new ArrayList
<String
>(1);
148 recipients
.add(recipient
);
149 return sendRemoteDeleteMessage(targetSentTimestamp
, recipients
);
153 public long sendRemoteDeleteMessage(
154 final long targetSentTimestamp
, final List
<String
> recipients
157 final var results
= m
.sendRemoteDeleteMessage(targetSentTimestamp
,
158 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
159 .map(RecipientIdentifier
.class::cast
)
160 .collect(Collectors
.toSet()));
161 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
162 return results
.getTimestamp();
163 } catch (IOException e
) {
164 throw new Error
.Failure(e
.getMessage());
165 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
166 throw new Error
.GroupNotFound(e
.getMessage());
171 public long sendGroupRemoteDeleteMessage(
172 final long targetSentTimestamp
, final byte[] groupId
175 final var results
= m
.sendRemoteDeleteMessage(targetSentTimestamp
,
176 Set
.of(new RecipientIdentifier
.Group(getGroupId(groupId
))));
177 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
178 return results
.getTimestamp();
179 } catch (IOException e
) {
180 throw new Error
.Failure(e
.getMessage());
181 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
182 throw new Error
.GroupNotFound(e
.getMessage());
187 public long sendMessageReaction(
189 final boolean remove
,
190 final String targetAuthor
,
191 final long targetSentTimestamp
,
192 final String recipient
194 var recipients
= new ArrayList
<String
>(1);
195 recipients
.add(recipient
);
196 return sendMessageReaction(emoji
, remove
, targetAuthor
, targetSentTimestamp
, recipients
);
200 public long sendMessageReaction(
202 final boolean remove
,
203 final String targetAuthor
,
204 final long targetSentTimestamp
,
205 final List
<String
> recipients
208 final var results
= m
.sendMessageReaction(emoji
,
210 getSingleRecipientIdentifier(targetAuthor
, m
.getSelfNumber()),
212 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
213 .map(RecipientIdentifier
.class::cast
)
214 .collect(Collectors
.toSet()));
215 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
216 return results
.getTimestamp();
217 } catch (IOException e
) {
218 throw new Error
.Failure(e
.getMessage());
219 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
220 throw new Error
.GroupNotFound(e
.getMessage());
225 public void sendTyping(
226 final String recipient
, final boolean stop
227 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.UntrustedIdentity
{
229 var recipients
= new ArrayList
<String
>(1);
230 recipients
.add(recipient
);
231 m
.sendTypingMessage(stop ? TypingAction
.STOP
: TypingAction
.START
,
232 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
233 .map(RecipientIdentifier
.class::cast
)
234 .collect(Collectors
.toSet()));
235 } catch (IOException e
) {
236 throw new Error
.Failure(e
.getMessage());
237 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
238 throw new Error
.GroupNotFound(e
.getMessage());
239 } catch (UntrustedIdentityException e
) {
240 throw new Error
.UntrustedIdentity(e
.getMessage());
245 public void sendReadReceipt(
246 final String recipient
, final List
<Long
> messageIds
247 ) throws Error
.Failure
, Error
.UntrustedIdentity
{
249 m
.sendReadReceipt(getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()), messageIds
);
250 } catch (IOException e
) {
251 throw new Error
.Failure(e
.getMessage());
252 } catch (UntrustedIdentityException e
) {
253 throw new Error
.UntrustedIdentity(e
.getMessage());
258 public void sendContacts() {
261 } catch (IOException e
) {
262 throw new Error
.Failure("SendContacts error: " + e
.getMessage());
267 public void sendSyncRequest() {
269 m
.requestAllSyncData();
270 } catch (IOException e
) {
271 throw new Error
.Failure("Request sync data error: " + e
.getMessage());
276 public long sendNoteToSelfMessage(
277 final String message
, final List
<String
> attachments
278 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.UntrustedIdentity
{
280 final var results
= m
.sendMessage(new Message(message
, attachments
),
281 Set
.of(RecipientIdentifier
.NoteToSelf
.INSTANCE
));
282 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
283 return results
.getTimestamp();
284 } catch (AttachmentInvalidException e
) {
285 throw new Error
.AttachmentInvalid(e
.getMessage());
286 } catch (IOException e
) {
287 throw new Error
.Failure(e
.getMessage());
288 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
289 throw new Error
.GroupNotFound(e
.getMessage());
294 public void sendEndSessionMessage(final List
<String
> recipients
) {
296 final var results
= m
.sendEndSessionMessage(getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()));
297 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
298 } catch (IOException e
) {
299 throw new Error
.Failure(e
.getMessage());
304 public long sendGroupMessage(final String message
, final List
<String
> attachments
, final byte[] groupId
) {
306 var results
= m
.sendMessage(new Message(message
, attachments
),
307 Set
.of(new RecipientIdentifier
.Group(getGroupId(groupId
))));
308 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
309 return results
.getTimestamp();
310 } catch (IOException e
) {
311 throw new Error
.Failure(e
.getMessage());
312 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
313 throw new Error
.GroupNotFound(e
.getMessage());
314 } catch (AttachmentInvalidException e
) {
315 throw new Error
.AttachmentInvalid(e
.getMessage());
320 public long sendGroupMessageReaction(
322 final boolean remove
,
323 final String targetAuthor
,
324 final long targetSentTimestamp
,
328 final var results
= m
.sendMessageReaction(emoji
,
330 getSingleRecipientIdentifier(targetAuthor
, m
.getSelfNumber()),
332 Set
.of(new RecipientIdentifier
.Group(getGroupId(groupId
))));
333 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
334 return results
.getTimestamp();
335 } catch (IOException e
) {
336 throw new Error
.Failure(e
.getMessage());
337 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
338 throw new Error
.GroupNotFound(e
.getMessage());
342 // Since contact names might be empty if not defined, also potentially return
345 public String
getContactName(final String number
) {
346 final var name
= m
.getContactOrProfileName(getSingleRecipientIdentifier(number
, m
.getSelfNumber()));
347 return name
== null ?
"" : name
;
351 public void setContactName(final String number
, final String name
) {
353 m
.setContactName(getSingleRecipientIdentifier(number
, m
.getSelfNumber()), name
);
354 } catch (NotMasterDeviceException e
) {
355 throw new Error
.Failure("This command doesn't work on linked devices.");
356 } catch (UnregisteredUserException e
) {
357 throw new Error
.Failure("Contact is not registered.");
362 public void setExpirationTimer(final String number
, final int expiration
) {
364 m
.setExpirationTimer(getSingleRecipientIdentifier(number
, m
.getSelfNumber()), expiration
);
365 } catch (IOException e
) {
366 throw new Error
.Failure(e
.getMessage());
371 public void setContactBlocked(final String number
, final boolean blocked
) {
373 m
.setContactBlocked(getSingleRecipientIdentifier(number
, m
.getSelfNumber()), blocked
);
374 } catch (NotMasterDeviceException e
) {
375 throw new Error
.Failure("This command doesn't work on linked devices.");
376 } catch (IOException e
) {
377 throw new Error
.Failure(e
.getMessage());
382 public void setGroupBlocked(final byte[] groupId
, final boolean blocked
) {
384 m
.setGroupBlocked(getGroupId(groupId
), blocked
);
385 } catch (GroupNotFoundException e
) {
386 throw new Error
.GroupNotFound(e
.getMessage());
387 } catch (IOException e
) {
388 throw new Error
.Failure(e
.getMessage());
393 public List
<byte[]> getGroupIds() {
394 var groups
= m
.getGroups();
395 var ids
= new ArrayList
<byte[]>(groups
.size());
396 for (var group
: groups
) {
397 ids
.add(group
.getGroupId().serialize());
403 public String
getGroupName(final byte[] groupId
) {
404 var group
= m
.getGroup(getGroupId(groupId
));
405 if (group
== null || group
.getTitle() == null) {
408 return group
.getTitle();
413 public List
<String
> getGroupMembers(final byte[] groupId
) {
414 var group
= m
.getGroup(getGroupId(groupId
));
418 return group
.getMembers().stream().map(RecipientAddress
::getLegacyIdentifier
).collect(Collectors
.toList());
423 public byte[] updateGroup(byte[] groupId
, String name
, List
<String
> members
, String avatar
) {
425 groupId
= nullIfEmpty(groupId
);
426 name
= nullIfEmpty(name
);
427 avatar
= nullIfEmpty(avatar
);
428 final var memberIdentifiers
= getSingleRecipientIdentifiers(members
, m
.getSelfNumber());
429 if (groupId
== null) {
430 final var results
= m
.createGroup(name
, memberIdentifiers
, avatar
== null ?
null : new File(avatar
));
431 checkSendMessageResults(results
.second().getTimestamp(), results
.second().getResults());
432 return results
.first().serialize();
434 final var results
= m
.updateGroup(getGroupId(groupId
),
445 avatar
== null ?
null : new File(avatar
),
448 if (results
!= null) {
449 checkSendMessageResults(results
.getTimestamp(), results
.getResults());
453 } catch (IOException e
) {
454 throw new Error
.Failure(e
.getMessage());
455 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
456 throw new Error
.GroupNotFound(e
.getMessage());
457 } catch (AttachmentInvalidException e
) {
458 throw new Error
.AttachmentInvalid(e
.getMessage());
463 public boolean isRegistered() {
468 public boolean isRegistered(String number
) {
469 var result
= isRegistered(List
.of(number
));
470 return result
.get(0);
474 public List
<Boolean
> isRegistered(List
<String
> numbers
) {
475 var results
= new ArrayList
<Boolean
>();
476 if (numbers
.isEmpty()) {
480 Map
<String
, Pair
<String
, UUID
>> registered
;
482 registered
= m
.areUsersRegistered(new HashSet
<>(numbers
));
483 } catch (IOException e
) {
484 throw new Error
.Failure(e
.getMessage());
487 return numbers
.stream().map(number
-> {
488 var uuid
= registered
.get(number
).second();
490 }).collect(Collectors
.toList());
494 public void updateProfile(
500 final boolean removeAvatar
503 givenName
= nullIfEmpty(givenName
);
504 familyName
= nullIfEmpty(familyName
);
505 about
= nullIfEmpty(about
);
506 aboutEmoji
= nullIfEmpty(aboutEmoji
);
507 avatarPath
= nullIfEmpty(avatarPath
);
508 Optional
<File
> avatarFile
= removeAvatar
510 : avatarPath
== null ?
null : Optional
.of(new File(avatarPath
));
511 m
.setProfile(givenName
, familyName
, about
, aboutEmoji
, avatarFile
);
512 } catch (IOException e
) {
513 throw new Error
.Failure(e
.getMessage());
518 public void updateProfile(
521 final String aboutEmoji
,
523 final boolean removeAvatar
525 updateProfile(name
, "", about
, aboutEmoji
, avatarPath
, removeAvatar
);
529 public void removePin() {
531 m
.setRegistrationLockPin(Optional
.absent());
532 } catch (UnauthenticatedResponseException e
) {
533 throw new Error
.Failure("Remove pin failed with unauthenticated response: " + e
.getMessage());
534 } catch (IOException e
) {
535 throw new Error
.Failure("Remove pin error: " + e
.getMessage());
540 public void setPin(String registrationLockPin
) {
542 m
.setRegistrationLockPin(Optional
.of(registrationLockPin
));
543 } catch (UnauthenticatedResponseException e
) {
544 throw new Error
.Failure("Set pin error failed with unauthenticated response: " + e
.getMessage());
545 } catch (IOException e
) {
546 throw new Error
.Failure("Set pin error: " + e
.getMessage());
550 // Provide option to query a version string in order to react on potential
551 // future interface changes
553 public String
version() {
554 return BaseConfig
.PROJECT_VERSION
;
557 // Create a unique list of Numbers from Identities and Contacts to really get
558 // all numbers the system knows
560 public List
<String
> listNumbers() {
561 return Stream
.concat(m
.getIdentities().stream().map(Identity
::getRecipient
),
562 m
.getContacts().stream().map(Pair
::first
))
563 .map(a
-> a
.getNumber().orElse(null))
564 .filter(Objects
::nonNull
)
566 .collect(Collectors
.toList());
570 public List
<String
> getContactNumber(final String name
) {
571 // Contact names have precedence.
572 var numbers
= new ArrayList
<String
>();
573 var contacts
= m
.getContacts();
574 for (var c
: contacts
) {
575 if (name
.equals(c
.second().getName())) {
576 numbers
.add(c
.first().getLegacyIdentifier());
579 // Try profiles if no contact name was found
580 for (var identity
: m
.getIdentities()) {
581 final var address
= identity
.getRecipient();
582 var number
= address
.getNumber().orElse(null);
583 if (number
!= null) {
584 Profile profile
= null;
586 profile
= m
.getRecipientProfile(RecipientIdentifier
.Single
.fromAddress(address
));
587 } catch (UnregisteredUserException ignored
) {
589 if (profile
!= null && profile
.getDisplayName().equals(name
)) {
598 public void quitGroup(final byte[] groupId
) {
599 var group
= getGroupId(groupId
);
601 m
.quitGroup(group
, Set
.of());
602 } catch (GroupNotFoundException
| NotAGroupMemberException e
) {
603 throw new Error
.GroupNotFound(e
.getMessage());
604 } catch (IOException
| LastGroupAdminException e
) {
605 throw new Error
.Failure(e
.getMessage());
610 public byte[] joinGroup(final String groupLink
) {
612 final var linkUrl
= GroupInviteLinkUrl
.fromUri(groupLink
);
613 if (linkUrl
== null) {
614 throw new Error
.Failure("Group link is invalid:");
616 final var result
= m
.joinGroup(linkUrl
);
617 return result
.first().serialize();
618 } catch (GroupInviteLinkUrl
.InvalidGroupLinkException
| GroupLinkNotActiveException e
) {
619 throw new Error
.Failure("Group link is invalid: " + e
.getMessage());
620 } catch (GroupInviteLinkUrl
.UnknownGroupLinkVersionException e
) {
621 throw new Error
.Failure("Group link was created with an incompatible version: " + e
.getMessage());
622 } catch (IOException e
) {
623 throw new Error
.Failure(e
.getMessage());
628 public boolean isContactBlocked(final String number
) {
629 return m
.isContactBlocked(getSingleRecipientIdentifier(number
, m
.getSelfNumber()));
633 public boolean isGroupBlocked(final byte[] groupId
) {
634 var group
= m
.getGroup(getGroupId(groupId
));
638 return group
.isBlocked();
643 public boolean isMember(final byte[] groupId
) {
644 var group
= m
.getGroup(getGroupId(groupId
));
648 return group
.isMember();
653 public String
uploadStickerPack(String stickerPackPath
) {
654 File path
= new File(stickerPackPath
);
656 return m
.uploadStickerPack(path
).toString();
657 } catch (IOException e
) {
658 throw new Error
.Failure("Upload error (maybe image size is too large):" + e
.getMessage());
659 } catch (StickerPackInvalidException e
) {
660 throw new Error
.Failure("Invalid sticker pack: " + e
.getMessage());
664 private static void checkSendMessageResult(long timestamp
, SendMessageResult result
) throws DBusExecutionException
{
665 var error
= ErrorUtils
.getErrorMessageFromSendMessageResult(result
);
671 final var message
= timestamp
+ "\nFailed to send message:\n" + error
+ '\n';
673 if (result
.getIdentityFailure() != null) {
674 throw new Error
.UntrustedIdentity(message
);
676 throw new Error
.Failure(message
);
680 private static void checkSendMessageResults(
681 long timestamp
, Map
<RecipientIdentifier
, List
<SendMessageResult
>> results
682 ) throws DBusExecutionException
{
683 final var sendMessageResults
= results
.values().stream().findFirst();
684 if (results
.size() == 1 && sendMessageResults
.get().size() == 1) {
685 checkSendMessageResult(timestamp
, sendMessageResults
.get().stream().findFirst().get());
689 var errors
= ErrorUtils
.getErrorMessagesFromSendMessageResults(results
);
690 if (errors
.size() == 0) {
694 var message
= new StringBuilder();
695 message
.append(timestamp
).append('\n');
696 message
.append("Failed to send (some) messages:\n");
697 for (var error
: errors
) {
698 message
.append(error
).append('\n');
701 throw new Error
.Failure(message
.toString());
704 private static void checkSendMessageResults(
705 long timestamp
, Collection
<SendMessageResult
> results
706 ) throws DBusExecutionException
{
707 if (results
.size() == 1) {
708 checkSendMessageResult(timestamp
, results
.stream().findFirst().get());
712 var errors
= ErrorUtils
.getErrorMessagesFromSendMessageResults(results
);
713 if (errors
.size() == 0) {
717 var message
= new StringBuilder();
718 message
.append(timestamp
).append('\n');
719 message
.append("Failed to send (some) messages:\n");
720 for (var error
: errors
) {
721 message
.append(error
).append('\n');
724 throw new Error
.Failure(message
.toString());
727 private static Set
<RecipientIdentifier
.Single
> getSingleRecipientIdentifiers(
728 final Collection
<String
> recipientStrings
, final String localNumber
729 ) throws DBusExecutionException
{
730 final var identifiers
= new HashSet
<RecipientIdentifier
.Single
>();
731 for (var recipientString
: recipientStrings
) {
732 identifiers
.add(getSingleRecipientIdentifier(recipientString
, localNumber
));
737 private static RecipientIdentifier
.Single
getSingleRecipientIdentifier(
738 final String recipientString
, final String localNumber
739 ) throws DBusExecutionException
{
741 return RecipientIdentifier
.Single
.fromString(recipientString
, localNumber
);
742 } catch (InvalidNumberException e
) {
743 throw new Error
.InvalidNumber(e
.getMessage());
747 private static GroupId
getGroupId(byte[] groupId
) throws DBusExecutionException
{
749 return GroupId
.unknownVersion(groupId
);
750 } catch (Throwable e
) {
751 throw new Error
.InvalidGroupId("Invalid group id: " + e
.getMessage());
755 private byte[] nullIfEmpty(final byte[] array
) {
756 return array
.length
== 0 ?
null : array
;
759 private String
nullIfEmpty(final String name
) {
760 return name
.isEmpty() ?
null : name
;