summaryrefslogtreecommitdiff
path: root/libsoup/xmlrpc/soup-xmlrpc.h
blob: 2a32e466ef797bbe839080d767285cf0d2eaed57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright 2015 - Collabora Ltd.
 */

#pragma once

#include "soup-types.h"

G_BEGIN_DECLS

/* XML-RPC client */
SOUP_AVAILABLE_IN_2_52
char       *soup_xmlrpc_build_request   (const char *method_name,
					 GVariant   *params,
					 GError    **error);
SOUP_AVAILABLE_IN_2_52
SoupMessage *soup_xmlrpc_message_new    (const char *uri,
					 const char *method_name,
					 GVariant   *params,
					 GError    **error);
SOUP_AVAILABLE_IN_2_52
GVariant    *soup_xmlrpc_parse_response (const char *method_response,
					 int         length,
					 const char *signature,
					 GError    **error);

/* XML-RPC server */
typedef struct _SoupXMLRPCParams SoupXMLRPCParams;
SOUP_AVAILABLE_IN_2_52
void         soup_xmlrpc_params_free          (SoupXMLRPCParams  *self);
SOUP_AVAILABLE_IN_2_52
GVariant    *soup_xmlrpc_params_parse         (SoupXMLRPCParams  *self,
					       const char        *signature,
					       GError           **error);
SOUP_AVAILABLE_IN_2_52
char       *soup_xmlrpc_parse_request         (const char        *method_call,
					       int                length,
					       SoupXMLRPCParams **params,
					       GError           **error);
SOUP_AVAILABLE_IN_2_52
char       *soup_xmlrpc_build_response        (GVariant          *value,
					       GError           **error);
SOUP_AVAILABLE_IN_2_4
char       *soup_xmlrpc_build_fault           (int                fault_code,
					       const char        *fault_format,
					       ...) G_GNUC_PRINTF (2, 3);
SOUP_AVAILABLE_IN_2_52
gboolean     soup_xmlrpc_message_set_response (SoupMessage       *msg,
					       GVariant          *value,
					       GError           **error);
SOUP_AVAILABLE_IN_2_52
void         soup_xmlrpc_message_set_fault    (SoupMessage       *msg,
					       int                fault_code,
					       const char        *fault_format,
					       ...) G_GNUC_PRINTF (3, 4);

/* Utils */
SOUP_AVAILABLE_IN_2_52
GVariant *soup_xmlrpc_variant_new_datetime (SoupDate *date);

SOUP_AVAILABLE_IN_2_52
SoupDate *soup_xmlrpc_variant_get_datetime (GVariant *variant,
					    GError  **error);

/* Errors */
#define SOUP_XMLRPC_ERROR soup_xmlrpc_error_quark()
SOUP_AVAILABLE_IN_2_4
GQuark soup_xmlrpc_error_quark (void);

typedef enum {
	SOUP_XMLRPC_ERROR_ARGUMENTS,
	SOUP_XMLRPC_ERROR_RETVAL
} SoupXMLRPCError;

#define SOUP_XMLRPC_FAULT soup_xmlrpc_fault_quark()
SOUP_AVAILABLE_IN_2_4
GQuark soup_xmlrpc_fault_quark (void);

typedef enum {
	SOUP_XMLRPC_FAULT_PARSE_ERROR_NOT_WELL_FORMED = -32700,
	SOUP_XMLRPC_FAULT_PARSE_ERROR_UNSUPPORTED_ENCODING = -32701,
	SOUP_XMLRPC_FAULT_PARSE_ERROR_INVALID_CHARACTER_FOR_ENCODING = -32702,
	SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_XML_RPC = -32600,
	SOUP_XMLRPC_FAULT_SERVER_ERROR_REQUESTED_METHOD_NOT_FOUND = -32601,
	SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_METHOD_PARAMETERS = -32602,
	SOUP_XMLRPC_FAULT_SERVER_ERROR_INTERNAL_XML_RPC_ERROR = -32603,
	SOUP_XMLRPC_FAULT_APPLICATION_ERROR = -32500,
	SOUP_XMLRPC_FAULT_SYSTEM_ERROR = -32400,
	SOUP_XMLRPC_FAULT_TRANSPORT_ERROR = -32300
} SoupXMLRPCFault;

G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupXMLRPCParams, soup_xmlrpc_params_free)

G_END_DECLS