#include "prefs_common.h"
#include "utils.h"
#include "gtkutils.h"
-#include "passcrypt.h"
+#include "password.h"
#include "codeconv.h"
#define CL(x) (((gulong) (x) >> (gulong) 8) & 0xFFUL)
cm_return_if_fail(rcfile != NULL);
if (encoding != NULL)
- g_warning("Encoding is ignored\n");
+ g_warning("Encoding is ignored");
debug_print("Reading configuration...\n");
switch (param[i].type) {
case P_STRING:
+ case P_PASSWORD:
{
gchar *tmp = NULL;
/* be compatible and accept ints */
*((gulong *)param[i].data) = strtoul(value, 0, 10);
break;
- case P_PASSWORD:
- g_free(*((gchar **)param[i].data));
- if (value[0] == '!') {
- gchar *tmp;
- gsize len;
-
- tmp = g_base64_decode(&value[1], &len);
- passcrypt_decrypt(tmp, len);
-
- *((gchar **)param[i].data) =
- *tmp ? g_strdup(tmp) : NULL;
- g_free(tmp);
- } else {
- *((gchar **)param[i].data) =
- *value ? g_strdup(value) : NULL;
- }
- break;
default:
break;
}
#define TRY(func) \
if (!(func)) \
{ \
- g_warning("Failed to write configuration to file\n"); \
+ g_warning("Failed to write configuration to file"); \
if (orig_fp) fclose(orig_fp); \
prefs_file_close_revert(pfile); \
g_free(rcpath); \
}
if ((pfile = prefs_write_open(rcpath)) == NULL) {
- g_warning("Failed to write configuration to file\n");
+ g_warning("Failed to write configuration to file");
if (orig_fp) fclose(orig_fp);
g_free(rcpath);
return;
if (orig_fp) fclose(orig_fp);
if (prefs_file_close(pfile) < 0)
- g_warning("Failed to write configuration to file\n");
+ g_warning("Failed to write configuration to file");
g_free(rcpath);
debug_print("Configuration is saved.\n");
g_free(tmp);
break;
}
+ case P_PASSWORD:
+ return 0; /* Passwords are written to password store. */
case P_INT:
g_snprintf(buf, sizeof(buf), "%s=%d\n", param[i].name,
*((gint *)param[i].data));
g_snprintf(buf, sizeof buf, "%s=#%6.6lx\n", param[i].name,
*((gulong *) param[i].data));
break;
- case P_PASSWORD:
- {
- gchar *tmp = NULL, *tmp2 = NULL;
-
- tmp = *((gchar **)param[i].data);
- if (tmp) {
- gint len;
-
- tmp = g_strdup(tmp);
- len = strlen(tmp);
- passcrypt_encrypt(tmp, len);
- tmp2 = g_base64_encode(tmp, len);
- g_free(tmp);
- tmp = tmp2;
- }
- g_snprintf(buf, sizeof(buf), "%s=!%s\n", param[i].name,
- tmp ?
- tmp : "");
- g_free(tmp);
- }
- break;
default:
/* unrecognized, fail */
debug_print("Unrecognized parameter type\n");
switch (pparam->type) {
case P_STRING:
- case P_PASSWORD:
str = (gchar **)pparam->data;
g_free(*str);
*str = entry_str[0] ? g_strdup(entry_str) : NULL;
break;
+ case P_PASSWORD:
+ break;
case P_USHORT:
*((gushort *)pparam->data) = atoi(entry_str);
break;
*((gint *)pparam->data) = atoi(entry_str);
break;
default:
- g_warning("Invalid PrefType for GtkEntry widget: %d\n",
+ g_warning("Invalid PrefType for GtkEntry widget: %d",
pparam->type);
}
}
*str = pref_get_pref_from_entry(GTK_ENTRY(*pparam->widget));
break;
default:
- g_warning("Invalid escaped PrefType for GtkEntry widget: %d\n",
+ g_warning("Invalid escaped PrefType for GtkEntry widget: %d",
pparam->type);
}
}
void prefs_set_entry(PrefParam *pparam)
{
gchar **str;
-
cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
- case P_PASSWORD:
str = (gchar **)pparam->data;
gtk_entry_set_text(GTK_ENTRY(*pparam->widget),
*str ? *str : "");
itos(*((gushort *)pparam->data)));
break;
default:
- g_warning("Invalid PrefType for GtkEntry widget: %d\n",
+ g_warning("Invalid PrefType for GtkEntry widget: %d",
pparam->type);
}
}
*str ? *str : "");
break;
default:
- g_warning("Invalid escaped PrefType for GtkEntry widget: %d\n",
+ g_warning("Invalid escaped PrefType for GtkEntry widget: %d",
pparam->type);
}
}
switch (pparam->type) {
case P_STRING:
- case P_PASSWORD:
str = (gchar **)pparam->data;
g_free(*str);
if (GTK_IS_EDITABLE(*pparam->widget)) { /* need? */
g_free(text);
break;
default:
- g_warning("Invalid PrefType for GtkText widget: %d\n",
+ g_warning("Invalid PrefType for GtkText widget: %d",
pparam->type);
}
}
*str = pref_get_pref_from_textview(GTK_TEXT_VIEW(*pparam->widget));
break;
default:
- g_warning("Invalid escaped PrefType for GtkText widget: %d\n",
+ g_warning("Invalid escaped PrefType for GtkText widget: %d",
pparam->type);
}
}
switch (pparam->type) {
case P_STRING:
- case P_PASSWORD:
str = (gchar **)pparam->data;
if (*str) {
bufp = buf = alloca(strlen(*str) + 1);
gtk_text_buffer_insert(buffer, &iter, buf, -1);
break;
default:
- g_warning("Invalid PrefType for GtkTextView widget: %d\n",
+ g_warning("Invalid PrefType for GtkTextView widget: %d",
pparam->type);
}
}
*str ? *str : "");
break;
default:
- g_warning("Invalid escaped PrefType for GtkTextView widget: %d\n",
+ g_warning("Invalid escaped PrefType for GtkTextView widget: %d",
pparam->type);
}
}
(GTK_SPIN_BUTTON(*pparam->widget));
break;
default:
- g_warning("Invalid PrefType for GtkSpinButton widget: %d\n",
+ g_warning("Invalid PrefType for GtkSpinButton widget: %d",
pparam->type);
}
}
(gfloat)*((gushort *)pparam->data));
break;
default:
- g_warning("Invalid PrefType for GtkSpinButton widget: %d\n",
+ g_warning("Invalid PrefType for GtkSpinButton widget: %d",
pparam->type);
}
}
{
prefswindow_open(_("Preferences"), prefs_pages, NULL,
&prefs_common.prefswin_width, &prefs_common.prefswin_height,
- NULL, prefs_gtk_window_closed_cb);
+ NULL, prefs_gtk_window_closed_cb, prefs_gtk_window_closed_cb);
}
void prefs_gtk_register_page(PrefsPage *page)
sections_table = g_hash_table_lookup(whole_cache, rcfile);
if (sections_table == NULL) {
- g_warning("Can't find %s in the whole cache\n", rcfile?rcfile:"(null)");
+ g_warning("Can't find %s in the whole cache", rcfile?rcfile:"(null)");
return FALSE;
}
values_table = g_hash_table_lookup(sections_table, label);