Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/remmina_file.c15
-rw-r--r--src/remmina_file_manager.c34
2 files changed, 34 insertions, 15 deletions
diff --git a/src/remmina_file.c b/src/remmina_file.c
index 2a439ff5d..210d5d9c0 100644
--- a/src/remmina_file.c
+++ b/src/remmina_file.c
@@ -36,10 +36,10 @@
#include "config.h"
-#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
+#include <sys/stat.h>
#include <locale.h>
#include <langinfo.h>
#include <stdlib.h>
@@ -329,12 +329,9 @@ remmina_file_load(const gchar *filename)
TRACE_CALL(__func__);
GKeyFile *gkeyfile;
RemminaFile *remminafile;
- gchar *proto;
- gchar **keys;
gchar *key;
- gchar *resolution_str;
gint i;
- gchar *s, *sec;
+ gchar *s;
RemminaProtocolPlugin *protocol_plugin;
RemminaSecretPlugin *secret_plugin;
gboolean secret_service_available;
@@ -357,7 +354,7 @@ remmina_file_load(const gchar *filename)
protocol_plugin = NULL;
/* Identify the protocol plugin and get pointers to its RemminaProtocolSetting structs */
- proto = g_key_file_get_string(gkeyfile, KEYFILE_GROUP_REMMINA, "protocol", NULL);
+ gchar *proto = g_key_file_get_string(gkeyfile, KEYFILE_GROUP_REMMINA, "protocol", NULL);
if (proto) {
protocol_plugin = (RemminaProtocolPlugin *)remmina_plugin_manager_get_plugin(REMMINA_PLUGIN_TYPE_PROTOCOL, proto);
g_free(proto);
@@ -367,7 +364,7 @@ remmina_file_load(const gchar *filename)
secret_service_available = secret_plugin && secret_plugin->is_service_available();
remminafile->filename = g_strdup(filename);
- keys = g_key_file_get_keys(gkeyfile, KEYFILE_GROUP_REMMINA, NULL, NULL);
+ gchar **keys = g_key_file_get_keys(gkeyfile, KEYFILE_GROUP_REMMINA, NULL, NULL);
if (keys) {
for (i = 0; keys[i]; i++) {
@@ -376,7 +373,7 @@ remmina_file_load(const gchar *filename)
s = g_key_file_get_string(gkeyfile, KEYFILE_GROUP_REMMINA, key, NULL);
if (g_strcmp0(s, ".") == 0) {
if (secret_service_available) {
- sec = secret_plugin->get_password(remminafile, key);
+ gchar *sec = secret_plugin->get_password(remminafile, key);
remmina_file_set_string(remminafile, key, sec);
/* Annotate in spsettings that this value comes from secret_plugin */
g_hash_table_insert(remminafile->spsettings, g_strdup(key), NULL);
@@ -391,7 +388,7 @@ remmina_file_load(const gchar *filename)
} else {
/* If we find "resolution", then we split it in two */
if (strcmp(key, "resolution") == 0) {
- resolution_str = g_key_file_get_string(gkeyfile, KEYFILE_GROUP_REMMINA, key, NULL);
+ gchar *resolution_str = g_key_file_get_string(gkeyfile, KEYFILE_GROUP_REMMINA, key, NULL);
if (remmina_public_split_resolution_string(resolution_str, &w, &h)) {
remmina_file_set_string_ref(remminafile, "resolution_width", g_strdup_printf("%i", w));
remmina_file_set_string_ref(remminafile, "resolution_height", g_strdup_printf("%i", h));
diff --git a/src/remmina_file_manager.c b/src/remmina_file_manager.c
index 687b75f83..6d7fab3d9 100644
--- a/src/remmina_file_manager.c
+++ b/src/remmina_file_manager.c
@@ -36,9 +36,11 @@
#include "config.h"
+#include <errno.h>
#include <gtk/gtk.h>
#include <string.h>
+#include "remmina_log.h"
#include "remmina_public.h"
#include "remmina_pref.h"
#include "remmina_string_array.h"
@@ -49,8 +51,11 @@
static gchar *remminadir;
static gchar *cachedir;
-/* return first found data dir as per XDG specs.
- * The returned string must be freed by the caller with g_free */
+/**
+ * Return datadir_path from pref or first found data dir as per XDG specs.
+ *
+ * The returned string must be freed by the caller with g_free
+ */
gchar *remmina_file_get_datadir(void)
{
TRACE_CALL(__func__);
@@ -99,6 +104,12 @@ static gboolean remmina_file_manager_do_copy(const char *src_path, const char *d
return ok;
}
+/**
+ * It creates the Remmina data and cache folders
+ *
+ * If it finds the legacy ~/.remmina folder it copies the connection profiles in the new folder.
+ *
+ * If it finds default profiles in the XDG_DATA_DIRS it copies the profiles in the user data folder.
void remmina_file_manager_init(void)
{
TRACE_CALL(__func__);
@@ -107,10 +118,21 @@ void remmina_file_manager_init(void)
const gchar *filename;
int i;
- remminadir = g_build_path("/", g_get_user_data_dir(), "remmina", NULL);
- /* Create the XDG_USER_DATA directory */
- g_mkdir_with_parents(remminadir, 0750);
- g_free(remminadir), remminadir = NULL;
+ /* Get and create the XDG_DATA_HOME directory */
+ remminadir = remmina_pref_get_value("datadir_path");
+ if (g_mkdir_with_parents(remminadir, 0750) == 0) {
+ REMMINA_DEBUG ("Remmina data folder %s initialized successfully", remminadir);
+ g_free(remminadir), remminadir = NULL;
+ } else {
+ g_free(remminadir), remminadir = NULL;
+ /* Get and create the XDG_DATA_HOME directory */
+ remminadir = g_build_path("/", g_get_user_data_dir(), "remmina", NULL);
+ if (g_mkdir_with_parents(remminadir, 0750) == 0)
+ REMMINA_DEBUG ("Remmina data folder %s initialized successfully", remminadir);
+ else
+ REMMINA_CRITICAL("Cannot create data folder %s", remminadir);
+ g_free(remminadir), remminadir = NULL;
+ }
/* Create the XDG_CACHE_HOME directory */
cachedir = g_build_path("/", g_get_user_cache_dir(), "remmina", NULL);
g_mkdir_with_parents(cachedir, 0750);