/* * Send a dpi cmd. * (For instance: add_bookmark, open_url, send_preferences, ...) */ int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server, int flags) { capi_conn_t *conn; DataBuf *dbuf; if (flags & 1) { /* open a new connection to server */ /* Create a new connection data struct and add it to the list */ conn = Capi_conn_new(url, bw, server, cmd); /* start the CCC operations */ a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, server); a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, server); } else { /* Re-use an open connection */ conn = Capi_conn_find(server); if (conn) { /* found */ dbuf = a_Chain_dbuf_new(cmd, (int)strlen(cmd), 0); a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL); dFree(dbuf); } else { MSG(" ERROR: [a_Capi_dpi_send_cmd] No open connection found\n"); } } return 0; }
/* * Resume connections that were waiting for dpid to start. */ static void Capi_conn_resume(void) { int i; DataBuf *dbuf; capi_conn_t *conn; for (i = 0; i < dList_length(CapiConns); ++i) { conn = dList_nth_data (CapiConns, i); if (conn->Flags & PENDING) { dbuf = a_Chain_dbuf_new(conn->datastr,(int)strlen(conn->datastr), 0); if (conn->InfoSend) { a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL); } dFree(dbuf); conn->Flags &= ~PENDING; } } }
/* * Create and submit the HTTP query to the IO engine */ static void Http_send_query(ChainLink *Info, SocketData_t *S) { Dstr *query; DataBuf *dbuf; /* Create the query */ query = a_Http_make_query_str(S->web->url, S->web->requester, S->flags & HTTP_SOCKET_USE_PROXY); dbuf = a_Chain_dbuf_new(query->str, query->len, 0); /* actually this message is sent too early. * It should go when the socket is ready for writing (i.e. connected) */ _MSG_BW(S->web, 1, "Sending query to %s...", URL_HOST_(S->web->url)); /* send query */ a_Chain_bcb(OpSend, Info, dbuf, NULL); dFree(dbuf); dStr_free(query, 1); }