[evolution-data-server/mmeeks-gdbus-import: 249/250] Merge branch 'master' into mmeeks-gdbus-import



commit daa35fb210082efaf8b692faed568b7721025801
Merge: afc0563 b96be68
Author: Michael Meeks <michael meeks novell com>
Date:   Fri Feb 26 12:39:45 2010 +0000

    Merge branch 'master' into mmeeks-gdbus-import
    
    Conflicts:
    	addressbook/libebook/e-book.c
    	addressbook/tests/ebook/Makefile.am
    	addressbook/tests/ebook/ebook-test-utils.c
    	addressbook/tests/ebook/ebook-test-utils.h
    	addressbook/tests/ebook/test-ebook-add-contact.c
    	addressbook/tests/ebook/test-ebook-commit-contact.c
    	addressbook/tests/ebook/test-ebook-get-book-view.c
    	addressbook/tests/ebook/test-ebook-get-contact.c
    	addressbook/tests/ebook/test-ebook-get-required-fields.c
    	addressbook/tests/ebook/test-ebook-get-static-capabilities.c
    	addressbook/tests/ebook/test-ebook-get-supported-auth-methods.c
    	addressbook/tests/ebook/test-ebook-get-supported-fields.c
    	addressbook/tests/ebook/test-ebook-remove-contact-by-id.c
    	addressbook/tests/ebook/test-ebook-remove-contact.c
    	addressbook/tests/ebook/test-ebook-remove-contacts.c
    	addressbook/tests/ebook/test-ebook-remove.c
    	addressbook/tests/ebook/test-ebook-stress-factory--fifo.c
    	addressbook/tests/ebook/test-ebook-stress-factory--serial.c
    	addressbook/tests/ebook/test-ebook-stress-factory--single-book.c
    	calendar/libecal/e-cal.c
    	calendar/libedata-cal/e-cal-backend-sync.c
    	calendar/tests/ecal/ecal-test-utils.c
    	calendar/tests/ecal/ecal-test-utils.h
    	calendar/tests/ecal/test-ecal-add-timezone.c
    	calendar/tests/ecal/test-ecal-create-object--2.c
    	calendar/tests/ecal/test-ecal-create-object.c
    	calendar/tests/ecal/test-ecal-get-alarm-email-address.c
    	calendar/tests/ecal/test-ecal-get-cal-address.c
    	calendar/tests/ecal/test-ecal-get-capabilities.c
    	calendar/tests/ecal/test-ecal-get-default-object.c
    	calendar/tests/ecal/test-ecal-get-free-busy.c
    	calendar/tests/ecal/test-ecal-get-ldap-attribute.c
    	calendar/tests/ecal/test-ecal-get-object-list.c
    	calendar/tests/ecal/test-ecal-get-objects-for-uid.c
    	calendar/tests/ecal/test-ecal-get-query.c
    	calendar/tests/ecal/test-ecal-get-timezone.c
    	calendar/tests/ecal/test-ecal-modify-object.c
    	calendar/tests/ecal/test-ecal-open.c
    	calendar/tests/ecal/test-ecal-receive-objects.c
    	calendar/tests/ecal/test-ecal-remove-object.c
    	calendar/tests/ecal/test-ecal-remove.c
    	calendar/tests/ecal/test-ecal-send-objects.c
    	calendar/tests/ecal/test-ecal-set-default-timezone.c
    	calendar/tests/ecal/test-ecal-set-mode.c
    	calendar/tests/ecal/test-ecal-stress-factory--fifo.c
    	calendar/tests/ecal/test-ecal-stress-factory--open-async.c
    	calendar/tests/ecal/test-ecal-stress-factory--serial.c
    	calendar/tests/ecal/test-ecal-stress-factory--single-cal.c
    	camel/camel-net-utils.c
    	camel/providers/imapx/camel-imapx-folder.c
    	camel/providers/imapx/camel-imapx-folder.h
    	camel/providers/imapx/camel-imapx-server.c

 NEWS                                               |  295 ++
 addressbook/backends/file/e-book-backend-file.c    |   10 +-
 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    |  131 +-
 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                      |   73 +-
 addressbook/libebook/e-book.h                      |    2 +-
 addressbook/libebook/e-contact.c                   |  117 +-
 addressbook/libebook/e-destination.c               |   34 +-
 addressbook/libebook/e-error.h                     |    8 +-
 addressbook/libebook/e-name-western.c              |   16 +-
 addressbook/libebook/e-name-western.h              |    2 +-
 addressbook/libebook/e-vcard.c                     |   28 +-
 addressbook/libedata-book/Makefile.am              |    1 +
 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.c    |    8 +-
 addressbook/libedata-book/e-data-book-factory.h    |    2 +-
 addressbook/libedata-book/e-data-book-view.h       |    2 +-
 addressbook/libedata-book/e-data-book.c            |   62 +-
 addressbook/libedata-book/e-data-book.h            |    2 +-
 addressbook/tests/ebook/Makefile.am                |   19 +-
 addressbook/tests/ebook/ebook-test-utils.c         |   76 +-
 addressbook/tests/ebook/ebook-test-utils.h         |   41 +
 addressbook/tests/ebook/test-ebook-add-contact.c   |    4 +-
 .../tests/ebook/test-ebook-commit-contact.c        |    4 +-
 addressbook/tests/ebook/test-ebook-get-book-view.c |    2 +-
 addressbook/tests/ebook/test-ebook-get-contact.c   |    2 +-
 .../tests/ebook/test-ebook-get-required-fields.c   |    6 +-
 .../ebook/test-ebook-get-static-capabilities.c     |    2 +-
 .../ebook/test-ebook-get-supported-auth-methods.c  |    6 +-
 .../tests/ebook/test-ebook-get-supported-fields.c  |    6 +-
 .../tests/ebook/test-ebook-remove-contact-by-id.c  |   16 +-
 .../tests/ebook/test-ebook-remove-contact.c        |    3 +-
 .../tests/ebook/test-ebook-remove-contacts.c       |   14 +-
 addressbook/tests/ebook/test-ebook-remove.c        |    2 +-
 .../tests/ebook/test-ebook-stress-factory--fifo.c  |    2 +-
 .../ebook/test-ebook-stress-factory--serial.c      |    2 +-
 .../ebook/test-ebook-stress-factory--single-book.c |    2 +-
 calendar/backends/caldav/e-cal-backend-caldav.c    |  123 +-
 .../backends/contacts/e-cal-backend-contacts.c     |   63 +-
 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        |   79 +-
 calendar/backends/google/e-cal-backend-google.c    |   82 +-
 .../groupwise/e-cal-backend-groupwise-utils.c      |    7 +-
 .../backends/groupwise/e-cal-backend-groupwise.c   |   92 +-
 calendar/backends/http/e-cal-backend-http.c        |  155 +-
 calendar/backends/weather/e-cal-backend-weather.c  |  159 +-
 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.c                      |    5 +-
 calendar/libecal/e-cal-util.h                      |    1 +
 calendar/libecal/e-cal-view.c                      |    2 +-
 calendar/libecal/e-cal.c                           |  115 +-
 calendar/libecal/e-cal.h                           |    2 +
 calendar/libedata-cal/Makefile.am                  |    1 +
 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   |    8 +-
 .../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         |  141 +-
 calendar/libedata-cal/e-cal-backend-sync.h         |    7 +-
 calendar/libedata-cal/e-cal-backend.c              |   17 +
 calendar/libedata-cal/e-cal-backend.h              |    2 +
 calendar/libedata-cal/e-data-cal-factory.c         |    6 +-
 calendar/libedata-cal/e-data-cal.c                 |   29 +-
 calendar/libedata-cal/e-data-cal.h                 |    1 +
 calendar/libedata-cal/e-data-cal.xml               |    5 +
 calendar/tests/ecal/ecal-test-utils.c              |   70 +-
 calendar/tests/ecal/ecal-test-utils.h              |   59 +
 calendar/tests/ecal/test-ecal-add-timezone.c       |    4 +-
 calendar/tests/ecal/test-ecal-create-object--2.c   |    4 +-
 calendar/tests/ecal/test-ecal-create-object.c      |    4 +-
 .../tests/ecal/test-ecal-get-alarm-email-address.c |    4 +-
 calendar/tests/ecal/test-ecal-get-cal-address.c    |    4 +-
 calendar/tests/ecal/test-ecal-get-capabilities.c   |    2 +-
 calendar/tests/ecal/test-ecal-get-default-object.c |    4 +-
 calendar/tests/ecal/test-ecal-get-free-busy.c      |    2 +-
 calendar/tests/ecal/test-ecal-get-ldap-attribute.c |    4 +-
 calendar/tests/ecal/test-ecal-get-object-list.c    |    4 +-
 .../tests/ecal/test-ecal-get-objects-for-uid.c     |    4 +-
 calendar/tests/ecal/test-ecal-get-query.c          |    4 +-
 calendar/tests/ecal/test-ecal-get-timezone.c       |    2 +-
 calendar/tests/ecal/test-ecal-modify-object.c      |    4 +-
 calendar/tests/ecal/test-ecal-open.c               |    2 +-
 calendar/tests/ecal/test-ecal-receive-objects.c    |    4 +-
 calendar/tests/ecal/test-ecal-remove-object.c      |    4 +-
 calendar/tests/ecal/test-ecal-remove.c             |    2 +-
 calendar/tests/ecal/test-ecal-send-objects.c       |    4 +-
 .../tests/ecal/test-ecal-set-default-timezone.c    |    2 +-
 calendar/tests/ecal/test-ecal-set-mode.c           |    2 +-
 .../tests/ecal/test-ecal-stress-factory--fifo.c    |    2 +-
 .../ecal/test-ecal-stress-factory--open-async.c    |    2 +-
 .../tests/ecal/test-ecal-stress-factory--serial.c  |    2 +-
 .../ecal/test-ecal-stress-factory--single-cal.c    |    2 +-
 camel/Makefile.am                                  |    6 +-
 camel/camel-address.h                              |    2 +-
 camel/camel-block-file.h                           |    2 +-
 camel/camel-charset-map.c                          |    2 +-
 camel/camel-charset-map.h                          |    2 +-
 camel/camel-data-cache.c                           |    3 +-
 camel/camel-db.c                                   |   20 +-
 camel/camel-db.h                                   |    2 +-
 camel/camel-digest-folder.h                        |    2 +-
 camel/camel-file-utils.c                           |    2 -
 camel/camel-filter-driver.h                        |    2 +-
 camel/camel-filter-search.h                        |    2 +-
 camel/camel-folder-search.c                        |    2 +-
 camel/camel-folder-search.h                        |    2 +-
 camel/camel-folder-summary.c                       |   91 +-
 camel/camel-folder-summary.h                       |    6 +-
 camel/camel-folder-thread.h                        |    2 +-
 camel/camel-folder.c                               |   18 +-
 camel/camel-folder.h                               |    2 +
 camel/camel-gpg-context.c                          |   89 +-
 camel/camel-html-parser.h                          |    2 +-
 camel/camel-iconv.c                                |    2 +-
 camel/camel-index.h                                |    2 +-
 camel/camel-internet-address.h                     |    2 +-
 camel/camel-list-utils.c                           |    2 +-
 camel/camel-lock-client.c                          |    4 +-
 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-filter-basic.h                    |    2 +-
 camel/camel-mime-filter-bestenc.h                  |    2 +-
 camel/camel-mime-filter-canon.h                    |    2 +-
 camel/camel-mime-filter-charset.h                  |    2 +-
 camel/camel-mime-filter-crlf.h                     |    2 +-
 camel/camel-mime-filter-from.h                     |    2 +-
 camel/camel-mime-filter-html.h                     |    2 +-
 camel/camel-mime-filter-index.h                    |    2 +-
 camel/camel-mime-filter-linewrap.h                 |    2 +-
 camel/camel-mime-filter-pgp.h                      |    2 +-
 camel/camel-mime-filter.h                          |    2 +-
 camel/camel-mime-message.c                         |   17 +-
 camel/camel-mime-parser.c                          |    2 +-
 camel/camel-mime-parser.h                          |    2 +-
 camel/camel-mime-part.c                            |   19 +-
 camel/camel-mime-part.h                            |    1 +
 camel/camel-mime-utils.c                           |    4 +-
 camel/camel-mime-utils.h                           |    2 +-
 camel/camel-msgport.c                              |   23 +
 camel/camel-msgport.h                              |    1 +
 camel/camel-net-utils.c                            |   45 +-
 camel/camel-news-address.h                         |    2 +-
 camel/camel-nntp-address.h                         |    2 +-
 camel/camel-object.c                               |    4 +-
 camel/camel-partition-table.c                      |    2 +-
 camel/camel-partition-table.h                      |    2 +-
 camel/camel-private.h                              |    5 +-
 camel/camel-sasl-gssapi.c                          |   76 +-
 camel/camel-search-private.c                       |    2 -
 camel/camel-search-private.h                       |    2 +-
 camel/camel-search-sql-sexp.c                      |   29 +-
 camel/camel-search-sql-sexp.h                      |    2 +-
 camel/camel-search-sql.h                           |    2 +-
 camel/camel-session.c                              |    2 -
 camel/camel-smime-context.c                        |    6 +-
 camel/camel-store-summary.c                        |    5 +-
 camel/camel-store-summary.h                        |    2 +-
 camel/camel-store.c                                |    4 +-
 camel/camel-stream-filter.h                        |    2 +-
 camel/camel-stream-null.h                          |    2 +-
 camel/camel-stream-process.h                       |    2 +-
 camel/camel-tcp-stream-ssl.c                       |    2 +-
 camel/camel-text-index.c                           |   26 +-
 camel/camel-text-index.h                           |    2 +-
 camel/camel-uid-cache.c                            |    4 +-
 camel/camel-url-scanner.c                          |    4 +
 camel/camel-utf8.c                                 |    6 +-
 camel/camel-utf8.h                                 |    2 +-
 camel/camel-vee-folder.c                           |   43 +-
 camel/camel-vee-folder.h                           |    2 +-
 camel/camel-vee-store.h                            |    2 +-
 camel/camel-vee-summary.h                          |    2 +-
 camel/camel-vtrash-folder.c                        |    2 +-
 camel/camel-vtrash-folder.h                        |    2 +-
 camel/db-scrap-tools/db.c                          |    2 +-
 camel/providers/Makefile.am                        |    8 +-
 camel/providers/groupwise/camel-groupwise-folder.c |   32 +-
 .../providers/groupwise/camel-groupwise-provider.c |    9 +-
 .../groupwise/camel-groupwise-store-summary.c      |    4 +-
 .../groupwise/camel-groupwise-store-summary.h      |    2 +-
 camel/providers/groupwise/camel-groupwise-store.c  |  103 +-
 camel/providers/groupwise/camel-groupwise-store.h  |    1 -
 camel/providers/groupwise/camel-groupwise-utils.c  |    2 +-
 camel/providers/imap/camel-imap-folder.c           |   17 +-
 camel/providers/imap/camel-imap-search.c           |    4 +-
 camel/providers/imap/camel-imap-search.h           |    2 +-
 camel/providers/imap/camel-imap-store-summary.c    |    2 +-
 camel/providers/imap/camel-imap-store-summary.h    |    2 +-
 camel/providers/imap/camel-imap-store.c            |  109 +-
 camel/providers/imap/camel-imap-summary.h          |    2 +-
 camel/providers/imap/camel-imap-utils.c            |    2 +-
 camel/providers/imap/camel-imap-wrapper.c          |   21 +-
 camel/providers/imap4/camel-imap4-folder.c         |    2 +-
 camel/providers/imapx/Makefile.am                  |   14 +-
 camel/providers/imapx/camel-imapx-folder.c         |  163 +-
 camel/providers/imapx/camel-imapx-folder.h         |   11 +-
 camel/providers/imapx/camel-imapx-provider.c       |  104 +-
 camel/providers/imapx/camel-imapx-server.c         | 2644 ++++++++++++-----
 camel/providers/imapx/camel-imapx-server.h         |   22 +-
 camel/providers/imapx/camel-imapx-store-summary.c  |   12 +-
 camel/providers/imapx/camel-imapx-store-summary.h  |    2 +-
 camel/providers/imapx/camel-imapx-store.c          |  735 ++----
 camel/providers/imapx/camel-imapx-store.h          |   16 +-
 camel/providers/imapx/camel-imapx-stream.c         |   85 +-
 camel/providers/imapx/camel-imapx-stream.h         |   14 +-
 camel/providers/imapx/camel-imapx-summary.h        |    2 +-
 camel/providers/imapx/camel-imapx-tokenise.h       |  211 +-
 camel/providers/imapx/camel-imapx-tokens.txt       |   70 +-
 camel/providers/imapx/camel-imapx-utils.c          |  764 ++++--
 camel/providers/imapx/camel-imapx-utils.h          |  160 +-
 camel/providers/imapx/camel-imapx-view-summary.h   |    2 +-
 camel/providers/imapx/test-imapx.c                 |    2 +-
 camel/providers/local/camel-local-store.c          |    4 +-
 camel/providers/local/camel-local-summary.h        |    2 +-
 camel/providers/local/camel-maildir-folder.c       |    3 +-
 camel/providers/local/camel-maildir-store.c        |    4 +-
 camel/providers/local/camel-maildir-summary.c      |   10 +-
 camel/providers/local/camel-maildir-summary.h      |    2 +-
 camel/providers/local/camel-mbox-store.c           |    8 +-
 camel/providers/local/camel-mbox-summary.c         |    2 +
 camel/providers/local/camel-mbox-summary.h         |    2 +-
 camel/providers/local/camel-mh-summary.c           |    4 +-
 camel/providers/local/camel-mh-summary.h           |    2 +-
 camel/providers/local/camel-spool-store.c          |    6 +-
 camel/providers/local/camel-spool-summary.h        |    2 +-
 camel/providers/nntp/camel-nntp-folder.c           |    4 +-
 camel/providers/nntp/camel-nntp-store-summary.h    |    2 +-
 camel/providers/nntp/camel-nntp-store.c            |    2 +-
 camel/providers/nntp/camel-nntp-stream.h           |    2 +-
 camel/providers/nntp/camel-nntp-summary.h          |    2 +-
 camel/providers/pop3/camel-pop3-engine.c           |    4 +-
 camel/providers/pop3/camel-pop3-engine.h           |    2 +-
 camel/providers/pop3/camel-pop3-store.c            |   56 +-
 camel/providers/pop3/camel-pop3-stream.h           |    2 +-
 camel/tests/lib/address-data.h                     |    2 +-
 camel/tests/misc/split.c                           |    1 -
 configure.ac                                       |  167 +-
 .../addressbook/libebook/libebook-sections.txt     |    1 +
 .../addressbook/libebook/tmpl/e-book.sgml          |    9 +
 .../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 +
 .../libedata-cal/tmpl/e-data-cal-common.sgml       |    1 +
 .../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            |   17 +-
 .../reference/camel/tmpl/camel-folder-summary.sgml |   18 +
 docs/reference/camel/tmpl/camel-folder.sgml        |    9 +
 docs/reference/camel/tmpl/camel-i18n.sgml          |   79 -
 docs/reference/camel/tmpl/camel-mime-part.sgml     |    9 +
 docs/reference/camel/tmpl/camel-msgport.sgml       |   11 +
 .../reference/camel/tmpl/camel-tcp-stream-ssl.sgml |    9 +
 .../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                      |   24 +-
 libedataserver/test-source-list.c                  |    2 +-
 libedataserverui/Makefile.am                       |    1 +
 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-passwords.c                     |   13 +-
 libedataserverui/e-source-combo-box.c              |   28 +-
 libedataserverui/e-source-selector.c               |   56 +-
 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                                           |  789 +++---
 po/et.po                                           |  672 ++---
 po/fr.po                                           | 1630 +++++------
 po/gl.po                                           | 1501 +++++-----
 po/nb.po                                           |  854 +++---
 po/pt_BR.po                                        | 2372 ++++++++-------
 po/ro.po                                           | 1241 ++++-----
 po/ru.po                                           | 3120 +++++++++-----------
 po/sl.po                                           |  937 ++++---
 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 +-
 350 files changed, 22250 insertions(+), 22496 deletions(-)
---
diff --cc addressbook/libebook/e-book.c
index 3b1c2bc,919dcce..7966562
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@@ -30,9 -30,10 +30,10 @@@
  #include "e-book.h"
  #include "e-error.h"
  #include "e-contact.h"
+ #include "e-name-western.h"
  #include "e-book-view-private.h"
 -#include "e-data-book-factory-bindings.h"
 -#include "e-data-book-bindings.h"
 +#include "e-data-book-factory-gdbus-bindings.h"
 +#include "e-data-book-gdbus-bindings.h"
  #include "libedata-book/e-data-book-types.h"
  #include "e-book-marshal.h"
  
@@@ -287,38 -254,34 +288,40 @@@ e_book_activate(GError **error
  		return TRUE;
  	}
  
 -	if (!connection) {
 -		connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
 -		if (!connection) {
 +	factory_proxy_name = get_factory_dbus_proxy_owner_name ();
 +
 +	/* FIXME: better to just watch for the proxy instead of using the
 +	 * connection directly? */
 +	if (!connection_gdbus) {
 +		connection_gdbus = e_dbus_connection_bus_get_private_sync (G_BUS_TYPE_SESSION, NULL, error);
 +		if (!connection_gdbus) {
  			UNLOCK_CONN ();
 +
 +			g_warning (G_STRLOC ": failed to create the factory gdbus connection");
 +
  			return FALSE;
  		}
+ 
+ 		dbus_connection_add_filter (dbus_g_connection_get_connection (connection), filter_dbus_msgs_cb, NULL, NULL);
  	}
  
 -	dbus_error_init (&derror);
 -	if (!dbus_bus_start_service_by_name (dbus_g_connection_get_connection (connection),
 -					     E_DATA_BOOK_FACTORY_SERVICE_NAME,
 -					     0, NULL, &derror)) {
 -		dbus_set_g_error (error, &derror);
 -		dbus_error_free (&derror);
 -		UNLOCK_CONN ();
 -		return FALSE;
 -	}
 -
 -	if (!factory_proxy) {
 -		factory_proxy = dbus_g_proxy_new_for_name_owner (connection,
 -								 E_DATA_BOOK_FACTORY_SERVICE_NAME,
 -								 "/org/gnome/evolution/dataserver/addressbook/BookFactory",
 -								 "org.gnome.evolution.dataserver.addressbook.BookFactory",
 -								 error);
 -		if (!factory_proxy) {
 +	/* FIXME: watch for changes to this proxy instead of relying upon
 +	 * dbus-glib to get the unique name */
 +	if (!factory_proxy_gdbus) {
 +		factory_proxy_gdbus = e_dbus_proxy_new_sync (connection_gdbus,
 +								E_TYPE_DBUS_PROXY,
 +								E_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | E_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
 +								factory_proxy_name,
 +								"/org/gnome/evolution/dataserver/addressbook/BookFactory",
 +								"org.gnome.evolution.dataserver.addressbook.BookFactory",
 +								NULL,
 +								error);
 +
 +		if (!factory_proxy_gdbus) {
  			UNLOCK_CONN ();
 +
 +			g_warning (G_STRLOC ": failed to create the factory gdbus proxy, %s", (*error)->message);
 +
  			return FALSE;
  		}
  
diff --cc addressbook/tests/ebook/ebook-test-utils.h
index 47f33eb,789e21d..8a5cfaf
--- a/addressbook/tests/ebook/ebook-test-utils.h
+++ b/addressbook/tests/ebook/ebook-test-utils.h
@@@ -36,18 -36,18 +36,31 @@@ typedef struct 
  } EBookTestClosure;
  
  void
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +test_print (const char *format,
++=======
+ test_print (const gchar *format,
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
  	    ...);
  
  gboolean
  ebook_test_utils_callback_quit (gpointer user_data);
  
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +char*
 +ebook_test_utils_new_vcard_from_test_case (const char *case_name);
 +
 +char*
 +ebook_test_utils_book_add_contact_from_test_case_verify (EBook       *book,
 +                                                         const char  *case_name,
++=======
+ gchar *
+ ebook_test_utils_new_vcard_from_test_case (const gchar *case_name);
+ 
+ gchar *
+ ebook_test_utils_book_add_contact_from_test_case_verify (EBook       *book,
+                                                          const gchar  *case_name,
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
  							 EContact   **contact);
  
  gboolean
@@@ -55,12 -55,12 +68,21 @@@ ebook_test_utils_contacts_are_equal_sha
                                               EContact *b);
  
  EBook*
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +ebook_test_utils_book_new_from_uri (const char *uri);
 +
 +EBook*
 +ebook_test_utils_book_new_temp (char **uri);
 +
 +const char*
++=======
+ ebook_test_utils_book_new_from_uri (const gchar *uri);
+ 
+ EBook*
+ ebook_test_utils_book_new_temp (gchar **uri);
+ 
+ const gchar *
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
  ebook_test_utils_book_add_contact (EBook    *book,
                                     EContact *contact);
  void
@@@ -80,10 -80,10 +102,17 @@@ ebook_test_utils_book_async_commit_cont
  
  EContact*
  ebook_test_utils_book_get_contact (EBook      *book,
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +                                   const char *uid);
 +void
 +ebook_test_utils_book_async_get_contact (EBook       *book,
 +                                         const char  *uid,
++=======
+                                    const gchar *uid);
+ void
+ ebook_test_utils_book_async_get_contact (EBook       *book,
+                                          const gchar  *uid,
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
                                           GSourceFunc  callback,
                                           gpointer     user_data);
  
@@@ -108,12 -108,12 +137,20 @@@ ebook_test_utils_book_async_get_support
  							GSourceFunc  callback,
  							gpointer     user_data);
  
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +const char*
++=======
+ const gchar *
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
  ebook_test_utils_book_get_static_capabilities (EBook *book);
  
  void
  ebook_test_utils_book_remove_contact (EBook      *book,
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +                                      const char *uid);
++=======
+                                       const gchar *uid);
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
  void
  ebook_test_utils_book_async_remove_contact (EBook       *book,
  					    EContact    *contact,
@@@ -121,7 -121,7 +158,11 @@@
  					    gpointer     user_data);
  void
  ebook_test_utils_book_async_remove_contact_by_id (EBook       *book,
++<<<<<<< HEAD:addressbook/tests/ebook/ebook-test-utils.h
 +                                                  const char  *uid,
++=======
+                                                   const gchar  *uid,
++>>>>>>> master:addressbook/tests/ebook/ebook-test-utils.h
                                                    GSourceFunc  callback,
                                                    gpointer     user_data);
  
diff --cc calendar/libecal/e-cal-view.c
index cd23f50,5e8302f..cfd67b8
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@@ -434,12 -413,10 +434,12 @@@ e_cal_view_start (ECalView *view
  
  	priv = E_CAL_VIEW_GET_PRIVATE(view);
  
 +	g_return_if_fail (G_IS_DBUS_PROXY (priv->view_proxy));
 +
  	LOCK_VIEW ();
 -	if (!org_gnome_evolution_dataserver_calendar_CalView_start (priv->view_proxy, &error)) {
 +	if (!e_data_cal_view_gdbus_start_sync (priv->view_proxy, &error)) {
  		UNLOCK_VIEW ();
- 		g_printerr("%s: %s\n", __FUNCTION__, error->message);
+ 		g_printerr("%s: %s\n", G_STRFUNC, error->message);
  		g_error_free (error);
  		g_warning (G_STRLOC ": Unable to start view");
  		return;
diff --cc calendar/tests/ecal/ecal-test-utils.h
index 4d16a0a,60760e7..92e7fb0
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@@ -33,16 -33,16 +33,29 @@@ typedef struct 
  } ECalTestClosure;
  
  void
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +test_print (const char *format,
 +            ...);
 +
 +ECal*
 +ecal_test_utils_cal_new_from_uri (const char     *uri,
 +				  ECalSourceType  type);
 +
 +ECal*
 +ecal_test_utils_cal_new_temp (char           **uri,
 +		              ECalSourceType   type);
++=======
+ test_print (const gchar *format,
+             ...);
+ 
+ ECal*
+ ecal_test_utils_cal_new_from_uri (const gchar     *uri,
+ 				  ECalSourceType  type);
+ 
+ ECal*
+ ecal_test_utils_cal_new_temp (gchar           **uri,
+ 			      ECalSourceType   type);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  void
  ecal_test_utils_cal_open (ECal     *cal,
@@@ -57,13 -57,13 +70,23 @@@ ecal_test_utils_cal_async_open (ECa
  void
  ecal_test_utils_cal_remove (ECal *cal);
  
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +char*
 +ecal_test_utils_cal_get_alarm_email_address (ECal *cal);
 +
 +char*
 +ecal_test_utils_cal_get_cal_address (ECal *cal);
 +
 +char*
++=======
+ gchar *
+ ecal_test_utils_cal_get_alarm_email_address (ECal *cal);
+ 
+ gchar *
+ ecal_test_utils_cal_get_cal_address (ECal *cal);
+ 
+ gchar *
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  ecal_test_utils_cal_get_ldap_attribute (ECal *cal);
  
  void
@@@ -85,7 -85,7 +108,11 @@@ ecal_test_utils_cal_assert_e_cal_compon
  
  icalcomponent*
  ecal_test_utils_cal_get_object (ECal       *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +                                const char *uid);
++=======
+                                 const gchar *uid);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  void
  ecal_test_utils_cal_modify_object (ECal          *cal,
@@@ -94,20 -94,20 +121,34 @@@
  
  void
  ecal_test_utils_cal_remove_object (ECal       *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +				   const char *uid);
++=======
+ 				   const gchar *uid);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  icalcomponent*
  ecal_test_utils_cal_get_default_object (ECal *cal);
  
  GList*
  ecal_test_utils_cal_get_object_list (ECal       *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +                                     const char *query);
 +
 +GList*
 +ecal_test_utils_cal_get_objects_for_uid (ECal       *cal,
 +					 const char *uid);
 +
 +char*
++=======
+                                      const gchar *query);
+ 
+ GList*
+ ecal_test_utils_cal_get_objects_for_uid (ECal       *cal,
+ 					 const gchar *uid);
+ 
+ gchar *
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  ecal_test_utils_cal_create_object (ECal          *cal,
  				   icalcomponent *component);
  
@@@ -119,13 -119,13 +160,23 @@@ ecal_test_utils_cal_set_mode (ECa
  
  void
  ecal_test_utils_create_component (ECal           *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +                                  const char     *dtstart,
 +                                  const char     *dtstart_tzid,
 +                                  const char     *dtend,
 +                                  const char     *dtend_tzid,
 +                                  const char     *summary,
 +                                  ECalComponent **comp_out,
 +                                  char          **uid_out);
++=======
+                                   const gchar     *dtstart,
+                                   const gchar     *dtstart_tzid,
+                                   const gchar     *dtend,
+                                   const gchar     *dtend_tzid,
+                                   const gchar     *summary,
+                                   ECalComponent **comp_out,
+                                   gchar          **uid_out);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  void
  ecal_test_utils_cal_component_set_icalcomponent (ECalComponent *e_component,
@@@ -133,7 -133,7 +184,11 @@@
  
  icaltimezone*
  ecal_test_utils_cal_get_timezone (ECal       *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +                                  const char *tzid);
++=======
+                                   const gchar *tzid);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  void
  ecal_test_utils_cal_add_timezone (ECal         *cal,
@@@ -155,6 -155,6 +210,10 @@@ ecal_test_utils_cal_receive_objects (EC
  
  ECalView*
  ecal_test_utils_get_query (ECal       *cal,
++<<<<<<< HEAD:calendar/tests/ecal/ecal-test-utils.h
 +                           const char *sexp);
++=======
+                            const gchar *sexp);
++>>>>>>> master:calendar/tests/ecal/ecal-test-utils.h
  
  #endif /* _ECAL_TEST_UTILS_H */
diff --cc camel/camel-net-utils.c
index d447e41,49324cf..f179378
--- a/camel/camel-net-utils.c
+++ b/camel/camel-net-utils.c
@@@ -506,19 -506,23 +506,25 @@@ cs_waitinfo(gpointer (worker)(gpointer)
  			   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);
 -			g_thread_join (thread);
++#warning FIXME: do we want this pthread_cancel here as per the comment ?
++/*			pthread_cancel(id); */
 +			pthread_join (id, NULL);
  			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 {
- 		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("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);
  
@@@ -599,9 -602,7 +606,13 @@@ cs_getaddrinfo(gpointer data
  		}
  	}
  
++<<<<<<< HEAD:camel/camel-net-utils.c
 +	pthread_testcancel ();
 +
 +	for (i=0;h.h_addr_list[i];i++) {
++=======
+ 	for (i = 0; h.h_addr_list[i] && !msg->cancelled; i++) {
++>>>>>>> master:camel/camel-net-utils.c
  		res = g_malloc0(sizeof(*res));
  		if (msg->hints) {
  			res->ai_flags = msg->hints->ai_flags;
@@@ -651,8 -652,6 +662,11 @@@ cs_getaddrinfo(gpointer data
  			info->result = getaddrinfo(info->name, "443", info->hints, info->res);
  	}
  
++<<<<<<< HEAD:camel/camel-net-utils.c
 +	pthread_testcancel ();
 +
++=======
++>>>>>>> master:camel/camel-net-utils.c
  	if (!info->cancelled)
  		camel_msgport_reply((CamelMsg *)info);
  
@@@ -773,7 -771,8 +788,12 @@@ cs_getnameinfo(gpointer data
  	if (msg->serv)
  		sprintf(msg->serv, "%d", sin->sin_port);
  
++<<<<<<< HEAD:camel/camel-net-utils.c
 +	camel_msgport_reply((CamelMsg *)msg);
++=======
+ 	if (!msg->cancelled)
+ 		camel_msgport_reply ((CamelMsg *)msg);
++>>>>>>> master:camel/camel-net-utils.c
  cancel:
  	return NULL;
  }
@@@ -786,8 -785,6 +806,11 @@@ cs_getnameinfo(gpointer 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);
  
++<<<<<<< HEAD:camel/camel-net-utils.c
 +	pthread_testcancel ();
 +
++=======
++>>>>>>> master:camel/camel-net-utils.c
  	if (!msg->cancelled)
  		camel_msgport_reply((CamelMsg *)msg);
  
diff --cc camel/providers/imapx/camel-imapx-server.c
index 1ef16e5,abd7822..a752cb6
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@@ -152,12 -173,15 +173,16 @@@ struct _refresh_info 
  };
  
  enum {
--	IMAPX_JOB_GET_MESSAGE,
--	IMAPX_JOB_APPEND_MESSAGE,
- 	IMAPX_JOB_REFRESH_INFO,
- 	IMAPX_JOB_SYNC_CHANGES,
- 	IMAPX_JOB_EXPUNGE,
- 	IMAPX_JOB_LIST,
 -	IMAPX_JOB_COPY_MESSAGE,
 -	IMAPX_JOB_REFRESH_INFO,
 -	IMAPX_JOB_SYNC_CHANGES,
 -	IMAPX_JOB_EXPUNGE,
 -	IMAPX_JOB_NOOP,
 -	IMAPX_JOB_IDLE,
 -	IMAPX_JOB_LIST,
++	IMAPX_JOB_GET_MESSAGE = 1<<0,
++	IMAPX_JOB_APPEND_MESSAGE = 1<<1,
++	IMAPX_JOB_COPY_MESSAGE = 1<<2,
++	IMAPX_JOB_FETCH_NEW_MESSAGES = 1<<3,
++	IMAPX_JOB_REFRESH_INFO = 1<<4,
++	IMAPX_JOB_SYNC_CHANGES = 1<<5,
++	IMAPX_JOB_EXPUNGE = 1<<6,
++	IMAPX_JOB_NOOP = 1<<7,
++	IMAPX_JOB_IDLE = 1<<8,
++	IMAPX_JOB_LIST = 1<<9,
  };
  
  struct _imapx_flag_change {
@@@ -177,7 -201,7 +202,7 @@@ struct _CamelIMAPXJob 
  	//CamelOperation *op;
  
  	gint noreply:1;		/* dont wait for reply */
--	gchar type;		/* operation type */
++	guint32 type;		/* operation type */
  	gchar pri;		/* the command priority */
  	short commands;		/* counts how many commands are outstanding */
  
@@@ -866,30 -952,33 +953,32 @@@ found
  
  /* Must not have QUEUE lock */
  static CamelIMAPXJob *
- imapx_find_job(CamelIMAPXServer *imap, gint type, const gchar *uid)
 -imapx_match_active_job (CamelIMAPXServer *is, gint type, const gchar *uid)
++imapx_match_active_job (CamelIMAPXServer *is, guint32 type, const gchar *uid)
  {
- 	CamelIMAPXJob *job;
- 	CamelDListNode *node;
+ 	CamelIMAPXJob *job = NULL;
+ 	CamelIMAPXCommand *ic;
  
- 	QUEUE_LOCK(imap);
+ 	QUEUE_LOCK(is);
  
- 	for (node = imap->jobs.head;node->next;node = job->msg.ln.next) {
- 		job = (CamelIMAPXJob *) node;
- 		if (job->type != type)
+ 	for (ic = (CamelIMAPXCommand *)is->active.head;ic->next;ic=ic->next) {
+ 		job = ic->job;
 -		if (!job || job->type != type)
++		if (!job || !(job->type & type))
  			continue;
  
--		switch (type) {
++		switch (job->type) {
  		case IMAPX_JOB_GET_MESSAGE:
- 			if (imap->select
- 			    && strcmp(job->folder->full_name, imap->select) == 0
+ 			if (is->select
+ 			    && strcmp(job->folder->full_name, is->select) == 0
  			    && strcmp(job->u.get_message.uid, uid) == 0)
  				goto found;
  			break;
++		case IMAPX_JOB_FETCH_NEW_MESSAGES:
  		case IMAPX_JOB_REFRESH_INFO:
- 			if (imap->select
- 			    && strcmp(job->folder->full_name, imap->select) == 0)
++		case IMAPX_JOB_EXPUNGE:
+ 			if (is->select
+ 			    && strcmp(job->folder->full_name, is->select) == 0)
  				goto found;
  			break;
 -		case IMAPX_JOB_EXPUNGE:
 -			if (is->select && strcmp (job->folder->full_name, is->select) == 0)
 -				goto found;
  		case IMAPX_JOB_LIST:
  			goto found;
  		}
@@@ -962,26 -1019,60 +1019,63 @@@ imapx_untagged(CamelIMAPXServer *imap, 
  	e(printf("Have token '%s' id %d\n", token, id));
  	p = token;
  	while ((c = *p))
- 		*p++ = toupper(c);
+ 		*p++ = toupper((gchar) c);
  
- 	switch (imap_tokenise(token, len)) {
- 	case IMAP_CAPABILITY:
+ 	switch (imapx_tokenise ((const gchar *) token, len)) {
+ 	case IMAPX_CAPABILITY:
  		if (imap->cinfo)
- 			imap_free_capability(imap->cinfo);
- 		imap->cinfo = imap_parse_capability(imap->stream, ex);
+ 			imapx_free_capability(imap->cinfo);
+ 		imap->cinfo = imapx_parse_capability(imap->stream, ex);
  		printf("got capability flags %08x\n", imap->cinfo->capa);
  		return 0;
- 	case IMAP_EXPUNGE: {
+ 	case IMAPX_EXPUNGE: {
  		guint32 expunge = id;
+ 		CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_EXPUNGE, NULL);
  
+ 		/* If there is a job running, let it handle the deletion */
+ 		if (job)
+ 			break;
+ 		
  		printf("expunged: %d\n", id);
- 		g_array_append_val(imap->expunged, expunge);
+ 		if (imap->select_folder) {
+ 			gchar *uid = NULL;
+ 			CamelMessageInfo *mi;
+ 
++			uid = camel_folder_summary_uid_from_index (imap->select_folder->summary, expunge - 1);
++			if (!uid)
++				break;
++
+ 			if (imap->changes == NULL)
+ 				imap->changes = camel_folder_change_info_new();
+ 
 -			uid = camel_folder_summary_uid_from_index (imap->select_folder->summary, expunge - 1);
+ 			mi = camel_folder_summary_uid (imap->select_folder->summary, uid);
+ 			if (mi) {
+ 				imapx_update_summary_for_removed_message (mi, imap->select_folder);
+ 				camel_message_info_free (mi);
+ 			}
+ 
+ 			camel_folder_summary_remove_uid_fast (imap->select_folder->summary, uid);
+ 			imap->expunged = g_slist_prepend (imap->expunged, uid);
+ 
+ 			camel_folder_change_info_remove_uid (imap->changes, uid);
+ 
+ 			if (imapx_idle_supported (imap) && imapx_in_idle (imap)) {
+ 				camel_db_delete_uids (imap->store->cdb_w, imap->select_folder->full_name, imap->expunged, NULL);
+ 				imapx_update_store_summary (imap->select_folder);
+ 				camel_object_trigger_event(imap->select_folder, "folder_changed", imap->changes);
+ 
+ 				g_slist_foreach (imap->expunged, (GFunc) g_free, NULL);
+ 				imap->expunged = NULL;
+ 				camel_folder_change_info_clear (imap->changes);
+ 			}
+ 		}
+ 
  		break;
  	}
- 	case IMAP_NAMESPACE: {
+ 	case IMAPX_NAMESPACE: {
  		CamelIMAPXNamespaceList *nsl = NULL;
  
- 		nsl = imap_parse_namespace_list (imap->stream, ex);
+ 		nsl = imapx_parse_namespace_list (imap->stream, ex);
  		if (nsl != NULL) {
  			CamelIMAPXStore *imapx_store = (CamelIMAPXStore *) imap->store;
  
@@@ -1030,8 -1133,49 +1136,49 @@@
  			}
  		}
  
- 		if ((finfo->got & (FETCH_FLAGS|FETCH_UID)) == (FETCH_FLAGS|FETCH_UID)) {
- 			CamelIMAPXJob *job = imapx_find_job(imap, IMAPX_JOB_REFRESH_INFO, NULL);
+ 		if (finfo->got & FETCH_FLAGS && !(finfo->got & FETCH_UID)) {
+ 			if (imap->select_folder) {
+ 				CamelFolder *folder;
+ 				CamelMessageInfo *mi = NULL;
+ 				gboolean changed = FALSE;
+ 				gchar *uid = NULL;
+ 
+ 				camel_object_ref(imap->select_folder);
+ 				folder = imap->select_folder;
+ 
+ 				printf("flag changed: %d\n", id);
+ 
+ 				if ( (uid = camel_folder_summary_uid_from_index (folder->summary, id - 1)))
+ 				{
+ 					mi = camel_folder_summary_uid (folder->summary, uid);
+ 					if (mi)
+ 						changed = imapx_update_message_info_flags (mi, finfo->flags, finfo->user_flags, folder);
+ 					finfo->user_flags = NULL;
+ 				}
+ 
+ 				if (changed) {
+ 					if (imap->changes == NULL)
+ 						imap->changes = camel_folder_change_info_new();
+ 
+ 					camel_folder_change_info_change_uid(imap->changes, uid);
+ 					g_free (uid);
+ 				}
+ 
+ 				if (imapx_idle_supported (imap) && changed && imapx_in_idle (imap)) {
+ 					camel_folder_summary_save_to_db (imap->select_folder->summary, NULL);
+ 					imapx_update_store_summary (imap->select_folder);
+ 					camel_object_trigger_event(imap->select_folder, "folder_changed", imap->changes);
+ 					camel_folder_change_info_clear (imap->changes);
+ 				}
+ 
+ 				if (mi)
+ 					camel_message_info_free (mi);
+ 				camel_object_unref (folder);
+ 			}
+ 		}
+ 
+ 		if ((finfo->got & (FETCH_FLAGS|FETCH_UID)) == (FETCH_FLAGS|FETCH_UID) && !(finfo->got & FETCH_HEADER)) {
 -			CamelIMAPXJob *job = imapx_match_active_job(imap, IMAPX_JOB_REFRESH_INFO, NULL);
++			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL);
  
  			/* This is either a refresh_info job, check to see if it is and update
  			   if so, otherwise it must've been an unsolicited response, so update
@@@ -1053,8 -1196,8 +1199,8 @@@
  		}
  
  		if ((finfo->got & (FETCH_HEADER|FETCH_UID)) == (FETCH_HEADER|FETCH_UID)) {
- 			CamelIMAPXJob *job = imapx_find_job(imap, IMAPX_JOB_REFRESH_INFO, NULL);
- 
 -			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_REFRESH_INFO, NULL);
 -
++			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL);
++			
  			/* This must be a refresh info job as well, but it has asked for
  			   new messages to be added to the index */
  
@@@ -1070,24 -1213,59 +1216,59 @@@
  				camel_object_unref(mp);
  
  				if (mi) {
- 					GArray *infos = job->u.refresh_info.infos;
- 					gint i = job->u.refresh_info.last_index;
- 
- 					/* This is rather inefficent, but should be ok if we're expecting it
- 					   since we break each fetch into lots of 100 */
- 					mi->uid = g_strdup(finfo->uid);
- 					for (i=0;i<infos->len;i++) {
- 						struct _refresh_info *r = &g_array_index(infos, struct _refresh_info, i);
- 
- 						if (r->uid && !strcmp(r->uid, finfo->uid)) {
- 							((CamelMessageInfoBase *)mi)->flags = r->server_flags;
- 							((CamelIMAPXMessageInfo *)mi)->server_flags = r->server_flags;
- 							camel_flag_list_copy(&((CamelMessageInfoBase *)mi)->user_flags, &r->server_user_flags);
- 							((CamelIMAPXMessageInfo *)mi)->server_user_flags = r->server_user_flags;
- 							break;
- 						}
+ 					guint32 server_flags;
+ 					CamelFlag *server_user_flags;
+ 					CamelMessageInfoBase *binfo;
+ 
 -					mi->uid = g_strdup(finfo->uid);
++					mi->uid = camel_pstring_strdup (finfo->uid);
+ 
+ 					if (!(finfo->got & FETCH_FLAGS))
+ 					{
+ 						struct _refresh_info *r = NULL;
+ 						GArray *infos = job->u.refresh_info.infos;
+ 						gint min = job->u.refresh_info.last_index;
+ 						gint max = job->u.refresh_info.index, mid;
+ 						gboolean found = FALSE;
+ 
+ 						/* array is sorted, so use a binary search */
+ 						do {
+ 							gint cmp = 0;
+ 
+ 							mid = (min + max)/2;
+ 							r = &g_array_index(infos, struct _refresh_info, mid);
+ 							cmp = imapx_uid_cmp (finfo->uid, r->uid, NULL);
+ 
+ 							if (cmp > 0)
+ 								min = mid + 1;
+ 							else if (cmp < 0)
+ 								max = mid - 1;
+ 							else
+ 								found = TRUE;
+ 
+ 						} while (!found && min <= max);
+ 
+ 						if (!found)
+ 							g_assert_not_reached ();
+ 
+ 						server_flags = r->server_flags;
+ 						server_user_flags = r->server_user_flags;
+ 					} else {
+ 						server_flags = finfo->flags;
+ 						server_user_flags = finfo->user_flags;
+ 						/* free user_flags ? */
+ 						finfo->user_flags = NULL;
+ 					}
+ 
+ 					binfo = (CamelMessageInfoBase *) mi;
+ 					binfo->size = finfo->size;
+ 
+ 					if (!camel_folder_summary_check_uid (job->folder->summary, mi->uid)) {
+ 						camel_folder_summary_add(job->folder->summary, mi);
+ 						imapx_set_message_info_flags_for_new_message (mi, server_flags, server_user_flags, job->folder);
+ 						camel_folder_change_info_add_uid (job->u.refresh_info.changes, mi->uid);
+ 
+ 						camel_operation_progress (job->op, (camel_folder_summary_count (job->folder->summary) * 100)/imap->exists);
  					}
- 					camel_folder_summary_add(job->folder->summary, mi);
  				}
  			}
  		}
@@@ -1349,19 -1588,269 +1591,270 @@@ imapx_command_run(CamelIMAPXServer *is
  	g_assert(camel_dlist_empty(&is->active));
  	imapx_command_start(is, ic);
  	QUEUE_UNLOCK(is);
+ 
  	do {
  		imapx_step(is, ex);
- 	} while (ic->status == NULL);
+ 	} while (ic->status == NULL && !camel_exception_is_set (ex));
  
+ 	QUEUE_LOCK(is);
  	camel_dlist_remove((CamelDListNode *)ic);
+ 	QUEUE_UNLOCK(is);
+ }
+ 
+ static void
+ imapx_command_complete (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ {
+ 	e_flag_set (ic->flag);
+ }
+ 
+ /* change status to a job and remove command_run_sync */
+ static void
+ imapx_command_status_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ {
+ 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) ic->job->folder;
+ 
+ 	ifolder->unread_on_server = is->unread;
+ 	e_flag_set (ic->flag);
+ }
+ 
+ /* The caller should free the command as well */
+ static void
+ imapx_command_run_sync (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ {
+ 	CamelIMAPXCommandFunc complete = NULL;
+ 
+ 	ic->flag = e_flag_new ();
+ 	complete = ic->complete;
+ 
+ 	if (!ic->complete)
+ 		ic->complete = imapx_command_complete;
+ 
+ 	imapx_command_queue (is, ic);
+ 	e_flag_wait (ic->flag);
+ 
+ 	e_flag_free (ic->flag);
+ 	ic->flag = NULL;
+ }
+ 
+ /* ********************************************************************** */
+ // IDLE support
+ 
+ #define IDLE_LOCK(x) (g_mutex_lock((x)->idle_lock))
+ #define IDLE_UNLOCK(x) (g_mutex_unlock((x)->idle_lock))
+ 
+ /*TODO handle negative cases sanely */
+ static gboolean
+ imapx_command_idle_stop (CamelIMAPXServer *is, CamelException *ex)
+ {
+ 	if (!is->stream || camel_stream_printf((CamelStream *)is->stream, "%s", "DONE\r\n") == -1) {
+ 		camel_exception_set (ex, 1, "Unable to issue DONE");
+ 		return FALSE;
+ 	}
+ 
+ 	return TRUE;
+ }
+ 
+ static void
+ imapx_command_idle_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ {
+ 	CamelIMAPXIdle *idle = is->idle;
+ 
+ 	if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+ 		if (!camel_exception_is_set (ic->ex))
+ 			camel_exception_setv(ic->job->ex, 1, "Error performing IDLE: %s", ic->status->text);
+ 		else
+ 			camel_exception_xfer (ic->job->ex, ic->ex);
+ 	}
+ 
+ 	IDLE_LOCK (idle);
+ 	idle->in_idle = FALSE;
+ 	idle->idle_issue_done = FALSE;
+ 	idle->started = FALSE;
+ 	IDLE_UNLOCK (idle);
+ 
+ 	imapx_job_done (is, ic->job);
+ 	camel_imapx_command_free (ic);
+ }
+ 
+ static void
+ imapx_job_idle_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
+ {
+ 	CamelIMAPXCommand *ic;
+ 	CamelIMAPXCommandPart *cp;
+ 
+ 	ic = camel_imapx_command_new ("IDLE", job->folder->full_name, "IDLE");
+ 	ic->job = job;
+ 	ic->complete = imapx_command_idle_done;
+ 
+ 	camel_imapx_command_close(ic);
+ 	cp = (CamelIMAPXCommandPart *)ic->parts.head;
+ 	cp->type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
+ 
+ 	QUEUE_LOCK (is);
+ 	imapx_command_start (is, ic);
+ 	QUEUE_UNLOCK (is);
+ }
+ 
+ static void
+ camel_imapx_server_idle (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+ {
+ 	CamelIMAPXJob *job;
+ 
+ 	job = g_malloc0 (sizeof(*job));
+ 	job->type = IMAPX_JOB_IDLE;
+ 	job->start = imapx_job_idle_start;
+ 	job->folder = folder;
+ 	job->ex = ex;
+ 
+ 	imapx_run_job(is, job);
+ 	g_free(job);
+ }
+ 
+ static void
 -imapx_server_fetch_new_messages (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
++imapx_server_fetch_new_messages (CamelIMAPXServer *is, CamelFolder *folder, gboolean async, CamelException *ex)
+ {
+ 	CamelIMAPXJob *job;
+ 
+ 	job = g_malloc0(sizeof(*job));
 -	job->type = IMAPX_JOB_REFRESH_INFO;
++	job->type = IMAPX_JOB_FETCH_NEW_MESSAGES;
+ 	job->start = imapx_job_fetch_new_messages_start;
+ 	job->folder = folder;
 -	job->noreply = 1;
++	job->noreply = async;
+ 	job->ex = ex;
+ 	job->u.refresh_info.changes = camel_folder_change_info_new();
++	job->op = camel_operation_registered ();
+ 
+ 	imapx_run_job (is, job);
+ }
+ 
+ static gpointer
+ idle_thread (gpointer data)
+ {
+ 	CamelException *ex = camel_exception_new ();
+ 	CamelIMAPXServer *is = (CamelIMAPXServer *) data;
+ 
+ 	while (TRUE) {
+ 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_folder;
+ 
+ 		e_flag_clear (is->idle->idle_start_watch);
+ 		camel_imapx_server_idle (is, is->select_folder, ex);
+ 
+ 		if (!camel_exception_is_set (ex) && ifolder->exists_on_server >
+ 				camel_folder_summary_count (((CamelFolder *) ifolder)->summary) && imapx_is_command_queue_empty (is))
 -			imapx_server_fetch_new_messages (is, is->select_folder, ex);
++			imapx_server_fetch_new_messages (is, is->select_folder, TRUE, ex);
+ 
+ 		if (camel_exception_is_set (ex)) {
+ 			printf ("Caught exception in idle thread:  %s \n", ex->desc);
+ 			/* No way to asyncronously notify UI ? */
+ 			camel_exception_clear (ex);
+ 		}
+ 
+ 		e_flag_wait (is->idle->idle_start_watch);
+ 
+ 		if (is->idle->idle_exit)
+ 			break;
+ 	}
+ 
+ 	camel_exception_free (ex);
+ 	return NULL;
+ }
+ 
+ static void
+ imapx_stop_idle (CamelIMAPXServer *is, CamelException *ex)
+ {
+ 	CamelIMAPXIdle *idle = is->idle;
+ 
+ 	IDLE_LOCK (idle);
+ 
+ 	if (!idle->idle_issue_done && idle->started) {
+ 		imapx_command_idle_stop (is, ex);
+ 		idle->idle_issue_done = TRUE;
+ 	}
+ 
+ 	IDLE_UNLOCK (idle);
  }
  
+ static void
+ imapx_init_idle (CamelIMAPXServer *is)
+ {
+ 	is->idle = g_new0 (CamelIMAPXIdle, 1);
+ 	is->idle->idle_lock = g_mutex_new ();
+ }
+ 
+ static void
+ imapx_exit_idle (CamelIMAPXServer *is)
+ {
+ 	CamelIMAPXIdle *idle = is->idle;
+ 
+ 	if (!idle)
+ 		return;
+ 
+ 	IDLE_LOCK (idle);
+ 
+ 	if (idle->idle_thread_id) {
+ 		idle->idle_exit = TRUE;
+ 		e_flag_set (idle->idle_start_watch);
+ 
+ 		pthread_join (idle->idle_thread_id, NULL);
+ 	}
+ 
+ 	IDLE_UNLOCK (idle);
+ 
+ 	g_mutex_free (idle->idle_lock);
+ 	if (idle->idle_start_watch)
+ 		e_flag_free (idle->idle_start_watch);
+ 
+ 	g_free (is->idle);
+ 	is->idle = NULL;
+ }
+ 
+ static void
+ imapx_start_idle (CamelIMAPXServer *is)
+ {
+ 	CamelIMAPXIdle *idle = is->idle;
+ 
+ 	if (camel_application_is_exiting)
+ 		return;
+ 
+ 	IDLE_LOCK (idle);
+ 
+ 	if (!idle->idle_thread_id) {
+ 		idle->idle_start_watch = e_flag_new ();
+ 		pthread_create (&idle->idle_thread_id, NULL, idle_thread, is);
+ 	} else
+ 		e_flag_set (idle->idle_start_watch);
+ 
+ 	idle->in_idle = TRUE;
+ 
+ 	IDLE_UNLOCK (idle);
+ }
+ 
+ static gboolean
+ imapx_in_idle (CamelIMAPXServer *is)
+ {
+ 	gboolean ret = FALSE;
+ 	CamelIMAPXIdle *idle = is->idle;
+ 
+ 	IDLE_LOCK (idle);
+ 	ret = idle->in_idle;
+ 	IDLE_UNLOCK (idle);
+ 
+ 	return ret;
+ }
+ 
+ static gboolean
+ imapx_idle_supported (CamelIMAPXServer *is)
+ {
+ 	return (is->cinfo && is->cinfo->capa & IMAPX_CAPABILITY_IDLE && is->use_idle);
+ }
+ 
+ // end IDLE
  /* ********************************************************************** */
  static void
- imapx_select_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
  {
  
- 	if (ic->status->result != IMAP_OK) {
+ 	if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
  		CamelDList failed;
  		CamelIMAPXCommand *cw, *cn;
  
@@@ -1751,18 -2418,31 +2422,33 @@@ imapx_command_append_message_done (Came
  	   and also create a correctly numbered MessageInfo, without losing any information.
  	   Otherwise we have to wait for the server to less us know it was appended. */
  
- 	if (ic->status->result == IMAP_OK) {
- 		if (ic->status->condition == IMAP_APPENDUID) {
+ 	mi = camel_message_info_clone(job->u.append_message.info);
+ 	old_uid = g_strdup (mi->uid);
+ 
+ 	if (!camel_exception_is_set (ic->ex) && ic->status->result == IMAPX_OK) {
+ 		if (ic->status->condition == IMAPX_APPENDUID) {
  			printf("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid);
  			if (ic->status->u.appenduid.uidvalidity == is->uidvalidity) {
- 				mi = camel_message_info_clone(job->u.append_message.info);
- 				mi->uid = g_strdup_printf("%u", (guint)ic->status->u.appenduid.uid);
- 				cur = imapx_get_path_uid(is, job->folder, NULL, mi->uid);
+ 				CamelFolderChangeInfo *changes;
++				char *uid;
+ 
 -				mi->uid = g_strdup_printf("%u", (guint)ic->status->u.appenduid.uid);
++				uid = g_strdup_printf("%u", (guint)ic->status->u.appenduid.uid);
++				mi->uid = camel_pstring_add (uid, TRUE);
+ 
+ 				cur = camel_data_cache_get_filename  (ifolder->cache, "cur", mi->uid, NULL);
  				printf("Moving cache item %s to %s\n", job->u.append_message.path, cur);
- 				link(job->u.append_message.path, cur);
+ 				link (job->u.append_message.path, cur);
+ 
+ 				/* should we update the message count ? */
+ 				camel_folder_summary_add (job->folder->summary, mi);
+ 
+ 				changes = camel_folder_change_info_new ();
+ 				camel_folder_change_info_add_uid (changes, mi->uid);
+ 				camel_object_trigger_event (CAMEL_OBJECT (job->folder), "folder_changed",
+ 						changes);
+ 				camel_folder_change_info_free (changes);
+ 
  				g_free(cur);
- 				camel_folder_summary_add(job->folder->summary, mi);
- 				camel_message_info_free(mi);
  			} else {
  				printf("but uidvalidity changed, uh ...\n");
  			}
@@@ -1805,12 -2487,12 +2493,12 @@@ imapx_job_append_message_start(CamelIMA
  /* ********************************************************************** */
  
  static gint
--imapx_refresh_info_uid_cmp(gconstpointer ap, gconstpointer bp)
++imapx_refresh_info_uid_cmp (gconstpointer ap, gconstpointer bp)
  {
  	guint av, bv;
  
--	av = strtoul((const gchar *)ap, NULL, 10);
--	bv = strtoul((const gchar *)bp, NULL, 10);
++	av = g_ascii_strtoull ((const gchar *)ap, NULL, 10);
++	bv = g_ascii_strtoull ((const gchar *)bp, NULL, 10);
  
  	if (av<bv)
  		return -1;
@@@ -1821,35 -2503,35 +2509,47 @@@
  }
  
  static gint
--imapx_refresh_info_cmp(gconstpointer ap, gconstpointer bp)
++imapx_uids_array_cmp (gconstpointer ap, gconstpointer bp)
++{
++	const gchar **a = (const gchar **) ap;
++        const gchar **b = (const gchar **) bp;
++
++	return imapx_refresh_info_uid_cmp (*a, *b);
++}
++
++static gint
++imapx_refresh_info_cmp (gconstpointer ap, gconstpointer bp)
  {
  	const struct _refresh_info *a = ap;
  	const struct _refresh_info *b = bp;
  
--	return imapx_refresh_info_uid_cmp(a->uid, b->uid);
++	return imapx_refresh_info_uid_cmp (a->uid, b->uid);
  }
  
  /* skips over non-server uids (pending appends) */
- static guint 
- imapx_index_next (CamelFolderSummary *s, guint index)
+ static guint
 -imapx_index_next (CamelFolderSummary *s, guint index)
++imapx_index_next (GPtrArray *uids, CamelFolderSummary *s, guint index)
  {
--	guint count = 0;
  
--	count = camel_folder_summary_count (s);
 -
 -	while (index < count) {
 -		const CamelMessageInfo *info;
++	while (index < uids->len) {
++		CamelMessageInfo *info;
  
- 	while (index < count) {
- 		const CamelMessageInfo *info;
- 		
  		index++;
--		info = camel_folder_summary_index (s, index);
++		if(index >= uids->len)
++			break;
++
++		info = camel_folder_summary_uid (s, g_ptr_array_index (uids, index));
  		if (!info)
  			continue;
- 	       
+ 
  		if (info && (strchr(camel_message_info_uid(info), '-') != NULL)) {
++			camel_message_info_free (info);
  			printf("Ignoring offline uid '%s'\n", camel_message_info_uid(info));
--		} else
++		} else {
++			camel_message_info_free (info);
  			break;
- 	}	
++		}
+ 	}
  
  	return index;
  }
@@@ -1929,21 -2630,21 +2648,22 @@@ imapx_uid_cmp(gconstpointer ap, gconstp
  }
  
  static void
--imapx_job_refresh_info_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
++imapx_job_scan_changes_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
  {
  	CamelIMAPXJob *job = ic->job;
  	gint i;
  	GArray *infos = job->u.refresh_info.infos;
  
- 	if (ic->status->result == IMAP_OK) {
+ 	if (!camel_exception_is_set (ic->ex) && ic->status->result == IMAPX_OK) {
  		GCompareDataFunc uid_cmp = imapx_uid_cmp;
- 		const CamelMessageInfo *s_minfo = NULL;
+ 		CamelMessageInfo *s_minfo = NULL;
  		CamelIMAPXMessageInfo *info;
  		CamelFolderSummary *s = job->folder->summary;
- 		GSList *removed = NULL;
+ 		GSList *removed = NULL, *l;
  		gboolean fetch_new = FALSE;
  		gint i;
--		guint j = 0, total = 0;
++		guint j = 0;
++		GPtrArray *uids;
  
  		/* Here we do the typical sort/iterate/merge loop.
  		   If the server flags dont match what we had, we modify our
@@@ -1954,67 -2655,93 +2674,105 @@@
  		   anything missing in our summary, and also queue up jobs
  		   for all outstanding messages to be uploaded */
  
++		/* obtain a copy to be thread safe */
++		uids = camel_folder_summary_array (s);
++
  		qsort(infos->data, infos->len, sizeof(struct _refresh_info), imapx_refresh_info_cmp);
--		total = camel_folder_summary_count (s);
--		s_minfo = camel_folder_summary_index (s, 0);
- 		
- 		for (i=0; i<infos->len ; i++) {
++		g_ptr_array_sort(uids, (GCompareFunc) imapx_uids_array_cmp);
++
++		if (uids->len)
++			s_minfo = camel_folder_summary_uid (s, g_ptr_array_index (uids, 0));
+ 
+ 		for (i=0; i<infos->len; i++) {
  			struct _refresh_info *r = &g_array_index(infos, struct _refresh_info, i);
  
--			while (s_minfo && uid_cmp(camel_message_info_uid(s_minfo), r->uid, s) < 0) {
- 				const char *uid = camel_message_info_uid (s_minfo);
++			while (s_minfo && uid_cmp (camel_message_info_uid(s_minfo), r->uid, s) < 0) {
+ 				const gchar *uid = camel_message_info_uid (s_minfo);
  
  				camel_folder_change_info_remove_uid (job->u.refresh_info.changes, uid);
- 				removed = g_slist_prepend (removed, (gpointer )uid);
- 				camel_folder_summary_remove_uid_fast (s, s_minfo->uid);
- 				j = imapx_index_next (s, j);
- 				s_minfo = camel_folder_summary_index (s, j);
+ 				removed = g_slist_prepend (removed, (gpointer ) g_strdup (uid));
+ 				camel_message_info_free (s_minfo);
++				s_minfo = NULL;
+ 				
 -				j = imapx_index_next (s, j);
 -				s_minfo = camel_folder_summary_index (s, j);
++				j = imapx_index_next (uids, s, j);
++				if (j < uids->len)
++					s_minfo = camel_folder_summary_uid (s, g_ptr_array_index (uids, j));
  			}
  
  			info = NULL;
  			if (s_minfo && uid_cmp(s_minfo->uid, r->uid, s) == 0) {
- 				printf("already have '%s'\n", r->uid);
  				info = (CamelIMAPXMessageInfo *)s_minfo;
- 				if (info->server_flags !=  r->server_flags
- 				    && camel_message_info_set_flags((CamelMessageInfo *)info, info->server_flags ^ r->server_flags, r->server_flags))
+ 
+ 				if (imapx_update_message_info_flags ((CamelMessageInfo *) info, r->server_flags, r->server_user_flags, job->folder))
  					camel_folder_change_info_change_uid (job->u.refresh_info.changes, camel_message_info_uid (s_minfo));
- 				g_free(r->uid);
- 				r->uid = NULL;
- 			} else 
+ 				r->exists = TRUE;
+ 			} else
  				fetch_new = TRUE;
- 			
- 			j = imapx_index_next (s, j);
- 			s_minfo = camel_folder_summary_index (s, j);
  
- 			if (j > total)
 -			if (s_minfo)
++			if (s_minfo) {
+ 				camel_message_info_free (s_minfo);
++				s_minfo = NULL;
++			}
+ 			
 -			if (j > total)
++			if (j >= uids->len)
  				break;
+ 
 -			j = imapx_index_next (s, j);
 -			s_minfo = camel_folder_summary_index (s, j);
++			j = imapx_index_next (uids, s, j);
++			if (j < uids->len)
++				s_minfo = camel_folder_summary_uid (s, g_ptr_array_index (uids, j));
  		}
  
- 		while (j < total) {
- 			s_minfo = camel_folder_summary_index (s, j);
+ 		if (s_minfo)
+ 			camel_message_info_free (s_minfo);
+ 
 -		while (j < total) {
 -			s_minfo = camel_folder_summary_index (s, j);
++		while (j < uids->len) {
++			s_minfo = camel_folder_summary_uid (s, g_ptr_array_index (uids, j));
  
  			if (!s_minfo) {
- 				j++;	
+ 				j++;
  				continue;
  			}
- 			
+ 
  			printf("Message %s vanished\n", s_minfo->uid);
- 			camel_folder_change_info_remove_uid (job->u.refresh_info.changes, s_minfo->uid);
- 			camel_folder_summary_remove_uid_fast (s, s_minfo->uid);
- 			removed = g_slist_prepend (removed, s_minfo->uid);
+ 			removed = g_slist_prepend (removed, (gpointer) g_strdup (s_minfo->uid));
+ 			camel_message_info_free (s_minfo);
  			j++;
- 		} 
+ 		}
+ 
+ 		for (l = removed; l != NULL; l = g_slist_next (l)) {
+ 			gchar *uid = (gchar *) l->data;
+ 			CamelMessageInfo *mi;
  
- 		camel_db_delete_uids (is->store, s->folder->full_name, removed, NULL);
+ 			mi = camel_folder_summary_uid (is->select_folder->summary, uid);
+ 			if (mi) {
+ 				imapx_update_summary_for_removed_message (mi, is->select_folder);
+ 				camel_message_info_free (mi);
+ 			}
+ 
+ 			camel_folder_change_info_remove_uid (job->u.refresh_info.changes, uid);
+ 			camel_folder_summary_remove_uid_fast (s, uid);
+ 		}
+ 
+ 		if (removed) {
+ 			camel_db_delete_uids (is->store->cdb_w, s->folder->full_name, removed, NULL);
+ 			g_slist_foreach (removed, (GFunc) g_free, NULL);
+ 			g_slist_free (removed);
+ 		}
+ 		
+ 		imapx_update_store_summary (job->folder);
  
  		if (camel_folder_change_info_changed(job->u.refresh_info.changes))
  			camel_object_trigger_event(job->folder, "folder_changed", job->u.refresh_info.changes);
  		camel_folder_change_info_clear(job->u.refresh_info.changes);
  
++		camel_folder_free_uids (job->folder, uids);
++
  		/* If we have any new messages, download their headers, but only a few (100?) at a time */
  		if (fetch_new) {
- 			imapx_uidset_init(&job->u.refresh_info.uidset, 100, 0);
- 			imapx_job_refresh_info_step_done(is, ic);
+ 			camel_operation_start (job->op, _("Fetching summary information for new messages in %s"), job->folder->name);
+ 			imapx_uidset_init(&job->u.refresh_info.uidset, BATCH_FETCH_COUNT, 0);
+ 			/* command will be free'ed in step_fetch_done */
+ 			imapx_command_step_fetch_done(is, ic);
  			return;
  		}
  	} else {
@@@ -2032,7 -2764,7 +2795,7 @@@
  }
  
  static void
--imapx_job_refresh_info_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
++imapx_job_scan_changes_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
  {
  	CamelIMAPXCommand *ic;
  
@@@ -2040,11 -2773,75 +2804,142 @@@
  	ic = camel_imapx_command_new ("FETCH", job->folder->full_name,
  				     "FETCH 1:* (UID FLAGS)");
  	ic->job = job;
--	ic->complete = imapx_job_refresh_info_done;
++	ic->complete = imapx_job_scan_changes_done;
  	job->u.refresh_info.infos = g_array_new (0, 0, sizeof(struct _refresh_info));
  	imapx_command_queue (is, ic);
  }
  
+ static void
+ imapx_command_fetch_new_messages_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
+ {
+ 	if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+ 		if (!camel_exception_is_set (ic->ex))
+ 			camel_exception_setv(ic->job->ex, 1, "Error fetching new messages : %s", ic->status->text);
+ 		else
+ 			camel_exception_xfer (ic->job->ex, ic->ex);
+ 		goto exception;
+ 	}
+ 
+ 	if (camel_folder_change_info_changed(ic->job->u.refresh_info.changes)) {
+ 		imapx_update_store_summary (ic->job->folder);
+ 		camel_folder_summary_save_to_db (ic->job->folder->summary, NULL);
+ 		camel_object_trigger_event(ic->job->folder, "folder_changed", ic->job->u.refresh_info.changes);
++		camel_folder_change_info_clear(ic->job->u.refresh_info.changes);
+ 	}
+ 
+ 
+ exception:
 -	camel_operation_end (ic->job->op);
 -	
+ 	if (ic->job->noreply)
+ 		camel_folder_change_info_free(ic->job->u.refresh_info.changes);
+ 
++	if (ic->job->op)
++		camel_operation_unref (ic->job->op);
+ 	imapx_job_done (is, ic->job);
+ 	camel_imapx_command_free (ic);
+ }
+ 
+ static void
+ imapx_job_fetch_new_messages_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
+ {
+ 	CamelIMAPXCommand *ic;
+ 	CamelFolder *folder = job->folder;
+ 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) folder;
+ 	guint32 total, diff;
+ 	gchar *uid = NULL;
+ 
+ 	total = camel_folder_summary_count (folder->summary);
+ 	diff = ifolder->exists_on_server - total;
+ 
+ 	if (total > 0)
+ 		uid = camel_folder_summary_uid_from_index (folder->summary, total - 1);
+ 	else
+ 		uid = g_strdup ("1");
+ 
+ 	camel_operation_start (job->op, _("Fetching summary information for new messages in %s"), folder->name);
+ 
+ 	if (diff > BATCH_FETCH_COUNT) {
+ 		ic = camel_imapx_command_new ("FETCH", job->folder->full_name,
+ 				     "FETCH %s:* (UID FLAGS)", uid);
+ 		imapx_uidset_init(&job->u.refresh_info.uidset, BATCH_FETCH_COUNT, 0);
+ 		job->u.refresh_info.infos = g_array_new (0, 0, sizeof(struct _refresh_info));
+ 		ic->complete = imapx_command_step_fetch_done;
+ 	} else {
+ 		ic = camel_imapx_command_new ("FETCH", job->folder->full_name,
+ 					"UID FETCH %s:* (RFC822.SIZE RFC822.HEADER FLAGS)", uid);
+ 		ic->complete = imapx_command_fetch_new_messages_done;
+ 	}
+ 
+ 	g_free (uid);
+ 	ic->job = job;
+ 	imapx_command_queue (is, ic);
+ }
+ 
++static void
++imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
++{
++	guint32 total;
++	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
++	CamelFolder *folder = job->folder;
++	CamelException *ex = job->ex;
++	
++	total = camel_folder_summary_count (folder->summary);
++	/* Check if there are any new messages. The old imap doc says one needs to reselect in case of inbox to fetch
++	   new messages. Need to check if its still true. Just use noop now */
++	if (ifolder->exists_on_server == total) {
++		camel_imapx_server_noop (is, folder, ex);
++
++		if (camel_exception_is_set (ex))
++			goto exception;
++	}
++
++	/* Fetch the new messages */
++	if (ifolder->exists_on_server > total || total == 0)
++	{
++		imapx_server_fetch_new_messages (is, folder, FALSE, job->ex);
++		if (camel_exception_is_set (job->ex))
++			goto exception;
++	}
++
++	/* Sync changes before fetching status, else unread count will not match. need to think about better ways for this */
++	camel_imapx_server_sync_changes (is, folder, ex);
++	if (camel_exception_is_set (job->ex))
++		goto exception;
++
++	/* Check if a rescan is needed */
++	total = camel_folder_summary_count (folder->summary);
++	if (ifolder->exists_on_server == total) {
++		guint32 unread;
++		CamelIMAPXCommand *ic;
++
++		ic = camel_imapx_command_new ("STATUS", folder->full_name, "STATUS %s (MESSAGES UNSEEN)", folder->full_name);
++		ic->job = job;
++		ic->complete = imapx_command_status_done;
++		imapx_command_run_sync (is, ic);
++
++		if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
++			if (!camel_exception_is_set (ic->ex))
++				camel_exception_setv(job->ex, 1, "Error refreshing folder: %s", ic->status->text);
++			else
++				camel_exception_xfer (job->ex, ic->ex);
++
++			camel_imapx_command_free (ic);
++			goto exception;
++		}
++		camel_imapx_command_free (ic);
++
++		camel_object_get (folder, NULL, CAMEL_FOLDER_UNREAD, &unread, NULL);
++		if (ifolder->exists_on_server == total && unread == ifolder->unread_on_server)
++			goto exception;
++	}
++
++	imapx_job_scan_changes_start (is, job);
++	return;
++
++exception:
++	imapx_job_done (is, job);
++}
++
++
  /* ********************************************************************** */
  
  static void
@@@ -2116,24 -3008,57 +3106,60 @@@ imapx_command_sync_changes_done (CamelI
  	   that what we just set is actually what is on the server now .. but
  	   if it isn't, i guess we'll fix up next refresh */
  
- 	if (ic->status->result != IMAP_OK && !camel_exception_is_set(job->ex))
- 		camel_exception_setv(job->ex, 1, "Error syncing changes: %s", ic->status->text);
+ 	if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+ 		if (!camel_exception_is_set (ic->ex))
+ 			camel_exception_setv(job->ex, 1, "Error syncing changes: %s", ic->status->text);
+ 		else
+ 			camel_exception_xfer (job->ex, ic->ex);
+ 		failed = TRUE;
+ 	}
  
- 	if (job->commands == 0) {
- 		if (!camel_exception_is_set(job->ex)) {
- 			gint i;
- /*
- 			for (i=0;i<job->u.sync_changes.infos->len;i++) {
- 				CamelIMAPXMessageInfo *info = job->u.sync_changes.infos->pdata[i];
+ 	/* lock cache ? */
+ 	if (!failed)
+ 	{
+ 		gint i;
  
- 				info->server_flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
+ 		for (i=0;i<job->u.sync_changes.changed_uids->len;i++) {
+ 			CamelIMAPXMessageInfo *info = (CamelIMAPXMessageInfo *) camel_folder_summary_uid (job->folder->summary,
+ 					job->u.sync_changes.changed_uids->pdata[i]);
+ 
++			if (!info)
++				continue;
++			
+ 			info->server_flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
+ 			info->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
+ 			info->info.dirty = TRUE;
+ 
+ 			camel_folder_summary_touch (job->folder->summary);
+ 			camel_message_info_free (info);
+ 
+ 			/* FIXME: move over user flags too */
+ 		}
+ 	}
+ 
+ 	if (job->commands == 0) {
+ 		if (job->folder->summary && (job->folder->summary->flags & CAMEL_SUMMARY_DIRTY) != 0) {
+ 			CamelStoreInfo *si;
+ 
+ 			/* ... and store's summary when folder's summary is dirty */
+ 			si = camel_store_summary_path ((CamelStoreSummary *)((CamelIMAPXStore *) job->folder->parent_store)->summary, job->folder->full_name);
+ 			if (si) {
+ 				if (si->total != job->folder->summary->saved_count || si->unread != job->folder->summary->unread_count) {
+ 					si->total = job->folder->summary->saved_count;
+ 					si->unread = job->folder->summary->unread_count;
+ 					camel_store_summary_touch ((CamelStoreSummary *)((CamelIMAPXStore *) job->folder->parent_store)->summary);
+ 				}
  
- 				/* FIXME: move over user flags too
- 			}*/
+ 				camel_store_summary_info_free ((CamelStoreSummary *)((CamelIMAPXStore *) job->folder->parent_store)->summary, si);
+ 			}
  		}
- 		camel_dlist_remove((CamelDListNode *)job);
- 		camel_msgport_reply((CamelMsg *)job);
+ 
+ 		camel_folder_summary_save_to_db (job->folder->summary, job->ex);
+ 		camel_store_summary_save((CamelStoreSummary *)((CamelIMAPXStore *) job->folder->parent_store)->summary);
+ 
+ 		imapx_job_done (is, job);
  	}
+ 	camel_imapx_command_free (ic);
  }
  
  static void
@@@ -2157,11 -3082,13 +3183,19 @@@ imapx_job_sync_changes_start(CamelIMAPX
  
  			printf("checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name);
  			imapx_uidset_init(&ss, 0, 100);
- 			for (i=0;i<infos->len;i++) {
- 				CamelIMAPXMessageInfo *info = infos->pdata[i];
- 				guint32 flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
- 				guint32 sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
- 				gint send = 0;
+ 			for (i = 0; i < uids->len; i++) {
+ 				CamelIMAPXMessageInfo *info = (CamelIMAPXMessageInfo *)camel_folder_summary_uid
+ 										(job->folder->summary, uids->pdata[i]);
++				guint32 flags;
++				guint32 sflags;
++				gint send;
+ 
 -				guint32 flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
 -				guint32 sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
 -				gint send = 0;
++				if (!info)
++					continue;
++				
++				flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
++				sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
++				send = 0;
  
  				if ( (on && (((flags ^ sflags) & flags) & flag))
  				     || (!on && (((flags ^ sflags) & ~flags) & flag))) {
@@@ -2518,6 -3579,7 +3686,8 @@@ imapx_server_get_message (CamelIMAPXSer
  	imapx_run_job(is, job);
  
  	stream = job->u.get_message.stream;
 -	camel_operation_unref (job->op);
++	if (job->op)
++		camel_operation_unref (job->op);
  	g_free(job);
  
  	if (stream) {
@@@ -2678,39 -3752,103 +3860,43 @@@ getmsgs(gpointer d
  } */
  
  void
- camel_imapx_server_refresh_info(CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+ camel_imapx_server_noop (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
+ {
+ 	CamelIMAPXJob *job;
+ 
+ 	job = g_malloc0(sizeof(*job));
+ 	job->type = IMAPX_JOB_NOOP;
+ 	job->start = imapx_job_noop_start;
+ 	job->folder = folder;
+ 	job->ex = ex;
+ 
+ 	imapx_run_job(is, job);
+ 	g_free(job);
+ }
+ 
+ void
+ camel_imapx_server_refresh_info (CamelIMAPXServer *is, CamelFolder *folder, CamelException *ex)
  {
  	CamelIMAPXJob *job;
  
  	job = g_malloc0(sizeof(*job));
  	job->type = IMAPX_JOB_REFRESH_INFO;
 -	job->start = imapx_job_fetch_new_messages_start;
 +	job->start = imapx_job_refresh_info_start;
  	job->folder = folder;
  	job->ex = ex;
+ 	job->op = camel_operation_registered ();
  	job->u.refresh_info.changes = camel_folder_change_info_new();
  
- 	imapx_run_job(is, job);
 -	total = camel_folder_summary_count (folder->summary);
 -
 -	/* Check if there are any new messages. The old imap doc says one needs to reselect in case of inbox to fetch
 -	    new messages. Need to check if its still true. Just use noop now */
 -	if (ifolder->exists_on_server == total) {
 -		camel_imapx_server_noop (is, folder, ex);
 -
 -		if (camel_exception_is_set (ex))
 -			goto done;
 -	}
 -
 -	/* Fetch the new messages */
 -	if (ifolder->exists_on_server > total)
 -	{
 -		imapx_run_job(is, job);
 -
 -		if (camel_folder_change_info_changed(job->u.refresh_info.changes))
 -			camel_object_trigger_event(folder, "folder_changed", job->u.refresh_info.changes);
 -		camel_folder_change_info_clear(job->u.refresh_info.changes);
 -
 -		if (camel_exception_is_set (job->ex))
 -			goto done;
 -	}
 -
 -	/* Sync changes before fetching status, else unread count will not match. need to think about better ways for this */
 -	camel_imapx_server_sync_changes (is, folder, ex);
 -	if (camel_exception_is_set (job->ex))
 -		goto done;
 -
 -	total = camel_folder_summary_count (folder->summary);
 -
 -	/* Check if a rescan is needed */
 -	if (ifolder->exists_on_server == total) {
 -		guint32 unread;
 -
 -		ic = camel_imapx_command_new ("STATUS", folder->full_name, "STATUS %s (MESSAGES UNSEEN)", folder->full_name);
 -		ic->job = job;
 -		ic->complete = imapx_command_status_done;
 -		imapx_command_run_sync (is, ic);
 -
 -		if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
 -			if (!camel_exception_is_set (ic->ex))
 -				camel_exception_setv(job->ex, 1, "Error refreshing folder: %s", ic->status->text);
 -			else
 -				camel_exception_xfer (job->ex, ic->ex);
 -
 -			camel_imapx_command_free (ic);
 -			goto done;
 -		}
 -		camel_imapx_command_free (ic);
 -
 -		camel_object_get (folder, NULL, CAMEL_FOLDER_UNREAD, &unread, NULL);
 -		if (ifolder->exists_on_server == total && unread == ifolder->unread_on_server)
 -			goto done;
 -	}
 -
 -	/* sync all the changed messages */
 -	job->start = imapx_job_refresh_info_start;
+ 	imapx_run_job (is, job);
  
- /*	if (camel_change_info_changed(job->u.refresh_info.changes))
+ 	if (camel_folder_change_info_changed(job->u.refresh_info.changes))
  		camel_object_trigger_event(folder, "folder_changed", job->u.refresh_info.changes);
- 	camel_change_info_free(job->u.refresh_info.changes);*/
  
 -done:
+ 	camel_folder_change_info_free(job->u.refresh_info.changes);
 -	camel_operation_unref (job->op);
++	
++	if (job->op)
++		camel_operation_unref (job->op);
  	g_free(job);
- 
- /*	{
- 		gint i;
- 		gint c = 3;
- 		pthread_t ids[10];
- 
- 		threadfolder = folder;
- 		threaditer = camel_folder_search(folder, NULL, NULL, NULL, NULL);
- 		for (i=0;i<c;i++)
- 			pthread_create(&ids[i], NULL, getmsgs, NULL);
- 
- 		for (i=0;i<c;i++)
- 			pthread_join(ids[i], NULL);
- 		camel_iterator_free(threaditer);
- 	} */
  }
  
  static void
@@@ -2744,13 -3892,26 +3940,29 @@@ camel_imapx_server_sync_changes(CamelIM
  	   one for each flag being turned off, including each
  	   info being turned off, and one for each flag being turned on.
  	*/
+ 	uids = camel_folder_summary_get_changed (folder->summary);
+ 
+ 	if (uids->len == 0) {
+ 		g_ptr_array_free (uids, TRUE);
+ 		return;
+ 	}
  
  	off_orset = on_orset = 0;
- 	for (i=0;i<infos->len;i++) {
+ 	for (i=0; i < uids->len; i++) {
  		guint32 flags, sflags;
  		CamelFlag *uflags, *suflags;
+ 		guint j = 0;
+ 
+ 		info = (CamelIMAPXMessageInfo *) camel_folder_summary_uid (folder->summary, uids->pdata[i]);
+ 
++		if (!info)
++			continue;
++
+ 		if (!(info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
+ 			camel_message_info_free (info);
+ 			continue;
+ 		}
  
- 		info = infos->pdata[i];
  		flags = ((CamelMessageInfoBase *)info)->flags & CAMEL_IMAPX_SERVER_FLAGS;
  		sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
  		if (flags != sflags) {



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