/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002 Match Grun
+ * Copyright (C) 2002-2007 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 2 of the License, or
+ * 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,
* 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/*
* Export address book to HTML file.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <glib.h>
+#include <glib/gi18n.h>
+
+#ifdef G_OS_WIN32
+# include <w32lib.h>
+#endif
-#include "intl.h"
#include "mgutils.h"
#include "utils.h"
#include "exporthtml.h"
-#include "addritem.h"
-#include "addrcache.h"
-#include "addrbook.h"
#include "xmlprops.h"
-#define DFL_DIR_SYLPHEED_OUT "sylpheed-out"
-#define DFL_FILE_SYLPHEED_OUT "addressbook.html"
+#ifdef MKDIR_TAKES_ONE_ARG
+#undef mkdir
+#define mkdir(a,b) mkdir(a)
+#endif
+
+#define DFL_DIR_CLAWS_OUT "claws-mail-out"
+#define DFL_FILE_CLAWS_OUT "addressbook.html"
#define FMT_BUFSIZE 2048
-#define HTML_SPACE " "
+#define SC_HTML_SPACE " "
#define BORDER_SIZE 2
#define CELL_PADDING 2
#define CELL_SPACING 2
-#define CHAR_ENCODING "ISO-8859-1"
+#define CHAR_ENCODING "UTF-8"
/* Stylesheet names */
#define FILENAME_NONE ""
-#define FILENAME_DEFAULT "sylpheed.css"
+#define FILENAME_DEFAULT "claws-mail.css"
#define FILENAME_FULL "full.css"
#define FILENAME_CUSTOM "custom.css"
#define FILENAME_CUSTOM2 "custom2.css"
ctl->path = NULL;
ctl->dirOutput = NULL;
ctl->fileHtml = NULL;
- ctl->encoding = NULL;
+ ctl->encoding = g_strconcat(CHAR_ENCODING, NULL);
ctl->stylesheet = EXPORT_HTML_ID_NONE;
ctl->nameFormat = EXPORT_HTML_FIRST_LAST;
ctl->banding = FALSE;
g_free( ctl );
}
-/*
- * Print control object.
- * Enter: ctl Export control data.
- * stream Output stream.
- */
-void exporthtml_print( ExportHtmlCtl *ctl, FILE *stream ) {
- fprintf( stream, "ExportHtmlCtl:\n" );
- fprintf( stream, " path: %s\n", ctl->path );
- fprintf( stream, "directory: %s\n", ctl->dirOutput );
- fprintf( stream, " file: %s\n", ctl->fileHtml );
- fprintf( stream, " settings: %s\n", ctl->settingsFile );
- fprintf( stream, " encoding: %s\n", ctl->encoding );
- fprintf( stream, " css file: %d\n", ctl->stylesheet );
- fprintf( stream, " name fmt: %d\n", ctl->nameFormat );
- fprintf( stream, " banding: %d\n", ctl->banding );
- fprintf( stream, "link mail: %d\n", ctl->linkEMail );
- fprintf( stream, "show attr: %d\n", ctl->showAttribs );
-}
-
/*
* Find style entry.
* Enter: ctl Export control data.
return retVal;
}
-/*
- * Properties...
- */
-/*
- * Specify path to folder where files are created.
- * Enter: ctl Export control data.
- * value Full directory path.
- */
-void exporthtml_set_output_dir( ExportHtmlCtl *ctl, const gchar *value ) {
- g_return_if_fail( ctl != NULL );
- ctl->dirOutput = mgu_replace_string( ctl->dirOutput, value );
- g_strstrip( ctl->dirOutput );
-}
-void exporthtml_set_path( ExportHtmlCtl *ctl, const gchar *value ) {
- g_return_if_fail( ctl != NULL );
- ctl->path = mgu_replace_string( ctl->path, value );
- g_strstrip( ctl->path );
-}
-void exporthtml_set_file_html( ExportHtmlCtl *ctl, const gchar *value ) {
- g_return_if_fail( ctl != NULL );
- ctl->fileHtml = mgu_replace_string( ctl->fileHtml, value );
- g_strstrip( ctl->fileHtml );
-}
-void exporthtml_set_encoding( ExportHtmlCtl *ctl, const gchar *value ) {
- g_return_if_fail( ctl != NULL );
- ctl->encoding = mgu_replace_string( ctl->encoding, value );
- g_strstrip( ctl->encoding );
-}
void exporthtml_set_stylesheet( ExportHtmlCtl *ctl, const gint value ) {
g_return_if_fail( ctl != NULL );
ctl->stylesheet = value;
static gint exporthtml_create_css_dfl( const gchar *fileSpec ) {
FILE *cssFile;
- cssFile = fopen( fileSpec, "rb" );
+ cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
fclose( cssFile );
return MGU_SUCCESS;
}
- cssFile = fopen( fileSpec, "wb" );
+ cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
static gint exporthtml_create_css_full( const gchar *fileSpec ) {
FILE *cssFile;
- cssFile = fopen( fileSpec, "rb" );
+ cssFile = g_fopen( fileSpec, "rb" );
if( cssFile ) {
fclose( cssFile );
return MGU_SUCCESS;
}
- cssFile = fopen( fileSpec, "wb" );
+ cssFile = g_fopen( fileSpec, "wb" );
if( ! cssFile ) {
return MGU_OPEN_FILE;
}
if( item2 ) name2 = ADDRITEM_NAME( item2 );
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
- return strcasecmp( name1, name2 );
+ return g_utf8_collate( name1, name2 );
}
/*
if( email2 ) name2 = email2->address;
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
- return strcasecmp( name1, name2 );
+ return g_utf8_collate( name1, name2 );
}
/*
if( attr2 ) name2 = attr2->name;
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
- return strcasecmp( name1, name2 );
+ return g_utf8_collate( name1, name2 );
}
/*
gchar *name;
if( listEMail == NULL ) {
- fprintf( stream, HTML_SPACE );
+ fprintf( stream, SC_HTML_SPACE );
return;
}
fprintf( stream, "%s", _( "Group Name" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"300\">" );
- fprintf( stream, "%s", _( "E-Mail Address" ) );
+ fprintf( stream, "%s", _( "Email Address" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, "</tr>\n" );
list = exporthtml_sort_name( folder->listGroup );
GList *list;
if( listAttr == NULL ) {
- fprintf( stream, HTML_SPACE );
+ fprintf( stream, SC_HTML_SPACE );
return;
}
fprintf( stream, "%s", _( "Display Name" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"300\">" );
- fprintf( stream, "%s", _( "E-Mail Address" ) );
+ fprintf( stream, "%s", _( "Email Address" ) );
fprintf( stream, "</th>\n" );
fprintf( stream, " <th width=\"200\">" );
fprintf( stream, "%s", _( "Full Name" ) );
fprintf( stream, "%s", buf );
}
else {
- fprintf( stream, "%s", HTML_SPACE );
+ fprintf( stream, "%s", SC_HTML_SPACE );
}
fprintf( stream, "</td>\n" );
entry = exporthtml_find_stylesheet( ctl );
fprintf( stream,
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n" );
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n" );
+ fprintf( stream,
+ "\"http://www.w3.org/TR/html4/loose.dtd\">\n" );
fprintf( stream, "<html>\n" );
fprintf( stream, "<head>\n" );
fprintf( stream, "href=\"%s\" >\n", entry->fileName );
}
}
- fprintf( stream, "<body>\n" );
fprintf( stream, "</head>\n" );
}
time_t tt;
gchar *dsName;
static gchar *title;
+ gchar buf[512];
- htmlFile = fopen( ctl->path, "wb" );
+ htmlFile = g_fopen( ctl->path, "wb" );
if( ! htmlFile ) {
/* Cannot open file */
- printf( "Cannot open file for write\n" );
+ g_print( "Cannot open file for write\n" );
ctl->retVal = MGU_OPEN_FILE;
return;
}
- title = _( "Sylpheed Address Book" );
+ title = _( "Claws Mail Address Book" );
rootFolder = cache->rootFolder;
dsName = cache->name;
exporthtml_fmt_folder( ctl, htmlFile, rootFolder );
tt = time( NULL );
- fprintf( htmlFile, "<p>%s</p>\n", ctime( &tt ) );
- fprintf( htmlFile, "<hr width=\"100\%\"></hr>\n" );
+#ifdef SOLARIS
+ fprintf(htmlFile, "<p>%s</p>\n", ctime_r(&tt, buf, sizeof(buf)));
+#else
+ fprintf( htmlFile, "<p>%s</p>\n", ctime_r( &tt, buf ) );
+#endif
+ fprintf( htmlFile, "<hr width=\"100%%\">\n" );
fprintf( htmlFile, "</body>\n" );
fprintf( htmlFile, "</html>\n" );
* Build full export file specification.
* Enter: ctl Export control data.
*/
-static void *exporthtml_build_filespec( ExportHtmlCtl *ctl ) {
+static void exporthtml_build_filespec( ExportHtmlCtl *ctl ) {
gchar *fileSpec;
fileSpec = g_strconcat(
*/
void exporthtml_parse_filespec( ExportHtmlCtl *ctl, gchar *fileSpec ) {
gchar *t;
+ gchar *base = g_path_get_basename(fileSpec);
ctl->fileHtml =
- mgu_replace_string( ctl->fileHtml, g_basename( fileSpec ) );
- t = g_dirname( fileSpec );
+ mgu_replace_string( ctl->fileHtml, base );
+ g_free(base);
+ t = g_path_get_dirname( fileSpec );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, t );
g_free( t );
ctl->path = mgu_replace_string( ctl->path, fileSpec );
gchar *str;
str = g_strconcat(
- g_get_home_dir(), G_DIR_SEPARATOR_S,
- DFL_DIR_SYLPHEED_OUT, NULL );
+ get_home_dir(), G_DIR_SEPARATOR_S,
+ DFL_DIR_CLAWS_OUT, NULL );
ctl->dirOutput = mgu_replace_string( ctl->dirOutput, str );
g_free( str );
ctl->fileHtml =
- mgu_replace_string( ctl->fileHtml, DFL_FILE_SYLPHEED_OUT );
+ mgu_replace_string( ctl->fileHtml, DFL_FILE_CLAWS_OUT );
ctl->encoding = NULL;
ctl->stylesheet = EXPORT_HTML_ID_DEFAULT;
ctl->nameFormat = EXPORT_HTML_FIRST_LAST;
xmlprops_set_property_b( props, EXMLPROP_BANDING, ctl->banding );
xmlprops_set_property_b( props, EXMLPROP_FMT_EMAIL, ctl->linkEMail );
xmlprops_set_property_b( props, EXMLPROP_FMT_ATTRIB, ctl->showAttribs );
- xmlprops_save_file( props );
+ if (xmlprops_save_file( props ) != MGU_SUCCESS)
+ g_warning("can't save settings");
xmlprops_free( props );
}