summaryrefslogtreecommitdiffstats
path: root/friendfinder
diff options
context:
space:
mode:
authorPatrick Hornecker2010-03-04 18:25:48 +0100
committerPatrick Hornecker2010-03-04 18:25:48 +0100
commit8ca42e34fecd370955559160829722c3b6b54690 (patch)
tree774a7bb248564147daeace8a4710a65d54799d9f /friendfinder
parentdone :) (diff)
downloadfriendfinder-8ca42e34fecd370955559160829722c3b6b54690.tar.gz
friendfinder-8ca42e34fecd370955559160829722c3b6b54690.tar.xz
friendfinder-8ca42e34fecd370955559160829722c3b6b54690.zip
bug fixes
Diffstat (limited to 'friendfinder')
-rw-r--r--friendfinder/Makefile2
-rw-r--r--friendfinder/barcode.pngbin296 -> 0 bytes
-rw-r--r--friendfinder/handler.h3
-rw-r--r--friendfinder/receiver.c68
-rw-r--r--friendfinder/sender.c13
5 files changed, 56 insertions, 30 deletions
diff --git a/friendfinder/Makefile b/friendfinder/Makefile
index 8b00324..240bdc1 100644
--- a/friendfinder/Makefile
+++ b/friendfinder/Makefile
@@ -1,7 +1,7 @@
include Makefile.inc
all: $(OBJECTS)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o gui$(SUFFIX)
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o friendfinder$(SUFFIX)
prepare: $(OBJECTS_PREPARE)
diff --git a/friendfinder/barcode.png b/friendfinder/barcode.png
deleted file mode 100644
index 9f6cab3..0000000
--- a/friendfinder/barcode.png
+++ /dev/null
Binary files differ
diff --git a/friendfinder/handler.h b/friendfinder/handler.h
index 229c250..a566218 100644
--- a/friendfinder/handler.h
+++ b/friendfinder/handler.h
@@ -1,9 +1,6 @@
#ifndef __HANDLER_H_
#define __HANDLER_H_
-/* starts postition sending */
-void start_pos();
-
/* init threads */
void init_msg_thread(char *from, char *to);
diff --git a/friendfinder/receiver.c b/friendfinder/receiver.c
index 0cf1a44..73a0409 100644
--- a/friendfinder/receiver.c
+++ b/friendfinder/receiver.c
@@ -240,16 +240,15 @@ void get_position(irc_session_t * session, const char * event, const char * orig
unsigned char *encrypted_base64;
char *sender_org = (char*) malloc(username_length + 1);
- char *own_sender_nickname = (char*) malloc(username_length + 2);
+ char *own_sender_nickname = (char*) malloc(username_length + 3);
sender_name = (char*) malloc(sizeof(char) * 50);
- memcpy(own_sender_nickname, own_nickname, sizeof(own_nickname));
+ memcpy(own_sender_nickname, own_nickname, strlen(own_nickname));
strcat(own_sender_nickname, "_s");
irc_target_get_nick(origin, sender_name, sizeof(sender_name));
strncpy(sender_org, sender_name, username_length);
sender_org[username_length] = '\0';
-//&& strcmp(sender_name, "_s")
if (strcmp(sender_org, own_nickname) != 0 && strcmp(params[1], "connected") != 0 && check_message(params[1], sender_name) == 1)
{
@@ -258,7 +257,7 @@ void get_position(irc_session_t * session, const char * event, const char * orig
if (s_sender[pos]->lat_set == 0)
{
encrypted_base64 = (char*) malloc(sizeof(char) *60);
- decrypted = (char*) malloc(sizeof(char) * 7);
+ decrypted = (char*) malloc(sizeof(char) * 8);
from_base64(params[1], strlen(params[1]), encrypted_base64, 60);
BF_ecb_encrypt(encrypted_base64, decrypted, &key, BF_DECRYPT);
@@ -276,7 +275,7 @@ void get_position(irc_session_t * session, const char * event, const char * orig
else if (s_sender[pos]->lon_set == 0)
{
encrypted_base64 = (char*) malloc(sizeof(char) * 60);
- decrypted = (char*) malloc(sizeof(char) * 7);
+ decrypted = (char*) malloc(sizeof(char) * 8);
from_base64(params[1], strlen(params[1]), encrypted_base64, 60);
BF_ecb_encrypt(encrypted_base64, decrypted, &key, BF_DECRYPT);
@@ -298,7 +297,6 @@ void get_position(irc_session_t * session, const char * event, const char * orig
_lon = atof(s_sender[pos]->lon);
printf(" DUMPING DATA \n");
- printf("position in struct is %i \n", pos);
printf("lat: %s lon: %s \n", s_sender[pos]->lat, s_sender[pos]->lon);
printf("nick: %s \n", s_sender[pos]->nick);
printf("=========================================\n");
@@ -326,18 +324,48 @@ void get_position(irc_session_t * session, const char * event, const char * orig
}
}
+int count_ack = 0;
+int is_init = 0;
+char* sender_base64;
+
void send_acknowledgement(char *sender)
{
- char* sender_base64 = (char*) malloc(sizeof(char) * 60);
- char* sender_crypted = (char*) malloc(sizeof(char) * 20);
+ if (is_init == 0 && count_ack == 0)
+ {
+ sender_base64 = (char*) malloc(sizeof(char) * 60);
+ char* sender_crypted = (char*) malloc(sizeof(char) * 30);
+
+ BF_ecb_encrypt(sender, sender_crypted, &key, BF_ENCRYPT);
- printf("sender: %s \n", sender);
- BF_ecb_encrypt(sender, sender_crypted, &key, BF_ENCRYPT);
- to_base64(sender_crypted, strlen(sender_crypted), sender_base64, 60);
- irc_cmd_msg(session, "#test", sender_base64);
+ to_base64(sender_crypted, strlen(sender_crypted), sender_base64, 60);
+
+ irc_cmd_msg(session, "#test", sender_base64);
+
+ free(sender_crypted);
+ is_init = 1;
+ count_ack++;
+
+ return;
+ }
+
+ if (is_init == 1 && count_ack < 3)
+ {
+ irc_cmd_msg(session, "#test", sender_base64);
+ count_ack++;
- free(sender_base64);
- free(sender_crypted);
+ return;
+ }
+
+ if (is_init == 1 && count_ack == 3)
+ {
+ irc_cmd_msg(session, "#test", sender_base64);
+ count_ack = 0;
+ is_init = 0;
+
+ free(sender_base64);
+
+ return;
+ }
}
int check_message(char *msg, char *sender)
@@ -396,18 +424,20 @@ void receiver_main(void *user)
callbacks.event_channel = get_position;
callbacks.event_connect = on_connect_receiver;
- username = (char*) malloc(sizeof(char) * 50);
- own_nickname = (char*) malloc(sizeof(char) * 50);
+ username = (char*) malloc(sizeof(char) * sizeof(user));
+ own_nickname = (char*) malloc(sizeof(char) * sizeof(user));
- memcpy(username, (char*) user, sizeof(user));
- memcpy(own_nickname, (char*) user, sizeof(user));
+ memcpy(username, user, sizeof(user));
+ memcpy(own_nickname, user, sizeof(user));
+
+ printf("%s \n", username);
username_length = strlen(username);
if (receiver_server_ip != NULL && user != NULL)
{
strcat(username, "_r");
-
+ printf("%s \n", username);
if (init_connection_receiver(receiver_server_ip, username) == 0)
{
printf("RECEIVER: connection succesfull...\n");
diff --git a/friendfinder/sender.c b/friendfinder/sender.c
index 3a81389..a81acc0 100644
--- a/friendfinder/sender.c
+++ b/friendfinder/sender.c
@@ -165,7 +165,6 @@ void send_position(irc_session_t * session, const char * event, const char * ori
pos = prepare_position(lat_char, lon_char);
- printf("%i \n", sizeof(pos->lat_first) + sizeof(pos->lat_second) + sizeof(pos->lon_first) + sizeof(pos->lon_second));
BF_ecb_encrypt(pos->lat_first, crypted_lat_first, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lat_second, crypted_lat_second, &key, BF_ENCRYPT);
@@ -227,8 +226,8 @@ void get_acknowledge(irc_session_t * session, const char * event, const char * o
BF_ecb_encrypt(ack_base64, ack, &key, BF_DECRYPT);
irc_target_get_nick(origin, sender_name, sizeof(sender_name));
-
- if(strcmp(suffix_username, sender_name) != 0 && strcmp(ack, suffix_username) == 0 && strcmp(sender_name, own_receiver_name) != 0 &&
+
+ if (strcmp(suffix_username, sender_name) != 0 && strcmp(ack, suffix_username) == 0 && strcmp(sender_name, own_receiver_name) != 0 &&
strcmp(sender_name, "_r") > 0)
{
if (ack_count < 4 && msg_count > 0)
@@ -255,16 +254,16 @@ void sender_main(void *user)
callbacks.event_connect = send_position;
callbacks.event_channel = get_acknowledge;
- username = (char*) malloc(sizeof(char) * 50);
- suffix_username = (char*) malloc(sizeof(char) * 50);
+ username = (char*) malloc(sizeof(char) * sizeof(user));
+ suffix_username = (char*) malloc(sizeof(char) * sizeof(user));
- memcpy(username, (char*) user, sizeof(user));
+ memcpy(username, user, strlen(user));
suffix_username = (char*) user;
if (sender_server_ip != NULL)
{
strcat(suffix_username, "_s");
-
+ printf("%s \n", suffix_username);
if (init_connection_sender(sender_server_ip, suffix_username) == 0)
{
printf("SENDER: connection succesfull...\n");