Properly handle NILs for the namespace separator (somehow I missed
this, silly me).
+2004-12-02 Not Zed <NotZed@Ximian.com>
+
+ * Makefile.am: version all the libraries with the base version of the
+ package. move libcamel-1.2 into libdir, etc.
+
+ * camel.pc.in: remove the provider stuff from here.
+
+ * camel-provider.pc.in: create a camel-provider pc file.
+
+2004-11-16 Not Zed <NotZed@Ximian.com>
+
+ * tests/lib/folders.c (test_folder_message_ops): updated counts for
+ delete also marking unread.
+
+ * tests/lib/camel-test.c (camel_test_provider_init): new api for
+ initialising test system 'in-build'.
+
+ * camel-provider.c: remove the assertions, init if we need to,k
+ use pthread_once stuff to serialise it.
+
+ * tests/folder/test3.c (main): remove gtk stuff (???).
+
+ * tests/*: Fix all the makefiles. Made make-check work 'in-build'.
+
+ * tests/lib/folders.c (test_folder_counts): update for api changes.
+ (test_message_info): similar.
+
+ * providers/Makefile.am: removed groupwise from the build, this
+ can't go in here anymore, not in its current state.
+
+ * camel-net-utils.c (camel_gethostbyaddr_r)
+ (camel_gethostbyname_r): the old e_gethost* calls from
+ e-host-utils.c.
+
+2004-11-15 Not Zed <NotZed@Ximian.com>
+
+ * providers/imap/camel-imap-utils.c (imap_path_to_physical):
+ copied from e-path.c.
+ (imap_path_find_folders): copied from e-path.c.
+
+ * camel.h: remove the provider stuff from the header.
+
+ * camel-provider.c: globalise provider_init variable, and asserton
+ it in all functions that rely on it.
+
+ * camel-service.c: removed getaddrinfo/etc.
+
+ * camel-net-utils.[ch]: separate out camel_getaddrinfo etc.
+
+ * Makefile.am: split camel into 2 libraries, libcamel and
+ libcamel-store.
+
+ * camel-multipart-signed.c (camel_multipart_signed_sign)
+ (camel_multipart_signed_verify, prepare_sign): remove old
+ deprecated api.
+
+ * camel-multipart-encrypted.c (camel_multipart_encrypted_encrypt)
+ (camel_multipart_encrypted_decrypt): remove old deprecated api.
+
2004-11-12 Not Zed <NotZed@Ximian.com>
** Merge in notzed-messageinfo-branch, fix some minor conflicts.
SUBDIRS = . providers tests
+%-$(BASE_VERSION).pc: %.pc
+ cp $< $@
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = camel-$(BASE_VERSION).pc camel-provider-$(BASE_VERSION).pc
+
libcamelincludedir = $(privincludedir)/camel
+libcamel_providerincludedir = $(privincludedir)/camel
-camellibexecdir = $(privlibexecdir)/camel
-camellibexec_PROGRAMS = camel-lock-helper camel-index-control
+camellibexecdir = $(libexecdir)
+camellibexec_PROGRAMS = camel-lock-helper-1.2 camel-index-control-1.2
-privlib_LTLIBRARIES = libcamel.la
+lib_LTLIBRARIES = libcamel-1.2.la libcamel-provider-1.2.la
INCLUDES = -I.. -I$(srcdir)/.. \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-DCAMEL_LIBEXECDIR=\""$(camellibexecdir)"\" \
-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" \
-DG_LOG_DOMAIN=\"camel\" \
$(CAMEL_CFLAGS)
-libcamel_la_SOURCES = \
- broken-date-parser.c \
- camel-address.c \
- camel-arg.c \
- camel-block-file.c \
- camel-certdb.c \
- camel-charset-map.c \
+libcamel_provider_1_2_la_SOURCES = \
camel-cipher-context.c \
- camel-data-cache.c \
- camel-data-wrapper.c \
- camel-debug.c \
camel-digest-folder.c \
camel-digest-store.c \
camel-digest-summary.c \
camel-disco-diary.c \
camel-disco-folder.c \
camel-disco-store.c \
- camel-exception.c \
- camel-file-utils.c \
camel-filter-driver.c \
camel-filter-search.c \
camel-folder-search.c \
camel-folder-thread.c \
camel-folder.c \
camel-gpg-context.c \
- camel-html-parser.c \
camel-http-stream.c \
+ camel-movemail.c \
+ camel-provider.c \
+ camel-sasl-anonymous.c \
+ camel-sasl-cram-md5.c \
+ camel-sasl-digest-md5.c \
+ camel-sasl-gssapi.c \
+ camel-sasl-kerberos4.c \
+ camel-sasl-login.c \
+ camel-sasl-ntlm.c \
+ camel-sasl-plain.c \
+ camel-sasl-popb4smtp.c \
+ camel-sasl.c \
+ camel-search-private.c \
+ camel-service.c \
+ camel-session.c \
+ camel-smime-context.c \
+ camel-store-summary.c \
+ camel-store.c \
+ camel-tcp-stream-openssl.c \
+ camel-tcp-stream-raw.c \
+ camel-tcp-stream-ssl.c \
+ camel-tcp-stream.c \
+ camel-transport.c \
+ camel-uid-cache.c \
+ camel-vee-folder.c \
+ camel-vee-store.c \
+ camel-vee-summary.c \
+ camel-vtrash-folder.c
+
+libcamel_providerinclude_HEADERS = \
+ camel-cipher-context.h \
+ camel-digest-folder.h \
+ camel-digest-store.h \
+ camel-digest-summary.h \
+ camel-disco-diary.h \
+ camel-disco-folder.h \
+ camel-disco-store.h \
+ camel-filter-driver.h \
+ camel-filter-search.h \
+ camel-folder-search.h \
+ camel-folder-summary.h \
+ camel-folder-thread.h \
+ camel-folder.h \
+ camel-gpg-context.h \
+ camel-http-stream.h \
+ camel-movemail.h \
+ camel-provider.h \
+ camel-sasl-anonymous.h \
+ camel-sasl-cram-md5.h \
+ camel-sasl-digest-md5.h \
+ camel-sasl-gssapi.h \
+ camel-sasl-kerberos4.h \
+ camel-sasl-login.h \
+ camel-sasl-ntlm.h \
+ camel-sasl-plain.h \
+ camel-sasl-popb4smtp.h \
+ camel-sasl.h \
+ camel-service.h \
+ camel-session.h \
+ camel-smime-context.h \
+ camel-store-summary.h \
+ camel-store.h \
+ camel-tcp-stream-raw.h \
+ camel-tcp-stream-ssl.h \
+ camel-tcp-stream.h \
+ camel-transport.h \
+ camel-uid-cache.h \
+ camel-vee-folder.h \
+ camel-vee-store.h \
+ camel-vee-summary.h \
+ camel-vtrash-folder.h
+
+libcamel_provider_1_2_la_LDFLAGS = -version-info $(LIBCAMEL_CURRENT):$(LIBCAMEL_REVISION):$(LIBCAMEL_AGE)
+
+libcamel_provider_1_2_la_LIBADD = \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
+ libcamel-1.2.la \
+ $(CAMEL_LIBS)
+
+libcamel_1_2_la_SOURCES = \
+ broken-date-parser.c \
+ camel-address.c \
+ camel-arg.c \
+ camel-block-file.c \
+ camel-certdb.c \
+ camel-charset-map.c \
+ camel-data-cache.c \
+ camel-data-wrapper.c \
+ camel-debug.c \
+ camel-exception.c \
+ camel-file-utils.c \
+ camel-html-parser.c \
camel-index.c \
camel-internet-address.c \
camel-junk-plugin.c \
- camel-lock.c \
+ camel-list-utils.c \
camel-lock-client.c \
+ camel-lock.c \
camel-medium.c \
- camel-mime-filter-bestenc.c \
camel-mime-filter-basic.c \
- camel-mime-filter-charset.c \
+ camel-mime-filter-bestenc.c \
camel-mime-filter-canon.c \
+ camel-mime-filter-charset.c \
camel-mime-filter-crlf.c \
camel-mime-filter-enriched.c \
camel-mime-filter-from.c \
camel-mime-filter-gzip.c \
camel-mime-filter-html.c \
- camel-mime-filter-tohtml.c \
camel-mime-filter-index.c \
camel-mime-filter-linewrap.c \
camel-mime-filter-save.c \
+ camel-mime-filter-tohtml.c \
camel-mime-filter-windows.c \
camel-mime-filter-yenc.c \
camel-mime-filter.c \
camel-mime-part-utils.c \
camel-mime-part.c \
camel-mime-utils.c \
- camel-movemail.c \
- camel-multipart.c \
camel-multipart-encrypted.c \
camel-multipart-signed.c \
- camel-list-utils.c \
+ camel-multipart.c \
+ camel-net-utils.c \
camel-object.c \
camel-operation.c \
camel-partition-table.c \
- camel-provider.c \
- camel-sasl.c \
- camel-sasl-anonymous.c \
- camel-sasl-cram-md5.c \
- camel-sasl-digest-md5.c \
- camel-sasl-gssapi.c \
- camel-sasl-kerberos4.c \
- camel-sasl-login.c \
- camel-sasl-ntlm.c \
- camel-sasl-plain.c \
- camel-sasl-popb4smtp.c \
- camel-search-private.c \
camel-seekable-stream.c \
camel-seekable-substream.c \
- camel-service.c \
- camel-session.c \
- camel-smime-context.c \
- camel-store.c \
- camel-store-summary.c \
camel-stream-buffer.c \
camel-stream-filter.c \
camel-stream-fs.c \
camel-stream.c \
camel-string-utils.c \
camel-text-index.c \
- camel-tcp-stream-raw.c \
- camel-tcp-stream-ssl.c \
- camel-tcp-stream-openssl.c \
- camel-tcp-stream.c \
- camel-transport.c \
- camel-uid-cache.c \
- camel-url.c \
camel-url-scanner.c \
+ camel-url.c \
camel-utf8.c \
- camel-vee-folder.c \
- camel-vee-store.c \
- camel-vee-summary.c \
- camel-vtrash-folder.c \
camel.c
libcamelinclude_HEADERS = \
camel-block-file.h \
camel-certdb.h \
camel-charset-map.h \
- camel-cipher-context.h \
camel-data-cache.h \
camel-data-wrapper.h \
camel-debug.h \
- camel-digest-folder.h \
- camel-digest-store.h \
- camel-digest-summary.h \
- camel-disco-diary.h \
- camel-disco-folder.h \
- camel-disco-store.h \
camel-exception-list.def \
camel-exception.h \
camel-file-utils.h \
- camel-filter-driver.h \
- camel-filter-search.h \
- camel-folder-search.h \
- camel-folder-summary.h \
- camel-folder-thread.h \
- camel-folder.h \
- camel-gpg-context.h \
- camel-http-stream.h \
+ camel-i18n.h \
camel-index.h \
camel-internet-address.h \
- camel-i18n.h \
camel-junk-plugin.h \
- camel-lock.h \
+ camel-list-utils.h \
camel-lock-client.h \
+ camel-lock.h \
camel-medium.h \
- camel-mime-filter-bestenc.h \
camel-mime-filter-basic.h \
- camel-mime-filter-charset.h \
+ camel-mime-filter-bestenc.h \
camel-mime-filter-canon.h \
+ camel-mime-filter-charset.h \
camel-mime-filter-crlf.h \
camel-mime-filter-enriched.h \
camel-mime-filter-from.h \
camel-mime-filter-gzip.h \
camel-mime-filter-html.h \
- camel-mime-filter-tohtml.h \
camel-mime-filter-index.h \
camel-mime-filter-linewrap.h \
camel-mime-filter-save.h \
+ camel-mime-filter-tohtml.h \
camel-mime-filter-windows.h \
camel-mime-filter-yenc.h \
camel-mime-filter.h \
camel-mime-part-utils.h \
camel-mime-part.h \
camel-mime-utils.h \
- camel-movemail.h \
- camel-multipart.h \
camel-multipart-encrypted.h \
camel-multipart-signed.h \
- camel-list-utils.h \
+ camel-multipart.h \
+ camel-net-utils.h \
camel-object.h \
camel-operation.h \
camel-partition-table.h \
- camel-provider.h \
- camel-sasl.h \
- camel-sasl-anonymous.h \
- camel-sasl-cram-md5.h \
- camel-sasl-digest-md5.h \
- camel-sasl-gssapi.h \
- camel-sasl-kerberos4.h \
- camel-sasl-login.h \
- camel-sasl-ntlm.h \
- camel-sasl-plain.h \
- camel-sasl-popb4smtp.h \
camel-seekable-stream.h \
camel-seekable-substream.h \
- camel-service.h \
- camel-session.h \
- camel-smime-context.h \
- camel-store.h \
- camel-store-summary.h \
camel-stream-buffer.h \
camel-stream-filter.h \
camel-stream-fs.h \
camel-stream.h \
camel-string-utils.h \
camel-text-index.h \
- camel-tcp-stream-raw.h \
- camel-tcp-stream-ssl.h \
- camel-tcp-stream.h \
- camel-transport.h \
camel-types.h \
- camel-uid-cache.h \
- camel-url.h \
camel-url-scanner.h \
+ camel-url.h \
camel-utf8.h \
- camel-vee-folder.h \
- camel-vee-store.h \
- camel-vee-summary.h \
- camel-vtrash-folder.h \
camel.h
-libcamel_la_LDFLAGS = -version-info 0:0:0
+libcamel_1_2_la_LDFLAGS = -version-info 0:0:0
-libcamel_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
+libcamel_1_2_la_LIBADD = \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(CAMEL_LIBS)
-camel_lock_helper_SOURCES = \
+camel_lock_helper_1_2_SOURCES = \
camel-lock-helper.c \
camel-lock-helper.h
# NOTE: This needs to be cleaned up, it shouldn't link with all this crap,
# because it might be setuid.
-camel_lock_helper_LDADD = \
+camel_lock_helper_1_2_LDADD = \
camel-lock.o \
- $(libcamel_la_LIBADD)
+ $(libcamel_1_2_la_LIBADD)
-camel_index_control_SOURCES = \
+camel_index_control_1_2_SOURCES = \
camel-index-control.c
-camel_index_control_LDADD = \
- $(libcamel_la_LIBADD) \
- libcamel.la
-# $(EVOLUTION_MAIL_LIBS)
+camel_index_control_1_2_LDADD = \
+ libcamel-1.2.la \
+ $(libcamel_1_2_la_LIBADD)
install-exec-hook:
@if test -n "$(CAMEL_LOCK_HELPER_USER)"; then \
if test `whoami` = root ; then \
- chown $(CAMEL_LOCK_HELPER_USER) $(DESTDIR)$(camellibexecdir)/camel-lock-helper ; \
- chmod u+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper ; \
+ chown $(CAMEL_LOCK_HELPER_USER) $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION) ; \
+ chmod u+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION) ; \
else \
echo '*** WARNING ***' ; \
echo "Camel will not be able to open mbox files until you perform the following steps:" ; \
fi
@if test -n "$(CAMEL_LOCK_HELPER_GROUP)"; then \
if test `whoami` = root ; then \
- chgrp $(CAMEL_LOCK_HELPER_GROUP) $(DESTDIR)$(camellibexecdir)/camel-lock-helper ; \
- chmod g+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper ; \
+ chgrp $(CAMEL_LOCK_HELPER_GROUP) $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION) ; \
+ chmod g+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION) ; \
else \
echo '*** WARNING ***' ; \
echo "Camel will not be able to open mbox files until you perform the following steps:" ; \
echo " 1. Become root" ; \
- echo " 2. chgrp $(CAMEL_LOCK_HELPER_GROUP) $(DESTDIR)$(camellibexecdir)/camel-lock-helper" ; \
- echo " 3. chmod g+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper" ; \
+ echo " 2. chgrp $(CAMEL_LOCK_HELPER_GROUP) $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION)" ; \
+ echo " 3. chmod g+s $(DESTDIR)$(camellibexecdir)/camel-lock-helper-$(BASE_VERSION)" ; \
echo '*** WARNING ***' ; \
fi \
else \
fi
noinst_HEADERS = \
+ broken-date-parser.h \
camel-charset-map-private.h \
camel-private.h \
camel-search-private.h \
camel-html-parser.h
EXTRA_DIST = \
+ $(pkgconfig_DATA:.pc=.pc.in) \
ChangeLog.pre-1-4 \
README
#include <time.h>
#include "broken-date-parser.h"
-#include "e-time-utils.h"
+#include "libedataserver/e-time-utils.h"
#define d(x)
#include <fcntl.h>
#include <errno.h>
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#include "camel-block-file.h"
#include "camel-file-utils.h"
#include <camel/camel-object.h>
#include <glib.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include <stdio.h>
typedef guint32 camel_block_t; /* block offset, absolute, bottom BLOCK_SIZE_BITS always 0 */
#include <camel/camel-file-utils.h>
-#include <e-util/e-memory.h>
+#include <libedataserver/e-memory.h>
#define CAMEL_CERTDB_GET_CLASS(db) ((CamelCertDBClass *) CAMEL_OBJECT_GET_CLASS (db))
#include "camel-charset-map.h"
#include "camel-charset-map-private.h"
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include <glib.h>
#include <locale.h>
#include <camel/camel-exception.h>
/* FIXME: camelise */
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
struct _CamelStream;
struct _CamelMimePart;
#include <pthread.h>
#include "camel-exception.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#include "camel-debug.h"
#include "camel-debug.h"
#include "camel-i18n.h"
-#include "e-util/e-sexp.h"
-#include "e-util/e-memory.h"
-#include "e-util/e-msgport.h" /* for edlist */
+#include "libedataserver/e-sexp.h"
+#include "libedataserver/e-memory.h"
+#include "libedataserver/e-msgport.h" /* for edlist */
#define d(x)
#include <signal.h>
#include <sys/wait.h>
-#include <e-util/e-sexp.h>
-
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-sexp.h>
+#include <libedataserver/e-iconv.h>
#include "camel-mime-message.h"
#include "camel-provider.h"
#include <glib.h>
+#include "libedataserver/e-memory.h"
+
#include "camel-folder-search.h"
#include "camel-folder-thread.h"
#include "camel-multipart.h"
#include "camel-mime-message.h"
#include "camel-stream-mem.h"
-#include "e-util/e-memory.h"
#include "camel-search-private.h"
#include "camel-i18n.h"
#pragma }
#endif /* __cplusplus */
-#include <e-util/e-sexp.h>
+#include <libedataserver/e-sexp.h>
#include <camel/camel-folder.h>
#include <camel/camel-object.h>
#include <camel/camel-index.h>
#include <errno.h>
#include <ctype.h>
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include "camel-folder-summary.h"
#include <camel/camel-string-utils.h>
-#include "e-util/md5-utils.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/md5-utils.h"
+#include "libedataserver/e-memory.h"
#include "camel-private.h"
#include <glib.h>
#include "camel-folder-thread.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#define d(x)
#define m(x)
#include "camel-store.h"
#include "camel-mime-message.h"
#include "camel-debug.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#include "camel-operation.h"
#include "camel-session.h"
#include "camel-filter-driver.h"
#include <errno.h>
#include <ctype.h>
-#include "gal/util/e-iconv.h"
+#include "libedataserver/e-iconv.h"
#include "camel-gpg-context.h"
#include "camel-mime-filter-charset.h"
#include <ctype.h>
#include <errno.h>
+#include "camel-net-utils.h"
#include "camel-http-stream.h"
#include "camel-mime-utils.h"
#include <langinfo.h>
#endif
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#include "camel-charset-map.h"
#include "string-utils.h"
#include "camel-iconv.h"
#include <sys/stat.h>
#include <fcntl.h>
-#include "e-util/e-msgport.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-msgport.h"
+#include "libedataserver/e-memory.h"
#include "camel/camel-object.h"
#include <string.h>
#include <errno.h>
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include "camel-mime-filter-charset.h"
#include "camel-charset-map.h"
#include <string.h>
#include <errno.h>
-#include <gal/util/e-iconv.h>
-
-#include <e-util/e-time-utils.h>
+#include <libedataserver/e-iconv.h>
+#include <libedataserver/e-time-utils.h>
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include <ctype.h>
#include <errno.h>
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include "camel-charset-map.h"
#include "camel-mime-part-utils.h"
#include <ctype.h>
#include <errno.h>
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include "camel-mime-parser.h"
#include "camel-stream-mem.h"
#endif
#include <glib.h>
-#include <gal/util/e-iconv.h>
-#include <e-util/e-time-utils.h>
+#include <libedataserver/e-iconv.h>
+#include <libedataserver/e-time-utils.h>
#include "camel-mime-utils.h"
#include "camel-charset-map.h"
-#include "camel-service.h" /* for camel_gethostbyname() */
+#include "camel-net-utils.h"
#include "camel-utf8.h"
#ifndef CLEAN_DATE
return multipart;
}
-
-
-int
-camel_multipart_encrypted_encrypt (CamelMultipartEncrypted *mpe, CamelMimePart *content,
- CamelCipherContext *cipher, const char *userid,
- GPtrArray *recipients, CamelException *ex)
-{
- abort();
-
-#if 0
- CamelMimePart *version_part, *encrypted_part;
- CamelContentType *mime_type;
- CamelDataWrapper *wrapper;
- CamelStream *stream;
-
- g_return_val_if_fail (CAMEL_IS_MULTIPART_ENCRYPTED (mpe), -1);
- g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (cipher), -1);
- g_return_val_if_fail (cipher->encrypt_protocol != NULL, -1);
- g_return_val_if_fail (CAMEL_IS_MIME_PART (content), -1);
-
- /* encrypt the content stream */
- encrypted_part = camel_mime_part_new();
- if (camel_cipher_encrypt (cipher, userid, recipients, content, encrypted_part, ex) == -1) {
- camel_object_unref(encrypted_part);
- return -1;
- }
-
- /* construct the version part */
- stream = camel_stream_mem_new ();
- camel_stream_write_string (stream, "Version: 1\n");
- camel_stream_reset (stream);
-
- version_part = camel_mime_part_new ();
- wrapper = camel_data_wrapper_new ();
- camel_data_wrapper_set_mime_type (wrapper, cipher->encrypt_protocol);
- camel_data_wrapper_construct_from_stream (wrapper, stream);
- camel_object_unref (stream);
- camel_medium_set_content_object ((CamelMedium *) version_part, wrapper);
- camel_object_unref (wrapper);
-
- /* save the version and encrypted parts */
- /* FIXME: make sure there aren't any other parts?? */
- camel_multipart_add_part (CAMEL_MULTIPART (mpe), version_part);
- camel_object_unref (version_part);
- camel_multipart_add_part (CAMEL_MULTIPART (mpe), encrypted_part);
- camel_object_unref (encrypted_part);
-
- /* cache the decrypted content */
- camel_object_ref (content);
- mpe->decrypted = content;
-
- /* set the content-type params for this multipart/encrypted part */
- mime_type = camel_content_type_new ("multipart", "encrypted");
- camel_content_type_set_param (mime_type, "protocol", cipher->encrypt_protocol);
- camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER (mpe), mime_type);
- camel_content_type_unref (mime_type);
- camel_multipart_set_boundary ((CamelMultipart *) mpe, NULL);
-#endif
-
- return 0;
-}
-
-
-CamelMimePart *
-camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe,
- CamelCipherContext *cipher,
- CamelException *ex)
-{
- CamelMimePart *version_part, *encrypted_part, *decrypted_part;
- CamelContentType *mime_type;
- CamelCipherValidity *valid;
- CamelDataWrapper *wrapper;
- const char *protocol;
- char *content_type;
-
- g_return_val_if_fail (CAMEL_IS_MULTIPART_ENCRYPTED (mpe), NULL);
- g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (cipher), NULL);
- g_return_val_if_fail (cipher->encrypt_protocol != NULL, NULL);
-
- if (mpe->decrypted) {
- /* we seem to have already decrypted the part */
- camel_object_ref (mpe->decrypted);
- return mpe->decrypted;
- }
-
- protocol = mpe->protocol;
-
- if (protocol) {
- /* make sure the protocol matches the cipher encrypt protocol */
- if (g_ascii_strcasecmp (cipher->encrypt_protocol, protocol) != 0) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to decrypt MIME part: protocol error"));
-
- return NULL;
- }
- } else {
- /* *shrug* - I guess just go on as if they match? */
- protocol = cipher->encrypt_protocol;
- }
-
- /* make sure the protocol matches the version part's content-type */
- version_part = camel_multipart_get_part (CAMEL_MULTIPART (mpe), CAMEL_MULTIPART_ENCRYPTED_VERSION);
- wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (version_part));
- content_type = camel_data_wrapper_get_mime_type (wrapper);
- if (g_ascii_strcasecmp (content_type, protocol) != 0) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to decrypt MIME part: protocol error"));
-
- g_free (content_type);
-
- return NULL;
- }
- g_free (content_type);
-
- /* get the encrypted part (second part) */
- encrypted_part = camel_multipart_get_part (CAMEL_MULTIPART (mpe), CAMEL_MULTIPART_ENCRYPTED_CONTENT);
- mime_type = camel_mime_part_get_content_type (encrypted_part);
- if (!camel_content_type_is (mime_type, "application", "octet-stream")) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failed to decrypt MIME part: invalid structure"));
- return NULL;
- }
-
- decrypted_part = camel_mime_part_new();
- valid = camel_cipher_decrypt(cipher, encrypted_part, decrypted_part, ex);
- if (valid) {
- camel_object_ref(decrypted_part);
- mpe->decrypted = decrypted_part;
- camel_cipher_validity_free(valid);
- } else {
- camel_object_ref(decrypted_part);
- decrypted_part = NULL;
- }
-
- return decrypted_part;
-}
#endif /* __cplusplus */
#include <camel/camel-multipart.h>
-#include <camel/camel-cipher-context.h>
#define CAMEL_MULTIPART_ENCRYPTED_TYPE (camel_multipart_encrypted_get_type ())
#define CAMEL_MULTIPART_ENCRYPTED(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MULTIPART_ENCRYPTED_TYPE, CamelMultipartEncrypted))
char *protocol;
};
-
struct _CamelMultipartEncryptedClass {
CamelMultipartClass parent_class;
};
-
CamelType camel_multipart_encrypted_get_type (void);
-
CamelMultipartEncrypted *camel_multipart_encrypted_new (void);
-int camel_multipart_encrypted_encrypt (CamelMultipartEncrypted *mpe, CamelMimePart *content,
- CamelCipherContext *cipher, const char *userid,
- GPtrArray *recipients, CamelException *ex);
-
-CamelMimePart *camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe,
- CamelCipherContext *cipher,
- CamelException *ex);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "camel-multipart-signed.h"
#include "camel-mime-part.h"
#include "camel-exception.h"
-#include "md5-utils.h"
+#include "libedataserver/md5-utils.h"
#include "camel-stream-filter.h"
#include "camel-seekable-substream.h"
return total;
}
-/* See rfc3156, section 2 and others */
-/* We do this simply: Anything not base64 must be qp
- This is so that we can safely translate any occurance of "From "
- into the quoted-printable escaped version safely. */
-static void
-prepare_sign(CamelMimePart *mime_part)
-{
- CamelDataWrapper *wrapper;
- CamelTransferEncoding encoding;
- int parts, i;
-
- wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
- if (!wrapper)
- return;
-
- if (CAMEL_IS_MULTIPART (wrapper)) {
- parts = camel_multipart_get_number((CamelMultipart *)wrapper);
- for (i = 0; i < parts; i++)
- prepare_sign(camel_multipart_get_part((CamelMultipart *)wrapper, i));
- } else if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
- prepare_sign((CamelMimePart *)wrapper);
- } else {
- encoding = camel_mime_part_get_encoding(mime_part);
-
- if (encoding != CAMEL_TRANSFER_ENCODING_BASE64
- && encoding != CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE) {
- camel_mime_part_set_encoding(mime_part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
- }
- }
-}
-
-/**
- * camel_multipart_signed_sign:
- * @mps:
- * @context: The CipherContext to use for signing.
- * @content: CamelMimePart content you wish to sign/transport.
- * @userid: The id of the signing key to use.
- * @hash: The algorithm to use.
- * @ex:
- *
- * Sign the part @content, and attach it as the first part
- * (CAMEL_MULTIPART_SIGNED_CONTENT) of the multipart @mps. A
- * signature object will be created and setup as the second part
- * (CAMEL_MULTIPART_SIGNED_SIGNATURE) of the object. Once a part has
- * been successfully signed the mutlipart is ready for transmission.
- *
- * This method should be used to create multipart/signed objects
- * which are properly canoncalised before signing, etc.
- *
- * Return value: -1 on error, setting @ex appropriately. On error
- * neither the content or signature parts will be setup.
- **/
-int
-camel_multipart_signed_sign(CamelMultipartSigned *mps, CamelCipherContext *context, CamelMimePart *content, const char *userid, CamelCipherHash hash, CamelException *ex)
-{
- abort();
-#if 0
- CamelMimeFilter *canon_filter;
- CamelStream *mem;
- CamelStreamFilter *filter;
- CamelContentType *mime_type;
- CamelMimePart *sigpart;
-
- /* this needs to be set */
- g_return_val_if_fail(context->sign_protocol != NULL, -1);
-
- prepare_sign(content);
-
- mem = camel_stream_mem_new();
- filter = camel_stream_filter_new_with_stream(mem);
-
- /* Note: see rfc2015 or rfc3156, section 5 */
- canon_filter = camel_mime_filter_canon_new(CAMEL_MIME_FILTER_CANON_STRIP|CAMEL_MIME_FILTER_CANON_CRLF|CAMEL_MIME_FILTER_CANON_FROM);
- camel_stream_filter_add(filter, (CamelMimeFilter *)canon_filter);
- camel_object_unref((CamelObject *)canon_filter);
-
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)content, (CamelStream *)filter);
- camel_stream_flush((CamelStream *)filter);
- camel_object_unref((CamelObject *)filter);
- camel_stream_reset(mem);
-
-#if 0
- printf("-- Signing:\n");
- fwrite(((CamelStreamMem *)mem)->buffer->data, ((CamelStreamMem *)mem)->buffer->len, 1, stdout);
- printf("-- end\n");
-#endif
-
- sigpart = camel_mime_part_new();
-
- if (camel_cipher_sign(context, userid, hash, mem, sigpart, ex) == -1) {
- camel_object_unref(mem);
- camel_object_unref(sigpart);
- return -1;
- }
-
- /* setup our mime type and boundary */
- mime_type = camel_content_type_new("multipart", "signed");
- camel_content_type_set_param(mime_type, "micalg", camel_cipher_hash_to_id(context, hash));
- camel_content_type_set_param(mime_type, "protocol", context->sign_protocol);
- camel_data_wrapper_set_mime_type_field(CAMEL_DATA_WRAPPER (mps), mime_type);
- camel_content_type_unref(mime_type);
- camel_multipart_set_boundary((CamelMultipart *)mps, NULL);
-
- /* just keep the whole raw content. We dont *really* need to do this because
- we know how we just proccessed it, but, well, better to be safe than sorry */
- mps->signature = sigpart;
- mps->contentraw = mem;
- camel_stream_reset(mem);
-
- /* clear the data-wrapper stream - tells write_to_stream to use the right object */
- if (((CamelDataWrapper *)mps)->stream) {
- camel_object_unref((CamelObject *) ((CamelDataWrapper *)mps)->stream);
- ((CamelDataWrapper *)mps)->stream = NULL;
- }
-#endif
- return 0;
-}
-
CamelStream *
camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex)
{
return constream;
}
-
-/**
- * camel_multipart_signed_verify:
- * @mps:
- * @context:
- * @ex:
- *
- * Verify a signed object. This may be used to verify newly signed
- * objects as well as those created from external streams or parsers.
- *
- * Return value: A validity value, or NULL on error, setting @ex
- * appropriately.
- **/
-CamelCipherValidity *
-camel_multipart_signed_verify(CamelMultipartSigned *mps, CamelCipherContext *context, CamelException *ex)
-{
- abort();
-
- return NULL;
-#if 0
- CamelCipherValidity *valid;
- CamelMimePart *sigpart;
- CamelStream *constream;
-
- /* we need to be able to verify stuff we just signed as well as stuff we loaded from a stream/parser */
-
- if (mps->contentraw) {
- constream = mps->contentraw;
- camel_object_ref((CamelObject *)constream);
- } else {
- CamelStream *sub;
- CamelMimeFilter *canon_filter;
-
- if (mps->start1 == -1 && parse_content(mps) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("parse error"));
- return NULL;
- }
-
- /* first, prepare our parts */
- sub = camel_seekable_substream_new((CamelSeekableStream *)((CamelDataWrapper *)mps)->stream, mps->start1, mps->end1);
- constream = (CamelStream *)camel_stream_filter_new_with_stream(sub);
- camel_object_unref((CamelObject *)sub);
-
- /* Note: see rfc2015 or rfc3156, section 5 */
- canon_filter = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF);
- camel_stream_filter_add((CamelStreamFilter *)constream, (CamelMimeFilter *)canon_filter);
- camel_object_unref((CamelObject *)canon_filter);
- }
-
- /* we do this as a normal mime part so we can have it handle transfer encoding etc */
- sigpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_SIGNATURE);
-
- /* do the magic, the caller must supply the right context for this kind of object */
- valid = camel_cipher_verify(context, camel_cipher_id_to_hash(context, mps->micalg), constream, sigpart, ex);
-
-#if 0
- {
- CamelStream *sout = camel_stream_fs_new_with_fd(dup(0));
-
- camel_stream_printf(sout, "-- Verifying:\n");
- camel_stream_reset(constream);
- camel_stream_write_to_stream(constream, sout);
- camel_stream_printf(sout, "-- end\n");
- camel_object_unref((CamelObject *)sout);
- }
-#endif
-
- camel_object_unref(constream);
-
- return valid;
-#endif
-}
-
-
#endif /* __cplusplus }*/
#include <camel/camel-multipart.h>
-#include <camel/camel-cipher-context.h>
#define CAMEL_MULTIPART_SIGNED_TYPE (camel_multipart_signed_get_type ())
#define CAMEL_MULTIPART_SIGNED(obj) (CAMEL_CHECK_CAST((obj), CAMEL_MULTIPART_SIGNED_TYPE, CamelMultipartSigned))
CamelStream *camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex);
-int camel_multipart_signed_sign (CamelMultipartSigned *mps, CamelCipherContext *context,
- CamelMimePart *content, const char *uiserid,
- CamelCipherHash hash, CamelException *ex);
-CamelCipherValidity *camel_multipart_signed_verify (CamelMultipartSigned *mps, CamelCipherContext *context,
- CamelException *ex);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "camel-multipart.h"
#include "camel-mime-part.h"
#include "camel-exception.h"
-#include "md5-utils.h"
+#include "libedataserver/md5-utils.h"
#define d(x)
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Michael Zucchi <notzed@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2004 Ximian Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/poll.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include "camel-i18n.h"
+#include "camel-operation.h"
+#include "camel-exception.h"
+#include "camel-net-utils.h"
+
+#include "libedataserver/e-msgport.h"
+
+#define d(x)
+
+/* gethostbyname emulation code for emulating getaddrinfo code ...
+
+This should probably go away */
+
+#ifdef NEED_ADDRINFO
+
+#if !defined (HAVE_GETHOSTBYNAME_R) || !defined (HAVE_GETHOSTBYADDR_R)
+G_LOCK_DEFINE_STATIC (gethost_mutex);
+#endif
+
+#define ALIGN(x) (((x) + (sizeof (char *) - 1)) & ~(sizeof (char *) - 1))
+
+#define GETHOST_PROCESS(h, host, buf, buflen, herr) G_STMT_START { \
+ int num_aliases = 0, num_addrs = 0; \
+ int req_length; \
+ char *p; \
+ int i; \
+ \
+ /* check to make sure we have enough room in our buffer */ \
+ req_length = 0; \
+ if (h->h_aliases) { \
+ for (i = 0; h->h_aliases[i]; i++) \
+ req_length += strlen (h->h_aliases[i]) + 1; \
+ num_aliases = i; \
+ } \
+ \
+ if (h->h_addr_list) { \
+ for (i = 0; h->h_addr_list[i]; i++) \
+ req_length += h->h_length; \
+ num_addrs = i; \
+ } \
+ \
+ req_length += sizeof (char *) * (num_aliases + 1); \
+ req_length += sizeof (char *) * (num_addrs + 1); \
+ req_length += strlen (h->h_name) + 1; \
+ \
+ if (buflen < req_length) { \
+ *herr = ERANGE; \
+ G_UNLOCK (gethost_mutex); \
+ return ERANGE; \
+ } \
+ \
+ /* we store the alias/addr pointers in the buffer */ \
+ /* their addresses here. */ \
+ p = buf; \
+ if (num_aliases) { \
+ host->h_aliases = (char **) p; \
+ p += sizeof (char *) * (num_aliases + 1); \
+ } else \
+ host->h_aliases = NULL; \
+ \
+ if (num_addrs) { \
+ host->h_addr_list = (char **) p; \
+ p += sizeof (char *) * (num_addrs + 1); \
+ } else \
+ host->h_addr_list = NULL; \
+ \
+ /* copy the host name into the buffer */ \
+ host->h_name = p; \
+ strcpy (p, h->h_name); \
+ p += strlen (h->h_name) + 1; \
+ host->h_addrtype = h->h_addrtype; \
+ host->h_length = h->h_length; \
+ \
+ /* copy the aliases/addresses into the buffer */ \
+ /* and assign pointers into the hostent */ \
+ *p = 0; \
+ if (num_aliases) { \
+ for (i = 0; i < num_aliases; i++) { \
+ strcpy (p, h->h_aliases[i]); \
+ host->h_aliases[i] = p; \
+ p += strlen (h->h_aliases[i]); \
+ } \
+ host->h_aliases[num_aliases] = NULL; \
+ } \
+ \
+ if (num_addrs) { \
+ for (i = 0; i < num_addrs; i++) { \
+ memcpy (p, h->h_addr_list[i], h->h_length); \
+ host->h_addr_list[i] = p; \
+ p += h->h_length; \
+ } \
+ host->h_addr_list[num_addrs] = NULL; \
+ } \
+} G_STMT_END
+
+
+#ifdef ENABLE_IPv6
+/* some helpful utils for IPv6 lookups */
+#define IPv6_BUFLEN_MIN (sizeof (char *) * 3)
+
+static int
+ai_to_herr (int error)
+{
+ switch (error) {
+ case EAI_NONAME:
+ case EAI_FAIL:
+ return HOST_NOT_FOUND;
+ break;
+ case EAI_SERVICE:
+ return NO_DATA;
+ break;
+ case EAI_ADDRFAMILY:
+ return NO_ADDRESS;
+ break;
+ case EAI_NODATA:
+ return NO_DATA;
+ break;
+ case EAI_MEMORY:
+ return ENOMEM;
+ break;
+ case EAI_AGAIN:
+ return TRY_AGAIN;
+ break;
+ case EAI_SYSTEM:
+ return errno;
+ break;
+ default:
+ return NO_RECOVERY;
+ break;
+ }
+}
+
+#endif /* ENABLE_IPv6 */
+
+static int
+camel_gethostbyname_r (const char *name, struct hostent *host,
+ char *buf, size_t buflen, int *herr)
+{
+#ifdef ENABLE_IPv6
+ struct addrinfo hints, *res;
+ int retval, len;
+ char *addr;
+
+ memset (&hints, 0, sizeof (struct addrinfo));
+#ifdef HAVE_AI_ADDRCONFIG
+ hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+#else
+ hints.ai_flags = AI_CANONNAME;
+#endif
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
+ *herr = ai_to_herr (retval);
+ return -1;
+ }
+
+ len = ALIGN (strlen (res->ai_canonname) + 1);
+ if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *))
+ return ERANGE;
+
+ /* h_name */
+ strcpy (buf, res->ai_canonname);
+ host->h_name = buf;
+ buf += len;
+
+ /* h_aliases */
+ ((char **) buf)[0] = NULL;
+ host->h_aliases = (char **) buf;
+ buf += sizeof (char *);
+
+ /* h_addrtype and h_length */
+ host->h_length = res->ai_addrlen;
+ if (res->ai_family == PF_INET6) {
+ host->h_addrtype = AF_INET6;
+
+ addr = (char *) &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
+ } else {
+ host->h_addrtype = AF_INET;
+
+ addr = (char *) &((struct sockaddr_in *) res->ai_addr)->sin_addr;
+ }
+
+ memcpy (buf, addr, host->h_length);
+ addr = buf;
+ buf += ALIGN (host->h_length);
+
+ /* h_addr_list */
+ ((char **) buf)[0] = addr;
+ ((char **) buf)[1] = NULL;
+ host->h_addr_list = (char **) buf;
+
+ freeaddrinfo (res);
+
+ return 0;
+#else /* No support for IPv6 addresses */
+#ifdef HAVE_GETHOSTBYNAME_R
+#ifdef GETHOSTBYNAME_R_FIVE_ARGS
+ if (gethostbyname_r (name, host, buf, buflen, herr))
+ return 0;
+ else
+ return errno;
+#else
+ struct hostent *hp;
+ int retval;
+
+ retval = gethostbyname_r (name, host, buf, buflen, &hp, herr);
+ if (hp != NULL) {
+ *herr = 0;
+ } else if (retval == 0) {
+ /* glibc 2.3.2 workaround - it seems that
+ * gethostbyname_r will sometimes return 0 on fail and
+ * not set the hostent values (hence the crash in bug
+ * #56337). Hopefully we can depend on @hp being NULL
+ * in this error case like we do with
+ * gethostbyaddr_r().
+ */
+ retval = -1;
+ }
+
+ return retval;
+#endif
+#else /* No support for gethostbyname_r */
+ struct hostent *h;
+
+ G_LOCK (gethost_mutex);
+
+ h = gethostbyname (name);
+
+ if (!h) {
+ *herr = h_errno;
+ G_UNLOCK (gethost_mutex);
+ return -1;
+ }
+
+ GETHOST_PROCESS (h, host, buf, buflen, herr);
+
+ G_UNLOCK (gethost_mutex);
+
+ return 0;
+#endif /* HAVE_GETHOSTBYNAME_R */
+#endif /* ENABLE_IPv6 */
+}
+
+static int
+camel_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host,
+ char *buf, size_t buflen, int *herr)
+{
+#ifdef ENABLE_IPv6
+ int retval, len;
+
+ if ((retval = getnameinfo (addr, addrlen, buf, buflen, NULL, 0, NI_NAMEREQD)) != 0) {
+ *herr = ai_to_herr (retval);
+ return -1;
+ }
+
+ len = ALIGN (strlen (buf) + 1);
+ if (buflen < IPv6_BUFLEN_MIN + len + addrlen + sizeof (char *))
+ return ERANGE;
+
+ /* h_name */
+ host->h_name = buf;
+ buf += len;
+
+ /* h_aliases */
+ ((char **) buf)[0] = NULL;
+ host->h_aliases = (char **) buf;
+ buf += sizeof (char *);
+
+ /* h_addrtype and h_length */
+ host->h_length = addrlen;
+ host->h_addrtype = type;
+
+ memcpy (buf, addr, host->h_length);
+ addr = buf;
+ buf += ALIGN (host->h_length);
+
+ /* h_addr_list */
+ ((char **) buf)[0] = addr;
+ ((char **) buf)[1] = NULL;
+ host->h_addr_list = (char **) buf;
+
+ return 0;
+#else /* No support for IPv6 addresses */
+#ifdef HAVE_GETHOSTBYADDR_R
+#ifdef GETHOSTBYADDR_R_SEVEN_ARGS
+ if (gethostbyaddr_r (addr, addrlen, type, host, buf, buflen, herr))
+ return 0;
+ else
+ return errno;
+#else
+ struct hostent *hp;
+ int retval;
+
+ retval = gethostbyaddr_r (addr, addrlen, type, host, buf, buflen, &hp, herr);
+ if (hp != NULL) {
+ *herr = 0;
+ retval = 0;
+ } else if (retval == 0) {
+ /* glibc 2.3.2 workaround - it seems that
+ * gethostbyaddr_r will sometimes return 0 on fail and
+ * fill @host with garbage strings from /etc/hosts
+ * (failure to parse the file? who knows). Luckily, it
+ * seems that we can rely on @hp being NULL on
+ * fail.
+ */
+ retval = -1;
+ }
+
+ return retval;
+#endif
+#else /* No support for gethostbyaddr_r */
+ struct hostent *h;
+
+ G_LOCK (gethost_mutex);
+
+ h = gethostbyaddr (addr, addrlen, type);
+
+ if (!h) {
+ *herr = h_errno;
+ G_UNLOCK (gethost_mutex);
+ return -1;
+ }
+
+ GETHOST_PROCESS (h, host, buf, buflen, herr);
+
+ G_UNLOCK (gethost_mutex);
+
+ return 0;
+#endif /* HAVE_GETHOSTBYADDR_R */
+#endif /* ENABLE_IPv6 */
+}
+#endif /* NEED_ADDRINFO */
+
+/* ********************************************************************** */
+struct _addrinfo_msg {
+ EMsg msg;
+ unsigned int cancelled:1;
+
+ /* for host lookup */
+ const char *name;
+ const char *service;
+ int result;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+
+ /* for host lookup emulation */
+#ifdef NEED_ADDRINFO
+ struct hostent hostbuf;
+ int hostbuflen;
+ char *hostbufmem;
+#endif
+
+ /* for name lookup */
+ const struct sockaddr *addr;
+ socklen_t addrlen;
+ char *host;
+ int hostlen;
+ char *serv;
+ int servlen;
+ int flags;
+};
+
+static void
+cs_freeinfo(struct _addrinfo_msg *msg)
+{
+ g_free(msg->host);
+ g_free(msg->serv);
+#ifdef NEED_ADDRINFO
+ g_free(msg->hostbufmem);
+#endif
+ g_free(msg);
+}
+
+/* returns -1 if cancelled */
+static int
+cs_waitinfo(void *(worker)(void *), struct _addrinfo_msg *msg, const char *error, CamelException *ex)
+{
+ EMsgPort *reply_port;
+ pthread_t id;
+ int err, cancel_fd, cancel = 0, fd;
+
+ cancel_fd = camel_operation_cancel_fd(NULL);
+ if (cancel_fd == -1) {
+ worker(msg);
+ return 0;
+ }
+
+ reply_port = msg->msg.reply_port = e_msgport_new();
+ fd = e_msgport_fd(msg->msg.reply_port);
+ if ((err = pthread_create(&id, NULL, worker, msg)) == 0) {
+ struct pollfd polls[2];
+ int status;
+
+ polls[0].fd = fd;
+ polls[0].events = POLLIN;
+ polls[1].fd = cancel_fd;
+ polls[1].events = POLLIN;
+
+ d(printf("waiting for name return/cancellation in main process\n"));
+ do {
+ polls[0].revents = 0;
+ polls[1].revents = 0;
+ status = poll(polls, 2, -1);
+ } while (status == -1 && errno == EINTR);
+
+ if (status == -1 || (polls[1].revents & POLLIN)) {
+ if (status == -1)
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s", error, g_strerror(errno));
+ else
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+
+ /* We cancel so if the thread impl is decent it causes immediate exit.
+ We detach so we dont need to wait for it to exit if it isn't.
+ We check the reply port incase we had a reply in the mean time, which we free later */
+ d(printf("Cancelling lookup thread and leaving it\n"));
+ msg->cancelled = 1;
+ pthread_detach(id);
+ pthread_cancel(id);
+ cancel = 1;
+ } else {
+ struct _addrinfo_msg *reply = (struct _addrinfo_msg *)e_msgport_get(reply_port);
+
+ g_assert(reply == msg);
+ d(printf("waiting for child to exit\n"));
+ pthread_join(id, NULL);
+ d(printf("child done\n"));
+ }
+ } else {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), g_strerror(err));
+ }
+ e_msgport_destroy(reply_port);
+
+ return cancel;
+}
+
+#ifdef NEED_ADDRINFO
+static void *
+cs_getaddrinfo(void *data)
+{
+ struct _addrinfo_msg *msg = data;
+ int herr;
+ struct hostent h;
+ struct addrinfo *res, *last = NULL;
+ struct sockaddr_in *sin;
+ in_port_t port = 0;
+ int i;
+
+ /* This is a pretty simplistic emulation of getaddrinfo */
+
+ while ((msg->result = camel_gethostbyname_r(msg->name, &h, msg->hostbufmem, msg->hostbuflen, &herr)) == ERANGE) {
+ pthread_testcancel();
+ msg->hostbuflen *= 2;
+ msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
+ }
+
+ /* If we got cancelled, dont reply, just free it */
+ if (msg->cancelled)
+ goto cancel;
+
+ /* FIXME: map error numbers across */
+ if (msg->result != 0)
+ goto reply;
+
+ /* check hints matched */
+ if (msg->hints && msg->hints->ai_family && msg->hints->ai_family != h.h_addrtype) {
+ msg->result = EAI_FAMILY;
+ goto reply;
+ }
+
+ /* we only support ipv4 for this interface, even if it could supply ipv6 */
+ if (h.h_addrtype != AF_INET) {
+ msg->result = EAI_FAMILY;
+ goto reply;
+ }
+
+ /* check service mapping */
+ if (msg->service) {
+ const char *p = msg->service;
+
+ while (*p) {
+ if (*p < '0' || *p > '9')
+ break;
+ p++;
+ }
+
+ if (*p) {
+ const char *socktype = NULL;
+ struct servent *serv;
+
+ if (msg->hints && msg->hints->ai_socktype) {
+ if (msg->hints->ai_socktype == SOCK_STREAM)
+ socktype = "tcp";
+ else if (msg->hints->ai_socktype == SOCK_DGRAM)
+ socktype = "udp";
+ }
+
+ serv = getservbyname(msg->service, socktype);
+ if (serv == NULL) {
+ msg->result = EAI_NONAME;
+ goto reply;
+ }
+ port = serv->s_port;
+ } else {
+ port = htons(strtoul(msg->service, NULL, 10));
+ }
+ }
+
+ for (i=0;h.h_addr_list[i];i++) {
+ res = g_malloc0(sizeof(*res));
+ if (msg->hints) {
+ res->ai_flags = msg->hints->ai_flags;
+ if (msg->hints->ai_flags & AI_CANONNAME)
+ res->ai_canonname = g_strdup(h.h_name);
+ res->ai_socktype = msg->hints->ai_socktype;
+ res->ai_protocol = msg->hints->ai_protocol;
+ } else {
+ res->ai_flags = 0;
+ res->ai_socktype = SOCK_STREAM; /* fudge */
+ res->ai_protocol = 0; /* fudge */
+ }
+ res->ai_family = AF_INET;
+ res->ai_addrlen = sizeof(*sin);
+ res->ai_addr = g_malloc(sizeof(*sin));
+ sin = (struct sockaddr_in *)res->ai_addr;
+ sin->sin_family = AF_INET;
+ sin->sin_port = port;
+ memcpy(&sin->sin_addr, h.h_addr_list[i], sizeof(sin->sin_addr));
+
+ if (last == NULL) {
+ *msg->res = last = res;
+ } else {
+ last->ai_next = res;
+ last = res;
+ }
+ }
+reply:
+ e_msgport_reply((EMsg *)msg);
+ return NULL;
+cancel:
+ cs_freeinfo(msg);
+ return NULL;
+}
+#else
+static void *
+cs_getaddrinfo(void *data)
+{
+ struct _addrinfo_msg *info = data;
+
+ info->result = getaddrinfo(info->name, info->service, info->hints, info->res);
+
+ if (info->cancelled) {
+ g_free(info);
+ } else {
+ e_msgport_reply((EMsg *)info);
+ }
+
+ return NULL;
+}
+#endif /* NEED_ADDRINFO */
+
+struct addrinfo *
+camel_getaddrinfo(const char *name, const char *service, const struct addrinfo *hints, CamelException *ex)
+{
+ struct _addrinfo_msg *msg;
+ struct addrinfo *res = NULL;
+#ifndef ENABLE_IPv6
+ struct addrinfo myhints;
+#endif
+ g_return_val_if_fail(name != NULL, NULL);
+
+ if (camel_operation_cancel_check(NULL)) {
+ camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+ return NULL;
+ }
+
+ camel_operation_start_transient(NULL, _("Resolving: %s"), name);
+
+ /* force ipv4 addresses only */
+#ifndef ENABLE_IPv6
+ if (hints == NULL)
+ memset(&myhints, 0, sizeof(myhints));
+ else
+ memcpy (&myhints, hints, sizeof (myhints));
+
+ myhints.ai_family = AF_INET;
+ hints = &myhints;
+#endif
+
+ msg = g_malloc0(sizeof(*msg));
+ msg->name = name;
+ msg->service = service;
+ msg->hints = hints;
+ msg->res = &res;
+#ifdef NEED_ADDRINFO
+ msg->hostbuflen = 1024;
+ msg->hostbufmem = g_malloc(msg->hostbuflen);
+#endif
+ if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0) {
+ if (msg->result != 0)
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
+ name, gai_strerror (msg->result));
+
+ cs_freeinfo(msg);
+ } else
+ res = NULL;
+
+ camel_operation_end(NULL);
+
+ return res;
+}
+
+void
+camel_freeaddrinfo(struct addrinfo *host)
+{
+#ifdef NEED_ADDRINFO
+ while (host) {
+ struct addrinfo *next = host->ai_next;
+
+ g_free(host->ai_canonname);
+ g_free(host->ai_addr);
+ g_free(host);
+ host = next;
+ }
+#else
+ freeaddrinfo(host);
+#endif
+}
+
+#ifdef NEED_ADDRINFO
+static void *
+cs_getnameinfo(void *data)
+{
+ struct _addrinfo_msg *msg = data;
+ int herr;
+ struct hostent h;
+ struct sockaddr_in *sin = (struct sockaddr_in *)msg->addr;
+
+ /* FIXME: error code */
+ if (msg->addr->sa_family != AF_INET) {
+ msg->result = -1;
+ return NULL;
+ }
+
+ /* FIXME: honour getnameinfo flags: do we care, not really */
+
+ while ((msg->result = camel_gethostbyaddr_r((const char *)&sin->sin_addr, sizeof(sin->sin_addr), AF_INET, &h,
+ msg->hostbufmem, msg->hostbuflen, &herr)) == ERANGE) {
+ pthread_testcancel ();
+ msg->hostbuflen *= 2;
+ msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
+ }
+
+ if (msg->cancelled)
+ goto cancel;
+
+ if (msg->host) {
+ g_free(msg->host);
+ if (msg->result == 0 && h.h_name && h.h_name[0]) {
+ msg->host = g_strdup(h.h_name);
+ } else {
+ unsigned char *in = (unsigned char *)&sin->sin_addr;
+
+ /* sin_addr is always network order which is big-endian */
+ msg->host = g_strdup_printf("%u.%u.%u.%u", in[0], in[1], in[2], in[3]);
+ }
+ }
+
+ /* we never actually use this anyway */
+ if (msg->serv)
+ sprintf(msg->serv, "%d", sin->sin_port);
+
+ e_msgport_reply((EMsg *)msg);
+ return NULL;
+cancel:
+ cs_freeinfo(msg);
+ return NULL;
+}
+#else
+static void *
+cs_getnameinfo(void *data)
+{
+ struct _addrinfo_msg *msg = data;
+
+ /* there doens't appear to be a return code which says host or serv buffers are too short, lengthen them */
+ msg->result = getnameinfo(msg->addr, msg->addrlen, msg->host, msg->hostlen, msg->serv, msg->servlen, msg->flags);
+
+ if (msg->cancelled)
+ cs_freeinfo(msg);
+ else
+ e_msgport_reply((EMsg *)msg);
+
+ return NULL;
+}
+#endif
+
+int
+camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv, int flags, CamelException *ex)
+{
+ struct _addrinfo_msg *msg;
+ int result;
+
+ if (camel_operation_cancel_check(NULL)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+ return -1;
+ }
+
+ camel_operation_start_transient(NULL, _("Resolving address"));
+
+ msg = g_malloc0(sizeof(*msg));
+ msg->addr = sa;
+ msg->addrlen = salen;
+ if (host) {
+ msg->hostlen = NI_MAXHOST;
+ msg->host = g_malloc(msg->hostlen);
+ msg->host[0] = 0;
+ }
+ if (serv) {
+ msg->servlen = NI_MAXSERV;
+ msg->serv = g_malloc(msg->servlen);
+ msg->serv[0] = 0;
+ }
+ msg->flags = flags;
+#ifdef NEED_ADDRINFO
+ msg->hostbuflen = 1024;
+ msg->hostbufmem = g_malloc(msg->hostbuflen);
+#endif
+ cs_waitinfo(cs_getnameinfo, msg, _("Name lookup failed"), ex);
+
+ if ((result = msg->result) != 0)
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Name lookup failed: %s"),
+ gai_strerror (result));
+
+ if (host)
+ *host = g_strdup(msg->host);
+ if (serv)
+ *serv = g_strdup(msg->serv);
+
+ g_free(msg->host);
+ g_free(msg->serv);
+ g_free(msg);
+
+ camel_operation_end(NULL);
+
+ return result;
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Michael Zucchi <notzed@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef CAMEL_NET_UTILS_H
+#define CAMEL_NET_UTILS_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#include <netdb.h>
+
+struct _CamelException;
+
+#ifdef NEED_ADDRINFO
+/* Some of this is copied from GNU's netdb.h
+
+ Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+*/
+struct addrinfo {
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t ai_addrlen;
+ struct sockaddr *ai_addr;
+ char *ai_canonname;
+ struct addrinfo *ai_next;
+};
+
+#define AI_CANONNAME 0x0002 /* Request for canonical name. */
+#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
+
+/* Error values for `getaddrinfo' function. */
+#define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
+#define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
+#define EAI_AGAIN -3 /* Temporary failure in name resolution. */
+#define EAI_FAIL -4 /* Non-recoverable failure in name res. */
+#define EAI_NODATA -5 /* No address associated with NAME. */
+#define EAI_FAMILY -6 /* `ai_family' not supported. */
+#define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
+#define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
+#define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+#define EAI_MEMORY -10 /* Memory allocation failure. */
+#define EAI_SYSTEM -11 /* System error returned in `errno'. */
+#define EAI_OVERFLOW -12 /* Argument buffer overflow. */
+
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+
+#define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
+#define NI_NUMERICSERV 2 /* Don't convert port number to name. */
+#define NI_NOFQDN 4 /* Only return nodename portion. */
+#define NI_NAMEREQD 8 /* Don't return numeric addresses. */
+#define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
+#endif
+
+struct addrinfo *camel_getaddrinfo(const char *name, const char *service,
+ const struct addrinfo *hints, struct _CamelException *ex);
+void camel_freeaddrinfo(struct addrinfo *host);
+int camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv,
+ int flags, struct _CamelException *ex);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CAMEL_NET_UTILS_H */
#include "camel-object.h"
#include "camel-file-utils.h"
-#include <e-util/e-memory.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-memory.h>
+#include <libedataserver/e-msgport.h>
#define d(x)
#define b(x) /* object bag */
#endif
#include "camel-operation.h"
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#define d(x)
#include <fcntl.h>
#include <errno.h>
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#include "camel-block-file.h"
#include "camel-partition-table.h"
#include <camel/camel-object.h>
#include <glib.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include "camel-block-file.h"
#endif
#include <pthread.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
struct _CamelFolderPrivate {
EMutex *lock;
#include "camel-exception.h"
#include "camel-string-utils.h"
#include "camel-vee-store.h"
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#include "camel-i18n.h"
/* table of CamelProviderModule's */
/* ... */
};
+static pthread_once_t setup_once = PTHREAD_ONCE_INIT;
+
+static void
+provider_setup(void)
+{
+ provider_lock = e_mutex_new(E_MUTEX_REC);
+ module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+ provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+
+ vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
+ vee_provider.url_hash = camel_url_hash;
+ vee_provider.url_equal = camel_url_equal;
+ camel_provider_register(&vee_provider);
+}
+
/**
* camel_provider_init:
*
* A .urls file has the same initial prefix as the shared library it
* correspond to, and consists of a series of lines containing the URL
* protocols that that library handles.
+ *
+ * TODO: This should be pathed?
+ * TODO: This should be plugin-d?
**/
void
camel_provider_init (void)
struct dirent *d;
char *p, *name, buf[80];
CamelProviderModule *m;
- static int init = 0;
+ static int loaded = 0;
- if (init)
- return;
+ pthread_once(&setup_once, provider_setup);
- init = 1;
-
- provider_lock = e_mutex_new(E_MUTEX_REC);
- module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
- provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+ if (loaded)
+ return;
- vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
- vee_provider.url_hash = camel_url_hash;
- vee_provider.url_equal = camel_url_equal;
- camel_provider_register(&vee_provider);
+ loaded = 1;
dir = opendir (CAMEL_PROVIDERDIR);
if (!dir) {
- g_error ("Could not open camel provider directory (%s): %s",
- CAMEL_PROVIDERDIR, g_strerror (errno));
+ g_warning("Could not open camel provider directory (%s): %s",
+ CAMEL_PROVIDERDIR, g_strerror (errno));
return;
}
GModule *module;
CamelProvider *(*camel_provider_module_init) (void);
+ pthread_once(&setup_once, provider_setup);
+
if (!g_module_supported ()) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not load %s: Module loading "
g_return_if_fail (provider != NULL);
+ g_assert(provider_table);
+
LOCK();
if (g_hash_table_lookup(provider_table, provider->protocol) != NULL) {
{
GList *list = NULL;
+ g_assert(provider_table);
+
LOCK();
if (load) {
size_t len;
g_return_val_if_fail(url_string != NULL, NULL);
+ g_assert(provider_table);
len = strcspn(url_string, ":");
protocol = g_alloca(len+1);
GHashTable **auto_detected, CamelException *ex)
{
g_return_val_if_fail (provider != NULL, -1);
-
+
if (provider->auto_detect) {
return provider->auto_detect (url, auto_detected, ex);
} else {
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+camel_providerdir=@camel_providerdir@
+privlibdir=@privlibdir@
+privincludedir=@privincludedir@
+
+Name: camel-provider
+Description: The Evolution mail access library
+Version: @VERSION@
+Libs: -L${libdir} -lcamel-1.2 -lcamel-provider-1.2 -ledataserver-1.2
+Cflags: -I${privincludedir}
#include "camel-sasl-cram-md5.h"
#include "camel-mime-utils.h"
#include "camel-service.h"
-#include <e-util/md5-utils.h>
+#include <libedataserver/md5-utils.h>
#include "camel-i18n.h"
CamelServiceAuthType camel_sasl_cram_md5_authtype = {
*
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ctype.h>
#include <unistd.h>
-#include <e-util/md5-utils.h>
+#include <libedataserver/md5-utils.h>
-#include <gal/util/e-iconv.h>
+#include <libedataserver/e-iconv.h>
#include "camel-charset-map.h"
#include "camel-mime-utils.h"
#include "camel-sasl-digest-md5.h"
#include "camel-i18n.h"
+#include "camel-net-utils.h"
#define d(x)
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include "camel-stream-mem.h"
-#include "e-util/e-sexp.h"
+#include "libedataserver/e-sexp.h"
#include "camel-search-private.h"
#include "camel-i18n.h"
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
-#include <netdb.h>
#include <errno.h>
#include <sys/poll.h>
-#include "e-util/e-msgport.h"
-#include "e-util/e-host-utils.h"
+#include "libedataserver/e-msgport.h"
#include "camel-service.h"
#include "camel-session.h"
return ret;
}
-
-/* ********************************************************************** */
-struct _addrinfo_msg {
- EMsg msg;
- unsigned int cancelled:1;
-
- /* for host lookup */
- const char *name;
- const char *service;
- int result;
- const struct addrinfo *hints;
- struct addrinfo **res;
-
- /* for host lookup emulation */
-#ifdef NEED_ADDRINFO
- struct hostent hostbuf;
- int hostbuflen;
- char *hostbufmem;
-#endif
-
- /* for name lookup */
- const struct sockaddr *addr;
- socklen_t addrlen;
- char *host;
- int hostlen;
- char *serv;
- int servlen;
- int flags;
-};
-
-static void
-cs_freeinfo(struct _addrinfo_msg *msg)
-{
- g_free(msg->host);
- g_free(msg->serv);
-#ifdef NEED_ADDRINFO
- g_free(msg->hostbufmem);
-#endif
- g_free(msg);
-}
-
-/* returns -1 if cancelled */
-static int
-cs_waitinfo(void *(worker)(void *), struct _addrinfo_msg *msg, const char *error, CamelException *ex)
-{
- EMsgPort *reply_port;
- pthread_t id;
- int err, cancel_fd, cancel = 0, fd;
-
- cancel_fd = camel_operation_cancel_fd(NULL);
- if (cancel_fd == -1) {
- worker(msg);
- return 0;
- }
-
- reply_port = msg->msg.reply_port = e_msgport_new();
- fd = e_msgport_fd(msg->msg.reply_port);
- if ((err = pthread_create(&id, NULL, worker, msg)) == 0) {
- struct pollfd polls[2];
- int status;
-
- polls[0].fd = fd;
- polls[0].events = POLLIN;
- polls[1].fd = cancel_fd;
- polls[1].events = POLLIN;
-
- d(printf("waiting for name return/cancellation in main process\n"));
- do {
- polls[0].revents = 0;
- polls[1].revents = 0;
- status = poll(polls, 2, -1);
- } while (status == -1 && errno == EINTR);
-
- if (status == -1 || (polls[1].revents & POLLIN)) {
- if (status == -1)
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s", error, g_strerror(errno));
- else
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
-
- /* We cancel so if the thread impl is decent it causes immediate exit.
- We detach so we dont need to wait for it to exit if it isn't.
- We check the reply port incase we had a reply in the mean time, which we free later */
- d(printf("Cancelling lookup thread and leaving it\n"));
- msg->cancelled = 1;
- pthread_detach(id);
- pthread_cancel(id);
- cancel = 1;
- } else {
- struct _addrinfo_msg *reply = (struct _addrinfo_msg *)e_msgport_get(reply_port);
-
- g_assert(reply == msg);
- d(printf("waiting for child to exit\n"));
- pthread_join(id, NULL);
- d(printf("child done\n"));
- }
- } else {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), g_strerror(err));
- }
- e_msgport_destroy(reply_port);
-
- return cancel;
-}
-
-#ifdef NEED_ADDRINFO
-static void *
-cs_getaddrinfo(void *data)
-{
- struct _addrinfo_msg *msg = data;
- int herr;
- struct hostent h;
- struct addrinfo *res, *last = NULL;
- struct sockaddr_in *sin;
- in_port_t port = 0;
- int i;
-
- /* This is a pretty simplistic emulation of getaddrinfo */
-
- while ((msg->result = e_gethostbyname_r(msg->name, &h, msg->hostbufmem, msg->hostbuflen, &herr)) == ERANGE) {
- pthread_testcancel();
- msg->hostbuflen *= 2;
- msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
- }
-
- /* If we got cancelled, dont reply, just free it */
- if (msg->cancelled)
- goto cancel;
-
- /* FIXME: map error numbers across */
- if (msg->result != 0)
- goto reply;
-
- /* check hints matched */
- if (msg->hints && msg->hints->ai_family && msg->hints->ai_family != h.h_addrtype) {
- msg->result = EAI_FAMILY;
- goto reply;
- }
-
- /* we only support ipv4 for this interface, even if it could supply ipv6 */
- if (h.h_addrtype != AF_INET) {
- msg->result = EAI_FAMILY;
- goto reply;
- }
-
- /* check service mapping */
- if (msg->service) {
- const char *p = msg->service;
-
- while (*p) {
- if (*p < '0' || *p > '9')
- break;
- p++;
- }
-
- if (*p) {
- const char *socktype = NULL;
- struct servent *serv;
-
- if (msg->hints && msg->hints->ai_socktype) {
- if (msg->hints->ai_socktype == SOCK_STREAM)
- socktype = "tcp";
- else if (msg->hints->ai_socktype == SOCK_DGRAM)
- socktype = "udp";
- }
-
- serv = getservbyname(msg->service, socktype);
- if (serv == NULL) {
- msg->result = EAI_NONAME;
- goto reply;
- }
- port = serv->s_port;
- } else {
- port = htons(strtoul(msg->service, NULL, 10));
- }
- }
-
- for (i=0;h.h_addr_list[i];i++) {
- res = g_malloc0(sizeof(*res));
- if (msg->hints) {
- res->ai_flags = msg->hints->ai_flags;
- if (msg->hints->ai_flags & AI_CANONNAME)
- res->ai_canonname = g_strdup(h.h_name);
- res->ai_socktype = msg->hints->ai_socktype;
- res->ai_protocol = msg->hints->ai_protocol;
- } else {
- res->ai_flags = 0;
- res->ai_socktype = SOCK_STREAM; /* fudge */
- res->ai_protocol = 0; /* fudge */
- }
- res->ai_family = AF_INET;
- res->ai_addrlen = sizeof(*sin);
- res->ai_addr = g_malloc(sizeof(*sin));
- sin = (struct sockaddr_in *)res->ai_addr;
- sin->sin_family = AF_INET;
- sin->sin_port = port;
- memcpy(&sin->sin_addr, h.h_addr_list[i], sizeof(sin->sin_addr));
-
- if (last == NULL) {
- *msg->res = last = res;
- } else {
- last->ai_next = res;
- last = res;
- }
- }
-reply:
- e_msgport_reply((EMsg *)msg);
- return NULL;
-cancel:
- cs_freeinfo(msg);
- return NULL;
-}
-#else
-static void *
-cs_getaddrinfo(void *data)
-{
- struct _addrinfo_msg *info = data;
-
- info->result = getaddrinfo(info->name, info->service, info->hints, info->res);
-
- if (info->cancelled) {
- g_free(info);
- } else {
- e_msgport_reply((EMsg *)info);
- }
-
- return NULL;
-}
-#endif /* NEED_ADDRINFO */
-
-struct addrinfo *
-camel_getaddrinfo(const char *name, const char *service, const struct addrinfo *hints, CamelException *ex)
-{
- struct _addrinfo_msg *msg;
- struct addrinfo *res = NULL;
-#ifndef ENABLE_IPv6
- struct addrinfo myhints;
-#endif
- g_return_val_if_fail(name != NULL, NULL);
-
- if (camel_operation_cancel_check(NULL)) {
- camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
- return NULL;
- }
-
- camel_operation_start_transient(NULL, _("Resolving: %s"), name);
-
- /* force ipv4 addresses only */
-#ifndef ENABLE_IPv6
- if (hints == NULL)
- memset(&myhints, 0, sizeof(myhints));
- else
- memcpy (&myhints, hints, sizeof (myhints));
-
- myhints.ai_family = AF_INET;
- hints = &myhints;
-#endif
-
- msg = g_malloc0(sizeof(*msg));
- msg->name = name;
- msg->service = service;
- msg->hints = hints;
- msg->res = &res;
-#ifdef NEED_ADDRINFO
- msg->hostbuflen = 1024;
- msg->hostbufmem = g_malloc(msg->hostbuflen);
-#endif
- if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0) {
- if (msg->result != 0)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
- name, gai_strerror (msg->result));
-
- cs_freeinfo(msg);
- } else
- res = NULL;
-
- camel_operation_end(NULL);
-
- return res;
-}
-
-void
-camel_freeaddrinfo(struct addrinfo *host)
-{
-#ifdef NEED_ADDRINFO
- while (host) {
- struct addrinfo *next = host->ai_next;
-
- g_free(host->ai_canonname);
- g_free(host->ai_addr);
- g_free(host);
- host = next;
- }
-#else
- freeaddrinfo(host);
-#endif
-}
-
-#ifdef NEED_ADDRINFO
-static void *
-cs_getnameinfo(void *data)
-{
- struct _addrinfo_msg *msg = data;
- int herr;
- struct hostent h;
- struct sockaddr_in *sin = (struct sockaddr_in *)msg->addr;
-
- /* FIXME: error code */
- if (msg->addr->sa_family != AF_INET) {
- msg->result = -1;
- return NULL;
- }
-
- /* FIXME: honour getnameinfo flags: do we care, not really */
-
- while ((msg->result = e_gethostbyaddr_r((const char *)&sin->sin_addr, sizeof(sin->sin_addr), AF_INET, &h,
- msg->hostbufmem, msg->hostbuflen, &herr)) == ERANGE) {
- pthread_testcancel ();
- msg->hostbuflen *= 2;
- msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
- }
-
- if (msg->cancelled)
- goto cancel;
-
- if (msg->host) {
- g_free(msg->host);
- if (msg->result == 0 && h.h_name && h.h_name[0]) {
- msg->host = g_strdup(h.h_name);
- } else {
- unsigned char *in = (unsigned char *)&sin->sin_addr;
-
- /* sin_addr is always network order which is big-endian */
- msg->host = g_strdup_printf("%u.%u.%u.%u", in[0], in[1], in[2], in[3]);
- }
- }
-
- /* we never actually use this anyway */
- if (msg->serv)
- sprintf(msg->serv, "%d", sin->sin_port);
-
- e_msgport_reply((EMsg *)msg);
- return NULL;
-cancel:
- cs_freeinfo(msg);
- return NULL;
-}
-#else
-static void *
-cs_getnameinfo(void *data)
-{
- struct _addrinfo_msg *msg = data;
-
- /* there doens't appear to be a return code which says host or serv buffers are too short, lengthen them */
- msg->result = getnameinfo(msg->addr, msg->addrlen, msg->host, msg->hostlen, msg->serv, msg->servlen, msg->flags);
-
- if (msg->cancelled)
- cs_freeinfo(msg);
- else
- e_msgport_reply((EMsg *)msg);
-
- return NULL;
-}
-#endif
-
-int
-camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv, int flags, CamelException *ex)
-{
- struct _addrinfo_msg *msg;
- int result;
-
- if (camel_operation_cancel_check(NULL)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
- return -1;
- }
-
- camel_operation_start_transient(NULL, _("Resolving address"));
-
- msg = g_malloc0(sizeof(*msg));
- msg->addr = sa;
- msg->addrlen = salen;
- if (host) {
- msg->hostlen = NI_MAXHOST;
- msg->host = g_malloc(msg->hostlen);
- msg->host[0] = 0;
- }
- if (serv) {
- msg->servlen = NI_MAXSERV;
- msg->serv = g_malloc(msg->servlen);
- msg->serv[0] = 0;
- }
- msg->flags = flags;
-#ifdef NEED_ADDRINFO
- msg->hostbuflen = 1024;
- msg->hostbufmem = g_malloc(msg->hostbuflen);
-#endif
- cs_waitinfo(cs_getnameinfo, msg, _("Name lookup failed"), ex);
-
- if ((result = msg->result) != 0)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Name lookup failed: %s"),
- gai_strerror (result));
-
- if (host)
- *host = g_strdup(msg->host);
- if (serv)
- *serv = g_strdup(msg->serv);
-
- g_free(msg->host);
- g_free(msg->serv);
- g_free(msg);
-
- camel_operation_end(NULL);
-
- return result;
-}
-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-service.h : Abstract class for an email service */
-
/*
*
- * Author :
- * Bertrand Guiheneuf <bertrand@helixcode.com>
+ * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
+ * Michael Zucchi <notzed@ximian.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
* USA
*/
-
#ifndef CAMEL_SERVICE_H
#define CAMEL_SERVICE_H 1
#pragma }
#endif /* __cplusplus }*/
-#include <netdb.h>
#include <camel/camel-object.h>
#include <camel/camel-url.h>
#include <camel/camel-provider.h>
CamelURL *url;
};
-
typedef struct {
CamelObjectClass parent_class;
} CamelServiceClass;
-
/* query_auth_types returns a GList of these */
typedef struct {
char *name; /* user-friendly name */
gboolean need_password; /* needs a password to authenticate */
} CamelServiceAuthType;
-
/* public methods */
void camel_service_construct (CamelService *service,
CamelSession *session,
GList * camel_service_query_auth_types (CamelService *service,
CamelException *ex);
-#ifdef NEED_ADDRINFO
-/* Some of this is copied from GNU's netdb.h
-
- Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-*/
-struct addrinfo {
- int ai_flags;
- int ai_family;
- int ai_socktype;
- int ai_protocol;
- size_t ai_addrlen;
- struct sockaddr *ai_addr;
- char *ai_canonname;
- struct addrinfo *ai_next;
-};
-
-#define AI_CANONNAME 0x0002 /* Request for canonical name. */
-#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
-
-/* Error values for `getaddrinfo' function. */
-#define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
-#define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
-#define EAI_AGAIN -3 /* Temporary failure in name resolution. */
-#define EAI_FAIL -4 /* Non-recoverable failure in name res. */
-#define EAI_NODATA -5 /* No address associated with NAME. */
-#define EAI_FAMILY -6 /* `ai_family' not supported. */
-#define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
-#define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
-#define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
-#define EAI_MEMORY -10 /* Memory allocation failure. */
-#define EAI_SYSTEM -11 /* System error returned in `errno'. */
-#define EAI_OVERFLOW -12 /* Argument buffer overflow. */
-
-#define NI_MAXHOST 1025
-#define NI_MAXSERV 32
-
-#define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
-#define NI_NUMERICSERV 2 /* Don't convert port number to name. */
-#define NI_NOFQDN 4 /* Only return nodename portion. */
-#define NI_NAMEREQD 8 /* Don't return numeric addresses. */
-#define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
-#endif
-
-/* new hostname interfaces */
-struct addrinfo *camel_getaddrinfo(const char *name, const char *service,
- const struct addrinfo *hints, CamelException *ex);
-void camel_freeaddrinfo(struct addrinfo *host);
-int camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv,
- int flags, CamelException *ex);
-
/* Standard Camel function */
CamelType camel_service_get_type (void);
#include <camel/camel-provider.h>
#include <camel/camel-junk-plugin.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#define CAMEL_SESSION_TYPE (camel_session_get_type ())
#define CAMEL_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession))
#include "camel-file-utils.h"
-#include "e-util/md5-utils.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/md5-utils.h"
+#include "libedataserver/e-memory.h"
#include "camel-private.h"
#include "camel-url.h"
#include "camel-file-utils.h"
#include "camel-operation.h"
#include "camel-stream-fs.h"
-#include "camel-session.h"
static CamelSeekableStreamClass *parent_class = NULL;
/* this is commented because otherwise we get an error about the
redefinition of MD5Context...yay */
-/*#include <e-util/md5-utils.h>*/
+/*#include <libedataserver/md5-utils.h>*/
#include "camel-tcp-stream-ssl.h"
#include "camel-stream-fs.h"
#include <fcntl.h>
#include <ctype.h>
-#include "e-util/e-msgport.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-msgport.h"
+#include "libedataserver/e-memory.h"
#include "camel/camel-object.h"
#include <string.h>
#include <ctype.h>
-#include "e-util/e-trie.h"
+#include "libedataserver/e-trie.h"
#include "camel-utf8.h"
#include "camel-url-scanner.h"
#include "camel-debug.h"
#include "camel-i18n.h"
-#include "e-util/md5-utils.h"
+#include "libedataserver/md5-utils.h"
#if defined (DOEPOOLV) || defined (DOESTRV)
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#endif
#define d(x)
camel_mime_utils_init();
camel_operation_init();
- camel_provider_init();
#ifdef HAVE_NSS
if (nss_init) {
#pragma }
#endif /* __cplusplus */
-#include <camel/camel-cipher-context.h>
#include <camel/camel-data-wrapper.h>
#include <camel/camel-exception.h>
-#include <camel/camel-folder.h>
-#include <camel/camel-digest-folder.h>
-#include <camel/camel-digest-store.h>
-#include <camel/camel-disco-diary.h>
-#include <camel/camel-disco-folder.h>
-#include <camel/camel-disco-store.h>
-#include <camel/camel-vee-folder.h>
#include <camel/camel-medium.h>
#include <camel/camel-mime-filter.h>
#include <camel/camel-mime-filter-basic.h>
#include <camel/camel-mime-part-utils.h>
#include <camel/camel-mime-part.h>
#include <camel/camel-mime-utils.h>
-#include <camel/camel-movemail.h>
#include <camel/camel-multipart.h>
#include <camel/camel-multipart-encrypted.h>
#include <camel/camel-multipart-signed.h>
-#include <camel/camel-gpg-context.h>
-#include <camel/camel-provider.h>
#include <camel/camel-seekable-stream.h>
#include <camel/camel-seekable-substream.h>
-#include <camel/camel-service.h>
-#include <camel/camel-session.h>
-#include <camel/camel-store.h>
#include <camel/camel-stream-buffer.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-stream-fs.h>
#include <camel/camel-stream-mem.h>
#include <camel/camel-stream.h>
-#include <camel/camel-tcp-stream-raw.h>
-#include <camel/camel-tcp-stream-ssl.h>
-#include <camel/camel-tcp-stream.h>
#include <camel/camel-transport.h>
-#include <camel/camel-uid-cache.h>
#include <camel/camel-url.h>
#include <camel/camel-string-utils.h>
+#include <glib.h>
+
int camel_init (const char *certdb_dir, gboolean nss_init);
#ifdef __cplusplus
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+privlibdir=@privlibdir@
+privincludedir=@privincludedir@
+
+Name: camel
+Description: the Evolution MIME message handling library
+Version: @VERSION@
+Libs: -L${libdir} -lcamel-1.2 -ledataserver-1.2
+Cflags: -I${privincludedir}
IMAP4_DIR=imap4
endif
-SUBDIRS = pop3 sendmail smtp imap $(NNTP_DIR) local $(IMAPP_DIR) $(IMAP4_DIR) groupwise
+SUBDIRS = pop3 sendmail smtp imap $(NNTP_DIR) local $(IMAPP_DIR) $(IMAP4_DIR)
+# groupwise
camel_provider_LTLIBRARIES = libcamelgroupwise.la
camel_provider_DATA = libcamelgroupwise.urls
-INCLUDES = -I.. \
- -I$(srcdir)/.. \
+INCLUDES = \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
+ -I$(top_srcdir)/servers/groupwise \
-I$(top_srcdir) \
-I$(top_srcdir)/camel/providers/imap \
-I$(top_srcdir)/camel/providers/smtp \
- $(EVOLUTION_CALENDAR_CFLAGS) \
$(CAMEL_GROUPWISE_CFLAGS) \
- $(GNOME_INCLUDEDIR) \
- $(E_UTIL_CFLAGS) \
- $(GTK_INCLUDEDIR) \
-DCAMEL_PROVIDERDIR=\"$(camel_providerdir)\" \
-DG_LOG_DOMAIN=\"camel-groupwise-provider\"
#define CAMEL_GW_LISTENER_H
-#include <e-util/e-account-list.h>
+#include <libedataserver/e-account-list.h>
#include<libedataserver/e-source.h>
#include<libedataserver/e-source-list.h>
#include "camel-url.h"
## Process this file with automake to produce Makefile.in
-libcamelimapincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelimap.la
camel_provider_DATA = libcamelimap.urls
camel-imap-utils.c \
camel-imap-wrapper.c
-libcamelimapinclude_HEADERS = \
+noinst_HEADERS = \
camel-imap-command.h \
camel-imap-folder.h \
camel-imap-message-cache.h \
camel-imap-summary.h \
camel-imap-types.h \
camel-imap-utils.h \
- camel-imap-wrapper.h
+ camel-imap-wrapper.h \
+ camel-imap-private.h
libcamelimap_la_LDFLAGS = -avoid-version -module
-noinst_HEADERS = \
- camel-imap-private.h
-
EXTRA_DIST = libcamelimap.urls
#include <fcntl.h>
#include <ctype.h>
-#include "e-util/e-path.h"
-#include "e-util/e-time-utils.h"
+/*#include "libedataserver/e-path.h"*/
+#include "libedataserver/e-time-utils.h"
#include "camel-imap-folder.h"
#include "camel-imap-command.h"
char *folders;
folders = g_strconcat (imap_store->storage_path, "/folders", NULL);
- folder_dir = e_path_to_physical (folders, new);
+ folder_dir = imap_path_to_physical (folders, new);
g_free (folders);
summary_path = g_strdup_printf("%s/summary", folder_dir);
#endif
#ifdef ENABLE_THREADS
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#endif
struct _CamelImapFolderPrivate {
#include "camel-imap-utils.h"
#include "camel-imap-summary.h"
-#include "e-util/md5-utils.h" /* md5 hash building */
+#include "libedataserver/md5-utils.h" /* md5 hash building */
#include "camel-mime-utils.h" /* base64 encoding */
#include "camel-seekable-stream.h"
#define _CAMEL_IMAP_SEARCH_H
#include <camel/camel-folder-search.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include <camel/camel-data-cache.h>
#define CAMEL_IMAP_SEARCH_TYPE (camel_imap_search_get_type ())
#include "camel-file-utils.h"
-#include "e-util/md5-utils.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/md5-utils.h"
+#include "libedataserver/e-memory.h"
#include "camel-private.h"
#include "camel-utf8.h"
#include <unistd.h>
#include <errno.h>
-#include "e-util/e-path.h"
-
#include "camel-imap-store.h"
#include "camel-imap-store-summary.h"
#include "camel-imap-folder.h"
#include "camel-private.h"
#include "camel-debug.h"
#include "camel-i18n.h"
+#include "camel-net-utils.h"
#define d(x)
name = folder_name;
storage_path = g_strdup_printf ("%s/folders", imap_store->storage_path);
- folder_dir = e_path_to_physical (storage_path, folder_name);
+ folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free (storage_path);
if (access (folder_dir, F_OK) != 0) {
g_free (folder_dir);
}
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
- folder_dir = e_path_to_physical (storage_path, folder_name);
+ folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free(storage_path);
new_folder = camel_imap_folder_new (store, folder_name, folder_dir, ex);
g_free (folder_dir);
folder_name = "INBOX";
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
- folder_dir = e_path_to_physical (storage_path, folder_name);
+ folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free(storage_path);
if (!folder_dir || access (folder_dir, F_OK) != 0) {
g_free (folder_dir);
manage_subscriptions(store, new_name_in, TRUE);
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
- oldpath = e_path_to_physical (storage_path, old_name);
- newpath = e_path_to_physical (storage_path, new_name_in);
+ oldpath = imap_path_to_physical (storage_path, old_name);
+ newpath = imap_path_to_physical (storage_path, new_name_in);
g_free(storage_path);
/* So do we care if this didn't work? Its just a cache? */
/* This is a lot of work for one path! */
storage_path = g_strdup_printf("%s/folders", ((CamelImapStore *)store)->storage_path);
- folder_dir = e_path_to_physical(storage_path, fi->full_name);
+ folder_dir = imap_path_to_physical(storage_path, fi->full_name);
path = g_strdup_printf("%s/summary", folder_dir);
s = (CamelFolderSummary *)camel_object_new(camel_imap_summary_get_type());
camel_folder_summary_set_build_content(s, TRUE);
/* A kludge to avoid having to pass a struct to the callback */
g_ptr_array_add (folders, imap_store);
storage_path = g_strdup_printf("%s/folders", imap_store->storage_path);
- if (!e_path_find_folders (storage_path, get_one_folder_offline, folders)) {
+ if (!imap_path_find_folders (storage_path, get_one_folder_offline, folders)) {
camel_disco_store_check_online (CAMEL_DISCO_STORE (imap_store), ex);
fi = NULL;
} else {
#include <camel/camel-disco-store.h>
#ifdef ENABLE_THREADS
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
typedef struct _CamelImapMsg CamelImapMsg;
#include <string.h>
#include <time.h>
#include <errno.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "camel-imap-utils.h"
#include "camel-imap-summary.h"
#define d(x)
+#define SUBFOLDER_DIR_NAME "subfolders"
+#define SUBFOLDER_DIR_NAME_LEN 10
+
const char *
imap_next_word (const char *buf)
{
return camel_utf7_utf8 (buf);
}
+
+char *
+imap_path_to_physical (const char *prefix, const char *vpath)
+{
+ const char *p, *newp;
+ char *dp;
+ char *ppath;
+ int ppath_len;
+ int prefix_len;
+
+ while (*vpath == '/')
+ vpath++;
+ if (!prefix)
+ prefix = "";
+
+ /* Calculate the length of the real path. */
+ ppath_len = strlen (vpath);
+ ppath_len++; /* For the ending zero. */
+
+ prefix_len = strlen (prefix);
+ ppath_len += prefix_len;
+ ppath_len++; /* For the separating slash. */
+
+ /* Take account of the fact that we need to translate every
+ * separator into `subfolders/'.
+ */
+ p = vpath;
+ while (1) {
+ newp = strchr (p, '/');
+ if (newp == NULL)
+ break;
+
+ ppath_len += SUBFOLDER_DIR_NAME_LEN;
+ ppath_len++; /* For the separating slash. */
+
+ /* Skip consecutive slashes. */
+ while (*newp == '/')
+ newp++;
+
+ p = newp;
+ };
+
+ ppath = g_malloc (ppath_len);
+ dp = ppath;
+
+ memcpy (dp, prefix, prefix_len);
+ dp += prefix_len;
+ *(dp++) = '/';
+
+ /* Copy the mangled path. */
+ p = vpath;
+ while (1) {
+ newp = strchr (p, '/');
+ if (newp == NULL) {
+ strcpy (dp, p);
+ break;
+ }
+
+ memcpy (dp, p, newp - p + 1); /* `+ 1' to copy the slash too. */
+ dp += newp - p + 1;
+
+ memcpy (dp, SUBFOLDER_DIR_NAME, SUBFOLDER_DIR_NAME_LEN);
+ dp += SUBFOLDER_DIR_NAME_LEN;
+
+ *(dp++) = '/';
+
+ /* Skip consecutive slashes. */
+ while (*newp == '/')
+ newp++;
+
+ p = newp;
+ }
+
+ return ppath;
+}
+
+static gboolean
+find_folders_recursive (const char *physical_path, const char *path,
+ IMAPPathFindFoldersCallback callback, gpointer data)
+{
+ DIR *dir;
+ char *subfolder_directory_path;
+ gboolean ok;
+
+ if (*path) {
+ if (!callback (physical_path, path, data))
+ return FALSE;
+
+ subfolder_directory_path = g_strdup_printf ("%s/%s", physical_path, SUBFOLDER_DIR_NAME);
+ } else {
+ /* On the top level, we have no folders and,
+ * consequently, no subfolder directory.
+ */
+
+ subfolder_directory_path = g_strdup (physical_path);
+ }
+
+ /* Now scan the subfolders and load them. */
+ dir = opendir (subfolder_directory_path);
+ if (dir == NULL) {
+ g_free (subfolder_directory_path);
+ return TRUE;
+ }
+
+ ok = TRUE;
+ while (ok) {
+ struct stat file_stat;
+ struct dirent *dirent;
+ char *file_path;
+ char *new_path;
+
+ dirent = readdir (dir);
+ if (dirent == NULL)
+ break;
+
+ if (strcmp (dirent->d_name, ".") == 0 || strcmp (dirent->d_name, "..") == 0)
+ continue;
+
+ file_path = g_strdup_printf ("%s/%s", subfolder_directory_path,
+ dirent->d_name);
+
+ if (stat (file_path, &file_stat) < 0 ||
+ ! S_ISDIR (file_stat.st_mode)) {
+ g_free (file_path);
+ continue;
+ }
+
+ new_path = g_strdup_printf ("%s/%s", path, dirent->d_name);
+
+ ok = find_folders_recursive (file_path, new_path, callback, data);
+
+ g_free (file_path);
+ g_free (new_path);
+ }
+
+ closedir (dir);
+ g_free (subfolder_directory_path);
+
+ return ok;
+}
+
+/**
+ * imap_path_find_folders:
+ * @prefix: directory to start from
+ * @callback: Callback to invoke on each folder
+ * @data: Data for @callback
+ *
+ * Walks the folder tree starting at @prefix and calls @callback
+ * on each folder.
+ *
+ * Return value: %TRUE on success, %FALSE if an error occurs at any point
+ **/
+gboolean
+imap_path_find_folders (const char *prefix, IMAPPathFindFoldersCallback callback, gpointer data)
+{
+ return find_folders_recursive (prefix, "", callback, data);
+}
char *imap_mailbox_encode (const unsigned char *in, size_t inlen);
char *imap_mailbox_decode (const unsigned char *in, size_t inlen);
+typedef gboolean (*IMAPPathFindFoldersCallback) (const char *physical_path, const char *path, gpointer user_data);
+
+char *imap_path_to_physical (const char *prefix, const char *vpath);
+gboolean imap_path_find_folders (const char *prefix, IMAPPathFindFoldersCallback callback, gpointer data);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
## Process this file with automake to produce Makefile.in
-libcamelimap4includedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelimap4.la
camel_provider_DATA = libcamelimap4.urls
#include <glib.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include <camel/camel-stream.h>
#include <camel/camel-exception.h>
#include <glib.h>
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include <camel/camel-stream.h>
#include <camel/camel-folder.h>
#include <camel/camel-private.h>
#include <camel/camel-i18n.h>
+#include <camel/camel-net-utils.h>
#include "camel-imap4-store.h"
#include "camel-imap4-engine.h"
#include <ctype.h>
#include <errno.h>
-#include <e-util/md5-utils.h>
+#include <libedataserver/md5-utils.h>
#include <camel/camel-file-utils.h>
#include <camel/camel-string-utils.h>
#include <camel/camel-store.h>
#include <camel/camel-i18n.h>
+#include <camel/camel-net-utils.h>
#include "camel-imap4-engine.h"
#include "camel-imap4-stream.h"
## Process this file with automake to produce Makefile.in
-libcamelimappincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelimapp.la
camel_provider_DATA = libcamelimapp.urls
camel-imapp-driver.c \
camel-imapp-summary.c
-libcamelimappinclude_HEADERS = \
+noinst_HEADERS = \
camel-imapp-utils.h \
camel-imapp-engine.h \
camel-imapp-stream.h \
libcamelimapp_la_LDFLAGS = -avoid-version -module
-#noinst_HEADERS = \
-# camel-imap-private.h
-
EXTRA_DIST = libcamelimapp.urls
#include <camel/camel-object.h>
#include "camel-imapp-stream.h"
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#define CAMEL_IMAPP_DRIVER_TYPE (camel_imapp_driver_get_type ())
#define CAMEL_IMAPP_DRIVER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_IMAPP_DRIVER_TYPE, CamelIMAPPDriver))
#include <camel/camel-object.h>
#include "camel-imapp-stream.h"
-#include <e-util/e-msgport.h>
+#include <libedataserver/e-msgport.h>
#include "camel-imapp-folder.h"
#define CAMEL_IMAPP_ENGINE_TYPE (camel_imapp_engine_get_type ())
#include "camel-imapp-summary.h"
#include "camel-imapp-exception.h"
-#include <e-util/md5-utils.h>
+#include <libedataserver/md5-utils.h>
#include <stdlib.h>
#include <string.h>
#include "camel/camel-file-utils.h"
#include "camel-string-utils.h"
-#include "e-util/md5-utils.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/md5-utils.h"
+#include "libedataserver/e-memory.h"
#include "camel-private.h"
#include "camel-utf8.h"
#include "camel-imapp-exception.h"
#include "camel-imapp-utils.h"
#include "camel-imapp-driver.h"
+#include "camel-net-utils.h"
/* Specified in RFC 2060 section 2.1 */
#define IMAP_PORT 143
#include <camel/camel-types.h>
#include <camel/camel-store.h>
#include "camel-imapp-driver.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#define CAMEL_IMAPP_STORE_TYPE (camel_imapp_store_get_type ())
#define CAMEL_IMAPP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_IMAPP_STORE_TYPE, CamelIMAPPStore))
#include "camel-imapp-utils.h"
#include "camel-imapp-exception.h"
#include "camel-imapp-engine.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
/* high-level parser state */
#define p(x)
## Process this file with automake to produce Makefile.in
-libcamellocalincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamellocal.la
camel_provider_DATA = libcamellocal.urls
-INCLUDES = -I.. \
- -I$(srcdir)/.. \
+INCLUDES = \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir) \
$(CAMEL_CFLAGS) \
- $(GNOME_INCLUDEDIR) \
- $(GTK_INCLUDEDIR) \
-DG_LOG_DOMAIN=\"camel-local-provider\"
libcamellocal_la_SOURCES = \
camel-spool-store.c \
camel-spool-summary.c
-libcamellocalinclude_HEADERS = \
+noinst_HEADERS = \
camel-local-folder.h \
camel-local-store.h \
camel-local-summary.h \
camel-maildir-summary.h \
camel-spool-folder.h \
camel-spool-store.h \
- camel-spool-summary.h
-
-noinst_HEADERS = \
+ camel-spool-summary.h \
camel-local-private.h
libcamellocal_la_LDFLAGS = -avoid-version -module
-libcamellocal_la_LIBADD = $(top_builddir)/e-util/libeutil.la
+libcamellocal_la_LIBADD = \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la
EXTRA_DIST = libcamellocal.urls
#include <camel/camel-operation.h>
#include "camel-private.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/e-memory.h"
#include "camel-i18n.h"
#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
## Process this file with automake to produce Makefile.in
-libcamelnntpincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelnntp.la
camel_provider_DATA = libcamelnntp.urls
camel-nntp-summary.c \
camel-nntp-store-summary.c
-libcamelnntpinclude_HEADERS = \
+noinst_HEADERS = \
camel-nntp-store.h \
camel-nntp-folder.h \
camel-nntp-resp-codes.h \
camel-nntp-stream.h \
camel-nntp-summary.h \
- camel-nntp-store-summary.h
-
-noinst_HEADERS = \
+ camel-nntp-store-summary.h \
camel-nntp-private.h
libcamelnntp_la_LDFLAGS = -avoid-version -module
#include <config.h>
#endif
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
struct _CamelNNTPStorePrivate {
int dummy;
#include "camel-file-utils.h"
-#include "e-util/md5-utils.h"
-#include "e-util/e-memory.h"
+#include "libedataserver/md5-utils.h"
+#include "libedataserver/e-memory.h"
#include "camel-private.h"
#include "camel-utf8.h"
#include "camel-nntp-private.h"
#include "camel-nntp-resp-codes.h"
#include "camel-i18n.h"
+#include "camel-net-utils.h"
#define w(x)
#define dd(x) (camel_debug("nntp")?(x):0)
#include "camel-stream-mem.h"
#include "camel-exception.h"
-#include "e-util/md5-utils.h"
+#include "libedataserver/md5-utils.h"
#include <stdlib.h>
#include <string.h>
## Process this file with automake to produce Makefile.in
-libcamelpop3includedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelpop3.la
camel_provider_DATA = libcamelpop3.urls
INCLUDES = \
- -I.. \
- -I$(srcdir)/.. \
- -I$(srcdir)/../../.. \
+ -I$(top_srcdir) \
-I$(top_srcdir)/intl \
-I$(top_srcdir)/camel \
- -I$(top_srcdir)/e-util \
$(CAMEL_CFLAGS) \
- $(GNOME_INCLUDEDIR) \
- $(GTK_INCLUDEDIR) \
-DG_LOG_DOMAIN=\"camel-pop3-provider\"
libcamelpop3_la_SOURCES = \
camel-pop3-stream.c \
camel-pop3-store.c
-libcamelpop3include_HEADERS = \
+noinst_HEADERS = \
camel-pop3-engine.h \
camel-pop3-folder.h \
camel-pop3-stream.h \
camel-pop3-store.h
-
libcamelpop3_la_LDFLAGS = -avoid-version -module
-libcamelpop3_la_LIBADD = $(top_builddir)/e-util/libeutil.la
+libcamelpop3_la_LIBADD = \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la
EXTRA_DIST = libcamelpop3.urls
#define _CAMEL_POP3_ENGINE_H
#include <camel/camel-object.h>
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#include "camel-pop3-stream.h"
#define CAMEL_POP3_ENGINE(obj) CAMEL_CHECK_CAST (obj, camel_pop3_engine_get_type (), CamelPOP3Engine)
#include "camel-data-cache.h"
#include "camel-i18n.h"
-#include <e-util/md5-utils.h>
+#include <libedataserver/md5-utils.h>
#include <stdlib.h>
#include <string.h>
#include "camel-session.h"
#include "camel-exception.h"
#include "camel-url.h"
-#include "e-util/md5-utils.h"
+#include "libedataserver/md5-utils.h"
#include "camel-pop3-engine.h"
#include "camel-sasl.h"
#include "camel-data-cache.h"
#include "camel-tcp-stream-ssl.h"
#endif
#include "camel-i18n.h"
+#include "camel-net-utils.h"
/* Specified in RFC 1939 */
#define POP3_PORT "110"
## Process this file with automake to produce Makefile.in
-libcamelsendmailincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelsendmail.la
camel_provider_DATA = libcamelsendmail.urls
camel-sendmail-provider.c \
camel-sendmail-transport.c
-libcamelsendmailinclude_HEADERS = \
+noinst_HEADERS = \
camel-sendmail-transport.h
libcamelsendmail_la_LDFLAGS = -avoid-version -module
## Process this file with automake to produce Makefile.in
-libcamelsmtpincludedir = $(privincludedir)/camel
-
camel_provider_LTLIBRARIES = libcamelsmtp.la
camel_provider_DATA = libcamelsmtp.urls
INCLUDES = \
- -I.. \
- -I$(srcdir)/.. \
- -I$(srcdir)/../../.. \
+ -I$(top_srcdir) \
-I$(top_srcdir)/intl \
-I$(top_srcdir)/camel \
- -I$(top_srcdir)/e-util \
$(CAMEL_CFLAGS) \
- $(GNOME_INCLUDEDIR) \
- $(GTK_INCLUDEDIR) \
- $(NSPR_CFLAGS) \
- $(NSS_CFLAGS) \
- $(OPENSSL_CFLAGS) \
-DG_LOG_DOMAIN=\"camel-smtp-provider\"
libcamelsmtp_la_SOURCES = \
camel-smtp-provider.c \
camel-smtp-transport.c
-libcamelsmtpinclude_HEADERS = \
+noinst_HEADERS = \
camel-smtp-transport.h
-
libcamelsmtp_la_LDFLAGS = -avoid-version -module
-libcamelsmtp_la_LIBADD = $(top_builddir)/e-util/libeutil.la
+libcamelsmtp_la_LIBADD = \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la
EXTRA_DIST = libcamelsmtp.urls
#include "camel-exception.h"
#include "camel-sasl.h"
#include "camel-i18n.h"
+#include "camel-net-utils.h"
extern int camel_verbose_debug;
#define d(x) (camel_verbose_debug ? (x) : 0)
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
$(CAMEL_CFLAGS)
LDADD = \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(top_builddir)/camel/tests/lib/libcameltest-provider.a \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/camel/libcamel-provider.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
+ $(INTLLIBS)
check_PROGRAMS = \
test1 test2 test3 \
/* store testing */
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *local_drivers[] = {
+ "local"
+};
+
static char *local_providers[] = {
"mbox",
"mh",
char *path;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
ex = camel_exception_new();
#include <pthread.h>
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "messages.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *local_drivers[] = { "local" };
static char *local_providers[] = {
"mbox",
"mh",
pthread_t threads[MAX_THREADS];
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
ex = camel_exception_new();
#include <fcntl.h>
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "messages.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *local_drivers[] = { "local" };
+
static char *stores[] = {
"mbox:///tmp/camel-test/mbox",
"mh:///tmp/camel-test/mh",
int i;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
/* folder/index testing */
-#include <gtk/gtk.h>
-
#include <string.h>
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "messages.h"
#include "folders.h"
#include "session.h"
pull();
}
+static const char *local_drivers[] = { "local" };
static char *stores[] = {
"mbox:///tmp/camel-test/mbox",
int indexed;
GPtrArray *uids;
- gtk_init(&argc, &argv);
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
ex = camel_exception_new();
/* store testing, for remote folders */
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *imap_drivers[] = { "imap" };
+
static char *remote_providers[] = {
"IMAP_TEST_URL",
};
char *path;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, imap_drivers);
ex = camel_exception_new();
/* store testing, for remote folders */
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *nntp_drivers[] = { "nntp" };
+
static char *remote_providers[] = {
"NNTP_TEST_URL",
};
char *path;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, nntp_drivers);
ex = camel_exception_new();
/* folder testing */
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *imap_drivers[] = { "imap" };
static char *remote_providers[] = {
"IMAP_TEST_URL",
};
char *path;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, imap_drivers);
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
/* folder testing */
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "messages.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *nntp_drivers[] = { "nntp" };
static char *remote_providers[] = {
"NNTP_TEST_URL",
};
char *path;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, nntp_drivers);
/* clear out any camel-test data */
system("/bin/rm -rf /tmp/camel-test");
#include <pthread.h>
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "folders.h"
#include "messages.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *local_drivers[] = { "local" };
+
static char *local_providers[] = {
"mbox",
"mh",
GPtrArray *uids;
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
ex = camel_exception_new();
#include <string.h>
#include "camel-test.h"
+#include "camel-test-provider.h"
#include "messages.h"
#include "folders.h"
#include "session.h"
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+static const char *local_drivers[] = { "local" };
+
struct {
char *name;
CamelFolder *folder;
CamelStream *mbox;
CamelFilterDriver *driver;
- /*gtk_init(&argc, &argv);*/
-
camel_test_init(argc, argv);
+ camel_test_provider_init(1, local_drivers);
ex = camel_exception_new();
-I$(top_srcdir)/intl \
-I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
+ -DCAMEL_BUILD_DIR=\"$(top_builddir)/camel\" \
$(CAMEL_CFLAGS)
-check_LIBRARIES = libcameltest.a
+check_LIBRARIES = libcameltest.a libcameltest-provider.a
libcameltest_a_SOURCES = \
camel-test.c camel-test.h \
streams.c streams.h \
address-data.h
+libcameltest_provider_a_SOURCES = \
+ camel-test-provider.c camel-test-provider.h
+
libcameltest_a_LIBADD = \
- $(top_builddir)/e-util/libeutil.la
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la
+
+libcameltest_provider_a_LIBADD = \
+ $(top_builddir)/camel/libcamel-provider.la \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la
{
GPtrArray *s;
int i, myunread;
+ int gettotal, getunread;
CamelMessageInfo *info;
push("test folder counts %d total %d unread", total, unread);
/* first, use the standard functions */
- check(camel_folder_get_message_count(folder) == total);
- check(camel_folder_get_unread_message_count(folder) == total);
+ camel_object_get(folder, NULL, CAMEL_FOLDER_TOTAL, &gettotal, CAMEL_FOLDER_UNREAD, &getunread, 0);
+ check(gettotal == total);
+ check(getunread == unread);
/* next, use the summary */
s = camel_folder_get_summary(folder);
myunread = s->len;
for (i=0;i<s->len;i++) {
info = s->pdata[i];
- if (info->flags & CAMEL_MESSAGE_SEEN)
+ if (camel_message_info_flags(info) & CAMEL_MESSAGE_SEEN)
myunread--;
}
check(unread == myunread);
myunread = s->len;
for (i=0;i<s->len;i++) {
info = camel_folder_get_message_info(folder, s->pdata[i]);
- if (info->flags & CAMEL_MESSAGE_SEEN)
+ if (camel_message_info_flags(info) & CAMEL_MESSAGE_SEEN)
myunread--;
camel_folder_free_message_info(folder, info);
}
/* FIXME: testing from/cc/to, etc is more tricky */
- check(info->date_sent == camel_mime_message_get_date(msg, NULL));
+ check(camel_message_info_date_sent(info) == camel_mime_message_get_date(msg, NULL));
/* date received isn't set for messages that haven't been sent anywhere ... */
/*check(info->date_received == camel_mime_message_get_date_received(msg, NULL));*/
push("deleting first message & expunging");
camel_folder_delete_message(folder, uids->pdata[0]);
- test_folder_counts(folder, 10, 10);
+ test_folder_counts(folder, 10, 9);
camel_folder_expunge(folder, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
test_folder_not_message(folder, uids->pdata[0]);
push("deleting last message & expunging");
camel_folder_delete_message(folder, uids->pdata[8]);
/* sync? */
- test_folder_counts(folder, 9, 9);
+ test_folder_counts(folder, 9, 8);
camel_folder_expunge(folder, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
test_folder_not_message(folder, uids->pdata[8]);
camel_folder_delete_message(folder, uids->pdata[j]);
}
/* sync? */
- test_folder_counts(folder, 8, 8);
+ test_folder_counts(folder, 8, 0);
camel_folder_expunge(folder, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
for (j=0;j<8;j++) {
int test_message_compare (CamelMimeMessage *msg);
void test_message_dump_structure(CamelMimeMessage *m);
+
+int test_message_compare_header(CamelMimeMessage *m1, CamelMimeMessage *m2);
+int test_message_compare_messages(CamelMimeMessage *m1, CamelMimeMessage *m2);
CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s;
CamelSeekableStream *sp = sus->parent_stream;
int i, len;
- off_t end;
push("writing substream, type %d", type);
CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s;
CamelSeekableStream *sp = sus->parent_stream;
int i, len;
- off_t end;
push("reading substream");
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
LDADD = \
$(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(INTLLIBS)
check_PROGRAMS = \
test1 \
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
LDADD = \
$(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(INTLLIBS)
EXTRA_DIST = \
crlf-1.in \
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
$(CAMEL_CFLAGS)
LDADD = \
+ $(top_builddir)/camel/libcamel-provider.la \
$(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(INTLLIBS)
check_PROGRAMS = \
url \
#include <stdlib.h>
#include <string.h>
#include <glib.h>
-#include <e-util/e-sexp.h>
+#include <libedataserver/e-sexp.h>
#include <camel/camel-exception.h>
#include <camel/camel-search-private.h>
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
$(CAMEL_CFLAGS)
LDADD = \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(top_builddir)/camel/libcamel-provider.la \
+ $(top_builddir)/camel/libcamel.la \
+ $(INTLLIBS)
check_PROGRAMS = \
pgp
camel_test_push ("PGP signing");
camel_cipher_sign (ctx, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, conpart, sigpart, ex);
- check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
+ if (camel_exception_is_set(ex)) {
+ printf("PGP signing failed assuming non-functional environment\n%s", camel_exception_get_description (ex));
+ camel_test_pull();
+ return 77;
+ }
camel_test_pull ();
camel_exception_clear (ex);
-I$(includedir) \
-I$(top_srcdir) \
-I$(top_srcdir)/intl \
- -I$(top_srcdir)/e-util \
-I$(top_srcdir)/camel \
-I$(top_srcdir)/camel/tests/lib \
-DG_LOG_DOMAIN=\"evolution-tests\" \
LDADD = \
$(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \
$(top_builddir)/camel/tests/lib/libcameltest.a \
- $(INTLLIBS) \
- $(EVOLUTION_MAIL_LIBS)
+ $(INTLLIBS)
check_PROGRAMS = \
test1 test2 test3