Skip to content

Commit

Permalink
Take policy from query msg #32 & #14
Browse files Browse the repository at this point in the history
  • Loading branch information
claucece committed Dec 19, 2017
1 parent 7171804 commit 689de75
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static otrv4_t *create_connection_for(const char *recipient,
if (!otr3_conn)
return NULL;

// TODO: put here policy none
conn = otrv4_new(client->state, get_policy_for(recipient));
if (!conn) {
otr3_conn_free(otr3_conn);
Expand Down Expand Up @@ -308,7 +309,7 @@ int otr4_client_receive(char **newmessage, char **todisplay,
}

char *otr4_client_query_message(const char *recipient, const char *message,
otr4_client_t *client) {
otr4_client_t *client, OtrlPolicy policy) {
otr4_conversation_t *conv = NULL;
char *ret = NULL;

Expand All @@ -319,6 +320,7 @@ char *otr4_client_query_message(const char *recipient, const char *message,
// TODO: add name
ret = "Failed to start an Off-the-Record private conversation.";

conv->conn->supported_versions = policy;
// TODO: implement policy
if (otrv4_build_query_message(&ret, message, conv->conn))
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ otr4_client_t *otr4_client_new(otr4_client_state_t *);
void otr4_client_free(otr4_client_t *client);

char *otr4_client_query_message(const char *recipient, const char *message,
otr4_client_t *client);
otr4_client_t *client, OtrlPolicy policy);

int otr4_client_send(char **newmessage, const char *message,
const char *recipient, otr4_client_t *client);
Expand Down
23 changes: 12 additions & 11 deletions src/test/test_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ void test_client_api() {
set_up_client(charlie_state, CHARLIE_IDENTITY, PHI, 3);

char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);
otrv4_assert(query_msg_to_bob);

char *query_msg_to_charlie =
otr4_client_query_message(CHARLIE_IDENTITY, "Hi charlie", alice);
char *query_msg_to_charlie = otr4_client_query_message(
CHARLIE_IDENTITY, "Hi charlie", alice, OTRV4_ALLOW_V4);
otrv4_assert(query_msg_to_charlie);

int ignore = 0;
Expand Down Expand Up @@ -264,7 +264,8 @@ void test_conversation_with_multiple_locations() {
otr4_client_t *alice = set_up_client(alice_state, ALICE_IDENTITY, PHI, 1);
otr4_client_t *bob = set_up_client(bob_state, BOB_IDENTITY, PHI, 2);

char *query_msg = otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
char *query_msg =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);

int ignore = 0;
char *from_alice_to_bob = NULL, *frombob = NULL, *todisplay = NULL;
Expand Down Expand Up @@ -361,7 +362,7 @@ void test_valid_identity_msg_in_waiting_auth_i() {
otr4_client_t *bob = set_up_client(bob_state, BOB_IDENTITY, PHI, 2);

char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);

int ignore = 0;
char *from_alice_to_bob = NULL, *todisplay = NULL, *bobs_id = NULL,
Expand Down Expand Up @@ -498,7 +499,7 @@ void test_invalid_auth_r_msg_in_not_waiting_auth_r() {

// Alice sends a query message to Bob
char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);

int ignore = 0;
char *todisplay = NULL, *bobs_id = NULL, *alices_auth_r = NULL,
Expand Down Expand Up @@ -613,11 +614,11 @@ void test_valid_identity_msg_in_waiting_auth_r() {

// Alice sends a query message to Bob
char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);

// Bob sends a query message to Alice
char *query_msg_to_alice =
otr4_client_query_message(ALICE_IDENTITY, "Hi alice", bob);
char *query_msg_to_alice = otr4_client_query_message(
ALICE_IDENTITY, "Hi alice", bob, OTRV4_ALLOW_V4);

int ignore = 0;
char *todisplay = NULL, *alices_id = NULL, *bobs_id = NULL,
Expand Down Expand Up @@ -789,7 +790,7 @@ void test_invalid_auth_i_msg_in_not_waiting_auth_i() {

// Alice sends a query message to Bob
char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);

int ignore = 0;
char *todisplay = NULL, *bobs_id = NULL, *alices_auth_r = NULL,
Expand Down Expand Up @@ -927,7 +928,7 @@ void test_client_sends_fragmented_message(void) {
otr4_client_t *bob = set_up_client(bob_state, BOB_IDENTITY, PHI, 2);

char *query_msg_to_bob =
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice);
otr4_client_query_message(BOB_IDENTITY, "Hi bob", alice, OTRV4_ALLOW_V4);
otrv4_assert(query_msg_to_bob);

char *from_alice_to_bob = NULL, *from_bob = NULL, *todisplay = NULL;
Expand Down

0 comments on commit 689de75

Please sign in to comment.