Searching through chat with TextSearch

This commit is contained in:
Jaidyn Ann 2021-08-31 22:04:19 -05:00
parent e2d801b84b
commit 3689f6cee3
4 changed files with 31 additions and 3 deletions

View File

@ -62,6 +62,9 @@ const uint32 APP_USER_INFO = 'CYuw';
//! Display a "room info" window
const uint32 APP_ROOM_INFO = 'CYrw';
//! Open the room's logs with TextSearch
const uint32 APP_ROOM_SEARCH = 'CYrs';
//! Toggle a specific flag for a room
const uint32 APP_ROOM_FLAG = 'Rlag';

View File

@ -576,6 +576,10 @@ Conversation::_LogChatMessage(BMessage* msg)
BFile logFile(fCachePath.Path(), B_READ_WRITE | B_OPEN_AT_END | B_CREATE_FILE);
WriteAttributeMessage(&logFile, "Chat:logs", &logMsg);
BString mime = BString("text/plain");
logFile.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0, mime.String(),
mime.CountChars() + 1);
// Plain-text logs
// Gotta make sure the formatting's pretty!
BString date;

View File

@ -76,6 +76,8 @@ public:
void SetFlags(int32 flags);
int32 DisallowedFlags() { return fDisallowedFlags; }
BPath CachePath() { return fCachePath; }
private:
void _WarnUser(BString message);

View File

@ -1,3 +1,4 @@
#include <iostream>
/*
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
@ -16,6 +17,7 @@
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <MenuBar.h>
#include <Roster.h>
#include <ScrollView.h>
#include <TranslationUtils.h>
@ -211,6 +213,21 @@ MainWindow::MessageReceived(BMessage* message)
RoomListWindow::Get(fServer)->Show();
break;
}
case APP_ROOM_SEARCH:
{
if (fConversation != NULL) {
entry_ref ref;
BEntry entry(fConversation->CachePath().Path());
if (entry.GetRef(&ref) != B_OK)
break;
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
BRoster roster;
roster.Launch("application/x-vnd.Haiku.TextSearch", &msg);
}
break;
}
case APP_EDIT_ROSTER:
{
RosterEditWindow::Get(fServer)->Show();
@ -518,15 +535,17 @@ MainWindow::_CreateMenuBar()
BMenu* chatMenu = new BMenu(B_TRANSLATE("Chat"));
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Join room" B_UTF8_ELLIPSIS),
new BMessage(APP_JOIN_ROOM), 'J', B_COMMAND_KEY));
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Room directory" B_UTF8_ELLIPSIS),
new BMessage(APP_ROOM_DIRECTORY)));
chatMenu->SetTargetForItems(this);
chatMenu->AddSeparatorItem();
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("New room" B_UTF8_ELLIPSIS),
new BMessage(APP_NEW_ROOM), 'N', B_COMMAND_KEY));
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("New chat" B_UTF8_ELLIPSIS),
new BMessage(APP_NEW_CHAT), 'M', B_COMMAND_KEY));
chatMenu->AddSeparatorItem();
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Room directory" B_UTF8_ELLIPSIS),
new BMessage(APP_ROOM_DIRECTORY)));
chatMenu->SetTargetForItems(this);
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS),
new BMessage(APP_ROOM_SEARCH), 'F', B_COMMAND_KEY));
// Roster
BMenu* rosterMenu = new BMenu(B_TRANSLATE("Roster"));