parent
577cfd1ae0
commit
a4e2b1dc5a
|
@ -55,17 +55,16 @@ enum im_what_code {
|
|||
|
||||
//! Chat message has been sent →Caya
|
||||
// Requires: String "chat_id", String "user_id", String "body"
|
||||
// Accepts: String "subject"
|
||||
IM_MESSAGE_SENT = 21,
|
||||
|
||||
//! Chat message received →Caya
|
||||
// Requires: String "chat_id", String "user_id", String "body"
|
||||
// Accepts: String "subject"
|
||||
IM_MESSAGE_RECEIVED = 22,
|
||||
|
||||
//! Logs received →Caya
|
||||
// Requires: String "chat_id", String "user_id", String "body"
|
||||
// Accepts: String "subject"
|
||||
// Without "when" (a time_t), the logged message will lack a timestamp
|
||||
// Requires: Strings "chat_id", Strings "user_id", Strings "body"
|
||||
// Accepts: in64s "when"
|
||||
IM_LOGS_RECEIVED = 23,
|
||||
|
||||
//! User started typing →Caya
|
||||
|
|
|
@ -342,11 +342,19 @@ Conversation::_LogChatMessage(BMessage* msg)
|
|||
// Binary logs
|
||||
// TODO: Don't hardcode 21, expose maximum as a setting
|
||||
BStringList users, bodies;
|
||||
int64 times[21] = { 0 };
|
||||
times[0] = (int64)time(NULL);
|
||||
|
||||
BMessage logMsg;
|
||||
if (_GetChatLogs(&logMsg) == B_OK) {
|
||||
logMsg.FindStrings("body", &bodies);
|
||||
logMsg.FindStrings("user_id", &users);
|
||||
|
||||
int64 found;
|
||||
for (int i = 0; i < 21; i++)
|
||||
if (logMsg.FindInt64("when", i, &found) == B_OK)
|
||||
times[i + 1] = found;
|
||||
|
||||
bodies.Remove(21);
|
||||
users.Remove(21);
|
||||
bodies.Add(body, 0);
|
||||
|
@ -357,6 +365,9 @@ Conversation::_LogChatMessage(BMessage* msg)
|
|||
newLogMsg.AddInt32("im_what", IM_LOGS_RECEIVED);
|
||||
newLogMsg.AddStrings("body", bodies);
|
||||
newLogMsg.AddStrings("user_id", users);
|
||||
newLogMsg.AddInt64("when", time(NULL));
|
||||
for (int i = 0; i < 21; i++)
|
||||
newLogMsg.AddInt64("when", times[i]);
|
||||
|
||||
BFile logFile(fCachePath.Path(), B_READ_WRITE | B_OPEN_AT_END | B_CREATE_FILE);
|
||||
WriteAttributeMessage(&logFile, "Caya:logs", &newLogMsg);
|
||||
|
@ -382,7 +393,7 @@ Conversation::_GetChatLogs(BMessage* msg)
|
|||
|
||||
BFile logFile(fCachePath.Path(), B_READ_WRITE | B_CREATE_FILE);
|
||||
|
||||
return ReadAttributeMessage(&logFile, "logs", msg);
|
||||
return ReadAttributeMessage(&logFile, "Caya:logs", msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -415,7 +426,6 @@ Conversation::_EnsureCachePath()
|
|||
{
|
||||
if (fCachePath.InitCheck() == B_OK)
|
||||
return;
|
||||
|
||||
fCachePath.SetTo(CayaRoomCachePath(fLooper->Protocol()->GetName(),
|
||||
fID.String()));
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ CayaRenderView::CayaRenderView(const char *name, const char* smileyConfig)
|
|||
|
||||
void
|
||||
CayaRenderView::AppendMessage(const char* nick, const char* message,
|
||||
rgb_color nameColor)
|
||||
rgb_color nameColor, time_t time)
|
||||
{
|
||||
rgb_color bg = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
rgb_color fg = ui_color(B_PANEL_TEXT_COLOR);
|
||||
|
||||
Append("<", nameColor, bg, nameColor, time(NULL));
|
||||
Append("<", nameColor, bg, nameColor, time);
|
||||
Append(nick, fg, bg, fg);
|
||||
Append("> ", nameColor, bg, nameColor);
|
||||
// AddEmoticText(message, fg, bg);
|
||||
|
|
|
@ -37,7 +37,8 @@ class CayaRenderView : public RunView
|
|||
public:
|
||||
CayaRenderView(const char* name, const char* smileyConfig = NULL);
|
||||
|
||||
void AppendMessage(const char* nick, const char* message, rgb_color nameColor);
|
||||
void AppendMessage(const char* nick, const char* message,
|
||||
rgb_color nameColor, time_t time = 0);
|
||||
void AppendGenericMessage(const char* message);
|
||||
void AddEmoticText(const char * txt, rgb_color fore, rgb_color bg);
|
||||
|
||||
|
|
|
@ -316,6 +316,10 @@ ConversationView::_AppendMessage(BMessage* msg)
|
|||
BString sender_name = users.StringAt(i);
|
||||
BString body = bodies.StringAt(i);
|
||||
rgb_color userColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||
int64 timeInt;
|
||||
|
||||
if (msg->FindInt64("when", i, &timeInt) != B_OK)
|
||||
timeInt = (int64)time(NULL);
|
||||
|
||||
if (sender != NULL) {
|
||||
sender_name = sender->GetName();
|
||||
|
@ -327,7 +331,8 @@ ConversationView::_AppendMessage(BMessage* msg)
|
|||
continue;
|
||||
}
|
||||
|
||||
fReceiveView->AppendMessage(sender_name.String(), body.String(), userColor);
|
||||
fReceiveView->AppendMessage(sender_name.String(), body.String(),
|
||||
userColor, (time_t)timeInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue