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 "Conversation.h"
|
||||
#include "NotifyMessage.h"
|
||||
#include "ProtocolManager.h"
|
||||
#include "RenderView.h"
|
||||
#include "SendTextView.h"
|
||||
#include "User.h"
|
||||
|
@ -36,28 +37,19 @@
|
|||
#define B_TRANSLATION_CONTEXT "ConversationView"
|
||||
|
||||
|
||||
ConversationView::ConversationView()
|
||||
ConversationView::ConversationView(Conversation* chat)
|
||||
:
|
||||
BGroupView("chatView", B_VERTICAL, B_USE_DEFAULT_SPACING),
|
||||
fMessageQueue(),
|
||||
fConversation(NULL)
|
||||
fConversation(chat)
|
||||
{
|
||||
_InitInterface();
|
||||
fSendView->MakeFocus(true);
|
||||
}
|
||||
|
||||
|
||||
ConversationView::ConversationView(Conversation* chat)
|
||||
:
|
||||
#if defined(__i386__) && !defined(__x86_64__)
|
||||
BGroupView("chatView", B_VERTICAL, B_USE_DEFAULT_SPACING),
|
||||
fMessageQueue()
|
||||
#else
|
||||
ConversationView()
|
||||
#endif
|
||||
{
|
||||
if (chat != NULL) {
|
||||
SetConversation(chat);
|
||||
fUserList->SetConversation(chat);
|
||||
}
|
||||
else
|
||||
_FakeChat();
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,8 +57,10 @@ bool
|
|||
ConversationView::QuitRequested()
|
||||
{
|
||||
BMessage msg(APP_CLOSE_CHAT_WINDOW);
|
||||
if (fConversation != NULL) {
|
||||
msg.AddString("chat_id", fConversation->GetId());
|
||||
fConversation->Messenger().SendMessage(&msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -96,7 +90,7 @@ ConversationView::MessageReceived(BMessage* message)
|
|||
case APP_CHAT:
|
||||
{
|
||||
BString text = fSendView->Text();
|
||||
if (text == "")
|
||||
if (fConversation == NULL || text == "")
|
||||
return;
|
||||
int64 instance = fConversation->GetProtocolLooper()->GetInstance();
|
||||
|
||||
|
@ -191,6 +185,11 @@ ConversationView::ImMessage(BMessage* msg)
|
|||
msg);
|
||||
break;
|
||||
}
|
||||
case IM_PROTOCOL_READY:
|
||||
{
|
||||
fReceiveView->SetText("");
|
||||
_FakeChatNoRooms();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -219,7 +218,7 @@ ConversationView::SetConversation(Conversation* chat)
|
|||
void
|
||||
ConversationView::UpdateIcon()
|
||||
{
|
||||
if (fConversation->IconBitmap() != NULL)
|
||||
if (fConversation != NULL && fConversation->IconBitmap() != NULL)
|
||||
fIcon->SetBitmap(fConversation->IconBitmap());
|
||||
}
|
||||
|
||||
|
@ -340,7 +339,9 @@ ConversationView::_AppendMessage(BMessage* msg)
|
|||
msg->FindStrings("user_id", &users);
|
||||
|
||||
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 body = bodies.StringAt(i);
|
||||
rgb_color userColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||
|
@ -393,3 +394,58 @@ ConversationView::_UserMessage(const char* format, const char* bodyFormat,
|
|||
_AppendOrEnqueueMessage(&newMsg);
|
||||
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 {
|
||||
public:
|
||||
ConversationView();
|
||||
ConversationView(Conversation* chat);
|
||||
ConversationView(Conversation* chat = NULL);
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void AttachedToWindow();
|
||||
|
@ -54,6 +53,11 @@ private:
|
|||
void _UserMessage(const char* format, const char* bodyFormat,
|
||||
BMessage* msg);
|
||||
|
||||
// When the user hasn't joined any real conversations
|
||||
void _FakeChat();
|
||||
void _FakeChatNoRooms();
|
||||
void _FakeChatNoAccounts();
|
||||
|
||||
Conversation* fConversation;
|
||||
BObjectList<BMessage> fMessageQueue;
|
||||
|
||||
|
|
|
@ -270,17 +270,20 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
case IM_STATUS_SET:
|
||||
case IM_CONTACT_INFO:
|
||||
case IM_EXTENDED_CONTACT_INFO:
|
||||
case IM_CONTACT_LIST_CONTACT_REMOVED:
|
||||
case IM_CONTACT_LIST_CONTACT_REMOVED: {
|
||||
if (fRosterWindow != NULL)
|
||||
fRosterWindow->PostMessage(msg);
|
||||
if (RosterEditWindow::Check() == true)
|
||||
RosterEditWindow::Get(fServer)->PostMessage(msg);
|
||||
break;
|
||||
|
||||
case IM_PROTOCOL_READY:
|
||||
}
|
||||
case IM_PROTOCOL_READY: {
|
||||
if (fConversation == NULL)
|
||||
fChatView->MessageReceived(msg);
|
||||
_ToggleMenuItems();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue