Chat-O-Matic/application/views/InviteDialogue.cpp

64 lines
1.1 KiB
C++
Raw Normal View History

/*
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "InviteDialogue.h"
2021-07-19 09:54:27 -05:00
#include <Catalog.h>
#include <Messenger.h>
2021-07-19 09:54:27 -05:00
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "InviteDialogue"
InviteDialogue::InviteDialogue(BMessenger target, const char* title,
const char* body, BMessage* acceptMsg, BMessage* rejectMsg, BBitmap* icon)
:
2021-07-19 09:54:27 -05:00
BAlert(title, body, B_TRANSLATE("Cancel"), B_TRANSLATE("Reject"),
B_TRANSLATE("Accept"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING),
fMessenger(target),
fAcceptMsg(acceptMsg),
fRejectMsg(rejectMsg)
{
if (icon != NULL)
SetIcon(icon);
}
void
InviteDialogue::MessageReceived(BMessage* msg)
{
int32 which;
if (msg->FindInt32("which", &which) != B_OK) {
BAlert::MessageReceived(msg);
return;
}
switch (which)
{
case 0:
break;
case 1:
fMessenger.SendMessage(fRejectMsg);
break;
case 2:
fMessenger.SendMessage(fAcceptMsg);
break;
default:
return;
}
PostMessage(B_QUIT_REQUESTED);
}
status_t
InviteDialogue::Go()
{
return BAlert::Go(NULL);
}