File: evd-jsonrpc.h

package info (click to toggle)
event-dance 0.1.20-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 5,068 kB
  • sloc: ansic: 25,946; sh: 11,340; makefile: 418; xml: 249; python: 27
file content (125 lines) | stat: -rw-r--r-- 6,422 bytes parent folder | download
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * evd-jsonrpc.h
 *
 * EventDance, Peer-to-peer IPC library <http://eventdance.org>
 *
 * Copyright (C) 2009/2010, Igalia S.L.
 *
 * Authors:
 *   Eduardo Lima Mitev <elima@igalia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 3, or (at your option) any later version as published by
 * the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License at http://www.gnu.org/licenses/lgpl-3.0.txt
 * for more details.
 */

#ifndef __EVD_JSONRPC_H__
#define __EVD_JSONRPC_H__

#include <glib-object.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>

#include <evd-transport.h>

G_BEGIN_DECLS

typedef struct _EvdJsonrpc EvdJsonrpc;
typedef struct _EvdJsonrpcClass EvdJsonrpcClass;
typedef struct _EvdJsonrpcPrivate EvdJsonrpcPrivate;

typedef gboolean (* EvdJsonrpcTransportWriteCb) (EvdJsonrpc  *self,
                                                 const gchar *buffer,
                                                 gsize        size,
                                                 gpointer     context,
                                                 gpointer     user_data);

typedef void (* EvdJsonrpcMethodCallCb) (EvdJsonrpc  *self,
                                         const gchar *method_name,
                                         JsonNode    *params,
                                         guint        invocation_id,
                                         gpointer     context,
                                         gpointer     user_data);

struct _EvdJsonrpc
{
  GObject parent;

  EvdJsonrpcPrivate *priv;
};

struct _EvdJsonrpcClass
{
  GObjectClass parent_class;
};

#define EVD_TYPE_JSONRPC           (evd_jsonrpc_get_type ())
#define EVD_JSONRPC(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVD_TYPE_JSONRPC, EvdJsonrpc))
#define EVD_JSONRPC_CLASS(obj)     (G_TYPE_CHECK_CLASS_CAST ((obj), EVD_TYPE_JSONRPC, EvdJsonrpcClass))
#define EVD_IS_JSONRPC(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVD_TYPE_JSONRPC))
#define EVD_IS_JSONRPC_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE ((obj), EVD_TYPE_JSONRPC))
#define EVD_JSONRPC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EVD_TYPE_JSONRPC, EvdJsonrpcClass))


GType                evd_jsonrpc_get_type                     (void) G_GNUC_CONST;

EvdJsonrpc *         evd_jsonrpc_new                          (void);

void                 evd_jsonrpc_transport_set_write_callback (EvdJsonrpc                 *self,
                                                               EvdJsonrpcTransportWriteCb  callback,
                                                               gpointer                    user_data);
gboolean             evd_jsonrpc_transport_read               (EvdJsonrpc   *self,
                                                               const gchar  *buffer,
                                                               gsize         size,
                                                               gpointer      context,
                                                               GError      **error);

void                 evd_jsonrpc_call_method                  (EvdJsonrpc          *self,
                                                               const gchar         *method_name,
                                                               JsonNode            *params,
                                                               gpointer             context,
                                                               GCancellable        *cancellable,
                                                               GAsyncReadyCallback  callback,
                                                               gpointer             user_data);
gboolean             evd_jsonrpc_call_method_finish           (EvdJsonrpc    *self,
                                                               GAsyncResult  *result,
                                                               JsonNode     **result_json,
                                                               JsonNode     **error_json,
                                                               GError       **error);

void                 evd_jsonrpc_set_method_call_callback     (EvdJsonrpc             *self,
                                                               EvdJsonrpcMethodCallCb  callback,
                                                               gpointer                user_data);

gboolean             evd_jsonrpc_respond                      (EvdJsonrpc  *self,
                                                               guint        invocation_id,
                                                               JsonNode    *result,
                                                               gpointer     context,
                                                               GError     **error);
gboolean             evd_jsonrpc_respond_error                (EvdJsonrpc  *self,
                                                               guint        invocation_id,
                                                               JsonNode    *json_error,
                                                               gpointer     context,
                                                               GError     **error);

void                 evd_jsonrpc_use_transport                (EvdJsonrpc   *self,
                                                               EvdTransport *transport);
void                 evd_jsonrpc_unuse_transport              (EvdJsonrpc   *self,
                                                               EvdTransport *transport);

gboolean             evd_jsonrpc_send_notification            (EvdJsonrpc   *self,
                                                               const gchar  *notification_name,
                                                               JsonNode     *params,
                                                               gpointer      context,
                                                               GError      **error);

G_END_DECLS

#endif /* __EVD_JSONRPC_H__ */