summaryrefslogtreecommitdiff
path: root/libsocialweb/sw-service.h
blob: 60fd658264965da88f6c11a28eb6dbcfc15e6289 (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
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
126
127
128
129
130
131
132
133
134
/*
 * libsocialweb - social data store
 * Copyright (C) 2008 - 2009 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope 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 for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 */


#ifndef _SW_SERVICE
#define _SW_SERVICE

#include <glib-object.h>
#include <libsocialweb/sw-types.h>
#include <libsocialweb/sw-item.h>
#include <libsocialweb/sw-set.h>
#include <libsocialweb/sw-enum-types.h>

G_BEGIN_DECLS

#define SW_TYPE_SERVICE sw_service_get_type()

typedef enum {
  SW_SERVICE_ERROR_NO_KEYS, /*< nick=NoKeys >*/
  SW_SERVICE_ERROR_INVALID_QUERY, /*< nick=InvalidQuery >*/
  SW_SERVICE_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/
  SW_SERVICE_ERROR_REMOTE_ERROR /*< nick=RemoteError >*/
} SwServiceError;

#define SW_SERVICE_ERROR sw_service_error_quark ()
GQuark sw_service_error_quark (void);

#define SW_SERVICE(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), SW_TYPE_SERVICE, SwService))

#define SW_SERVICE_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), SW_TYPE_SERVICE, SwServiceClass))

#define SW_IS_SERVICE(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SW_TYPE_SERVICE))

#define SW_IS_SERVICE_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), SW_TYPE_SERVICE))

#define SW_SERVICE_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), SW_TYPE_SERVICE, SwServiceClass))

struct _SwService {
  GObject parent;
};

typedef struct _SwServiceClass SwServiceClass;
struct _SwServiceClass {
  GObjectClass parent_class;
  /* vfuncs */
  const char *(*get_name) (SwService *service);
  const gchar ** (*get_static_caps) (SwService *service);
  const gchar ** (*get_dynamic_caps) (SwService *service);
  void (*credentials_updated) (SwService *service);
};

/* Keep in sync with sw-client-service.h */
#define IS_CONFIGURED "is-configured"
#define CAN_VERIFY_CREDENTIALS "can-verify-credentials"
#define CREDENTIALS_VALID "credentials-valid"
#define CREDENTIALS_INVALID "credentials-invalid"
#define CAN_UPDATE_STATUS "can-update-status"
#define CAN_REQUEST_AVATAR "can-request-avatar"
#define CAN_GEOTAG "can-geotag"

#define HAS_UPDATE_STATUS_IFACE "has-update-status-iface"
#define HAS_AVATAR_IFACE "has-avatar-iface"
#define HAS_PHOTO_UPLOAD_IFACE "has-photo-upload-iface"
#define HAS_VIDEO_UPLOAD_IFACE "has-video-upload-iface"
#define HAS_BANISHABLE_IFACE "has-banishable-iface"
#define HAS_QUERY_IFACE "has-query-iface"
#define HAS_CONTACTS_QUERY_IFACE "has-contacts-query-iface"
#define HAS_COLLECTIONS_IFACE "has-collections-iface"

#define CAN_UPDATE_STATUS_WITH_GEOTAG "can-update-status-with-geotag"

GType sw_service_get_type (void);

const char *sw_service_get_name (SwService *service);

void sw_service_emit_capabilities_changed (SwService   *service,
                                           const char **caps);
void sw_service_emit_user_changed (SwService *service);

gboolean sw_service_is_uid_banned (SwService   *service,
                                   const gchar *uid);

gboolean sw_service_has_cap (const char **caps, const char *cap);

typedef struct {
  char *lsw_param;
  char *service_param;
} ParameterNameMapping;

/**
 * SwServiceSetParamFunc:
 * @object: A remote call or hash object that can store key/value pairs.
 * @param_name: The parameter name.
 * @param_value: The parameter value.
 *
 * This type signature reflects a function that sets a name/value association
 * on a given object. Functions such as g_hash_table_insert and
 * rest_proxy_call_add_param are good examples.
 */


typedef void (*SwServiceSetParamFunc) (gpointer object,
                                       const gchar *param_name,
                                       const gchar *param_value);

void sw_service_map_params (const ParameterNameMapping *mapping,
                            GHashTable                 *parameters,
                            SwServiceSetParamFunc       set_param_func,
                            gpointer                    remote_call_object);

G_END_DECLS

#endif /* _SW_SERVICE */