/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002-2006 Match Grun and the Sylpheed-Claws team
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/*
#include <glib.h>
#include <glib/gi18n.h>
+#ifdef G_OS_WIN32
+# include <w32lib.h>
+#endif
+
#include "mgutils.h"
#include "utils.h"
#include "exporthtml.h"
#define mkdir(a,b) mkdir(a)
#endif
-#define DFL_DIR_SYLPHEED_OUT "sylpheed-out"
-#define DFL_FILE_SYLPHEED_OUT "addressbook.html"
+#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;
gchar *name;
if( listEMail == NULL ) {
- fprintf( stream, HTML_SPACE );
+ fprintf( stream, SC_HTML_SPACE );
return;
}
GList *list;
if( listAttr == NULL ) {
- fprintf( stream, HTML_SPACE );
+ fprintf( stream, SC_HTML_SPACE );
return;
}
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 = 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-Claws 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" );
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 );
}