summaryrefslogtreecommitdiff
path: root/ytstenut/yts-client.h
blob: 32bcfe23773213e5c848c57dd9cc553c4ac9cac5 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 * Copyright © 2011 Intel Corp.
 *
 * This  library is free  software; you can  redistribute it and/or
 * modify it  under  the terms  of the  GNU Lesser  General  Public
 * License  as published  by the Free  Software  Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * 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 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Authored by: Tomas Frydrych <tf@linux.intel.com>
 *              Rob Staudinger <robsta@linux.intel.com>
 */

#ifndef YTS_CLIENT_H
#define YTS_CLIENT_H

#include <stdint.h>
#include <glib-object.h>
#include <ytstenut/yts-capability.h>
#include <ytstenut/yts-roster.h>

G_BEGIN_DECLS

#define YTS_TYPE_CLIENT (yts_client_get_type())

#define YTS_CLIENT(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), YTS_TYPE_CLIENT, YtsClient))

#define YTS_CLIENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), YTS_TYPE_CLIENT, YtsClientClass))

#define YTS_IS_CLIENT(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YTS_TYPE_CLIENT))

#define YTS_IS_CLIENT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), YTS_TYPE_CLIENT))

#define YTS_CLIENT_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), YTS_TYPE_CLIENT, YtsClientClass))

typedef struct {

  /*< private >*/
  GObject parent;

} YtsClient;

/**
 * YtsClientClass:
 * @authenticated: virtual function for the #YtsClient::authenticated signal.
 * @disconnected: virtual function for the #YtsClient::disconnected signal.
 * @incoming_file: virtual function for the #YtsClient::incoming-file signal.
 * @raw_message: virtual function for the #YtsClient::raw-message signal.
 * @ready: virtual function for the #YtsClient::ready signal.
 *
 * Deprecated: the class handlers for signals are deprecated and will be
 *             removed in 0.4.
 * Since: 0.1
 */
typedef struct {

  /*< private >*/
  GObjectClass parent;

  /*< public >*/

  void
  (*authenticated) (YtsClient *self);

  void
  (*disconnected) (YtsClient *self);

  void
  (*raw_message) (YtsClient   *self,
                  char const  *xml_payload);

  void
  (*ready) (YtsClient *self);

} YtsClientClass;

GType
yts_client_get_type (void) G_GNUC_CONST;

/**
 * YtsProtocol:
 * @YTS_PROTOCOL_XMPP: Jabber
 * @YTS_PROTOCOL_LOCAL_XMPP: XEP-0174 serverless messaging.
 *
 * YtsProtocol represents the XMPP variant to use.
 */
typedef enum { /*< prefix=YTS_PROTOCOL >*/
  YTS_PROTOCOL_XMPP = 0,
  YTS_PROTOCOL_LOCAL_XMPP
} YtsProtocol;

YtsClient *
yts_client_new_c2s (char const *account_id,
                    char const *service_id);

YtsClient *
yts_client_new_p2p (char const *service_id);

void
yts_client_disconnect (YtsClient *self);

void
yts_client_connect (YtsClient *self);

/**
 * YtsCapabilityMode:
 * @YTS_CAPABILITY_MODE_PROVIDED: @capability is provided by this client.
 * @YTS_CAPABILITY_MODE_CONSUMED: @capability is going to be consumed by this
 *                                client so track other services providing it.
 *
 * YtsCapabilityMode is used to determine whether a capability is provided or
 * sought after.
 */
typedef enum { /*< prefix=YTS_CAPABILITY_MODE >*/
  YTS_CAPABILITY_MODE_PROVIDED = 0,
  YTS_CAPABILITY_MODE_CONSUMED
} YtsCapabilityMode;  /* FIXME better naming? */

void
yts_client_add_capability (YtsClient          *self,
                           char const         *capability,
                           YtsCapabilityMode   mode);

YtsRoster *const
yts_client_get_roster (YtsClient const *self);

void
yts_client_set_incoming_file_directory (YtsClient   *self,
                                        char const  *directory);

char const *
yts_client_get_incoming_file_directory (YtsClient const *self);

char const *
yts_client_get_contact_id (YtsClient const *self);

char const *
yts_client_get_service_id (YtsClient const *self);

void
yts_client_set_status_by_capability (YtsClient    *self,
                                      char const  *capability,
                                      char const  *activity,
                                      char const  *status_xml);

bool
yts_client_publish_service (YtsClient     *self,
                            YtsCapability *service);

/**
 * YtsClientServiceIterator:
 * @self: object owning @service.
 * @fqc_id: capability ID.
 * @service: service implementation.
 * @user_data: data passed to yts_client_foreach_service().
 *
 * Callback signature for iterating a an #YtsClient's published services.
 *
 * Returns: %false to abort the iteration.
 *
 * Since: 0.3
 */
typedef bool
(*YtsClientServiceIterator) (YtsClient      *self,
                             char const     *fqc_id,
                             YtsCapability  *service,
                             void           *user_data);

bool
yts_client_foreach_service (YtsClient                 *self,
                            YtsClientServiceIterator   iterator,
                            void                      *user_data);

G_END_DECLS

#endif /* YTS_CLIENT_H */