diff --git a/application/AppMessages.h b/application/AppMessages.h index 7d2751d..0975e08 100644 --- a/application/AppMessages.h +++ b/application/AppMessages.h @@ -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'; diff --git a/application/Conversation.cpp b/application/Conversation.cpp index 77a19f7..65a5d0f 100644 --- a/application/Conversation.cpp +++ b/application/Conversation.cpp @@ -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; diff --git a/application/Conversation.h b/application/Conversation.h index 28d07c3..f892669 100644 --- a/application/Conversation.h +++ b/application/Conversation.h @@ -76,6 +76,8 @@ public: void SetFlags(int32 flags); int32 DisallowedFlags() { return fDisallowedFlags; } + BPath CachePath() { return fCachePath; } + private: void _WarnUser(BString message); diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index 321861c..ea23963 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -1,3 +1,4 @@ +#include /* * Copyright 2009-2011, Andrea Anzani. All rights reserved. * Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved. @@ -16,6 +17,7 @@ #include #include #include +#include #include #include @@ -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"));