diff options
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r-- | src/gnunet_chat_lib.c | 74 |
1 files changed, 4 insertions, 70 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index c52ddf4..8c7558d 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -88,46 +88,7 @@ GNUNET_CHAT_account_create (struct GNUNET_CHAT_Handle *handle, | |||
88 | if ((!handle) || (handle->destruction) || (!name)) | 88 | if ((!handle) || (handle->destruction) || (!name)) |
89 | return GNUNET_SYSERR; | 89 | return GNUNET_SYSERR; |
90 | 90 | ||
91 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; | 91 | return handle_create_account(handle, name); |
92 | while (accounts) | ||
93 | { | ||
94 | if (!(accounts->account)) | ||
95 | goto skip_account; | ||
96 | |||
97 | if ((accounts->account->name) && | ||
98 | (0 == strcmp(accounts->account->name, name))) | ||
99 | return GNUNET_NO; | ||
100 | |||
101 | skip_account: | ||
102 | accounts = accounts->next; | ||
103 | } | ||
104 | |||
105 | accounts = GNUNET_new(struct GNUNET_CHAT_InternalAccounts); | ||
106 | accounts->account = NULL; | ||
107 | accounts->handle = handle; | ||
108 | |||
109 | accounts->op = GNUNET_IDENTITY_create( | ||
110 | handle->identity, | ||
111 | name, | ||
112 | NULL, | ||
113 | GNUNET_IDENTITY_TYPE_ECDSA, | ||
114 | cb_account_creation, | ||
115 | accounts | ||
116 | ); | ||
117 | |||
118 | if (!(accounts->op)) | ||
119 | { | ||
120 | GNUNET_free(accounts); | ||
121 | return GNUNET_SYSERR; | ||
122 | } | ||
123 | |||
124 | GNUNET_CONTAINER_DLL_insert_tail( | ||
125 | handle->accounts_head, | ||
126 | handle->accounts_tail, | ||
127 | accounts | ||
128 | ); | ||
129 | |||
130 | return GNUNET_OK; | ||
131 | } | 92 | } |
132 | 93 | ||
133 | 94 | ||
@@ -140,34 +101,7 @@ GNUNET_CHAT_account_delete(struct GNUNET_CHAT_Handle *handle, | |||
140 | if ((!handle) || (handle->destruction) || (!name)) | 101 | if ((!handle) || (handle->destruction) || (!name)) |
141 | return GNUNET_SYSERR; | 102 | return GNUNET_SYSERR; |
142 | 103 | ||
143 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; | 104 | return handle_delete_account(handle, name); |
144 | while (accounts) | ||
145 | { | ||
146 | if (!(accounts->account)) | ||
147 | goto skip_account; | ||
148 | |||
149 | if ((accounts->account->name) && | ||
150 | (0 == strcmp(accounts->account->name, name))) | ||
151 | break; | ||
152 | |||
153 | skip_account: | ||
154 | accounts = accounts->next; | ||
155 | } | ||
156 | |||
157 | if (!accounts) | ||
158 | return GNUNET_NO; | ||
159 | |||
160 | if (accounts->op) | ||
161 | GNUNET_IDENTITY_cancel(accounts->op); | ||
162 | |||
163 | accounts->op = GNUNET_IDENTITY_delete( | ||
164 | handle->identity, | ||
165 | name, | ||
166 | cb_account_deletion, | ||
167 | handle | ||
168 | ); | ||
169 | |||
170 | return (accounts->op? GNUNET_OK : GNUNET_SYSERR); | ||
171 | } | 105 | } |
172 | 106 | ||
173 | 107 | ||
@@ -186,7 +120,7 @@ GNUNET_CHAT_iterate_accounts (const struct GNUNET_CHAT_Handle *handle, | |||
186 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; | 120 | struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; |
187 | while (accounts) | 121 | while (accounts) |
188 | { | 122 | { |
189 | if (!(accounts->account)) | 123 | if ((!(accounts->account)) || (accounts->op)) |
190 | goto skip_account; | 124 | goto skip_account; |
191 | 125 | ||
192 | result++; | 126 | result++; |
@@ -361,7 +295,7 @@ GNUNET_CHAT_uri_to_string (const struct GNUNET_CHAT_Uri *uri) | |||
361 | char *key_string = GNUNET_IDENTITY_public_key_to_string(&(uri->zone)); | 295 | char *key_string = GNUNET_IDENTITY_public_key_to_string(&(uri->zone)); |
362 | 296 | ||
363 | char *string; | 297 | char *string; |
364 | GNUNET_asprintf( | 298 | GNUNET_asprintf ( |
365 | &string, | 299 | &string, |
366 | "gnunet://chat/%s.%s", | 300 | "gnunet://chat/%s.%s", |
367 | key_string, | 301 | key_string, |