about summary refs log tree commit diff stats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/api.c2
-rw-r--r--src/plugins/api.h2
-rw-r--r--src/plugins/autocompleters.c2
-rw-r--r--src/plugins/autocompleters.h2
-rw-r--r--src/plugins/c_api.c2
-rw-r--r--src/plugins/c_api.h2
-rw-r--r--src/plugins/c_plugins.c2
-rw-r--r--src/plugins/c_plugins.h2
-rw-r--r--src/plugins/callbacks.c2
-rw-r--r--src/plugins/callbacks.h2
-rw-r--r--src/plugins/disco.c2
-rw-r--r--src/plugins/disco.h2
-rw-r--r--src/plugins/plugins.c39
-rw-r--r--src/plugins/plugins.h6
-rw-r--r--src/plugins/profapi.c2
-rw-r--r--src/plugins/profapi.h2
-rw-r--r--src/plugins/python_api.c2
-rw-r--r--src/plugins/python_api.h2
-rw-r--r--src/plugins/python_plugins.c2
-rw-r--r--src/plugins/python_plugins.h2
-rw-r--r--src/plugins/settings.c2
-rw-r--r--src/plugins/settings.h2
-rw-r--r--src/plugins/themes.c2
-rw-r--r--src/plugins/themes.h2
24 files changed, 57 insertions, 32 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c
index d30914dc..4d8434e1 100644
--- a/src/plugins/api.c
+++ b/src/plugins/api.c
@@ -1,7 +1,7 @@
 /*
  * api.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/api.h b/src/plugins/api.h
index 0f4881f0..0ba89f59 100644
--- a/src/plugins/api.h
+++ b/src/plugins/api.h
@@ -1,7 +1,7 @@
 /*
  * api.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/autocompleters.c b/src/plugins/autocompleters.c
index 040fcf4d..814253dd 100644
--- a/src/plugins/autocompleters.c
+++ b/src/plugins/autocompleters.c
@@ -1,7 +1,7 @@
 /*
  * autocompleters.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/autocompleters.h b/src/plugins/autocompleters.h
index edb076f4..dd811894 100644
--- a/src/plugins/autocompleters.h
+++ b/src/plugins/autocompleters.h
@@ -1,7 +1,7 @@
 /*
  * autocompleters.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c
index f3679d8f..3578d8f0 100644
--- a/src/plugins/c_api.c
+++ b/src/plugins/c_api.c
@@ -1,7 +1,7 @@
 /*
  * c_api.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/c_api.h b/src/plugins/c_api.h
index 8416ca20..dbce52e7 100644
--- a/src/plugins/c_api.h
+++ b/src/plugins/c_api.h
@@ -1,7 +1,7 @@
 /*
  * c_api.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/c_plugins.c b/src/plugins/c_plugins.c
index 44010e95..5a3b5957 100644
--- a/src/plugins/c_plugins.c
+++ b/src/plugins/c_plugins.c
@@ -1,7 +1,7 @@
 /*
  * c_plugins.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/c_plugins.h b/src/plugins/c_plugins.h
index 4098170a..a82e92cc 100644
--- a/src/plugins/c_plugins.h
+++ b/src/plugins/c_plugins.h
@@ -1,7 +1,7 @@
 /*
  * c_plugins.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c
index d197a44b..c2e79ff1 100644
--- a/src/plugins/callbacks.c
+++ b/src/plugins/callbacks.c
@@ -1,7 +1,7 @@
 /*
  * callbacks.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/callbacks.h b/src/plugins/callbacks.h
index 23edd8eb..783f073e 100644
--- a/src/plugins/callbacks.h
+++ b/src/plugins/callbacks.h
@@ -1,7 +1,7 @@
 /*
  * callbacks.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/disco.c b/src/plugins/disco.c
index a2889f9a..ae97a758 100644
--- a/src/plugins/disco.c
+++ b/src/plugins/disco.c
@@ -1,7 +1,7 @@
 /*
  * disco.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/disco.h b/src/plugins/disco.h
index 07c6a946..ab19e2a0 100644
--- a/src/plugins/disco.h
+++ b/src/plugins/disco.h
@@ -1,7 +1,7 @@
 /*
  * disco.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index 5ec90d0c..41885541 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -1,7 +1,7 @@
 /*
  * plugins.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
@@ -34,6 +34,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <gio/gio.h>
 
 #include "log.h"
 #include "config.h"
@@ -149,16 +150,19 @@ 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));
             }
         }
         curr = g_slist_next(curr);
+        g_string_free(error_message, TRUE);
     }
 
     g_slist_free_full(contents, g_free);
@@ -167,7 +171,25 @@ plugins_install_all(const char *const path)
 }
 
 gboolean
-plugins_install(const char *const plugin_name, const char *const filename)
+plugins_uninstall(const char *const plugin_name)
+{
+    plugins_unload(plugin_name);
+    char *plugins_dir = files_get_data_path(DIR_PLUGINS);   
+    GString *target_path = g_string_new(plugins_dir);
+    free(plugins_dir);
+    g_string_append(target_path, "/");
+    g_string_append(target_path, plugin_name);
+    GFile *file = g_file_new_for_path(target_path->str);
+    GError *error = NULL;
+    gboolean result = g_file_delete(file, NULL, &error);
+    g_object_unref(file);
+    g_error_free(error);
+    g_string_free(target_path, TRUE);
+    return result;
+}
+
+gboolean
+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,18 +197,19 @@ plugins_install(const char *const plugin_name, const char *const filename)
     g_string_append(target_path, "/");
     g_string_append(target_path, plugin_name);
 
-    ProfPlugin *plugin = g_hash_table_lookup(plugins, plugin_name);
-    if (plugin) {
-        plugins_unload(plugin_name);
+    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;
     }
 
-    gboolean result = copy_file(filename, target_path->str);
+    gboolean result = copy_file(filename, target_path->str, false);
     g_string_free(target_path, TRUE);
 
     if (result) {
         result = plugins_load(plugin_name);
     }
-
     return result;
 }
 
diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h
index 16d6874a..4267cb22 100644
--- a/src/plugins/plugins.h
+++ b/src/plugins/plugins.h
@@ -1,7 +1,7 @@
 /*
  * plugins.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
@@ -114,7 +114,9 @@ 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);
+gboolean plugins_uninstall(const char *const plugin_name);
+gboolean plugins_update(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);
diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c
index 11b9d154..53e175f9 100644
--- a/src/plugins/profapi.c
+++ b/src/plugins/profapi.c
@@ -1,7 +1,7 @@
 /*
  * prof_api.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h
index 48d9f189..68469b30 100644
--- a/src/plugins/profapi.h
+++ b/src/plugins/profapi.h
@@ -1,7 +1,7 @@
 /*
  * prof_api.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index 086ccbfb..99a96634 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -1,7 +1,7 @@
 /*
  * python_api.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/python_api.h b/src/plugins/python_api.h
index 8133c853..cf34c1e6 100644
--- a/src/plugins/python_api.h
+++ b/src/plugins/python_api.h
@@ -1,7 +1,7 @@
 /*
  * python_api.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c
index 6f7c2158..a6339793 100644
--- a/src/plugins/python_plugins.c
+++ b/src/plugins/python_plugins.c
@@ -1,7 +1,7 @@
 /*
  * python_plugins.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/python_plugins.h b/src/plugins/python_plugins.h
index 587d13d7..b5083ff0 100644
--- a/src/plugins/python_plugins.h
+++ b/src/plugins/python_plugins.h
@@ -1,7 +1,7 @@
 /*
  * python_plugins.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/settings.c b/src/plugins/settings.c
index e4286f22..6f4d37c5 100644
--- a/src/plugins/settings.c
+++ b/src/plugins/settings.c
@@ -1,7 +1,7 @@
 /*
  * settings.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/settings.h b/src/plugins/settings.h
index 3a81b2d1..cbff1bbf 100644
--- a/src/plugins/settings.h
+++ b/src/plugins/settings.h
@@ -1,7 +1,7 @@
 /*
  * settings.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/themes.c b/src/plugins/themes.c
index 85c26290..756a9793 100644
--- a/src/plugins/themes.c
+++ b/src/plugins/themes.c
@@ -1,7 +1,7 @@
 /*
  * themes.c
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *
diff --git a/src/plugins/themes.h b/src/plugins/themes.h
index 4feb9f2e..470f7926 100644
--- a/src/plugins/themes.h
+++ b/src/plugins/themes.h
@@ -1,7 +1,7 @@
 /*
  * themes.h
  *
- * Copyright (C) 2012 - 2018 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
  *
  * This file is part of Profanity.
  *