mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-04 05:00:39 +00:00
Dbus group methods
And update documentation ==== Reimplemented methods ==== removeDevice() -> <>:: - becomes a device method (implemented by AsamK) updateDeviceName(deviceName<s>) -> <>:: - becomes setDeviceName and is a device method (implemented by AsamK) setDeviceName(deviceName<s>) -> <>:: - allow changing local name for device (updating AsamK's implementation) getDevice(deviceId<x>) -> devicePath<o>:: - prevent crash when negative number is given for deviceId (updating AsamK's implementation) sendTyping(typingAction<b>, groupIdStrings<as>, numbers<as>) -> <>:: - conform to sendTyping command and flesh it out link() -> deviceLinkUri<s>:: - restore variant where default name is "cli" ==== New device methods ==== getDeviceName() -> deviceName<s>:: ==== Already implemented, newly documented methods ==== getSelfNumber() -> number<s>:: (implemented by AsamK) ==== Other new methods ==== getGroupId(groupName<s>) -> groupId<ay>:: getGroupIdStrings() -> groupIdStrings<as>:: getGroupIdString(groupName<s>) -> groupIdString<s>:: getGroupNames() -> groupNames<as>:: updateGroup(groupId<ay>, name<s>, description<s>, addMembers<s>, removeMembers<s>, addAdmins<s>, removeAdmins<s>, resetGroupLink<b>, groupLinkState<s>, addMemberPermission<s>, editDetailsPermission<s>, avatar<s>, expiration<i>, isAnnouncementGroup<b>) -> groupId<ay>:: updateGroup(groupId<ay>, name<s>, description<s>, addMembers<s>, removeMembers<s>, addAdmins<s>, removeAdmins<s>, resetGroupLink<b>, groupLinkState<s>, addMemberPermission<s>, editDetailsPermission<s>, avatar<s>, expiration<i>) -> groupId<ay>:: getGroupInviteUri(groupId<ay>) -> inviteUri<s>:: getGroupAdminMembers(groupId<ay>) -> groupAdminMembers<as>:: getGroupPendingMembers(groupId<ay>) -> groupPendingMembers<as>:: getGroupRequestingMembers(groupId<ay>) -> groupRequestingMembers<as>:: updateMembers(groupId<ay>, members<as>, addToMembers<b>) -> memberList<as>:: updateAdmins(groupId<ay>, admins<as>, addToAdmins<b>) -> adminList<as>:: setGroupAnnounceOnly(groupId<ay>, isAnnouncementGroup<b>) -> <>:: isGroupAnnounceOnly(groupId<ay>) -> isAnnouncementGroup<b>:: isAdmin(groupId<ay>) -> isAdmin<b>::
This commit is contained in:
parent
8b83992e95
commit
b1a9ed2bd5
8 changed files with 879 additions and 179 deletions
|
@ -3,7 +3,7 @@ package org.asamk.signal.manager.api;
|
||||||
public class Device {
|
public class Device {
|
||||||
|
|
||||||
private final long id;
|
private final long id;
|
||||||
private final String name;
|
private String name;
|
||||||
private final long created;
|
private final long created;
|
||||||
private final long lastSeen;
|
private final long lastSeen;
|
||||||
private final boolean thisDevice;
|
private final boolean thisDevice;
|
||||||
|
@ -35,4 +35,8 @@ public class Device {
|
||||||
public boolean isThisDevice() {
|
public boolean isThisDevice() {
|
||||||
return thisDevice;
|
return thisDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String deviceName) {
|
||||||
|
this.name = deviceName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,13 @@ method(arg1<type>, arg2<type>, ...) -> return<type>
|
||||||
|
|
||||||
Where <type> is according to DBus specification:
|
Where <type> is according to DBus specification:
|
||||||
|
|
||||||
|
* <a> : Array of ...
|
||||||
* <s> : String
|
* <s> : String
|
||||||
* <ay> : Byte Array
|
* <b> : Boolean (false|true)
|
||||||
* <aay> : Array of Byte Arrays
|
* <i> : Signed int32 integer (int)
|
||||||
* <as> : String Array
|
* <o> : DBusPath object
|
||||||
* <ax> : Array of signed 64 bit integer
|
* <x> : Signed int64 integer (long)
|
||||||
* <b> : Boolean (0|1)
|
* <y> : Byte
|
||||||
* <x> : Signed 64 bit integer
|
|
||||||
* <> : no return value
|
* <> : no return value
|
||||||
|
|
||||||
Exceptions are the names of the Java Exceptions returned in the body field. They typically contain an additional message with details. All Exceptions begin with "org.asamk.Signal.Error." which is omitted here for better readability.
|
Exceptions are the names of the Java Exceptions returned in the body field. They typically contain an additional message with details. All Exceptions begin with "org.asamk.Signal.Error." which is omitted here for better readability.
|
||||||
|
@ -45,9 +45,9 @@ Phone numbers always have the format +<countrycode><regional number>
|
||||||
== Methods
|
== Methods
|
||||||
|
|
||||||
=== Control methods
|
=== Control methods
|
||||||
These methods are available if the daemon is started anonymously (without an explicit `-u USERNAME`).
|
These methods are available if the daemon is started anonymously (without an explicit `-u USERNAME`).
|
||||||
Requests are sent to `/org/asamk/Signal`; requests related to individual accounts are sent to
|
Requests are sent to `/org/asamk/Signal`; requests related to individual accounts are sent to
|
||||||
`/org/asamk/Signal/_441234567890` where the + dialing code is replaced by an underscore (_).
|
`/org/asamk/Signal/_441234567890` where the + dialing code is replaced by an underscore (_).
|
||||||
Only `version()` is activated in single-user mode; the rest are disabled.
|
Only `version()` is activated in single-user mode; the rest are disabled.
|
||||||
|
|
||||||
link() -> deviceLinkUri<s>::
|
link() -> deviceLinkUri<s>::
|
||||||
|
@ -60,7 +60,7 @@ can be captured by a Signal smartphone client. For example:
|
||||||
|
|
||||||
`dbus-send --session --dest=org.asamk.Signal --type=method_call --print-reply /org/asamk/Signal org.asamk.Signal.link string:"My secondary client"|tr '\n' '\0'|sed 's/.*string //g'|sed 's/\"//g'|qrencode -s10 -tANSI256`
|
`dbus-send --session --dest=org.asamk.Signal --type=method_call --print-reply /org/asamk/Signal org.asamk.Signal.link string:"My secondary client"|tr '\n' '\0'|sed 's/.*string //g'|sed 's/\"//g'|qrencode -s10 -tANSI256`
|
||||||
|
|
||||||
Exception: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
listAccounts() -> accountList<as>::
|
listAccounts() -> accountList<as>::
|
||||||
* accountList : Array of all attached accounts in DBus object path form
|
* accountList : Array of all attached accounts in DBus object path form
|
||||||
|
@ -86,29 +86,94 @@ verify(number<s>, verificationCode<s>) -> <>::
|
||||||
|
|
||||||
Command fails if PIN was set after previous registration; use verifyWithPin instead.
|
Command fails if PIN was set after previous registration; use verifyWithPin instead.
|
||||||
|
|
||||||
Exception: Failure, InvalidNumber
|
Exceptions: Failure, InvalidNumber
|
||||||
|
|
||||||
verifyWithPin(number<s>, verificationCode<s>, pin<s>) -> <>::
|
verifyWithPin(number<s>, verificationCode<s>, pin<s>) -> <>::
|
||||||
* number : Phone number
|
* number : Phone number
|
||||||
* verificationCode : Code received from Signal after successful registration request
|
* verificationCode : Code received from Signal after successful registration request
|
||||||
* pin : PIN you set with setPin command after verifying previous registration
|
* pin : PIN you set with setPin command after verifying previous registration
|
||||||
|
|
||||||
Exception: Failure, InvalidNumber
|
Exceptions: Failure, InvalidNumber
|
||||||
|
|
||||||
version() -> version<s>::
|
version() -> version<s>::
|
||||||
* version : Version string of signal-cli
|
* version : Version string of signal-cli
|
||||||
|
|
||||||
Exceptions: None
|
Exceptions: None
|
||||||
|
|
||||||
|
=== Device methods
|
||||||
|
Requests for these methods are sent to a specific device (main or linked); the list is available
|
||||||
|
from the listDevices() method (see below under "Other methods").
|
||||||
|
|
||||||
|
getDeviceName() -> deviceName<s>::
|
||||||
|
* deviceName : Name of this device
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
|
removeDevice() -> <>::
|
||||||
|
|
||||||
|
Exceptions: Failure
|
||||||
|
|
||||||
|
setDeviceName(deviceName<s>) -> <>::
|
||||||
|
* deviceName : Name of this device
|
||||||
|
|
||||||
|
Sets the name of this device locally. If this device is controlled by this signal-cli instance, also sets the name on the Signal servers.
|
||||||
|
|
||||||
|
Exceptions: Failure
|
||||||
|
|
||||||
=== Other methods
|
=== Other methods
|
||||||
|
|
||||||
|
updateAdmins(groupId<ay>, admins<as>, addToAdmins<b>) -> adminList<as>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* admins : Phone numbers of users to grant or deny admin status
|
||||||
|
* addToAdmins : true for add to group admins; false for remove from group admins
|
||||||
|
* adminList : List of admins after command execution
|
||||||
|
|
||||||
|
Exceptions: GroupNotFound, InvalidGroupId, Failure
|
||||||
|
|
||||||
|
updateGroup(groupId<ay>, name<s>, description<s>, addMembers<s>, removeMembers<s>, addAdmins<s>, removeAdmins<s>, resetGroupLink<b>, groupLinkState<s>, addMemberPermission<s>, editDetailsPermission<s>, avatar<s>, expiration<i>, isAnnouncementGroup<b>) -> groupId<ay>::
|
||||||
|
updateGroup(groupId<ay>, name<s>, description<s>, addMembers<s>, removeMembers<s>, addAdmins<s>, removeAdmins<s>, resetGroupLink<b>, groupLinkState<s>, addMemberPermission<s>, editDetailsPermission<s>, avatar<s>, expiration<i>) -> groupId<ay>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* name : Name of group (empty if unchanged)
|
||||||
|
* description : Description (empty if unchanged)
|
||||||
|
* addMembers : String array of new members to be invited to group (empty if unchanged)
|
||||||
|
* removeMembers : String array of members to be removed from group (empty if unchanged)
|
||||||
|
* addAdmins : String array of members granted admin privileges (empty if unchanged)
|
||||||
|
* removeAdmins : String array of members denied admin privileges (empty if unchanged)
|
||||||
|
* resetGroupLink : Boolean (true = change the group link, false = don't change)
|
||||||
|
* groupLinkState : String ("enabled", "enabled-with-approval", "disabled") (empty if unchanged)
|
||||||
|
* addMemberPermission : String of who may add members ("every-member", "only-admins") (empty if unchanged)
|
||||||
|
* editDetailsPermission : String of who may edit group details ("every-member", "only-admins") (empty if unchanged)
|
||||||
|
* avatar : Filename of avatar picture to be set for group (see below).
|
||||||
|
* expiration : Expiration time (in seconds) for messages sent to this group (see below).
|
||||||
|
* isAnnouncementGroup : true=only admins can post, false=any member can post (omit if unchanged)
|
||||||
|
|
||||||
|
If groupId is empty or null, Signal creates a group with a random identifier
|
||||||
|
and returns it. To delete the group avatar, send the name of an empty file; leave field
|
||||||
|
empty if avatar is unchanged. Set expiration time to 0 to disable expirations, set to a
|
||||||
|
negative number to leave unchanged. Omit the isAnnouncementGroup parameter to leave it unchanged.
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
updateGroup(groupId<ay>, newName<s>, members<as>, avatar<s>) -> groupId<ay>::
|
updateGroup(groupId<ay>, newName<s>, members<as>, avatar<s>) -> groupId<ay>::
|
||||||
* groupId : Byte array representing the internal group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
* newName : New name of group (empty if unchanged)
|
* newName : New name of group (empty if unchanged)
|
||||||
* members : String array of new members to be invited to group
|
* members : String array of new members to be invited to group
|
||||||
* avatar : Filename of avatar picture to be set for group (empty if none)
|
* avatar : Filename of avatar picture to be set for group (empty if none)
|
||||||
|
|
||||||
Exceptions: AttachmentInvalid, Failure, InvalidNumber, GroupNotFound
|
If groupId is empty or null, Signal creates a group with a random identifier
|
||||||
|
and returns it. To delete the group avatar, send the name of an empty file; leave field
|
||||||
|
empty if avatar is unchanged. Set expiration time to 0 to disable expirations.
|
||||||
|
|
||||||
|
Exceptions: AttachmentInvalid, Failure, GroupNotFound, InvalidGroupId, InvalidNumber
|
||||||
|
|
||||||
|
updateMembers(groupId<ay>, members<as>, addToMembers<b>) -> memberList<as>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* members : Phone numbers of users to add to or remove from group
|
||||||
|
* addToMembers : true for add to group members; false for remove from group members
|
||||||
|
* active : Boolean representing whether you are a member of the group
|
||||||
|
* memberList : List of members after command execution
|
||||||
|
|
||||||
|
Exceptions: GroupNotFound, Failure, InvalidGroupId, InvalidNumber
|
||||||
|
|
||||||
updateProfile(name<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
|
updateProfile(name<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
|
||||||
updateProfile(givenName<s>, familyName<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
|
updateProfile(givenName<s>, familyName<s>, about<s>, aboutEmoji <s>, avatar<s>, remove<b>) -> <>::
|
||||||
|
@ -122,16 +187,15 @@ updateProfile(givenName<s>, familyName<s>, about<s>, aboutEmoji <s>, avatar<s>,
|
||||||
|
|
||||||
Exceptions: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
|
|
||||||
setExpirationTimer(number<s>, expiration<i>) -> <>::
|
setExpirationTimer(number<s>, expiration<i>) -> <>::
|
||||||
* number : Phone number of recipient
|
* number : Phone number of recipient
|
||||||
* expiration : int32 for the number of seconds before messages to this recipient disappear. Set to 0 to disable expiration.
|
* expiration : int32 for the number of seconds before messages to this recipient disappear. Set to 0 to disable expiration.
|
||||||
|
|
||||||
Exceptions: Failure
|
Exceptions: Failure, InvalidNumber
|
||||||
|
|
||||||
setContactBlocked(number<s>, block<b>) -> <>::
|
setContactBlocked(number<s>, block<b>) -> <>::
|
||||||
* number : Phone number affected by method
|
* number : Phone number affected by method
|
||||||
* block : 0=remove block , 1=blocked
|
* block : false=remove block, true=blocked
|
||||||
|
|
||||||
Messages from blocked numbers will no longer be forwarded via DBus.
|
Messages from blocked numbers will no longer be forwarded via DBus.
|
||||||
|
|
||||||
|
@ -139,28 +203,36 @@ Exceptions: InvalidNumber
|
||||||
|
|
||||||
setGroupBlocked(groupId<ay>, block<b>) -> <>::
|
setGroupBlocked(groupId<ay>, block<b>) -> <>::
|
||||||
* groupId : Byte array representing the internal group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
* block : 0=remove block , 1=blocked
|
* block : false=remove block , true=blocked
|
||||||
|
|
||||||
Messages from blocked groups will no longer be forwarded via DBus.
|
Messages from blocked groups will no longer be forwarded via DBus.
|
||||||
|
|
||||||
Exceptions: GroupNotFound
|
Exceptions: GroupNotFound, InvalidGroupId
|
||||||
|
|
||||||
joinGroup(inviteURI<s>) -> <>::
|
getGroupInviteUri(groupId<ay>) -> inviteUri<s>::
|
||||||
* inviteURI : String starting with https://signal.group which is generated when you share a group link via Signal App
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* inviteUri : String representing the URI of the group invitation link (starts with https://signal.group)
|
||||||
|
|
||||||
|
Exceptions: Failure, InvalidGroupId
|
||||||
|
|
||||||
|
joinGroup(inviteUri<ay>) -> groupId<ay>::
|
||||||
|
* inviteUri : String representing the URI of the group invitation link (starts with https://signal.group)
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
|
||||||
Exceptions: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
quitGroup(groupId<ay>) -> <>::
|
quitGroup(groupId<ay>) -> <>::
|
||||||
* groupId : Byte array representing the internal group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
|
||||||
Note that quitting a group will not remove the group from the getGroupIds command, but set it inactive which can be tested with isMember()
|
Note that quitting a group will not remove the group from the getGroupIds command, but set it inactive which can be tested with isMember()
|
||||||
|
|
||||||
Exceptions: GroupNotFound, Failure
|
Exceptions: GroupNotFound, Failure, InvalidGroupId
|
||||||
|
|
||||||
isMember(groupId<ay>) -> active<b>::
|
isMember(groupId<ay>) -> isMember<b>::
|
||||||
* groupId : Byte array representing the internal group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* isMember : true=you are a group member; false=you are not a group member
|
||||||
|
|
||||||
Note that this method does not raise an Exception for a non-existing/unknown group but will simply return 0 (false)
|
Exceptions: GroupNotFound, Failure, InvalidGroupId
|
||||||
|
|
||||||
sendEndSessionMessage(recipients<as>) -> <>::
|
sendEndSessionMessage(recipients<as>) -> <>::
|
||||||
* recipients : Array of phone numbers
|
* recipients : Array of phone numbers
|
||||||
|
@ -169,11 +241,11 @@ Exceptions: Failure, InvalidNumber, UntrustedIdentity
|
||||||
|
|
||||||
sendGroupMessage(message<s>, attachments<as>, groupId<ay>) -> timestamp<x>::
|
sendGroupMessage(message<s>, attachments<as>, groupId<ay>) -> timestamp<x>::
|
||||||
* message : Text to send (can be UTF8)
|
* message : Text to send (can be UTF8)
|
||||||
* attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
|
* attachments : String array of filenames or URLs to send as attachments
|
||||||
* groupId : Byte array representing the internal group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
* timestamp : Can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding Signal reply
|
||||||
|
|
||||||
Exceptions: GroupNotFound, Failure, AttachmentInvalid
|
Exceptions: GroupNotFound, Failure, AttachmentInvalid, InvalidGroupId
|
||||||
|
|
||||||
sendContacts() -> <>::
|
sendContacts() -> <>::
|
||||||
|
|
||||||
|
@ -185,37 +257,37 @@ sendSyncRequest() -> <>::
|
||||||
|
|
||||||
Sends a synchronization request to the primary device (for group, contacts, ...). Only works if sent from a secondary device.
|
Sends a synchronization request to the primary device (for group, contacts, ...). Only works if sent from a secondary device.
|
||||||
|
|
||||||
Exception: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
sendNoteToSelfMessage(message<s>, attachments<as>) -> timestamp<x>::
|
sendNoteToSelfMessage(message<s>, attachments<as>) -> timestamp<x>::
|
||||||
* message : Text to send (can be UTF8)
|
* message : Text to send (can be UTF8)
|
||||||
* attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
|
* attachments : String array of filenames or URLs to send as attachments
|
||||||
* timestamp : Can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding Signal reply
|
||||||
|
|
||||||
Exceptions: Failure, AttachmentInvalid
|
Exceptions: Failure, AttachmentInvalid
|
||||||
|
|
||||||
sendMessage(message<s>, attachments<as>, recipient<s>) -> timestamp<x>::
|
sendMessage(message<s>, attachments<as>, recipient<s>) -> timestamp<x>::
|
||||||
sendMessage(message<s>, attachments<as>, recipients<as>) -> timestamp<x>::
|
sendMessage(message<s>, attachments<as>, recipients<as>) -> timestamp<x>::
|
||||||
* message : Text to send (can be UTF8)
|
* message : Text to send (can be UTF8)
|
||||||
* attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
|
* attachments : String array of filenames or URLs to send as attachments
|
||||||
* recipient : Phone number of a single recipient
|
* recipient : Phone number of a single recipient
|
||||||
* recipients : Array of phone numbers
|
* recipients : String array of phone numbers
|
||||||
* timestamp : Can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding Signal reply
|
||||||
|
|
||||||
Depending on the type of the recipient field this sends a message to one or multiple recipients.
|
Depending on the type of the recipient field this sends a message to one or multiple recipients.
|
||||||
|
|
||||||
Exceptions: AttachmentInvalid, Failure, InvalidNumber, UntrustedIdentity
|
Exceptions: AttachmentInvalid, Failure, InvalidNumber, UntrustedIdentity
|
||||||
|
|
||||||
sendTyping(recipient<s>, stop<b>) -> <>::
|
sendTyping(typingAction<b>, groupIdStrings<as>, numbers<as>) -> <>::
|
||||||
* recipient : Phone number of a single recipient
|
* typingAction : true = start typing, false = stop typing
|
||||||
* targetSentTimestamp : True, if typing state should be stopped
|
* groupIdStrings : List of strings representing the internal group identifiers in Base64 format
|
||||||
|
* numbers : List of phone numbers for recipients
|
||||||
|
|
||||||
Exceptions: Failure, GroupNotFound, UntrustedIdentity
|
Exceptions: Failure, GroupNotFound, UntrustedIdentity
|
||||||
|
|
||||||
|
sendReadReceipt(recipient<s>, targetSentTimestamps<ax>) -> <>::
|
||||||
sendReadReceipt(recipient<s>, targetSentTimestamp<ax>) -> <>::
|
|
||||||
* recipient : Phone number of a single recipient
|
* recipient : Phone number of a single recipient
|
||||||
* targetSentTimestamp : Array of Longs to identify the corresponding signal messages
|
* targetSentTimestamps : Array of Longs to identify the corresponding Signal messages
|
||||||
|
|
||||||
Exceptions: Failure, UntrustedIdentity
|
Exceptions: Failure, UntrustedIdentity
|
||||||
|
|
||||||
|
@ -224,10 +296,10 @@ sendGroupMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimesta
|
||||||
* remove : Boolean, whether a previously sent reaction (emoji) should be removed
|
* remove : Boolean, whether a previously sent reaction (emoji) should be removed
|
||||||
* targetAuthor : String with the phone number of the author of the message to which to react
|
* targetAuthor : String with the phone number of the author of the message to which to react
|
||||||
* targetSentTimestamp : Long representing timestamp of the message to which to react
|
* targetSentTimestamp : Long representing timestamp of the message to which to react
|
||||||
* groupId : Byte array with base64 encoded group identifier
|
* groupId : Byte array representing the internal group identifier
|
||||||
* timestamp : Long, can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding signal reply
|
||||||
|
|
||||||
Exceptions: Failure, InvalidNumber, GroupNotFound
|
Exceptions: Failure, InvalidNumber, GroupNotFound, InvalidGroupId
|
||||||
|
|
||||||
sendMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>, recipient<s>) -> timestamp<x>::
|
sendMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>, recipient<s>) -> timestamp<x>::
|
||||||
sendMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>, recipients<as>) -> timestamp<x>::
|
sendMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>, recipients<as>) -> timestamp<x>::
|
||||||
|
@ -237,7 +309,7 @@ sendMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>
|
||||||
* targetSentTimestamp : Long representing timestamp of the message to which to react
|
* targetSentTimestamp : Long representing timestamp of the message to which to react
|
||||||
* recipient : String with the phone number of a single recipient
|
* recipient : String with the phone number of a single recipient
|
||||||
* recipients : Array of strings with phone numbers, should there be more recipients
|
* recipients : Array of strings with phone numbers, should there be more recipients
|
||||||
* timestamp : Long, can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding Signal reply
|
||||||
|
|
||||||
Depending on the type of the recipient(s) field this sends a reaction to one or multiple recipients.
|
Depending on the type of the recipient(s) field this sends a reaction to one or multiple recipients.
|
||||||
|
|
||||||
|
@ -248,7 +320,7 @@ sendGroupRemoteDeleteMessage(targetSentTimestamp<x>, groupId<ay>) -> timestamp<x
|
||||||
* groupId : Byte array with base64 encoded group identifier
|
* groupId : Byte array with base64 encoded group identifier
|
||||||
* timestamp : Long, can be used to identify the corresponding signal reply
|
* timestamp : Long, can be used to identify the corresponding signal reply
|
||||||
|
|
||||||
Exceptions: Failure, GroupNotFound
|
Exceptions: Failure, GroupNotFound, InvalidGroupId
|
||||||
|
|
||||||
sendRemoteDeleteMessage(targetSentTimestamp<x>, recipient<s>) -> timestamp<x>::
|
sendRemoteDeleteMessage(targetSentTimestamp<x>, recipient<s>) -> timestamp<x>::
|
||||||
sendRemoteDeleteMessage(targetSentTimestamp<x>, recipients<as>) -> timestamp<x>::
|
sendRemoteDeleteMessage(targetSentTimestamp<x>, recipients<as>) -> timestamp<x>::
|
||||||
|
@ -265,66 +337,149 @@ getContactName(number<s>) -> name<s>::
|
||||||
* number : Phone number
|
* number : Phone number
|
||||||
* name : Contact's name in local storage (from the master device for a linked account, or the one set with setContactName); if not set, contact's profile name is used
|
* name : Contact's name in local storage (from the master device for a linked account, or the one set with setContactName); if not set, contact's profile name is used
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
setContactName(number<s>,name<>) -> <>::
|
setContactName(number<s>,name<>) -> <>::
|
||||||
* number : Phone number
|
* number : Phone number
|
||||||
* name : Name to be set in contacts (in local storage with signal-cli)
|
* name : Name to be set in contacts (in local storage with signal-cli)
|
||||||
|
|
||||||
|
Exceptions: InvalidNumber, Failure
|
||||||
|
|
||||||
getGroupIds() -> groupList<aay>::
|
getGroupIds() -> groupList<aay>::
|
||||||
groupList : Array of Byte arrays representing the internal group identifiers
|
groupList : Array of Byte arrays representing the internal group identifiers
|
||||||
|
|
||||||
All groups known are returned, regardless of their active or blocked status. To query that use isMember() and isGroupBlocked()
|
All groups known are returned, regardless of their active or blocked status. To query that use isMember() and isGroupBlocked()
|
||||||
|
|
||||||
getGroupName(groupId<ay>) -> groupName<s>::
|
Exceptions: None
|
||||||
groupName : The display name of the group
|
|
||||||
groupId : Byte array representing the internal group identifier
|
|
||||||
|
|
||||||
Exceptions: None, if the group name is not found an empty string is returned
|
getGroupId(groupName<s>) -> groupId<ay>::
|
||||||
|
* groupName : String representing name of a group
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
|
||||||
|
Exceptions: GroupNotFound
|
||||||
|
|
||||||
|
getGroupIdStrings() -> groupIdStrings<as>::
|
||||||
|
* groupIdStrings : Array of strings representing the internal group identifiers
|
||||||
|
|
||||||
|
All groups known are returned, regardless of their active or blocked status. To query that use isMember() and isGroupBlocked()
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
|
getGroupIdString(groupName<s>) -> groupIdString<s>::
|
||||||
|
* groupName : String representing name of a group
|
||||||
|
* groupIdString : String representing the internal group identifier
|
||||||
|
|
||||||
|
Exceptions: GroupNotFound
|
||||||
|
|
||||||
|
getGroupName(groupId<ay>) -> groupName<s>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* groupName : The display name of the group
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
getGroupNames() -> groupNames<as>::
|
||||||
|
* groupName : Array of strings representing names of groups
|
||||||
|
|
||||||
|
All groups known are returned, regardless of their active or blocked status. To query that use isMember() and isGroupBlocked()
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
getGroupMembers(groupId<ay>) -> members<as>::
|
getGroupMembers(groupId<ay>) -> members<as>::
|
||||||
members : String array with the phone numbers of all active members of a group
|
* groupId : Byte array representing the internal group identifier
|
||||||
groupId : Byte array representing the internal group identifier
|
* members : String array with the phone numbers of all active members of a group
|
||||||
|
|
||||||
Exceptions: None, if the group name is not found an empty array is returned
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
getGroupAdminMembers(groupId<ay>) -> groupAdminMembers<as>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* groupAdminMembers : String array of phone numbers of members granted admin privileges
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
getGroupPendingMembers(groupId<ay>) -> groupPendingMembers<as>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* groupPendingMembers : String array of phone numbers of pending members
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
getGroupRequestingMembers(groupId<ay>) -> groupRequestingMembers<as>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* groupRequestingMembers : String array of phone numbers of requesting members
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
isGroupAnnounceOnly(groupId<ay>) -> isAnnouncementGroup<b>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* isAnnouncementGroup : true=only admins can post, false=any member can post
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
|
setGroupAnnounceOnly(groupId<ay>, isAnnouncementGroup<b>) -> <>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* isAnnouncementGroup : true=only admins can post, false=any member can post
|
||||||
|
|
||||||
|
Exceptions: GroupNotFound, InvalidGroupId, Failure
|
||||||
|
|
||||||
|
isAdmin(groupId<ay>) -> isAdmin<b>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* isAdmin : true=you are a group admin; false=you are not a group admin
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
listNumbers() -> numbers<as>::
|
listNumbers() -> numbers<as>::
|
||||||
numbers : String array of all known numbers
|
* numbers : String array of all known numbers
|
||||||
|
|
||||||
This is a concatenated list of all defined contacts as well of profiles known (e.g. peer group members or sender of received messages)
|
This is a concatenated list of all defined contacts as well of profiles known (e.g. peer group members or sender of received messages)
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
getContactNumber(name<s>) -> numbers<as>::
|
getContactNumber(name<s>) -> numbers<as>::
|
||||||
* numbers : Array of phone number
|
* numbers : Array of phone number
|
||||||
* name : Contact or profile name ("firstname lastname")
|
* name : Contact or profile name ("firstname lastname")
|
||||||
|
|
||||||
Searches contacts and known profiles for a given name and returns the list of all known numbers. May result in e.g. two entries if a contact and profile name is set.
|
Searches contacts and known profiles for a given name and returns the list of all known numbers. May result in e.g. two entries if a contact and profile name is set.
|
||||||
|
|
||||||
isContactBlocked(number<s>) -> state<b>::
|
Exceptions: None
|
||||||
* number : Phone number
|
|
||||||
* state : 1=blocked, 0=not blocked
|
|
||||||
|
|
||||||
Exceptions: None, for unknown numbers 0 (false) is returned
|
isContactBlocked(number<s>) -> blocked<b>::
|
||||||
|
* number : Phone number
|
||||||
|
* blocked : true=blocked, false=not blocked
|
||||||
|
|
||||||
isGroupBlocked(groupId<ay>) -> state<b>::
|
For unknown numbers false is returned but no exception is raised.
|
||||||
* groupId : Byte array representing the internal group identifier
|
|
||||||
* state : 1=blocked, 0=not blocked
|
|
||||||
|
|
||||||
Exceptions: None, for unknown groups 0 (false) is returned
|
Exceptions: InvalidPhoneNumber
|
||||||
|
|
||||||
|
isGroupBlocked(groupId<ay>) -> isGroupBlocked<b>::
|
||||||
|
* groupId : Byte array representing the internal group identifier
|
||||||
|
* isGroupBlocked : true=group is blocked; false=group is not blocked
|
||||||
|
|
||||||
|
Dbus will not forward messages from a group when you have blocked it.
|
||||||
|
|
||||||
|
Exceptions: InvalidGroupId, Failure
|
||||||
|
|
||||||
removePin() -> <>::
|
removePin() -> <>::
|
||||||
|
|
||||||
Removes registration PIN protection.
|
Removes registration PIN protection.
|
||||||
|
|
||||||
Exception: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
setPin(pin<s>) -> <>::
|
setPin(pin<s>) -> <>::
|
||||||
* pin : PIN you set after registration (resets after 7 days of inactivity)
|
* pin : PIN you set after registration (resets after 7 days of inactivity)
|
||||||
|
|
||||||
Sets a registration lock PIN, to prevent others from registering your number.
|
Sets a registration lock PIN, to prevent others from registering your number.
|
||||||
|
|
||||||
Exception: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
version() -> version<s>::
|
version() -> version<s>::
|
||||||
* version : Version string of signal-cli
|
* version : Version string of signal-cli
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
|
getSelfNumber() -> number<s>::
|
||||||
|
* number : Your phone number
|
||||||
|
|
||||||
|
Exceptions: None
|
||||||
|
|
||||||
isRegistered() -> result<b>::
|
isRegistered() -> result<b>::
|
||||||
isRegistered(number<s>) -> result<b>::
|
isRegistered(number<s>) -> result<b>::
|
||||||
isRegistered(numbers<as>) -> results<ab>::
|
isRegistered(numbers<as>) -> results<ab>::
|
||||||
|
@ -333,39 +488,44 @@ isRegistered(numbers<as>) -> results<ab>::
|
||||||
* result : true=number is registered, false=number is not registered
|
* result : true=number is registered, false=number is not registered
|
||||||
* results : Boolean array of results
|
* results : Boolean array of results
|
||||||
|
|
||||||
Exception: InvalidNumber for an incorrectly formatted phone number. For unknown numbers, false is returned, but no exception is raised. If no number is given, returns whether you are registered (presumably true).
|
For unknown numbers, false is returned, but no exception is raised. If no number is given, returns true (indicating that you are registered).
|
||||||
|
|
||||||
|
Exceptions: InvalidNumber
|
||||||
|
|
||||||
addDevice(deviceUri<s>) -> <>::
|
addDevice(deviceUri<s>) -> <>::
|
||||||
* deviceUri : URI in the form of tsdevice:/?uuid=... Normally received from Signal desktop or smartphone app
|
* deviceUri : URI in the form of tsdevice:/?uuid=... Normally displayed by a Signal desktop app, smartphone app, or another signal-cli instance using the `link` control method.
|
||||||
|
|
||||||
Exception: InvalidUri
|
Exceptions: InvalidUri
|
||||||
|
|
||||||
listDevices() -> devices<as>::
|
getDevice(deviceId<x>) -> devicePath<o>::
|
||||||
* devices : String array of linked devices
|
* deviceId : Long representing a (potential) deviceId
|
||||||
|
* devicePath : DBusPath object for the device
|
||||||
|
|
||||||
Exception: Failure
|
Note that this method returns a value even if the device does not exist.
|
||||||
|
|
||||||
removeDevice(deviceId<i>) -> <>::
|
Exceptions: None
|
||||||
* deviceId : Device ID to remove, obtained from listDevices() command
|
|
||||||
|
|
||||||
Exception: Failure
|
listDevices() -> devices<ao>::
|
||||||
|
* devices : Array of DBusPath objects for main device and any linked devices
|
||||||
|
|
||||||
updateDeviceName(deviceName<s>) -> <>::
|
Exceptions: Failure
|
||||||
* deviceName : New name
|
|
||||||
|
|
||||||
Set a new name for this device (main or linked).
|
|
||||||
|
|
||||||
Exception: Failure
|
|
||||||
|
|
||||||
uploadStickerPack(stickerPackPath<s>) -> url<s>::
|
uploadStickerPack(stickerPackPath<s>) -> url<s>::
|
||||||
* stickerPackPath : Path to the manifest.json file or a zip file in the same directory
|
* stickerPackPath : Path to the manifest.json file or a zip file in the same directory
|
||||||
* url : URL of sticker pack after successful upload
|
* url : URL of sticker pack after successful upload
|
||||||
|
|
||||||
Exception: Failure
|
Exceptions: Failure
|
||||||
|
|
||||||
== Signals
|
== Signals
|
||||||
|
|
||||||
SyncMessageReceived (timestamp<x>, sender<s>, destination<s>, groupId<ay>,message<s>, attachments<as>)::
|
SyncMessageReceived (timestamp<x>, sender<s>, destination<s>, groupId<ay>, message<s>, attachments<as>)::
|
||||||
|
* timestamp : Integer value that can be used to associate this e.g. with a sendMessage()
|
||||||
|
* sender : Phone number of the sender
|
||||||
|
* destination : DBus code for destination
|
||||||
|
* groupId : Byte array representing the internal group identifier (empty when private message)
|
||||||
|
* message : Message text
|
||||||
|
* attachments : String array of filenames in the signal-cli storage (~/.local/share/signal-cli/attachments/)
|
||||||
|
|
||||||
The sync message is received when the user sends a message from a linked device.
|
The sync message is received when the user sends a message from a linked device.
|
||||||
|
|
||||||
ReceiptReceived (timestamp<x>, sender<s>)::
|
ReceiptReceived (timestamp<x>, sender<s>)::
|
||||||
|
@ -379,7 +539,7 @@ MessageReceived(timestamp<x>, sender<s>, groupId<ay>, message<s>, attachments<as
|
||||||
* sender : Phone number of the sender
|
* sender : Phone number of the sender
|
||||||
* groupId : Byte array representing the internal group identifier (empty when private message)
|
* groupId : Byte array representing the internal group identifier (empty when private message)
|
||||||
* message : Message text
|
* message : Message text
|
||||||
* attachments : String array of filenames for the attachments. These files are located in the signal-cli storage and the current user needs to have read access there
|
* attachments : String array of filenames in the signal-cli storage (~/.local/share/signal-cli/attachments/)
|
||||||
|
|
||||||
This signal is received whenever we get a private message or a message is posted in a group we are an active member
|
This signal is received whenever we get a private message or a message is posted in a group we are an active member
|
||||||
|
|
||||||
|
|
|
@ -22,47 +22,39 @@ public interface Signal extends DBusInterface {
|
||||||
String message, List<String> attachments, String recipient
|
String message, List<String> attachments, String recipient
|
||||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||||
|
|
||||||
long sendMessage(
|
List<String> getGroupAdminMembers(final byte[] groupId);
|
||||||
String message, List<String> attachments, List<String> recipients
|
|
||||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
|
||||||
|
|
||||||
void sendTyping(
|
List<byte[]> getGroupIds();
|
||||||
String recipient, boolean stop
|
|
||||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
|
||||||
|
|
||||||
void sendReadReceipt(
|
byte[] getGroupId(String groupName) throws Error.GroupNotFound;
|
||||||
String recipient, List<Long> messageIds
|
|
||||||
) throws Error.Failure, Error.UntrustedIdentity;
|
|
||||||
|
|
||||||
long sendRemoteDeleteMessage(
|
List<String> getGroupIdStrings();
|
||||||
long targetSentTimestamp, String recipient
|
|
||||||
) throws Error.Failure, Error.InvalidNumber;
|
|
||||||
|
|
||||||
long sendRemoteDeleteMessage(
|
String getGroupIdString(String groupName) throws Error.GroupNotFound;
|
||||||
long targetSentTimestamp, List<String> recipients
|
|
||||||
) throws Error.Failure, Error.InvalidNumber;
|
|
||||||
|
|
||||||
long sendGroupRemoteDeleteMessage(
|
String getGroupInviteUri(byte[] groupId);
|
||||||
long targetSentTimestamp, byte[] groupId
|
|
||||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
|
||||||
|
|
||||||
long sendMessageReaction(
|
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
||||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
|
|
||||||
) throws Error.InvalidNumber, Error.Failure;
|
|
||||||
|
|
||||||
long sendMessageReaction(
|
String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
|
||||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
|
||||||
) throws Error.InvalidNumber, Error.Failure;
|
|
||||||
|
|
||||||
void sendContacts() throws Error.Failure;
|
List<String> getGroupNames();
|
||||||
|
|
||||||
void sendSyncRequest() throws Error.Failure;
|
List<String> getGroupPendingMembers(final byte[] groupId);
|
||||||
|
|
||||||
long sendNoteToSelfMessage(
|
List<String> getGroupRequestingMembers(final byte[] groupId);
|
||||||
String message, List<String> attachments
|
|
||||||
) throws Error.AttachmentInvalid, Error.Failure;
|
|
||||||
|
|
||||||
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
boolean isAdmin(final byte[] groupId);
|
||||||
|
|
||||||
|
boolean isGroupAnnounceOnly(byte[] groupId);
|
||||||
|
|
||||||
|
boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
|
||||||
|
|
||||||
|
boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
|
||||||
|
|
||||||
|
byte[] joinGroup(final String groupLink) throws Error.Failure;
|
||||||
|
|
||||||
|
void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
|
||||||
|
|
||||||
long sendGroupMessage(
|
long sendGroupMessage(
|
||||||
String message, List<String> attachments, byte[] groupId
|
String message, List<String> attachments, byte[] groupId
|
||||||
|
@ -72,33 +64,35 @@ public interface Signal extends DBusInterface {
|
||||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
|
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
|
||||||
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||||
|
|
||||||
String getContactName(String number) throws Error.InvalidNumber;
|
long sendGroupRemoteDeleteMessage(
|
||||||
|
long targetSentTimestamp, byte[] groupId
|
||||||
|
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
void setContactName(String number, String name) throws Error.InvalidNumber;
|
void setGroupAnnounceOnly(byte[] groupId, boolean isAnnouncementGroup);
|
||||||
|
|
||||||
void setExpirationTimer(final String number, final int expiration) throws Error.Failure;
|
void setExpirationTimer(final String number, final int expiration) throws Error.Failure;
|
||||||
|
|
||||||
void setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
|
|
||||||
|
|
||||||
void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
|
void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
List<byte[]> getGroupIds();
|
List<String> updateAdmins(final byte[] groupId, List<String>admins, boolean addToAdmins) throws Error.GroupNotFound, Error.InvalidGroupId, Error.Failure;
|
||||||
|
|
||||||
String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
|
|
||||||
|
|
||||||
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
|
||||||
|
|
||||||
byte[] updateGroup(
|
byte[] updateGroup(
|
||||||
byte[] groupId, String name, List<String> members, String avatar
|
byte[] groupId, String name, List<String> members, String avatar
|
||||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
boolean isRegistered() throws Error.Failure, Error.InvalidNumber;
|
byte[] updateGroup(
|
||||||
|
byte[] groupId, String name, String description, List<String> addMembers, List<String> removeMembers, List<String> addAdmins, List<String> removeAdmins, boolean resetGroupLink, String groupLinkState, String addMemberPermission, String editDetailsPermission, String avatar, Integer expirationTimer, Boolean isAnnouncementGroup
|
||||||
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
boolean isRegistered(String number) throws Error.Failure, Error.InvalidNumber;
|
byte[] updateGroup(
|
||||||
|
byte[] groupId, String name, String description, List<String> addMembers, List<String> removeMembers, List<String> addAdmins, List<String> removeAdmins, boolean resetGroupLink, String groupLinkState, String addMemberPermission, String editDetailsPermission, String avatar, Integer expirationTimer
|
||||||
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
List<Boolean> isRegistered(List<String> numbers) throws Error.Failure, Error.InvalidNumber;
|
List<String> updateMembers(final byte[] groupId, List<String> members, boolean addToMembers);
|
||||||
|
|
||||||
void addDevice(String uri) throws Error.InvalidUri;
|
void sendContacts() throws Error.Failure;
|
||||||
|
|
||||||
|
void sendSyncRequest() throws Error.Failure;
|
||||||
|
|
||||||
DBusPath getDevice(long deviceId);
|
DBusPath getDevice(long deviceId);
|
||||||
|
|
||||||
|
@ -115,9 +109,13 @@ public interface Signal extends DBusInterface {
|
||||||
boolean removeAvatar
|
boolean removeAvatar
|
||||||
) throws Error.Failure;
|
) throws Error.Failure;
|
||||||
|
|
||||||
void updateProfile(
|
void addDevice(String uri) throws Error.Failure, Error.InvalidUri;
|
||||||
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
|
||||||
) throws Error.Failure;
|
void setContactBlocked(final String number, final boolean blocked) throws Error.Failure;
|
||||||
|
|
||||||
|
boolean isRegistered();
|
||||||
|
boolean isRegistered(String number);
|
||||||
|
List<Boolean> isRegistered(List<String> numbers) throws Error.Failure;
|
||||||
|
|
||||||
void removePin();
|
void removePin();
|
||||||
|
|
||||||
|
@ -125,19 +123,51 @@ public interface Signal extends DBusInterface {
|
||||||
|
|
||||||
String version();
|
String version();
|
||||||
|
|
||||||
List<String> listNumbers();
|
String getContactName(String number) throws Error.InvalidNumber;
|
||||||
|
|
||||||
List<String> getContactNumber(final String name) throws Error.Failure;
|
List<String> getContactNumber(final String name) throws Error.Failure;
|
||||||
|
|
||||||
void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
|
|
||||||
|
|
||||||
boolean isContactBlocked(final String number) throws Error.InvalidNumber;
|
boolean isContactBlocked(final String number) throws Error.InvalidNumber;
|
||||||
|
|
||||||
boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
|
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||||
|
|
||||||
boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
|
long sendMessage(
|
||||||
|
String message, List<String> attachments, List<String> recipients
|
||||||
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||||
|
|
||||||
byte[] joinGroup(final String groupLink) throws Error.Failure;
|
long sendMessageReaction(
|
||||||
|
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
|
||||||
|
) throws Error.InvalidNumber, Error.Failure;
|
||||||
|
|
||||||
|
long sendMessageReaction(
|
||||||
|
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
||||||
|
) throws Error.InvalidNumber, Error.Failure;
|
||||||
|
|
||||||
|
void sendReadReceipt(
|
||||||
|
String recipient, List<Long> targetSentTimestamp
|
||||||
|
) throws Error.Failure, Error.UntrustedIdentity;
|
||||||
|
|
||||||
|
long sendRemoteDeleteMessage(
|
||||||
|
long targetSentTimestamp, String recipient
|
||||||
|
) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
|
long sendRemoteDeleteMessage(
|
||||||
|
long targetSentTimestamp, List<String> recipients
|
||||||
|
) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
|
void setContactName(String number, String name) throws Error.InvalidNumber;
|
||||||
|
|
||||||
|
List<String> listNumbers();
|
||||||
|
|
||||||
|
long sendNoteToSelfMessage(
|
||||||
|
String message, List<String> attachments
|
||||||
|
) throws Error.AttachmentInvalid, Error.Failure;
|
||||||
|
|
||||||
|
void sendTyping(boolean typingAction, List<String> groupIdStrings, List<String> numbers) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||||
|
|
||||||
|
void updateProfile(
|
||||||
|
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
||||||
|
) throws Error.Failure;
|
||||||
|
|
||||||
String uploadStickerPack(String stickerPackPath) throws Error.Failure;
|
String uploadStickerPack(String stickerPackPath) throws Error.Failure;
|
||||||
|
|
||||||
|
@ -265,6 +295,11 @@ public interface Signal extends DBusInterface {
|
||||||
interface Device extends DBusInterface, Properties {
|
interface Device extends DBusInterface, Properties {
|
||||||
|
|
||||||
void removeDevice() throws Error.Failure;
|
void removeDevice() throws Error.Failure;
|
||||||
|
|
||||||
|
String getDeviceName() throws Error.Failure;
|
||||||
|
|
||||||
|
void setDeviceName(String deviceName) throws Error.Failure;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Error {
|
interface Error {
|
||||||
|
|
|
@ -24,6 +24,7 @@ public interface SignalControl extends DBusInterface {
|
||||||
|
|
||||||
void verifyWithPin(String number, String verificationCode, String pin) throws Error.Failure, Error.InvalidNumber;
|
void verifyWithPin(String number, String verificationCode, String pin) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
|
String link() throws Error.Failure;
|
||||||
String link(String newDeviceName) throws Error.Failure;
|
String link(String newDeviceName) throws Error.Failure;
|
||||||
|
|
||||||
public String version();
|
public String version();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
||||||
subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
|
subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupLinkState getGroupLinkState(String value) throws UserErrorException {
|
public static GroupLinkState getGroupLinkState(String value) throws UserErrorException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupPermission getGroupPermission(String value) throws UserErrorException {
|
public static GroupPermission getGroupPermission(String value) throws UserErrorException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,14 +247,17 @@ public class DbusManagerImpl implements Manager {
|
||||||
public void sendTypingMessage(
|
public void sendTypingMessage(
|
||||||
final TypingAction action, final Set<RecipientIdentifier> recipients
|
final TypingAction action, final Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, UntrustedIdentityException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, UntrustedIdentityException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
|
List<String> groupIdStrings = new ArrayList<>();
|
||||||
|
List<String> numbers = new ArrayList<>();
|
||||||
|
boolean typingAction = (action == TypingAction.START);
|
||||||
for (final var recipient : recipients) {
|
for (final var recipient : recipients) {
|
||||||
if (recipient instanceof RecipientIdentifier.Single) {
|
if (recipient instanceof RecipientIdentifier.Single) {
|
||||||
signal.sendTyping(((RecipientIdentifier.Single) recipient).getIdentifier(),
|
numbers.add(((RecipientIdentifier.Single) recipient).getIdentifier());
|
||||||
action == TypingAction.STOP);
|
|
||||||
} else if (recipient instanceof RecipientIdentifier.Group) {
|
} else if (recipient instanceof RecipientIdentifier.Group) {
|
||||||
throw new UnsupportedOperationException();
|
groupIdStrings.add(((RecipientIdentifier.Group) recipient).groupId.toBase64());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
signal.sendTyping(typingAction, groupIdStrings, numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -131,6 +131,11 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String link() throws Error.Failure {
|
||||||
|
return link("cli");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String link(final String newDeviceName) throws Error.Failure {
|
public String link(final String newDeviceName) throws Error.Failure {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
package org.asamk.signal.dbus;
|
package org.asamk.signal.dbus;
|
||||||
|
|
||||||
import org.asamk.Signal;
|
import org.asamk.Signal;
|
||||||
|
import org.asamk.Signal.Error;
|
||||||
import org.asamk.signal.BaseConfig;
|
import org.asamk.signal.BaseConfig;
|
||||||
|
import org.asamk.signal.commands.UpdateGroupCommand;
|
||||||
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
import org.asamk.signal.manager.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
import org.asamk.signal.manager.StickerPackInvalidException;
|
||||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
import org.asamk.signal.manager.UntrustedIdentityException;
|
||||||
|
import org.asamk.signal.manager.api.Device;
|
||||||
|
import org.asamk.signal.manager.api.Group;
|
||||||
import org.asamk.signal.manager.api.Identity;
|
import org.asamk.signal.manager.api.Identity;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
|
import org.asamk.signal.manager.groups.GroupIdFormatException;
|
||||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
||||||
|
@ -19,7 +25,9 @@ import org.asamk.signal.manager.groups.LastGroupAdminException;
|
||||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||||
import org.asamk.signal.manager.storage.recipients.Profile;
|
import org.asamk.signal.manager.storage.recipients.Profile;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
|
import org.asamk.signal.util.CommandUtil;
|
||||||
import org.asamk.signal.util.ErrorUtils;
|
import org.asamk.signal.util.ErrorUtils;
|
||||||
|
|
||||||
import org.freedesktop.dbus.DBusPath;
|
import org.freedesktop.dbus.DBusPath;
|
||||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
|
@ -37,7 +45,9 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -96,6 +106,9 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DBusPath getDevice(long deviceId) {
|
public DBusPath getDevice(long deviceId) {
|
||||||
|
if (deviceId < 0) {
|
||||||
|
throw new Error.InvalidNumber("Invalid deviceId: Negative number");
|
||||||
|
}
|
||||||
updateDevices();
|
updateDevices();
|
||||||
return new DBusPath(getDeviceObjectPath(objectPath, deviceId));
|
return new DBusPath(getDeviceObjectPath(objectPath, deviceId));
|
||||||
}
|
}
|
||||||
|
@ -249,26 +262,6 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendTyping(
|
|
||||||
final String recipient, final boolean stop
|
|
||||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
|
||||||
try {
|
|
||||||
var recipients = new ArrayList<String>(1);
|
|
||||||
recipients.add(recipient);
|
|
||||||
m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
|
||||||
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
|
||||||
.map(RecipientIdentifier.class::cast)
|
|
||||||
.collect(Collectors.toSet()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new Error.Failure(e.getMessage());
|
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
|
||||||
} catch (UntrustedIdentityException e) {
|
|
||||||
throw new Error.UntrustedIdentity(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendReadReceipt(
|
public void sendReadReceipt(
|
||||||
final String recipient, final List<Long> messageIds
|
final String recipient, final List<Long> messageIds
|
||||||
|
@ -367,6 +360,39 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendTyping(boolean typingAction, List<String> groupIdStrings, List<String> numbers) {
|
||||||
|
final boolean noNumbers = numbers == null || numbers.isEmpty();
|
||||||
|
final boolean noGroup = groupIdStrings == null || groupIdStrings.isEmpty();
|
||||||
|
if (noNumbers && noGroup) {
|
||||||
|
throw new Error.Failure("No recipients given");
|
||||||
|
}
|
||||||
|
|
||||||
|
final TypingAction action = typingAction ? TypingAction.START : TypingAction.STOP;
|
||||||
|
final var timestamp = System.currentTimeMillis();
|
||||||
|
final var localNumber = m.getSelfNumber();
|
||||||
|
Set<RecipientIdentifier> recipients = new HashSet<RecipientIdentifier>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!noGroup) {
|
||||||
|
recipients.addAll(CommandUtil.getGroupIdentifiers(groupIdStrings));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!noNumbers) {
|
||||||
|
recipients.addAll(CommandUtil.getSingleRecipientIdentifiers(numbers, localNumber));
|
||||||
|
}
|
||||||
|
m.sendTypingMessage(action, recipients);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error.Failure("Failed to send message: " + e.getMessage());
|
||||||
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
|
throw new Error.InvalidGroupId("Invalid group id: " + e.getMessage());
|
||||||
|
} catch (UserErrorException e) {
|
||||||
|
throw new Error.Failure("Invalid number: " + e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Error.UntrustedIdentity("Failed to send message: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Since contact names might be empty if not defined, also potentially return
|
// Since contact names might be empty if not defined, also potentially return
|
||||||
// the profile name
|
// the profile name
|
||||||
@Override
|
@Override
|
||||||
|
@ -408,8 +434,17 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupBlocked(final byte[] groupId, final boolean blocked) {
|
public void setGroupBlocked(final byte[] groupId, final boolean blocked) {
|
||||||
|
GroupId group = null;
|
||||||
try {
|
try {
|
||||||
m.setGroupBlocked(getGroupId(groupId), blocked);
|
group = getGroupId(groupId);
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
m.setGroupBlocked(group, blocked);
|
||||||
} catch (GroupNotFoundException e) {
|
} catch (GroupNotFoundException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -427,11 +462,58 @@ public class DbusSignalImpl implements Signal {
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getGroupId(String groupName) {
|
||||||
|
List<Group> groups = m.getGroups();
|
||||||
|
for (Group group : groups) {
|
||||||
|
if (groupName.equals(group.getTitle())) {
|
||||||
|
return group.getGroupId().serialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error.GroupNotFound(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupIdStrings() {
|
||||||
|
List<Group> groups = m.getGroups();
|
||||||
|
List<String> idStrings = new ArrayList<>(groups.size());
|
||||||
|
for (Group group : groups) {
|
||||||
|
idStrings.add(group.getGroupId().toBase64());
|
||||||
|
}
|
||||||
|
return idStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupIdString(String groupName) {
|
||||||
|
List<Group> groups = m.getGroups();
|
||||||
|
for (Group group : groups) {
|
||||||
|
if (groupName.equals(group.getTitle())) {
|
||||||
|
return group.getGroupId().toBase64();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error.GroupNotFound(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupNames() {
|
||||||
|
List<Group> groups = m.getGroups();
|
||||||
|
List<String> groupNames = new ArrayList<>(groups.size());
|
||||||
|
for (Group group : groups) {
|
||||||
|
groupNames.add(group.getTitle());
|
||||||
|
}
|
||||||
|
return groupNames;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupName(final byte[] groupId) {
|
public String getGroupName(final byte[] groupId) {
|
||||||
var group = m.getGroup(getGroupId(groupId));
|
Group group = null;
|
||||||
if (group == null || group.getTitle() == null) {
|
try {
|
||||||
return "";
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
} else {
|
} else {
|
||||||
return group.getTitle();
|
return group.getTitle();
|
||||||
}
|
}
|
||||||
|
@ -439,9 +521,14 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getGroupMembers(final byte[] groupId) {
|
public List<String> getGroupMembers(final byte[] groupId) {
|
||||||
var group = m.getGroup(getGroupId(groupId));
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return List.of();
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
} else {
|
} else {
|
||||||
return group.getMembers().stream().map(RecipientAddress::getLegacyIdentifier).collect(Collectors.toList());
|
return group.getMembers().stream().map(RecipientAddress::getLegacyIdentifier).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
@ -487,6 +574,227 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] updateGroup(
|
||||||
|
byte[] groupId,
|
||||||
|
String name,
|
||||||
|
String description,
|
||||||
|
List<String> addMembers,
|
||||||
|
List<String> removeMembers,
|
||||||
|
List<String> addAdmins,
|
||||||
|
List<String> removeAdmins,
|
||||||
|
boolean resetGroupLink,
|
||||||
|
String groupLinkState,
|
||||||
|
String addMemberPermission,
|
||||||
|
String editDetailsPermission,
|
||||||
|
String avatar,
|
||||||
|
Integer expirationTimer
|
||||||
|
) {
|
||||||
|
return updateGroup(
|
||||||
|
groupId,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
addMembers,
|
||||||
|
removeMembers,
|
||||||
|
addAdmins,
|
||||||
|
removeAdmins,
|
||||||
|
resetGroupLink,
|
||||||
|
groupLinkState,
|
||||||
|
addMemberPermission,
|
||||||
|
editDetailsPermission,
|
||||||
|
avatar,
|
||||||
|
expirationTimer,
|
||||||
|
isGroupAnnounceOnly(groupId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] updateGroup(
|
||||||
|
byte[] groupId,
|
||||||
|
String name,
|
||||||
|
String description,
|
||||||
|
List<String> addMembers,
|
||||||
|
List<String> removeMembers,
|
||||||
|
List<String> addAdmins,
|
||||||
|
List<String> removeAdmins,
|
||||||
|
boolean resetGroupLink,
|
||||||
|
String groupLinkState,
|
||||||
|
String addMemberPermission,
|
||||||
|
String editDetailsPermission,
|
||||||
|
String avatar,
|
||||||
|
Integer expirationTimer,
|
||||||
|
Boolean isAnnouncementGroup
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
File avatarFile = null;
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
name = null;
|
||||||
|
}
|
||||||
|
if (description.isEmpty()) {
|
||||||
|
description= null;
|
||||||
|
}
|
||||||
|
if (addMembers.isEmpty()) {
|
||||||
|
addMembers = null;
|
||||||
|
}
|
||||||
|
if (removeMembers.isEmpty()) {
|
||||||
|
removeMembers = null;
|
||||||
|
}
|
||||||
|
if (addAdmins.isEmpty()) {
|
||||||
|
addAdmins = null;
|
||||||
|
}
|
||||||
|
if (removeAdmins.isEmpty()) {
|
||||||
|
removeAdmins = null;
|
||||||
|
}
|
||||||
|
if (groupLinkState.isEmpty()) {
|
||||||
|
groupLinkState = null;
|
||||||
|
}
|
||||||
|
if (addMemberPermission.isEmpty()) {
|
||||||
|
addMemberPermission = null;
|
||||||
|
}
|
||||||
|
if (editDetailsPermission.isEmpty()) {
|
||||||
|
editDetailsPermission = null;
|
||||||
|
}
|
||||||
|
if (avatar.isEmpty()) {
|
||||||
|
avatarFile = null;
|
||||||
|
} else {
|
||||||
|
avatarFile = new File(avatar);
|
||||||
|
//TODO: check if we are sending an empty file. If so, this tells Signal
|
||||||
|
// to delete the avatar, so we should delete it from the local AvatarStore
|
||||||
|
long fileSize = avatarFile.length();
|
||||||
|
if (fileSize == 0) {
|
||||||
|
try {
|
||||||
|
if (avatarFile.exists()) {
|
||||||
|
Files.delete(avatarFile.toPath());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String localNumber = m.getSelfNumber();
|
||||||
|
final var memberIdentifiers = getSingleRecipientIdentifiers(addMembers, localNumber);
|
||||||
|
if (groupId == null) {
|
||||||
|
final var results = m.createGroup(name, memberIdentifiers, avatar == null ? null : new File(avatar));
|
||||||
|
checkSendMessageResults(results.second().getTimestamp(), results.second().getResults());
|
||||||
|
return results.first().serialize();
|
||||||
|
} else {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
getSingleRecipientIdentifiers(addMembers, localNumber),
|
||||||
|
getSingleRecipientIdentifiers(removeMembers, localNumber),
|
||||||
|
getSingleRecipientIdentifiers(addAdmins, localNumber),
|
||||||
|
getSingleRecipientIdentifiers(removeAdmins, localNumber),
|
||||||
|
resetGroupLink,
|
||||||
|
groupLinkState == null ? null : UpdateGroupCommand.getGroupLinkState(groupLinkState),
|
||||||
|
addMemberPermission == null ? null : UpdateGroupCommand.getGroupPermission(addMemberPermission),
|
||||||
|
editDetailsPermission == null ? null : UpdateGroupCommand.getGroupPermission(editDetailsPermission),
|
||||||
|
avatarFile,
|
||||||
|
expirationTimer,
|
||||||
|
isAnnouncementGroup
|
||||||
|
);
|
||||||
|
if (results != null) {
|
||||||
|
checkSendMessageResults(results.getTimestamp(), results.getResults());
|
||||||
|
}
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
|
throw new Error.InvalidGroupId("Invalid group id: " + e.getMessage());
|
||||||
|
} catch (UserErrorException e) {
|
||||||
|
throw new Error.InvalidNumber(e.getMessage());
|
||||||
|
} catch (AttachmentInvalidException e) {
|
||||||
|
throw new Error.AttachmentInvalid(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupInviteUri(byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
GroupInviteLinkUrl groupInviteUri = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
groupInviteUri = group.getGroupInviteLinkUrl();
|
||||||
|
if (groupInviteUri == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return groupInviteUri.getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupPendingMembers(final byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
List<String> members = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
} else {
|
||||||
|
for (RecipientAddress addr : group.getPendingMembers()) {
|
||||||
|
members.add(addr.getNumber().orElse(""));
|
||||||
|
}
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupRequestingMembers(final byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
List<String> members = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
} else {
|
||||||
|
for (RecipientAddress addr : group.getRequestingMembers()) {
|
||||||
|
members.add(addr.getNumber().orElse(""));
|
||||||
|
}
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupAdminMembers(final byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
List<String> members = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
} else {
|
||||||
|
for (RecipientAddress addr : group.getAdminMembers()) {
|
||||||
|
members.add(addr.getNumber().orElse(""));
|
||||||
|
}
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered() {
|
public boolean isRegistered() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -624,7 +932,15 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void quitGroup(final byte[] groupId) {
|
public void quitGroup(final byte[] groupId) {
|
||||||
var group = getGroupId(groupId);
|
GroupId group = null;
|
||||||
|
try {
|
||||||
|
group = getGroupId(groupId);
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
m.quitGroup(group, Set.of());
|
m.quitGroup(group, Set.of());
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException e) {
|
||||||
|
@ -659,9 +975,14 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGroupBlocked(final byte[] groupId) {
|
public boolean isGroupBlocked(final byte[] groupId) {
|
||||||
var group = m.getGroup(getGroupId(groupId));
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return false;
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
} else {
|
} else {
|
||||||
return group.isBlocked();
|
return group.isBlocked();
|
||||||
}
|
}
|
||||||
|
@ -669,9 +990,14 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMember(final byte[] groupId) {
|
public boolean isMember(final byte[] groupId) {
|
||||||
var group = m.getGroup(getGroupId(groupId));
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return false;
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
} else {
|
} else {
|
||||||
return group.isMember();
|
return group.isMember();
|
||||||
}
|
}
|
||||||
|
@ -689,6 +1015,166 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> updateMembers(final byte[] groupId, List<String>members, boolean addToMembers) {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
var localNumber = m.getSelfNumber();
|
||||||
|
if (addToMembers) {
|
||||||
|
var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
getSingleRecipientIdentifiers(members, localNumber),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isGroupAnnounceOnly(groupId)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
getSingleRecipientIdentifiers(members, localNumber),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isGroupAnnounceOnly(groupId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return getGroupMembers(groupId);
|
||||||
|
} catch (NotAGroupMemberException | AssertionError | IOException | AttachmentInvalidException | GroupSendingNotAllowedException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (GroupNotFoundException e) {
|
||||||
|
throw new Error.InvalidGroupId("Invalid group id: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGroupAnnounceOnly(byte[] groupId, boolean isAnnouncementGroup) {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isAnnouncementGroup
|
||||||
|
);
|
||||||
|
} catch (NotAGroupMemberException | AssertionError | IOException | AttachmentInvalidException | GroupSendingNotAllowedException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (GroupNotFoundException e) {
|
||||||
|
throw new Error.InvalidGroupId("Invalid group id: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGroupAnnounceOnly(byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
} else {
|
||||||
|
return group.isAnnouncementGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAdmin(final byte[] groupId) {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
} else {
|
||||||
|
return getGroupAdminMembers(groupId).contains(m.getSelfNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> updateAdmins(final byte[] groupId, List<String>admins, boolean addToAdmins) {
|
||||||
|
Group group = null;
|
||||||
|
try {
|
||||||
|
group = m.getGroup(getGroupId(groupId));
|
||||||
|
if (group == null) {
|
||||||
|
throw new Error.InvalidGroupId("GroupId is null.");
|
||||||
|
}
|
||||||
|
var localNumber = m.getSelfNumber();
|
||||||
|
if (addToAdmins) {
|
||||||
|
var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
getSingleRecipientIdentifiers(admins, localNumber),
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isGroupAnnounceOnly(groupId)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var results = m.updateGroup(getGroupId(groupId),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
getSingleRecipientIdentifiers(admins, localNumber),
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
isGroupAnnounceOnly(groupId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return getGroupAdminMembers(groupId);
|
||||||
|
} catch (NotAGroupMemberException | AssertionError | IOException | AttachmentInvalidException | GroupSendingNotAllowedException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (GroupNotFoundException e) {
|
||||||
|
throw new Error.GroupNotFound("Group not found: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException {
|
private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException {
|
||||||
var error = ErrorUtils.getErrorMessageFromSendMessageResult(result);
|
var error = ErrorUtils.getErrorMessageFromSendMessageResult(result);
|
||||||
|
|
||||||
|
@ -823,17 +1309,23 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDeviceName(String name) {
|
@Override
|
||||||
if (!device.isThisDevice()) {
|
public String getDeviceName() {
|
||||||
throw new Error.Failure("Only the name of this device can be changed");
|
return device.getName();
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
m.updateAccountAttributes(name);
|
@Override
|
||||||
// update device list
|
public void setDeviceName(String deviceName) {
|
||||||
updateDevices();
|
if (device.isThisDevice()) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
throw new Error.Failure(e.getMessage());
|
m.updateAccountAttributes(deviceName);
|
||||||
|
// update device list
|
||||||
|
updateDevices();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error.Failure(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
device.setName(deviceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue