Modified ContactLinker : moved some inline methods from class declaration, added Get* methods for contact status and status message. Added code in the ChatWindow to show the current avatar of the user. Modified the Server to allow a plugin set the status message when sending a IM_CONTACT_INFO notification to the server, as before it's already possible to do it using a IM_STATUS_SET message.
This commit is contained in:
parent
8d04f539c2
commit
c22310f510
|
@ -22,6 +22,7 @@
|
|||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "BitmapView.h"
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "ChatWindow.h"
|
||||
|
@ -50,15 +51,30 @@ 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));
|
||||
*/
|
||||
|
||||
fStatus = new BStringView("status", "");
|
||||
fStatus->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
|
||||
fAvatar = new BitmapView("ContactIcon");
|
||||
fAvatar->SetExplicitMaxSize(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)
|
||||
.Add(scrollViewReceive, 2)
|
||||
.Add(scrollViewSend)
|
||||
.Add(fStatus)
|
||||
.Add(fStatus, 3)
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
);
|
||||
|
||||
|
@ -78,6 +94,13 @@ ChatWindow::QuitRequested()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
ChatWindow::UpdateAvatar()
|
||||
{
|
||||
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChatWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "CayaConstants.h"
|
||||
|
||||
class BitmapView;
|
||||
class ContactLinker;
|
||||
class CayaRenderView;
|
||||
|
||||
|
@ -22,6 +23,7 @@ public:
|
|||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
void UpdateAvatar();
|
||||
void ImMessage(BMessage* msg);
|
||||
|
||||
void ObserveString(int32 what, BString str);
|
||||
|
@ -34,6 +36,7 @@ private:
|
|||
ContactLinker* fContactLinker;
|
||||
CayaRenderView* fReceiveView;
|
||||
BStringView* fStatus;
|
||||
BitmapView* fAvatar;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -119,6 +119,20 @@ ContactLinker::DeletePopUp()
|
|||
}
|
||||
|
||||
|
||||
RosterItem*
|
||||
ContactLinker::GetRosterItem() const
|
||||
{
|
||||
return fRosterItem;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetId() const
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
|
||||
BMessenger
|
||||
ContactLinker::Messenger() const
|
||||
{
|
||||
|
@ -140,6 +154,34 @@ ContactLinker::GetProtocolLooper() const
|
|||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
ContactLinker::AvatarBitmap() const
|
||||
{
|
||||
return fAvatarBitmap;
|
||||
}
|
||||
|
||||
|
||||
CayaStatus
|
||||
ContactLinker::GetNotifyStatus() const
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetNotifyPersonalStatus() const
|
||||
{
|
||||
return fPersonalStatus;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
|
||||
{
|
||||
|
@ -171,6 +213,8 @@ ContactLinker::SetNotifyAvatarBitmap(BBitmap* bitmap)
|
|||
if ((fAvatarBitmap != bitmap) && (bitmap != NULL)) {
|
||||
fAvatarBitmap = bitmap;
|
||||
NotifyPointer(PTR_AVATAR_BITMAP, (void*)bitmap);
|
||||
if (fChatWindow != NULL)
|
||||
fChatWindow->UpdateAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ public:
|
|||
void DeletePopUp();
|
||||
void HidePopUp();
|
||||
|
||||
RosterItem* GetRosterItem() { return fRosterItem; }
|
||||
RosterItem* GetRosterItem() const;
|
||||
|
||||
BString GetId() { return fID; }
|
||||
BString GetId() const;
|
||||
|
||||
BMessenger Messenger() const;
|
||||
void SetMessenger(BMessenger messenger);
|
||||
|
@ -43,8 +43,10 @@ public:
|
|||
ProtocolLooper* GetProtocolLooper() const;
|
||||
void SetProtocolLooper(ProtocolLooper* looper);
|
||||
|
||||
BString GetName() { return fName; }
|
||||
BBitmap* AvatarBitmap() { return fAvatarBitmap; }
|
||||
BString GetName() const;
|
||||
BBitmap* AvatarBitmap() const;
|
||||
CayaStatus GetNotifyStatus() const;
|
||||
BString GetNotifyPersonalStatus() const;
|
||||
|
||||
void SetNotifyName(BString name);
|
||||
void SetNotifyAvatarBitmap(BBitmap* bitmap);
|
||||
|
|
|
@ -262,6 +262,11 @@ Server::ImMessage(BMessage* msg)
|
|||
if ((msg->FindString("name", &name) == B_OK)
|
||||
&& (strcmp(name, "") != 0))
|
||||
linker->SetNotifyName(name);
|
||||
|
||||
BString status;
|
||||
if (msg->FindString("message", &status) == B_OK)
|
||||
linker->SetNotifyPersonalStatus(status);
|
||||
|
||||
break;
|
||||
}
|
||||
case IM_EXTENDED_CONTACT_INFO:
|
||||
|
|
Ŝarĝante…
Reference in New Issue