]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/textsecure/Manager.java
Make config path configurable
[signal-cli] / src / main / java / org / asamk / textsecure / Manager.java
index f0714ce15f25f26dc07e092381a418421e63d96c..e5a77dcd6425aba7a7bd322b5e71305067551014 100644 (file)
@@ -59,9 +59,9 @@ class Manager implements TextSecure {
     public final static String PROJECT_VERSION = Manager.class.getPackage().getImplementationVersion();
     private final static String USER_AGENT = PROJECT_NAME + " " + PROJECT_VERSION;
 
-    private final static String settingsPath = System.getProperty("user.home") + "/.config/textsecure";
-    private final static String dataPath = settingsPath + "/data";
-    private final static String attachmentsPath = settingsPath + "/attachments";
+    private final String settingsPath;
+    private final String dataPath;
+    private final String attachmentsPath;
 
     private final ObjectMapper jsonProcessot = new ObjectMapper();
     private String username;
@@ -76,8 +76,12 @@ class Manager implements TextSecure {
     private TextSecureAccountManager accountManager;
     private JsonGroupStore groupStore;
 
-    public Manager(String username) {
+    public Manager(String username, String settingsPath) {
         this.username = username;
+        this.settingsPath = settingsPath;
+        this.dataPath = this.settingsPath + "/data";
+        this.attachmentsPath = this.settingsPath + "/attachments";
+
         jsonProcessot.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); // disable autodetect
         jsonProcessot.enable(SerializationFeature.INDENT_OUTPUT); // for pretty print, you can disable it.
         jsonProcessot.enable(SerializationFeature.WRITE_NULL_MAP_VALUES);
@@ -239,7 +243,7 @@ class Manager implements TextSecure {
     public void verifyAccount(String verificationCode) throws IOException {
         verificationCode = verificationCode.replace("-", "");
         signalingKey = Util.getSecret(52);
-        accountManager.verifyAccountWithCode(verificationCode, signalingKey, axolotlStore.getLocalRegistrationId(), false);
+        accountManager.verifyAccountWithCode(verificationCode, signalingKey, axolotlStore.getLocalRegistrationId(), false, true);
 
         //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
         registered = true;
@@ -535,7 +539,7 @@ class Manager implements TextSecure {
     }
 
     public File getAttachmentFile(long attachmentId) {
-        return new File(attachmentsPath + "/" + attachmentId);
+        return new File(attachmentsPath, attachmentId + "");
     }
 
     private File retrieveAttachment(TextSecureAttachmentPointer pointer) throws IOException, InvalidMessageException {