imap-urlauth-fetch.c revision b22a040754a7011cfbb4f5cca02fb525a496e73f
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "llist.h"
#include "array.h"
#include "net.h"
#include "istream.h"
#include "mail-user.h"
#include "mail-error.h"
#include "mail-storage.h"
#include "imap-url.h"
#include "imap-msgpart-url.h"
#include "imap-urlauth-private.h"
#include "imap-urlauth-fetch.h"
#include "imap-urlauth-connection.h"
struct imap_urlauth_fetch_url {
char *url;
};
struct imap_urlauth_fetch {
unsigned int refcount;
struct imap_urlauth_context *uctx;
void *context;
/* local urls */
struct imap_msgpart_url *local_url;
unsigned int pending_requests;
struct {
char *url;
char *bodypartstruct;
char *error;
unsigned int succeeded:1;
unsigned int binary_has_nuls:1;
unsigned int failed:1;
unsigned int waiting_local:1;
unsigned int waiting_service:1;
};
{
}
}
}
{
if (ufetch->pending_requests > 0)
}
{
}
struct imap_urlauth_fetch *
{
struct imap_urlauth_fetch *ufetch;
return ufetch;
}
{
}
{
return;
/* dont leave the connection in limbo; make sure continue is called */
if (ufetch->waiting_service)
}
{
}
static void
const char *error)
{
struct imap_urlauth_fetch_reply reply;
int ret;
T_BEGIN {
} T_END;
if (ret == 0) {
} else if (ret < 0) {
}
}
static void
{
struct imap_urlauth_fetch_reply reply;
struct imap_msgpart_open_result mpresult;
enum mail_error error_code;
int ret;
if (debug)
if (url_flags == 0)
/* fetch URL */
} else {
}
if (ret <= 0) {
if (ret == 0) {
if (debug)
}
}
/* fetch metadata */
if (success &&
(url_flags & IMAP_URLAUTH_FETCH_FLAG_BODYPARTSTRUCTURE) != 0) {
if (ret <= 0) {
if (ret == 0) {
if (debug)
}
}
}
/* if requested, read the message part the URL points to */
(url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0)) {
if (ret <= 0) {
if (ret == 0) {
if (debug)
}
}
}
i_debug("Fetched URLAUTH yielded empty result");
else {
}
}
return;
}
if (ret == 0) {
} else {
if (ret < 0)
}
}
static int
void *context)
{
struct imap_urlauth_fetch *ufetch =
(struct imap_urlauth_fetch *)context;
int ret = 1;
}
return 0;
}
}
/* report failure only once */
} else if (ret == 0) {
}
return ret;
}
{
/* parse the url */
if (mail_user->mail_debug)
return 1;
}
}
{
int ret = 0;
/* if access user and target user match, handle fetch request locally */
if (ufetch->waiting_local) {
struct imap_urlauth_fetch_url *url_local;
} else T_BEGIN {
} T_END;
/* don't try to fetch remote URLs that are already known to fail access */
if (mail_user->mail_debug)
}
/* create request for url */
ret = -1;
}
if (ret >= 0)
return ret;
}
{
int ret;
return FALSE;
/* not currently waiting for anything */
return ufetch->pending_requests > 0;
}
/* we finished a request */
if (!ufetch->waiting_local) {
/* not waiting for local request handling */
return ufetch->pending_requests > 0;
}
/* finished local request */
}
/* handle pending remote reply */
struct imap_urlauth_fetch_reply reply;
if (ret < 0) {
return FALSE;
}
if (ret == 0) {
return TRUE;
}
}
/* handle pending local urls */
T_BEGIN {
} T_END;
if (ufetch->waiting_local)
return TRUE;
}
return ufetch->pending_requests > 0;
}
{
bool pending;
return pending;
}
{
return ufetch->pending_requests > 0;
}