commit fa6c5447605a39b6c5f05664479c2aeac1d12bb4
parent 97b8469a6a676e1a09d3e82c8bd88e109c56d8f3
Author: Oliver Lowe <o@olowe.co>
Date: Wed, 13 Aug 2025 18:37:09 +1000
Drop vcard support
Maybe later
Diffstat:
14 files changed, 4 insertions(+), 1380 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -33,10 +33,8 @@ abook_source = \
editaddress.c \
editbook.c \
editgroup.c \
- editvcard.c \
exphtmldlg.c \
- exporthtml.c \
- vcard.c
+ exporthtml.c
abook_headers = \
adbookbase.h \
@@ -53,10 +51,8 @@ abook_headers = \
editaddress.h \
editbook.h \
editgroup.h \
- editvcard.h \
exphtmldlg.h \
- exporthtml.h \
- vcard.h
+ exporthtml.h
claws_mail_SOURCES = \
account.c \
@@ -486,7 +482,6 @@ EXTRA_DIST = \
pixmaps/unread.xpm \
pixmaps/read.xpm \
pixmaps/up_arrow.xpm \
- pixmaps/vcard.xpm \
pixmaps/watchthread.xpm \
pixmaps/zoom_fit.xpm \
pixmaps/zoom_in.xpm \
diff --git a/src/adbookbase.h b/src/adbookbase.h
@@ -31,7 +31,6 @@
typedef enum {
ADBOOKTYPE_NONE,
ADBOOKTYPE_BOOK,
- ADBOOKTYPE_VCARD,
} AddressBookType;
/*
diff --git a/src/addressbook.c b/src/addressbook.c
@@ -60,8 +60,6 @@
#include "addressadd.h"
#include "addrduplicates.h"
#include "addressbook_foldersel.h"
-#include "vcard.h"
-#include "editvcard.h"
#include "editgroup.h"
#include "editaddress.h"
#include "editbook.h"
@@ -121,7 +119,6 @@ static GdkPixbuf *groupxpm = NULL;
static GdkPixbuf *interfacexpm = NULL;
static GdkPixbuf *bookxpm = NULL;
static GdkPixbuf *addressxpm = NULL;
-static GdkPixbuf *vcardxpm = NULL;
static GdkPixbuf *categoryxpm = NULL;
static GdkPixbuf *addrsearchxpm = NULL;
@@ -231,8 +228,6 @@ static void addressbook_file_save_cb (GtkAction *action,
/* Data source edit stuff */
static void addressbook_new_book_cb (GtkAction *action,
gpointer data);
-static void addressbook_new_vcard_cb (GtkAction *action,
- gpointer data);
static void addressbook_set_clist (AddressObject *obj,
gboolean refresh);
@@ -362,8 +357,6 @@ static GtkActionEntry addressbook_entries[] =
/* Book menu */
{"Book/NewBook", NULL, N_("New _Book"), "<control>B", NULL, G_CALLBACK(addressbook_new_book_cb) },
{"Book/NewFolder", NULL, N_("New _Folder"), "<control>R", NULL, G_CALLBACK(addressbook_new_folder_cb) },
- {"Book/NewVCard", NULL, N_("New _vCard"), "<control><shift>D", NULL, G_CALLBACK(addressbook_new_vcard_cb) },
-
{"Book/---", NULL, "---", NULL, NULL, NULL },
{"Book/EditBook", NULL, N_("_Edit book"), NULL, NULL, G_CALLBACK(addressbook_treenode_edit_cb) },
@@ -859,7 +852,6 @@ static void addressbook_create(void)
/* Book menu */
MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "NewBook", "Book/NewBook", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "NewFolder", "Book/NewFolder", GTK_UI_MANAGER_MENUITEM)
- MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "NewVCard", "Book/NewVCard", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "Separator1", "Book/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "EditBook", "Book/EditBook", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(ui_manager, "/Menu/Book", "DeleteBook", "Book/DeleteBook", GTK_UI_MANAGER_MENUITEM)
@@ -2694,9 +2686,6 @@ static gchar *addressbook_edit_datasource( AddressObject *obj, GtkCMCTreeNode *n
ads = ADAPTER_DSOURCE(obj);
if( ads->subType == ADDR_BOOK ) {
if( addressbook_edit_book( _addressIndex_, ads ) == NULL ) return NULL;
- }
- else if( ads->subType == ADDR_VCARD ) {
- if( addressbook_edit_vcard( _addressIndex_, ads ) == NULL ) return NULL;
} else {
return NULL;
}
@@ -4271,23 +4260,6 @@ static void addressbook_new_book_cb( GtkAction *action, gpointer data ) {
}
}
-static void addressbook_new_vcard_cb( GtkAction *action, gpointer data ) {
- AdapterDSource *ads;
- AdapterInterface *adapter;
- GtkCMCTreeNode *newNode;
-
- adapter = addrbookctl_find_interface( ADDR_IF_VCARD );
- if( adapter == NULL ) return;
- ads = addressbook_edit_vcard( _addressIndex_, NULL );
- if( ads ) {
- newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
- if( newNode ) {
- gtk_sctree_select( GTK_SCTREE(addrbook.ctree), newNode );
- addrbook.treeSelected = newNode;
- }
- }
-}
-
/**
* Display address search status message.
* \param queryType Query type.
@@ -4529,8 +4501,6 @@ static void addrbookctl_build_icons( GtkWidget *window ) {
g_object_unref(folderopenxpm);
if (groupxpm)
g_object_unref(groupxpm);
- if (vcardxpm)
- g_object_unref(vcardxpm);
if (bookxpm)
g_object_unref(bookxpm);
if (addressxpm)
@@ -4543,7 +4513,6 @@ static void addrbookctl_build_icons( GtkWidget *window ) {
stock_pixbuf_gdk(STOCK_PIXMAP_DIR_CLOSE, &folderxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_DIR_OPEN, &folderopenxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_GROUP, &groupxpm);
- stock_pixbuf_gdk(STOCK_PIXMAP_VCARD, &vcardxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_BOOK, &bookxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_ADDRESS, &addressxpm);
stock_pixbuf_gdk(STOCK_PIXMAP_CATEGORY, &categoryxpm);
@@ -4555,7 +4524,6 @@ static void addrbookctl_build_icons( GtkWidget *window ) {
UPDATE_ICON_ATCI(ADDR_ITEM_EMAIL,addressxpm,addressxpm);
UPDATE_ICON_ATCI(ADDR_ITEM_GROUP,groupxpm,groupxpm);
UPDATE_ICON_ATCI(ADDR_ITEM_FOLDER,folderxpm,folderopenxpm);
- UPDATE_ICON_ATCI(ADDR_VCARD,vcardxpm,vcardxpm);
UPDATE_ICON_ATCI(ADDR_CATEGORY,categoryxpm,categoryxpm);
}
@@ -4641,18 +4609,6 @@ static void addrbookctl_build_map( GtkWidget *window ) {
g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
_addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
- /* vCard */
- atci = g_new0( AddressTypeControlItem, 1 );
- atci->objectType = ADDR_VCARD;
- atci->interfaceType = ADDR_IF_VCARD;
- atci->showInTree = TRUE;
- atci->treeExpand = TRUE;
- atci->treeLeaf = TRUE;
- atci->displayName = _( "vCard" );
- atci->menuCommand = "Menu/Book/NewVCard";
- g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
- _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
-
addrbookctl_build_icons(window);
}
diff --git a/src/addressitem.h b/src/addressitem.h
@@ -48,7 +48,6 @@ typedef enum {
ADDR_INTERFACE,
ADDR_DATASOURCE,
ADDR_BOOK, /* Sub-type */
- ADDR_VCARD, /* Sub-type */
ADDR_CATEGORY, /* Sub-type */
} AddressObjectType;
diff --git a/src/addrindex.c b/src/addrindex.c
@@ -49,23 +49,16 @@
#include "codeconv.h"
#endif
-#include "vcard.h"
-
#define TAG_ADDRESS_INDEX "addressbook"
#define TAG_IF_ADDRESS_BOOK "book_list"
-#define TAG_IF_VCARD "vcard_list"
#define TAG_DS_ADDRESS_BOOK "book"
-#define TAG_DS_VCARD "vcard"
/* XML Attribute names */
#define ATTAG_BOOK_NAME "name"
#define ATTAG_BOOK_FILE "file"
-#define ATTAG_VCARD_NAME "name"
-#define ATTAG_VCARD_FILE "file"
-
/* Attribute values */
#define ATVAL_BOOLEAN_YES "yes"
#define ATVAL_BOOLEAN_NO "no"
@@ -199,43 +192,6 @@ static void addrindex_build_if_list( AddressIndex *addrIndex ) {
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
-
- /* Create vCard interface */
- iface = addrindex_create_interface(
- ADDR_IF_VCARD, "vCard", TAG_IF_VCARD, TAG_DS_VCARD );
- iface->getModifyFlag = ( void * ) vcard_get_modified;
- iface->getAccessFlag = ( void * ) vcard_get_accessed;
- iface->getReadFlag = ( void * ) vcard_get_read_flag;
- iface->getStatusCode = ( void * ) vcard_get_status;
- iface->getReadData = ( void * ) vcard_read_data;
- iface->getRootFolder = ( void * ) vcard_get_root_folder;
- iface->getListFolder = ( void * ) vcard_get_list_folder;
- iface->getListPerson = ( void * ) vcard_get_list_person;
- iface->getAllPersons = ( void * ) vcard_get_all_persons;
- iface->getName = ( void * ) vcard_get_name;
- iface->setAccessFlag = ( void * ) vcard_set_accessed;
- iface->searchOrder = 0;
- addrIndex->interfaceList =
- g_list_append( addrIndex->interfaceList, iface );
- ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
-
- /* Two old legacy data sources (pre 0.7.0) */
- iface = addrindex_create_interface(
- ADDR_IF_COMMON, "Old Address - common",
- TAG_IF_OLD_COMMON, NULL );
- iface->legacyFlag = TRUE;
- addrIndex->interfaceList =
- g_list_append( addrIndex->interfaceList, iface );
- ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
-
- iface = addrindex_create_interface(
- ADDR_IF_COMMON, "Old Address - personal",
- TAG_IF_OLD_PERSONAL, NULL );
- iface->legacyFlag = TRUE;
- addrIndex->interfaceList =
- g_list_append( addrIndex->interfaceList, iface );
- ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
-
}
/**
@@ -311,10 +267,6 @@ void addrindex_free_datasource( AddressDataSource *ds ) {
AddressBookFile *abf = ds->rawDataSource;
addrbook_free_book( abf );
}
- else if( iface->type == ADDR_IF_VCARD ) {
- VCardFile *vcf = ds->rawDataSource;
- vcard_free( vcf );
- }
} else {
AddressIfFragment *fragment = ds->rawDataSource;
addrindex_free_fragment( fragment );
@@ -681,9 +633,8 @@ static AddressInterface *addrindex_get_interface(
}
/**
- * Add raw data source to index. The raw data object (an AddressBookFile or
- * VCardFile object, for example) should be supplied as the raw dataSource
- * argument.
+ * Add raw data source to index. The raw data object (an AddressBookFile for example)
+ * should be supplied as the raw dataSource argument.
*
* \param addrIndex Address index.
* \param ifType Interface type to add.
@@ -911,44 +862,6 @@ static int addrindex_write_book( FILE *fp, AddressDataSource *ds, gint lvl ) {
return 0;
}
-static AddressDataSource *addrindex_parse_vcard( XMLFile *file ) {
- AddressDataSource *ds;
- VCardFile *vcf;
- GList *attr;
-
- ds = addrindex_create_datasource( ADDR_IF_VCARD );
- vcf = vcard_create();
- attr = xml_get_current_tag_attr( file );
- while( attr ) {
- gchar *name = ((XMLAttr *)attr->data)->name;
- gchar *value = ((XMLAttr *)attr->data)->value;
- if( strcmp( name, ATTAG_VCARD_NAME ) == 0 ) {
- vcard_set_name( vcf, value );
- }
- else if( strcmp( name, ATTAG_VCARD_FILE ) == 0) {
- vcard_set_file( vcf, value );
- }
- attr = g_list_next( attr );
- }
- ds->rawDataSource = vcf;
- return ds;
-}
-
-static int addrindex_write_vcard( FILE *fp, AddressDataSource *ds, gint lvl ) {
- VCardFile *vcf = ds->rawDataSource;
- if( vcf ) {
- if (addrindex_write_elem_s( fp, lvl, TAG_DS_VCARD ) < 0)
- return -1;
- if (addrindex_write_attr( fp, ATTAG_VCARD_NAME, vcard_get_name( vcf ) ) < 0)
- return -1;
- if (addrindex_write_attr( fp, ATTAG_VCARD_FILE, vcf->path ) < 0)
- return -1;
- if (fputs( " />\n", fp ) == EOF)
- return -1;
- }
- return 0;
-}
-
/* **********************************************************************
* Address index I/O functions.
* ***********************************************************************
@@ -991,9 +904,6 @@ static void addrindex_read_index( AddressIndex *addrIndex, XMLFile *file ) {
addrIndex->filePath );
}
}
- else if( addrIndex->lastType == ADDR_IF_VCARD ) {
- ds = addrindex_parse_vcard( file );
- }
if( ds ) {
ds->interface = dsIFace;
addrindex_hash_add_cache( addrIndex, ds );
@@ -1097,10 +1007,6 @@ static int addrindex_write_index( AddressIndex *addrIndex, FILE *fp ) {
if (addrindex_write_book( fp, ds, lvlItem ) < 0)
return -1;
}
- if( iface->type == ADDR_IF_VCARD ) {
- if (addrindex_write_vcard( fp, ds, lvlItem ) < 0)
- return -1;
- }
}
nodeDS = g_list_next( nodeDS );
}
diff --git a/src/addrindex.h b/src/addrindex.h
@@ -37,7 +37,6 @@
typedef enum {
ADDR_IF_NONE,
ADDR_IF_BOOK,
- ADDR_IF_VCARD,
ADDR_IF_COMMON,
ADDR_IF_PERSONAL
} AddressIfType;
diff --git a/src/editvcard.c b/src/editvcard.c
@@ -1,293 +0,0 @@
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2022 the Claws Mail team and Match Grun
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Edit vCard address book data.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#include "claws-features.h"
-#endif
-
-#include "defs.h"
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include "addressbook.h"
-#include "prefs_common.h"
-#include "addressitem.h"
-#include "vcard.h"
-#include "mgutils.h"
-#include "filesel.h"
-#include "gtkutils.h"
-#include "codeconv.h"
-#include "manage_window.h"
-
-#define ADDRESSBOOK_GUESS_VCARD "MyGnomeCard"
-
-static struct _VCardEdit {
- GtkWidget *window;
- GtkWidget *name_entry;
- GtkWidget *file_entry;
- GtkWidget *ok_btn;
- GtkWidget *cancel_btn;
- GtkWidget *statusbar;
- gint status_cid;
-} vcardedit;
-
-/*
-* Edit functions.
-*/
-static void edit_vcard_status_show( gchar *msg ) {
- if( vcardedit.statusbar != NULL ) {
- gtk_statusbar_pop( GTK_STATUSBAR(vcardedit.statusbar), vcardedit.status_cid );
- if( msg ) {
- gtk_statusbar_push( GTK_STATUSBAR(vcardedit.statusbar), vcardedit.status_cid, msg );
- }
- }
-}
-
-static void edit_vcard_ok( GtkWidget *widget, gboolean *cancelled ) {
- *cancelled = FALSE;
- gtk_main_quit();
-}
-
-static void edit_vcard_cancel( GtkWidget *widget, gboolean *cancelled ) {
- *cancelled = TRUE;
- gtk_main_quit();
-}
-
-static void edit_vcard_file_check( void ) {
- gint t;
- gchar *sFile;
- gchar *sFSFile;
- gchar *sMsg;
-
- sFile = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.file_entry), 0, -1 );
- sFSFile = conv_filename_from_utf8( sFile );
- t = vcard_test_read_file( sFSFile );
- g_free( sFSFile );
- g_free( sFile );
- if( t == MGU_SUCCESS ) {
- sMsg = "";
- }
- else if( t == MGU_BAD_FORMAT ) {
- sMsg = _("File does not appear to be vCard format.");
- }
- else {
- sMsg = _("Could not read file.");
- }
- edit_vcard_status_show( sMsg );
-}
-
-static void edit_vcard_file_select( void ) {
- gchar *sFile;
- gchar *sUTF8File;
-
- sFile = filesel_select_file_open( _("Select vCard File"), NULL);
-
- if( sFile ) {
- sUTF8File = conv_filename_to_utf8( sFile );
- gtk_entry_set_text( GTK_ENTRY(vcardedit.file_entry), sUTF8File );
- g_free( sUTF8File );
- g_free( sFile );
- edit_vcard_file_check();
- }
-}
-
-static gint edit_vcard_delete_event( GtkWidget *widget, GdkEventAny *event, gboolean *cancelled ) {
- *cancelled = TRUE;
- gtk_main_quit();
- return TRUE;
-}
-
-static gboolean edit_vcard_key_pressed( GtkWidget *widget, GdkEventKey *event, gboolean *cancelled ) {
- if (event && event->keyval == GDK_KEY_Escape) {
- *cancelled = TRUE;
- gtk_main_quit();
- }
- return FALSE;
-}
-
-static void addressbook_edit_vcard_create( gboolean *cancelled ) {
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *table;
- GtkWidget *label;
- GtkWidget *name_entry;
- GtkWidget *file_entry;
- GtkWidget *hbbox;
- GtkWidget *hsep;
- GtkWidget *ok_btn;
- GtkWidget *cancel_btn;
- GtkWidget *check_btn;
- GtkWidget *file_btn;
- GtkWidget *statusbar;
- GtkWidget *hsbox;
-
- window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "editvcard");
- gtk_widget_set_size_request(window, 450, -1);
- gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
- gtk_window_set_title(GTK_WINDOW(window), _("Edit vCard Entry"));
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
- g_signal_connect(G_OBJECT(window), "delete_event",
- G_CALLBACK(edit_vcard_delete_event),
- cancelled);
- g_signal_connect(G_OBJECT(window), "key_press_event",
- G_CALLBACK(edit_vcard_key_pressed),
- cancelled);
-
- vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
- gtk_container_add(GTK_CONTAINER(window), vbox);
- gtk_container_set_border_width( GTK_CONTAINER(vbox), 0 );
-
- table = gtk_grid_new();
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
- gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
- gtk_grid_set_row_spacing(GTK_GRID(table), 8);
- gtk_grid_set_column_spacing(GTK_GRID(table), 8);
-
- /* First row */
- label = gtk_label_new(_("Name"));
- gtk_label_set_xalign(GTK_LABEL(label), 0.0);
- gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
-
- name_entry = gtk_entry_new();
- gtk_grid_attach(GTK_GRID(table), name_entry, 1, 0, 1, 1);
- gtk_widget_set_hexpand(name_entry, TRUE);
- gtk_widget_set_halign(name_entry, GTK_ALIGN_FILL);
-
- check_btn = gtk_button_new_with_label( _(" Check File "));
- gtk_grid_attach(GTK_GRID(table), check_btn, 2, 0, 1, 1);
-
- /* Second row */
- label = gtk_label_new(_("File"));
- gtk_label_set_xalign(GTK_LABEL(label), 0.0);
- gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
-
- file_entry = gtk_entry_new();
- gtk_grid_attach(GTK_GRID(table), file_entry, 1, 1, 1, 1);
- gtk_widget_set_hexpand(file_entry, TRUE);
- gtk_widget_set_halign(file_entry, GTK_ALIGN_FILL);
-
- file_btn = gtkut_get_browse_file_btn(_("_Browse"));
- gtk_grid_attach(GTK_GRID(table), file_btn, 2, 1, 1, 1);
-
- /* Status line */
- hsbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH);
- statusbar = gtk_statusbar_new();
- gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH);
-
- /* Button panel */
- gtkut_stock_button_set_create(&hbbox, &cancel_btn, NULL, _("_Cancel"),
- &ok_btn, NULL, _("_OK"),
- NULL, NULL, NULL);
- gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
- gtk_container_set_border_width( GTK_CONTAINER(hbbox), 0 );
- gtk_widget_grab_default(ok_btn);
-
- hsep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_end(GTK_BOX(vbox), hsep, FALSE, FALSE, 0);
-
- g_signal_connect(G_OBJECT(ok_btn), "clicked",
- G_CALLBACK(edit_vcard_ok), cancelled);
- g_signal_connect(G_OBJECT(cancel_btn), "clicked",
- G_CALLBACK(edit_vcard_cancel), cancelled);
- g_signal_connect(G_OBJECT(file_btn), "clicked",
- G_CALLBACK(edit_vcard_file_select), NULL);
- g_signal_connect(G_OBJECT(check_btn), "clicked",
- G_CALLBACK(edit_vcard_file_check), NULL);
-
- gtk_widget_show_all(vbox);
-
- vcardedit.window = window;
- vcardedit.name_entry = name_entry;
- vcardedit.file_entry = file_entry;
- vcardedit.ok_btn = ok_btn;
- vcardedit.cancel_btn = cancel_btn;
- vcardedit.statusbar = statusbar;
- vcardedit.status_cid = gtk_statusbar_get_context_id( GTK_STATUSBAR(statusbar), "Edit vCard Dialog" );
-}
-
-AdapterDSource *addressbook_edit_vcard( AddressIndex *addrIndex, AdapterDSource *ads ) {
- static gboolean cancelled;
- gchar *sName;
- gchar *sFile;
- gchar *sFSFile;
- AddressDataSource *ds = NULL;
- VCardFile *vcf = NULL;
- gboolean fin;
-
- if( ! vcardedit.window )
- addressbook_edit_vcard_create(&cancelled);
- gtk_widget_grab_focus(vcardedit.ok_btn);
- gtk_widget_grab_focus(vcardedit.name_entry);
- gtk_widget_show(vcardedit.window);
- manage_window_set_transient(GTK_WINDOW(vcardedit.window));
- gtk_window_set_modal(GTK_WINDOW(vcardedit.window), TRUE);
- edit_vcard_status_show( "" );
- if( ads ) {
- ds = ads->dataSource;
- vcf = ds->rawDataSource;
- if ( vcard_get_name( vcf ) )
- gtk_entry_set_text(GTK_ENTRY(vcardedit.name_entry), vcard_get_name( vcf ) );
- if (vcf->path)
- gtk_entry_set_text(GTK_ENTRY(vcardedit.file_entry), vcf->path);
- gtk_window_set_title( GTK_WINDOW(vcardedit.window), _("Edit vCard Entry"));
- }
- else {
- gtk_entry_set_text(GTK_ENTRY(vcardedit.name_entry), ADDRESSBOOK_GUESS_VCARD );
- gtk_entry_set_text(GTK_ENTRY(vcardedit.file_entry), vcard_find_gnomecard() );
- gtk_window_set_title( GTK_WINDOW(vcardedit.window), _("Add New vCard Entry"));
- }
-
- gtk_main();
- gtk_widget_hide(vcardedit.window);
- gtk_window_set_modal(GTK_WINDOW(vcardedit.window), FALSE);
- if (cancelled == TRUE) return NULL;
-
- fin = FALSE;
- sName = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.name_entry), 0, -1 );
- sFile = gtk_editable_get_chars( GTK_EDITABLE(vcardedit.file_entry), 0, -1 );
- sFSFile = conv_filename_from_utf8( sFile );
- if( *sName == '\0' ) fin = TRUE;
- if( *sFile == '\0' ) fin = TRUE;
- if( ! sFSFile || *sFSFile == '\0' ) fin = TRUE;
-
- if( ! fin ) {
- if( ! ads ) {
- vcf = vcard_create();
- ds = addrindex_index_add_datasource( addrIndex, ADDR_IF_VCARD, vcf );
- ads = addressbook_create_ds_adapter( ds, ADDR_VCARD, NULL );
- }
- addressbook_ads_set_name( ads, sName );
- vcard_set_name( vcf, sName );
- vcard_set_file( vcf, sFSFile );
- }
- g_free( sFSFile );
- g_free( sFile );
- g_free( sName );
-
- return ads;
-}
diff --git a/src/editvcard.h b/src/editvcard.h
@@ -1,29 +0,0 @@
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2012 Match Grun 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * Edit vCard address book data.
- */
-
-#ifndef __EDITVCARD_H__
-#define __EDITVCARD_H__
-
-AdapterDSource *addressbook_edit_vcard( AddressIndex *addrIndex, AdapterDSource *ads );
-
-#endif /* __EDITVCARD_H__ */
diff --git a/src/pixmaps/vcard.xpm b/src/pixmaps/vcard.xpm
@@ -1,99 +0,0 @@
-/* XPM */
-static char * vcard_xpm[] = {
-"16 16 80 1",
-" c None",
-". c #838383",
-"+ c #000000",
-"@ c #7F7F7F",
-"# c #1D1D1D",
-"$ c #FFFFFF",
-"% c #1C1C1C",
-"& c #232323",
-"* c #CFCFCF",
-"= c #C9CACA",
-"- c #BDBDBC",
-"; c #C8C8C7",
-"> c #E2E2E2",
-", c #F9F9F9",
-"' c #FEFEFE",
-") c #FAFAFA",
-"! c #F8F8F8",
-"~ c #FBFBFB",
-"{ c #F7F7F7",
-"] c #1F1F1F",
-"^ c #BFBFBF",
-"/ c #9C9190",
-"( c #0F0303",
-"_ c #010101",
-": c #CECDCC",
-"< c #B3B3B3",
-"[ c #E0E0E0",
-"} c #F4F4F4",
-"| c #C5C5C5",
-"1 c #F6F6F6",
-"2 c #F5F5F5",
-"3 c #CECBC8",
-"4 c #D0C59D",
-"5 c #000002",
-"6 c #C5C4C2",
-"7 c #9A9A9A",
-"8 c #ACACAC",
-"9 c #B4B4B4",
-"0 c #CBCBCB",
-"a c #CECECE",
-"b c #FCFCFC",
-"c c #C9C5C4",
-"d c #93A1A5",
-"e c #9EA193",
-"f c #C9C8C6",
-"g c #FDFDFD",
-"h c #276274",
-"i c #203D6A",
-"j c #1F416B",
-"k c #27276A",
-"l c #CCD2D0",
-"m c #939393",
-"n c #C3C3C3",
-"o c #B7B7B7",
-"p c #C0C0C0",
-"q c #D6D6D6",
-"r c #A7B5C3",
-"s c #A3A0C0",
-"t c #A19FBE",
-"u c #A5A7C3",
-"v c #C3D2D8",
-"w c #FDFCFC",
-"x c #CACACA",
-"y c #E3E3E3",
-"z c #C4C4C4",
-"A c #E1E1E1",
-"B c #D8D8D8",
-"C c #D7D7D6",
-"D c #B8B8B8",
-"E c #F2F2F2",
-"F c #F3F3F3",
-"G c #242424",
-"H c #E8E8E8",
-"I c #B9B9B9",
-"J c #DDDDDD",
-"K c #A9A9A9",
-"L c #D9D9D9",
-"M c #1B1B1B",
-"N c #747474",
-"O c #585858",
-" ",
-" ",
-".++++++++++++++@",
-"#$$$$$$$$$$$$$$%",
-"&$*=-;>,')!~{{)]",
-"&$^/(_:$<[}|12)]",
-"&$^3456$78990ab]",
-"&$cde+f)~ggb),!]",
-"&$hijkl$mnopnq)]",
-"&$rstuvw0xyozA,]",
-"&$BC}Dq)2}{EF}1]",
-"G$ApHI$~JBK*LL!]",
-"M$''bg,!!!,{2}$M",
-"N++++++++++++++O",
-" ",
-" "};
diff --git a/src/prefs_toolbar.c b/src/prefs_toolbar.c
@@ -105,7 +105,6 @@ static const gint ToolbarIcons[] =
STOCK_PIXMAP_PASTE,
STOCK_PIXMAP_PREFERENCES,
STOCK_PIXMAP_PROPERTIES,
- STOCK_PIXMAP_VCARD,
STOCK_PIXMAP_ONLINE,
STOCK_PIXMAP_OFFLINE,
STOCK_PIXMAP_NOTICE_WARN, /* small warning */
diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c
@@ -98,7 +98,6 @@
#include "pixmaps/address_book.xpm"
#include "pixmaps/unread.xpm"
#include "pixmaps/read.xpm"
-#include "pixmaps/vcard.xpm"
#include "pixmaps/ignorethread.xpm"
#include "pixmaps/online.xpm"
#include "pixmaps/offline.xpm"
@@ -380,7 +379,6 @@ static StockPixmapData pixmaps[] =
{trash_close_mark_xpm , NULL, NULL, "trash_close_mark", NULL, NULL},
{trash_close_hrm_mark_xpm , NULL, NULL, "trash_close_hrm_mark", NULL, NULL},
{unread_xpm , NULL, NULL, "unread", NULL, NULL},
- {vcard_xpm , NULL, NULL, "vcard", NULL, NULL},
{online_xpm , NULL, NULL, "online", NULL, NULL},
{offline_xpm , NULL, NULL, "offline", NULL, NULL},
{notice_warn_xpm , NULL, NULL, "notice_warn", NULL, NULL},
diff --git a/src/stock_pixmap.h b/src/stock_pixmap.h
@@ -131,7 +131,6 @@ typedef enum
STOCK_PIXMAP_TRASH_CLOSE_MARK,
STOCK_PIXMAP_TRASH_CLOSE_HRM_MARK,
STOCK_PIXMAP_UNREAD,
- STOCK_PIXMAP_VCARD,
STOCK_PIXMAP_ONLINE,
STOCK_PIXMAP_OFFLINE,
STOCK_PIXMAP_NOTICE_WARN, /* small warning */
diff --git a/src/vcard.c b/src/vcard.c
@@ -1,700 +0,0 @@
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2015 Match Grun 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Functions necessary to access vCard files. vCard files are used
- * by GnomeCard for addressbook, and Netscape for sending business
- * card information. Refer to http://www.imc.org/pdi/vcard-21.txt and
- * RFC2426 for more information.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#include "claws-features.h"
-#endif
-
-#include <glib.h>
-#include <sys/stat.h>
-#include <string.h>
-
-#include "mgutils.h"
-#include "vcard.h"
-#include "addritem.h"
-#include "addrcache.h"
-#include "adbookbase.h"
-#include "utils.h"
-#include "codeconv.h"
-#include "quoted-printable.h"
-#include "file-utils.h"
-
-#define GNOMECARD_DIR ".gnome"
-#define GNOMECARD_FILE "GnomeCard"
-#define GNOMECARD_SECTION "[file]"
-#define GNOMECARD_PARAM "open"
-
-#define VCARD_TEST_LINES 200
-
-/*
-* Create new cardfile object.
-*/
-VCardFile *vcard_create() {
- VCardFile *cardFile;
- cardFile = g_new0( VCardFile, 1 );
- cardFile->type = ADBOOKTYPE_VCARD;
- cardFile->addressCache = addrcache_create();
- cardFile->retVal = MGU_SUCCESS;
-
- cardFile->file = NULL;
- cardFile->path = NULL;
- cardFile->bufptr = cardFile->buffer;
- return cardFile;
-}
-
-/*
-* Properties...
-*/
-void vcard_set_name( VCardFile* cardFile, const gchar *value ) {
- cm_return_if_fail( cardFile != NULL );
- addrcache_set_name( cardFile->addressCache, value );
-}
-void vcard_set_file( VCardFile* cardFile, const gchar *value ) {
- cm_return_if_fail( cardFile != NULL );
- addrcache_refresh( cardFile->addressCache );
- cardFile->path = mgu_replace_string( cardFile->path, value );
- g_strstrip( cardFile->path );
-}
-void vcard_set_accessed( VCardFile *cardFile, const gboolean value ) {
- cm_return_if_fail( cardFile != NULL );
- cardFile->addressCache->accessFlag = value;
-}
-
-/*
-* Test whether file was modified since last access.
-* Return: TRUE if file was modified.
-*/
-gboolean vcard_get_modified( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, FALSE );
- cardFile->addressCache->modified =
- addrcache_check_file( cardFile->addressCache, cardFile->path );
- return cardFile->addressCache->modified;
-}
-gboolean vcard_get_accessed( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, FALSE );
- return cardFile->addressCache->accessFlag;
-}
-
-/*
-* Test whether file was read.
-* Return: TRUE if file was read.
-*/
-gboolean vcard_get_read_flag( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, FALSE );
- return cardFile->addressCache->dataRead;
-}
-
-/*
-* Return status code from last file operation.
-* Return: Status code.
-*/
-gint vcard_get_status( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, -1 );
- return cardFile->retVal;
-}
-
-ItemFolder *vcard_get_root_folder( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, NULL );
- return addrcache_get_root_folder( cardFile->addressCache );
-}
-gchar *vcard_get_name( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, NULL );
- return addrcache_get_name( cardFile->addressCache );
-}
-
-/*
-* Create new cardfile object for specified file.
-*/
-static VCardFile *vcard_create_path( const gchar *path ) {
- VCardFile *cardFile;
- cardFile = vcard_create();
- vcard_set_file(cardFile, path);
- return cardFile;
-}
-
-/*
-* Free up cardfile object by releasing internal memory.
-*/
-void vcard_free( VCardFile *cardFile ) {
- cm_return_if_fail( cardFile != NULL );
-
- /* Close file */
- if( cardFile->file ) fclose( cardFile->file );
-
- /* Clear cache */
- addrcache_clear( cardFile->addressCache );
- addrcache_free( cardFile->addressCache );
-
- /* Free internal stuff */
- g_free( cardFile->path );
-
- /* Clear pointers */
- cardFile->file = NULL;
- cardFile->path = NULL;
- cardFile->bufptr = NULL;
-
- cardFile->type = ADBOOKTYPE_NONE;
- cardFile->addressCache = NULL;
- cardFile->retVal = MGU_SUCCESS;
-
- /* Now release file object */
- g_free( cardFile );
-}
-
-/*
-* Open file for read.
-* return: TRUE if file opened successfully.
-*/
-static gint vcard_open_file( VCardFile* cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, -1 );
-
- /* g_print( "Opening file\n" ); */
- cardFile->addressCache->dataRead = FALSE;
- if( cardFile->path ) {
- cardFile->file = g_fopen( cardFile->path, "rb" );
- if( ! cardFile->file ) {
- /* g_printerr( "can't open %s\n", cardFile->path ); */
- cardFile->retVal = MGU_OPEN_FILE;
- return cardFile->retVal;
- }
- }
- else {
- /* g_printerr( "file not specified\n" ); */
- cardFile->retVal = MGU_NO_FILE;
- return cardFile->retVal;
- }
-
- /* Setup a buffer area */
- cardFile->buffer[0] = '\0';
- cardFile->bufptr = cardFile->buffer;
- cardFile->retVal = MGU_SUCCESS;
- return cardFile->retVal;
-}
-
-/*
-* Close file.
-*/
-static void vcard_close_file( VCardFile *cardFile ) {
- cm_return_if_fail( cardFile != NULL );
- if( cardFile->file ) fclose( cardFile->file );
- cardFile->file = NULL;
-}
-
-/*
-* Read line of text from file.
-* Return: ptr to buffer where line starts.
-*/
-static gchar *vcard_read_line( VCardFile *cardFile ) {
- while( *cardFile->bufptr == '\n' || *cardFile->bufptr == '\0' ) {
- if( fgets( cardFile->buffer, VCARDBUFSIZE, cardFile->file ) == NULL )
- return NULL;
- g_strstrip( cardFile->buffer );
- cardFile->bufptr = cardFile->buffer;
- }
- return cardFile->bufptr;
-}
-
-/*
-* Read line of text from file.
-* Return: ptr to buffer where line starts.
-*/
-static gchar *vcard_get_line( VCardFile *cardFile ) {
- gchar buf[ VCARDBUFSIZE ];
- gchar *start, *end;
- gint len;
-
- if (vcard_read_line( cardFile ) == NULL ) {
- buf[0] = '\0';
- return NULL;
- }
-
- /* Copy into private buffer */
- start = cardFile->bufptr;
- len = strlen( start );
- end = start + len;
- memcpy( buf, start, len );
- buf[ len ] = '\0';
- g_strstrip(buf);
- cardFile->bufptr = end + 1;
-
- /* Return a copy of buffer */
- return g_strdup( buf );
-}
-
-/*
-* Free linked lists of character strings.
-*/
-static void vcard_free_lists( GSList *listName, GSList *listAddr, GSList *listRem, GSList* listID ) {
- g_slist_free_full( listName, g_free );
- g_slist_free_full( listAddr, g_free );
- g_slist_free_full( listRem, g_free );
- g_slist_free_full( listID, g_free );
-}
-
-/*
-* Read quoted-printable text, which may span several lines into one long string.
-* Param: cardFile - object.
-* Param: tagvalue - will be placed into the linked list.
-*/
-static gchar *vcard_read_qp( VCardFile *cardFile, char *tagvalue ) {
- GSList *listQP = NULL;
- gint len = 0;
- gchar *line = tagvalue;
- while( line ) {
- listQP = g_slist_append( listQP, line );
- len = strlen( line ) - 1;
- if( line[ len ] != '=' ) break;
- line[ len ] = '\0';
- line = vcard_get_line( cardFile );
- }
-
- /* Coalesce linked list into one long buffer. */
- line = mgu_list_coalesce( listQP );
-
- /* Clean up */
- g_slist_free_full( listQP, g_free );
- listQP = NULL;
- return line;
-}
-
-/*
-* Parse tag name from line buffer.
-* Return: Buffer containing the tag name, or NULL if no delimiter char found.
-*/
-static gchar *vcard_get_tagname( char* line, gchar dlm ) {
- gint len = 0;
- gchar *tag = NULL;
- gchar *lptr = line;
- gchar *down;
- while( *lptr++ ) {
- if( *lptr == dlm ) {
- len = lptr - line;
- tag = g_strndup( line, len+1 );
- tag[ len ] = '\0';
- down = g_utf8_strdown( tag, -1 );
- g_free(tag);
- return down;
- }
- }
- return tag;
-}
-
-/*
-* Parse tag value from line buffer.
-* Return: Buffer containing the tag value. Empty string is returned if
-* no delimiter char found.
-*/
-static gchar *vcard_get_tagvalue( gchar* line, gchar dlm ) {
- gchar *value = NULL;
- gchar *start = NULL;
- gchar *lptr;
- gint len = 0;
-
- for( lptr = line; *lptr; lptr++ ) {
- if( *lptr == dlm ) {
- if( ! start )
- start = lptr + 1;
- }
- }
- if( start ) {
- len = lptr - start;
- value = g_strndup( start, len+1 );
- }
- else {
- /* Ensure that we get an empty string */
- value = g_strndup( "", 1 );
- }
- value[ len ] = '\0';
- return value;
-}
-
-/*
-* Build an address list entry and append to list of address items.
-*/
-static void vcard_build_items(
- VCardFile *cardFile, GSList *listName, GSList *listAddr,
- GSList *listRem, GSList *listID )
-{
- GSList *nodeName = listName;
- GSList *nodeID = listID;
- gchar *str;
- while( nodeName ) {
- GSList *nodeAddress = listAddr;
- GSList *nodeRemarks = listRem;
- ItemPerson *person = addritem_create_item_person();
- addritem_person_set_common_name( person, nodeName->data );
- while( nodeAddress ) {
- str = nodeAddress->data;
- if( *str != '\0' ) {
- ItemEMail *email = addritem_create_item_email();
- addritem_email_set_address( email, str );
- if( nodeRemarks ) {
- str = nodeRemarks->data;
- if( str ) {
- if( g_utf8_collate( str, "internet" ) != 0 ) {
- if( *str != '\0' )
- addritem_email_set_remarks( email, str );
- }
- }
- }
- addrcache_id_email( cardFile->addressCache, email );
- addrcache_person_add_email( cardFile->addressCache, person, email );
- }
- nodeAddress = g_slist_next( nodeAddress );
- nodeRemarks = g_slist_next( nodeRemarks );
- }
- if( person->listEMail ) {
- addrcache_id_person( cardFile->addressCache, person );
- addrcache_add_person( cardFile->addressCache, person );
- if( nodeID ) {
- str = nodeID->data;
- addritem_person_set_external_id( person, str );
- }
- }
- else {
- addritem_free_item_person( person );
- }
- nodeName = g_slist_next( nodeName );
- nodeID = g_slist_next( nodeID );
- }
-}
-
-/* Unescape characters in quoted-printable string. */
-static gchar *vcard_unescape_qp( gchar *value ) {
- gchar *res = NULL;
- gint len;
- if (value == NULL)
- return NULL;
-
- len = strlen(value);
- res = g_malloc(len + 1);
- qp_decode_const(res, len, value);
- if (!g_utf8_validate(res, -1, NULL)) {
- gchar *mybuf = g_malloc(strlen(res)*2 +1);
- conv_localetodisp(mybuf, strlen(res)*2 +1, res);
- g_free(res);
- res = mybuf;
- }
- return res;
-}
-
- /*
-* Read file data into root folder.
-* Note that one vCard can have multiple E-Mail addresses (MAIL tags);
-* these are broken out into separate address items. An address item
-* is generated for the person identified by FN tag and each EMAIL tag.
-* If a sub-type is included in the EMAIL entry, this will be used as
-* the Remarks member. Also note that it is possible for one vCard
-* entry to have multiple FN tags; this might not make sense. However,
-* it will generate duplicate address entries for each person listed.
-*/
-static void vcard_read_file( VCardFile *cardFile ) {
- gchar *tagtemp = NULL, *tagname = NULL, *tagvalue = NULL, *tagtype = NULL;
- GSList *listName = NULL, *listAddress = NULL, *listRemarks = NULL, *listID = NULL;
- /* GSList *listQP = NULL; */
-
- for( ;; ) {
- gchar *line = vcard_get_line( cardFile );
- if( line == NULL ) break;
-
- /* g_print( "%s\n", line ); */
-
- /* Parse line */
- tagtemp = vcard_get_tagname( line, VCARD_SEP_TAG );
- if( tagtemp == NULL ) {
- g_free( line );
- continue;
- }
-
- /* g_print( "\ttemp: %s\n", tagtemp ); */
- tagvalue = vcard_get_tagvalue( line, VCARD_SEP_TAG );
- if( tagvalue == NULL ) {
- g_free( tagtemp );
- g_free( line );
- continue;
- }
-
- tagname = vcard_get_tagname( tagtemp, VCARD_SEP_TYPE );
- tagtype = vcard_get_tagvalue( tagtemp, VCARD_SEP_TYPE );
- if( tagname == NULL ) {
- tagname = tagtemp;
- tagtemp = NULL;
- }
-
- /* g_print( "\tname: %s\n", tagname ); */
- /* g_print( "\ttype: %s\n", tagtype ); */
- /* g_print( "\tvalue: %s\n", tagvalue ); */
-
- if( g_utf8_collate( tagtype, VCARD_TYPE_QP ) == 0
- || g_utf8_collate( tagtype, VCARD_TYPE_E_QP ) == 0
- || g_utf8_collate( tagtype, VCARD_TYPE_CS_UTF8_E_QP ) == 0) {
- gchar *tmp;
- /* Quoted-Printable: could span multiple lines */
- tagvalue = vcard_read_qp( cardFile, tagvalue );
- tmp = vcard_unescape_qp( tagvalue );
- g_free(tagvalue);
- tagvalue=tmp;
- /* g_print( "QUOTED-PRINTABLE !!! final\n>%s<\n", tagvalue ); */
- }
-
- if( g_utf8_collate( tagname, VCARD_TAG_START ) == 0 &&
- g_ascii_strcasecmp( tagvalue, VCARD_NAME ) == 0 ) {
- /* g_print( "start card\n" ); */
- vcard_free_lists( listName, listAddress, listRemarks, listID );
- listName = listAddress = listRemarks = listID = NULL;
- }
- if( g_utf8_collate( tagname, VCARD_TAG_FULLNAME ) == 0 ) {
- /* g_print( "- full name: %s\n", tagvalue ); */
- listName = g_slist_append( listName, g_strdup( tagvalue ) );
- }
- if( g_utf8_collate( tagname, VCARD_TAG_EMAIL ) == 0 ) {
- /* g_print( "- address: %s\n", tagvalue ); */
- listAddress = g_slist_append( listAddress, g_strdup( tagvalue ) );
- listRemarks = g_slist_append( listRemarks, g_strdup( tagtype ) );
- }
- if( g_utf8_collate( tagname, VCARD_TAG_UID ) == 0 ) {
- /* g_print( "- id: %s\n", tagvalue ); */
- listID = g_slist_append( listID, g_strdup( tagvalue ) );
- }
- if( g_utf8_collate( tagname, VCARD_TAG_END ) == 0 &&
- g_ascii_strcasecmp( tagvalue, VCARD_NAME ) == 0 ) {
- /* vCard is complete */
- /* g_print( "end card\n--\n" ); */
- /* vcard_dump_lists( listName, listAddress, listRemarks, listID, stdout ); */
- vcard_build_items( cardFile, listName, listAddress, listRemarks, listID );
- vcard_free_lists( listName, listAddress, listRemarks, listID );
- listName = listAddress = listRemarks = listID = NULL;
- }
-
- g_free( tagname );
- g_free( tagtype );
- g_free( tagvalue );
- g_free( tagtemp );
- g_free( line );
- line = NULL;
- }
-
- /* Free lists */
- vcard_free_lists( listName, listAddress, listRemarks, listID );
- listName = listAddress = listRemarks = listID = NULL;
-}
-
-/* ============================================================================================ */
-/*
-* Read file into list. Main entry point
-* Return: TRUE if file read successfully.
-*/
-/* ============================================================================================ */
-gint vcard_read_data( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, -1 );
-
- cardFile->retVal = MGU_SUCCESS;
- cardFile->addressCache->accessFlag = FALSE;
- if( addrcache_check_file( cardFile->addressCache, cardFile->path ) ) {
- addrcache_clear( cardFile->addressCache );
- vcard_open_file( cardFile );
- if( cardFile->retVal == MGU_SUCCESS ) {
- /* Read data into the list */
- vcard_read_file( cardFile );
- vcard_close_file( cardFile );
-
- /* Mark cache */
- addrcache_mark_file( cardFile->addressCache, cardFile->path );
- cardFile->addressCache->modified = FALSE;
- cardFile->addressCache->dataRead = TRUE;
- }
- }
- return cardFile->retVal;
-}
-
-/*
-* Return link list of persons.
-*/
-GList *vcard_get_list_person( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, NULL );
- return addrcache_get_list_person( cardFile->addressCache );
-}
-
-/*
-* Return link list of folders. This is always NULL since there are
-* no folders in GnomeCard.
-* Return: NULL.
-*/
-GList *vcard_get_list_folder( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, NULL );
- return NULL;
-}
-
-/*
-* Return link list of all persons. Note that the list contains references
-* to items. Do *NOT* attempt to use the addrbook_free_xxx() functions...
-* this will destroy the addressbook data!
-* Return: List of items, or NULL if none.
-*/
-GList *vcard_get_all_persons( VCardFile *cardFile ) {
- cm_return_val_if_fail( cardFile != NULL, NULL );
- return addrcache_get_all_persons( cardFile->addressCache );
-}
-
-#define WORK_BUFLEN 1024
-
-/*
-* Attempt to find a valid GnomeCard file.
-* Return: Filename, or home directory if not found. Filename should
-* be g_free() when done.
-*/
-gchar *vcard_find_gnomecard( void ) {
- const gchar *homedir;
- gchar buf[ WORK_BUFLEN ];
- gchar str[ WORK_BUFLEN + 1 ];
- gchar *fileSpec;
- gint len, lenlbl, i;
- FILE *fp;
-
- homedir = get_home_dir();
- if( ! homedir ) return NULL;
-
- strncpy( str, homedir, WORK_BUFLEN );
- len = strlen( str );
- if( len > 0 ) {
- if( str[ len-1 ] != G_DIR_SEPARATOR ) {
- str[ len ] = G_DIR_SEPARATOR;
- str[ ++len ] = '\0';
- }
- }
- strncat( str, GNOMECARD_DIR, WORK_BUFLEN - strlen(str) );
- strncat( str, G_DIR_SEPARATOR_S, WORK_BUFLEN - strlen(str) );
- strncat( str, GNOMECARD_FILE, WORK_BUFLEN - strlen(str) );
-
- fileSpec = NULL;
- if( ( fp = g_fopen( str, "rb" ) ) != NULL ) {
- /* Read configuration file */
- lenlbl = strlen( GNOMECARD_SECTION );
- while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
- if( 0 == g_ascii_strncasecmp( buf, GNOMECARD_SECTION, lenlbl ) ) {
- break;
- }
- }
-
- while( fgets( buf, sizeof( buf ), fp ) != NULL ) {
- g_strchomp( buf );
- if( buf[0] == '[' ) break;
- for( i = 0; i < lenlbl; i++ ) {
- if( buf[i] == '=' ) {
- if( 0 == g_ascii_strncasecmp( buf, GNOMECARD_PARAM, i ) ) {
- fileSpec = g_strdup( buf + i + 1 );
- g_strstrip( fileSpec );
- }
- }
- }
- }
- fclose( fp );
- }
-
- if( fileSpec == NULL ) {
- /* Use the home directory */
- str[ len ] = '\0';
- fileSpec = g_strdup( str );
- }
-
- return fileSpec;
-}
-
-/*
-* Attempt to read file, testing for valid vCard format.
-* Return: TRUE if file appears to be valid format.
-*/
-gint vcard_test_read_file( const gchar *fileSpec ) {
- gboolean haveStart;
- gchar *tagtemp = NULL, *tagname = NULL, *tagvalue = NULL, *tagtype = NULL, *line;
- VCardFile *cardFile;
- gint retVal, lines;
-
- if( ! fileSpec ) return MGU_NO_FILE;
-
- cardFile = vcard_create_path( fileSpec );
- cardFile->retVal = MGU_SUCCESS;
- vcard_open_file( cardFile );
- if( cardFile->retVal == MGU_SUCCESS ) {
- cardFile->retVal = MGU_BAD_FORMAT;
- haveStart = FALSE;
- lines = VCARD_TEST_LINES;
- while( lines > 0 ) {
- lines--;
- if( ( line = vcard_get_line( cardFile ) ) == NULL ) break;
-
- /* Parse line */
- tagtemp = vcard_get_tagname( line, VCARD_SEP_TAG );
- if( tagtemp == NULL ) {
- g_free( line );
- continue;
- }
-
- tagvalue = vcard_get_tagvalue( line, VCARD_SEP_TAG );
- if( tagvalue == NULL ) {
- g_free( tagtemp );
- g_free( line );
- continue;
- }
-
- tagname = vcard_get_tagname( tagtemp, VCARD_SEP_TYPE );
- tagtype = vcard_get_tagvalue( tagtemp, VCARD_SEP_TYPE );
- if( tagname == NULL ) {
- tagname = tagtemp;
- tagtemp = NULL;
- }
-
- if( g_utf8_collate( tagtype, VCARD_TYPE_QP ) == 0 ) {
- gchar *tmp;
- /* Quoted-Printable: could span multiple lines */
- tagvalue = vcard_read_qp( cardFile, tagvalue );
- tmp = vcard_unescape_qp( tagvalue );
- g_free(tagvalue);
- tagvalue=tmp;
- }
- if( g_utf8_collate( tagname, VCARD_TAG_START ) == 0 &&
- g_ascii_strcasecmp( tagvalue, VCARD_NAME ) == 0 ) {
- haveStart = TRUE;
- }
- if( g_utf8_collate( tagname, VCARD_TAG_END ) == 0 &&
- g_ascii_strcasecmp( tagvalue, VCARD_NAME ) == 0 ) {
- /* vCard is complete */
- if( haveStart ) cardFile->retVal = MGU_SUCCESS;
- }
-
- g_free( tagname );
- g_free( tagtype );
- g_free( tagvalue );
- g_free( tagtemp );
- g_free( line );
- }
- vcard_close_file( cardFile );
- }
- retVal = cardFile->retVal;
- vcard_free( cardFile );
- cardFile = NULL;
- return retVal;
-}
diff --git a/src/vcard.h b/src/vcard.h
@@ -1,105 +0,0 @@
-/*
- * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2015 Match Grun 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Definitions necessary to access vCard files. vCard files are used
- * by GnomeCard for addressbook, and Netscape for sending business
- * card information. Refer to http://www.imc.org/pdi/vcard-21.txt and
- * RFC2426 for more information.
- */
-
-#ifndef __VCARD_H__
-#define __VCARD_H__
-
-#include <stdio.h>
-#include <glib.h>
-
-#include "addritem.h"
-#include "addrcache.h"
-#include "adbookbase.h"
-
-#define VCARDBUFSIZE 1024
-
-#define VCARD_TAG_START "begin"
-#define VCARD_TAG_END "end"
-#define VCARD_NAME "vcard"
-
-#define VCARD_TAG_FULLNAME "fn"
-#define VCARD_TAG_NAME "n"
-#define VCARD_TAG_EMAIL "email"
-#define VCARD_TAG_UID "uid"
-
-#define VCARD_TYPE_QP "quoted-printable"
-#define VCARD_TYPE_E_QP "encoding=quoted-printable"
-#define VCARD_TYPE_CS_UTF8_E_QP "charset=utf-8;encoding=quoted-printable"
-
-#define VCARD_SEP_TAG ':'
-#define VCARD_SEP_TYPE ';'
-
-/*
-* Typical vCard entry:
-*
-* BEGIN:VCARD
-* FN:Axle Rose
-* N:Rose;Axle;D;Ms;Jnr
-* REV:2001-04-22T03:52:05
-* ADR;HOME:;;777 Lexington Avenue;Denver;CO;80299;USA
-* ADR;POSTAL:P O Box 777;;;Denver;CO;80298;Usa
-* TEL;HOME:303-555-1234
-* EMAIL;AOL:axlerose@aol.com
-* EMAIL;INTERNET:axlerose@netscape.net
-* TITLE:Janitor
-* ORG:The Company
-* URL:http://www.axlerose.com
-* END:VCARD
-*/
-
-/* vCard object */
-typedef struct _VCardFile VCardFile;
-struct _VCardFile {
- AddressBookType type;
- AddressCache *addressCache;
- gint retVal;
- FILE *file;
- gchar *path;
- gchar buffer[ VCARDBUFSIZE ];
- gchar *bufptr;
-};
-
-/* Function prototypes */
-VCardFile *vcard_create ( void );
-void vcard_set_name ( VCardFile* cardFile, const gchar *value );
-void vcard_set_file ( VCardFile* cardFile, const gchar *value );
-void vcard_set_modified ( VCardFile *cardFile, const gboolean value );
-void vcard_set_accessed ( VCardFile *cardFile, const gboolean value );
-gboolean vcard_get_modified ( VCardFile *cardFile );
-gboolean vcard_get_accessed ( VCardFile *cardFile );
-gboolean vcard_get_read_flag ( VCardFile *cardFile );
-gint vcard_get_status ( VCardFile *cardFile );
-ItemFolder *vcard_get_root_folder ( VCardFile *cardFile );
-gchar *vcard_get_name ( VCardFile *cardFile );
-void vcard_free ( VCardFile *cardFile );
-gint vcard_read_data ( VCardFile *cardFile );
-GList *vcard_get_list_person ( VCardFile *cardFile );
-GList *vcard_get_list_folder ( VCardFile *cardFile );
-GList *vcard_get_all_persons ( VCardFile *cardFile );
-gchar *vcard_find_gnomecard ( void );
-gint vcard_test_read_file ( const gchar *fileSpec );
-
-#endif /* __VCARD_H__ */
-