Fix message-passing to roster window

This commit is contained in:
Jaidyn Ann 2021-05-30 17:12:41 -05:00
parent 5dbcfc1a52
commit 3e202e3609
3 changed files with 20 additions and 4 deletions

View File

@ -38,7 +38,8 @@ const uint32 kLogin = 'LOGI';
MainWindow::MainWindow()
:
BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
fWorkspaceChanged(false)
fWorkspaceChanged(false),
fRosterWindow(NULL)
{
_InitInterface();
@ -103,9 +104,9 @@ MainWindow::MessageReceived(BMessage* message)
case CAYA_NEW_CHAT:
{
RosterWindow* roster = new RosterWindow("Invite contact to chat"
fRosterWindow = new RosterWindow("Invite contact to chat"
B_UTF8_ELLIPSIS, IM_CREATE_CHAT, new BMessenger(this), fServer);
roster->Show();
fRosterWindow->Show();
break;
}
@ -191,6 +192,15 @@ MainWindow::ImMessage(BMessage* msg)
_EnsureConversationItem(msg);
break;
}
case IM_AVATAR_SET:
case IM_CONTACT_INFO:
case IM_EXTENDED_CONTACT_INFO:
case IM_STATUS_SET:
{
if (fRosterWindow != NULL)
fRosterWindow->PostMessage(msg);
break;
}
}
}
@ -310,7 +320,7 @@ MainWindow::_CreateMenuBar()
BMenu* chatMenu = new BMenu("Chat");
chatMenu->AddItem(new BMenuItem("New chat" B_UTF8_ELLIPSIS,
new BMessage(CAYA_NEW_CHAT)));
new BMessage(CAYA_NEW_CHAT), 'M', B_COMMAND_KEY));
chatMenu->SetTargetForItems(this);
menuBar->AddItem(programMenu);

View File

@ -18,6 +18,7 @@ class ConversationItem;
class ConversationListView;
class ConversationView;
class RosterItem;
class RosterWindow;
class Server;
class StatusView;
@ -51,6 +52,7 @@ private:
void _UpdateListItem(ConversationItem* item);
Server* fServer;
RosterWindow* fRosterWindow;
bool fWorkspaceChanged;
// Left panel, chat list

View File

@ -110,6 +110,10 @@ RosterWindow::MessageReceived(BMessage* message)
break;
}
case IM_MESSAGE:
ImMessage(message);
break;
default:
BWindow::MessageReceived(message);
}