about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPhilip Flohr <philip.flohr@student.kit.edu>2018-05-07 18:27:01 +0200
committerDmitry Podgorny <pasis.ua@gmail.com>2018-09-06 19:28:02 +0300
commit1f66c08567bf85eaa51eeffbc08d60e5903151f2 (patch)
tree3621ac9c668f98efa4c94ad8ae679db84072c7ff /src
parentadb4955c34bd1cddda7482d214787a918d28171b (diff)
downloadprofani-tty-1f66c08567bf85eaa51eeffbc08d60e5903151f2.tar.gz
provide feedback on failure cause if plugin installation fails
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c5
-rw-r--r--src/plugins/plugins.c9
-rw-r--r--src/plugins/plugins.h2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index c8aa22b4..a955e2f8 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6616,12 +6616,13 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args)
             return TRUE;
         }
 
+        GString* error_message = g_string_new(NULL);
         gchar *plugin_name = g_path_get_basename(path);
-        gboolean result = plugins_install(plugin_name, path);
+        gboolean result = plugins_install(plugin_name, path, error_message);
         if (result) {
             cons_show("Plugin installed: %s", plugin_name);
         } else {
-            cons_show("Failed to install plugin: %s", plugin_name);
+            cons_show("Failed to install plugin: %s. %s", plugin_name, error_message->str);
         }
         g_free(plugin_name);
 
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index d10cf5b8..e63aec84 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -149,10 +149,12 @@ plugins_install_all(const char *const path)
     get_file_paths_recursive(path, &contents);
 
     GSList *curr = contents;
+    GString *error_message = NULL;
     while (curr) {
+        error_message = g_string_new(NULL);
         if (g_str_has_suffix(curr->data, ".py") || g_str_has_suffix(curr->data, ".so")) {
             gchar *plugin_name = g_path_get_basename(curr->data);
-            if (plugins_install(plugin_name, curr->data)) {
+            if (plugins_install(plugin_name, curr->data, error_message)) {
                 result->installed = g_slist_append(result->installed, strdup(curr->data));
             } else {
                 result->failed = g_slist_append(result->failed, strdup(curr->data));
@@ -167,7 +169,7 @@ plugins_install_all(const char *const path)
 }
 
 gboolean
-plugins_install(const char *const plugin_name, const char *const filename)
+plugins_install(const char *const plugin_name, const char *const filename, GString *error_message)
 {
     char *plugins_dir = files_get_data_path(DIR_PLUGINS);
     GString *target_path = g_string_new(plugins_dir);
@@ -175,9 +177,10 @@ plugins_install(const char *const plugin_name, const char *const filename)
     g_string_append(target_path, "/");
     g_string_append(target_path, plugin_name);
 
-    if (g_file_test (filename,G_FILE_TEST_EXISTS))
+    if (g_file_test (target_path->str, G_FILE_TEST_EXISTS))
     {
         log_info("Failed to install plugin: %s, file exists", plugin_name);
+        g_string_assign(error_message, "File exists");
         return FALSE;
     }
 
diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h
index 16d6874a..c787ee93 100644
--- a/src/plugins/plugins.h
+++ b/src/plugins/plugins.h
@@ -114,7 +114,7 @@ void plugins_shutdown(void);
 
 void plugins_free_install_result(PluginsInstallResult *result);
 
-gboolean plugins_install(const char *const plugin_name, const char *const filename);
+gboolean plugins_install(const char *const plugin_name, const char *const filename, GString * error_message);
 PluginsInstallResult* plugins_install_all(const char *const path);
 gboolean plugins_load(const char *const name);
 GSList* plugins_load_all(void);