Revision e43fd4ef
Von martin vor mehr als 15 Jahren hinzugefügt
src/libs/aqbanking/httpsession.c | ||
---|---|---|
|
||
GWEN_HTTP_SESSION *AB_HttpSession_new(AB_PROVIDER *pro,
|
||
AB_USER *u,
|
||
const char *url) {
|
||
const char *url,
|
||
const char *defaultProto,
|
||
int defaultPort) {
|
||
GWEN_HTTP_SESSION *sess;
|
||
AB_HTTP_SESSION *xsess;
|
||
|
||
assert(pro);
|
||
assert(u);
|
||
|
||
sess=GWEN_HttpSession_new(url, "https", 443);
|
||
sess=GWEN_HttpSession_new(url, defaultProto, defaultPort);
|
||
assert(sess);
|
||
GWEN_NEW_OBJECT(AB_HTTP_SESSION, xsess);
|
||
GWEN_INHERIT_SETDATA(GWEN_HTTP_SESSION, AB_HTTP_SESSION, sess, xsess,
|
src/libs/aqbanking/httpsession.h | ||
---|---|---|
*/
|
||
/*@{*/
|
||
AQBANKING_API
|
||
GWEN_HTTP_SESSION *AB_HttpSession_new(AB_PROVIDER *pro, AB_USER *u, const char *url);
|
||
GWEN_HTTP_SESSION *AB_HttpSession_new(AB_PROVIDER *pro, AB_USER *u,
|
||
const char *url,
|
||
const char *defaultProto,
|
||
int defaultPort);
|
||
|
||
/*@}*/
|
||
|
src/plugins/backends/aqhbci/plugin/msglayer/dialog_https.c | ||
---|---|---|
|
||
sess=AB_HttpSession_new(AB_User_GetProvider(dlg->dialogOwner),
|
||
dlg->dialogOwner,
|
||
GWEN_Buffer_GetStart(tbuf));
|
||
GWEN_Buffer_GetStart(tbuf),
|
||
"https",
|
||
443);
|
||
GWEN_Buffer_free(tbuf);
|
||
|
||
/* setup session */
|
src/plugins/backends/aqofxconnect/plugin/network.c | ||
---|---|---|
/***************************************************************************
|
||
$RCSfile$
|
||
-------------------
|
||
begin : Mon Mar 01 2004
|
||
copyright : (C) 2004 by Martin Preuss
|
||
copyright : (C) 2004-2010 by Martin Preuss
|
||
email : martin@libchipcard.de
|
||
|
||
***************************************************************************
|
||
... | ... | |
***************************************************************************/
|
||
|
||
|
||
#include <gwenhywfar/url.h>
|
||
#include <gwenhywfar/io_socket.h>
|
||
#include <gwenhywfar/io_tls.h>
|
||
#include <gwenhywfar/io_http.h>
|
||
#include <gwenhywfar/io_buffered.h>
|
||
#include <gwenhywfar/iomanager.h>
|
||
|
||
|
||
#define AO_PROVIDER_TIMEOUT_SEND 60000
|
||
#define AO_PROVIDER_TIMEOUT_RECV 60000
|
||
#define AO_PROVIDER_TIMEOUT_CONNECT 60000
|
||
|
||
|
||
|
||
int AO_Provider__SetAddress(GWEN_INETADDRESS *addr,
|
||
const char *bankAddr) {
|
||
int err;
|
||
|
||
err=GWEN_InetAddr_SetAddress(addr, bankAddr);
|
||
if (err) {
|
||
char dbgbuf[256];
|
||
|
||
snprintf(dbgbuf, sizeof(dbgbuf)-1,
|
||
I18N("Resolving hostname \"%s\" ..."),
|
||
bankAddr);
|
||
dbgbuf[sizeof(dbgbuf)-1]=0;
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Notice,
|
||
dbgbuf);
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Resolving hostname \"%s\"",
|
||
bankAddr);
|
||
err=GWEN_InetAddr_SetName(addr, bankAddr);
|
||
if (err) {
|
||
snprintf(dbgbuf, sizeof(dbgbuf)-1,
|
||
I18N("Unknown hostname \"%s\""),
|
||
bankAddr);
|
||
dbgbuf[sizeof(dbgbuf)-1]=0;
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Error,
|
||
dbgbuf);
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN,
|
||
"Error resolving hostname \"%s\":",
|
||
bankAddr);
|
||
DBG_ERROR_ERR(AQOFXCONNECT_LOGDOMAIN, err);
|
||
return err;
|
||
}
|
||
else {
|
||
char addrBuf[256];
|
||
int err;
|
||
#include <aqbanking/httpsession.h>
|
||
|
||
err=GWEN_InetAddr_GetAddress(addr, addrBuf, sizeof(addrBuf)-1);
|
||
addrBuf[sizeof(addrBuf)-1]=0;
|
||
if (err) {
|
||
DBG_ERROR_ERR(AQOFXCONNECT_LOGDOMAIN, err);
|
||
}
|
||
else {
|
||
snprintf(dbgbuf, sizeof(dbgbuf)-1,
|
||
I18N("IP address is %s"),
|
||
addrBuf);
|
||
dbgbuf[sizeof(dbgbuf)-1]=0;
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Notice,
|
||
dbgbuf);
|
||
}
|
||
}
|
||
}
|
||
#include <gwenhywfar/url.h>
|
||
|
||
return 0;
|
||
}
|
||
|
||
|
||
|
||
int AO_Provider_CreateConnection(AB_PROVIDER *pro,
|
||
AB_USER *u,
|
||
GWEN_IO_LAYER **pIo) {
|
||
int port;
|
||
GWEN_SOCKET *sk;
|
||
GWEN_INETADDRESS *addr;
|
||
GWEN_URL *url;
|
||
GWEN_IO_LAYER *io;
|
||
GWEN_IO_LAYER *ioBase;
|
||
GWEN_HTTP_SESSION **pSess) {
|
||
int rv;
|
||
GWEN_DB_NODE *db;
|
||
AO_USER_SERVERTYPE addrType;
|
||
const char *s;
|
||
GWEN_HTTP_SESSION *sess;
|
||
uint32_t flags;
|
||
const char *addr;
|
||
const char *addrType;
|
||
|
||
/* take bank addr from user */
|
||
s=AO_User_GetServerAddr(u);
|
||
if (s==NULL) {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN,
|
||
"Missing server address");
|
||
GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error,
|
||
I18N("Missing server address"));
|
||
return GWEN_ERROR_INVALID;
|
||
}
|
||
url=GWEN_Url_fromString(s);
|
||
if (!url) {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN,
|
||
"Bad server address [%s]", s);
|
||
GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error,
|
||
I18N("Bad server address"));
|
||
addr=AO_User_GetServerAddr(u);
|
||
if (!(addr && *addr)) {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN, "User has no valid address settings");
|
||
return GWEN_ERROR_INVALID;
|
||
}
|
||
|
||
/* prepare socket layer */
|
||
sk=GWEN_Socket_new(GWEN_SocketTypeTCP);
|
||
io=GWEN_Io_LayerSocket_new(sk);
|
||
|
||
addrType=AO_User_GetServerType(u);
|
||
|
||
addr=GWEN_InetAddr_new(GWEN_AddressFamilyIP);
|
||
rv=AO_Provider__SetAddress(addr, GWEN_Url_GetServer(url));
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Url_free(url);
|
||
return rv;
|
||
}
|
||
port=AO_User_GetServerPort(u);
|
||
if (port<1) {
|
||
/* set default port if none given */
|
||
switch(addrType) {
|
||
case AO_User_ServerTypeHTTP: port=80; break;
|
||
case AO_User_ServerTypeHTTPS: port=443; break;
|
||
default:
|
||
DBG_WARN(AQOFXCONNECT_LOGDOMAIN,
|
||
"Unknown address type (%d), assuming HTTPS",
|
||
addrType);
|
||
port=443;
|
||
break;
|
||
} /* switch */
|
||
}
|
||
|
||
GWEN_InetAddr_SetPort(addr, port);
|
||
GWEN_Io_LayerSocket_SetPeerAddr(io, addr);
|
||
|
||
if (addrType==AO_User_ServerTypeHTTPS) {
|
||
/* possibly prepare TLS layer */
|
||
ioBase=io;
|
||
io=GWEN_Io_LayerTls_new(ioBase);
|
||
if (io==NULL) {
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Io_Layer_free(ioBase);
|
||
GWEN_Url_free(url);
|
||
return GWEN_ERROR_GENERIC;
|
||
}
|
||
GWEN_Io_Layer_AddFlags(io,
|
||
GWEN_IO_LAYER_TLS_FLAGS_ALLOW_V1_CA_CRT|
|
||
GWEN_IO_LAYER_TLS_FLAGS_ADD_TRUSTED_CAS);
|
||
|
||
if (AO_User_GetFlags(u) & AO_USER_FLAGS_FORCE_SSL3)
|
||
GWEN_Io_Layer_AddFlags(io, GWEN_IO_LAYER_TLS_FLAGS_FORCE_SSL_V3);
|
||
|
||
GWEN_Io_LayerTls_SetRemoteHostName(io, GWEN_Url_GetServer(url));
|
||
}
|
||
|
||
/* prepare buffered layer */
|
||
ioBase=io;
|
||
io=GWEN_Io_LayerBuffered_new(ioBase);
|
||
if (io==NULL) {
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Io_Layer_free(ioBase);
|
||
GWEN_Url_free(url);
|
||
return GWEN_ERROR_GENERIC;
|
||
}
|
||
|
||
/* prepare HTTP layer */
|
||
ioBase=io;
|
||
io=GWEN_Io_LayerHttp_new(ioBase);
|
||
if (io==NULL) {
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Io_Layer_free(ioBase);
|
||
GWEN_Url_free(url);
|
||
return GWEN_ERROR_GENERIC;
|
||
}
|
||
|
||
/* prepare HTTP command line */
|
||
db=GWEN_Io_LayerHttp_GetDbCommandOut(io);
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "command", "POST");
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "protocol", "HTTP/1.0");
|
||
|
||
if (1) {
|
||
GWEN_BUFFER *pbuf;
|
||
|
||
pbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||
rv=GWEN_Url_toCommandString(url, pbuf);
|
||
if (rv) {
|
||
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_Buffer_free(pbuf);
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Io_Layer_free(ioBase);
|
||
GWEN_Url_free(url);
|
||
return rv;
|
||
}
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "url",
|
||
GWEN_Buffer_GetStart(pbuf));
|
||
GWEN_Buffer_free(pbuf);
|
||
}
|
||
|
||
/* prepare HTTP out header */
|
||
db=GWEN_Io_LayerHttp_GetDbHeaderOut(io);
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Host", GWEN_Url_GetServer(url));
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Pragma", "no-cache");
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Cache-control", "no cache");
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Content-type",
|
||
"application/x-ofx");
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Accept",
|
||
"*/*, application/x-ofx");
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "Connection", "close");
|
||
GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "Content-length", 0);
|
||
|
||
/* now register the layer */
|
||
rv=GWEN_Io_Manager_RegisterLayer(io);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Could not register io layer (%d)", rv);
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Io_Layer_free(io);
|
||
GWEN_Url_free(url);
|
||
return 0;
|
||
}
|
||
|
||
*pIo=io;
|
||
GWEN_InetAddr_free(addr);
|
||
GWEN_Url_free(url);
|
||
return 0;
|
||
}
|
||
|
||
|
||
|
||
int AO_Provider_SendPacket(AB_PROVIDER *pro,
|
||
GWEN_IO_LAYER *io,
|
||
const uint8_t *buf, int blen) {
|
||
int rv;
|
||
|
||
/* first connect to server */
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Notice,
|
||
I18N("Connecting to bank..."));
|
||
rv=GWEN_Io_Layer_ConnectRecursively(io, NULL, 0, 0,
|
||
AO_PROVIDER_TIMEOUT_CONNECT);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Could not connect to server (%d)", rv);
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
GWEN_IO_REQUEST_FLAGS_FORCE,
|
||
0, 2000);
|
||
return rv;
|
||
switch(AO_User_GetServerType(u)) {
|
||
case AO_User_ServerTypeHTTP:
|
||
addrType="http";
|
||
break;
|
||
case AO_User_ServerTypeHTTPS:
|
||
default:
|
||
addrType="https";
|
||
break;
|
||
}
|
||
else {
|
||
GWEN_DB_NODE *db;
|
||
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Notice,
|
||
I18N("Connected."));
|
||
|
||
db=GWEN_Io_LayerHttp_GetDbHeaderOut(io);
|
||
GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"Content-length", blen);
|
||
|
||
/* send message */
|
||
rv=GWEN_Io_Layer_WriteBytes(io,
|
||
buf, blen,
|
||
GWEN_IO_REQUEST_FLAGS_PACKETBEGIN |
|
||
GWEN_IO_REQUEST_FLAGS_PACKETEND |
|
||
GWEN_IO_REQUEST_FLAGS_FLUSH,
|
||
0, AO_PROVIDER_TIMEOUT_SEND);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Could not send message (%d)", rv);
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
GWEN_IO_REQUEST_FLAGS_FORCE,
|
||
0, 2000);
|
||
return rv;
|
||
}
|
||
sess=AB_HttpSession_new(pro, u, addr, addrType, AO_User_GetServerPort(u));
|
||
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Message sent.");
|
||
return 0;
|
||
}
|
||
}
|
||
/* setup session */
|
||
flags=AO_User_GetFlags(u);
|
||
if (flags & AO_USER_FLAGS_FORCE_SSL3)
|
||
GWEN_HttpSession_AddFlags(sess, GWEN_HTTP_SESSION_FLAGS_FORCE_SSL3);
|
||
GWEN_HttpSession_AddFlags(sess, GWEN_HTTP_SESSION_FLAGS_NO_CACHE);
|
||
|
||
GWEN_HttpSession_SetHttpContentType(sess, "application/x-ofx");
|
||
|
||
GWEN_HttpSession_SetHttpVMajor(sess, AO_User_GetHttpVMajor(u));
|
||
GWEN_HttpSession_SetHttpVMinor(sess, AO_User_GetHttpVMinor(u));
|
||
|
||
int AO_Provider_RecvPacket(AB_PROVIDER *pro,
|
||
GWEN_IO_LAYER *io,
|
||
GWEN_BUFFER *buf) {
|
||
int rv;
|
||
GWEN_DB_NODE *db;
|
||
int code;
|
||
|
||
/* recv packet (this reads the HTTP body) */
|
||
rv=GWEN_Io_Layer_ReadPacketToBuffer(io, buf, 0, 0,
|
||
AO_PROVIDER_TIMEOUT_RECV);
|
||
/* init session */
|
||
rv=GWEN_HttpSession_Init(sess);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "No message received (%d)", rv);
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_HttpSession_free(sess);
|
||
return rv;
|
||
}
|
||
|
||
/* check for status and log it */
|
||
db=GWEN_Io_LayerHttp_GetDbStatusIn(io);
|
||
code=GWEN_DB_GetIntValue(db, "code", 0, 0);
|
||
if (code) {
|
||
GWEN_BUFFER *lbuf;
|
||
char sbuf[32];
|
||
const char *text;
|
||
|
||
lbuf=GWEN_Buffer_new(0, 64, 0, 1);
|
||
GWEN_Buffer_AppendString(lbuf, "HTTP-Status: ");
|
||
snprintf(sbuf, sizeof(sbuf)-1, "%d", code);
|
||
sbuf[sizeof(sbuf)-1]=0;
|
||
GWEN_Buffer_AppendString(lbuf, sbuf);
|
||
text=GWEN_DB_GetCharValue(db, "text", 0, NULL);
|
||
if (text) {
|
||
GWEN_Buffer_AppendString(lbuf, " (");
|
||
GWEN_Buffer_AppendString(lbuf, text);
|
||
GWEN_Buffer_AppendString(lbuf, ")");
|
||
}
|
||
DBG_DEBUG(AQOFXCONNECT_LOGDOMAIN, "Status: %d (%s)",
|
||
code, text);
|
||
if (code<200 || code>299) {
|
||
/* response is only ok for continuation (100) code */
|
||
if (code!=100) {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN,
|
||
"Got an error response (%d: %s)",
|
||
code, text);
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Error,
|
||
GWEN_Buffer_GetStart(lbuf));
|
||
/* set error code */
|
||
code=AB_ERROR_NETWORK;
|
||
}
|
||
else {
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Notice,
|
||
GWEN_Buffer_GetStart(lbuf));
|
||
}
|
||
GWEN_Buffer_free(lbuf);
|
||
}
|
||
else {
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Info,
|
||
GWEN_Buffer_GetStart(lbuf));
|
||
GWEN_Buffer_free(lbuf);
|
||
}
|
||
}
|
||
else {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN, "No HTTP status code received");
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Error,
|
||
I18N("No HTTP status code received"));
|
||
code=AB_ERROR_NETWORK;
|
||
}
|
||
|
||
return code;
|
||
*pSess=sess;
|
||
return 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
int AO_Provider_SendAndReceive(AB_PROVIDER *pro,
|
||
AB_USER *u,
|
||
const uint8_t *p,
|
||
unsigned int plen,
|
||
GWEN_BUFFER **pRbuf) {
|
||
AO_PROVIDER *dp;
|
||
GWEN_IO_LAYER *io;
|
||
GWEN_HTTP_SESSION *sess=NULL;
|
||
GWEN_BUFFER *rbuf;
|
||
int rv;
|
||
|
||
... | ... | |
}
|
||
|
||
/* setup connection */
|
||
rv=AO_Provider_CreateConnection(pro, u, &io);
|
||
rv=AO_Provider_CreateConnection(pro, u, &sess);
|
||
if (rv) {
|
||
DBG_ERROR(AQOFXCONNECT_LOGDOMAIN,
|
||
"Could not create connection");
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Error,
|
||
I18N("Could not connect to bank server"));
|
||
GWEN_Gui_ProgressLog2(0,
|
||
GWEN_LoggerLevel_Error,
|
||
I18N("Could not create connection (%d)"),
|
||
rv);
|
||
return rv;
|
||
}
|
||
|
||
/* send message */
|
||
/* send request */
|
||
GWEN_Gui_ProgressLog(0,
|
||
GWEN_LoggerLevel_Info,
|
||
I18N("Sending request..."));
|
||
rv=AO_Provider_SendPacket(pro, io, p, plen);
|
||
if (rv) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Error %d", rv);
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
GWEN_IO_REQUEST_FLAGS_FORCE,
|
||
0, 2000);
|
||
GWEN_Io_Layer_free(io);
|
||
rv=GWEN_HttpSession_SendPacket(sess, "POST", p, plen);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_HttpSession_Fini(sess);
|
||
GWEN_HttpSession_free(sess);
|
||
return rv;
|
||
}
|
||
|
||
... | ... | |
GWEN_LoggerLevel_Info,
|
||
I18N("Waiting for response..."));
|
||
rbuf=GWEN_Buffer_new(0, 1024, 0, 1);
|
||
rv=AO_Provider_RecvPacket(pro, io, rbuf);
|
||
rv=GWEN_HttpSession_RecvPacket(sess, rbuf);
|
||
if (rv<0) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN,
|
||
"Error receiving packet (%d)", rv);
|
||
... | ... | |
GWEN_LoggerLevel_Error,
|
||
I18N("Network error while waiting for response"));
|
||
GWEN_Buffer_free(rbuf);
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
GWEN_IO_REQUEST_FLAGS_FORCE,
|
||
0, 2000);
|
||
GWEN_Io_Layer_free(io);
|
||
GWEN_HttpSession_Fini(sess);
|
||
GWEN_HttpSession_free(sess);
|
||
return rv;
|
||
}
|
||
else if (!(rv>=200 && rv<=299)) {
|
||
/* not a HTTP: ok code */
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_Buffer_free(rbuf);
|
||
GWEN_HttpSession_Fini(sess);
|
||
GWEN_HttpSession_free(sess);
|
||
return rv;
|
||
}
|
||
|
||
/* disconnect (ignore result) */
|
||
rv=GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
0,
|
||
0, 2000);
|
||
if (rv) {
|
||
DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Could not disconnect (%d)", rv);
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL,
|
||
GWEN_IO_REQUEST_FLAGS_FORCE,
|
||
0, 2000);
|
||
}
|
||
GWEN_HttpSession_Fini(sess);
|
||
GWEN_HttpSession_free(sess);
|
||
|
||
/* found a response, transform it */
|
||
GWEN_Gui_ProgressLog(0,
|
||
... | ... | |
|
||
*pRbuf=rbuf;
|
||
|
||
/* release connection ressources */
|
||
GWEN_Io_Layer_free(io);
|
||
|
||
if (getenv("AQOFX_LOG_COMM")) {
|
||
FILE *f;
|
||
|
src/plugins/backends/aqofxconnect/plugin/user.c | ||
---|---|---|
GWEN_INHERIT_SETDATA(AB_USER, AO_USER, u, ue, AO_User_FreeData);
|
||
|
||
if (em==AB_ProviderExtendMode_Create) {
|
||
ue->httpVMajor=1;
|
||
ue->httpVMinor=0;
|
||
}
|
||
else {
|
||
const char *s;
|
||
... | ... | |
ue->clientUid=strdup(s);
|
||
else
|
||
ue->clientUid=NULL;
|
||
}
|
||
|
||
ue->httpVMajor=GWEN_DB_GetIntValue(db, "httpVMajor", 0, -1);
|
||
ue->httpVMinor=GWEN_DB_GetIntValue(db, "httpVMinor", 0, -1);
|
||
if (ue->httpVMajor==-1 || ue->httpVMinor==-1) {
|
||
ue->httpVMajor=1;
|
||
ue->httpVMinor=0;
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
AO_USER *ue;
|
||
... | ... | |
if (ue->clientUid)
|
||
GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"clientUid", ue->clientUid);
|
||
|
||
GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"httpVMajor", ue->httpVMajor);
|
||
GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS,
|
||
"httpVMinor", ue->httpVMinor);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
|
||
|
||
|
||
int AO_User_GetHttpVMajor(const AB_USER *u) {
|
||
AO_USER *ue;
|
||
|
||
assert(u);
|
||
ue=GWEN_INHERIT_GETDATA(AB_USER, AO_USER, u);
|
||
assert(ue);
|
||
|
||
return ue->httpVMajor;
|
||
}
|
||
|
||
|
||
|
||
void AO_User_SetHttpVMajor(AB_USER *u, int i) {
|
||
AO_USER *ue;
|
||
|
||
assert(u);
|
||
ue=GWEN_INHERIT_GETDATA(AB_USER, AO_USER, u);
|
||
assert(ue);
|
||
|
||
ue->httpVMajor=i;
|
||
}
|
||
|
||
|
||
|
||
int AO_User_GetHttpVMinor(const AB_USER *u) {
|
||
AO_USER *ue;
|
||
|
||
assert(u);
|
||
ue=GWEN_INHERIT_GETDATA(AB_USER, AO_USER, u);
|
||
assert(ue);
|
||
|
||
return ue->httpVMinor;
|
||
}
|
||
|
||
|
||
|
||
void AO_User_SetHttpVMinor(AB_USER *u, int i) {
|
||
AO_USER *ue;
|
||
|
||
assert(u);
|
||
ue=GWEN_INHERIT_GETDATA(AB_USER, AO_USER, u);
|
||
assert(ue);
|
||
|
||
ue->httpVMinor=i;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
src/plugins/backends/aqofxconnect/plugin/user.h | ||
---|---|---|
void AO_User_SetClientUid(AB_USER *u, const char *s);
|
||
|
||
|
||
|
||
AQOFXCONNECT_API
|
||
int AO_User_GetHttpVMajor(const AB_USER *u);
|
||
|
||
AQOFXCONNECT_API
|
||
void AO_User_SetHttpVMajor(AB_USER *u, int i);
|
||
|
||
AQOFXCONNECT_API
|
||
int AO_User_GetHttpVMinor(const AB_USER *u);
|
||
|
||
AQOFXCONNECT_API
|
||
void AO_User_SetHttpVMinor(AB_USER *u, int i);
|
||
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
src/plugins/backends/aqofxconnect/plugin/user_p.h | ||
---|---|---|
/***************************************************************************
|
||
$RCSfile$
|
||
-------------------
|
||
cvs : $Id$
|
||
begin : Mon Mar 01 2004
|
||
copyright : (C) 2004 by Martin Preuss
|
||
copyright : (C) 2004-2010 by Martin Preuss
|
||
email : martin@libchipcard.de
|
||
|
||
***************************************************************************
|
||
... | ... | |
char *appVer;
|
||
char *headerVer;
|
||
char *clientUid;
|
||
|
||
int httpVMajor;
|
||
int httpVMinor;
|
||
};
|
||
|
||
static void GWENHYWFAR_CB AO_User_FreeData(void *bp, void *p);
|
src/plugins/imexporters/csv/csv_editprofile.c | ||
---|---|---|
#include <gwenhywfar/misc.h>
|
||
#include <gwenhywfar/pathmanager.h>
|
||
#include <gwenhywfar/debug.h>
|
||
#include <gwenhywfar/io_file.h>
|
||
#include <gwenhywfar/io_buffered.h>
|
||
#include <gwenhywfar/iomanager.h>
|
||
#include <gwenhywfar/syncio_file.h>
|
||
#include <gwenhywfar/syncio_buffered.h>
|
||
#include <gwenhywfar/stringlist.h>
|
||
#include <gwenhywfar/text.h>
|
||
|
||
... | ... | |
|
||
static int readTestData(GWEN_DIALOG *dlg) {
|
||
AB_CSV_EDIT_PROFILE_DIALOG *xdlg;
|
||
int fd;
|
||
GWEN_IO_LAYER *io;
|
||
GWEN_IO_LAYER *baseIo;
|
||
GWEN_SYNCIO *sio;
|
||
GWEN_SYNCIO *baseIo;
|
||
GWEN_BUFFER *dbuf;
|
||
int i;
|
||
int ignoreLines=0;
|
||
... | ... | |
|
||
GWEN_StringList_Clear(xdlg->columns);
|
||
|
||
fd=open(xdlg->testFileName, O_RDONLY);
|
||
if (fd==-1) {
|
||
DBG_ERROR(AQBANKING_LOGDOMAIN, "open(%s): %s (%d)",
|
||
xdlg->testFileName, strerror(errno), errno);
|
||
return GWEN_ERROR_IO;
|
||
}
|
||
/* create file IO */
|
||
sio=GWEN_SyncIo_File_new(xdlg->testFileName, GWEN_SyncIo_File_CreationMode_OpenExisting);
|
||
GWEN_SyncIo_AddFlags(sio, GWEN_SYNCIO_FILE_FLAGS_READ);
|
||
baseIo=sio;
|
||
|
||
baseIo=GWEN_Io_LayerFile_new(fd, -1);
|
||
io=GWEN_Io_LayerBuffered_new(baseIo);
|
||
GWEN_Io_Manager_RegisterLayer(io);
|
||
/* create buffered IO on top of file io to allow for reading of lines below */
|
||
sio=GWEN_SyncIo_Buffered_new(baseIo);
|
||
|
||
dbuf=GWEN_Buffer_new(0, 1024, 0, 1);
|
||
|
||
... | ... | |
else if (strcasecmp(delimiter, "SPACE")==0)
|
||
delimiter=" ";
|
||
|
||
/* open file */
|
||
rv=GWEN_SyncIo_Connect(sio);
|
||
if (rv<0) {
|
||
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
|
||
GWEN_Buffer_free(dbuf);
|
||
GWEN_SyncIo_free(sio);
|
||
return rv;
|
||
}
|
||
|
||
for (i=0; i<ignoreLines; i++) {
|
||
rv=GWEN_Io_LayerBuffered_ReadLineToBuffer(io, dbuf, GWEN_Dialog_GetGuiId(dlg), 2000);
|
||
rv=GWEN_SyncIo_Buffered_ReadLineToBuffer(sio, dbuf);
|
||
if (rv<0) {
|
||
DBG_ERROR(AQBANKING_LOGDOMAIN, "Error reading: %d", rv);
|
||
GWEN_Buffer_free(dbuf);
|
||
GWEN_SyncIo_Disconnect(sio);
|
||
GWEN_SyncIo_free(sio);
|
||
return rv;
|
||
}
|
||
GWEN_Buffer_Reset(dbuf);
|
||
}
|
||
|
||
/* read single data line */
|
||
rv=GWEN_Io_LayerBuffered_ReadLineToBuffer(io, dbuf, GWEN_Dialog_GetGuiId(dlg), 2000);
|
||
rv=GWEN_SyncIo_Buffered_ReadLineToBuffer(sio, dbuf);
|
||
if (rv<0) {
|
||
DBG_ERROR(AQBANKING_LOGDOMAIN, "Error reading: %d", rv);
|
||
GWEN_Buffer_free(dbuf);
|
||
GWEN_SyncIo_Disconnect(sio);
|
||
GWEN_SyncIo_free(sio);
|
||
return rv;
|
||
}
|
||
|
||
... | ... | |
GWEN_Buffer_GetStart(dbuf), 0);
|
||
|
||
/* we don't need the io layer any longer */
|
||
GWEN_Io_Layer_DisconnectRecursively(io, NULL, 0, GWEN_Dialog_GetGuiId(dlg), 2000);
|
||
GWEN_Io_Layer_free(io);
|
||
GWEN_SyncIo_Disconnect(sio);
|
||
GWEN_SyncIo_free(sio);
|
||
|
||
wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
|
||
s=GWEN_Buffer_GetStart(dbuf);
|
Auch abrufbar als: Unified diff
Use AB_HttpSession for OFX DirectConnect in addition to HBCI/PINTAN.
Now no AqBanking code uses Gwen's deprecated async IO layer.
Also, the HBCI and OFX DirectConnect backends share the same network base
code.
git-svn-id: https://devel.aqbanking.de/svn/aqbanking/trunk@1906 5c42a225-8b10-0410-9873-89b7810ad06e