From a036f4b00cb0c2a7e6c070667ac562f0e585c7e4 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 21 Aug 2022 10:17:09 +0200 Subject: Implement correct recipient for send_message() --- data.c | 6 ++++++ data.h | 1 + gtk.c | 3 +-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/data.c b/data.c index afa4616..7645679 100644 --- a/data.c +++ b/data.c @@ -22,6 +22,8 @@ void data_add_roster_item(const char* jid, const char* subscription, // initialize chat chat->messages = NULL; + chat->jid = malloc(sizeof(char)*strlen(jid)); + strcpy(chat->jid, jid); gui_add_chat_widget(chat); // initialize roster item @@ -63,6 +65,7 @@ void data_add_roster_item(const char* jid, const char* subscription, void data_add_incoming_message(const char* sender_jid, const char* content) { + // TODO rework based on chat->jid // find correct chat chat_t* chat = NULL; roster_item_t* i; @@ -95,4 +98,7 @@ void data_add_incoming_message(const char* sender_jid, const char* content) { // append message to chat m = msg; + // TODO could be more correct to update chat->jid to full JID of just + // received message so that future responses go to this ressource + } diff --git a/data.h b/data.h index 6b6e936..51d9b01 100644 --- a/data.h +++ b/data.h @@ -17,6 +17,7 @@ typedef struct _message_t { } message_t; typedef struct _chat_t { + char* jid; message_t* messages; void* widget; } chat_t; diff --git a/gtk.c b/gtk.c index 42bdb16..45e6f10 100644 --- a/gtk.c +++ b/gtk.c @@ -71,11 +71,10 @@ void send_message(chat_t* chat) { chat_widget_t* chat_widget = (chat_widget_t*)chat->widget; // get recipient and message text - const char* recipient = "unknown@example.com"; // TODO implement this const char* text = gtk_editable_get_text(GTK_EDITABLE(chat_widget->entry)); // execute dummy XMPP send TODO - printf("Sending to %s:\n> %s\n", recipient, text); + printf("Sending to %s:\n> %s\n", chat->jid, text); //// add message content to the chat //GtkWidget* message = gtk_label_new(text); -- cgit v1.2.3-70-g09d2