From a9eeaa51fe8bc08bf784ad13115ee0d23f563dc8 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 18 Aug 2021 23:05:57 -0500 Subject: [PATCH] (irc) Default room of #haiku for OFTC --- protocols/irc/IrcProtocol.cpp | 28 +++++++++++++++------------- protocols/irc/IrcProtocol.h | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/protocols/irc/IrcProtocol.cpp b/protocols/irc/IrcProtocol.cpp index 78929e1..c641382 100644 --- a/protocols/irc/IrcProtocol.cpp +++ b/protocols/irc/IrcProtocol.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #undef B_TRANSLATION_CONTEXT @@ -876,6 +877,7 @@ IrcProtocol::_MakeReady(BString nick, BString ident) _SendIrc("MOTD\n"); _LoadContacts(); + _JoinDefaultRooms(); } @@ -1241,25 +1243,25 @@ IrcProtocol::_RoleTitle(UserRole role) const char* -IrcProtocol::_CachePath() +IrcProtocol::_ContactsCache() { - BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) - return NULL; - path.Append(APP_NAME "/Cache/Accounts"); - path.Append(fName); - if (create_directory(path.Path(), 0755) != B_OK) - return NULL; + BPath path(AccountCachePath(fName)); + path.Append("contact_list"); return path.Path(); } -const char* -IrcProtocol::_ContactsCache() +void +IrcProtocol::_JoinDefaultRooms() { - BPath path(_CachePath()); - path.Append("contact_list"); - return path.Path(); + // Hardcoded default room… I'm so awful, aren't I? ;-) + if (fServer == "irc.oftc.net") { + BFile room(RoomCachePath(fName, "#haiku"), B_READ_ONLY); + if (room.InitCheck() != B_OK) { + BString cmd("JOIN #haiku"); + _SendIrc(cmd); + } + } } diff --git a/protocols/irc/IrcProtocol.h b/protocols/irc/IrcProtocol.h index 1efd21b..89139fb 100644 --- a/protocols/irc/IrcProtocol.h +++ b/protocols/irc/IrcProtocol.h @@ -102,8 +102,8 @@ private: int32 _RolePerms(UserRole role); const char* _RoleTitle(UserRole role); - const char* _CachePath(); const char* _ContactsCache(); + void _JoinDefaultRooms(); // Read a data stream until newline found; if data found past // newline, append to given buffer for later use