diff --git a/meshms.c b/meshms.c index ef8db671..9492d890 100644 --- a/meshms.c +++ b/meshms.c @@ -384,6 +384,51 @@ int app_meshms_list_messages(const struct cli_parsed *parsed, void *context) return 0; } + +int meshms_get_last_ack_offset(const char *left_sid,const char *right_sid) +{ + rhizome_manifest *m_left=NULL; + m_left=meshms_find_or_create_manifestid(left_sid,right_sid,0); + if (!m_left) { + DEBUGF("Couldn't find manifest for thread ply"); + return 0; + } + unsigned char *left_messages=malloc(m_left->fileLength); + if (!left_messages) { + WHYF("malloc(%d) failed while reading meshms logs",m_left->fileLength); + return 0; + } + if (meshms_read_message(m_left,left_messages)) { + DEBUGF("Couldn't read message log for thread ply"); + rhizome_manifest_free(m_left); return 0; + } + + int left_len=m_left->fileLength; + rhizome_manifest_free(m_left); m_left=NULL; + + // Scan through messages and look for acks + int left_ack_limit=0; + int left_offset=0; + for(left_offset=0;left_offset=message_offset) { + INFO("Already acknowledged."); + return 0; + } + // Create serialised ack message for appending to the conversation ply int length_int = 0; unsigned char buffer_serialize[100]; @@ -429,5 +481,7 @@ int app_meshms_ack_messages(const struct cli_parsed *parsed, void *context) ret|=meshms_append_messageblock(sender_sid,recipient_sid, buffer_serialize,length_int); + if (!ret) INFO("Acknowledged."); + return ret; }