summaryrefslogtreecommitdiff
path: root/src/conversation/test_conversation_api_twocalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/test_conversation_api_twocalls.c')
-rw-r--r--src/conversation/test_conversation_api_twocalls.c205
1 files changed, 73 insertions, 132 deletions
diff --git a/src/conversation/test_conversation_api_twocalls.c b/src/conversation/test_conversation_api_twocalls.c
index 0b19f4783..c0768f590 100644
--- a/src/conversation/test_conversation_api_twocalls.c
+++ b/src/conversation/test_conversation_api_twocalls.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -39,11 +39,9 @@
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 25)
-#define LOG(kind,...) \
- GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-#define LOG_DEBUG(...) \
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+#define LOG_DEBUG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -97,7 +95,7 @@ static const char *phone0 = "phone";
#define CALLER2 &caller2
#define PHONE0 &phone0
-#define CLS_STR(caller) (*((char **)caller))
+#define CLS_STR(caller) (*((char **) caller))
/**
@@ -116,8 +114,7 @@ struct MicContext
void *rdc_cls;
- struct GNUNET_SCHEDULER_Task * call_task;
-
+ struct GNUNET_SCHEDULER_Task *call_task;
};
static struct MicContext call1_mic_ctx;
@@ -133,12 +130,8 @@ phone_send (void *cls)
(void) cls;
GNUNET_assert (NULL != phone_rdc);
GNUNET_snprintf (buf, sizeof (buf), "phone");
- phone_rdc (phone_rdc_cls,
- strlen (buf) + 1,
- buf);
- phone_task = GNUNET_SCHEDULER_add_delayed (FREQ,
- &phone_send,
- NULL);
+ phone_rdc (phone_rdc_cls, strlen (buf) + 1, buf);
+ phone_task = GNUNET_SCHEDULER_add_delayed (FREQ, &phone_send, NULL);
}
@@ -150,15 +143,9 @@ call_send (void *cls)
(void) cls;
GNUNET_assert (NULL != mc->rdc);
- GNUNET_snprintf (buf,
- sizeof (buf),
- "call");
- mc->rdc (mc->rdc_cls,
- strlen (buf) + 1,
- buf);
- mc->call_task = GNUNET_SCHEDULER_add_delayed (FREQ,
- &call_send,
- mc);
+ GNUNET_snprintf (buf, sizeof (buf), "call");
+ mc->rdc (mc->rdc_cls, strlen (buf) + 1, buf);
+ mc->call_task = GNUNET_SCHEDULER_add_delayed (FREQ, &call_send, mc);
}
@@ -168,8 +155,7 @@ enable_speaker (void *cls)
const char *origin = CLS_STR (cls);
(void) cls;
- LOG_DEBUG ("Speaker %s enabled\n",
- origin);
+ LOG_DEBUG ("Speaker %s enabled\n", origin);
return GNUNET_OK;
}
@@ -180,15 +166,12 @@ disable_speaker (void *cls)
const char *origin = CLS_STR (cls);
(void) cls;
- LOG_DEBUG ("Speaker %s disabled\n",
- origin);
+ LOG_DEBUG ("Speaker %s disabled\n", origin);
}
static void
-play (void *cls,
- size_t data_size,
- const void *data)
+play (void *cls, size_t data_size, const void *data)
{
static unsigned int phone_i;
static unsigned int call_i;
@@ -206,9 +189,7 @@ play (void *cls,
(const char *) data);
}
- if ( (20 < call_i) &&
- (20 < phone_i) &&
- (CALLER2 == cls) )
+ if ((20 < call_i) && (20 < phone_i) && (CALLER2 == cls))
{
/* time to hang up ... */
GNUNET_CONVERSATION_call_stop (call2);
@@ -218,9 +199,7 @@ play (void *cls,
phone_i = 0;
call2_finished = GNUNET_YES;
}
- if ( (20 < call_i) &&
- (20 < phone_i) &&
- (CALLER1 == cls) )
+ if ((20 < call_i) && (20 < phone_i) && (CALLER1 == cls))
{
/* time to hang up ... */
GNUNET_CONVERSATION_call_stop (call1);
@@ -241,31 +220,25 @@ destroy_speaker (void *cls)
}
-static struct GNUNET_SPEAKER_Handle call1_speaker = {
- &enable_speaker,
- &play,
- &disable_speaker,
- &destroy_speaker,
- CALLER1
-};
+static struct GNUNET_SPEAKER_Handle call1_speaker = {&enable_speaker,
+ &play,
+ &disable_speaker,
+ &destroy_speaker,
+ CALLER1};
-static struct GNUNET_SPEAKER_Handle call2_speaker = {
- &enable_speaker,
- &play,
- &disable_speaker,
- &destroy_speaker,
- CALLER2
-};
+static struct GNUNET_SPEAKER_Handle call2_speaker = {&enable_speaker,
+ &play,
+ &disable_speaker,
+ &destroy_speaker,
+ CALLER2};
-static struct GNUNET_SPEAKER_Handle phone_speaker = {
- &enable_speaker,
- &play,
- &disable_speaker,
- &destroy_speaker,
- PHONE0
-};
+static struct GNUNET_SPEAKER_Handle phone_speaker = {&enable_speaker,
+ &play,
+ &disable_speaker,
+ &destroy_speaker,
+ PHONE0};
static int
@@ -276,8 +249,7 @@ enable_mic (void *cls,
const char *origin = CLS_STR (cls);
struct MicContext *mc;
- LOG_DEBUG ("Mic %s enabled\n",
- origin);
+ LOG_DEBUG ("Mic %s enabled\n", origin);
if (PHONE0 == cls)
{
phone_rdc = rdc;
@@ -301,8 +273,7 @@ disable_mic (void *cls)
const char *origin = CLS_STR (cls);
struct MicContext *mc;
- LOG_DEBUG ("Mic %s disabled\n",
- origin);
+ LOG_DEBUG ("Mic %s disabled\n", origin);
if (PHONE0 == cls)
{
phone_rdc = NULL;
@@ -324,33 +295,26 @@ destroy_mic (void *cls)
{
const char *origin = CLS_STR (cls);
- LOG_DEBUG ("Mic %s destroyed\n",
- origin);
+ LOG_DEBUG ("Mic %s destroyed\n", origin);
}
-static struct GNUNET_MICROPHONE_Handle call1_mic = {
- &enable_mic,
- &disable_mic,
- &destroy_mic,
- CALLER1
-};
+static struct GNUNET_MICROPHONE_Handle call1_mic = {&enable_mic,
+ &disable_mic,
+ &destroy_mic,
+ CALLER1};
-static struct GNUNET_MICROPHONE_Handle call2_mic = {
- &enable_mic,
- &disable_mic,
- &destroy_mic,
- CALLER2
-};
+static struct GNUNET_MICROPHONE_Handle call2_mic = {&enable_mic,
+ &disable_mic,
+ &destroy_mic,
+ CALLER2};
-static struct GNUNET_MICROPHONE_Handle phone_mic = {
- &enable_mic,
- &disable_mic,
- &destroy_mic,
- PHONE0
-};
+static struct GNUNET_MICROPHONE_Handle phone_mic = {&enable_mic,
+ &disable_mic,
+ &destroy_mic,
+ PHONE0};
/**
@@ -363,8 +327,7 @@ end_test (void *cls)
{
(void) cls;
timeout_task = NULL;
- fprintf (stderr,
- "Timeout!\n");
+ fprintf (stderr, "Timeout!\n");
GNUNET_SCHEDULER_shutdown ();
}
@@ -423,17 +386,14 @@ do_shutdown (void *cls)
static void
-caller_event_handler (void *cls,
- enum GNUNET_CONVERSATION_CallerEventCode code)
+caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
{
(void) cls;
switch (code)
{
case GNUNET_CONVERSATION_EC_CALLER_SUSPEND:
case GNUNET_CONVERSATION_EC_CALLER_RESUME:
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Unexpected caller code: %d\n",
- code);
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected caller code: %d\n", code);
break;
}
}
@@ -490,17 +450,14 @@ phone_event_handler (void *cls,
}
break;
default:
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Unexpected phone code: %d\n",
- code);
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected phone code: %d\n", code);
break;
}
}
static void
-call_event_handler (void *cls,
- enum GNUNET_CONVERSATION_CallEventCode code)
+call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
{
const char *cid = cls;
@@ -541,6 +498,7 @@ call_event_handler (void *cls,
static void
caller_ego_create_cont (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
const char *emsg)
{
(void) cls;
@@ -550,19 +508,14 @@ caller_ego_create_cont (void *cls,
static void
-namestore_put_cont (void *cls,
- int32_t success,
- const char *emsg)
+namestore_put_cont (void *cls, int32_t success, const char *emsg)
{
(void) cls;
qe = NULL;
GNUNET_assert (GNUNET_YES == success);
GNUNET_assert (NULL == emsg);
GNUNET_assert (NULL == op);
- op = GNUNET_IDENTITY_create (id,
- "caller-ego",
- &caller_ego_create_cont,
- NULL);
+ op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL);
}
@@ -587,23 +540,21 @@ identity_cb (void *cls,
GNUNET_asprintf (&gns_name,
"phone.%s",
GNUNET_GNSRECORD_pkey_to_zkey (&pub));
- phone = GNUNET_CONVERSATION_phone_create (cfg,
- ego,
- &phone_event_handler,
- NULL);
+ phone =
+ GNUNET_CONVERSATION_phone_create (cfg, ego, &phone_event_handler, NULL);
GNUNET_assert (NULL != phone);
memset (&rd, 0, sizeof (rd));
- GNUNET_CONVERSATION_phone_get_record (phone,
- &rd);
+ GNUNET_CONVERSATION_phone_get_record (phone, &rd);
GNUNET_assert (rd.record_type == GNUNET_GNSRECORD_TYPE_PHONE);
rd.expiration_time = UINT64_MAX;
- qe = GNUNET_NAMESTORE_records_store (ns,
- GNUNET_IDENTITY_ego_get_private_key (ego),
- "phone" /* GNS label */,
- 1,
- &rd,
- &namestore_put_cont,
- NULL);
+ qe =
+ GNUNET_NAMESTORE_records_store (ns,
+ GNUNET_IDENTITY_ego_get_private_key (ego),
+ "phone" /* GNS label */,
+ 1,
+ &rd,
+ &namestore_put_cont,
+ NULL);
return;
}
if (0 == strcmp (name, "caller-ego"))
@@ -632,8 +583,7 @@ identity_cb (void *cls,
static void
-phone_ego_create_cont (void *cls,
- const char *emsg)
+phone_ego_create_cont (void *cls, const char *emsg)
{
(void) cls;
op = NULL;
@@ -649,32 +599,23 @@ run (void *cls,
(void) cls;
(void) peer;
cfg = c;
- timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &end_test,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
- id = GNUNET_IDENTITY_connect (cfg,
- &identity_cb,
- NULL);
- op = GNUNET_IDENTITY_create (id,
- "phone-ego",
- &phone_ego_create_cont,
- NULL);
+ timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+ id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL);
+ op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL);
ns = GNUNET_NAMESTORE_connect (cfg);
}
int
-main (int argc,
- char *argv[])
+main (int argc, char *argv[])
{
(void) argc;
(void) argv;
if (0 != GNUNET_TESTING_peer_run ("test_conversation_api_twocalls",
- "test_conversation.conf",
- &run,
- NULL))
+ "test_conversation.conf",
+ &run,
+ NULL))
return 1;
if (call1_finished && call2_finished)
return 0;