/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* camel-disco-folder.c: abstract class for a disconnectable folder */ /* * Authors: Dan Winship * * Copyright (C) 2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ #ifdef HAVE_CONFIG_H #include #endif #include "camel-disco-folder.h" #include "camel-disco-store.h" #include "camel-exception.h" #define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (o))) #define CDF_CLASS(o) (CAMEL_DISCO_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (o))) static CamelFolderClass *parent_class = NULL; static void disco_refresh_info (CamelFolder *folder, CamelException *ex); static void disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex); static void disco_expunge (CamelFolder *folder, CamelException *ex); static void disco_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex); static void disco_copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, CamelException *ex); static void disco_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, CamelException *ex); static void disco_cache_message (CamelDiscoFolder *disco_folder, const char *uid, CamelException *ex); static void disco_prepare_for_offline (CamelDiscoFolder *disco_folder, const char *expression, CamelException *ex); static void camel_disco_folder_class_init (CamelDiscoFolderClass *camel_disco_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_disco_folder_class); parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ())); /* virtual method definition */ camel_disco_folder_class->cache_message = disco_cache_message; camel_disco_folder_class->prepare_for_offline = disco_prepare_for_offline; /* virtual method overload */ camel_folder_class->refresh_info = disco_refresh_info; camel_folder_class->sync = disco_sync; camel_folder_class->expunge = disco_expunge; camel_folder_class->append_message = disco_append_message; camel_folder_class->copy_messages_to = disco_copy_messages_to; camel_folder_class->move_messages_to = disco_move_messages_to; } CamelType camel_disco_folder_get_type (void) { static CamelType camel_disco_folder_type = CAMEL_INVALID_TYPE; if (camel_disco_folder_type == CAMEL_INVALID_TYPE) { camel_disco_folder_type = camel_type_register ( CAMEL_FOLDER_TYPE, "CamelDiscoFolder", sizeof (CamelDiscoFolder), sizeof (CamelDiscoFolderClass), (CamelObjectClassInitFunc) camel_disco_folder_class_init, NULL, NULL, NULL); } return camel_disco_folder_type; } static void disco_refresh_info (CamelFolder *folder, CamelException *ex) { if (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store)) != CAMEL_DISCO_STORE_ONLINE) return; CDF_CLASS (folder)->refresh_info_online (folder, ex); } static void disco_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { if (expunge) { disco_expunge (folder, ex); if (camel_exception_is_set (ex)) return; } switch (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store))) { case CAMEL_DISCO_STORE_ONLINE: CDF_CLASS (folder)->sync_online (folder, ex); break; case CAMEL_DISCO_STORE_OFFLINE: CDF_CLASS (folder)->sync_offline (folder, ex); break; case CAMEL_DISCO_STORE_RESYNCING: CDF_CLASS (folder)->sync_resyncing (folder, ex); break; } } static void disco_expunge_uids (CamelFolder *folder, GPtrArray *uids, CamelException *ex) { CamelDiscoStore *disco = CAMEL_DISCO_STORE (folder->parent_store); if (uids->len == 0) return; switch (camel_disco_store_status (disco)) { case CAMEL_DISCO_STORE_ONLINE: CDF_CLASS (folder)->expunge_uids_online (folder, uids, ex); break; case CAMEL_DISCO_STORE_OFFLINE: CDF_CLASS (folder)->expunge_uids_offline (folder, uids, ex); break; case CAMEL_DISCO_STORE_RESYNCING: CDF_CLASS (folder)->expunge_uids_resyncing (folder, uids, ex); break; } } static void disco_expunge (CamelFolder *folder, CamelException *ex) { GPtrArray *uids; int i, count; CamelMessageInfo *info; uids = g_ptr_array_new (); count = camel_folder_summary_count (folder->summary); for (i = 0; i < count; i++) { info = camel_folder_summary_index (folder->summary, i); if (info->flags & CAMEL_MESSAGE_DELETED) g_ptr_array_add (uids, g_strdup (camel_message_info_uid (info))); camel_folder_summary_info_free (folder->summary, info); } disco_expunge_uids (folder, uids, ex); for (i = 0; i < uids->len; i++) g_free (uids->pdata[i]); g_ptr_array_free (uids, TRUE); } static void disco_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex) { CamelDiscoStore *disco = CAMEL_DISCO_STORE (folder->parent_store); switch (camel_disco_store_status (disco)) { case CAMEL_DISCO_STORE_ONLINE: CDF_CLASS (folder)->append_online (folder, message, info, ex); break; case CAMEL_DISCO_STORE_OFFLINE: CDF_CLASS (folder)->append_offline (folder, message, info, ex); break; case CAMEL_DISCO_STORE_RESYNCING: CDF_CLASS (folder)->append_resyncing (folder, message, info, ex); break; } } static void disco_copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, CamelException *ex) { CamelDiscoStore *disco = CAMEL_DISCO_STORE (source->parent_store); switch (camel_disco_store_status (disco)) { case CAMEL_DISCO_STORE_ONLINE: CDF_CLASS (source)->copy_online (source, uids, destination, ex); break; case CAMEL_DISCO_STORE_OFFLINE: CDF_CLASS (source)->copy_offline (source, uids, destination, ex); break; case CAMEL_DISCO_STORE_RESYNCING: CDF_CLASS (source)->copy_resyncing (source, uids, destination, ex); break; } } static void disco_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *destination, CamelException *ex) { CamelDiscoStore *disco = CAMEL_DISCO_STORE (source->parent_store); switch (camel_disco_store_status (disco)) { case CAMEL_DISCO_STORE_ONLINE: CDF_CLASS (source)->move_online (source, uids, destination, ex); break; case CAMEL_DISCO_STORE_OFFLINE: CDF_CLASS (source)->move_offline (source, uids, destination, ex); break; case CAMEL_DISCO_STORE_RESYNCING: CDF_CLASS (source)->move_resyncing (source, uids, destination, ex); break; } } /** * camel_disco_folder_expunge_uids: * @folder: a (disconnectable) folder * @uids: array of UIDs to expunge * @ex: a CamelException * * This expunges the messages in @uids from @folder. It should take * whatever steps are needed to avoid expunging any other messages, * although in some cases it may not be possible to avoid expunging * messages that are marked deleted by another client at the same time * as the expunge_uids call is running. **/ void camel_disco_folder_expunge_uids (CamelFolder *folder, GPtrArray *uids, CamelException *ex) { disco_expunge_uids (folder, uids, ex); } static void disco_cache_message (CamelDiscoFolder *disco_folder, const char *uid, CamelException *ex) { g_warning ("CamelDiscoFolder::cache_message not implemented for `%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (disco_folder))); } /** * camel_disco_folder_cache_message: * @disco_folder: the folder * @uid: the UID of the message to cache * @ex: a CamelException * * Requests that @disco_folder cache message @uid to disk. **/ void camel_disco_folder_cache_message (CamelDiscoFolder *disco_folder, const char *uid, CamelException *ex) { CDF_CLASS (disco_folder)->cache_message (disco_folder, uid, ex); } static void disco_prepare_for_offline (CamelDiscoFolder *disco_folder, const char *expression, CamelException *ex) { CamelFolder *folder = CAMEL_FOLDER (disco_folder); GPtrArray *uids; int i; if (expression) uids = camel_folder_search_by_expression (folder, expression, ex); else uids = camel_folder_get_uids (folder); if (!uids) return; for (i = 0; i < uids->len; i++) { camel_disco_folder_cache_message (disco_folder, uids->pdata[i], ex); if (camel_exception_is_set (ex)) break; } if (expression) camel_folder_search_free (folder, uids); else camel_folder_free_uids (folder, uids); } /** * camel_disco_folder_prepare_for_offline: * @disco_folder: the folder * @expression: an expression describing messages to synchronize, or %NULL * if all messages should be sync'ed. * @ex: a CamelException * * This prepares @disco_folder for offline operation, by downloading * the bodies of all messages described by @expression (using the * same syntax as camel_folder_search_by_expression() ). **/ void camel_disco_folder_prepare_for_offline (CamelDiscoFolder *disco_folder, const char *expression, CamelException *ex) { g_return_if_fail (CAMEL_IS_DISCO_FOLDER (disco_folder)); CDF_CLASS (disco_folder)->prepare_for_offline (disco_folder, expression, ex); } ss='deletions'>-2/+2 * - Fix a minor glitch in the OSS patchesehaupt2010-03-284-8/+83 * - update to 1.4.1dinoex2010-03-28234-208/+239 * audio/ym2wav is now part of audio/stymulatorehaupt2010-03-284-42/+0 * Add stymulator, a command-line Yamaha YM2149 (.ym) chiptune player.ehaupt2010-03-2814-0/+635 * RC_SUBR_SUFFIX has not been needed for a long time now, all supporteddougb2010-03-272-3/+3 * Remove the remaining examples of quotes around /etc/rc.subrdougb2010-03-271-1/+1 * Begin the process of deprecating sysutils/rc_subr bydougb2010-03-2717-17/+17 * Add ym2wav, convert .ym (Yamaha YM2149 soundchip) music files to wav.ehaupt2010-03-244-0/+42 * - Fix plist for the standard case [1]gahr2010-03-241-0/+2 * - Chase x11-toolkits/fltk updategahr2010-03-248-25/+15 * - Update to 0.23amdmi32010-03-233-33/+17 * - Update to 1.4.18sylvio2010-03-212-5/+4 * - Update to 2010.02.23sylvio2010-03-212-4/+4 * Discontinue audacious plugin support. The plugin won't build after audaciousehaupt2010-03-213-35/+2 * - Update to 0.7.2miwi2010-03-212-11/+5 * mcplay is a curses based front-end for various audio players. Itmiwi2010-03-219-0/+170 * - Update to 11.4dhn2010-03-203-4/+5 * Update cmus to 2.3.1, add Pulseaudio support.lx2010-03-194-11/+20 * - Update to 0.3.1.0amdmi32010-03-185-299/+328 * - The maintainer reappearedpav2010-03-142-2/+2 * Mark BROKEN on 8.x: does not builderwin2010-03-133-0/+12 * Update to 0.11.tobez2010-03-122-4/+4 * - Update to 0.62wen2010-03-122-4/+4 * Update to 0.97ehaupt2010-03-102-4/+4 * Don't depend on libcompat.ed2010-03-092-1/+14 * Update to 1.220.tobez2010-03-082-4/+4 * - Update to 1.4.4sylvio2010-03-083-5/+6 * - Update to 0.5.2dhn2010-03-072-4/+4 * - Update to 11.3dhn2010-03-074-71/+10 * Update to 1.4makc2010-03-076-11/+12 * - Update to 2.7.1sylvio2010-03-022-4/+4 * Update to 0.12.7.marcus2010-03-014-39/+55 * Update to 1.10.1.novel2010-02-282-4/+4 * - Update to 0.99.8wen2010-02-282-5/+4 * - Update to 1.2gahr2010-02-277-90/+109 * - Update to 0.10.18wen2010-02-264-10/+8 * - S/ONLY_FOR_ARCH/ONLY_FOR_ARCHSmiwi2010-02-262-2/+2 * Add stdin support from:brooks2010-02-262-1/+262 * - Update to 1.3.2miwi2010-02-253-59/+35 * Upgrade to 7.4.2.brooks2010-02-253-49/+5 * - Update plist after doxygen updatepav2010-02-252-52/+51 * - Update to 0.59wen2010-02-222-4/+4 * - Update MASTER_SITESsylvio2010-02-212-18/+12 * - Update to 3.5.3tdb2010-02-202-5/+4 * - Update to 5.8.14tdb2010-02-203-5/+5 * Fix crash described at http://chakra-project.org/bbs/viewtopic.php?pid=14917lx2010-02-182-1/+21 * - Update to 0.8.3pav2010-02-162-6/+5 * Update to 0.10.tobez2010-02-142-4/+4 * - make portlint happymiwi2010-02-141-1/+0 * - Mark BROKEN fails to build on RELENG_8miwi2010-02-131-1/+7 * - Chase sysutils/sg3_utils slib bumpmiwi2010-02-131-2/+2 * - Update to 0.15.8miwi2010-02-133-15/+12 * - Correct login/LOGIN in rc scriptpav2010-02-122-3/+2 * - Update to 0.9beta11amdmi32010-02-123-14/+30 * Update to 0.09.tobez2010-02-122-4/+4 * - fix build with new GCCdinoex2010-02-111-0/+2 * - Reset more ports I don't use anymorepgollucci2010-02-111-1/+1 * DeaDBeeF (as in 0xDEADBEEF) is an audio player for GNU/Linux systems withamdmi32010-02-109-0/+274 * Update to 0.08.tobez2010-02-102-4/+4 * - Update to 1.9.1miwi2010-02-082-6/+10 * Update to 0.07. Change maintainer to perl@.tobez2010-02-082-5/+8 * - update to jpeg-8dinoex2010-02-05211-163/+212 * - Update to 3.8.2pgollucci2010-02-052-10/+12 * - USE_RC_SUBRpgollucci2010-02-042-8/+41 * - Lightweight media player based on Qt and Gstreamersylvio2010-02-045-0/+64 * - Update to 3.5.4jadawin2010-02-033-8/+4 * - Update to 1.4.17sylvio2010-02-032-4/+5 * - Fix build when doxygen is installed.miwi2010-02-022-4/+6 * Change MAINTAINER address to romain@.romain2010-02-025-5/+5 * Fix encoding of desktop filearved2010-02-012-2/+3 * - use $SUB_FILES to dynamically adjust pkg-messagepgollucci2010-01-313-7/+8 * The KDE FreeBSD team is proud to announce the release of SIP-4.10 andfluffy2010-01-302-0/+2 * - Update to 0.10.17dhn2010-01-306-10/+12 * - Update devel/sdl12 to version 1.2.14.mva2010-01-306-9/+18 * - Remove unneeded dependencies which is in perl-5.8.9 distkuriyama2010-01-296-14/+7 * - Update to 0.58wen2010-01-292-4/+4 * Sanitize previous commit.danfe2010-01-271-1/+1 * - Update my e-mail address in the ports I maintain.avilla2010-01-271-1/+1 * Update to 0.3.4, change default MIDI input from ALSA to JACK.makc2010-01-264-9/+38 * - Unbreak on sparc64 by explicitely depend on audio/jackgahr2010-01-261-7/+4 * - Update audacity to 1.3.11nemoliu2010-01-263-14/+14 * - Update to 1.0.4dhn2010-01-266-54/+5 * - Introduce USE_OPENAL variable for OpenAL consumerspav2010-01-265-15/+18 * - Update to 0.8.12miwi2010-01-253-68/+147 * - Update to 0.16miwi2010-01-252-12/+16 * - Fix build with qt4.6.1beat2010-01-241-5/+0 * Unconditionally depend on consolekit, and remove an unused configure option.marcus2010-01-241-3/+4 * - Add cpan site to WWWehaupt2010-01-231-0/+2 * - Update to 0.4.6miwi2010-01-226-114/+148 * - Update to 1.11.753.mva2010-01-224-12/+12 * Reset maintainer at his request.linimon2010-01-216-11/+3 * 2010-01-08 audio/dino: has been broken for 7 monthsmiwi2010-01-218-118/+0 * - Update to 5.8.12.tdb2010-01-213-4/+6 * - Mark BROKEN on 6.xpav2010-01-211-0/+4 * Liquidsoap is the audio stream generator of the Savonet project, notably usedwen2010-01-2017-0/+605 * Fix build on -CURRENT.jkim2010-01-202-0/+30 * libbpm is a C-library which contains low level beam position monitor (BPM)wen2010-01-195-0/+115 * Update to 2.28.5.marcus2010-01-183-5/+34 * - remove broken/expired ports@ portspgollucci2010-01-1811-118/+0 * Update to 20100101ehaupt2010-01-182-4/+4 * bump version for protobuf shlib version bump.vanilla2010-01-171-1/+2 * - Update to 1.2.1beat2010-01-1714-83/+193 * - Update to 1.0.3dhn2010-01-157-44/+23 * - Fix compilation in presence of x11-toolkits/fltkamdmi32010-01-154-6/+35 * - Update to 1.0.2dhn2010-01-156-54/+18 * - Add missing dependency on oggencamdmi32010-01-151-1/+3 * Update to 0.62ehaupt2010-01-134-51/+4 * - Update to 0.57wen2010-01-132-4/+4 * A Haskell binding for the OpenAL Utility Toolkit, which makespgj2010-01-135-0/+125 * A Haskell binding for the OpenAL cross-platform 3D audio API,pgj2010-01-135-0/+150 * - Update to 1.2.0amdmi32010-01-138-45/+61 * - adoptpgollucci2010-01-121-1/+1 * - Update Amarok to 2.2.2 "Maya Gold" release!fluffy2010-01-125-19/+432 * - Fix CVS blunderpgollucci2010-01-122-0/+15 * - Reset maintainer at his request.nemoliu2010-01-121-1/+1 * Add PORTSCOUT variable in order to skip version 0.1.19 which is just a tarbal...ehaupt2010-01-111-0/+2 * Remove the leftover mtpdevice plug-in directory.marcus2010-01-111-0/+1 * bump PORTREVISION for the recent update ofoliver2010-01-103-2/+3 * Fix pkg-plist: /compat/linux/include.edwin2010-01-102-0/+2 * - Update to 0.5dhn2010-01-092-9/+7 * - Add festival-freebsoft-utilsfluffy2010-01-085-0/+66 * - SUB_FILES += pkg-messagepgollucci2010-01-082-15/+1 * - Fix OPTIONspgollucci2010-01-081-1/+3 * Update to 3.1.0ehaupt2010-01-082-4/+4 * - Remove my mirror from MASTER_SITESgahr2010-01-071-2/+1 * Dynamically adjust pkg-messageehaupt2010-01-072-2/+5 * - Update to 2.2.7awen2010-01-072-4/+4 * - Update to 0.5.8awen2010-01-072-4/+4 * Update AdLib database fileehaupt2010-01-062-8/+10 * New port: linux-fmodapiedwin2010-01-066-0/+78 * - Chase audio/fluidsynth shlib bumpmiwi2010-01-065-8/+9 * - Update to 1.0.1dhn2010-01-061-125/+0 * - Update to 1.0.1dhn2010-01-0610-8/+109 * Chase audio/libadplug updateehaupt2010-01-051-1/+2 * Update to 1.7ehaupt2010-01-052-6/+5 * Update to 2.2ehaupt2010-01-053-7/+11 * - Update to 1.1.1miwi2010-01-054-16/+62 * Update to 1.10.0.novel2010-01-053-5/+5 * Update to 0.90.85ehaupt2010-01-044-9/+52 * - Update to 1.42.04nivit2010-01-033-6/+32 * - Set USE_GCC to 4.4+ as suggested by gerald@nivit2010-01-031-1/+1 * Update to 20091213ehaupt2010-01-032-4/+4 * Reset cjh due to inactivity. We hope to see him back again soon.linimon2010-01-032-3/+2 * Remove pkg-plist since the port uses PLIST_FILES. This was forgotten in theehaupt2010-01-021-182/+0 * - Restore maintainershippav2009-12-311-1/+1 * Update to 1.12.novel2009-12-312-4/+4 * Update to 0.95ehaupt2009-12-312-19/+12 * Update to 1.3.1ahze2009-12-302-4/+4 * This port now works under amd64ehaupt2009-12-301-1/+1 * The Analysis & Resynthesis Sound Spectrograph (formerly known as the Analysis &miwi2009-12-294-0/+47 * - Update to 1.4.2wen2009-12-294-45/+56 * A stable, documented, asynchronous API library for interfacing MPD inwen2009-12-295-0/+70 * Update to 1.13.6lme2009-12-293-5/+5 * Mark BROKEN on 9.x: does not build.erwin2009-12-271-0/+2 * Update to 0.1.18, this version comes with optional sdl audio supportehaupt2009-12-273-7/+20 * - Update to 1.10.622mva2009-12-253-5/+5 * - Update to 1.1.2miwi2009-12-254-80/+39 * MusicBrainz::DiscID is a class to calculate a MusicBrainz DiscIDwen2009-12-235-0/+42 * Update version to 1.52sanpei2009-12-232-4/+4 * - Chase libtre shlib bumpmiwi2009-12-221-1/+2 * - Update to 0.8.2amdmi32009-12-222-4/+8 * Update to 3.0.1ehaupt2009-12-222-4/+4 * - Update to 0.56wen2009-12-222-4/+4 * - Update to 1.1.6pav2009-12-223-22/+27 * - Install the shared library in an usable mannerpav2009-12-223-13/+6 * - Update to 3.5.3jadawin2009-12-212-4/+4 * - Update to 0.8.1amdmi32009-12-212-4/+4 * For ports maintained by ports@FreeBSD.org, remove names and/ordougb2009-12-2160-147/+3 * Changes to editors/emacs and Mk/bsd.emacs.mk were taken frombsam2009-12-211-8/+8 * - Add dependency on librsvg2 to prevent crashes on runtimepav2009-12-191-1/+2 * - Chase liboggz updatepav2009-12-191-2/+2 * - Update to 1.1.0pav2009-12-193-5/+28 * - Portlintpav2009-12-191-1/+1 * - Portlint, tweak plistfluffy2009-12-182-12/+13 * - Portlint, tweak plistfluffy2009-12-182-12/+13 * - Portlint, tweak plistfluffy2009-12-182-13/+13 * - Portlint, tweak plistfluffy2009-12-182-13/+13 * - Portlint, tweak plistfluffy2009-12-182-13/+13 * . update to the new version 1.0.21-2.fc10;bsam2009-12-182-7/+8 * - Add more configuration optionswen2009-12-173-18/+51 * Reset maintainer at his request.linimon2009-12-162-3/+2 * - Update to 1.093170pgollucci2009-12-153-12/+11 * - Update to 0.8pav2009-12-155-97/+23 * - Update to 11.1dhn2009-12-153-5/+8 * - Get rip python 2.3+miwi2009-12-143-3/+3 * An audio player inspired by Sonata.miwi2009-12-134-0/+43 * - Fix rc-scriptamdmi32009-12-12