aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-10-21 03:39:44 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-10-21 03:39:44 +0800
commit458b72a844f8c86edf904367307217b231f773fe (patch)
tree1ec79cca9675992f22302d452111edd79c496210
parent435e8893664733275ef5426c166b21f831433614 (diff)
downloadgsoc2013-evolution-458b72a844f8c86edf904367307217b231f773fe.tar.gz
gsoc2013-evolution-458b72a844f8c86edf904367307217b231f773fe.tar.zst
gsoc2013-evolution-458b72a844f8c86edf904367307217b231f773fe.zip
Don't allow users to create folders in offline mode. When in offline mode,
2004-10-20 Jeffrey Stedfast <fejj@ximian.com> * providers/imap4/camel-imap4-store.c (imap4_get_folder): Don't allow users to create folders in offline mode. When in offline mode, use a different codepath to get a folder object. (imap4_noop): Handle offline mode. (imap4_unsubscribe_folder): Throw an exception if we are in offline mode. (imap4_subscribe_folder): Same. (imap4_get_folder_info): Started to implement offline support. Also, even if we are in online mode but the engine has not yet been connected, we should follow the "offline" code path and get the folder info's from the cache. (imap4_rename_folder): Disallow in offline mode. (imap4_delete_folder): Same. (imap4_connect): Handle offline mode. (imap4_disconnect): Handle offline mode and do proper locking. (imap4_query_auth_types): Same. svn path=/trunk/; revision=27660
-rw-r--r--camel/ChangeLog19
-rw-r--r--camel/providers/imap4/camel-imap4-folder.c4
-rw-r--r--camel/providers/imap4/camel-imap4-store.c71
3 files changed, 86 insertions, 8 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 44cdd79de5..e077b4207c 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,22 @@
+2004-10-20 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/imap4/camel-imap4-store.c (imap4_get_folder): Don't
+ allow users to create folders in offline mode. When in offline
+ mode, use a different codepath to get a folder object.
+ (imap4_noop): Handle offline mode.
+ (imap4_unsubscribe_folder): Throw an exception if we are in
+ offline mode.
+ (imap4_subscribe_folder): Same.
+ (imap4_get_folder_info): Started to implement offline
+ support. Also, even if we are in online mode but the engine has
+ not yet been connected, we should follow the "offline" code path
+ and get the folder info's from the cache.
+ (imap4_rename_folder): Disallow in offline mode.
+ (imap4_delete_folder): Same.
+ (imap4_connect): Handle offline mode.
+ (imap4_disconnect): Handle offline mode and do proper locking.
+ (imap4_query_auth_types): Same.
+
2004-10-19 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap4/camel-imap4-summary.c (imap4_summary_fetch_all):
diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c
index f0f8793933..58aebfd092 100644
--- a/camel/providers/imap4/camel-imap4-folder.c
+++ b/camel/providers/imap4/camel-imap4-folder.c
@@ -404,7 +404,7 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
int id, max, i;
int retval;
- if (!camel_session_is_online (!session))
+ if (!camel_session_is_online (session))
return;
CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
@@ -855,7 +855,7 @@ imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest
GPtrArray **transferred_uids, gboolean move, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) src->parent_store)->engine;
- CamelSession *session = ((CamelService *) folder->parent_store)->session;
+ CamelSession *session = ((CamelService *) src->parent_store)->session;
int i, j, n, id, dest_namelen;
CamelMessageInfo *info;
CamelIMAP4Command *ic;
diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c
index c643bbf901..02f38401fa 100644
--- a/camel/providers/imap4/camel-imap4-store.c
+++ b/camel/providers/imap4/camel-imap4-store.c
@@ -296,7 +296,7 @@ connect_to_server_wrapper (CamelIMAP4Engine *engine, CamelException *ex)
int mode, ret, i;
char *serv;
const char *port;
-
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
@@ -489,6 +489,9 @@ imap4_connect (CamelService *service, CamelException *ex)
{
gboolean retval;
+ if (!camel_session_is_online (service->session))
+ return TRUE;
+
CAMEL_SERVICE_LOCK (service, connect_lock);
retval = imap4_reconnect (((CamelIMAP4Store *) service)->engine, ex);
CAMEL_SERVICE_UNLOCK (service, connect_lock);
@@ -503,6 +506,10 @@ imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex)
CamelIMAP4Command *ic;
int id;
+ if (!camel_session_is_online (service->session))
+ return TRUE;
+
+ CAMEL_SERVICE_LOCK (store, connect_lock);
if (clean && !store->engine->istream->disconnected) {
ic = camel_imap4_engine_queue (store->engine, NULL, "LOGOUT\r\n");
while ((id = camel_imap4_engine_iterate (store->engine)) < ic->id && id != -1)
@@ -510,6 +517,7 @@ imap4_disconnect (CamelService *service, gboolean clean, CamelException *ex)
camel_imap4_command_unref (ic);
}
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
return 0;
}
@@ -524,6 +532,9 @@ imap4_query_auth_types (CamelService *service, CamelException *ex)
GList *sasl_types, *t, *next;
gboolean connected;
+ if (!camel_session_is_online (service->session))
+ return NULL;
+
CAMEL_SERVICE_LOCK (store, connect_lock);
connected = connect_to_server_wrapper (store->engine, ex);
CAMEL_SERVICE_UNLOCK (store, connect_lock);
@@ -588,6 +599,7 @@ static CamelFolder *
imap4_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelFolder *folder = NULL;
camel_imap4_list_t *list;
CamelIMAP4Command *ic;
@@ -599,6 +611,19 @@ imap4_get_folder (CamelStore *store, const char *folder_name, guint32 flags, Cam
CAMEL_SERVICE_LOCK (store, connect_lock);
+ if (!camel_session_is_online (session)) {
+ if ((flags & CAMEL_STORE_FOLDER_CREATE) != 0) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create IMAP folders in offline mode."));
+ } else {
+ /* FIXME: implement me */
+ /*folder = camel_imap4_folder_new_offline (store, folder_name, ex);*/
+ }
+
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
+
+ return folder;
+ }
+
/* make sure the folder exists - try LISTing it? */
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "LIST \"\" %S\r\n", utf7_name);
@@ -676,6 +701,7 @@ imap4_create_folder (CamelStore *store, const char *parent_name, const char *fol
* contain subfolders - delete them and re-create with the
* proper hint */
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelFolderInfo *fi = NULL;
CamelIMAP4Command *ic;
char *utf7_name;
@@ -700,6 +726,11 @@ imap4_create_folder (CamelStore *store, const char *parent_name, const char *fol
c++;
}
+ if (!camel_session_is_online (session)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create IMAP folders in offline mode."));
+ return NULL;
+ }
+
if (parent_name != NULL && *parent_name)
name = g_strdup_printf ("%s/%s", parent_name, folder_name);
else
@@ -769,6 +800,7 @@ static void
imap4_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelFolder *selected = (CamelFolder *) engine->folder;
CamelIMAP4Command *ic, *ic0 = NULL;
CamelFolderInfo *fi;
@@ -785,6 +817,11 @@ imap4_delete_folder (CamelStore *store, const char *folder_name, CamelException
return;
}
+ if (!camel_session_is_online (session)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot delete IMAP folders in offline mode."));
+ return;
+ }
+
CAMEL_SERVICE_LOCK (store, connect_lock);
if (selected && !strcmp (folder_name, selected->full_name))
@@ -857,6 +894,7 @@ static void
imap4_rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
char *old_uname, *new_uname;
CamelIMAP4Command *ic;
int id;
@@ -869,6 +907,11 @@ imap4_rename_folder (CamelStore *store, const char *old_name, const char *new_na
return;
}
+ if (!camel_session_is_online (session)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename IMAP folders in offline mode."));
+ return;
+ }
+
CAMEL_SERVICE_LOCK (store, connect_lock);
old_uname = imap4_folder_utf7_name (store, old_name, '\0');
@@ -1067,6 +1110,7 @@ static CamelFolderInfo *
imap4_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelIMAP4Command *ic, *ic0 = NULL;
CamelFolderInfo *fi = NULL;
camel_imap4_list_t *list;
@@ -1078,11 +1122,10 @@ imap4_get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelE
CAMEL_SERVICE_LOCK (store, connect_lock);
- if (engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED) {
- if (!camel_service_connect ((CamelService *) store, ex))
- return NULL;
-
- engine = ((CamelIMAP4Store *) store)->engine;
+ if (!camel_session_is_online (session) /* || engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED */) {
+ /* FIXME: get cached folder-info's */
+ CAMEL_SERVICE_UNLOCK (store, connect_lock);
+ return NULL;
}
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
@@ -1180,6 +1223,7 @@ static void
imap4_subscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelIMAP4Command *ic;
CamelFolderInfo *fi;
char *utf7_name;
@@ -1187,6 +1231,11 @@ imap4_subscribe_folder (CamelStore *store, const char *folder_name, CamelExcepti
const char *p;
int id;
+ if (!camel_session_is_online (session)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot subscribe to IMAP folders in offline mode."));
+ return;
+ }
+
CAMEL_SERVICE_LOCK (store, connect_lock);
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
@@ -1245,6 +1294,7 @@ static void
imap4_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelIMAP4Command *ic;
CamelFolderInfo *fi;
char *utf7_name;
@@ -1252,6 +1302,11 @@ imap4_unsubscribe_folder (CamelStore *store, const char *folder_name, CamelExcep
const char *p;
int id;
+ if (!camel_session_is_online (session)) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot unsubscribe from IMAP folders in offline mode."));
+ return;
+ }
+
CAMEL_SERVICE_LOCK (store, connect_lock);
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
@@ -1310,10 +1365,14 @@ static void
imap4_noop (CamelStore *store, CamelException *ex)
{
CamelIMAP4Engine *engine = ((CamelIMAP4Store *) store)->engine;
+ CamelSession *session = ((CamelService *) store)->session;
CamelFolder *folder = (CamelFolder *) engine->folder;
CamelIMAP4Command *ic;
int id;
+ if (!camel_session_is_online (session))
+ return;
+
CAMEL_SERVICE_LOCK (store, connect_lock);
if (folder) {