Forwarding messages to ChatWindow

Added stringview as status feedback
This commit is contained in:
urnenfeld 2010-05-28 22:38:16 +00:00
parent ff80897441
commit 3a8af7c9f9
3 changed files with 34 additions and 18 deletions

View File

@ -45,18 +45,21 @@ ChatWindow::ChatWindow(ContactLinker* cl)
fSendView = new BTextView("fReceiveView");
BScrollView* scrollViewSend = new BScrollView("scrollviewS", fSendView,
B_WILL_DRAW, false, true);
B_WILL_DRAW, false, true);
fSendView->SetWordWrap(true);
AddCommonFilter(new EditingFilter(fSendView));
fSendView->MakeFocus(true);
fStatus = new BStringView("status", "");
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(scrollViewReceive, 2)
.Add(scrollViewSend)
.Add(fStatus)
.SetInsets(5, 5, 5, 5)
);
);
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
@ -101,7 +104,7 @@ ChatWindow::MessageReceived(BMessage* message)
default:
BWindow::MessageReceived(message);
break;
}
}
}
@ -115,7 +118,15 @@ ChatWindow::ImMessage(BMessage* msg)
BString message = msg->FindString("body");
fReceiveView->AppendOtherMessage(message.String());
break;
}
}
case IM_CONTACT_STARTED_TYPING:
fStatus->SetText("Buddy is typing ...");
break;
case IM_CONTACT_STOPPED_TYPING:
fStatus->SetText("");
break;
default:
break;
}
@ -143,7 +154,7 @@ void
ChatWindow::ObservePointer(int32 what, void* ptr)
{
switch (what) {
case PTR_AVATAR_BITMAP:
case PTR_AVATAR_BITMAP:
break;
}
}
@ -163,9 +174,9 @@ ChatWindow::ObserveInteger(int32 what, int32 val)
}
void
void
ChatWindow::AppendStatus(CayaStatus status)
{
{
BString message(fContactLinker->GetName());
switch (status) {
@ -180,7 +191,7 @@ ChatWindow::AppendStatus(CayaStatus status)
message << " is busy, please do not disturb!";
break;
case CAYA_OFFLINE:
message << " is offline";
message << " is offline";
break;
default:
break;

View File

@ -4,9 +4,10 @@
*/
#ifndef _CHAT_WINDOW_H
#define _CHAT_WINDOW_H
#include <Window.h>
#include <TextView.h>
#include <StringView.h>
#include "Observer.h"
#include "CayaConstants.h"
@ -30,8 +31,10 @@ public:
private:
BTextView* fSendView;
ContactLinker* fContactLinker;
ContactLinker* fContactLinker;
CayaRenderView* fReceiveView;
BStringView* fStatus;
};
#endif // _CHAT_WINDOW_H

View File

@ -37,7 +37,7 @@ Server::Server()
void
Server::Quit()
{
ContactLinker* linker = NULL;
ContactLinker* linker = NULL;
while ((linker = fRosterMap.ValueAt(0))) {
linker->DeleteWindow();
@ -139,7 +139,7 @@ Server::Filter(BMessage* message, BHandler **target)
ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (found)
item->HideWindow();
item->HideWindow();
}
result = B_SKIP_MESSAGE;
break;
@ -152,7 +152,7 @@ Server::Filter(BMessage* message, BHandler **target)
break;
}
return result;
return result;
}
@ -163,18 +163,18 @@ Server::RosterItems() const
}
RosterItem*
RosterItem*
Server::RosterItemForId(BString id)
{
bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found);
return item ? item->GetRosterItem() : NULL;
return item ? item->GetRosterItem() : NULL;
}
filter_result
Server::ImMessage(BMessage* msg)
{
{
filter_result result = B_DISPATCH_MESSAGE;
int32 im_what = msg->FindInt32("im_what");
@ -274,6 +274,8 @@ Server::ImMessage(BMessage* msg)
break;
}
case IM_MESSAGE_RECEIVED:
case IM_CONTACT_STARTED_TYPING:
case IM_CONTACT_STOPPED_TYPING:
{
BString id = msg->FindString("id");
if (id.Length() > 0) {
@ -296,7 +298,7 @@ Server::ImMessage(BMessage* msg)
}
ContactLinker*
ContactLinker*
Server::GetOwnContact()
{
return fMySelf;
@ -323,7 +325,7 @@ Server::_LooperFromMessage(BMessage* message)
}
ContactLinker*
ContactLinker*
Server::_EnsureContactLinker(BMessage* message)
{
if (!message)