diff options
Diffstat (limited to 'src/userpref.c')
| -rw-r--r-- | src/userpref.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/userpref.c b/src/userpref.c index 10c14a0..6eff534 100644 --- a/src/userpref.c +++ b/src/userpref.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <glib.h> | 22 | #include <glib.h> |
| 23 | #include <glib/gstdio.h> | ||
| 23 | #include <glib/gprintf.h> | 24 | #include <glib/gprintf.h> |
| 24 | #include <stdio.h> | 25 | #include <stdio.h> |
| 25 | #include <stdint.h> | 26 | #include <stdint.h> |
| @@ -30,7 +31,7 @@ | |||
| 30 | #include <gcrypt.h> | 31 | #include <gcrypt.h> |
| 31 | 32 | ||
| 32 | #include "userpref.h" | 33 | #include "userpref.h" |
| 33 | #include "utils.h" | 34 | #include "debug.h" |
| 34 | 35 | ||
| 35 | #define LIBIPHONE_CONF_DIR "libiphone" | 36 | #define LIBIPHONE_CONF_DIR "libiphone" |
| 36 | #define LIBIPHONE_CONF_FILE "libiphonerc" | 37 | #define LIBIPHONE_CONF_FILE "libiphonerc" |
| @@ -105,7 +106,7 @@ static int userpref_set_host_id(const char *host_id) | |||
| 105 | key_file = g_key_file_new(); | 106 | key_file = g_key_file_new(); |
| 106 | 107 | ||
| 107 | /* Store in config file */ | 108 | /* Store in config file */ |
| 108 | log_debug_msg("%s: setting hostID to %s\n", __func__, host_id); | 109 | debug_info("setting hostID to %s", host_id); |
| 109 | g_key_file_set_value(key_file, "Global", "HostID", host_id); | 110 | g_key_file_set_value(key_file, "Global", "HostID", host_id); |
| 110 | 111 | ||
| 111 | /* Write config file on disk */ | 112 | /* Write config file on disk */ |
| @@ -154,7 +155,7 @@ void userpref_get_host_id(char **host_id) | |||
| 154 | userpref_set_host_id(*host_id); | 155 | userpref_set_host_id(*host_id); |
| 155 | } | 156 | } |
| 156 | 157 | ||
| 157 | log_debug_msg("%s: Using %s as HostID\n", __func__, *host_id); | 158 | debug_info("Using %s as HostID", *host_id); |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | /** Determines whether this iPhone has been connected to this system before. | 161 | /** Determines whether this iPhone has been connected to this system before. |
| @@ -212,6 +213,30 @@ userpref_error_t userpref_set_device_public_key(const char *uuid, gnutls_datum_t | |||
| 212 | return USERPREF_E_SUCCESS; | 213 | return USERPREF_E_SUCCESS; |
| 213 | } | 214 | } |
| 214 | 215 | ||
| 216 | /** Remove the public key stored for the device with uuid from this host. | ||
| 217 | * | ||
| 218 | * @param uuid The uuid of the device | ||
| 219 | * | ||
| 220 | * @return USERPREF_E_SUCCESS on success. | ||
| 221 | */ | ||
| 222 | userpref_error_t userpref_remove_device_public_key(const char *uuid) | ||
| 223 | { | ||
| 224 | if (!userpref_has_device_public_key(uuid)) | ||
| 225 | return USERPREF_E_SUCCESS; | ||
| 226 | |||
| 227 | /* build file path */ | ||
| 228 | gchar *device_file = g_strconcat(uuid, ".pem", NULL); | ||
| 229 | gchar *pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, device_file, NULL); | ||
| 230 | |||
| 231 | /* remove file */ | ||
| 232 | g_remove(pem); | ||
| 233 | |||
| 234 | g_free(pem); | ||
| 235 | g_free(device_file); | ||
| 236 | |||
| 237 | return USERPREF_E_SUCCESS; | ||
| 238 | } | ||
| 239 | |||
| 215 | /** Private function which reads the given file into a gnutls structure. | 240 | /** Private function which reads the given file into a gnutls structure. |
| 216 | * | 241 | * |
| 217 | * @param file The filename of the file to read | 242 | * @param file The filename of the file to read |
