-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add account management interface to libtextsecure api
- Loading branch information
Showing
32 changed files
with
464 additions
and
492 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
library/src/org/whispersystems/textsecure/api/TextSecureAccountManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.whispersystems.textsecure.api; | ||
|
||
import org.whispersystems.libaxolotl.IdentityKey; | ||
import org.whispersystems.libaxolotl.state.PreKeyRecord; | ||
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord; | ||
import org.whispersystems.libaxolotl.util.guava.Optional; | ||
import org.whispersystems.textsecure.push.ContactTokenDetails; | ||
import org.whispersystems.textsecure.push.PushServiceSocket; | ||
import org.whispersystems.textsecure.push.SignedPreKeyEntity; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class TextSecureAccountManager { | ||
|
||
private final PushServiceSocket pushServiceSocket; | ||
|
||
public TextSecureAccountManager(String url, PushServiceSocket.TrustStore trustStore, | ||
String user, String password) | ||
{ | ||
this.pushServiceSocket = new PushServiceSocket(url, trustStore, user, password); | ||
} | ||
|
||
public void setGcmId(Optional<String> gcmRegistrationId) throws IOException { | ||
if (gcmRegistrationId.isPresent()) { | ||
this.pushServiceSocket.registerGcmId(gcmRegistrationId.get()); | ||
} else { | ||
this.pushServiceSocket.unregisterGcmId(); | ||
} | ||
} | ||
|
||
public void requestSmsVerificationCode() throws IOException { | ||
this.pushServiceSocket.createAccount(false); | ||
} | ||
|
||
public void requestVoiceVerificationCode() throws IOException { | ||
this.pushServiceSocket.createAccount(true); | ||
} | ||
|
||
public void verifyAccount(String verificationCode, String signalingKey, | ||
boolean supportsSms, int axolotlRegistrationId) | ||
throws IOException | ||
{ | ||
this.pushServiceSocket.verifyAccount(verificationCode, signalingKey, | ||
supportsSms, axolotlRegistrationId); | ||
} | ||
|
||
public void setPreKeys(IdentityKey identityKey, PreKeyRecord lastResortKey, | ||
SignedPreKeyRecord signedPreKey, List<PreKeyRecord> oneTimePreKeys) | ||
throws IOException | ||
{ | ||
this.pushServiceSocket.registerPreKeys(identityKey, lastResortKey, signedPreKey, oneTimePreKeys); | ||
} | ||
|
||
public int getPreKeysCount() throws IOException { | ||
return this.pushServiceSocket.getAvailablePreKeys(); | ||
} | ||
|
||
public void setSignedPreKey(SignedPreKeyRecord signedPreKey) throws IOException { | ||
this.pushServiceSocket.setCurrentSignedPreKey(signedPreKey); | ||
} | ||
|
||
public SignedPreKeyEntity getSignedPreKey() throws IOException { | ||
return this.pushServiceSocket.getCurrentSignedPreKey(); | ||
} | ||
|
||
public Optional<ContactTokenDetails> getContact(String contactToken) throws IOException { | ||
return Optional.fromNullable(this.pushServiceSocket.getContactTokenDetails(contactToken)); | ||
} | ||
|
||
public List<ContactTokenDetails> getContacts(Set<String> contactTokens) { | ||
return this.pushServiceSocket.retrieveDirectory(contactTokens); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re/directory/NotInDirectoryException.java → ...sms/database/NotInDirectoryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.whispersystems.textsecure.directory; | ||
package org.thoughtcrime.securesms.database; | ||
|
||
public class NotInDirectoryException extends Throwable { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.