[evolution-data-server/camel-gobject: 204/331] Merge branch 'master' into camel-gobject.



commit 065d34dc6469fad41201e8dca56f9e848478c89e
Merge: fc80200 bc6f842
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Feb 28 11:28:08 2010 -0500

    Merge branch 'master' into camel-gobject.

 NEWS                                               |  195 ++
 addressbook/backends/file/e-book-backend-file.c    |   55 +-
 addressbook/backends/file/e-book-backend-file.h    |    2 +-
 addressbook/backends/google/Makefile.am            |    1 -
 .../google/e-book-backend-google-factory.c         |   53 +-
 .../google/e-book-backend-google-factory.h         |   53 -
 .../backends/groupwise/e-book-backend-groupwise.c  |    6 +-
 .../backends/groupwise/e-book-backend-groupwise.h  |    2 +-
 addressbook/backends/ldap/e-book-backend-ldap.c    |   83 +-
 addressbook/backends/ldap/e-book-backend-ldap.h    |    2 +-
 addressbook/backends/ldap/openldap-extract.h       |  275 +-
 addressbook/backends/vcf/e-book-backend-vcf.c      |    8 +-
 addressbook/backends/vcf/e-book-backend-vcf.h      |    2 +-
 .../backends/webdav/e-book-backend-webdav.c        |   26 +-
 addressbook/libebook/e-address-western.h           |    2 +-
 addressbook/libebook/e-book-query.c                |   12 +-
 addressbook/libebook/e-book-types.h                |    2 +-
 addressbook/libebook/e-book-view-private.h         |    2 +-
 addressbook/libebook/e-book-view.h                 |    2 +-
 addressbook/libebook/e-book.c                      |   40 +-
 addressbook/libebook/e-book.h                      |    2 +-
 addressbook/libebook/e-contact.c                   |  117 +-
 addressbook/libebook/e-destination.c               |   34 +-
 addressbook/libebook/e-name-western.c              |   16 +-
 addressbook/libebook/e-name-western.h              |    2 +-
 addressbook/libebook/e-vcard.c                     |   28 +-
 addressbook/libedata-book/e-book-backend-cache.c   |   24 +-
 addressbook/libedata-book/e-book-backend-factory.c |   28 +-
 addressbook/libedata-book/e-book-backend-sexp.c    |   29 +-
 addressbook/libedata-book/e-book-backend-summary.c |   29 +-
 addressbook/libedata-book/e-book-backend-sync.c    |   29 +-
 addressbook/libedata-book/e-book-backend-sync.h    |    2 +-
 addressbook/libedata-book/e-book-backend.c         |   29 +-
 addressbook/libedata-book/e-book-backend.h         |    2 +-
 addressbook/libedata-book/e-data-book-factory.h    |    2 +-
 addressbook/libedata-book/e-data-book-view.h       |    2 +-
 addressbook/libedata-book/e-data-book.h            |    2 +-
 addressbook/tests/ebook/Makefile.am                |  107 +-
 addressbook/tests/ebook/data/vcards/name-only.vcf  |    3 +
 addressbook/tests/ebook/data/vcards/simple-1.vcf   |    4 +
 addressbook/tests/ebook/data/vcards/simple-2.vcf   |    4 +
 addressbook/tests/ebook/ebook-test-utils.c         |  786 +++++
 addressbook/tests/ebook/ebook-test-utils.h         |  158 +
 addressbook/tests/ebook/test-changes.c             |   45 +-
 addressbook/tests/ebook/test-ebook-add-contact.c   |   55 +
 .../tests/ebook/test-ebook-commit-contact.c        |   97 +
 addressbook/tests/ebook/test-ebook-get-book-view.c |  131 +
 addressbook/tests/ebook/test-ebook-get-contact.c   |   44 +
 .../tests/ebook/test-ebook-get-required-fields.c   |   76 +
 .../ebook/test-ebook-get-static-capabilities.c     |   32 +
 .../ebook/test-ebook-get-supported-auth-methods.c  |   76 +
 .../tests/ebook/test-ebook-get-supported-fields.c  |   76 +
 .../tests/ebook/test-ebook-remove-contact-by-id.c  |   34 +
 .../tests/ebook/test-ebook-remove-contact.c        |   59 +
 .../tests/ebook/test-ebook-remove-contacts.c       |   71 +
 addressbook/tests/ebook/test-ebook-remove.c        |   33 +
 .../tests/ebook/test-ebook-stress-factory--fifo.c  |   33 +
 .../ebook/test-ebook-stress-factory--serial.c      |   29 +
 .../ebook/test-ebook-stress-factory--single-book.c |   35 +
 addressbook/tests/ebook/test-ebook-view.c          |   99 -
 addressbook/tests/ebook/test-ebook.c               |    9 +-
 calendar/backends/caldav/e-cal-backend-caldav.c    |   27 +-
 .../backends/contacts/e-cal-backend-contacts.c     |   36 +-
 calendar/backends/file/e-cal-backend-file-events.c |   38 +-
 .../backends/file/e-cal-backend-file-journal.c     |   38 +-
 calendar/backends/file/e-cal-backend-file-todos.c  |   38 +-
 calendar/backends/file/e-cal-backend-file.c        |   34 +-
 calendar/backends/google/e-cal-backend-google.c    |   33 +-
 .../backends/groupwise/e-cal-backend-groupwise.c   |   38 +-
 calendar/backends/http/e-cal-backend-http.c        |   36 +-
 calendar/backends/weather/e-cal-backend-weather.c  |   35 +-
 calendar/backends/weather/e-weather-source-ccf.c   |   24 +-
 calendar/backends/weather/e-weather-source.c       |   24 +-
 calendar/libecal/e-cal-component.c                 |   36 +-
 calendar/libecal/e-cal-util.h                      |    2 +-
 calendar/libecal/e-cal.c                           |   99 +-
 calendar/libedata-cal/e-cal-backend-cache.c        |   38 +-
 calendar/libedata-cal/e-cal-backend-factory.c      |   28 +-
 calendar/libedata-cal/e-cal-backend-file-store.c   |    2 +-
 .../libedata-cal/e-cal-backend-loader-factory.c    |   29 +-
 calendar/libedata-cal/e-cal-backend-sexp.c         |   33 +-
 calendar/libedata-cal/e-cal-backend-store.c        |    2 +
 calendar/libedata-cal/e-cal-backend-sync.c         |   35 +-
 calendar/libedata-cal/e-cal-backend-sync.h         |    6 +-
 calendar/libedata-cal/e-data-cal.c                 |    2 +-
 calendar/tests/ecal/Makefile.am                    |  118 +-
 calendar/tests/ecal/ecal-test-utils.c              |  697 +++++
 calendar/tests/ecal/ecal-test-utils.h              |  160 +
 calendar/tests/ecal/test-ecal-add-timezone.c       |   50 +
 calendar/tests/ecal/test-ecal-create-object--2.c   |   38 +
 calendar/tests/ecal/test-ecal-create-object.c      |   36 +
 .../tests/ecal/test-ecal-get-alarm-email-address.c |   28 +
 calendar/tests/ecal/test-ecal-get-cal-address.c    |   28 +
 calendar/tests/ecal/test-ecal-get-capabilities.c   |   22 +
 calendar/tests/ecal/test-ecal-get-default-object.c |   31 +
 calendar/tests/ecal/test-ecal-get-free-busy.c      |   39 +
 calendar/tests/ecal/test-ecal-get-ldap-attribute.c |   28 +
 calendar/tests/ecal/test-ecal-get-object-list.c    |   51 +
 .../tests/ecal/test-ecal-get-objects-for-uid.c     |   48 +
 calendar/tests/ecal/test-ecal-get-query.c          |  184 ++
 calendar/tests/ecal/test-ecal-get-timezone.c       |   31 +
 calendar/tests/ecal/test-ecal-modify-object.c      |   69 +
 calendar/tests/ecal/test-ecal-open.c               |   57 +
 calendar/tests/ecal/test-ecal-receive-objects.c    |   36 +
 calendar/tests/ecal/test-ecal-remove-object.c      |   36 +
 calendar/tests/ecal/test-ecal-remove.c             |   21 +
 calendar/tests/ecal/test-ecal-send-objects.c       |   41 +
 .../tests/ecal/test-ecal-set-default-timezone.c    |   54 +
 calendar/tests/ecal/test-ecal-set-mode.c           |   60 +
 .../tests/ecal/test-ecal-stress-factory--fifo.c    |   34 +
 .../ecal/test-ecal-stress-factory--open-async.c    |   65 +
 .../tests/ecal/test-ecal-stress-factory--serial.c  |   31 +
 .../ecal/test-ecal-stress-factory--single-cal.c    |   36 +
 camel/Makefile.am                                  |    7 +-
 camel/camel-charset-map.c                          |    2 +-
 camel/camel-data-cache.c                           |    3 +-
 camel/camel-folder-search.c                        |    2 +-
 camel/camel-folder-summary.c                       |   75 +-
 camel/camel-folder-summary.h                       |    4 +-
 camel/camel-folder-thread.h                        |    2 +-
 camel/camel-folder.c                               |    2 +-
 camel/camel-gpg-context.c                          |   18 +-
 camel/camel-iconv.c                                |    2 +-
 camel/camel-list-utils.c                           |    2 +-
 camel/camel-lock-client.c                          |    2 +-
 camel/camel-lock-client.h                          |    2 +-
 camel/camel-lock-helper.h                          |    2 +-
 camel/camel-lock.c                                 |    2 +-
 camel/camel-lock.h                                 |    2 +-
 camel/camel-mime-message.c                         |    2 +-
 camel/camel-mime-parser.c                          |    2 +-
 camel/camel-mime-utils.c                           |    4 +-
 camel/camel-msgport.c                              |   23 +
 camel/camel-msgport.h                              |    1 +
 camel/camel-net-utils.c                            |   45 +-
 camel/camel-object.c                               |    4 +-
 camel/camel-partition-table.c                      |    2 +-
 camel/camel-private.h                              |    5 +-
 camel/camel-sasl-gssapi.c                          |   79 +-
 camel/camel-search-sql-sexp.c                      |   29 +-
 camel/camel-store-summary.c                        |    5 +-
 camel/camel-store.c                                |    4 +-
 camel/camel-text-index.c                           |   28 +-
 camel/camel-uid-cache.c                            |    4 +-
 camel/camel-url-scanner.c                          |    4 +
 camel/camel-utf8.c                                 |    6 +-
 camel/camel-vtrash-folder.c                        |    2 +-
 camel/db-scrap-tools/db.c                          |    2 +-
 camel/providers/Makefile.am                        |    8 +-
 camel/providers/groupwise/camel-groupwise-folder.c |   10 +-
 .../providers/groupwise/camel-groupwise-provider.c |    9 +-
 .../groupwise/camel-groupwise-store-summary.c      |    4 +-
 camel/providers/groupwise/camel-groupwise-store.c  |   85 +-
 camel/providers/groupwise/camel-groupwise-store.h  |    1 -
 camel/providers/groupwise/camel-groupwise-utils.c  |    2 +-
 camel/providers/imap/camel-imap-folder.c           |    1 -
 camel/providers/imap/camel-imap-store-summary.c    |    2 +-
 camel/providers/imap/camel-imap-store.c            |  105 +-
 camel/providers/imap/camel-imap-utils.c            |    2 +-
 camel/providers/imap/camel-imap-wrapper.c          |   10 +-
 camel/providers/imap4/camel-imap4-folder.c         |    2 +-
 camel/providers/imapx/Makefile.am                  |   14 +-
 camel/providers/imapx/camel-imapx-folder.c         |  160 +-
 camel/providers/imapx/camel-imapx-folder.h         |    9 +-
 camel/providers/imapx/camel-imapx-provider.c       |  104 +-
 camel/providers/imapx/camel-imapx-server.c         | 2194 ++++++++++----
 camel/providers/imapx/camel-imapx-server.h         |   30 +-
 camel/providers/imapx/camel-imapx-store-summary.c  |    2 +-
 camel/providers/imapx/camel-imapx-store-summary.h  |    2 +-
 camel/providers/imapx/camel-imapx-store.c          |  649 ++---
 camel/providers/imapx/camel-imapx-store.h          |   16 +-
 camel/providers/imapx/camel-imapx-stream.c         |   82 +-
 camel/providers/imapx/camel-imapx-stream.h         |   14 +-
 camel/providers/imapx/camel-imapx-summary.h        |    2 +-
 camel/providers/imapx/camel-imapx-tokenise.h       |  200 +-
 camel/providers/imapx/camel-imapx-tokens.txt       |   71 +-
 camel/providers/imapx/camel-imapx-utils.c          |  546 +++-
 camel/providers/imapx/camel-imapx-utils.h          |  158 +-
 camel/providers/imapx/camel-imapx-view-summary.h   |    2 +-
 camel/providers/local/camel-maildir-folder.c       |    2 +-
 camel/providers/local/camel-maildir-store.c        |    4 +-
 camel/providers/local/camel-maildir-summary.c      |   10 +-
 camel/providers/local/camel-mbox-store.c           |    2 +-
 camel/providers/local/camel-mbox-summary.c         |    2 +
 camel/providers/local/camel-mh-summary.c           |    4 +-
 camel/providers/local/camel-spool-store.c          |    4 +-
 camel/providers/nntp/camel-nntp-folder.c           |    2 +-
 camel/providers/nntp/camel-nntp-store.c            |    2 +-
 camel/providers/pop3/camel-pop3-engine.c           |    4 +-
 camel/providers/pop3/camel-pop3-store.c            |   53 +-
 camel/tests/lib/address-data.h                     |    2 +-
 configure.ac                                       |  165 +-
 .../calendar/libecal/libecal-sections.txt          |    3 +
 .../calendar/libecal/tmpl/e-cal-util.sgml          |    7 +
 docs/reference/calendar/libecal/tmpl/e-cal.sgml    |   19 +
 .../libedata-cal/libedata-cal-sections.txt         |    3 +
 .../libedata-cal/tmpl/e-cal-backend-sync.sgml      |   10 +
 .../calendar/libedata-cal/tmpl/e-cal-backend.sgml  |   10 +
 .../calendar/libedata-cal/tmpl/e-data-cal.sgml     |   10 +
 docs/reference/camel/Makefile.am                   |    1 +
 docs/reference/camel/camel-docs.sgml               |    2 -
 docs/reference/camel/camel-sections.txt            |   15 +-
 .../reference/camel/tmpl/camel-folder-summary.sgml |    8 +
 .../camel/tmpl/camel-groupwise-store.sgml          |    1 -
 docs/reference/camel/tmpl/camel-i18n.sgml          |   79 -
 docs/reference/camel/tmpl/camel-mime-part.sgml     |    9 +
 docs/reference/camel/tmpl/camel-msgport.sgml       |   10 +
 docs/reference/camel/tmpl/camel-unused.sgml        |    8 +
 .../libedataserverui/libedataserverui-sections.txt |    2 +
 .../tmpl/e-name-selector-model.sgml                |   19 +
 libebackend/e-db3-utils.h                          |    2 +-
 libebackend/e-dbhash.h                             |    2 +-
 libebackend/e-offline-listener.c                   |   37 +-
 libedataserver/e-iconv.c                           |    2 +-
 libedataserver/e-iconv.h                           |    2 +-
 libedataserver/e-iterator.h                        |    2 +-
 libedataserver/e-list-iterator.h                   |    2 +-
 libedataserver/e-list.h                            |    2 +-
 libedataserver/e-memory.c                          |    2 +-
 libedataserver/e-memory.h                          |    2 +-
 libedataserver/e-msgport.c                         |    2 +-
 libedataserver/e-proxy.c                           |   30 +-
 libedataserver/e-sexp.c                            |   32 +-
 libedataserver/e-source-group.c                    |    4 +-
 libedataserver/e-source-list.c                     |   28 +-
 libedataserver/e-time-utils.c                      |   10 +-
 libedataserver/test-source-list.c                  |    2 +-
 libedataserverui/e-categories-dialog.c             |   32 +-
 libedataserverui/e-category-completion.c           |   33 +-
 libedataserverui/e-contact-store.c                 |   44 +-
 libedataserverui/e-destination-store.c             |   55 +-
 libedataserverui/e-name-selector-dialog.c          |   29 +-
 libedataserverui/e-name-selector-entry.c           |    2 +-
 libedataserverui/e-name-selector-list.c            |    2 +-
 libedataserverui/e-name-selector-model.c           |  135 +-
 libedataserverui/e-name-selector-model.h           |    3 +
 libedataserverui/e-source-combo-box.c              |   28 +-
 libedataserverui/e-source-selector-dialog.c        |   16 +
 libedataserverui/e-source-selector.c               |   48 +-
 libedataserverui/e-tree-model-generator.c          |   44 +-
 libedataserverui/libedataserverui.pc.in            |    2 +-
 po/POTFILES.in                                     |    1 +
 po/ast.po                                          | 2151 +++++++-------
 po/bg.po                                           | 2052 ++++++-------
 po/bn.po                                           | 1968 +++++++------
 po/cs.po                                           | 2128 ++++++--------
 po/de.po                                           | 2255 +++++++--------
 po/en_GB.po                                        | 2204 ++++++++-------
 po/es.po                                           |  554 ++--
 po/et.po                                           |  577 +---
 po/fr.po                                           | 1630 +++++------
 po/gl.po                                           | 1501 +++++-----
 po/nb.po                                           |  539 ++--
 po/pt_BR.po                                        | 2372 ++++++++-------
 po/ro.po                                           | 1142 +++++---
 po/ru.po                                           | 3120 +++++++++-----------
 po/sl.po                                           |  726 +++---
 po/sv.po                                           |  708 +++---
 po/ta.po                                           | 1214 ++++----
 po/uk.po                                           | 2468 +++++++---------
 po/zh_HK.po                                        | 1848 ++++++-------
 po/zh_TW.po                                        | 1848 ++++++-------
 .../google/libgdata-google/gdata-google-service.c  |   60 +-
 servers/google/libgdata/gdata-entry.c              |   34 +-
 servers/google/libgdata/gdata-feed.c               |   35 +-
 servers/google/libgdata/gdata-service-iface.c      |   15 +-
 servers/groupwise/e-gw-connection.c                |   26 +-
 servers/groupwise/e-gw-container.c                 |   26 +-
 servers/groupwise/e-gw-filter.c                    |   26 +-
 servers/groupwise/e-gw-item.c                      |   32 +-
 servers/groupwise/e-gw-sendoptions.c               |   36 +-
 271 files changed, 24306 insertions(+), 21112 deletions(-)
---
diff --cc camel/Makefile.am
index b57c652,d04c829..09e73ae
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@@ -30,17 -30,17 +30,18 @@@ camellibexec_PROGRAMS =	$(LOCK_HELPER) 
  lib_LTLIBRARIES = libcamel-1.2.la libcamel-provider-1.2.la
  
  libcamel_provider_1_2_la_CPPFLAGS = \
 -	$(AM_CPPFLAGS)									\
 -	-I$(top_srcdir) 								\
 -	-I$(top_builddir)								\
 -	-I$(srcdir)										\
 +	$(AM_CPPFLAGS)						\
 +	-I$(top_srcdir) 					\
 +	-I$(top_builddir)					\
 +	-I$(srcdir)						\
  	-DCAMEL_LIBEXECDIR=\""$(camellibexecdir)"\"		\
 -	-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" 	\
 -	-DG_LOG_DOMAIN=\"camel\"						\
 +	-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\"		\
 +	-DG_LOG_DOMAIN=\"camel\"				\
  	-DE_DATA_SERVER_PREFIX=\"$(prefix)\"			\
  	-DEVOLUTION_LOCALEDIR=\""$(localedir)"\"		\
 +	-DCAMEL_COMPILATION					\
- 	$(CAMEL_CFLAGS)
+ 	$(CAMEL_CFLAGS)						\
+ 	$(DBUS_GLIB_CFLAGS)
  
  libcamel_provider_1_2_la_SOURCES = 		\
  	camel-cipher-context.c			\
@@@ -149,19 -148,19 +149,20 @@@ libcamel_provider_1_2_la_LIBADD =			
  	libcamel-1.2.la				\
  	$(CAMEL_LIBS)				\
  	$(SOCKET_LIBS)				\
- 	$(REGEX_LIBS)
+ 	$(REGEX_LIBS)				\
+ 	$(DBUS_GLIB_LIBS)	
  
  libcamel_1_2_la_CPPFLAGS = \
 -	$(AM_CPPFLAGS)									\
 -	-I$(top_srcdir) 								\
 -	-I$(top_builddir)								\
 -	-I$(srcdir)										\
 +	$(AM_CPPFLAGS)						\
 +	-I$(top_srcdir) 					\
 +	-I$(top_builddir)					\
 +	-I$(srcdir)						\
  	-DCAMEL_LIBEXECDIR=\""$(camellibexecdir)"\"		\
 -	-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" 	\
 -	-DG_LOG_DOMAIN=\"camel\"						\
 +	-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\"		\
 +	-DG_LOG_DOMAIN=\"camel\"				\
  	-DE_DATA_SERVER_PREFIX=\"$(prefix)\"			\
  	-DEVOLUTION_LOCALEDIR=\""$(localedir)"\"		\
 +	-DCAMEL_COMPILATION					\
  	$(CAMEL_CFLAGS)
  
  libcamel_1_2_la_SOURCES = 			\
diff --cc camel/camel-data-cache.c
index 82756be,7fbcea3..a07d79b
--- a/camel/camel-data-cache.c
+++ b/camel/camel-data-cache.c
@@@ -36,8 -36,9 +36,7 @@@
  #include <glib/gstdio.h>
  #include <glib/gi18n-lib.h>
  
- #include <libedataserver/e-data-server-util.h>
  #include "camel-data-cache.h"
 -#include "camel-exception.h"
  #include "camel-stream-fs.h"
  #include "camel-stream-mem.h"
  #include "camel-file-utils.h"
diff --cc camel/camel-folder-summary.c
index 39e4ee3,85265ac..e173b7b
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@@ -60,12 -61,12 +60,12 @@@
  #include "camel-vee-folder.h"
  #include "camel-mime-part-utils.h"
  
 -/* To switch between e-memchunk and g-alloc */
 -#define ALWAYS_ALLOC 1
 -#define USE_GSLICE 1
 +#define CAMEL_FOLDER_SUMMARY_GET_PRIVATE(obj) \
 +	(G_TYPE_INSTANCE_GET_PRIVATE \
 +	((obj), CAMEL_TYPE_FOLDER_SUMMARY, CamelFolderSummaryPrivate))
  
  /* Make 5 minutes as default cache drop */
- #define SUMMARY_CACHE_DROP 300
+ #define SUMMARY_CACHE_DROP 300 
  #define dd(x) if (camel_debug("sync")) x
  
  static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER;
@@@ -1268,22 -563,31 +1266,20 @@@ message_info_from_uid (CamelFolderSumma
  		data.double_ref = TRUE;
  		data.add = FALSE;
  
 -		ret = camel_db_read_message_info_record_with_uid (cdb, folder_name, uid, &data, camel_read_mir_callback, &ex);
 -		if (ret != 0) {
 -			camel_exception_clear (&ex);
 +		ret = camel_db_read_message_info_record_with_uid (
 +			cdb, folder_name, uid, &data,
 +			camel_read_mir_callback, NULL);
 +		if (ret != 0)
  			return NULL;
 -		}
  
  		CAMEL_SUMMARY_LOCK(s, summary_lock);
- 		CAMEL_SUMMARY_LOCK(s, ref_lock);
  
  		/* We would have double reffed at camel_read_mir_callback */
  		info = g_hash_table_lookup (s->loaded_infos, uid);
  
 -		if (!info) {
 -			gchar *errmsg = g_strdup_printf ("no uid [%s] exists", uid);
 -
 -			/* Makes no sense now as the exception is local as of now. FIXME: Pass exception from caller */
 -			camel_exception_set (&ex, CAMEL_EXCEPTION_SYSTEM, _(errmsg));
 -			d(g_warning ("No uid[%s] exists in %s\n", uid, folder_name));
 -			camel_exception_clear (&ex);
 -			g_free (errmsg);
 -		}
 -	}
 -
 -	if (info)
 -		camel_message_info_ref (info);
 +	} else
 +		info->refcount++;
  
- 	CAMEL_SUMMARY_UNLOCK(s, ref_lock);
  	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
  
  	return info;
diff --cc camel/camel-folder-thread.h
index 2d973d2,4c0515d..9a72f55
--- a/camel/camel-folder-thread.h
+++ b/camel/camel-folder-thread.h
@@@ -69,4 -65,4 +69,4 @@@ gint camel_folder_threaded_messages_dum
  
  G_END_DECLS
  
- #endif /* !CAMEL_FOLDER_THREAD_H */
 -#endif /* _CAMEL_FOLDER_THREAD_H */
++#endif /* CAMEL_FOLDER_THREAD_H */
diff --cc camel/camel-iconv.c
index 8825f28,926bc92..1eccd8e
--- a/camel/camel-iconv.c
+++ b/camel/camel-iconv.c
@@@ -256,9 -256,9 +256,9 @@@ locale_parse_lang (const gchar *locale
  	}
  }
  
- /* NOTE: Owns the lock on return if keep is TRUE ! */
+ /* NOTE: Owns the lock on return if keep is TRUE !*/
  static void
 -camel_iconv_init(gint keep)
 +iconv_init(gint keep)
  {
  	gchar *from, *to, *locale;
  	gint i;
diff --cc camel/camel-lock-client.h
index 76fd986,0a99bed..249d5c3
--- a/camel/camel-lock-client.h
+++ b/camel/camel-lock-client.h
@@@ -37,4 -33,4 +37,4 @@@ gint camel_lock_helper_unlock(gint lock
  
  G_END_DECLS
  
- #endif /* !CAMEL_LOCK_HELPER_H */
 -#endif /* _CAMEL_LOCK_HELPER_H */
++#endif /* CAMEL_LOCK_HELPER_H */
diff --cc camel/camel-lock-helper.h
index e58ace5,9582e58..e02490c
--- a/camel/camel-lock-helper.h
+++ b/camel/camel-lock-helper.h
@@@ -65,4 -61,4 +65,4 @@@ enum 
  
  G_END_DECLS
  
- #endif /* !CAMEL_LOCK_HELPER_H */
 -#endif /* _CAMEL_LOCK_HELPER_H */
++#endif /* CAMEL_LOCK_HELPER_H */
diff --cc camel/camel-lock.c
index 016af8c,d584791..a4e712f
--- a/camel/camel-lock.c
+++ b/camel/camel-lock.c
@@@ -143,12 -141,9 +143,12 @@@ camel_lock_dot (const gchar *path
  
  	d(printf("failed to get lock after %d retries\n", retry));
  
 -	camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Timed out trying to get lock file on %s. Try again later."), path);
 +	g_set_error (
 +		error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
 +		_("Timed out trying to get lock file on %s.  "
 +		"Try again later."), path);
  	return -1;
- #else /* ! USE_DOT */
+ #else /* !USE_DOT */
  	return 0;
  #endif
  }
diff --cc camel/camel-lock.h
index bc663b8,8e3e78f..6b9e225
--- a/camel/camel-lock.h
+++ b/camel/camel-lock.h
@@@ -59,4 -55,4 +59,4 @@@ void camel_unlock_folder(const gchar *p
  
  G_END_DECLS
  
- #endif /* !CAMEL_LOCK_H */
 -#endif /* _CAMEL_LOCK_H */
++#endif /* CAMEL_LOCK_H */
diff --cc camel/camel-net-utils.c
index 2578e36,49324cf..6920c44
--- a/camel/camel-net-utils.c
+++ b/camel/camel-net-utils.c
@@@ -26,11 -26,12 +26,10 @@@
  #endif
  
  #include <errno.h>
- #include <pthread.h>
  #include <stdio.h>
  
 -#include <glib.h>
  #include <glib/gi18n-lib.h>
  
 -#include "camel-exception.h"
  #include "camel-msgport.h"
  #include "camel-net-utils.h"
  #ifdef G_OS_WIN32
@@@ -444,14 -443,12 +443,14 @@@ cs_freeinfo(struct _addrinfo_msg *msg
  
  /* returns -1 if we didn't wait for reply from thread */
  static gint
 -cs_waitinfo(gpointer (worker)(gpointer), struct _addrinfo_msg *msg, const gchar *error, CamelException *ex)
 +cs_waitinfo (gpointer (worker)(gpointer),
 +             struct _addrinfo_msg *msg,
 +             const gchar *errmsg,
 +             GError **error)
  {
  	CamelMsgPort *reply_port;
- 	pthread_t id;
- 	gint err, cancel_fd, cancel = 0, fd;
+ 	GThread *thread;
 -	GError *err = NULL;
+ 	gint cancel_fd, cancel = 0, fd;
  
  	cancel_fd = camel_operation_cancel_fd(NULL);
  	if (cancel_fd == -1) {
@@@ -461,7 -458,7 +460,7 @@@
  
  	reply_port = msg->msg.reply_port = camel_msgport_new();
  	fd = camel_msgport_fd(msg->msg.reply_port);
- 	if ((err = pthread_create(&id, NULL, worker, msg)) == 0) {
 -	if ((thread = g_thread_create (worker, msg, TRUE, &err)) != NULL) {
++	if ((thread = g_thread_create (worker, msg, TRUE, error)) != NULL) {
  		gint status;
  #ifndef G_OS_WIN32
  		GPollFD polls[2];
@@@ -515,22 -506,23 +514,19 @@@
  			   We check the reply port incase we had a reply in the mean time, which we free later */
  			d(printf("Canceling lookup thread and leaving it\n"));
  			msg->cancelled = 1;
- 			pthread_cancel(id);
- 			pthread_join (id, NULL);
+ 			g_thread_join (thread);
  			cancel = 1;
  		} else {
- 			struct _addrinfo_msg *reply = (struct _addrinfo_msg *)camel_msgport_try_pop(reply_port);
+ 			struct _addrinfo_msg *reply;
  
- 			g_assert(reply == msg);
  			d(printf("waiting for child to exit\n"));
- 			pthread_join(id, NULL);
+ 			g_thread_join (thread);
  			d(printf("child done\n"));
+ 
+ 			reply = (struct _addrinfo_msg *)camel_msgport_try_pop(reply_port);
+ 			if (reply != msg)
+ 				g_warning ("%s: Received msg reply %p doesn't match msg %p", G_STRFUNC, reply, msg);
  		}
--	} else {
- 		g_set_error (
- 			error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
- 			"%s: %s: %s", errmsg, _("cannot create thread"),
- 			g_strerror (err));
 -		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), err ? err->message : _("Unknown error"));
 -		if (err)
 -			g_error_free (err);
  	}
  	camel_msgport_destroy(reply_port);
  
diff --cc camel/camel-object.c
index f2d7ea2,c54ae59..1b15dd5
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@@ -29,11 -29,11 +29,9 @@@
  #include <stdio.h>
  #include <string.h>
  
 -#include <glib.h>
  #include <glib/gstdio.h>
  
- #include <libedataserver/e-data-server-util.h>
- 
  #include "camel-file-utils.h"
 -#include "camel-list-utils.h"
  #include "camel-object.h"
  
  #define d(x)
diff --cc camel/camel-partition-table.c
index 08aa629,bec514b..1fcc787
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@@ -190,7 -179,7 +190,7 @@@ static CamelBlock *find_partition (Came
  		bl = bl->next;
  	}
  
- 	g_warning ("could not find a partition that could fit !  partition table corrupt!");
 -	g_warning("could not find a partition that could fit !partition table corrupt!");
++	g_warning ("could not find a partition that could fit!  partition table corrupt!");
  
  	/* This should never be reached */
  
diff --cc camel/camel-sasl-gssapi.c
index e1a1691,5c49d0e..306c714
--- a/camel/camel-sasl-gssapi.c
+++ b/camel/camel-sasl-gssapi.c
@@@ -56,13 -57,17 +57,21 @@@ extern gss_OID gss_nt_service_name
  
  #include <glib/gi18n-lib.h>
  
+ #include <dbus/dbus.h>
+ #include <dbus/dbus-glib-lowlevel.h>
+ 
  #include "camel-net-utils.h"
  #include "camel-sasl-gssapi.h"
+ #include "camel-session.h"
+ 
+ #define DBUS_PATH		"/org/gnome/KrbAuthDialog"
+ #define DBUS_INTERFACE		"org.gnome.KrbAuthDialog"
+ #define DBUS_METHOD		"org.gnome.KrbAuthDialog.acquireTgt"
  
 +#define CAMEL_SASL_GSSAPI_GET_PRIVATE(obj) \
 +	(G_TYPE_INSTANCE_GET_PRIVATE \
 +	((obj), CAMEL_TYPE_SASL_GSSAPI, CamelSaslGssapiPrivate))
 +
  CamelServiceAuthType camel_sasl_gssapi_authtype = {
  	N_("GSSAPI"),
  
@@@ -147,36 -209,72 +156,95 @@@ gssapi_set_exception (OM_uint32 major
  		str = _("Bad authentication response from server.");
  	}
  
 -	camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, str);
 +	g_set_error (
 +		error, CAMEL_SERVICE_ERROR,
 +		CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
 +		"%s", str);
 +}
 +
 +static void
 +sasl_gssapi_finalize (GObject *object)
 +{
 +	CamelSaslGssapi *sasl = CAMEL_SASL_GSSAPI (object);
 +	guint32 status;
 +
 +	if (sasl->priv->ctx != GSS_C_NO_CONTEXT)
 +		gss_delete_sec_context (
 +			&status, &sasl->priv->ctx, GSS_C_NO_BUFFER);
 +
 +	if (sasl->priv->target != GSS_C_NO_NAME)
 +		gss_release_name (&status, &sasl->priv->target);
 +
 +	/* Chain up to parent's finalize() method. */
 +	G_OBJECT_CLASS (parent_class)->finalize (object);
  }
  
+ /* DBUS Specific code */
+ 
+ static gboolean
+ send_dbus_message (gchar *name)
+ {
+ 	DBusMessage *message, *reply;
+ 	DBusError dbus_error;
+ 	gint success = FALSE;
+ 	DBusConnection *bus = NULL;
+ 
+ 	dbus_error_init (&dbus_error);
+ 	if (!(bus = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error))) {
+ 		g_warning ("could not get system bus: %s\n", dbus_error.message);
+ 		dbus_error_free (&dbus_error);
+ 		return FALSE;
+ 	}
+ 
+ 	dbus_error_free (&dbus_error);
+ 
+ 	dbus_connection_setup_with_g_main (bus, NULL);
+ 	dbus_connection_set_exit_on_disconnect (bus, FALSE);
+ 
+ 	/* Create a new message on the DBUS_INTERFACE */
+ 	if (!(message = dbus_message_new_method_call (DBUS_INTERFACE, DBUS_PATH, DBUS_INTERFACE, "acquireTgt"))) {
+ 		g_object_unref (bus);
+ 		return FALSE;
+ 	}
+ 	/* Appends the data as an argument to the message */
+ 	if (strchr(name, '\\'))
+ 		name = strchr(name, '\\');
+ 	dbus_message_append_args (message,
+ 				  DBUS_TYPE_STRING, &name,
+ 				  DBUS_TYPE_INVALID);
+ 	dbus_error_init(&dbus_error);
+ 
+ 	/* Sends the message: Have a 300 sec wait timeout  */
+ 	reply = dbus_connection_send_with_reply_and_block (bus, message, 300 * 1000, &dbus_error);
+ 
+ 	if (dbus_error_is_set(&dbus_error))
+ 		g_warning ("%s: %s\n", dbus_error.name, dbus_error.message);
+ 	dbus_error_free(&dbus_error);
+ 
+         if (reply)
+         {
+                 dbus_error_init(&dbus_error);
+                 dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_BOOLEAN, &success, DBUS_TYPE_INVALID);
+                 dbus_error_free(&dbus_error);
+                 dbus_message_unref(reply);
+         }
+ 
+ 	/* Free the message */
+ 	dbus_message_unref (message);
+ 	dbus_connection_unref (bus);
+ 
+ 	return success;
+ }
+ 
+ /* END DBus stuff */
+ 
  static GByteArray *
 -gssapi_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
 +sasl_gssapi_challenge (CamelSasl *sasl,
 +                       GByteArray *token,
 +                       GError **error)
  {
 -	struct _CamelSaslGssapiPrivate *priv = CAMEL_SASL_GSSAPI (sasl)->priv;
 +	CamelSaslGssapiPrivate *priv;
 +	CamelService *service;
  	OM_uint32 major, minor, flags, time;
  	gss_buffer_desc inbuf, outbuf;
  	GByteArray *challenge = NULL;
@@@ -246,7 -336,13 +314,16 @@@
  			priv->state = GSSAPI_STATE_CONTINUE_NEEDED;
  			break;
  		default:
- 			gssapi_set_exception (major, minor, error);
+ 			if (major == (OM_uint32)GSS_S_FAILURE &&
+ 			    (minor == (OM_uint32)KRB5KRB_AP_ERR_TKT_EXPIRED ||
+ 			     minor == (OM_uint32)KRB5KDC_ERR_NEVER_VALID)) {
 -				if (send_dbus_message (sasl->service->url->user))
++				CamelService *service;
++
++				service = camel_sasl_get_service (sasl);
++				if (send_dbus_message (service->url->user))
+ 					goto challenge;
+ 			} else
 -				gssapi_set_exception (major, minor, ex);
++				gssapi_set_exception (major, minor, error);
  			return NULL;
  		}
  
diff --cc camel/camel-search-sql-sexp.c
index 8f6b7c0,fae78dd..e9bb5fd
--- a/camel/camel-search-sql-sexp.c
+++ b/camel/camel-search-sql-sexp.c
@@@ -30,8 -30,8 +30,7 @@@
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
 -#include <glib.h>
  #include "camel-search-sql-sexp.h"
- #include "libedataserver/e-sexp.h"
  #define d(x) /* x;printf("\n"); */
  
  #ifdef TEST_MAIN
diff --cc camel/camel-store-summary.c
index df22096,41807b8..5a5b0a6
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@@ -631,11 -429,11 +631,11 @@@ camel_store_summary_save (CamelStoreSum
  		return -1;
  	}
  
- 	out = fdopen (fd, "wb");
- 	if ( out == NULL ) {
+ 	out = fdopen(fd, "wb");
+ 	if (out == NULL) {
  		i = errno;
 -		printf("**  fdopen error: %s\n", g_strerror (errno));
 -		close(fd);
 +		printf ("**  fdopen error: %s\n", g_strerror (errno));
 +		close (fd);
  		errno = i;
  		return -1;
  	}
@@@ -1031,20 -841,160 +1031,19 @@@ camel_store_info_string (CamelStoreSumm
   * Set a specific string on the @info.
   **/
  void
 -camel_store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *info, gint type, const gchar *value)
 +camel_store_info_set_string (CamelStoreSummary *s,
 +                             CamelStoreInfo *info,
 +                             gint type,
 +                             const gchar *value)
  {
 -	((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_set_string(s, info, type, value);
 -}
 +	CamelStoreSummaryClass *class;
  
 -static CamelStoreInfo *
 -store_info_new(CamelStoreSummary *s, const gchar *f)
 -{
 -	CamelStoreInfo *info;
 -
 -	info = camel_store_summary_info_new(s);
 -
 -	info->path = g_strdup(f);
 -	info->unread = CAMEL_STORE_INFO_FOLDER_UNKNOWN;
 -	info->total = CAMEL_STORE_INFO_FOLDER_UNKNOWN;
 -
 -	return info;
 -}
 -
 -static CamelStoreInfo *
 -store_info_load(CamelStoreSummary *s, FILE *in)
 -{
 -	CamelStoreInfo *info;
 -
 -	info = camel_store_summary_info_new(s);
 -
 -	io(printf("Loading folder info\n"));
 -
 -	camel_file_util_decode_string(in, &info->path);
 -	camel_file_util_decode_uint32(in, &info->flags);
 -	camel_file_util_decode_uint32(in, &info->unread);
 -	camel_file_util_decode_uint32(in, &info->total);
 -
 -	/* Ok, brown paper bag bug - prior to version 2 of the file, flags are
 -	   stored using the bit number, not the bit. Try to recover as best we can */
 -	if (s->version < CAMEL_STORE_SUMMARY_VERSION_2) {
 -		guint32 flags = 0;
 -
 -		if (info->flags & 1)
 -			flags |= CAMEL_STORE_INFO_FOLDER_NOSELECT;
 -		if (info->flags & 2)
 -			flags |= CAMEL_STORE_INFO_FOLDER_READONLY;
 -		if (info->flags & 3)
 -			flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
 -		if (info->flags & 4)
 -			flags |= CAMEL_STORE_INFO_FOLDER_FLAGGED;
 +	/* XXX Can 'value' be NULL? */
 +	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (s));
 +	g_return_if_fail (info != NULL);
  
 -		info->flags = flags;
 -	}
 -
 -	if (!ferror(in))
 -		return info;
 +	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
 +	g_return_if_fail (class->store_info_set_string != NULL);
  
 -	camel_store_summary_info_free(s, info);
 -
 -	return NULL;
 -}
 -
 -static gint
 -store_info_save(CamelStoreSummary *s, FILE *out, CamelStoreInfo *info)
 -{
 -	io(printf("Saving folder info\n"));
 -
 -	camel_file_util_encode_string(out, camel_store_info_path(s, info));
 -	camel_file_util_encode_uint32(out, info->flags);
 -	camel_file_util_encode_uint32(out, info->unread);
 -	camel_file_util_encode_uint32(out, info->total);
 -
 -	return ferror(out);
 -}
 -
 -static void
 -store_info_free(CamelStoreSummary *s, CamelStoreInfo *info)
 -{
 -	g_free(info->path);
 -	g_free(info->uri);
 -	g_slice_free1(s->store_info_size, info);
 -}
 -
 -static const gchar *
 -store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
 -{
 -	const gchar *p;
 -
 -	/* FIXME: Locks? */
 -
 -	g_assert (info != NULL);
 -
 -	switch (type) {
 -	case CAMEL_STORE_INFO_PATH:
 -		return info->path;
 -	case CAMEL_STORE_INFO_NAME:
 -		p = strrchr(info->path, '/');
 -		if (p)
 -			return p+1;
 -		else
 -			return info->path;
 -	case CAMEL_STORE_INFO_URI:
 -		if (info->uri == NULL) {
 -			CamelURL *uri;
 -
 -			uri = camel_url_new_with_base(s->uri_base, info->path);
 -			((CamelStoreInfo *)info)->uri = camel_url_to_string(uri, 0);
 -			camel_url_free(uri);
 -		}
 -		return info->uri;
 -	}
 -
 -	return "";
 -}
 -
 -static void
 -store_info_set_string (CamelStoreSummary *s, CamelStoreInfo *info, gint type, const gchar *str)
 -{
 -	const gchar *p;
 -	gchar *v;
 -	gint len;
 -
 -	g_assert (info != NULL);
 -
 -	switch (type) {
 -	case CAMEL_STORE_INFO_PATH:
 -		CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
 -		g_hash_table_remove(s->folders_path, (gchar *)camel_store_info_path(s, info));
 -		g_free(info->path);
 -		g_free(info->uri);
 -		info->uri = NULL;
 -		info->path = g_strdup(str);
 -		g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
 -		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 -		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
 -		break;
 -	case CAMEL_STORE_INFO_NAME:
 -		CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
 -		g_hash_table_remove(s->folders_path, (gchar *)camel_store_info_path(s, info));
 -		p = strrchr(info->path, '/');
 -		if (p) {
 -			len = p-info->path+1;
 -			v = g_malloc(len+strlen(str)+1);
 -			memcpy(v, info->path, len);
 -			strcpy(v+len, str);
 -		} else {
 -			v = g_strdup(str);
 -		}
 -		g_free(info->path);
 -		info->path = v;
 -		g_free (info->uri);
 -		info->uri = NULL;
 -		g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
 -		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
 -		break;
 -	case CAMEL_STORE_INFO_URI:
 -		g_warning("Cannot set store info uri, aborting");
 -		abort();
 -		break;
 -	}
 +	class->store_info_set_string (s, info, type, value);
  }
- 
diff --cc camel/camel-text-index.c
index 0bb6210,5dce85a..a23505e
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@@ -363,18 -278,16 +363,18 @@@ text_index_sync (CamelIndex *idx
  	/* this doesn't really need to be dropped, its only used in updates anyway */
  	p->word_cache_limit = 1024;
  
 -	work = !camel_dlist_empty(&p->word_cache);
 +	work = !camel_dlist_empty (&p->word_cache);
  
- 	while ( (ww = (struct _CamelTextIndexWord *)camel_dlist_remhead (&p->word_cache)) ) {
 -	while ((ww = (struct _CamelTextIndexWord *)camel_dlist_remhead(&p->word_cache))) {
++	while ((ww = (struct _CamelTextIndexWord *)camel_dlist_remhead (&p->word_cache))) {
  		if (ww->used > 0) {
 -			io(printf("writing key file entry '%s' [%x]\n", ww->word, ww->data));
 -			if (camel_key_file_write(p->links, &ww->data, ww->used, ww->names) != -1) {
 -				io(printf("  new data [%x]\n", ww->data));
 +			io (printf ("writing key file entry '%s' [%x]\n", ww->word, ww->data));
 +			if (camel_key_file_write (p->links, &ww->data, ww->used, ww->names) != -1) {
 +				io (printf ("  new data [%x]\n", ww->data));
  				rb->keys++;
 -				camel_block_file_touch_block(p->blocks, p->blocks->root_block);
 -				camel_key_table_set_data(p->word_index, ww->wordid, ww->data);
 +				camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 +				camel_key_table_set_data (
 +					p->word_index, ww->wordid,
 +					ww->data, NULL);
  			} else {
  				ret = -1;
  			}
@@@ -498,18 -408,17 +498,18 @@@ text_index_compress_nosync (CamelIndex 
  
  	   For each word:
  	   Copy word's data to a new file
 -	   Add new word to index(*) (can we just copy blocks?) */
 +	   Add new word to index (*) (can we just copy blocks?) */
  
  	/* Copy undeleted names to new index file, creating new indices */
 -	io(printf("Copying undeleted names to new file\n"));
 -	remap = g_hash_table_new(NULL, NULL);
 +	io (printf ("Copying undeleted names to new file\n"));
 +	remap = g_hash_table_new (NULL, NULL);
  	oldkeyid = 0;
  	deleted = 0;
- 	while ( (oldkeyid = camel_key_table_next (oldp->name_index, oldkeyid, &name, &flags, &data, NULL)) ) {
 -	while ((oldkeyid = camel_key_table_next(oldp->name_index, oldkeyid, &name, &flags, &data))) {
++	while ((oldkeyid = camel_key_table_next (oldp->name_index, oldkeyid, &name, &flags, &data, NULL))) {
  		if ((flags&1) == 0) {
 -			io(printf("copying name '%s'\n", name));
 -			newkeyid = camel_key_table_add(newp->name_index, name, data, flags);
 +			io (printf ("copying name '%s'\n", name));
 +			newkeyid = camel_key_table_add (
 +				newp->name_index, name, data, flags, error);
  			if (newkeyid == 0)
  				goto fail;
  			rb->names++;
@@@ -528,8 -436,8 +528,8 @@@
  	/* We re-block the data into 256 entry lots while we're at it, since we only
  	   have to do 1 at a time and its cheap */
  	oldkeyid = 0;
- 	while ( (oldkeyid = camel_key_table_next (oldp->word_index, oldkeyid, &name, &flags, &data, NULL)) ) {
- 		io (printf ("copying word '%s'\n", name));
 -	while ((oldkeyid = camel_key_table_next(oldp->word_index, oldkeyid, &name, &flags, &data))) {
 -		io(printf("copying word '%s'\n", name));
++	while ((oldkeyid = camel_key_table_next (oldp->word_index, oldkeyid, &name, &flags, &data, NULL))) {
++		io(printf ("copying word '%s'\n", name));
  		newdata = 0;
  		newcount = 0;
  		if (data) {
@@@ -1292,32 -1207,32 +1292,32 @@@ camel_text_index_dump (CamelTextIndex *
  
  	/* Iterate over all names in the file first */
  
 -	printf("UID's in index\n");
 +	printf ("UID's in index\n");
  
  	keyid = 0;
- 	while ( (keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data, NULL)) ) {
 -	while ((keyid = camel_key_table_next(p->name_index, keyid, &word, &flags, &data))) {
++	while ((keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data, NULL))) {
  		if ((flags & 1) == 0)
 -			printf(" %s\n", word);
 +			printf (" %s\n", word);
  		else
 -			printf(" %s (deleted)\n", word);
 -		g_free(word);
 +			printf (" %s (deleted)\n", word);
 +		g_free (word);
  	}
  
 -	printf("Word's in index\n");
 +	printf ("Word's in index\n");
  
  	keyid = 0;
- 	while ( (keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data, NULL)) ) {
 -	while ((keyid = camel_key_table_next(p->word_index, keyid, &word, &flags, &data))) {
++	while ((keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data, NULL))) {
  		CamelIndexCursor *idc;
  
 -		printf("Word: '%s':\n", word);
 +		printf ("Word: '%s':\n", word);
  
 -		idc = camel_index_find((CamelIndex *)idx, word);
 -		while ((name = camel_index_cursor_next(idc))) {
 -			printf(" %s", name);
 +		idc = camel_index_find ((CamelIndex *)idx, word);
 +		while ( (name = camel_index_cursor_next (idc)) ) {
 +			printf (" %s", name);
  		}
 -		printf("\n");
 -		camel_object_unref((CamelObject *)idc);
 -		g_free(word);
 +		printf ("\n");
 +		g_object_unref (idc);
 +		g_free (word);
  	}
  #else
  	/* a more low-level dump routine */
@@@ -1365,28 -1280,28 +1365,28 @@@ camel_text_index_validate (CamelTextInd
  
  	/* Iterate over all names in the file first */
  
 -	printf("Checking UID consistency\n");
 +	printf ("Checking UID consistency\n");
  
  	keyid = 0;
- 	while ( (keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data, NULL)) ) {
- 		if ((oldword = g_hash_table_lookup (names, GINT_TO_POINTER (keyid))) != NULL
- 		    || (oldword = g_hash_table_lookup (deleted, GINT_TO_POINTER (keyid))) != NULL) {
 -	while ((keyid = camel_key_table_next(p->name_index, keyid, &word, &flags, &data))) {
 -		if ((oldword = g_hash_table_lookup(names, GINT_TO_POINTER(keyid))) != NULL
 -		    || (oldword = g_hash_table_lookup(deleted, GINT_TO_POINTER(keyid))) != NULL) {
 -			printf("Warning, name '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
 -			g_free(word);
++	while ((keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data, NULL))) {
++		if ((oldword = g_hash_table_lookup (names, GINT_TO_POINTER(keyid))) != NULL
++		    || (oldword = g_hash_table_lookup (deleted, GINT_TO_POINTER(keyid))) != NULL) {
 +			printf ("Warning, name '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
 +			g_free (word);
  		} else {
 -			g_hash_table_insert(name_word, word, GINT_TO_POINTER (1));
 +			g_hash_table_insert (name_word, word, GINT_TO_POINTER (1));
  			if ((flags & 1) == 0) {
 -				g_hash_table_insert(names, GINT_TO_POINTER(keyid), word);
 +				g_hash_table_insert (names, GINT_TO_POINTER (keyid), word);
  			} else {
 -				g_hash_table_insert(deleted, GINT_TO_POINTER(keyid), word);
 +				g_hash_table_insert (deleted, GINT_TO_POINTER (keyid), word);
  			}
  		}
  	}
  
 -	printf("Checking WORD member consistency\n");
 +	printf ("Checking WORD member consistency\n");
  
  	keyid = 0;
- 	while ( (keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data, NULL)) ) {
 -	while ((keyid = camel_key_table_next(p->word_index, keyid, &word, &flags, &data))) {
++	while ((keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data, NULL))) {
  		CamelIndexCursor *idc;
  		GHashTable *used;
  
@@@ -1795,48 -1690,22 +1795,48 @@@ camel_text_index_cursor_new (CamelTextI
  /* CamelTextIndexKeyCursor */
  /* ********************************************************************** */
  
 -static CamelIndexCursorClass *camel_text_index_key_cursor_parent;
 +static gpointer text_index_key_cursor_parent_class;
 +
 +static void
 +text_index_key_cursor_dispose (GObject *object)
 +{
 +	CamelTextIndexKeyCursorPrivate *priv;
 +
 +	priv = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (object);
 +
 +	if (priv->table != NULL) {
 +		g_object_unref (priv->table);
 +		priv->table = NULL;
 +	}
 +
 +	/* Chain up parent's dispose() method. */
 +	G_OBJECT_CLASS (text_index_key_cursor_parent_class)->dispose (object);
 +}
 +
 +static void
 +text_index_key_cursor_finalize (GObject *object)
 +{
 +	CamelTextIndexKeyCursorPrivate *priv;
  
 -#define CIKC_CLASS(o) ((CamelTextIndexKeyCursorClass *)(((CamelObject *)o)->classfuncs))
 -#define CIKC_PRIVATE(o) (((CamelTextIndexKeyCursor *)(o))->priv)
 +	priv = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (object);
 +
 +	g_free (priv->current);
 +
 +	/* Chain up to parent's finalize() method. */
 +	G_OBJECT_CLASS (text_index_key_cursor_parent_class)->finalize (object);
 +}
  
  static const gchar *
 -text_index_key_cursor_next(CamelIndexCursor *idc)
 +text_index_key_cursor_next (CamelIndexCursor *idc)
  {
 -	struct _CamelTextIndexKeyCursorPrivate *p = CIKC_PRIVATE(idc);
 +	CamelTextIndexKeyCursorPrivate *p = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (idc);
  
 -	c(printf("Going to next cursor for keyid %08x\n", p->keyid));
 +	c (printf ("Going to next cursor for keyid %08x\n", p->keyid));
  
 -	g_free(p->current);
 +	g_free (p->current);
  	p->current = NULL;
  
- 	while ( (p->keyid = camel_key_table_next (p->table, p->keyid, &p->current, &p->flags, &p->data, NULL)) ) {
 -	while ((p->keyid = camel_key_table_next(p->table, p->keyid, &p->current, &p->flags, &p->data))) {
++	while ((p->keyid = camel_key_table_next (p->table, p->keyid, &p->current, &p->flags, &p->data, NULL))) {
  		if ((p->flags & 1) == 0) {
  			return p->current;
  		} else {
@@@ -1980,35 -1852,35 +1980,35 @@@ gint main (gint argc, gchar **argv
  	for (i=0;i<100;i++) {
  		gchar name[16];
  
 -		sprintf(name, "%d", i);
 -		printf("Adding words to name '%s'\n", name);
 -		idn = camel_index_add_name(idx, name);
 -		camel_index_name_add_buffer(idn, wordbuffer, sizeof(wordbuffer)-1);
 -		camel_index_write_name(idx, idn);
 -		camel_object_unref((CamelObject *)idn);
 +		sprintf (name, "%d", i);
 +		printf ("Adding words to name '%s'\n", name);
 +		idn = camel_index_add_name (idx, name);
 +		camel_index_name_add_buffer (idn, wordbuffer, sizeof (wordbuffer)-1);
 +		camel_index_write_name (idx, idn);
 +		g_object_unref (idn);
  	}
  
 -	printf("Looking up which names contain word 'word'\n");
 -	idc = camel_index_find(idx, "words");
 -	while ((word = camel_index_cursor_next(idc)) != NULL) {
 -		printf(" name is '%s'\n", word);
 +	printf ("Looking up which names contain word 'word'\n");
 +	idc = camel_index_find (idx, "words");
- 	while ( (word = camel_index_cursor_next (idc)) != NULL ) {
++	while ((word = camel_index_cursor_next (idc)) != NULL) {
 +		printf (" name is '%s'\n", word);
  	}
 -	camel_object_unref((CamelObject *)idc);
 -	printf("done.\n");
 +	g_object_unref (idc);
 +	printf ("done.\n");
  
 -	printf("Looking up which names contain word 'truncate'\n");
 -	idc = camel_index_find(idx, "truncate");
 -	while ((word = camel_index_cursor_next(idc)) != NULL) {
 -		printf(" name is '%s'\n", word);
 +	printf ("Looking up which names contain word 'truncate'\n");
 +	idc = camel_index_find (idx, "truncate");
- 	while ( (word = camel_index_cursor_next (idc)) != NULL ) {
++	while ((word = camel_index_cursor_next (idc)) != NULL) {
 +		printf (" name is '%s'\n", word);
  	}
 -	camel_object_unref((CamelObject *)idc);
 -	printf("done.\n");
 +	g_object_unref (idc);
 +	printf ("done.\n");
  
 -	camel_index_sync(idx);
 -	camel_object_unref((CamelObject *)idx);
 +	camel_index_sync (idx);
 +	g_object_unref (idx);
  
  #if 0
 -	bs = camel_block_file_new("blocks", "TESTINDX", CAMEL_BLOCK_SIZE);
 +	bs = camel_block_file_new ("blocks", "TESTINDX", CAMEL_BLOCK_SIZE);
  
  	root = (struct _CamelIndexRoot *)bs->root;
  	if (root->word_root == 0) {
diff --cc camel/camel-uid-cache.c
index 8880f0a,ca219d4..8538c27
--- a/camel/camel-uid-cache.c
+++ b/camel/camel-uid-cache.c
@@@ -32,10 -32,9 +32,8 @@@
  #include <unistd.h>
  #include <sys/stat.h>
  
 -#include <glib.h>
  #include <glib/gstdio.h>
  
- #include <libedataserver/e-data-server-util.h>
- 
  #include "camel-file-utils.h"
  #include "camel-private.h"
  #include "camel-uid-cache.h"
diff --cc camel/providers/Makefile.am
index 0bd583b,5cdbafa..f67de7a
--- a/camel/providers/Makefile.am
+++ b/camel/providers/Makefile.am
@@@ -19,8 -15,6 +15,6 @@@ els
  SENDMAIL_DIR=sendmail
  endif
  
- SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap $(IMAPX_DIR) $(IMAP4_DIR) $(NNTP_DIR) local groupwise $(HULA_DIR)
- 
- 
 -SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap imapx $(IMAP4_DIR) $(NNTP_DIR) local groupwise $(HULA_DIR)
++SUBDIRS = pop3 $(SENDMAIL_DIR) smtp imap $(IMAP4_DIR) $(NNTP_DIR) local groupwise $(HULA_DIR)
  
  -include $(top_srcdir)/git.mk
diff --cc camel/providers/groupwise/camel-groupwise-folder.c
index 07677dc,9627fab..73cd4d8
--- a/camel/providers/groupwise/camel-groupwise-folder.c
+++ b/camel/providers/groupwise/camel-groupwise-folder.c
@@@ -758,23 -744,24 +758,23 @@@ groupwise_sync (CamelFolder *folder, gb
  
  	deleted_items = deleted_head = NULL;
  
 -	if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
 -		groupwise_sync_summary (folder, ex);
 -		return;
 +	if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
 +			((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
 +		return groupwise_sync_summary (folder, error);
  	}
- 	cnc = cnc_lookup (priv);
- 
- 	container_id =  camel_groupwise_store_container_id_lookup (gw_store, folder->full_name);
  
  	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 -	if (!camel_groupwise_store_connected (gw_store, ex)) {
 +	if (!camel_groupwise_store_connected (gw_store, NULL)) {
  		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 -		camel_exception_clear (ex);
 -		return;
 +		return TRUE;
  	}
  	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
  
+ 	cnc = cnc_lookup (priv);
+ 	container_id =  camel_groupwise_store_container_id_lookup (gw_store, folder->full_name);
+ 
  	if (folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED)
 -		return;
 +		return TRUE;
  
  	count = camel_folder_summary_count (folder->summary);
  	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
diff --cc camel/providers/groupwise/camel-groupwise-provider.c
index 4792e7e,a42190e..19c339f
--- a/camel/providers/groupwise/camel-groupwise-provider.c
+++ b/camel/providers/groupwise/camel-groupwise-provider.c
@@@ -120,10 -126,16 +120,15 @@@ voi
  camel_provider_module_init(void)
  {
  	CamelProvider *imap_provider = NULL;
 -	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
  	gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
  
- 	if (use_imap)
- 	    imap_provider =  camel_provider_get("imap://", NULL);
+ 	if (use_imap) {
+ #ifdef ENABLE_IMAPX
 -	    imap_provider = camel_provider_get("imapx://", &ex);
++	    imap_provider = camel_provider_get("imapx://", NULL);
+ #else
 -	    imap_provider = camel_provider_get("imap://", &ex);
++	    imap_provider = camel_provider_get("imap://", NULL);
+ #endif
+ 	}
  
  	groupwise_provider.url_hash = groupwise_url_hash;
  	groupwise_provider.url_equal = groupwise_url_equal;
diff --cc camel/providers/groupwise/camel-groupwise-store.c
index 86270ab,cc82de4..420ad4b
--- a/camel/providers/groupwise/camel-groupwise-store.c
+++ b/camel/providers/groupwise/camel-groupwise-store.c
@@@ -92,29 -93,19 +92,22 @@@ groupwise_store_construct (CamelServic
  
  	d(printf ("\nin groupwise store constrcut\n"));
  
 -	CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
 -	if (camel_exception_is_set (ex))
 -		return;
 +	/* Chain up to parent's construct() method. */
 +	service_class = CAMEL_SERVICE_CLASS (parent_class);
 +	if (!service_class->construct (service, session, provider, url, error))
 +		return FALSE;
  
  	if (!(url->host || url->user)) {
 -		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
 -				     _("Host or user not available in url"));
 +		g_set_error (
 +			error, CAMEL_SERVICE_ERROR,
 +			CAMEL_SERVICE_ERROR_INVALID,
 +			_("Host or user not available in url"));
  	}
  
- 	/*XXX: The number 3 assigned to the list_loaded variable denotes
- 	 * the number of times the get_folder_info is called during startup.
- 	 * We are just trying to minimize the call.
- 	 * This is a dirty hack. But it *WORKS*
- 	 */
- 	groupwise_store->list_loaded = 3;
- 
  	/*storage path*/
 -	priv->storage_path = camel_session_get_storage_path (session, service, ex);
 +	priv->storage_path = camel_session_get_storage_path (session, service, error);
  	if (!priv->storage_path)
 -		return;
 +		return FALSE;
  
  	/*store summary*/
  	path = g_alloca (strlen (priv->storage_path) + 32);
@@@ -1024,10 -983,10 +1012,10 @@@ groupwise_folders_sync (CamelGroupwiseS
  
  		if (e_gw_container_is_root(container))
  			continue;
- 		if ( (type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS) )
+ 		if ((type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS))
  			continue;
  
 -		info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const gchar *)url, ex);
 +		info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const gchar *)url, error);
  		if (info) {
  			hfi = g_hash_table_lookup (present, info->full_name);
  			if (hfi == NULL)
@@@ -1161,80 -1118,32 +1149,31 @@@ static CamelSessionThreadOps store_refr
  /*** Thread stuff ends ***/
  
  static CamelFolderInfo *
 -groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
 +groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error)
  {
  	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
- 	CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
  	CamelFolderInfo *info = NULL;
- 	gchar *top_folder = NULL;
- 
- 	if (top) {
- 		top_folder = g_hash_table_lookup (priv->name_hash, top);
- 		/* 'top' is a valid path, but doesnt have a container id
- 		 *  return NULL */
- /*		if (!top_folder) {
- 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- 					_("You must be working online to complete this operation"));
- 			return NULL;
- 		}*/
- 	}
  
- 	if (top && groupwise_is_system_folder (top))
- 		return groupwise_build_folder_info (groupwise_store, NULL, top );
+ 	/* Do not call groupwise_store_connected function as it would internall call folders_sync 
+ 	   to populate the hash table which is used for mapping container id */
+ 	if (!(((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
 -	    && camel_service_connect ((CamelService *)store, ex)))
++	    && camel_service_connect ((CamelService *)store, error)))
+ 		goto offline;
  
- 	/*
- 	 * Thanks to Michael, for his cached folders implementation in IMAP
- 	 * is used as is here.
- 	 */
- 	if (camel_store_summary_count ((CamelStoreSummary *)groupwise_store->summary) == 0) {
- 		GError *local_error = NULL;
+ 	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 -	
 -	groupwise_folders_sync (groupwise_store, ex);
 -	if (camel_exception_is_set (ex)) {
 +
- 		CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- 		if (groupwise_store->list_loaded == 3) {
- 			groupwise_folders_sync (groupwise_store, &local_error);
- 			groupwise_store->list_loaded -= 1;
- 		}
- 		if (local_error != NULL) {
- 			camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
- 			CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- 			g_propagate_error (error, local_error);
- 			return NULL;
- 		}
++	if (!groupwise_folders_sync (groupwise_store, error)) {
  		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- 		camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
- 		goto end_r;
+ 		return NULL;
  	}
  
- 	if ((camel_store_summary_count((CamelStoreSummary *)groupwise_store->summary) > 0) && (groupwise_store->list_loaded > 1)) {
- 		/*Load from cache*/
- 		groupwise_store->list_loaded -= 1;
- 		goto end_r;
- 	}
+ 	camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
+ 	camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
 -	
 +
- 	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
- 	if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, error)) {
- 		if (!priv->cnc) {
- 			if (groupwise_connect ((CamelService *)store, error)) {
- 				g_warning ("Could connect!!!\n");
- 			} else
- 				g_warning ("Could not connect..failure connecting\n");
- 		}
- 		if (camel_groupwise_store_connected (groupwise_store, error)) {
- 			if (groupwise_store->current_folder)
- 				CAMEL_FOLDER_GET_CLASS (groupwise_store->current_folder)->sync (groupwise_store->current_folder, FALSE, error);
- 			if (!groupwise_folders_sync (groupwise_store, error)) {
- 				CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
- 				return NULL;
- 			}
- 			camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
- 			camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
- 		}
- 	}
  	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
  
- 	/*camel_exception_clear (ex);*/
- end_r:
+ offline:
 -	info = groupwise_get_folder_info_offline (store, top, flags, ex);
 +	info = groupwise_get_folder_info_offline (store, top, flags, error);
  	return info;
  }
  
diff --cc camel/providers/imap/camel-imap-folder.c
index d0dfe86,4c3ebaf..a1a7fb3
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@@ -36,10 -36,31 +36,9 @@@
  
  #include <glib/gi18n-lib.h>
  
- #include <libedataserver/e-data-server-util.h>
  #include <libedataserver/e-time-utils.h>
  
 -#include "camel-db.h"
 -#include "camel-data-wrapper.h"
 -#include "camel-debug.h"
 -#include "camel-imap-journal.h"
 -#include "camel-exception.h"
 -#include "camel-file-utils.h"
 -#include "camel-mime-filter-crlf.h"
 -#include "camel-mime-filter-from.h"
 -#include "camel-mime-message.h"
 -#include "camel-mime-utils.h"
 -#include "camel-mime-part-utils.h"
 -#include "camel-multipart-encrypted.h"
 -#include "camel-multipart-signed.h"
 -#include "camel-multipart.h"
 -#include "camel-operation.h"
  #include "camel-private.h"
 -#include "camel-session.h"
 -#include "camel-store-summary.h"
 -#include "camel-stream-buffer.h"
 -#include "camel-stream-filter.h"
 -#include "camel-stream-mem.h"
 -#include "camel-stream.h"
 -#include "camel-string-utils.h"
  
  #include "camel-imap-command.h"
  #include "camel-imap-folder.h"
diff --cc camel/providers/imap/camel-imap-store.c
index 1c38beb,77cd364..6b1da66
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@@ -2581,55 -2537,59 +2583,61 @@@ get_folders_sync (CamelImapStore *imap_
  		pattern = "";
  
  	for (ns = imap_store->summary->namespace; ns; ns = ns->next) {
- 		gchar *tmp = NULL;
- 
- 		if (!ppattern) {
- 			if (!ns->full_name || !*ns->full_name)
- 				tmp = g_strdup ("*");
- 			else
- 				tmp = g_strdup_printf ("%s%c*", ns->full_name, ns->sep);
- 			pattern = tmp;
- 		}
+ 		for (k = 0; k < 2; k++) {
+ 			gchar *tmp = NULL;
  
- 		for (j = 0; j < 2; j++) {
- 			response = camel_imap_command (imap_store, NULL, error,
- 							"%s \"\" %G", j==1 ? "LSUB" : "LIST",
- 							pattern);
- 			if (!response) {
- 				success = FALSE;
- 				goto fail;
+ 			if (!ppattern) {
+ 				if (!ns->full_name || !*ns->full_name) {
+ 					tmp = g_strdup ("*");
+ 					if (k == 1)
+ 						break;
+ 				} else if (k == 0)
+ 					tmp = g_strdup_printf ("%s%c", ns->full_name, ns->sep);
+ 				else
+ 					tmp = g_strdup_printf ("%s%c*", ns->full_name, ns->sep);
+ 				pattern = tmp;
  			}
  
- 			for (i = 0; i < response->untagged->len; i++) {
- 				list = response->untagged->pdata[i];
- 				fi = parse_list_response_as_folder_info (imap_store, list);
- 				if (fi && *fi->full_name) {
- 					hfi = g_hash_table_lookup(present, fi->full_name);
- 					if (hfi == NULL) {
- 						if (j == 1) {
- 							fi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
- 							if ((fi->flags & (CAMEL_IMAP_FOLDER_MARKED | CAMEL_IMAP_FOLDER_UNMARKED)))
- 								imap_store->capabilities |= IMAP_CAPABILITY_useful_lsub;
+ 			for (j = 0; j < 2; j++) {
 -				response = camel_imap_command (imap_store, NULL, ex,
++				response = camel_imap_command (imap_store, NULL, error,
+ 								"%s \"\" %G", j==1 ? "LSUB" : "LIST",
+ 								pattern);
 -				if (!response)
++				if (!response) {
++					success = FALSE;
+ 					goto fail;
++				}
+ 
+ 				for (i = 0; i < response->untagged->len; i++) {
+ 					list = response->untagged->pdata[i];
+ 					fi = parse_list_response_as_folder_info (imap_store, list);
+ 					if (fi && *fi->full_name) {
+ 						hfi = g_hash_table_lookup(present, fi->full_name);
+ 						if (hfi == NULL) {
+ 							if (j == 1) {
+ 								fi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
+ 								if ((fi->flags & (CAMEL_IMAP_FOLDER_MARKED | CAMEL_IMAP_FOLDER_UNMARKED)))
+ 									imap_store->capabilities |= IMAP_CAPABILITY_useful_lsub;
+ 							}
+ 							g_hash_table_insert(present, fi->full_name, fi);
+ 						} else {
+ 							if (j == 1)
+ 								hfi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
+ 							camel_folder_info_free(fi);
  						}
- 						g_hash_table_insert(present, fi->full_name, fi);
- 					} else {
- 						if (j == 1)
- 							hfi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
- 						camel_folder_info_free(fi);
+ 					} else if (fi) {
+ 						camel_folder_info_free (fi);
  					}
- 				} else if (fi) {
- 					camel_folder_info_free (fi);
  				}
- 			}
  
- 			camel_imap_response_free (imap_store, response);
- 		}
+ 				camel_imap_response_free (imap_store, response);
+ 			}
  
- 		g_free (tmp);
+ 			g_free (tmp);
  
- 		/* look for matching only, if ppattern was non-NULL */
- 		if (ppattern)
- 			break;
+ 			/* look for matching only, if ppattern was non-NULL */
+ 			if (ppattern)
+ 				break;
+ 		}
  	}
  
  	/* Sync summary to match */
@@@ -2743,17 -2705,26 +2751,26 @@@ static voi
  refresh_refresh(CamelSession *session, CamelSessionThreadMsg *msg)
  {
  	struct _refresh_msg *m = (struct _refresh_msg *)msg;
+ 	CamelImapStore *store = (CamelImapStore *)m->store;
  
- 	CAMEL_SERVICE_REC_LOCK(m->store, connect_lock);
+ 	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
  
 -	if (!camel_imap_store_connected (store, &m->ex))
 +	if (!camel_imap_store_connected((CamelImapStore *)m->store, &m->error))
  		goto done;
  
+ 	if (store->users_namespace && store->users_namespace[0]) {
 -		get_folders_sync (store, "INBOX", &m->ex);
 -		if (camel_exception_is_set (&m->ex))
++		get_folders_sync (store, "INBOX", &m->error);
++		if (m->error != NULL)
+ 			goto done;
+ 	} else {
 -		get_folders_sync (store, "*", &m->ex);
++		get_folders_sync (store, "*", &m->error);
+ 	}
+ 
  	/* look in all namespaces */
 -	get_folders_sync (store, NULL, &m->ex);
 -	camel_store_summary_save ((CamelStoreSummary *)store->summary);
 +	get_folders_sync((CamelImapStore *)m->store, NULL, &m->error);
 +	camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)m->store)->summary);
  done:
- 	CAMEL_SERVICE_REC_UNLOCK(m->store, connect_lock);
+ 	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
  }
  
  static void
diff --cc camel/providers/imap/camel-imap-wrapper.c
index 26550fd,c7c7f17..5143c7c
--- a/camel/providers/imap/camel-imap-wrapper.c
+++ b/camel/providers/imap/camel-imap-wrapper.c
@@@ -103,7 -141,10 +103,8 @@@ imap_wrapper_write_to_stream (CamelData
  
  		datastream = camel_imap_folder_fetch_data (
  			imap_wrapper->folder, imap_wrapper->uid,
 -			imap_wrapper->part_spec, FALSE, &ex);
 -
 -		camel_exception_clear (&ex);
 +			imap_wrapper->part_spec, FALSE, NULL);
+ 
  		if (!datastream) {
  			CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
  #ifdef ENETUNREACH
@@@ -173,12 -171,16 +174,14 @@@ camel_imap_wrapper_new (CamelImapFolde
  			CamelMimePart *part)
  {
  	CamelImapWrapper *imap_wrapper;
 -	CamelStore *store = (((CamelFolder *) imap_folder)->parent_store);
  	CamelStream *stream;
+ 	gboolean sync_offline = FALSE;
  
 -	sync_offline = (camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL ||
 -					((CamelOfflineFolder *)imap_folder)->sync_offline);
 +	imap_wrapper = g_object_new (CAMEL_TYPE_IMAP_WRAPPER, NULL);
  
 -	imap_wrapper = (CamelImapWrapper *)camel_object_new(camel_imap_wrapper_get_type());
++	imap_wrapper = (CamelImapWrapper *)g_object_new (camel_imap_wrapper_get_type(), NULL);
  	camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER (imap_wrapper), type);
- 	((CamelDataWrapper *)imap_wrapper)->offline = TRUE;
+ 	((CamelDataWrapper *)imap_wrapper)->offline = !sync_offline;
  	((CamelDataWrapper *)imap_wrapper)->encoding = encoding;
  
  	imap_wrapper->folder = imap_folder;
@@@ -189,12 -191,13 +192,13 @@@
  	/* Don't ref this, it's our parent. */
  	imap_wrapper->part = part;
  
- 	/* Try the cache. */
+ 	/* Download the attachments if sync_offline is set, else skip them by checking only in cache */
  	stream = camel_imap_folder_fetch_data (imap_folder, uid, part_spec,
- 					       TRUE, NULL);
+ 			!sync_offline, NULL);
+ 
  	if (stream) {
  		imap_wrapper_hydrate (imap_wrapper, stream);
 -		camel_object_unref (stream);
 +		g_object_unref (stream);
  	}
  
  	return (CamelDataWrapper *)imap_wrapper;
diff --cc camel/providers/imap4/camel-imap4-folder.c
index 30af417,0e388fb..48362a9
--- a/camel/providers/imap4/camel-imap4-folder.c
+++ b/camel/providers/imap4/camel-imap4-folder.c
@@@ -365,9 -374,9 +365,9 @@@ camel_imap4_folder_new (CamelStore *sto
  
  	folder->summary = camel_imap4_summary_new (folder);
  	imap4_folder->cachedir = imap4_store_build_filename (store, folder->full_name);
- 	g_mkdir_with_parents (imap4_folder->cachedir, 0777);
+ 	g_mkdir_with_parents (imap4_folder->cachedir, 0700);
  
 -	imap4_folder->cache = camel_data_cache_new (imap4_folder->cachedir, 0, NULL);
 +	imap4_folder->cache = camel_data_cache_new (imap4_folder->cachedir, NULL);
  
  	path = imap4_get_summary_filename (imap4_folder->cachedir);
  	camel_folder_summary_set_filename (folder->summary, path);
diff --cc camel/providers/imapx/camel-imapx-folder.c
index bf05fcb,002282a..240e7c2
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@@ -26,7 -26,9 +26,8 @@@
  #endif
  
  #include <errno.h>
+ #include <glib/gi18n-lib.h>
  
 -#include "camel/camel-exception.h"
  #include "camel/camel-stream-mem.h"
  #include "camel/camel-stream-filter.h"
  #include "camel/camel-mime-message.h"
@@@ -126,10 -155,15 +154,15 @@@ imapx_expunge (CamelFolder *folder, Cam
  }
  
  static void
 -imapx_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 +imapx_sync (CamelFolder *folder, gboolean expunge, GError **error)
  {
  	CamelIMAPXStore *is = (CamelIMAPXStore *)folder->parent_store;
- 	GPtrArray *changed_uids;
+ 
+ 	if (CAMEL_OFFLINE_STORE (is)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+ 		return;
+ 
+ 	if (is->server && camel_imapx_server_connect (is->server, 1))
+ 		camel_imapx_server_sync_changes (is->server, folder, ex);
  
  	/* Sync twice - make sure deleted flags are written out,
  	   then sync again incase expunge changed anything */
@@@ -153,29 -176,48 +175,48 @@@
  }
  
  static CamelMimeMessage *
 -imapx_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 +imapx_get_message (CamelFolder *folder, const gchar *uid, GError **error)
  {
  	CamelMimeMessage *msg = NULL;
- 	CamelStream *stream;
- 	CamelIMAPXStore *is = (CamelIMAPXStore *)folder->parent_store;
+ 	CamelStream *stream = NULL;
+ 	CamelIMAPXStore *istore = (CamelIMAPXStore *)folder->parent_store;
+ 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
+ 	const gchar *path = NULL;
+ 	gboolean offline_message = FALSE;
+ 
+ 	if (!strchr (uid, '-'))
+ 		path = "cur";
+ 	else {
+ 		path = "new";
+ 		offline_message = TRUE;
+ 	}
  
- 	if (is->server) {
- 		stream = camel_imapx_server_get_message(is->server, folder, uid, ex);
- 		if (stream) {
- 			msg = camel_mime_message_new();
- 			if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == -1) {
- 				camel_exception_setv(ex, 1, "error building message?");
- 				camel_object_unref(msg);
- 				msg = NULL;
- 			}
- 			camel_object_unref(stream);
+ 	stream = camel_data_cache_get (ifolder->cache, path, uid, NULL);
+ 	if (!stream) {
+ 		if (offline_message) {
+ 			camel_exception_setv(ex, 2, "Offline message vanished from disk: %s", uid);
+ 			return NULL;
+ 		}
+ 
+ 		if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+ 			return NULL;
+ 
+ 		if (istore->server && camel_imapx_server_connect (istore->server, 1)) {
+ 			stream = camel_imapx_server_get_message(istore->server, folder, uid, ex);
+ 		} else {
+ 			camel_exception_setv(ex, 1, "not authenticated");
+ 			return NULL;
  		}
- 	} else {
- 		camel_exception_setv(ex, 1, "not ready");
+ 	}
+ 
+ 	if (!camel_exception_is_set (ex)) {
+ 		msg = camel_mime_message_new();
+ 		if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == -1) {
+ 			camel_exception_setv(ex, 1, "error building message?");
+ 			camel_object_unref(msg);
+ 			msg = NULL;
+ 		}
+ 		camel_object_unref(stream);
  	}
  
  	return msg;
diff --cc camel/providers/imapx/camel-imapx-server.c
index ce3eedc,bbd03a8..0fa3dff
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@@ -905,76 -990,9 +990,9 @@@ found
  	return job;
  }
  
- /* Process all expunged results we had from the last command.
-    This can be somewhat slow ... */
- static void
- imapx_expunged(CamelIMAPXServer *imap)
- {
- //	gint count = 1, index=0, expunge;
- 
- 	g_assert(imap->select_folder);
- 
- 	if (imap->expunged->len == 0)
- 		return;
- 
- 	printf("Processing '%d' expunges\n", imap->expunged->len);
- 
- /*	Change implementation
- 
- 	expunge = g_array_index(imap->expunged, guint32, index++);
- 	iter = camel_folder_summary_search(imap->select_folder->summary, NULL, NULL, NULL, NULL);
- 	while ((iterinfo = camel_iterator_next(iter, NULL))) {
- 		if (count == expunge) {
- 			printf("expunging '%d' - '%s'\n", expunge, camel_message_info_subject(iterinfo));
- 			camel_folder_summary_remove(imap->select_folder->summary, (CamelMessageInfo *)iterinfo);
- 			if (index >= imap->expunged->len)
- 				break;
- 			expunge = g_array_index(imap->expunged, guint32, index++);
- 		} else
- 			//FIXME: skip over offline uids
- 			count++;
- 	}
- 	camel_iterator_free(iter);
- 	g_array_set_size(imap->expunged, 0); */
- }
- 
- static void
- update_summary (CamelFolderSummary *summary, CamelMessageInfoBase *info)
- {
- 	gint unread=0, deleted=0, junk=0;
- 	guint32 flags = info->flags;
- 
- 	if (!(flags & CAMEL_MESSAGE_SEEN))
- 		unread = 1;
- 
- 	if (flags & CAMEL_MESSAGE_DELETED)
- 		deleted = 1;
- 
- 	if (flags & CAMEL_MESSAGE_JUNK)
- 		junk = 1;
- 
- 	if (summary) {
- 
- 		if (unread)
- 			summary->unread_count += unread;
- 		if (deleted)
- 			summary->deleted_count += deleted;
- 		if (junk)
- 			summary->junk_count += junk;
- 		if (junk && !deleted)
- 			summary->junk_not_deleted_count += junk;
- 		summary->visible_count++;
- 		if (junk ||  deleted)
- 			summary->visible_count -= junk ? junk : deleted;
- 
- 		summary->saved_count++;
- 		camel_folder_summary_touch(summary);
- 	}
- }
- 
  /* handle any untagged responses */
  static gint
 -imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 +imapx_untagged(CamelIMAPXServer *imap, GError **error)
  {
  	guint id, len;
  	guchar *token, *p, c;
@@@ -1410,9 -1577,9 +1577,9 @@@ imapx_step(CamelIMAPXServer *is, CamelE
  }
  
  /* Used to run 1 command synchronously,
-    use for capa, login, and selecting only. */
+    use for capa, login, and namespaces only. */
  static void
 -imapx_command_run(CamelIMAPXServer *is, CamelIMAPXCommand *ic, CamelException *ex)
 +imapx_command_run(CamelIMAPXServer *is, CamelIMAPXCommand *ic, GError **error)
  /* throws IO,PARSE exception */
  {
  	camel_imapx_command_close(ic);
diff --cc camel/providers/imapx/camel-imapx-server.h
index 8a4622d,5d98ef1..760d6aa
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@@ -100,13 -110,15 +110,15 @@@ CamelIMAPXServer *camel_imapx_server_ne
  
  gboolean camel_imapx_server_connect(CamelIMAPXServer *is, gint state);
  
 -GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, CamelException *ex);
 +GPtrArray *camel_imapx_server_list(CamelIMAPXServer *is, const gchar *top, guint32 flags, GError **error);
  
- void camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, struct _GError **error);
- void camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, GPtrArray *infos, GError **error);
- void camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, GError **error);
+ void camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelException *ex);
+ void camel_imapx_server_sync_changes(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
+ void camel_imapx_server_expunge(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
+ void camel_imapx_server_noop (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex);
  
- CamelStream *camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, struct _GError **error);
- void camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelMimeMessage *message, const struct _CamelMessageInfo *mi, GError **error);
+ CamelStream *camel_imapx_server_get_message(CamelIMAPXServer *is, CamelFolder *folder, const gchar *uid, struct _CamelException *ex);
+ void camel_imapx_server_copy_message (CamelIMAPXServer *is, CamelFolder *source, CamelFolder *dest, GPtrArray *uids, gboolean delete_originals, CamelException *ex);
+ void camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, struct _CamelMimeMessage *message, const struct _CamelMessageInfo *mi, CamelException *ex);
  
- #endif /* ! _CAMEL_IMAPX_SERVER_H */
+ #endif /* _CAMEL_IMAPX_SERVER_H */
diff --cc camel/providers/imapx/camel-imapx-stream.h
index f7177ef,174c2cf..eaab31e
--- a/camel/providers/imapx/camel-imapx-stream.h
+++ b/camel/providers/imapx/camel-imapx-stream.h
@@@ -76,20 -76,20 +76,20 @@@ gint		 camel_imapx_stream_getl		(CamelI
  /* all throw IO,PARSE exceptions */
  
  /* gets an atom, upper-cases */
 -gint		 camel_imapx_stream_atom		(CamelIMAPXStream *is, guchar **start, guint *len, CamelException *ex);
 +gint		 camel_imapx_stream_atom		(CamelIMAPXStream *is, guchar **start, guint *len, GError **error);
  /* gets an atom or string */
 -gint		 camel_imapx_stream_astring	(CamelIMAPXStream *is, guchar **start, CamelException *ex);
 +gint		 camel_imapx_stream_astring	(CamelIMAPXStream *is, guchar **start, GError **error);
  /* gets a NIL or a string, start==NULL if NIL */
 -gint		 camel_imapx_stream_nstring	(CamelIMAPXStream *is, guchar **start, CamelException *ex);
 +gint		 camel_imapx_stream_nstring	(CamelIMAPXStream *is, guchar **start, GError **error);
  /* gets a NIL or string into a stream, stream==NULL if NIL */
 -gint		 camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, CamelException *ex);
 +gint		 camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, GError **error);
  /* gets 'text' */
 -gint		 camel_imapx_stream_text		(CamelIMAPXStream *is, guchar **text, CamelException *ex);
 +gint		 camel_imapx_stream_text		(CamelIMAPXStream *is, guchar **text, GError **error);
  
  /* gets a 'number' */
 -guint32		 camel_imapx_stream_number(CamelIMAPXStream *is, CamelException *ex);
 +guint32		 camel_imapx_stream_number(CamelIMAPXStream *is, GError **error);
  
  /* skips the rest of a line, including literals, etc */
 -gint camel_imapx_stream_skip(CamelIMAPXStream *is, CamelException *ex);
 +gint camel_imapx_stream_skip(CamelIMAPXStream *is, GError **error);
  
- #endif /* ! _CAMEL_IMAPX_STREAM_H */
+ #endif /* _CAMEL_IMAPX_STREAM_H */
diff --cc camel/providers/local/camel-mbox-store.c
index 0923b1b,c7a7ef7..af7b199
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@@ -531,13 -490,11 +531,13 @@@ rename_folder(CamelStore *store, const 
  	newibex = camel_local_store_get_meta_path(store, new, ".ibex");
  
  	newdir = g_path_get_dirname(newibex);
- 	if (g_mkdir_with_parents(newdir, 0777) == -1) {
+ 	if (g_mkdir_with_parents(newdir, 0700) == -1) {
  		if (errno != EEXIST) {
 -			camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
 -					     _("Could not rename '%s': '%s': %s"),
 -					     old, new, g_strerror(errno));
 +			g_set_error (
 +				error, G_FILE_ERROR,
 +				g_file_error_from_errno (errno),
 +				_("Could not rename '%s': '%s': %s"),
 +				old, new, g_strerror(errno));
  			g_free(oldibex);
  			g_free(newibex);
  			g_free(newdir);
diff --cc camel/providers/nntp/camel-nntp-folder.c
index 62fa70e,b20ccff..6fba7af
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@@ -563,9 -536,9 +563,9 @@@ camel_nntp_folder_new (CamelStore *pare
  		return NULL;
  
  	/* If this doesn't work, stuff wont save, but let it continue anyway */
- 	g_mkdir_with_parents (root, 0777);
+ 	g_mkdir_with_parents (root, 0700);
  
 -	folder = (CamelFolder *) camel_object_new (CAMEL_NNTP_FOLDER_TYPE);
 +	folder = g_object_new (CAMEL_TYPE_NNTP_FOLDER, NULL);
  	nntp_folder = (CamelNNTPFolder *)folder;
  
  	camel_folder_construct (folder, parent, folder_name, folder_name);
diff --cc camel/providers/nntp/camel-nntp-store.c
index c0705a4,6e20bff..29d55c9
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@@ -1412,13 -1375,13 +1412,13 @@@ camel_nntp_command (CamelNNTPStore *sto
  		retry ++;
  
  		if (store->stream == NULL
 -		    && !camel_service_connect (CAMEL_SERVICE (store), ex))
 +		    && !camel_service_connect (CAMEL_SERVICE (store), error))
  			return -1;
  
- 		/* Check for unprocessed data, ! */
+ 		/* Check for unprocessed data, !*/
  		if (store->stream->mode == CAMEL_NNTP_STREAM_DATA) {
  			g_warning("Unprocessed data left in stream, flushing");
 -			while (camel_nntp_stream_getd(store->stream, (guchar **)&p, &u) > 0)
 +			while (camel_nntp_stream_getd(store->stream, (guchar **)&p, &u, NULL) > 0)
  				;
  		}
  		camel_nntp_stream_set_mode(store->stream, CAMEL_NNTP_STREAM_LINE);
diff --cc camel/providers/pop3/camel-pop3-store.c
index 87ed14c,ecff22e..3602534
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@@ -44,77 -60,83 +44,80 @@@
  #define POP3_PORT "110"
  #define POP3S_PORT "995"
  
+ /* defines the length of the server error message we can display in the error dialog */
+ #define POP3_ERROR_SIZE_LIMIT 60
+ 
 -static CamelStoreClass *parent_class = NULL;
 -
 -static void finalize (CamelObject *object);
 +static gpointer parent_class;
  
 -static gboolean pop3_connect (CamelService *service, CamelException *ex);
 -static gboolean pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex);
 -static GList *query_auth_types (CamelService *service, CamelException *ex);
 +static gboolean pop3_connect (CamelService *service, GError **error);
 +static gboolean pop3_disconnect (CamelService *service, gboolean clean, GError **error);
 +static GList *query_auth_types (CamelService *service, GError **error);
  
  static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
 -				guint32 flags, CamelException *ex);
 +				guint32 flags, GError **error);
  
 -static CamelFolder *get_trash  (CamelStore *store, CamelException *ex);
 +static CamelFolder *get_trash  (CamelStore *store, GError **error);
  
 -static gboolean pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
 +static gboolean pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error);
  
  static void
 -camel_pop3_store_class_init (CamelPOP3StoreClass *camel_pop3_store_class)
 +pop3_store_finalize (GObject *object)
  {
 -	CamelServiceClass *camel_service_class =
 -		CAMEL_SERVICE_CLASS (camel_pop3_store_class);
 -	CamelStoreClass *camel_store_class =
 -		CAMEL_STORE_CLASS (camel_pop3_store_class);
 +	CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (object);
  
 -	parent_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ()));
 +	/* force disconnect so we dont have it run later, after we've cleaned up some stuff */
 +	/* SIGH */
  
 -	/* virtual method overload */
 -	camel_service_class->query_auth_types = query_auth_types;
 -	camel_service_class->connect = pop3_connect;
 -	camel_service_class->disconnect = pop3_disconnect;
 +	camel_service_disconnect((CamelService *)pop3_store, TRUE, NULL);
  
 -	camel_store_class->get_folder = get_folder;
 -	camel_store_class->get_trash = get_trash;
 -	camel_store_class->can_refresh_folder = pop3_can_refresh_folder;
 -}
 +	if (pop3_store->engine)
 +		g_object_unref (pop3_store->engine);
 +	if (pop3_store->cache)
 +		g_object_unref (pop3_store->cache);
  
 -static void
 -camel_pop3_store_init (gpointer object, gpointer klass)
 -{
 -	;
 +	/* Chain up to parent's finalize() method. */
 +	G_OBJECT_CLASS (parent_class)->finalize (object);
  }
  
 -CamelType
 -camel_pop3_store_get_type (void)
 +static void
 +pop3_store_class_init (CamelPOP3StoreClass *class)
  {
 -	static CamelType camel_pop3_store_type = CAMEL_INVALID_TYPE;
 -
 -	if (!camel_pop3_store_type) {
 -		camel_pop3_store_type = camel_type_register (CAMEL_STORE_TYPE,
 -							     "CamelPOP3Store",
 -							     sizeof (CamelPOP3Store),
 -							     sizeof (CamelPOP3StoreClass),
 -							     (CamelObjectClassInitFunc) camel_pop3_store_class_init,
 -							     NULL,
 -							     (CamelObjectInitFunc) camel_pop3_store_init,
 -							     finalize);
 -	}
 +	GObjectClass *object_class;
 +	CamelServiceClass *service_class;
 +	CamelStoreClass *store_class;
  
 -	return camel_pop3_store_type;
 -}
 +	parent_class = g_type_class_peek_parent (class);
  
 -static void
 -finalize (CamelObject *object)
 -{
 -	CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (object);
 +	object_class = G_OBJECT_CLASS (class);
 +	object_class->finalize = pop3_store_finalize;
  
 -	/* force disconnect so we dont have it run later, after we've cleaned up some stuff */
 -	/* SIGH */
 +	service_class = CAMEL_SERVICE_CLASS (class);
 +	service_class->query_auth_types = query_auth_types;
 +	service_class->connect = pop3_connect;
 +	service_class->disconnect = pop3_disconnect;
  
 -	camel_service_disconnect((CamelService *)pop3_store, TRUE, NULL);
 +	store_class = CAMEL_STORE_CLASS (class);
 +	store_class->get_folder = get_folder;
 +	store_class->get_trash = get_trash;
 +	store_class->can_refresh_folder = pop3_can_refresh_folder;
 +}
  
 -	if (pop3_store->engine)
 -		camel_object_unref((CamelObject *)pop3_store->engine);
 -	if (pop3_store->cache)
 -		camel_object_unref((CamelObject *)pop3_store->cache);
 +GType
 +camel_pop3_store_get_type (void)
 +{
 +	static GType type = G_TYPE_INVALID;
 +
 +	if (G_UNLIKELY (type == G_TYPE_INVALID))
 +		type = g_type_register_static_simple (
 +			CAMEL_TYPE_STORE,
 +			"CamelPOP3Store",
 +			sizeof (CamelPOP3StoreClass),
 +			(GClassInitFunc) pop3_store_class_init,
 +			sizeof (CamelPOP3Store),
 +			(GInstanceInitFunc) NULL,
 +			0);
 +
 +	return type;
  }
  
  enum {
@@@ -128,11 -150,27 +131,30 @@@
  #define STARTTLS_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_TLS)
  #endif
  
+ /* returns error message with ': ' as prefix */
+ static gchar *
+ get_valid_utf8_error (const gchar *text)
+ {
+ 	gchar *tmp = camel_utf8_make_valid (text);
+ 	gchar *ret = NULL;
+ 
+ 	/*TODO If the error message > size limit log it somewhere */
+ 	if (!tmp || g_utf8_strlen (tmp, -1) > POP3_ERROR_SIZE_LIMIT) {
+ 		g_free (tmp);
+ 		return NULL;
+ 	}
+ 
+ 	ret = g_strconcat (": ", tmp, NULL);
+ 
+ 	g_free (tmp);
+ 	return ret;
+ }
+ 
  static gboolean
 -connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
 +connect_to_server (CamelService *service,
 +                   struct addrinfo *ai,
 +                   gint ssl_mode,
 +                   GError **error)
  {
  	CamelPOP3Store *store = CAMEL_POP3_STORE (service);
  	CamelStream *tcp_stream;
@@@ -216,10 -256,13 +238,14 @@@
  	camel_pop3_engine_command_free (store->engine, pc);
  
  	if (ret == FALSE) {
 -		gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 -
 -		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 -				_("Failed to connect to POP server %s in secure mode%s"),
 -				service->url->host, tmp ? tmp:"");
++		gchar *tmp;
+ 
++		tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 +		g_set_error (
 +			error, CAMEL_ERROR, CAMEL_ERROR_SYSTEM,
 +			_("Failed to connect to POP server %s in secure mode: %s"),
- 			service->url->host, store->engine->line);
++			service->url->host, (tmp != NULL) ? tmp : "");
+ 		g_free (tmp);
  		goto stls_exception;
  	}
  
@@@ -417,11 -440,13 +443,18 @@@ try_sasl (CamelPOP3Store *store
  		if (strncmp((gchar *) line, "+OK", 3) == 0)
  			break;
  		if (strncmp((gchar *) line, "-ERR", 4) == 0) {
 -			gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 -
 -			camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
 -					      _("SASL '%s' Login failed for POP server %s%s"),
 -					      mech, CAMEL_SERVICE (store)->url->host, tmp ? tmp : "");
 -
++			gchar *tmp;
++
++			tmp = get_valid_utf8_error (
++				(gchar *) store->engine->line);
 +			g_set_error (
 +				error, CAMEL_SERVICE_ERROR,
 +				CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
 +				_("SASL '%s' Login failed for POP server %s: %s"),
- 				mech, CAMEL_SERVICE (store)->url->host, line);
++				mech, CAMEL_SERVICE (store)->url->host,
++				(tmp != NULL) ? tmp : "");
+ 			g_free (tmp);
++
  			goto done;
  		}
  		/* If we dont get continuation, or the sasl object's run out of work, or we dont get a challenge,
@@@ -557,38 -573,32 +590,42 @@@ pop3_try_authenticate (CamelService *se
  
  	if (status == -1) {
  		if (errno == EINTR) {
 -			camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
 +			g_set_error (
 +				error, CAMEL_ERROR,
 +				CAMEL_ERROR_USER_CANCEL, _("Canceled"));
  		} else {
 -			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 -					      _("Unable to connect to POP server %s.\n"
 -						"Error sending password: %s"),
 -					      CAMEL_SERVICE (store)->url->host,
 -					      errno ? g_strerror (errno) : _("Unknown error"));
 +			g_set_error (
 +				error, CAMEL_ERROR,
 +				CAMEL_ERROR_SYSTEM,
 +				_("Unable to connect to POP server %s.\n"
 +				  "Error sending password: %s"),
 +				CAMEL_SERVICE (store)->url->host, errno ?
 +				g_strerror (errno) : _("Unknown error"));
  		}
  	} else if (pcu && pcu->state != CAMEL_POP3_COMMAND_OK) {
 -		gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 -
 -		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
 -				      _("Unable to connect to POP server %s.\n"
 -					"Error sending username%s"),
 -				      CAMEL_SERVICE (store)->url->host,
 -				      tmp ? tmp : "");
++		gchar *tmp;
++
++		tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 +		g_set_error (
 +			error, CAMEL_SERVICE_ERROR,
 +			CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
 +			_("Unable to connect to POP server %s.\n"
 +			  "Error sending username: %s"),
 +			CAMEL_SERVICE (store)->url->host,
- 			store->engine->line ?
- 			(gchar *)store->engine->line :
- 			_("Unknown error"));
++			(tmp != NULL) ? tmp : "");
+ 		g_free (tmp);
  	} else if (pcp->state != CAMEL_POP3_COMMAND_OK) {
 -		gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 -
 -		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
 -				      _("Unable to connect to POP server %s.\n"
 -					"Error sending password%s"),
 -				      CAMEL_SERVICE (store)->url->host,
 -				      tmp ? tmp :"");
++		gchar *tmp;
++
++		tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 +		g_set_error (
 +			error, CAMEL_SERVICE_ERROR,
 +			CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
 +			_("Unable to connect to POP server %s.\n"
 +			  "Error sending password: %s"),
 +			CAMEL_SERVICE (store)->url->host,
- 			store->engine->line ?
- 			(gchar *)store->engine->line :
- 			_("Unknown error"));
++			(tmp != NULL) ? tmp : "");
+ 		g_free (tmp);
  	}
  
  	camel_pop3_engine_command_free (store->engine, pcp);
diff --cc docs/reference/camel/tmpl/camel-groupwise-store.sgml
index 8cef245,d34c10f..b8d4243
--- a/docs/reference/camel/tmpl/camel-groupwise-store.sgml
+++ b/docs/reference/camel/tmpl/camel-groupwise-store.sgml
@@@ -35,7 -35,7 +35,6 @@@ CamelGroupwiseStor
  @priv: 
  @current_folder: 
  @refresh_stamp: 
-- list_loaded: 
  
  <!-- ##### STRUCT CamelGroupwiseStorePrivate ##### -->
  <para>
diff --cc docs/reference/camel/tmpl/camel-unused.sgml
index 2305d45,f578a14..5ce4142
--- a/docs/reference/camel/tmpl/camel-unused.sgml
+++ b/docs/reference/camel/tmpl/camel-unused.sgml
@@@ -829,6 -484,6 +829,14 @@@ camel-type
  @value: 
  @Returns: 
  
++<!-- ##### FUNCTION camel_folder_set_lock_async ##### -->
++<para>
++
++</para>
++
++ folder: 
++ async: 
++
  <!-- ##### FUNCTION camel_folder_summary_array_free ##### -->
  <para>
  



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]