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
|
Contact*
|
||||||
Conversation::GetOwnId()
|
Conversation::GetOwnContact()
|
||||||
{
|
{
|
||||||
return fLooper->GetOwnId();
|
return fLooper->GetOwnContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
UserMap Users();
|
UserMap Users();
|
||||||
User* UserById(BString id);
|
User* UserById(BString id);
|
||||||
BString GetOwnId();
|
Contact* GetOwnContact();
|
||||||
|
|
||||||
void AddUser(User* user);
|
void AddUser(User* user);
|
||||||
void RemoveUser(User* user);
|
void RemoveUser(User* user);
|
||||||
|
|
|
@ -167,17 +167,17 @@ ProtocolLooper::CommandById(BString id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
Contact*
|
||||||
ProtocolLooper::GetOwnId()
|
ProtocolLooper::GetOwnContact()
|
||||||
{
|
{
|
||||||
return fMySelf;
|
return fMySelf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ProtocolLooper::SetOwnId(BString user_id)
|
ProtocolLooper::SetOwnContact(Contact* contact)
|
||||||
{
|
{
|
||||||
fMySelf = user_id;
|
fMySelf = contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ public:
|
||||||
CommandMap Commands() const;
|
CommandMap Commands() const;
|
||||||
ChatCommand* CommandById(BString id);
|
ChatCommand* CommandById(BString id);
|
||||||
|
|
||||||
BString GetOwnId();
|
Contact* GetOwnContact();
|
||||||
void SetOwnId(BString user_id);
|
void SetOwnContact(Contact* contact);
|
||||||
|
|
||||||
int64 GetInstance();
|
int64 GetInstance();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ private:
|
||||||
ChatProtocol* fProtocol;
|
ChatProtocol* fProtocol;
|
||||||
int64 fInstance;
|
int64 fInstance;
|
||||||
|
|
||||||
BString fMySelf;
|
Contact* fMySelf;
|
||||||
|
|
||||||
ChatMap fChatMap;
|
ChatMap fChatMap;
|
||||||
RosterMap fRosterMap;
|
RosterMap fRosterMap;
|
||||||
|
|
|
@ -270,10 +270,17 @@ Server::ImMessage(BMessage* msg)
|
||||||
}
|
}
|
||||||
case IM_OWN_CONTACT_INFO:
|
case IM_OWN_CONTACT_INFO:
|
||||||
{
|
{
|
||||||
Contact* contact = _EnsureContact(msg);
|
BString id = msg->FindString("user_id");
|
||||||
if (contact != NULL) {
|
ProtocolLooper* looper = _LooperFromMessage(msg);
|
||||||
contact->GetProtocolLooper()->SetOwnId(contact->GetId());
|
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;
|
BString name;
|
||||||
if (msg->FindString("user_name", &name) == B_OK)
|
if (msg->FindString("user_name", &name) == B_OK)
|
||||||
contact->SetNotifyName(name);
|
contact->SetNotifyName(name);
|
||||||
|
@ -449,7 +456,6 @@ Server::ImMessage(BMessage* msg)
|
||||||
{
|
{
|
||||||
Conversation* item = _EnsureConversation(msg);
|
Conversation* item = _EnsureConversation(msg);
|
||||||
item->ImMessage(msg);
|
item->ImMessage(msg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_ROOM_INVITE_RECEIVED:
|
case IM_ROOM_INVITE_RECEIVED:
|
||||||
|
@ -922,7 +928,7 @@ Server::_EnsureConversation(BMessage* message)
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
item = new Conversation(chat_id, Looper());
|
item = new Conversation(chat_id, Looper());
|
||||||
item->SetProtocolLooper(looper);
|
item->SetProtocolLooper(looper);
|
||||||
item->AddUser(looper->ContactById(looper->GetOwnId()));
|
item->AddUser(looper->GetOwnContact());
|
||||||
looper->AddConversation(item);
|
looper->AddConversation(item);
|
||||||
|
|
||||||
BMessage meta(IM_MESSAGE);
|
BMessage meta(IM_MESSAGE);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
RosterItem::RosterItem(const char* name, Contact* contact)
|
RosterItem::RosterItem(const char* name, Contact* contact)
|
||||||
: BStringItem(name),
|
: BStringItem(name),
|
||||||
fBitmap(NULL),
|
fBitmap(contact->AvatarBitmap()),
|
||||||
fStatus(STATUS_OFFLINE),
|
fStatus(STATUS_OFFLINE),
|
||||||
contactLinker(contact),
|
contactLinker(contact),
|
||||||
fVisible(true)
|
fVisible(true)
|
||||||
|
@ -49,8 +49,6 @@ RosterItem::SetVisible(bool visible)
|
||||||
void
|
void
|
||||||
RosterItem::SetBitmap(BBitmap* bitmap)
|
RosterItem::SetBitmap(BBitmap* bitmap)
|
||||||
{
|
{
|
||||||
if (fBitmap != NULL)
|
|
||||||
delete fBitmap;
|
|
||||||
fBitmap = bitmap;
|
fBitmap = bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ UserListView::_UserPopUp()
|
||||||
if (item == NULL || (selected_user = item->GetUser()) == NULL)
|
if (item == NULL || (selected_user = item->GetUser()) == NULL)
|
||||||
return _BlankPopUp();
|
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());
|
Role* selected_role = fChat->GetRole(selected_user->GetId());
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue