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