The personal message of a contact is now show in the chat window, added also the needed code in Server.cpp to update the windows. Solved a bug with the contact avatar that was causing Caya to crash.

This commit is contained in:
barrett 2012-03-08 00:47:00 +00:00
parent c22310f510
commit 3f2f2783ff
3 changed files with 37 additions and 13 deletions

View File

@ -51,12 +51,14 @@ ChatWindow::ChatWindow(ContactLinker* cl)
AddCommonFilter(new EditingFilter(fSendView));
fSendView->MakeFocus(true);
/*
BStringView* personalMessage = new BStringView("personalMessage", "");
personalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
personalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
personalMessage->SetExplicitMaxSize(BSize(200, 200));
*/
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
fPersonalMessage->SetExplicitMaxSize(BSize(400, 200));
fPersonalMessage->MakeEditable(false);
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fStatus = new BStringView("status", "");
fStatus->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
@ -65,13 +67,16 @@ ChatWindow::ChatWindow(ContactLinker* cl)
fAvatar = new BitmapView("ContactIcon");
fAvatar->SetExplicitMaxSize(BSize(50, 50));
fAvatar->SetExplicitMinSize(BSize(50, 50));
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
// .Add(personalMessage)
.Add(fAvatar, 1)
.AddGroup(B_HORIZONTAL)
.Add(fPersonalMessage)
.Add(fAvatar)
.End()
.Add(scrollViewReceive, 2)
.Add(scrollViewSend)
.Add(fStatus, 3)
@ -97,7 +102,20 @@ ChatWindow::QuitRequested()
void
ChatWindow::UpdateAvatar()
{
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
if (fContactLinker->AvatarBitmap() != NULL)
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
}
void
ChatWindow::UpdatePersonalMessage()
{
if (fContactLinker->GetNotifyPersonalStatus() != NULL) {
LockLooper();
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
UnlockLooper();
}
}

View File

@ -24,6 +24,7 @@ public:
virtual bool QuitRequested();
void UpdateAvatar();
void UpdatePersonalMessage();
void ImMessage(BMessage* msg);
void ObserveString(int32 what, BString str);
@ -36,6 +37,7 @@ private:
ContactLinker* fContactLinker;
CayaRenderView* fReceiveView;
BStringView* fStatus;
BTextView* fPersonalMessage;
BitmapView* fAvatar;
};

View File

@ -247,8 +247,11 @@ Server::ImMessage(BMessage* msg)
break;
linker->SetNotifyStatus((CayaStatus)status);
linker->SetNotifyPersonalStatus(msg->FindString("message"));
BString statusMsg;
if (msg->FindString("message", &statusMsg) == B_OK) {
linker->SetNotifyPersonalStatus(statusMsg);
linker->GetChatWindow()->UpdatePersonalMessage();
}
break;
}
case IM_CONTACT_INFO:
@ -264,9 +267,10 @@ Server::ImMessage(BMessage* msg)
linker->SetNotifyName(name);
BString status;
if (msg->FindString("message", &status) == B_OK)
if (msg->FindString("message", &status) == B_OK) {
linker->SetNotifyPersonalStatus(status);
linker->GetChatWindow()->UpdatePersonalMessage();
}
break;
}
case IM_EXTENDED_CONTACT_INFO: