Commit 6d44c6fe authored by Pekka Pessi's avatar Pekka Pessi
Browse files

soa_activate() now returns error code.

darcs-hash:20050913065032-65a35-8d3f9479b4095998f61caac3f146344bfabf3583.gz
parent e7f8d6af
......@@ -126,6 +126,7 @@ struct soa_session_actions const soa_default_actions =
soa_default_generate_answer,
soa_default_process_answer,
soa_base_activate,
soa_base_deactivate,
soa_base_terminate
};
#endif
......@@ -1052,22 +1053,41 @@ int soa_default_process_answer(soa_session_t *ss,
}
/** Activate session */
void soa_activate(soa_session_t *ss, char const *option)
int soa_activate(soa_session_t *ss, char const *option)
{
/** @ERROR EFAULT Bad address as @a ss. */
if (ss == NULL)
return;
return -1;
ss->ss_active = 1;
ss->ss_actions->soa_activate_session(ss, option);
return ss->ss_actions->soa_activate_session(ss, option);
}
int soa_base_activate(soa_session_t *ss, char const *option)
{
(void)ss;
(void)option;
return 0;
}
/** Deactivate session */
int soa_deactivate(soa_session_t *ss, char const *option)
{
/** @ERROR EFAULT Bad address as @a ss. */
if (ss == NULL)
return -1;
ss->ss_active = 0;
return ss->ss_actions->soa_deactivate_session(ss, option);
}
void soa_base_activate(soa_session_t *ss,
char const *option)
int soa_base_deactivate(soa_session_t *ss, char const *option)
{
(void)ss;
(void)option;
return 0;
}
/** Terminate session */
......
......@@ -105,7 +105,9 @@ int soa_generate_answer(soa_session_t *, soa_callback_f *);
/* Process answer */
int soa_process_answer(soa_session_t *, soa_callback_f *);
void soa_activate(soa_session_t *, char const *option);
int soa_activate(soa_session_t *, char const *option);
int soa_deactivate(soa_session_t *, char const *option);
void soa_terminate(soa_session_t *, char const *option);
int soa_is_complete(soa_session_t const *ss);
......
......@@ -84,7 +84,8 @@ static int soa_asynch_generate_answer(soa_session_t *ss,
soa_callback_f *completed);
static int soa_asynch_process_answer(soa_session_t *ss,
soa_callback_f *completed);
static void soa_asynch_activate(soa_session_t *ss, char const *option);
static int soa_asynch_activate(soa_session_t *ss, char const *option);
static int soa_asynch_deactivate(soa_session_t *ss, char const *option);
static void soa_asynch_terminate(soa_session_t *ss, char const *option);
struct soa_session_actions const soa_asynch_actions =
......@@ -107,6 +108,7 @@ struct soa_session_actions const soa_asynch_actions =
soa_asynch_generate_answer,
soa_asynch_process_answer,
soa_asynch_activate,
soa_asynch_deactivate,
soa_asynch_terminate
};
......@@ -273,9 +275,14 @@ static int soa_asynch_process_answer(soa_session_t *ss,
}
static void soa_asynch_activate(soa_session_t *ss, char const *option)
static int soa_asynch_activate(soa_session_t *ss, char const *option)
{
soa_base_activate(ss, option);
return soa_base_activate(ss, option);
}
static int soa_asynch_deactivate(soa_session_t *ss, char const *option)
{
return soa_base_deactivate(ss, option);
}
static void soa_asynch_terminate(soa_session_t *ss, char const *option)
......
......@@ -67,7 +67,8 @@ struct soa_session_actions
int (*soa_generate_answer)(soa_session_t *ss, soa_callback_f *completed);
int (*soa_process_answer)(soa_session_t *ss,
soa_callback_f *completed);
void (*soa_activate_session)(soa_session_t *ss, char const *option);
int (*soa_activate_session)(soa_session_t *ss, char const *option);
int (*soa_deactivate_session)(soa_session_t *ss, char const *option);
void (*soa_terminate_session)(soa_session_t *ss, char const *option);
};
......@@ -99,7 +100,8 @@ int soa_base_generate_offer(soa_session_t *ss, soa_callback_f *completed);
int soa_base_generate_answer(soa_session_t *ss, soa_callback_f *completed);
int soa_base_process_answer(soa_session_t *ss,
soa_callback_f *completed);
void soa_base_activate(soa_session_t *ss, char const *option);
int soa_base_activate(soa_session_t *ss, char const *option);
int soa_base_deactivate(soa_session_t *ss, char const *option);
void soa_base_terminate(soa_session_t *ss, char const *option);
int soa_default_generate_offer(soa_session_t *ss,
......
......@@ -77,7 +77,8 @@ static int soa_static_generate_answer(soa_session_t *ss,
soa_callback_f *completed);
static int soa_static_process_answer(soa_session_t *ss,
soa_callback_f *completed);
static void soa_static_activate(soa_session_t *ss, char const *option);
static int soa_static_activate(soa_session_t *ss, char const *option);
static int soa_static_deactivate(soa_session_t *ss, char const *option);
static void soa_static_terminate(soa_session_t *ss, char const *option);
struct soa_session_actions const soa_static_actions =
......@@ -100,6 +101,7 @@ struct soa_session_actions const soa_static_actions =
soa_static_generate_answer,
soa_static_process_answer,
soa_static_activate,
soa_static_deactivate,
soa_static_terminate
};
......@@ -123,6 +125,7 @@ struct soa_session_actions const soa_default_actions =
soa_static_generate_answer,
soa_static_process_answer,
soa_static_activate,
soa_static_deactivate,
soa_static_terminate
};
......@@ -214,9 +217,14 @@ static int soa_static_process_answer(soa_session_t *ss,
return soa_base_process_answer(ss, NULL);
}
static void soa_static_activate(soa_session_t *ss, char const *option)
static int soa_static_activate(soa_session_t *ss, char const *option)
{
soa_base_activate(ss, option);
return soa_base_activate(ss, option);
}
static int soa_static_deactivate(soa_session_t *ss, char const *option)
{
return soa_base_deactivate(ss, option);
}
static void soa_static_terminate(soa_session_t *ss, char const *option)
......
......@@ -132,7 +132,8 @@ int test_api_errors(struct context *ctx)
TEST_1(-1 == soa_process_answer(NULL, test_api_completed));
TEST_VOID(soa_activate(NULL, "both"));
TEST(soa_activate(NULL, "both"), -1);
TEST(soa_deactivate(NULL, "both"), -1);
TEST_VOID(soa_terminate(NULL, "both"));
TEST_1(!soa_is_complete(NULL));
......@@ -265,7 +266,8 @@ int test_static_offer_answer(struct context *ctx)
n = soa_generate_answer(b, test_completed); TEST(n, 0);
TEST_VOID(soa_activate(b, NULL));
TEST_1(soa_is_complete(b));
TEST(soa_activate(b, NULL), 0);
n = soa_get_local_sdp(b, &answer, &answerlen); TEST(n, 1);
TEST_1(answer != NULL && answer != NONE);
......@@ -274,7 +276,8 @@ int test_static_offer_answer(struct context *ctx)
n = soa_process_answer(a, test_completed); TEST(n, 0);
TEST_VOID(soa_activate(a, NULL));
TEST_1(soa_is_complete(a));
TEST(soa_activate(a, NULL), 0);
TEST_1(SOA_ACTIVE_SENDRECV == soa_is_audio_active(a));
TEST_1(SOA_ACTIVE_DISABLED == soa_is_video_active(a));
......@@ -346,7 +349,8 @@ int test_asynch_offer_answer(struct context *ctx)
su_root_run(ctx->root); TEST(ctx->completed, ctx->asynch.b);
ctx->completed = NULL;
TEST_VOID(soa_activate(ctx->asynch.b, NULL));
TEST_1(soa_is_complete(ctx->asynch.b));
TEST(soa_activate(ctx->asynch.b, NULL), 0);
n = soa_get_local_sdp(ctx->asynch.b, &answer, &answerlen); TEST(n, 1);
......@@ -357,7 +361,8 @@ int test_asynch_offer_answer(struct context *ctx)
su_root_run(ctx->root); TEST(ctx->completed, ctx->asynch.a);
ctx->completed = NULL;
TEST_VOID(soa_activate(ctx->asynch.a, NULL));
TEST_1(soa_is_complete(ctx->asynch.a));
TEST(soa_activate(ctx->asynch.a, NULL), 0);
TEST_1(SOA_ACTIVE_SENDRECV == soa_is_audio_active(ctx->asynch.a));
TEST_1(SOA_ACTIVE_DISABLED == soa_is_video_active(ctx->asynch.a));
......@@ -369,6 +374,9 @@ int test_asynch_offer_answer(struct context *ctx)
TEST_1(SOA_ACTIVE_DISABLED == soa_is_remote_image_active(ctx->asynch.a));
TEST_1(SOA_ACTIVE_DISABLED == soa_is_remote_chat_active(ctx->asynch.a));
TEST(soa_deactivate(ctx->asynch.a, NULL), 0);
TEST(soa_deactivate(ctx->asynch.b, NULL), 0);
TEST_VOID(soa_terminate(ctx->asynch.a, NULL));
TEST_1(SOA_ACTIVE_DISABLED == soa_is_audio_active(ctx->asynch.a));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment