Commit f4690440 authored by Benoît Minisini's avatar Benoît Minisini

[GB.MIME]

* NEW: New component that manages MIME messages. It is based on the GMime 
  library. Just the beginning of the implementation, not tested.


git-svn-id: svn://localhost/gambas/trunk@5112 867c0c6c-44f3-4631-809d-bfa615b0a4ec
parent 3dc4fd90
......@@ -10,6 +10,7 @@ SUBDIRS = \
@net_dir@ \
@curl_dir@ \
@smtp_dir@ \
@mime_dir@ \
@pcre_dir@ \
@sdl_dir@ \
@sdlsound_dir@ \
......
/* Copyrights */
#define __COPYRIGHT (c) 2012
#define __AUTHOR Benoît Minisini
#define __EMAIL <gambas@users.sourceforge.net>
/* Name of the component */
#define __COMPONENT gb.mime
/* Name of the component with points replaced by underscore */
#define __COMPONENT_UNDERSCORE gb_mime
/* Short name of the component */
#define __NAME mime
/* Short name of the component in uppercase */
#define __UNAME MIME
/* Description of the component */
#define __DESCRIPTION MIME message management based on gmime library
/* If the component detection uses pkg-config */
#define __USE_PKGCONFIG 1
#if __USE_PKGCONFIG
/* Name of the package for pkg-config */
#define __PKGCONFIG_NAME gmime-2.6
/* Minimum version needed */
#define __PKGCONFIG_VERSION
#else /* __USE_PKGCONFIG */
/* If your component uses C */
#define __USE_C 1
/* If your component uses C++ */
#define __USE_CPLUSPLUS 0
/* If your component uses multi-threading */
#define __USE_THREAD 0
/* If your component uses X-Window */
#define __USE_XWINDOW 0
/* Includes to search for */
#define __SEARCH_INCLUDE gmp.h
/* Includes directories search path */
#define __SEARCH_INCLUDE_PATH /usr/local /usr
/* Includes sub-directories search */
#define __SEARCH_INCLUDE_DIR include
/* Libraries to search for */
#define __SEARCH_LIBRARY libgmp.$SHLIBEXT
/* Libraries directories search path */
#define __SEARCH_LIBRARY_PATH /usr/local /usr
/* Libraries sub-directories search path */
#define __SEARCH_LIBRARY_DIR lib/* lib
/* Libraries to link with */
#define __LIBRARY -lgmp
/* Includes to link with */
#define __INCLUDE
#endif /* __USE_PKGCONFIG */
/* Source file list */
#define __SOURCES main.c main.h
/* Main C/C++ source basename in uppercase */
#define __MAIN_UNAME MAIN
......@@ -179,142 +179,146 @@ msgid "GStreamer multimedia component"
msgstr ""
#: CComponent.class:114
msgid "MySQL specific routines"
msgid "MIME format management based on GMime library"
msgstr ""
#: CComponent.class:115
msgid "MySQL specific routines"
msgstr ""
#: CComponent.class:116
msgid "NCurses library"
msgstr ""
#: CComponent.class:116 FCreateProject.form:299
#: CComponent.class:117 FCreateProject.form:299
msgid "Network programming"
msgstr ""
#: CComponent.class:117
#: CComponent.class:118
msgid "Network high-level protocols management"
msgstr ""
#: CComponent.class:118
#: CComponent.class:119
msgid "POP3 client"
msgstr ""
#: CComponent.class:119
#: CComponent.class:120
msgid "SMTP client"
msgstr ""
#: CComponent.class:120
#: CComponent.class:121
msgid "3D programming with OpenGL"
msgstr ""
#: CComponent.class:121
#: CComponent.class:122
msgid "OpenGL utility component"
msgstr ""
#: CComponent.class:122
#: CComponent.class:123
msgid "OpenGL shaders management"
msgstr ""
#: CComponent.class:123
#: CComponent.class:124
msgid "GNU command option parser"
msgstr ""
#: CComponent.class:124
#: CComponent.class:125
msgid "Perl-compatible Regular Expression Matching"
msgstr ""
#: CComponent.class:125
#: CComponent.class:126
msgid "PDF renderer based on Poppler library"
msgstr ""
#: CComponent.class:126
#: CComponent.class:127
msgid "QT4 toolkit"
msgstr ""
#: CComponent.class:127
#: CComponent.class:128
msgid "QT4 toolkit extension"
msgstr ""
#: CComponent.class:128
#: CComponent.class:129
msgid "QT4 WebKit component"
msgstr ""
#: CComponent.class:129
#: CComponent.class:130
msgid "OpenGL with QT4 toolkit"
msgstr ""
#: CComponent.class:130
#: CComponent.class:131
msgid "Report designer"
msgstr ""
#: CComponent.class:131
#: CComponent.class:132
msgid "SDL library"
msgstr ""
#: CComponent.class:132
#: CComponent.class:133
msgid "SDL sound & CD-ROM management"
msgstr ""
#: CComponent.class:133
#: CComponent.class:134
msgid "Application settings management"
msgstr ""
#: CComponent.class:134
#: CComponent.class:135
msgid "Signals management"
msgstr ""
#: CComponent.class:135
#: CComponent.class:136
msgid "Video capture"
msgstr ""
#: CComponent.class:136
#: CComponent.class:137
msgid "Visual Basic compatibility"
msgstr ""
#: CComponent.class:137
#: CComponent.class:138
msgid "XML tools based on libxml"
msgstr ""
#: CComponent.class:138
#: CComponent.class:139
msgid "XML tools"
msgstr ""
#: CComponent.class:139
#: CComponent.class:140
msgid "HTML generator"
msgstr ""
#: CComponent.class:140
#: CComponent.class:141
msgid "XML-RPC protocol"
msgstr ""
#: CComponent.class:141
#: CComponent.class:142
msgid "XSLT tools based on libxslt and libxml"
msgstr ""
#: CComponent.class:142
#: CComponent.class:143
msgid "Web applications tools"
msgstr ""
#: CComponent.class:148 FPropertyComponent.form:126
#: CComponent.class:149 FPropertyComponent.form:126
msgid "Graphical form management"
msgstr ""
#: CComponent.class:149 FPropertyComponent.form:132
#: CComponent.class:150 FPropertyComponent.form:132
msgid "Event loop management"
msgstr ""
#: CComponent.class:151 FPropertyComponent.form:144
#: CComponent.class:152 FPropertyComponent.form:144
msgid "OpenGL display"
msgstr ""
#: CComponent.class:152
#: CComponent.class:153
msgid "Complex numbers"
msgstr ""
#: CComponent.class:153
#: CComponent.class:154
msgid "XML management"
msgstr ""
#: CComponent.class:447
#: CComponent.class:448
msgid "Loading information on component &1..."
msgstr ""
......
......@@ -771,7 +771,7 @@ msgstr "<h2 align=center>Auteurs</h2>\n"
msgid "<h2 align=center>Licence</h2>\n\n<p align=center>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, or (at your option) any later version.</p>\n\n<p align=center>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.</p>\n"
msgstr "<h2 align=center>Licence</h2><p align=center>Ce programme est un LOGICIEL LIBRE. Vous pouvez le redistribuer ET/OU le modifier selon les termes de la Licence Publique Générale GNU telle qu'elle est publiée par la Free Software Foundation ; soit la version 2, ou bien n'importe quelle version ultérieure de votre choix.</p><p align=center>Ce programme est distribué en espérant qu'il soit utile MAIS SANS GARANTIE D'AUCUNE SORTE ; y compris les garanties implicites de COMMERCIABILITÉ ET DE CONFORMITÉ À UNE UTILISATION PARTICULIÈRE. Se reporter à la Licence Publique Générale GNU pour plus d'information.</p>\n"
#: CComponent.class:120
#: CComponent.class:121
msgid "3D programming with OpenGL"
msgstr "Programmation 3D avec OpenGL"
......@@ -931,7 +931,7 @@ msgstr "Améthiste"
msgid "Application debugger helper"
msgstr "Debogueur intégré"
#: CComponent.class:133
#: CComponent.class:134
msgid "Application settings management"
msgstr "Gestion des fichiers de configuration"
......@@ -1643,7 +1643,7 @@ msgstr "Tout compiler"
msgid "Compiling project"
msgstr "Compilation du projet"
#: CComponent.class:152
#: CComponent.class:153
msgid "Complex numbers"
msgstr "Nombres complexes"
......@@ -2291,7 +2291,7 @@ msgstr "Evènement"
msgid "Event loop"
msgstr "Boucle d'évènements"
#: CComponent.class:149 FPropertyComponent.form:132
#: CComponent.class:150 FPropertyComponent.form:132
msgid "Event loop management"
msgstr "Gestion de la boucle d'évènements"
......@@ -2707,7 +2707,7 @@ msgstr "Allemand (Allemagne)"
msgid "Get from 'VERSION' file"
msgstr "Obtenir depuis un fichier 'VERSION'"
#: CComponent.class:123
#: CComponent.class:124
msgid "GNU command option parser"
msgstr "Analyseur d'options de ligne de commande GNU"
......@@ -2739,7 +2739,7 @@ msgstr "Aller à la ligne..."
msgid "Graphical application"
msgstr "Application graphique"
#: CComponent.class:148 FPropertyComponent.form:126
#: CComponent.class:149 FPropertyComponent.form:126
msgid "Graphical form management"
msgstr "Gestion de formulaires graphiques"
......@@ -2839,7 +2839,7 @@ msgstr "Fichier HTML"
msgid "HTML files"
msgstr "Fichiers HTML"
#: CComponent.class:139
#: CComponent.class:140
msgid "HTML generator"
msgstr "Générateur HTML"
......@@ -3215,7 +3215,7 @@ msgstr "Chargement de &1..."
msgid "Loading has already failed"
msgstr "Le chargement a déjà échoué"
#: CComponent.class:447
#: CComponent.class:448
msgid "Loading information on component &1..."
msgstr "Chargement des informations sur le composant &1..."
......@@ -3343,6 +3343,10 @@ msgstr "Messages"
msgid "Methods"
msgstr "Méthodes"
#: CComponent.class:114
msgid "MIME format management based on GMime library"
msgstr "Gestion du format MIME basée sur la bibliothèque GMime"
#: FMakeInstall.form:523
msgid "Mimetypes"
msgstr "Types MIME"
......@@ -3455,7 +3459,7 @@ msgstr "Héritage multiple"
msgid "MySQL database driver"
msgstr "Pilote de base de données MySQL"
#: CComponent.class:114
#: CComponent.class:115
msgid "MySQL specific routines"
msgstr "Routines spécifiques pour MySQL"
......@@ -3467,15 +3471,15 @@ msgstr "Nom"
msgid "native code"
msgstr "code natif"
#: CComponent.class:115
#: CComponent.class:116
msgid "NCurses library"
msgstr "Bibliothèque NCurses"
#: CComponent.class:117
#: CComponent.class:118
msgid "Network high-level protocols management"
msgstr "Gestion de protocoles réseaux de haut-niveau"
#: CComponent.class:116 FCreateProject.form:299
#: CComponent.class:117 FCreateProject.form:299
msgid "Network programming"
msgstr "Programmation réseau"
......@@ -3783,7 +3787,7 @@ msgstr "Ouvrir un projet..."
msgid "OpenGL"
msgstr "OpenGL"
#: CComponent.class:151 FPropertyComponent.form:144
#: CComponent.class:152 FPropertyComponent.form:144
msgid "OpenGL display"
msgstr "Affichage OpenGL"
......@@ -3791,11 +3795,11 @@ msgstr "Affichage OpenGL"
msgid "OpenGL programming"
msgstr "Programmation OpenGL"
#: CComponent.class:122
#: CComponent.class:123
msgid "OpenGL shaders management"
msgstr "Gestion des shaders OpenGL"
#: CComponent.class:121
#: CComponent.class:122
msgid "OpenGL utility component"
msgstr "composant utilitaire OpenGL"
......@@ -3807,7 +3811,7 @@ msgstr "OpenGL avec GTK+"
msgid "OpenGL with QT/GTK+ switcher component"
msgstr "Sélection du composant graphique OpenGL selon le bureau"
#: CComponent.class:129
#: CComponent.class:130
msgid "OpenGL with QT4 toolkit"
msgstr "OpenGL avec QT4"
......@@ -3927,11 +3931,11 @@ msgstr "Emplacement"
msgid "Pause"
msgstr "Pause"
#: CComponent.class:125
#: CComponent.class:126
msgid "PDF renderer based on Poppler library"
msgstr "Lecture de PDF basée sur la bibliothèque Poppler"
#: CComponent.class:124
#: CComponent.class:125
msgid "Perl-compatible Regular Expression Matching"
msgstr "Expression rationnelles compatibles avec Perl"
......@@ -4055,7 +4059,7 @@ msgstr "Pointer"
msgid "Polish (Poland)"
msgstr "Polonais (Pologne)"
#: CComponent.class:118
#: CComponent.class:119
msgid "POP3 client"
msgstr "Client POP3"
......@@ -4223,15 +4227,15 @@ msgstr "Application graphique QT"
msgid "QT/GTK+ switcher component"
msgstr "Sélection du composant graphique selon le bureau"
#: CComponent.class:126
#: CComponent.class:127
msgid "QT4 toolkit"
msgstr "Bibliothèque QT4"
#: CComponent.class:127
#: CComponent.class:128
msgid "QT4 toolkit extension"
msgstr "Controles supplémentaires basés sur la bibliothèque QT4"
#: CComponent.class:128
#: CComponent.class:129
msgid "QT4 WebKit component"
msgstr "Composant WebKit de QT4"
......@@ -4371,7 +4375,7 @@ msgstr "Remplacement de couleur"
msgid "Report"
msgstr "État"
#: CComponent.class:130
#: CComponent.class:131
msgid "Report designer"
msgstr "Générateur d'états"
......@@ -4527,11 +4531,11 @@ msgstr "Déplacer"
msgid "SDL application"
msgstr "Application SDL"
#: CComponent.class:131
#: CComponent.class:132
msgid "SDL library"
msgstr "Bibliothèque SDL"
#: CComponent.class:132
#: CComponent.class:133
msgid "SDL sound & CD-ROM management"
msgstr "Gestion du son et du CD-ROM basé sur la bibliothèque SDL"
......@@ -4751,7 +4755,7 @@ msgstr "Afficher les astuces au démarrage"
msgid "Show tooltips"
msgstr "Afficher les bulles d'aide"
#: CComponent.class:134
#: CComponent.class:135
msgid "Signals management"
msgstr "Gestion des signaux"
......@@ -4775,7 +4779,7 @@ msgstr "Petite"
msgid "Small font size"
msgstr "Petite taille de police"
#: CComponent.class:119
#: CComponent.class:120
msgid "SMTP client"
msgstr "Client SMTP"
......@@ -6031,7 +6035,7 @@ msgstr "Séparation verticale"
msgid "Video"
msgstr "Vidéo"
#: CComponent.class:135
#: CComponent.class:136
msgid "Video capture"
msgstr "Capture vidéo"
......@@ -6047,7 +6051,7 @@ msgstr "Affichage"
msgid "Visual"
msgstr "Visuel"
#: CComponent.class:136
#: CComponent.class:137
msgid "Visual Basic compatibility"
msgstr "Compatibilité avec Visual Basic"
......@@ -6075,7 +6079,7 @@ msgstr "Surveiller"
msgid "Watch expression"
msgstr "Surveiller des expressions"
#: CComponent.class:142
#: CComponent.class:143
msgid "Web applications tools"
msgstr "Outils pour les applications Web"
......@@ -6115,23 +6119,23 @@ msgstr "Programmation XML / XSLT"
msgid "XML file"
msgstr "Fichier XML"
#: CComponent.class:153
#: CComponent.class:154
msgid "XML management"
msgstr "Gestion du XML"
#: CComponent.class:138
#: CComponent.class:139
msgid "XML tools"
msgstr "Outils XML"
#: CComponent.class:137
#: CComponent.class:138
msgid "XML tools based on libxml"
msgstr "Outils XML basés sur la bibliothèque libxml"
#: CComponent.class:140
#: CComponent.class:141
msgid "XML-RPC protocol"
msgstr "Protocole XML-RPC"
#: CComponent.class:141
#: CComponent.class:142
msgid "XSLT tools based on libxslt and libxml"
msgstr "Outils XSLT basés sur libxslt et libxml"
......
......@@ -111,6 +111,7 @@ Static Private Sub InitComponentNames()
$cName["gb.image.io"] = ("Image loading and saving")
$cName["gb.ldap"] = ("OpenLDAP client")
$cName["gb.media"] = ("GStreamer multimedia component")
$cName["gb.mime"] = ("MIME format management based on GMime library")
$cName["gb.mysql"] = ("MySQL specific routines")
$cName["gb.ncurses"] = ("NCurses library")
$cName["gb.net"] = ("Network programming")
......
......@@ -19,6 +19,7 @@ GB_CONFIG_SUBDIRS(sqlite3, gb.db.sqlite3)
GB_CONFIG_SUBDIRS(net, gb.net)
GB_CONFIG_SUBDIRS(curl, gb.net.curl)
GB_CONFIG_SUBDIRS(smtp, gb.net.smtp)
GB_CONFIG_SUBDIRS(mime, gb.mime)
GB_CONFIG_SUBDIRS(pcre, gb.pcre)
GB_CONFIG_SUBDIRS(sdl, gb.sdl)
GB_CONFIG_SUBDIRS(sdlsound, gb.sdl.sound)
......
../COPYING
\ No newline at end of file
../INSTALL
\ No newline at end of file
ACLOCAL_AMFLAGS = -I m4 --install
SUBDIRS = @MIME_DIR@
EXTRA_DIST = reconf gambas.h gb*.h
../acinclude.m4
\ No newline at end of file
../component.am
\ No newline at end of file
dnl ---- configure.ac for gb.mime
AC_INIT(configure.ac)
AC_CONFIG_MACRO_DIR([m4])
GB_INIT(gb.mime)
AC_PROG_LIBTOOL
GB_COMPONENT_PKG_CONFIG(
mime,
MIME,
gb.mime,
[src],
gmime-2.6)
AC_OUTPUT( Makefile src/Makefile )
GB_PRINT_MESSAGES
../main/share/gambas.h
\ No newline at end of file
../main/share/gb_common.h
\ No newline at end of file
../m4
\ No newline at end of file
../missing
\ No newline at end of file
../reconf
\ No newline at end of file
COMPONENT = gb.mime
include $(top_srcdir)/component.am
gblib_LTLIBRARIES = gb.mime.la
gb_mime_la_LIBADD = @MIME_LIB@
gb_mime_la_LDFLAGS = -module @LD_FLAGS@ @MIME_LDFLAGS@
gb_mime_la_CPPFLAGS = @MIME_INC@
gb_mime_la_SOURCES = main.c main.h \
c_mimemessage.h c_mimemessage.c \
c_mimepart.h c_mimepart.c
/***************************************************************************
c_mimemessage.c
gb.mime component
(c) 2012 Benoît Minisini <gambas@users.sourceforge.net>
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 1, 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#define __C_MIMEMESSAGE_C
#include "c_mimemessage.h"
#define THIS ((CMIMEMESSAGE *)_object)
#define MESSAGE THIS->message
//-------------------------------------------------------------------------
BEGIN_METHOD(MimeMessage_new, GB_STRING contents)
GMimeMessage *message;
if (MISSING(contents))
{
message = g_mime_message_new(FALSE);
}
else
{
GMimeParser *parser;
GMimeStream *stream;
/* create a stream to read from memory */
stream = g_mime_stream_mem_new_with_buffer(STRING(contents), LENGTH(contents));
/* create a new parser object to parse the stream */
parser = g_mime_parser_new_with_stream (stream);
/* unref the stream (parser owns a ref, so this object does not actually get free'd until we destroy the parser) */
g_object_unref (stream);
/* parse the message from the stream */
message = g_mime_parser_construct_message (parser);
/* free the parser (and the stream) */
g_object_unref (parser);
}
THIS->message = message;
END_METHOD
BEGIN_METHOD_VOID(MimeMessage_free)
g_object_unref(MESSAGE);
END_METHOD
#define IMPLEMENT_STRING_PROPERTY(_name, _func) \
BEGIN_PROPERTY(MimeMessage_##_name) \
\
if (READ_PROPERTY) \
GB.ReturnNewZeroString(g_mime_message_get_##_func(MESSAGE)); \
else \
g_mime_message_set_##_func(MESSAGE, GB.ToZeroString(PROP(GB_STRING))); \
\
END_PROPERTY
IMPLEMENT_STRING_PROPERTY(Sender, sender)
IMPLEMENT_STRING_PROPERTY(ReplyTo, reply_to)
IMPLEMENT_STRING_PROPERTY(Subject, subject)
IMPLEMENT_STRING_PROPERTY(Id, message_id)
#define IMPLEMENT_RECIPIENT_PROPERTY(_name, _type) \
BEGIN_PROPERTY(MimeMessage_##_name) \
\
InternetAddressList *addr = g_mime_message_get_recipients(MESSAGE, _type); \
\
if (READ_PROPERTY) \
{ \
char *list = internet_address_list_to_string(addr, FALSE); \
GB.ReturnNewZeroString(list); \
g_free(list); \
} \
else \
{ \
InternetAddressList *new_addr; \
\
internet_address_list_clear(addr); \
\
new_addr = internet_address_list_parse_string(GB.ToZeroString(PROP(GB_STRING))); \
internet_address_list_append(addr, new_addr); \
g_object_unref(new_addr); \
} \
\
END_PROPERTY
IMPLEMENT_RECIPIENT_PROPERTY(To, GMIME_RECIPIENT_TYPE_TO);
IMPLEMENT_RECIPIENT_PROPERTY(Cc, GMIME_RECIPIENT_TYPE_CC);
IMPLEMENT_RECIPIENT_PROPERTY(Bcc, GMIME_RECIPIENT_TYPE_BCC);
//-------------------------------------------------------------------------
GB_DESC MimeMessageDesc[] =
{
GB_DECLARE("MimeMessage", sizeof(CMIMEMESSAGE)),
GB_METHOD("_new", NULL, MimeMessage_new, "[(Contents)s]"),
GB_METHOD("_free", NULL, MimeMessage_free, NULL),
GB_PROPERTY("Sender", "s", MimeMessage_Sender),
GB_PROPERTY("ReplyTo", "s", MimeMessage_ReplyTo),
GB_PROPERTY("To", "s", MimeMessage_To),
GB_PROPERTY("Cc", "s", MimeMessage_Cc),
GB_PROPERTY("Bcc", "s", MimeMessage_Bcc),
GB_PROPERTY("Subject", "s", MimeMessage_Subject),
//GB_PROPERTY("Date", "d", MimeMessage_Date),
GB_PROPERTY("Id", "s", MimeMessage_Id),
//GB_PROPERTY("Part", "MimePart", MimeMessage_Part),
//GB_PROPERTY_Read("Body", "MimePart", MimeMessage_Body)
GB_END_DECLARE
};
\ No newline at end of file
/***************************************************************************
c_mimemessage.h
gb.mime component