evolution-addressbook-export: Make ActionContext a struct.
Defining this as a union makes the code needlessly verbose.
This commit is contained in:
@@ -612,29 +612,29 @@ action_list_cards (GSList *contacts,
|
||||
length = g_slist_length (contacts);
|
||||
|
||||
if (length <= 0) {
|
||||
g_warning ("Couldn't load addressbook correctly!!!! %s####", p_actctx->action_list_cards.addressbook_source_uid ?
|
||||
p_actctx->action_list_cards.addressbook_source_uid : "NULL");
|
||||
g_warning ("Couldn't load addressbook correctly!!!! %s####", p_actctx->addressbook_source_uid ?
|
||||
p_actctx->addressbook_source_uid : "NULL");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
if (p_actctx->action_list_cards.output_file == NULL) {
|
||||
if (p_actctx->output_file == NULL) {
|
||||
outputfile = stdout;
|
||||
} else {
|
||||
/* fopen output file */
|
||||
if (!(outputfile = g_fopen (p_actctx->action_list_cards.output_file, "w"))) {
|
||||
if (!(outputfile = g_fopen (p_actctx->output_file, "w"))) {
|
||||
g_warning (_("Can not open file"));
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_actctx->action_list_cards.IsVCard == TRUE)
|
||||
if (p_actctx->IsVCard == TRUE)
|
||||
format = CARD_FORMAT_VCARD;
|
||||
else
|
||||
format = CARD_FORMAT_CSV;
|
||||
|
||||
output_n_cards_file (outputfile, contacts, length, 0, format);
|
||||
|
||||
if (p_actctx->action_list_cards.output_file != NULL) {
|
||||
if (p_actctx->output_file != NULL) {
|
||||
fclose (outputfile);
|
||||
}
|
||||
}
|
||||
@@ -703,7 +703,7 @@ action_list_cards_init (ESourceRegistry *registry,
|
||||
|
||||
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FAILED);
|
||||
|
||||
uid = p_actctx->action_list_cards.addressbook_source_uid;
|
||||
uid = p_actctx->addressbook_source_uid;
|
||||
|
||||
if (uid != NULL)
|
||||
source = e_source_registry_ref_source (registry, uid);
|
||||
@@ -722,8 +722,8 @@ action_list_cards_init (ESourceRegistry *registry,
|
||||
if (error != NULL) {
|
||||
g_warning (
|
||||
"Couldn't load addressbook %s: %s",
|
||||
p_actctx->action_list_cards.addressbook_source_uid ?
|
||||
p_actctx->action_list_cards.addressbook_source_uid :
|
||||
p_actctx->addressbook_source_uid ?
|
||||
p_actctx->addressbook_source_uid :
|
||||
"'default'", error->message);
|
||||
g_error_free (error);
|
||||
exit (-1);
|
||||
|
||||
@@ -41,8 +41,8 @@ action_list_folders_init (ESourceRegistry *registry,
|
||||
|
||||
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FAILED);
|
||||
|
||||
if (p_actctx->action_list_folders.output_file != NULL) {
|
||||
if (!(outputfile = g_fopen (p_actctx->action_list_folders.output_file, "w"))) {
|
||||
if (p_actctx->output_file != NULL) {
|
||||
if (!(outputfile = g_fopen (p_actctx->output_file, "w"))) {
|
||||
g_warning (_("Can not open file"));
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
@@ -158,22 +158,22 @@ main (gint argc,
|
||||
if (current_action == ACTION_LIST_FOLDERS) {
|
||||
actctx.action_type = current_action;
|
||||
if (opt_output_file == NULL) {
|
||||
actctx.action_list_folders.output_file = NULL;
|
||||
actctx.output_file = NULL;
|
||||
} else {
|
||||
actctx.action_list_folders.output_file = g_strdup (opt_output_file);
|
||||
actctx.output_file = g_strdup (opt_output_file);
|
||||
}
|
||||
action_list_folders_init (registry, &actctx);
|
||||
|
||||
} else if (current_action == ACTION_LIST_CARDS) {
|
||||
actctx.action_type = current_action;
|
||||
if (opt_output_file == NULL) {
|
||||
actctx.action_list_cards.output_file = NULL;
|
||||
actctx.output_file = NULL;
|
||||
} else {
|
||||
actctx.action_list_cards.output_file = g_strdup (opt_output_file);
|
||||
actctx.output_file = g_strdup (opt_output_file);
|
||||
}
|
||||
actctx.action_list_cards.IsCSV = IsCSV;
|
||||
actctx.action_list_cards.IsVCard = IsVCard;
|
||||
actctx.action_list_cards.addressbook_source_uid =
|
||||
actctx.IsCSV = IsCSV;
|
||||
actctx.IsVCard = IsVCard;
|
||||
actctx.addressbook_source_uid =
|
||||
g_strdup (opt_addressbook_source_uid);
|
||||
|
||||
action_list_cards_init (registry, &actctx);
|
||||
|
||||
@@ -37,30 +37,18 @@ G_BEGIN_DECLS
|
||||
|
||||
#define DEFAULT_SIZE_NUMBER 100
|
||||
|
||||
union _ActionContext
|
||||
{
|
||||
struct _ActionContext {
|
||||
|
||||
guint action_type;
|
||||
gchar *output_file;
|
||||
|
||||
struct
|
||||
{
|
||||
gint action_type;
|
||||
gchar *output_file;
|
||||
}
|
||||
action_list_folders;
|
||||
|
||||
struct
|
||||
{
|
||||
gint action_type;
|
||||
gchar *output_file;
|
||||
gint IsCSV;
|
||||
gint IsVCard;
|
||||
gchar *addressbook_source_uid;
|
||||
}
|
||||
action_list_cards;
|
||||
/* for cards only */
|
||||
gint IsCSV;
|
||||
gint IsVCard;
|
||||
gchar *addressbook_source_uid;
|
||||
};
|
||||
|
||||
typedef union _ActionContext ActionContext;
|
||||
typedef struct _ActionContext ActionContext;
|
||||
|
||||
/* action_list_folders */
|
||||
guint action_list_folders_init (ESourceRegistry *registry,
|
||||
|
||||
Reference in New Issue
Block a user