/*********************************************************************** * * imap_perform() * * This is the actual DO function for IMAP. Get a file/directory according to * the options previously setup. */ static CURLcode imap_perform(struct connectdata *conn, bool *connected, bool *dophase_done) { /* This is IMAP and no proxy */ CURLcode result = CURLE_OK; DEBUGF(infof(conn->data, "DO phase starts\n")); if(conn->data->set.opt_no_body) { /* Requested no body means no transfer */ struct FTP *imap = conn->data->state.proto.imap; imap->transfer = FTPTRANSFER_INFO; } *dophase_done = FALSE; /* not done yet */ /* Start the first command in the DO phase */ result = imap_select(conn); if(result) return result; /* Run the state-machine */ if(conn->data->state.used_interface == Curl_if_multi) result = imap_multi_statemach(conn, dophase_done); else { result = imap_easy_statemach(conn); *dophase_done = TRUE; /* with the easy interface we are done here */ } *connected = conn->bits.tcpconnect[FIRSTSOCKET]; if(*dophase_done) DEBUGF(infof(conn->data, "DO phase is complete\n")); return result; }
/*********************************************************************** * * imap_connect() should do everything that is to be considered a part of * the connection phase. * * The variable 'done' points to will be TRUE if the protocol-layer connect * phase is done when this function returns, or FALSE is not. When called as * a part of the easy interface, it will always be TRUE. */ static CURLcode imap_connect(struct connectdata *conn, bool *done) /* see description above */ { CURLcode result; struct imap_conn *imapc = &conn->proto.imapc; struct SessionHandle *data=conn->data; struct pingpong *pp = &imapc->pp; *done = FALSE; /* default to not done yet */ /* If there already is a protocol-specific struct allocated for this sessionhandle, deal with it */ Curl_reset_reqproto(conn); result = imap_init(conn); if(CURLE_OK != result) return result; /* We always support persistent connections on imap */ conn->bits.close = FALSE; pp->response_time = RESP_TIMEOUT; /* set default response time-out */ pp->statemach_act = imap_statemach_act; pp->endofresp = imap_endofresp; pp->conn = conn; if((conn->handler->flags & PROTOPT_SSL) && data->state.used_interface != Curl_if_multi) { /* IMAPS is simply imap with SSL for the control channel */ /* so perform the SSL initialization for this socket */ result = Curl_ssl_connect(conn, FIRSTSOCKET); if(result) return result; } /* Initialise the response reader stuff */ Curl_pp_init(pp); /* Start off waiting for the server greeting response */ state(conn, IMAP_SERVERGREET); /* Start off with an id of '*' */ imapc->idstr = "*"; if(data->state.used_interface == Curl_if_multi) result = imap_multi_statemach(conn, done); else { result = imap_easy_statemach(conn); if(!result) *done = TRUE; } return result; }
/* called from multi.c while DOing */ static CURLcode imap_doing(struct connectdata *conn, bool *dophase_done) { CURLcode result; result = imap_multi_statemach(conn, dophase_done); if(*dophase_done) { result = imap_dophase_done(conn, FALSE /* not connected */); DEBUGF(infof(conn->data, "DO phase is complete\n")); } return result; }
/* * imap_connect() should do everything that is to be considered a part of * the connection phase. * * The variable 'done' points to will be TRUE if the protocol-layer connect * phase is done when this function returns, or FALSE is not. When called as * a part of the easy interface, it will always be TRUE. */ static CURLcode imap_connect(struct connectdata *conn, bool *done) /* see description above */ { CURLcode result; struct imap_conn *imapc = &conn->proto.imapc; struct SessionHandle *data=conn->data; struct pingpong *pp = &imapc->pp; *done = FALSE; /* default to not done yet */ /* If there already is a protocol-specific struct allocated for this sessionhandle, deal with it */ Curl_reset_reqproto(conn); result = imap_init(conn); if(CURLE_OK != result) return result; /* We always support persistant connections on imap */ conn->bits.close = FALSE; pp->response_time = RESP_TIMEOUT; /* set default response time-out */ pp->statemach_act = imap_statemach_act; pp->endofresp = imap_endofresp; pp->conn = conn; #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_PROXY) if(conn->bits.tunnel_proxy && conn->bits.httpproxy) { /* for IMAP over HTTP proxy */ struct HTTP http_proxy; struct FTP *imap_save; /* BLOCKING */ /* We want "seamless" IMAP operations through HTTP proxy tunnel */ /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the member * conn->proto.http; we want IMAP through HTTP and we have to change the * member temporarily for connecting to the HTTP proxy. After * Curl_proxyCONNECT we have to set back the member to the original struct * IMAP pointer */ imap_save = data->state.proto.imap; memset(&http_proxy, 0, sizeof(http_proxy)); data->state.proto.http = &http_proxy; result = Curl_proxyCONNECT(conn, FIRSTSOCKET, conn->host.name, conn->remote_port); data->state.proto.imap = imap_save; if(CURLE_OK != result) return result; } #endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_PROXY */ if(conn->protocol & PROT_IMAPS) { /* BLOCKING */ /* IMAPS is simply imap with SSL for the control channel */ /* now, perform the SSL initialization for this socket */ result = Curl_ssl_connect(conn, FIRSTSOCKET); if(result) return result; } Curl_pp_init(pp); /* init generic pingpong data */ /* When we connect, we start in the state where we await the server greeting response */ state(conn, IMAP_SERVERGREET); imapc->idstr = "*"; /* we start off waiting for a '*' response */ if(data->state.used_interface == Curl_if_multi) result = imap_multi_statemach(conn, done); else { result = imap_easy_statemach(conn); if(!result) *done = TRUE; } return result; }