summaryrefslogtreecommitdiffstats
path: root/friendfinder
diff options
context:
space:
mode:
authorPatrick Hornecker2010-01-18 14:00:02 +0100
committerPatrick Hornecker2010-01-18 14:00:02 +0100
commit8d32265f5c99e3f703c39511a6e31e49f8988c92 (patch)
tree2d7a9f6cf6fdd9dd9c4911cd73d9fd8558402b52 /friendfinder
parentmessages converted into blocks of 7*char, and send them (diff)
downloadfriendfinder-8d32265f5c99e3f703c39511a6e31e49f8988c92.tar.gz
friendfinder-8d32265f5c99e3f703c39511a6e31e49f8988c92.tar.xz
friendfinder-8d32265f5c99e3f703c39511a6e31e49f8988c92.zip
msg block send finished
Diffstat (limited to 'friendfinder')
-rw-r--r--friendfinder/barcode.c21
-rw-r--r--friendfinder/barcode.h0
-rw-r--r--friendfinder/gui.c18
-rw-r--r--friendfinder/msg_sender.c84
4 files changed, 84 insertions, 39 deletions
diff --git a/friendfinder/barcode.c b/friendfinder/barcode.c
new file mode 100644
index 0000000..555205a
--- /dev/null
+++ b/friendfinder/barcode.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+#include "qrencode.h"
+
+
+
+void generate_barcode(char* key)
+{
+ QRcode *code;
+
+ code = QRcode_encodeString(key, 0, QR_ECLEVEL_M, QR_MODE_8, 1);
+
+
+
+ QRinput_free(code);
+}
+
+void generate_png(QRcode *code)
+{
+
+}
diff --git a/friendfinder/barcode.h b/friendfinder/barcode.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/friendfinder/barcode.h
diff --git a/friendfinder/gui.c b/friendfinder/gui.c
index 659069a..34bbb3f 100644
--- a/friendfinder/gui.c
+++ b/friendfinder/gui.c
@@ -125,6 +125,11 @@ static void on_options(void *data, Evas_Object *obj, void *event_info)
init_options();
}
+static void on_barcode(void *data, Evas_Object *obj, void *event_info)
+{
+
+}
+
static void on_message(void *data, Evas_Object *obj, void *event_info)
{
msg_text = elm_entry_entry_get(obj);
@@ -198,6 +203,8 @@ void show_message(char *current_msg)
first = 1;
bubble_pos = bubble_pos + h/6;
+
+ current_msg[0] = '\0';
return;
}
@@ -211,6 +218,8 @@ void show_message(char *current_msg)
first = 2;
bubble_pos = bubble_pos + h/6;
+
+ current_msg[0] = '\0';
return;
}
@@ -224,6 +233,8 @@ void show_message(char *current_msg)
first = 0;
bubble_pos = 100;
+
+ current_msg[0] = '\0';
return;
}
}
@@ -341,9 +352,14 @@ void init_toolbar()
evas_object_show(ic);
ic = elm_icon_add(win);
- elm_icon_standard_set(ic, "clock");
+ elm_icon_standard_set(ic, "home");
elm_toolbar_item_add(tb, ic, "Map", on_map, NULL);
evas_object_show(ic);
+
+ ic = elm_icon_add(win);
+ elm_icon_standard_set(ic, "file");
+ elm_toolbar_item_add(tb, ic, "Barcode", on_barcode, NULL);
+ evas_object_show(ic);
evas_object_show(ic);
diff --git a/friendfinder/msg_sender.c b/friendfinder/msg_sender.c
index 4946c37..dbd82af 100644
--- a/friendfinder/msg_sender.c
+++ b/friendfinder/msg_sender.c
@@ -16,7 +16,7 @@ char sender_name[100];
char* nick_from;
char* send_to;
char* msg_to_send;
-char *msg;
+char msg[300];
irc_dcc_t dccid;
irc_dcc_t buddy_dccid = 1;
@@ -27,7 +27,7 @@ int init_connection(char* server_ip, char* user)
{
printf("MSG_SENDER: initialising connection...\n");
- msg = (char*) malloc(sizeof(char));
+// msg = (char*) malloc(sizeof(char) * 300);
session = irc_create_session(&callbacks);
int con = irc_connect(session, server_ip, 6666, NULL, user, user, user);
@@ -59,23 +59,29 @@ struct msg_part* prepare_msg(char *msg)
int len_used = 0;
struct msg_part *msg_p = (struct msg_part*) malloc(sizeof(struct msg_part));
- msg_p->part_count = len / 7;
+
+ if (len % 6 != 0)
+ msg_p->part_count = len / 6;
+
+ if (len % 6 == 0)
+ msg_p->part_count = (len / 6) - 1;
int inc_part_count = msg_p->part_count + 1;
msg_p->msg_parts = (char(*)[inc_part_count]) malloc(sizeof(char*) * inc_part_count);
char *message = (char*) malloc(len + 1);
memcpy(message, msg, len + 1);
+
- if (len <= 7)
+ if (len <= 6 && len > 0)
{
msg_p->msg_parts[0] = message;
return msg_p;
}
- if (len > 7)
+ if (len > 6 && len > 0)
{
- int i = 0;
+ int i = 0, n = 0;
while (i <= msg_p->part_count)
{
@@ -83,25 +89,26 @@ struct msg_part* prepare_msg(char *msg)
{
msg_p->msg_parts[i] = (char*) malloc(sizeof(char) * 8);
- strncpy(msg_p->msg_parts[i], message, 7);
- for (int j = 0; j <= 7; j++)
+ strncpy(msg_p->msg_parts[i], message, 6);
+ msg_p->msg_parts[7] = '\0';
+ for (int j = 0; j < 6; j++)
{
- if (len - len_used >= 7)
+ if (len - len_used >= 6)
{
- *(message + j) = *(message + j + 7);
+ *(message + j) = *(message + len_used + j + 6);
}
}
- len_used += 7;
+ len_used = len_used + 6;
}
- else if (i == msg_p->part_count)
+ else if (i == msg_p->part_count && (len - len_used) != 0)
{
- msg_p->msg_parts[i] = (char*) malloc(sizeof(char) * (len - len_used)); //FIXME
+ msg_p->msg_parts[i] = (char*) malloc(sizeof(char) * (len - len_used));
- for (int j = 0; j <= (len - len_used); j++)
- {
- *(message + j) = *(message + j + len_used);
- }
- strncpy(msg_p->msg_parts[i], message, (len - len_used));
+ if ((len - len_used) < 6)
+ strncpy(msg_p->msg_parts[i], message, (len - len_used) + 1);
+
+ if ((len - len_used) == 6)
+ strncpy(msg_p->msg_parts[i], message, (len - len_used) + 1);
}
i++;
}
@@ -115,18 +122,16 @@ struct msg_part* prepare_msg(char *msg)
void repair_msg(char* inc_msg, char *msg)
{
- int len = strlen(msg);
+ int len = strlen(inc_msg);
+ printf("repair_msg len: %i \n", len);
+ printf("repair_msg: %s \n", msg);
+
+ if (strcmp(inc_msg, "//c//") != 0)
+ strcat(msg, inc_msg);
- if (len == 7)
- {
- strcat(inc_msg, msg);
- }
- if (len < 7)
- {
- strcat(inc_msg, msg);
- strcat(inc_msg, '\0');
+ if (strcmp(inc_msg, "//c//") == 0)
show_message(msg);
- }
+ printf("repair_msg: %s \n", msg);
}
void set_txt_msg(char *msg)
@@ -137,20 +142,29 @@ void set_txt_msg(char *msg)
msg_p = prepare_msg(msg);
send_message(session, msg_p);
}
- else printf("MSG_SENDER: NULL value \n");
+ else printf("MSG_SENDER: session not initialized \n");
}
void send_message(irc_session_t *session, struct msg_part *msg_p)
{
- if (msg_p->msg_parts != NULL)
+ if (msg_p->msg_parts != NULL && strlen(msg_p->msg_parts[0]) > 0)
{
for (int i = 0; i <= msg_p->part_count; i++)
{
char *crypted_msg = (char*) malloc(sizeof(char));
- BF_ecb_encrypt(msg_p->msg_parts[i], crypted_msg, &key, BF_ENCRYPT);
+ BF_ecb_encrypt(msg_p->msg_parts[i], crypted_msg, &key, BF_ENCRYPT);
irc_cmd_msg(session, "#msg", crypted_msg);
free(crypted_msg);
}
+ char* eof = "//c//";
+
+ char *crypted_eof = (char*) malloc(sizeof(char));
+ BF_ecb_encrypt(eof, crypted_eof, &key, BF_ENCRYPT);
+ irc_cmd_msg(session, "#msg", crypted_eof);
+ free(crypted_eof);
+
+ free(msg_p);
+
}
else return;
}
@@ -159,18 +173,15 @@ void send_message(irc_session_t *session, struct msg_part *msg_p)
void on_connect(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
char *_key = read_key();
- printf("%s \n", _key);
irc_cmd_join(session, "#msg", NULL);
irc_cmd_msg(session, "#msg", "connected");
BF_set_key(&key, strlen(_key) - 1, _key);
-// BF_set_key(&key, 5, "abcde");
}
void on_channel(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
- //char *msg = (char*) malloc(sizeof(char));
- char *inc_msg = (char*) malloc(sizeof(char));
+ char *inc_msg = (char*) malloc(sizeof(char) * 8);
irc_target_get_nick(origin, sender_name, sizeof(sender_name));
@@ -184,9 +195,6 @@ void on_channel(irc_session_t * session, const char * event, const char * origin
else
{
BF_ecb_encrypt(params[1], inc_msg, &key, BF_DECRYPT);
- printf("%s: %s \n", params[0], msg);
-
- //show_message(msg);
repair_msg(inc_msg, msg);
}
}