1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright 2015 - Collabora Ltd.
4 */
5
6#ifndef __SOUP_XMLRPC_H__
7#define __SOUP_XMLRPC_H__ 1
8
9#include <libsoup/soup-types.h>
10#include <libsoup/soup-xmlrpc-old.h>
11
12G_BEGIN_DECLS
13
14/* XML-RPC client */
15SOUP_AVAILABLE_IN_2_52
16char *soup_xmlrpc_build_request (const char *method_name,
17 GVariant *params,
18 GError **error);
19SOUP_AVAILABLE_IN_2_52
20SoupMessage *soup_xmlrpc_message_new (const char *uri,
21 const char *method_name,
22 GVariant *params,
23 GError **error);
24SOUP_AVAILABLE_IN_2_52
25GVariant *soup_xmlrpc_parse_response (const char *method_response,
26 int length,
27 const char *signature,
28 GError **error);
29
30/* XML-RPC server */
31typedef struct _SoupXMLRPCParams SoupXMLRPCParams;
32SOUP_AVAILABLE_IN_2_52
33void soup_xmlrpc_params_free (SoupXMLRPCParams *self);
34SOUP_AVAILABLE_IN_2_52
35GVariant *soup_xmlrpc_params_parse (SoupXMLRPCParams *self,
36 const char *signature,
37 GError **error);
38SOUP_AVAILABLE_IN_2_52
39char *soup_xmlrpc_parse_request (const char *method_call,
40 int length,
41 SoupXMLRPCParams **params,
42 GError **error);
43SOUP_AVAILABLE_IN_2_52
44char *soup_xmlrpc_build_response (GVariant *value,
45 GError **error);
46SOUP_AVAILABLE_IN_2_4
47char *soup_xmlrpc_build_fault (int fault_code,
48 const char *fault_format,
49 ...) G_GNUC_PRINTF (2, 3);
50SOUP_AVAILABLE_IN_2_52
51gboolean soup_xmlrpc_message_set_response (SoupMessage *msg,
52 GVariant *value,
53 GError **error);
54SOUP_AVAILABLE_IN_2_52
55void soup_xmlrpc_message_set_fault (SoupMessage *msg,
56 int fault_code,
57 const char *fault_format,
58 ...) G_GNUC_PRINTF (3, 4);
59
60/* Utils */
61SOUP_AVAILABLE_IN_2_52
62GVariant *soup_xmlrpc_variant_new_datetime (SoupDate *date);
63
64SOUP_AVAILABLE_IN_2_52
65SoupDate *soup_xmlrpc_variant_get_datetime (GVariant *variant,
66 GError **error);
67
68/* Errors */
69#define SOUP_XMLRPC_ERROR soup_xmlrpc_error_quark()
70SOUP_AVAILABLE_IN_2_4
71GQuark soup_xmlrpc_error_quark (void);
72
73typedef enum {
74 SOUP_XMLRPC_ERROR_ARGUMENTS,
75 SOUP_XMLRPC_ERROR_RETVAL
76} SoupXMLRPCError;
77
78#define SOUP_XMLRPC_FAULT soup_xmlrpc_fault_quark()
79SOUP_AVAILABLE_IN_2_4
80GQuark soup_xmlrpc_fault_quark (void);
81
82typedef enum {
83 SOUP_XMLRPC_FAULT_PARSE_ERROR_NOT_WELL_FORMED = -32700,
84 SOUP_XMLRPC_FAULT_PARSE_ERROR_UNSUPPORTED_ENCODING = -32701,
85 SOUP_XMLRPC_FAULT_PARSE_ERROR_INVALID_CHARACTER_FOR_ENCODING = -32702,
86 SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_XML_RPC = -32600,
87 SOUP_XMLRPC_FAULT_SERVER_ERROR_REQUESTED_METHOD_NOT_FOUND = -32601,
88 SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_METHOD_PARAMETERS = -32602,
89 SOUP_XMLRPC_FAULT_SERVER_ERROR_INTERNAL_XML_RPC_ERROR = -32603,
90 SOUP_XMLRPC_FAULT_APPLICATION_ERROR = -32500,
91 SOUP_XMLRPC_FAULT_SYSTEM_ERROR = -32400,
92 SOUP_XMLRPC_FAULT_TRANSPORT_ERROR = -32300
93} SoupXMLRPCFault;
94
95G_END_DECLS
96
97#endif /* __SOUP_XMLRPC_H__ */
98