Index: camel/camel-store.c
===================================================================
--- camel/camel-store.c	(revision 8287)
+++ camel/camel-store.c	(working copy)
@@ -77,6 +77,8 @@
 
 static void noop (CamelStore *store, CamelException *ex);
 
+static gboolean can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+
 static void construct (CamelService *service, CamelSession *session,
 		       CamelProvider *provider, CamelURL *url,
 		       CamelException *ex);
@@ -109,6 +111,7 @@
 	camel_store_class->subscribe_folder = subscribe_folder;
 	camel_store_class->unsubscribe_folder = unsubscribe_folder;
 	camel_store_class->noop = noop;
+	camel_store_class->can_refresh_folder = can_refresh_folder;
 
 	/* virtual method overload */
 	camel_service_class->construct = construct;
@@ -1258,6 +1261,33 @@
 	return equal;
 }
 
+static gboolean
+can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	return ((info->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX);
+}
+
+/**
+ * camel_store_can_refresh_folder
+ * Returns if this folder (param info) should be checked for new mail or not.
+ * It should not look into sub infos (info->child) or next infos, it should
+ * return value only for the actual folder info.
+ * Default behavior is that all Inbox folders are intended to be refreshed.
+ *
+ * @param store Store, to which belong folder.
+ * @param info Info of folder of our interest.
+ * @param ex [out] Will set this exception in case of any error.
+ * @return Whether folder should be checked for new mails or not.
+ **/
+gboolean
+camel_store_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	g_return_val_if_fail (store != NULL, FALSE);
+	g_return_val_if_fail (info != NULL, FALSE);
+
+	return CS_CLASS (store)->can_refresh_folder (store, info, ex);	
+}
+
 /* subscriptions interface */
 
 static void
Index: camel/camel-store.h
===================================================================
--- camel/camel-store.h	(revision 8287)
+++ camel/camel-store.h	(working copy)
@@ -185,6 +185,11 @@
 						     CamelException *ex);
 	void            (*noop)                     (CamelStore *store,
 						     CamelException *ex);
+
+	gboolean        (*can_refresh_folder)       (CamelStore *store,
+						     CamelFolderInfo *info,
+						     CamelException *ex);
+
 } CamelStoreClass;
 
 /* Standard Camel function */
@@ -254,6 +259,10 @@
 						       const char *uri0,
 						       const char *uri1);
 
+gboolean         camel_store_can_refresh_folder       (CamelStore *store,
+						       CamelFolderInfo *info,
+						       CamelException *ex);
+
 typedef struct _CamelISubscribe CamelISubscribe;
 struct _CamelISubscribe {
 	CamelInterface iface;
Index: camel/providers/nntp/ChangeLog
===================================================================
--- camel/providers/nntp/ChangeLog	(revision 8287)
+++ camel/providers/nntp/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2007-12-10  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #336074
+
+	* camel-nntp-store.c: (nntp_can_refresh_folder),
+	(nntp_store_class_init): Implements its own CamelStore's
+	can_refresh_folder function - any folder can be refreshed here.
+
 2007-12-04 David Turner <cillian64@googlemail.com>
 
 	** Fix for bug #466499
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
--- camel/providers/nntp/camel-nntp-store.c	(revision 8287)
+++ camel/providers/nntp/camel-nntp-store.c	(working copy)
@@ -1004,6 +1004,13 @@
 	g_free(p);
 }
 
+static gboolean 
+nntp_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	/* any nntp folder can be refreshed */
+	return TRUE;
+}
+
 static void
 nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class)
 {
@@ -1041,6 +1048,7 @@
 	camel_store_class->create_folder = nntp_create_folder;
 	camel_store_class->delete_folder = nntp_delete_folder;
 	camel_store_class->rename_folder = nntp_rename_folder;
+	camel_store_class->can_refresh_folder = nntp_can_refresh_folder;
 }
 
 /* construction function in which we set some basic store properties */
Index: camel/providers/pop3/ChangeLog
===================================================================
--- camel/providers/pop3/ChangeLog	(revision 8287)
+++ camel/providers/pop3/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2007-12-10  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #336074
+
+	* camel-pop3-store.c: (pop3_can_refresh_folder),
+	(camel_pop3_store_class_init): Implements its own CamelStore's
+	can_refresh_folder function - any folder can be refreshed here.
+
 2007-12-04 David Turner <cillian64@googlemail.com>
 
 	** Fix for bug #466499
Index: camel/providers/pop3/camel-pop3-store.c
===================================================================
--- camel/providers/pop3/camel-pop3-store.c	(revision 8287)
+++ camel/providers/pop3/camel-pop3-store.c	(working copy)
@@ -74,6 +74,8 @@
 
 static CamelFolder *get_trash  (CamelStore *store, CamelException *ex);
 
+static gboolean pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+
 static void
 camel_pop3_store_class_init (CamelPOP3StoreClass *camel_pop3_store_class)
 {
@@ -91,6 +93,7 @@
 
 	camel_store_class->get_folder = get_folder;
 	camel_store_class->get_trash = get_trash;
+	camel_store_class->can_refresh_folder = pop3_can_refresh_folder;
 }
 
 
@@ -667,3 +670,10 @@
 	/* no-op */
 	return NULL;
 }
+
+static gboolean
+pop3_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	/* any pop3 folder can be refreshed */
+	return TRUE;
+}
Index: camel/providers/imap/camel-imap-store.c
===================================================================
--- camel/providers/imap/camel-imap-store.c	(revision 8287)
+++ camel/providers/imap/camel-imap-store.c	(working copy)
@@ -128,6 +128,8 @@
 static void imap_forget_folder(CamelImapStore *imap_store, const char *folder_name, CamelException *ex);
 static void imap_set_server_level (CamelImapStore *store);
 
+static gboolean imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
+
 static void
 camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
 {
@@ -162,6 +164,7 @@
 	camel_store_class->noop = imap_noop;
 	camel_store_class->get_trash = imap_get_trash;
 	camel_store_class->get_junk = imap_get_junk;
+	camel_store_class->can_refresh_folder = imap_can_refresh_folder;
 
 	camel_disco_store_class->can_work_offline = can_work_offline;
 	camel_disco_store_class->connect_online = imap_connect_online;
@@ -3069,3 +3072,22 @@
 
 	return nread;
 }
+
+static gboolean
+imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	gboolean res;
+
+	res = CAMEL_STORE_CLASS(parent_class)->can_refresh_folder (store, info, ex) ||
+	      (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
+
+	if (!res && !camel_exception_is_set (ex)) {
+		CamelFolder *folder;
+
+		folder = camel_store_get_folder (store, info->full_name, 0, ex);
+		if (folder && CAMEL_IS_IMAP_FOLDER (folder))
+			res = CAMEL_IMAP_FOLDER (folder)->check_folder;
+	}
+
+	return res;
+}
Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog	(revision 8287)
+++ camel/providers/imap/ChangeLog	(working copy)
@@ -1,3 +1,20 @@
+2007-12-10  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #336074
+
+	* camel-imap-folder.h: (struct _CamelImapFolder):
+	* camel-imap-folder.c: (imap_property_list), 
+	(camel_imap_folder_get_type), (camel_imap_folder_class_init),
+	(imap_getv), (imap_setv): New property of IMAP folder, check_folder,
+	to let user setup for each folder to check for new mail here or not,
+	but only if not enabled 'check_all' for the store.
+	* camel-imap-store.c: (imap_can_refresh_folder),
+	(camel_imap_store_class_init): Implements its own CamelStore's
+	can_refresh_folder function - IMAP folder has a property if it
+	should be refreshed always or not, so depends on this property
+	in case parent class doesn't permit refresh of the folder or
+	the store doesn't have enabled 'check_all' property.
+
 2007-11-14  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Merge a bunch of compiler warning fixes and cosmetic
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 8287)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -83,8 +83,13 @@
 #define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(o)))
 static CamelDiscoFolderClass *disco_folder_class = NULL;
 
+static CamelProperty imap_property_list[] = {
+	{ CAMEL_IMAP_FOLDER_CHECK_FOLDER, "check_folder", N_("Always check for new mail in this folder") },
+};
+
 static void imap_finalize (CamelObject *object);
-static int imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static int imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static int imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
 
 static void imap_rescan (CamelFolder *folder, int exists, CamelException *ex);
 static void imap_refresh_info (CamelFolder *folder, CamelException *ex);
@@ -151,6 +156,7 @@
 
 	/* virtual method overload */
 	((CamelObjectClass *)camel_imap_folder_class)->getv = imap_getv;
+	((CamelObjectClass *)camel_imap_folder_class)->setv = imap_setv;
 
 	camel_folder_class->get_message = imap_get_message;
 	camel_folder_class->rename = imap_rename;
@@ -205,6 +211,8 @@
 	static CamelType camel_imap_folder_type = CAMEL_INVALID_TYPE;
 
 	if (camel_imap_folder_type == CAMEL_INVALID_TYPE) {
+		int i;
+
 		parent_class = camel_disco_folder_get_type();
 		camel_imap_folder_type =
 			camel_type_register (parent_class, "CamelImapFolder",
@@ -214,6 +222,10 @@
 					     NULL,
 					     (CamelObjectInitFunc) camel_imap_folder_init,
 					     (CamelObjectFinalizeFunc) imap_finalize);
+
+		/* only localize here, do not create GSList, we do not want to leak */
+		for (i = 0; i < sizeof (imap_property_list)/sizeof (imap_property_list [0]); i++)
+			imap_property_list [i].description = _(imap_property_list [i].description);
 	}
 
 	return camel_imap_folder_type;
@@ -443,6 +455,22 @@
 		tag = arg->tag;
 
 		switch (tag & CAMEL_ARG_TAG) {
+		case CAMEL_OBJECT_ARG_PERSISTENT_PROPERTIES:
+		case CAMEL_FOLDER_ARG_PROPERTIES: {
+			CamelArgGetV props;
+			int i;
+
+			props.argc = 1;
+			props.argv[0] = *arg;
+			((CamelObjectClass *)parent_class)->getv(object, ex, &props);
+
+			for (i = 0; i < sizeof (imap_property_list)/sizeof (imap_property_list [0]); i++)
+				*arg->ca_ptr = g_slist_append (*arg->ca_ptr, &imap_property_list[i]);
+			break; }
+			/* imap args */
+		case CAMEL_IMAP_FOLDER_ARG_CHECK_FOLDER:
+			*arg->ca_int = ((CamelImapFolder *)object)->check_folder;
+			break;
 			/* CamelObject args */
 		case CAMEL_OBJECT_ARG_DESCRIPTION:
 			if (folder->description == NULL) {
@@ -467,6 +495,38 @@
 	return 0;
 }
 
+static int
+imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
+{
+	int save = 0;
+	int i;
+	guint32 tag;
+
+	for (i = 0; i < args->argc; i++) {
+		CamelArg *arg = &args->argv[i];
+
+		tag = arg->tag;
+
+		switch (tag & CAMEL_ARG_TAG) {
+		case CAMEL_IMAP_FOLDER_ARG_CHECK_FOLDER:
+			if (((CamelImapFolder *)object)->check_folder != arg->ca_int) {
+				((CamelImapFolder *)object)->check_folder = arg->ca_int;
+				save = 1;
+			}
+			break;
+		default:
+			continue;
+		}
+
+		arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
+	}
+
+	if (save)
+		camel_object_state_write (object);
+
+	return ((CamelObjectClass *)parent_class)->setv (object, ex, args);
+}
+
 static void
 imap_rename (CamelFolder *folder, const char *new)
 {
Index: camel/providers/imap/camel-imap-folder.h
===================================================================
--- camel/providers/imap/camel-imap-folder.h	(revision 8287)
+++ camel/providers/imap/camel-imap-folder.h	(working copy)
@@ -38,6 +38,15 @@
 
 G_BEGIN_DECLS
 
+enum {
+	CAMEL_IMAP_FOLDER_ARG_CHECK_FOLDER = CAMEL_DISCO_FOLDER_ARG_LAST,
+	CAMEL_IMAP_FOLDER_ARG_LAST = CAMEL_DISCO_FOLDER_ARG_LAST + 0x100
+};
+
+enum {
+	CAMEL_IMAP_FOLDER_CHECK_FOLDER = CAMEL_IMAP_FOLDER_ARG_CHECK_FOLDER | CAMEL_ARG_BOO,
+};
+
 struct _CamelImapFolder {
 	CamelDiscoFolder parent_object;
 
@@ -49,6 +58,7 @@
 	unsigned int need_rescan:1;
 	unsigned int need_refresh:1;
 	unsigned int read_only:1;
+	unsigned int check_folder:1;
 };
 
 typedef struct {
Index: camel/providers/local/camel-local-store.c
===================================================================
--- camel/providers/local/camel-local-store.c	(revision 8287)
+++ camel/providers/local/camel-local-store.c	(working copy)
@@ -61,6 +61,7 @@
 static void delete_folder(CamelStore *store, const char *folder_name, CamelException *ex);
 static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex);
 static CamelFolderInfo *create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
+static gboolean local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex);
 
 static char *local_get_full_path(CamelLocalStore *lf, const char *full_name);
 static char *local_get_meta_path(CamelLocalStore *lf, const char *full_name, const char *ext);
@@ -88,6 +89,7 @@
 	camel_store_class->create_folder = create_folder;
 	camel_store_class->delete_folder = delete_folder;
 	camel_store_class->rename_folder = rename_folder;
+	camel_store_class->can_refresh_folder = local_can_refresh_folder;
 
 	camel_local_store_class->get_full_path = local_get_full_path;
 	camel_local_store_class->get_meta_path = local_get_meta_path;
@@ -523,3 +525,10 @@
 {
 	return g_strdup_printf("%s%s%s", ls->toplevel_dir, full_name, ext);
 }
+
+static gboolean
+local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	/* any local folder can be refreshed */
+	return TRUE;
+}
Index: camel/providers/local/ChangeLog
===================================================================
--- camel/providers/local/ChangeLog	(revision 8287)
+++ camel/providers/local/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2007-12-10  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #336074
+
+	* camel-local-store.c: (local_can_refresh_folder),
+	(camel_local_store_class_init): Implements its own CamelStore's
+	can_refresh_folder function - any folder can be refreshed here.
+
 2007-12-04  David Turner  <cillian64@googlemail.com>
 
 	** Fix for bug #466499
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 8287)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,14 @@
+2007-12-10  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #336074
+
+	* camel-store.h: (struct CamelStoreClass::can_refresh_folder),
+	(camel_store_can_refresh_folder):
+	* camel-store.c: (can_refresh_folder), (camel_store_class_init),
+	(camel_store_can_refresh_folder):
+	New virtual function to check if folder can be refreshed or not.
+	Default behavior of this function is that the Inbox will be refreshed.
+
 2007-12-05  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes bug #501622
