dd298281e2
The new Notifier→Observer relation chain: * Conversation → ConversationItem, ConversationView * User → UserListItem, UserInfoWindow, UserPopUp * Contact → RosterItem These line up pretty intuitively― if something changes in the conversation, you want the list item and view to change too. But there's one more here that's less intuitive: * User → Conversation If Conversation observes something from a user (i.e., status change), it immediately knows to do one thing only: invalidate the user list, because something's changed.
72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
/*
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _CHAT_VIEW_H
|
|
#define _CHAT_VIEW_H
|
|
|
|
#include <GroupView.h>
|
|
#include <ObjectList.h>
|
|
|
|
#include "CayaConstants.h"
|
|
#include "Conversation.h"
|
|
#include "Observer.h"
|
|
|
|
class BStringView;
|
|
class BTextView;
|
|
|
|
class BitmapView;
|
|
class CayaRenderView;
|
|
class User;
|
|
class UserListView;
|
|
|
|
|
|
class ConversationView : public BGroupView, public Observer {
|
|
public:
|
|
ConversationView();
|
|
ConversationView(Conversation* chat);
|
|
|
|
virtual bool QuitRequested();
|
|
virtual void AttachedToWindow();
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
|
void ImMessage(BMessage* msg);
|
|
|
|
Conversation* GetConversation();
|
|
void SetConversation(Conversation* chat);
|
|
|
|
void UpdateAvatar();
|
|
void UpdatePersonalMessage();
|
|
|
|
void UpdateUserList(UserMap users);
|
|
void InvalidateUserList();
|
|
|
|
void ObserveString(int32 what, BString str);
|
|
void ObservePointer(int32 what, void* ptr);
|
|
void ObserveInteger(int32 what, int32 val);
|
|
|
|
void AvoidFocus(bool avoid);
|
|
|
|
private:
|
|
void _InitInterface();
|
|
|
|
bool _AppendOrEnqueueMessage(BMessage* msg);
|
|
void _AppendMessage(BMessage* msg);
|
|
|
|
Conversation* fConversation;
|
|
User* fContact;
|
|
int32 fMessageCount;
|
|
BObjectList<BMessage> fMessageQueue;
|
|
|
|
CayaRenderView* fReceiveView;
|
|
BStringView* fStatus;
|
|
BTextView* fPersonalMessage;
|
|
BitmapView* fProtocolView;
|
|
BitmapView* fAvatar;
|
|
UserListView* fUserList;
|
|
};
|
|
|
|
|
|
#endif // _CHAT_VIEW_H
|
|
|