Remove own user from contacts; fix roster bitmaps
It doesn't make sense to lump the user themself with their contacts list― their Contact object is now stored seperately. BBitmap loading for RosterItems are fixed, as well. Fixes #33
This commit is contained in:
parent
f0f2375b09
commit
52a580e03d
|
@ -332,10 +332,10 @@ Conversation::RemoveUser(User* user)
|
|||
}
|
||||
|
||||
|
||||
BString
|
||||
Conversation::GetOwnId()
|
||||
Contact*
|
||||
Conversation::GetOwnContact()
|
||||
{
|
||||
return fLooper->GetOwnId();
|
||||
return fLooper->GetOwnContact();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
UserMap Users();
|
||||
User* UserById(BString id);
|
||||
BString GetOwnId();
|
||||
Contact* GetOwnContact();
|
||||
|
||||
void AddUser(User* user);
|
||||
void RemoveUser(User* user);
|
||||
|
|
|
@ -167,17 +167,17 @@ ProtocolLooper::CommandById(BString id)
|
|||
}
|
||||
|
||||
|
||||
BString
|
||||
ProtocolLooper::GetOwnId()
|
||||
Contact*
|
||||
ProtocolLooper::GetOwnContact()
|
||||
{
|
||||
return fMySelf;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProtocolLooper::SetOwnId(BString user_id)
|
||||
ProtocolLooper::SetOwnContact(Contact* contact)
|
||||
{
|
||||
fMySelf = user_id;
|
||||
fMySelf = contact;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ public:
|
|||
CommandMap Commands() const;
|
||||
ChatCommand* CommandById(BString id);
|
||||
|
||||
BString GetOwnId();
|
||||
void SetOwnId(BString user_id);
|
||||
Contact* GetOwnContact();
|
||||
void SetOwnContact(Contact* contact);
|
||||
|
||||
int64 GetInstance();
|
||||
|
||||
|
@ -67,7 +67,7 @@ private:
|
|||
ChatProtocol* fProtocol;
|
||||
int64 fInstance;
|
||||
|
||||
BString fMySelf;
|
||||
Contact* fMySelf;
|
||||
|
||||
ChatMap fChatMap;
|
||||
RosterMap fRosterMap;
|
||||
|
|
|
@ -270,10 +270,17 @@ Server::ImMessage(BMessage* msg)
|
|||
}
|
||||
case IM_OWN_CONTACT_INFO:
|
||||
{
|
||||
Contact* contact = _EnsureContact(msg);
|
||||
if (contact != NULL) {
|
||||
contact->GetProtocolLooper()->SetOwnId(contact->GetId());
|
||||
BString id = msg->FindString("user_id");
|
||||
ProtocolLooper* looper = _LooperFromMessage(msg);
|
||||
if (looper == NULL || id.IsEmpty() == true) break;
|
||||
|
||||
Contact* contact = looper->GetOwnContact();
|
||||
if (contact == NULL) {
|
||||
contact = new Contact(id, Looper());
|
||||
contact->SetProtocolLooper(looper);
|
||||
looper->SetOwnContact(contact);
|
||||
}
|
||||
|
||||
BString name;
|
||||
if (msg->FindString("user_name", &name) == B_OK)
|
||||
contact->SetNotifyName(name);
|
||||
|
@ -449,7 +456,6 @@ Server::ImMessage(BMessage* msg)
|
|||
{
|
||||
Conversation* item = _EnsureConversation(msg);
|
||||
item->ImMessage(msg);
|
||||
|
||||
break;
|
||||
}
|
||||
case IM_ROOM_INVITE_RECEIVED:
|
||||
|
@ -922,7 +928,7 @@ Server::_EnsureConversation(BMessage* message)
|
|||
if (item == NULL) {
|
||||
item = new Conversation(chat_id, Looper());
|
||||
item->SetProtocolLooper(looper);
|
||||
item->AddUser(looper->ContactById(looper->GetOwnId()));
|
||||
item->AddUser(looper->GetOwnContact());
|
||||
looper->AddConversation(item);
|
||||
|
||||
BMessage meta(IM_MESSAGE);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
RosterItem::RosterItem(const char* name, Contact* contact)
|
||||
: BStringItem(name),
|
||||
fBitmap(NULL),
|
||||
fBitmap(contact->AvatarBitmap()),
|
||||
fStatus(STATUS_OFFLINE),
|
||||
contactLinker(contact),
|
||||
fVisible(true)
|
||||
|
@ -49,8 +49,6 @@ RosterItem::SetVisible(bool visible)
|
|||
void
|
||||
RosterItem::SetBitmap(BBitmap* bitmap)
|
||||
{
|
||||
if (fBitmap != NULL)
|
||||
delete fBitmap;
|
||||
fBitmap = bitmap;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ UserListView::_UserPopUp()
|
|||
if (item == NULL || (selected_user = item->GetUser()) == NULL)
|
||||
return _BlankPopUp();
|
||||
|
||||
Role* own_role = fChat->GetRole(fChat->GetOwnId());
|
||||
Role* own_role = fChat->GetRole(fChat->GetOwnContact()->GetId());
|
||||
|
||||
Role* selected_role = fChat->GetRole(selected_user->GetId());
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue