aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_conversation_service.h
blob: 6b01119d8b447ed6632aa12a4d5e4643032298e5 (plain) (blame)
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
  This file is part of GNUnet
  (C) 2013 Christian Grothoff (and other contributing authors)
  
  GNUnet is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 3, or (at your
  option) any later version.
  
  GNUnet 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
  General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with GNUnet; see the file COPYING.  If not, write to the
  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  Boston, MA 02111-1307, USA.
 */

/**
 * @file include/gnunet_conversation_service.h
 * @brief API to the conversation service
 * @author Simon Dieterle
 * @author Andreas Fuchs
 */
#ifndef GNUNET_CONVERSATION_SERVICE_H
#define GNUNET_CONVERSATION_SERVICE_H

#ifdef __cplusplus
extern "C"
{
#if 0				/* keep Emacsens' auto-indent happy */
}
#endif
#endif

/**
 * Version of the conversation API.
 */
#define GNUNET_CONVERSATION_VERSION 0x00000001


enum GNUNET_CONVERSATION_RejectReason
{
  GNUNET_CONVERSATION_REJECT_REASON_GENERIC = 0,
  GNUNET_CONVERSATION_REJECT_REASON_NOT_AVAILABLE,
  GNUNET_CONVERSATION_REJECT_REASON_NO_CLIENT,
  GNUNET_CONVERSATION_REJECT_REASON_ACTIVE_CALL,
  GNUNET_CONVERSATION_REJECT_REASON_NOT_WANTED,
  GNUNET_CONVERSATION_REJECT_REASON_NO_ANSWER

};


enum GNUNET_CONVERSATION_NotificationType
{
  GNUNET_CONVERSATION_NT_SERVICE_BLOCKED = 0,
  GNUNET_CONVERSATION_NT_NO_PEER,
  GNUNET_CONVERSATION_NT_NO_ANSWER,
  GNUNET_CONVERSATION_NT_AVAILABLE_AGAIN,
  GNUNET_CONVERSATION_NT_CALL_ACCEPTED,
  GNUNET_CONVERSATION_NT_CALL_TERMINATED
};


/**
 *
 */
struct GNUNET_CONVERSATION_MissedCall
{
  struct GNUNET_PeerIdentity peer;
  struct GNUNET_TIME_Absolute time; 
};


struct GNUNET_CONVERSATION_MissedCallNotification
{
  int number;
  struct GNUNET_CONVERSATION_MissedCall *calls;
};

struct GNUNET_CONVERSATION_CallInformation;

struct GNUNET_CONVERSATION_Handle;


/**
 * Method called whenever a call is incoming
 *
 * @param cls closure
 * @param handle to the conversation session
 * @param caller peer that calls you
 */
typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls,
						struct GNUNET_CONVERSATION_Handle *handle,
						const struct GNUNET_PeerIdentity *caller);


/**
 * Method called whenever a call is rejected
 *
 * @param cls closure
 * @param handle to the conversation session
 * @param reason reason given for rejecting the call
 * @param peer peer that rejected your call
 */
typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls,
						  struct GNUNET_CONVERSATION_Handle *handle,
						  enum GNUNET_CONVERSATION_RejectReason reason,
						  const struct GNUNET_PeerIdentity *peer);


/**
 * Method called whenever a notification is there
 *
 * @param cls closure
 * @param handle to the conversation session
 * @param type the type of the notification
 * @param peer peer that the notification is about
 */
typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls,
							struct GNUNET_CONVERSATION_Handle *handle,
							enum GNUNET_CONVERSATION_NotificationType type,
							const struct GNUNET_PeerIdentity *peer);


/**
 * Method called whenever a notification for missed calls is there
 *
 * @param cls closure
 * @param handle to the conversation session
 * @param missed_calls a list of missed calls
 */
typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls,
						      struct GNUNET_CONVERSATION_Handle *handle,
						      struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls);


/**
 * Connect to the VoIP service
 *
 * @param cfg configuration
 * @param cls NULL
 * @param call_handler the callback which is called when a call is incoming
 * @param reject_handler the callback which is called when a call is rejected
 * @param notification_handler the callback which is called when there is a notification
 * @param missed_call_handler the callback which is called when the service notifies the client about missed clients
 * @return handle to the connection to the conversation service
 */
struct GNUNET_CONVERSATION_Handle *
GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 
			     void *cls,
			     GNUNET_CONVERSATION_CallHandler call_handler,
			     GNUNET_CONVERSATION_RejectHandler reject_handler,
			     GNUNET_CONVERSATION_NotificationHandler notification_handler,
			     GNUNET_CONVERSATION_MissedCallHandler missed_call_handler);


/**
 * Disconnect from the VoIP service
 *
 * @param handle handle to the VoIP connection
 */
void
GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle);


/**
 * Establish a call
 *
 * @param handle handle to the VoIP connection
 * @param callee the peer (PeerIdentity or GNS name) to call
 * @param doGnsLookup 0 = no GNS lookup or 1  = GNS lookup
 */
void
GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, 
			  const char *callee,
			  int doGnsLookup);


/**
 * Terminate the active call
 *
 * @param handle handle to the VoIP connection
 */
void 
GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle);


/**
 * Accept an incoming call
 *
 * @param handle handle to the VoIP connection
 */
void
GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle);


/**
 * Reject an incoming call
 *
 * @param handle handle to the VoIP connection
 */
void
GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);


#if 0				/* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
}
#endif

#endif