aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 19:06:07 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 19:06:07 +0000
commitec9740ca2ca84525842e6743b45ceb9cb2a3ea95 (patch)
tree5382b500ec7e5e66197d697c40a69bf4b0cb890f /src/conversation
parent705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99 (diff)
downloadgnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.tar.gz
gnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.zip
-split off microphone/speaker APIs
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/Makefile.am3
-rw-r--r--src/conversation/conversation_api2.c251
2 files changed, 253 insertions, 1 deletions
diff --git a/src/conversation/Makefile.am b/src/conversation/Makefile.am
index b5dc0d49b..895e1136e 100644
--- a/src/conversation/Makefile.am
+++ b/src/conversation/Makefile.am
@@ -21,7 +21,8 @@ pkgcfgdir= $(prefix)/share/gnunet/config.d/
21libexecdir= $(prefix)/lib/gnunet/libexec/ 21libexecdir= $(prefix)/lib/gnunet/libexec/
22 22
23libgnunetconversation_la_SOURCES = \ 23libgnunetconversation_la_SOURCES = \
24 conversation_api.c 24 conversation_api.c \
25 conversation_api2.c
25libgnunetconversation_la_LIBADD = \ 26libgnunetconversation_la_LIBADD = \
26 -lgnunetutil -lgnunetnamestore -lgnunetgns 27 -lgnunetutil -lgnunetnamestore -lgnunetgns
27libgnunetconversation_la_LDFLAGS = \ 28libgnunetconversation_la_LDFLAGS = \
diff --git a/src/conversation/conversation_api2.c b/src/conversation/conversation_api2.c
new file mode 100644
index 000000000..3c19828a4
--- /dev/null
+++ b/src/conversation/conversation_api2.c
@@ -0,0 +1,251 @@
1/*
2 This file is part of GNUnet
3 (C) 2013 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21/**
22 * @file conversation/conversation_api2.c
23 * @brief API to the conversation service
24 * @author Simon Dieterle
25 * @author Andreas Fuchs
26 * @author Christian Grothoff
27 */
28#include "platform.h"
29#include "gnunet_conversation_service.h"
30
31
32/**
33 * A phone record specifies which peer is hosting a given user and
34 * may also specify the phone line that is used (typically zero).
35 * The version is also right now always zero.
36 */
37struct PhoneRecord
38{
39
40 /**
41 * Version of the phone record, for now always zero. We may
42 * use other versions for anonymously hosted phone lines in
43 * the future.
44 */
45 uint32_t version GNUNET_PACKED;
46
47 /**
48 * Phone line to use at the peer.
49 */
50 uint32_t line GNUNET_PACKED;
51
52 /**
53 * Identity of the peer hosting the phone service.
54 */
55 struct GNUNET_PeerIdentity my_peer;
56
57};
58
59
60
61/**
62 * A phone is a device that can ring to signal an incoming call and
63 * that you can pick up to answer the call and hang up to terminate
64 * the call. You can also hang up a ringing phone immediately
65 * (without picking it up) to stop it from ringing. Phones have
66 * caller ID. You can ask the phone for its record and make that
67 * record available (via GNS) to enable others to call you.
68 * Multiple phones maybe connected to the same line (the line is
69 * something rather internal to a phone and not obvious from it).
70 * You can only have one conversation per phone at any time.
71 */
72struct GNUNET_CONVERSATION_Phone
73{
74 /**
75 * Our configuration.
76 */
77 const struct GNUNET_CONFIGURATION_Handle *cfg;
78
79 /**
80 * Function to call for phone events.
81 */
82 GNUNET_CONVERSATION_EventHandler event_handler;
83
84 /**
85 * Closure for @e event_handler
86 */
87 void *event_handler_cls;
88
89 /**
90 * Speaker, or NULL if none is attached.
91 */
92 struct GNUNET_CONVERSATION_Speaker *speaker;
93
94 /**
95 * Microphone, or NULL if none is attached.
96 */
97 struct GNUNET_CONVERSATION_Microphone *mic;
98
99 /**
100 * This phone's record.
101 */
102 struct PhoneRecord my_record;
103
104};
105
106
107/**
108 * Create a new phone.
109 *
110 * @param cfg configuration for the phone; specifies the phone service and
111 * which line the phone is to be connected to
112 * @param event_handler how to notify the owner of the phone about events
113 * @param event_handler_cls closure for @a event_handler
114 */
115struct GNUNET_CONVERSATION_Phone *
116GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
117 GNUNET_CONVERSATION_EventHandler event_handler,
118 void *event_handler_cls)
119{
120 return NULL;
121}
122
123
124/**
125 * Fill in a namestore record with the contact information
126 * for this phone. Note that the filled in "data" value
127 * is only valid until the phone is destroyed.
128 *
129 * @param phone phone to create a record for
130 * @param rd namestore record to fill in
131 */
132void
133GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
134 struct GNUNET_NAMESTORE_RecordData *rd)
135{
136 GNUNET_assert (0);
137}
138
139
140/**
141 * Picks up a (ringing) phone. This will connect the speaker
142 * to the microphone of the other party, and vice versa.
143 *
144 * @param phone phone to pick up
145 * @param metadata meta data to give to the other user about the pick up event
146 * @param speaker speaker to use
147 * @param mic microphone to use
148 */
149void
150GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
151 const char *metadata,
152 struct GNUNET_SPEAKER_Handle *speaker,
153 struct GNUNET_MICROPHONE_Handle *mic)
154{
155 GNUNET_assert (0);
156}
157
158
159/**
160 * Hang up up a (possibly ringing) phone. This will notify the other
161 * party that we are no longer interested in talking with them.
162 *
163 * @param phone phone to pick up
164 * @param reason text we give to the other party about why we terminated the conversation
165 */
166void
167GNUNET_CONVERSTATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone,
168 const char *reason)
169{
170 GNUNET_assert (0);
171}
172
173
174/**
175 * Destroys a phone.
176 *
177 * @param phone phone to destroy
178 */
179void
180GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
181{
182 GNUNET_assert (0);
183}
184
185
186/**
187 * Handle for an outgoing call.
188 */
189struct GNUNET_CONVERSATION_Call
190{
191
192 const struct GNUNET_CONFIGURATION_Handle *cfg;
193
194 struct GNUNET_IDENTITY_Ego *caller_id;
195
196 char *callee;
197
198 struct GNUNET_CONVERSATION_Speaker *speaker;
199
200 struct GNUNET_CONVERSATION_Microphone *mic;
201
202 GNUNET_CONVERSATION_EventHandler event_handler;
203
204 void *event_handler_cls;
205
206};
207
208
209/**
210 * Call the phone of another user.
211 *
212 * @param cfg configuration to use, specifies our phone service
213 * @param caller_id identity of the caller
214 * @param callee GNS name of the callee (used to locate the callee's record)
215 * @param speaker speaker to use (will be used automatically immediately once the
216 * #GNUNET_CONVERSATION_EC_READY event is generated); we will NOT generate
217 * a ring tone on the speaker
218 * @param mic microphone to use (will be used automatically immediately once the
219 * #GNUNET_CONVERSATION_EC_READY event is generated)
220 * @param event_handler how to notify the owner of the phone about events
221 * @param event_handler_cls closure for @a event_handler
222 */
223struct GNUNET_CONVERSATION_Call *
224GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
225 struct GNUNET_IDENTITY_Ego *caller_id,
226 const char *callee,
227 struct GNUNET_SPEAKER_Handle *speaker,
228 struct GNUNET_MICROPHONE_Handle *mic,
229 GNUNET_CONVERSATION_EventHandler event_handler,
230 void *event_handler_cls)
231{
232 GNUNET_assert (0);
233}
234
235
236/**
237 * Terminate a call. The call may be ringing or ready at this time.
238 *
239 * @param call call to terminate
240 * @param reason if the call was active (ringing or ready) this will be the
241 * reason given to the other user for why we hung up
242 */
243void
244GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call,
245 const char *reason)
246{
247 GNUNET_assert (0);
248}
249
250
251/* end of conversation_api.c */