aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-store.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-08-01 04:00:20 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-08-01 04:00:20 +0800
commit3ef60c2537f654d15bed4347dbc12076be3064fc (patch)
treea9fca24bffe91e1e1f4b576e616876b54256c6ec /camel/providers/imap/camel-imap-store.c
parentf67eb8f79172e77dadb0c02636409e087856baeb (diff)
downloadgsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar.gz
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar.bz2
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar.lz
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar.xz
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.tar.zst
gsoc2013-evolution-3ef60c2537f654d15bed4347dbc12076be3064fc.zip
New convenience function to translate a Camel sexp into the equivalent
2000-07-31 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-utils.c (imap_translate_sexp): New convenience function to translate a Camel sexp into the equivalent IMAP sexp. * providers/imap/camel-imap-store.c: More places now use imap_next_word * providers/imap/camel-imap-folder.c (imap_search_by_expression): Implemented initial version (this may or may not work quite right) svn path=/trunk/; revision=4428
Diffstat (limited to 'camel/providers/imap/camel-imap-store.c')
-rw-r--r--camel/providers/imap/camel-imap-store.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index a46903d975..d3ba8f14f9 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -140,7 +140,7 @@ static void
finalize (GtkObject *object)
{
CamelException ex;
-
+
camel_exception_init (&ex);
imap_disconnect (CAMEL_SERVICE (object), &ex);
camel_exception_clear (&ex);
@@ -148,10 +148,10 @@ finalize (GtkObject *object)
static CamelServiceAuthType password_authtype = {
"Password",
-
+
"This option will connect to the IMAP server using a "
"plaintext password.",
-
+
"",
TRUE
};
@@ -162,26 +162,25 @@ try_connect (CamelService *service, CamelException *ex)
struct hostent *h;
struct sockaddr_in sin;
gint fd;
-
+
h = camel_service_gethost (service, ex);
if (!h)
return FALSE;
-
+
sin.sin_family = h->h_addrtype;
sin.sin_port = htons (service->url->port ? service->url->port : IMAP_PORT);
memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
-
+
fd = socket (h->h_addrtype, SOCK_STREAM, 0);
- if (fd == -1 || connect (fd, (struct sockaddr *)&sin, sizeof (sin)) == -1) {
-
+ if (fd == -1 || connect (fd, (struct sockaddr *)&sin, sizeof (sin)) == -1) {
/* We don't want to set a CamelException here */
-
+
if (fd > -1)
close (fd);
-
+
return FALSE;
}
-
+
close (fd);
return TRUE;
}
@@ -191,24 +190,23 @@ query_auth_types (CamelService *service, CamelException *ex)
{
GList *ret = NULL;
gboolean passwd = TRUE;
-
-
+
if (service->url) {
passwd = try_connect (service, ex);
if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE)
return NULL;
}
-
+
if (passwd)
ret = g_list_append (ret, &password_authtype);
-
+
if (!ret) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not connect to IMAP server on "
- "%s.", service->url->host ? service->url->host :
+ "Could not connect to IMAP server on %s.",
+ service->url->host ? service->url->host :
"(unknown host)");
}
-
+
return ret;
}
@@ -750,15 +748,19 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, char **ret, char
status = camel_imap_status (cmdid, respbuf);
g_free (cmdid);
-
+
if (ret) {
- if (status != CAMEL_IMAP_FAIL) {
- *ret = strchr (respbuf, ' ');
- if (*ret)
- *ret = g_strdup (*ret + 1);
- } else
+ if (status != CAMEL_IMAP_FAIL && respbuf) {
+ char *word;
+
+ word = imap_next_word (respbuf); /* word should now point to NO or BAD */
+
+ *ret = g_strdup (imap_next_word (word));
+ } else {
*ret = NULL;
+ }
}
+
g_free (respbuf);
return status;
@@ -802,8 +804,8 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
GPtrArray *data;
va_list app;
int i;
-
-#if 0
+
+#if 0
/* First make sure we're connected... */
if (!service->connected || !stream_is_alive (store->istream)) {
CamelException *ex;
@@ -821,7 +823,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
camel_exception_free (ex);
}
-#endif
+#endif
if (folder && store->current_folder != folder && strncmp (fmt, "CREATE", 6)) {
/* We need to select the correct mailbox first */
@@ -886,7 +888,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
imap_disconnect (service, ex);
camel_exception_free (ex);
}
-#endif
+#endif
break;
}
@@ -938,10 +940,15 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
}
*p = '\0';
} else {
- if (status != CAMEL_IMAP_FAIL && respbuf)
- *ret = g_strdup (imap_next_word (respbuf));
- else
+ if (status != CAMEL_IMAP_FAIL && respbuf) {
+ char *word;
+
+ word = imap_next_word (respbuf); /* word should now point to NO or BAD */
+
+ *ret = g_strdup (imap_next_word (word));
+ } else {
*ret = NULL;
+ }
}
for (i = 0; i < data->len; i++)