/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#define _GNU_SOURCE
#include "utils.h"
#include "gtkutils.h"
#include "passcrypt.h"
-#include "base64.h"
#include "codeconv.h"
#define CL(x) (((gulong) (x) >> (gulong) 8) & 0xFFUL)
gchar buf[PREFSBUFSIZE];
gchar *block_label;
- g_return_if_fail(param != NULL);
- g_return_if_fail(label != NULL);
- g_return_if_fail(rcfile != NULL);
+ cm_return_if_fail(param != NULL);
+ cm_return_if_fail(label != NULL);
+ cm_return_if_fail(rcfile != NULL);
if (encoding != NULL)
g_warning("Encoding is ignored\n");
case P_PASSWORD:
g_free(*((gchar **)param[i].data));
if (value[0] == '!') {
- gchar tmp[1024];
- gint len;
+ gchar *tmp;
+ gsize len;
- len = base64_decode(tmp, &value[1], strlen(value) - 1);
+ tmp = g_base64_decode_zero(&value[1], &len);
passcrypt_decrypt(tmp, len);
- tmp[len] = '\0';
+
*((gchar **)param[i].data) =
*tmp ? g_strdup(tmp) : NULL;
+ g_free(tmp);
} else {
*((gchar **)param[i].data) =
*value ? g_strdup(value) : NULL;
gchar *block_label = NULL;
gboolean block_matched = FALSE;
- g_return_if_fail(param != NULL);
- g_return_if_fail(label != NULL);
- g_return_if_fail(rcfile != NULL);
+ cm_return_if_fail(param != NULL);
+ cm_return_if_fail(label != NULL);
+ cm_return_if_fail(rcfile != NULL);
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, rcfile, NULL);
if ((orig_fp = g_fopen(rcpath, "rb")) == NULL) {
break;
case P_PASSWORD:
{
- gchar *tmp = NULL, tmp2[1024] = {0};
+ gchar *tmp = NULL, *tmp2 = NULL;
tmp = *((gchar **)param[i].data);
if (tmp) {
tmp = g_strdup(tmp);
len = strlen(tmp);
passcrypt_encrypt(tmp, len);
- base64_encode(tmp2, 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:
gint i;
GdkColor color;
- g_return_if_fail(param != NULL);
+ cm_return_if_fail(param != NULL);
for (i = 0; param[i].name != NULL; i++) {
if (!param[i].data) continue;
g_strconcat(get_home_dir(),
param[i].defval + 1,
NULL);
- else if (param[i].defval[0] != '\0')
+ else
*((gchar **)param[i].data) =
g_strdup(param[i].defval);
- else
- *((gchar **)param[i].data) = NULL;
} else
*((gchar **)param[i].data) = NULL;
break;
{
gint i;
- g_return_if_fail(param != NULL);
+ cm_return_if_fail(param != NULL);
for (i = 0; param[i].name != NULL; i++) {
if (!param[i].data) continue;
gchar **str;
const gchar *entry_str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
entry_str = gtk_entry_get_text(GTK_ENTRY(*pparam->widget));
{
gchar **str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
{
gchar **str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
{
gchar **str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
gchar *text = NULL, *tp = NULL;
gchar *tmp, *tmpp;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
tp = text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
}
- g_return_if_fail (tp && text);
+ cm_return_if_fail (tp && text);
if (text[0] == '\0') {
*str = NULL;
{
gchar **str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
GtkTextBuffer *buffer;
GtkTextIter iter;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
{
gchar **str;
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_STRING:
void prefs_set_data_from_toggle(PrefParam *pparam)
{
- g_return_if_fail(pparam->type == P_BOOL);
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(pparam->type == P_BOOL);
+ cm_return_if_fail(*pparam->widget != NULL);
*((gboolean *)pparam->data) =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(*pparam->widget));
void prefs_set_toggle(PrefParam *pparam)
{
- g_return_if_fail(pparam->type == P_BOOL);
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(pparam->type == P_BOOL);
+ cm_return_if_fail(*pparam->widget != NULL);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(*pparam->widget),
*((gboolean *)pparam->data));
void prefs_set_data_from_spinbtn(PrefParam *pparam)
{
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_INT:
void prefs_set_spinbtn(PrefParam *pparam)
{
- g_return_if_fail(*pparam->widget != NULL);
+ cm_return_if_fail(*pparam->widget != NULL);
switch (pparam->type) {
case P_INT: