Add 'Create Account' message for first-time start-up
This commit is contained in:
parent
c339587b06
commit
924f628c75
|
@ -24,6 +24,7 @@
|
||||||
#include "ChatProtocolMessages.h"
|
#include "ChatProtocolMessages.h"
|
||||||
#include "Conversation.h"
|
#include "Conversation.h"
|
||||||
#include "NotifyMessage.h"
|
#include "NotifyMessage.h"
|
||||||
|
#include "ProtocolManager.h"
|
||||||
#include "RenderView.h"
|
#include "RenderView.h"
|
||||||
#include "SendTextView.h"
|
#include "SendTextView.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
|
@ -36,37 +37,30 @@
|
||||||
#define B_TRANSLATION_CONTEXT "ConversationView"
|
#define B_TRANSLATION_CONTEXT "ConversationView"
|
||||||
|
|
||||||
|
|
||||||
ConversationView::ConversationView()
|
ConversationView::ConversationView(Conversation* chat)
|
||||||
:
|
:
|
||||||
BGroupView("chatView", B_VERTICAL, B_USE_DEFAULT_SPACING),
|
BGroupView("chatView", B_VERTICAL, B_USE_DEFAULT_SPACING),
|
||||||
fMessageQueue(),
|
fMessageQueue(),
|
||||||
fConversation(NULL)
|
fConversation(chat)
|
||||||
{
|
{
|
||||||
_InitInterface();
|
_InitInterface();
|
||||||
fSendView->MakeFocus(true);
|
if (chat != NULL) {
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ConversationView::ConversationView(Conversation* chat)
|
|
||||||
:
|
|
||||||
#if defined(__i386__) && !defined(__x86_64__)
|
|
||||||
BGroupView("chatView", B_VERTICAL, B_USE_DEFAULT_SPACING),
|
|
||||||
fMessageQueue()
|
|
||||||
#else
|
|
||||||
ConversationView()
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
SetConversation(chat);
|
SetConversation(chat);
|
||||||
fUserList->SetConversation(chat);
|
fUserList->SetConversation(chat);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
_FakeChat();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConversationView::QuitRequested()
|
ConversationView::QuitRequested()
|
||||||
{
|
{
|
||||||
BMessage msg(APP_CLOSE_CHAT_WINDOW);
|
BMessage msg(APP_CLOSE_CHAT_WINDOW);
|
||||||
|
if (fConversation != NULL) {
|
||||||
msg.AddString("chat_id", fConversation->GetId());
|
msg.AddString("chat_id", fConversation->GetId());
|
||||||
fConversation->Messenger().SendMessage(&msg);
|
fConversation->Messenger().SendMessage(&msg);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +90,7 @@ ConversationView::MessageReceived(BMessage* message)
|
||||||
case APP_CHAT:
|
case APP_CHAT:
|
||||||
{
|
{
|
||||||
BString text = fSendView->Text();
|
BString text = fSendView->Text();
|
||||||
if (text == "")
|
if (fConversation == NULL || text == "")
|
||||||
return;
|
return;
|
||||||
int64 instance = fConversation->GetProtocolLooper()->GetInstance();
|
int64 instance = fConversation->GetProtocolLooper()->GetInstance();
|
||||||
|
|
||||||
|
@ -191,6 +185,11 @@ ConversationView::ImMessage(BMessage* msg)
|
||||||
msg);
|
msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case IM_PROTOCOL_READY:
|
||||||
|
{
|
||||||
|
fReceiveView->SetText("");
|
||||||
|
_FakeChatNoRooms();
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +218,7 @@ ConversationView::SetConversation(Conversation* chat)
|
||||||
void
|
void
|
||||||
ConversationView::UpdateIcon()
|
ConversationView::UpdateIcon()
|
||||||
{
|
{
|
||||||
if (fConversation->IconBitmap() != NULL)
|
if (fConversation != NULL && fConversation->IconBitmap() != NULL)
|
||||||
fIcon->SetBitmap(fConversation->IconBitmap());
|
fIcon->SetBitmap(fConversation->IconBitmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +339,9 @@ ConversationView::_AppendMessage(BMessage* msg)
|
||||||
msg->FindStrings("user_id", &users);
|
msg->FindStrings("user_id", &users);
|
||||||
|
|
||||||
for (int i = bodies.CountStrings(); i >= 0; i--) {
|
for (int i = bodies.CountStrings(); i >= 0; i--) {
|
||||||
User* sender = fConversation->UserById(users.StringAt(i));
|
User* sender = NULL;
|
||||||
|
if (fConversation != NULL)
|
||||||
|
sender = fConversation->UserById(users.StringAt(i));
|
||||||
BString sender_name = users.StringAt(i);
|
BString sender_name = users.StringAt(i);
|
||||||
BString body = bodies.StringAt(i);
|
BString body = bodies.StringAt(i);
|
||||||
rgb_color userColor = ui_color(B_PANEL_TEXT_COLOR);
|
rgb_color userColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||||
|
@ -393,3 +394,58 @@ ConversationView::_UserMessage(const char* format, const char* bodyFormat,
|
||||||
_AppendOrEnqueueMessage(&newMsg);
|
_AppendOrEnqueueMessage(&newMsg);
|
||||||
fReceiveView->ScrollToBottom();
|
fReceiveView->ScrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "ConversationView ― Startup messages"
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationView::_FakeChat()
|
||||||
|
{
|
||||||
|
if (ProtocolManager::Get()->CountProtocolInstances() <= 0)
|
||||||
|
_FakeChatNoAccounts();
|
||||||
|
else
|
||||||
|
_FakeChatNoRooms();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationView::_FakeChatNoRooms()
|
||||||
|
{
|
||||||
|
fNameTextView->SetText(B_TRANSLATE("Cardie"));
|
||||||
|
fSubjectTextView->SetText(B_TRANSLATE("No current rooms or chats."));
|
||||||
|
|
||||||
|
BMessage welcome(IM_MESSAGE);
|
||||||
|
welcome.AddInt32("im_what", IM_MESSAGE_RECEIVED);
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("You know, only if you want. I'm not trying to be pushy."));
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("You can join or create one through the Chat menu.. :-)"));
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("You aren't in any rooms or chats right now."));
|
||||||
|
_AppendOrEnqueueMessage(&welcome);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationView::_FakeChatNoAccounts()
|
||||||
|
{
|
||||||
|
fNameTextView->SetText(B_TRANSLATE("Cardie setup"));
|
||||||
|
fSubjectTextView->SetText(B_TRANSLATE("No accounts configured, no joy."));
|
||||||
|
|
||||||
|
BMessage welcome(IM_MESSAGE);
|
||||||
|
welcome.AddInt32("im_what", IM_MESSAGE_RECEIVED);
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("Afterward, you can join a room or start a chat through the Chat menu. :-)"));
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("Add an account through the [Program→Preferences] menu to get started."));
|
||||||
|
|
||||||
|
welcome.AddString("user_id", B_TRANSLATE("Master Foo"));
|
||||||
|
welcome.AddString("body", B_TRANSLATE("It looks like you don't have any accounts set up."));
|
||||||
|
_AppendOrEnqueueMessage(&welcome);
|
||||||
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ class UserListView;
|
||||||
|
|
||||||
class ConversationView : public BGroupView, public Observer, public Notifier {
|
class ConversationView : public BGroupView, public Observer, public Notifier {
|
||||||
public:
|
public:
|
||||||
ConversationView();
|
ConversationView(Conversation* chat = NULL);
|
||||||
ConversationView(Conversation* chat);
|
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
@ -54,6 +53,11 @@ private:
|
||||||
void _UserMessage(const char* format, const char* bodyFormat,
|
void _UserMessage(const char* format, const char* bodyFormat,
|
||||||
BMessage* msg);
|
BMessage* msg);
|
||||||
|
|
||||||
|
// When the user hasn't joined any real conversations
|
||||||
|
void _FakeChat();
|
||||||
|
void _FakeChatNoRooms();
|
||||||
|
void _FakeChatNoAccounts();
|
||||||
|
|
||||||
Conversation* fConversation;
|
Conversation* fConversation;
|
||||||
BObjectList<BMessage> fMessageQueue;
|
BObjectList<BMessage> fMessageQueue;
|
||||||
|
|
||||||
|
|
|
@ -270,18 +270,21 @@ MainWindow::ImMessage(BMessage* msg)
|
||||||
case IM_STATUS_SET:
|
case IM_STATUS_SET:
|
||||||
case IM_CONTACT_INFO:
|
case IM_CONTACT_INFO:
|
||||||
case IM_EXTENDED_CONTACT_INFO:
|
case IM_EXTENDED_CONTACT_INFO:
|
||||||
case IM_CONTACT_LIST_CONTACT_REMOVED:
|
case IM_CONTACT_LIST_CONTACT_REMOVED: {
|
||||||
if (fRosterWindow != NULL)
|
if (fRosterWindow != NULL)
|
||||||
fRosterWindow->PostMessage(msg);
|
fRosterWindow->PostMessage(msg);
|
||||||
if (RosterEditWindow::Check() == true)
|
if (RosterEditWindow::Check() == true)
|
||||||
RosterEditWindow::Get(fServer)->PostMessage(msg);
|
RosterEditWindow::Get(fServer)->PostMessage(msg);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IM_PROTOCOL_READY:
|
case IM_PROTOCOL_READY: {
|
||||||
|
if (fConversation == NULL)
|
||||||
|
fChatView->MessageReceived(msg);
|
||||||
_ToggleMenuItems();
|
_ToggleMenuItems();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Ŝarĝante…
Reference in New Issue