// ============================================================
// vqt6/_bridge_network.h — QtNetwork C 桥接函数声明
// ============================================================

#ifndef VQT6_BRIDGE_NETWORK_H
#define VQT6_BRIDGE_NETWORK_H

#include "_bridge.h"

#ifdef __cplusplus
extern "C" {
#endif

// ============================================================
// QHostAddress
// ============================================================
VQT6_API void* vqt6_qhostaddress_create(void);
VQT6_API void* vqt6_qhostaddress_create_with_ipv4(uint32_t ipv4);
VQT6_API void* vqt6_qhostaddress_create_with_string(void* address);
VQT6_API void* vqt6_qhostaddress_create_with_local_host(void);
VQT6_API void* vqt6_qhostaddress_create_with_local_ipv4(void);
VQT6_API void* vqt6_qhostaddress_create_with_broadcast(void);
VQT6_API void* vqt6_qhostaddress_create_with_any_ipv4(void);
VQT6_API void* vqt6_qhostaddress_to_string(void* addr);
VQT6_API uint32_t vqt6_qhostaddress_to_ipv4(void* addr);
VQT6_API int   vqt6_qhostaddress_is_null(void* addr);
VQT6_API int   vqt6_qhostaddress_is_loopback(void* addr);
VQT6_API int   vqt6_qhostaddress_is_broadcast(void* addr);
VQT6_API int   vqt6_qhostaddress_protocol(void* addr);
VQT6_API void  vqt6_qhostaddress_free(void* addr);

// ============================================================
// QAbstractSocket
// ============================================================
VQT6_API int   vqt6_qabstractsocket_state(void* socket);
VQT6_API int   vqt6_qabstractsocket_error(void* socket);
VQT6_API void* vqt6_qabstractsocket_error_string(void* socket);
VQT6_API void  vqt6_qabstractsocket_connect_to_host(void* socket, void* host_name, uint16_t port);
VQT6_API void  vqt6_qabstractsocket_connect_to_host_with_addr(void* socket, void* address, uint16_t port);
VQT6_API void  vqt6_qabstractsocket_disconnect_from_host(void* socket);
VQT6_API int   vqt6_qabstractsocket_wait_for_connected(void* socket, int timeout_ms);
VQT6_API int   vqt6_qabstractsocket_wait_for_ready_read(void* socket, int timeout_ms);
VQT6_API int   vqt6_qabstractsocket_wait_for_bytes_written(void* socket, int timeout_ms);
VQT6_API int   vqt6_qabstractsocket_wait_for_disconnected(void* socket, int timeout_ms);
VQT6_API int   vqt6_qabstractsocket_is_valid(void* socket);
VQT6_API int   vqt6_qabstractsocket_is_open(void* socket);
VQT6_API int   vqt6_qabstractsocket_flush(void* socket);
VQT6_API void  vqt6_qabstractsocket_close(void* socket);
VQT6_API void  vqt6_qabstractsocket_abort(void* socket);
VQT6_API size_t vqt6_qabstractsocket_read(void* socket, void* buf, size_t max_size);
VQT6_API void* vqt6_qabstractsocket_read_all(void* socket, size_t* out_size);
VQT6_API size_t vqt6_qabstractsocket_write(void* socket, const void* data, size_t size);
VQT6_API size_t vqt6_qabstractsocket_bytes_available(void* socket);
VQT6_API size_t vqt6_qabstractsocket_bytes_to_write(void* socket);
VQT6_API void* vqt6_qabstractsocket_peer_address(void* socket);
VQT6_API uint16_t vqt6_qabstractsocket_peer_port(void* socket);
VQT6_API void* vqt6_qabstractsocket_local_address(void* socket);
VQT6_API uint16_t vqt6_qabstractsocket_local_port(void* socket);

// ============================================================
// QTcpSocket
// ============================================================
VQT6_API void* vqt6_qtcpsocket_create(void);
VQT6_API void* vqt6_qtcpsocket_create_with_parent(void* parent);
VQT6_API void  vqt6_qtcpsocket_connect_to_host(void* socket, void* host_name, uint16_t port, int mode);
VQT6_API void  vqt6_qtcpsocket_connect_to_host_with_addr(void* socket, void* address, uint16_t port, int mode);
VQT6_API int   vqt6_qtcpsocket_set_socket_descriptor(void* socket, intptr_t socket_descriptor);
VQT6_API intptr_t vqt6_qtcpsocket_socket_descriptor(void* socket);
VQT6_API void  vqt6_qtcpsocket_set_proxy(void* socket, int proxy_type);
VQT6_API void  vqt6_qtcpsocket_abort(void* socket);

// ============================================================
// QUdpSocket
// ============================================================
VQT6_API void* vqt6_qudpsocket_create(void);
VQT6_API void* vqt6_qudpsocket_create_with_parent(void* parent);
VQT6_API int   vqt6_qudpsocket_bind(void* socket, uint16_t port);
VQT6_API int   vqt6_qudpsocket_bind_with_addr(void* socket, void* address, uint16_t port);
VQT6_API void  vqt6_qudpsocket_close(void* socket);
VQT6_API size_t vqt6_qudpsocket_write_datagram(void* socket, const void* data, size_t size, void* host, uint16_t port);
VQT6_API size_t vqt6_qudpsocket_read_datagram(void* socket, void* data, size_t max_size, void* host, uint16_t* port);
VQT6_API int   vqt6_qudpsocket_has_pending_datagrams(void* socket);
VQT6_API size_t vqt6_qudpsocket_pending_datagram_size(void* socket);
VQT6_API int   vqt6_qudpsocket_join_multicast_group(void* socket, void* group_address);
VQT6_API int   vqt6_qudpsocket_leave_multicast_group(void* socket, void* group_address);

// ============================================================
// QNetworkRequest
// ============================================================
VQT6_API void* vqt6_qnetworkrequest_create(void);
VQT6_API void* vqt6_qnetworkrequest_create_with_url(void* url);
VQT6_API void  vqt6_qnetworkrequest_set_url(void* req, void* url);
VQT6_API void* vqt6_qnetworkrequest_url(void* req);
VQT6_API void  vqt6_qnetworkrequest_set_header(void* req, int header_type, void* value);
VQT6_API void* vqt6_qnetworkrequest_header(void* req, int header_type);
VQT6_API void  vqt6_qnetworkrequest_set_raw_header(void* req, const char* header_name, const void* value, size_t value_size);
VQT6_API void* vqt6_qnetworkrequest_raw_header(void* req, const char* header_name, size_t* out_size);
VQT6_API void  vqt6_qnetworkrequest_set_attribute(void* req, int attr_type, void* value);
VQT6_API void* vqt6_qnetworkrequest_attribute(void* req, int attr_type);
VQT6_API void  vqt6_qnetworkrequest_free(void* req);

// ============================================================
// QNetworkAccessManager
// ============================================================
VQT6_API void* vqt6_qnetworkaccessmanager_create(void);
VQT6_API void* vqt6_qnetworkaccessmanager_create_with_parent(void* parent);
VQT6_API void* vqt6_qnetworkaccessmanager_get(void* nam, void* req);
VQT6_API void* vqt6_qnetworkaccessmanager_post(void* nam, void* req, const void* data, size_t size);
VQT6_API void* vqt6_qnetworkaccessmanager_put(void* nam, void* req, const void* data, size_t size);
VQT6_API void* vqt6_qnetworkaccessmanager_delete_resource(void* nam, void* req);
VQT6_API void* vqt6_qnetworkaccessmanager_head(void* nam, void* req);
VQT6_API void  vqt6_qnetworkaccessmanager_set_cookie_store(void* nam, void* store);

// ============================================================
// QNetworkReply
// ============================================================
VQT6_API void* vqt6_qnetworkreply_url(void* reply);
VQT6_API void* vqt6_qnetworkreply_request(void* reply);
VQT6_API int   vqt6_qnetworkreply_error(void* reply);
VQT6_API void* vqt6_qnetworkreply_error_string(void* reply);
VQT6_API int   vqt6_qnetworkreply_is_finished(void* reply);
VQT6_API int   vqt6_qnetworkreply_is_running(void* reply);
VQT6_API void  vqt6_qnetworkreply_abort(void* reply);
VQT6_API size_t vqt6_qnetworkreply_read(void* reply, void* buf, size_t max_size);
VQT6_API void* vqt6_qnetworkreply_read_all(void* reply, size_t* out_size);
VQT6_API size_t vqt6_qnetworkreply_bytes_available(void* reply);
VQT6_API void* vqt6_qnetworkreply_header(void* reply, int header_type);
VQT6_API void* vqt6_qnetworkreply_raw_header(void* reply, const char* header_name, size_t* out_size);
VQT6_API void* vqt6_qnetworkreply_attribute(void* reply, int attribute_code);
VQT6_API int   vqt6_qnetworkreply_attribute_int(void* reply, int attribute_code, int default_value);
VQT6_API void  vqt6_qnetworkreply_set_raw_header(void* reply, const char* header_name, const void* value, size_t value_size);

#ifdef __cplusplus
}
#endif

#endif // VQT6_BRIDGE_NETWORK_H
