Log message recieve times

This commit is contained in:
Jaidyn Ann 2021-05-24 14:48:25 -05:00
parent 385bfbff35
commit cba947475c
2 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,9 @@
#include "Conversation.h" #include "Conversation.h"
#include <DateTimeFormat.h>
#include <Locale.h>
#include "CayaPreferences.h" #include "CayaPreferences.h"
#include "CayaProtocolMessages.h" #include "CayaProtocolMessages.h"
#include "CayaUtils.h" #include "CayaUtils.h"
@ -24,7 +27,8 @@ Conversation::Conversation(BString id, BMessenger msgn)
fMessenger(msgn), fMessenger(msgn),
fChatWindow(NULL), fChatWindow(NULL),
fNewWindow(true), fNewWindow(true),
fLooper(NULL) fLooper(NULL),
fDateFormatter()
{ {
} }
@ -215,11 +219,15 @@ Conversation::_CreateChatWindow()
} }
#include <iostream>
void void
Conversation::_LogChatMessage(BMessage* msg) Conversation::_LogChatMessage(BMessage* msg)
{ {
_EnsureLogPath(); _EnsureLogPath();
BString date;
fDateFormatter.Format(date, time(0), B_SHORT_DATE_FORMAT, B_MEDIUM_TIME_FORMAT);
BString id = msg->FindString("user_id"); BString id = msg->FindString("user_id");
BString uname; BString uname;
@ -228,7 +236,11 @@ Conversation::_LogChatMessage(BMessage* msg)
else else
uname = "You"; uname = "You";
BString logLine = uname;
BString logLine("[");
logLine << date;
logLine << "] ";
logLine << uname;
logLine << ": "; logLine << ": ";
logLine << msg->FindString("body"); logLine << msg->FindString("body");
logLine << "\n"; logLine << "\n";

View File

@ -5,6 +5,7 @@
#ifndef CONVERSATION_H #ifndef CONVERSATION_H
#define CONVERSATION_H #define CONVERSATION_H
#include <DateTimeFormat.h>
#include <Messenger.h> #include <Messenger.h>
#include <Path.h> #include <Path.h>
@ -71,6 +72,7 @@ private:
BString fName; BString fName;
BPath fLogPath; BPath fLogPath;
BDateTimeFormat fDateFormatter;
UserMap fUsers; UserMap fUsers;
}; };