diff options
Diffstat (limited to 'src/gnunet_chat_account.c')
-rw-r--r-- | src/gnunet_chat_account.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gnunet_chat_account.c b/src/gnunet_chat_account.c index 53163ae..2e93c9c 100644 --- a/src/gnunet_chat_account.c +++ b/src/gnunet_chat_account.c | |||
@@ -34,6 +34,7 @@ account_create_from_ego(struct GNUNET_IDENTITY_Ego *ego, | |||
34 | struct GNUNET_CHAT_Account *account = GNUNET_new(struct GNUNET_CHAT_Account); | 34 | struct GNUNET_CHAT_Account *account = GNUNET_new(struct GNUNET_CHAT_Account); |
35 | 35 | ||
36 | account->ego = ego; | 36 | account->ego = ego; |
37 | account->directory = NULL; | ||
37 | account->name = NULL; | 38 | account->name = NULL; |
38 | 39 | ||
39 | util_set_name_field(name, &(account->name)); | 40 | util_set_name_field(name, &(account->name)); |
@@ -44,6 +45,30 @@ account_create_from_ego(struct GNUNET_IDENTITY_Ego *ego, | |||
44 | } | 45 | } |
45 | 46 | ||
46 | void | 47 | void |
48 | account_update_directory (struct GNUNET_CHAT_Account *account, | ||
49 | const char *base_directory) | ||
50 | { | ||
51 | GNUNET_assert((account) && (base_directory)); | ||
52 | |||
53 | if (account->directory) | ||
54 | GNUNET_free(account->directory); | ||
55 | |||
56 | struct GNUNET_IDENTITY_PublicKey key; | ||
57 | GNUNET_IDENTITY_ego_get_public_key(account->ego, &key); | ||
58 | |||
59 | char *key_string = GNUNET_IDENTITY_public_key_to_string(&key); | ||
60 | |||
61 | if (!key_string) | ||
62 | { | ||
63 | account->directory = NULL; | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | util_get_dirname(base_directory, key_string, &(account->directory)); | ||
68 | GNUNET_free(key_string); | ||
69 | } | ||
70 | |||
71 | void | ||
47 | account_destroy(struct GNUNET_CHAT_Account *account) | 72 | account_destroy(struct GNUNET_CHAT_Account *account) |
48 | { | 73 | { |
49 | GNUNET_assert(account); | 74 | GNUNET_assert(account); |
@@ -51,5 +76,8 @@ account_destroy(struct GNUNET_CHAT_Account *account) | |||
51 | if (account->name) | 76 | if (account->name) |
52 | GNUNET_free(account->name); | 77 | GNUNET_free(account->name); |
53 | 78 | ||
79 | if (account->directory) | ||
80 | GNUNET_free(account->directory); | ||
81 | |||
54 | GNUNET_free(account); | 82 | GNUNET_free(account); |
55 | } | 83 | } |