From f560943e6f6ddb52446e1c514ae44f017944801b Mon Sep 17 00:00:00 2001 From: plfiorini Date: Sun, 30 May 2010 08:51:19 +0000 Subject: [PATCH] Handle IM_OWN_AVATAR_SET. There's only one little problem that will probably be solved after Alpha1: if you have multiple accounts, all of them will set the avatar icon and the user will see just the last icon set. --- application/MainWindow.cpp | 8 +++++--- application/views/StatusView.cpp | 11 ++++++----- application/views/StatusView.h | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 9018285..136b755 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -199,13 +199,15 @@ MainWindow::ImMessage(BMessage* msg) int32 im_what = msg->FindInt32("im_what"); switch (im_what) { case IM_OWN_CONTACT_INFO: - { fStatusView->SetName(msg->FindString("name")); - + break; + case IM_OWN_AVATAR_SET: + { entry_ref ref; + if (msg->FindRef("ref", &ref) == B_OK) { BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref); - fStatusView->SetAvatar(bitmap); + fStatusView->SetAvatarIcon(bitmap); } break; } diff --git a/application/views/StatusView.cpp b/application/views/StatusView.cpp index e75cb81..738268d 100644 --- a/application/views/StatusView.cpp +++ b/application/views/StatusView.cpp @@ -28,10 +28,11 @@ const int32 kSetNickname = 'stnk'; StatusView::StatusView(const char* name) - : BView(name, B_WILL_DRAW) + : + BView(name, B_WILL_DRAW) { // Nick name - fNickname = new NicknameTextControl("nickname", new BMessage(kSetNickname)); + fNickname = new NicknameTextControl("Nickname", new BMessage(kSetNickname)); // Status menu fStatusMenu = new BPopUpMenu("-"); @@ -58,11 +59,11 @@ StatusView::StatusView(const char* name) } // Menu field - BMenuField* statusField = new BMenuField("statusField", NULL, + BMenuField* statusField = new BMenuField("StatusField", NULL, fStatusMenu, NULL); // Icon - fAvatar = new BitmapView("icon"); + fAvatar = new BitmapView("AvatarIcon"); fAvatar->SetExplicitMaxSize(BSize(50, 50)); fAvatar->SetExplicitPreferredSize(BSize(50, 50)); @@ -134,7 +135,7 @@ StatusView::SetStatus(CayaStatus status) void -StatusView::SetAvatar(BBitmap* bitmap) +StatusView::SetAvatarIcon(BBitmap* bitmap) { fAvatar->SetBitmap(bitmap); } diff --git a/application/views/StatusView.h b/application/views/StatusView.h index 1db2c6a..d90d37e 100644 --- a/application/views/StatusView.h +++ b/application/views/StatusView.h @@ -23,7 +23,7 @@ public: void SetName(BString name); void SetStatus(CayaStatus status); - void SetAvatar(BBitmap* bitmap); + void SetAvatarIcon(BBitmap* bitmap); private: BPopUpMenu* fStatusMenu;