Rename ContactLinker to Contact

This commit is contained in:
Jaidyn Ann 2021-05-23 14:39:07 -05:00
parent 4705d586f9
commit fc16b9b090
16 changed files with 111 additions and 110 deletions

View File

@ -31,18 +31,18 @@
#include "CayaMessages.h" #include "CayaMessages.h"
#include "CayaProtocolMessages.h" #include "CayaProtocolMessages.h"
#include "CayaPreferences.h" #include "CayaPreferences.h"
#include "ContactLinker.h" #include "Contact.h"
#include "EditingFilter.h" #include "EditingFilter.h"
#include "CayaConstants.h" #include "CayaConstants.h"
#include "CayaRenderView.h" #include "CayaRenderView.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
ChatWindow::ChatWindow(ContactLinker* cl) ChatWindow::ChatWindow(Contact* cl)
: :
BWindow(BRect(200, 200, 500, 500), BWindow(BRect(200, 200, 500, 500),
cl->GetName().String(), B_TITLED_WINDOW, 0), cl->GetName().String(), B_TITLED_WINDOW, 0),
fContactLinker(cl) fContact(cl)
{ {
fMessageCount = 0; fMessageCount = 0;
@ -63,7 +63,7 @@ ChatWindow::ChatWindow(ContactLinker* cl)
fPersonalMessage->SetExplicitAlignment( fPersonalMessage->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus()); fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
fPersonalMessage->SetExplicitMaxSize(BSize(400, 200)); fPersonalMessage->SetExplicitMaxSize(BSize(400, 200));
fPersonalMessage->MakeEditable(false); fPersonalMessage->MakeEditable(false);
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@ -77,9 +77,9 @@ ChatWindow::ChatWindow(ContactLinker* cl)
fAvatar->SetExplicitMinSize(BSize(50, 50)); fAvatar->SetExplicitMinSize(BSize(50, 50));
fAvatar->SetExplicitPreferredSize(BSize(50, 50)); fAvatar->SetExplicitPreferredSize(BSize(50, 50));
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
fAvatar->SetBitmap(fContactLinker->AvatarBitmap()); fAvatar->SetBitmap(fContact->AvatarBitmap());
BBitmap* protocolBitmap = fContactLinker->ProtocolBitmap(); BBitmap* protocolBitmap = fContact->ProtocolBitmap();
BitmapView* protocolView = new BitmapView("protocolView"); BitmapView* protocolView = new BitmapView("protocolView");
protocolView->SetBitmap(protocolBitmap); protocolView->SetBitmap(protocolBitmap);
@ -120,8 +120,8 @@ bool
ChatWindow::QuitRequested() ChatWindow::QuitRequested()
{ {
BMessage msg(CAYA_CLOSE_CHAT_WINDOW); BMessage msg(CAYA_CLOSE_CHAT_WINDOW);
msg.AddString("id", fContactLinker->GetId()); msg.AddString("id", fContact->GetId());
fContactLinker->Messenger().SendMessage(&msg); fContact->Messenger().SendMessage(&msg);
return false; return false;
} }
@ -129,9 +129,9 @@ ChatWindow::QuitRequested()
void void
ChatWindow::UpdateAvatar() ChatWindow::UpdateAvatar()
{ {
if (fContactLinker->AvatarBitmap() != NULL) { if (fContact->AvatarBitmap() != NULL) {
LockLooper(); LockLooper();
fAvatar->SetBitmap(fContactLinker->AvatarBitmap()); fAvatar->SetBitmap(fContact->AvatarBitmap());
UnlockLooper(); UnlockLooper();
} }
} }
@ -141,9 +141,9 @@ void
ChatWindow::UpdatePersonalMessage() ChatWindow::UpdatePersonalMessage()
{ {
if (fContactLinker->GetNotifyPersonalStatus() != NULL) { if (fContact->GetNotifyPersonalStatus() != NULL) {
LockLooper(); LockLooper();
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus()); fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
UnlockLooper(); UnlockLooper();
} }
} }
@ -163,9 +163,9 @@ ChatWindow::MessageReceived(BMessage* message)
BMessage msg(IM_MESSAGE); BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_SEND_MESSAGE); msg.AddInt32("im_what", IM_SEND_MESSAGE);
msg.AddString("id", fContactLinker->GetId()); msg.AddString("id", fContact->GetId());
msg.AddString("body", message); msg.AddString("body", message);
fContactLinker->Messenger().SendMessage(&msg); fContact->Messenger().SendMessage(&msg);
fSendView->SetText(""); fSendView->SetText("");
break; break;
@ -204,7 +204,7 @@ ChatWindow::ImMessage(BMessage* msg)
BString title = "["; BString title = "[";
title<<fMessageCount; title<<fMessageCount;
title<<"] "; title<<"] ";
title<<fContactLinker->GetName(); title<<fContact->GetName();
SetTitle(title); SetTitle(title);
} }
@ -220,14 +220,14 @@ ChatWindow::ImMessage(BMessage* msg)
} else { } else {
notify_message << " new messages from "; notify_message << " new messages from ";
}; };
notify_message << fContactLinker->GetName().String(); notify_message << fContact->GetName().String();
BNotification notification(B_INFORMATION_NOTIFICATION); BNotification notification(B_INFORMATION_NOTIFICATION);
notification.SetGroup(BString("Caya")); notification.SetGroup(BString("Caya"));
notification.SetTitle(BString("New message")); notification.SetTitle(BString("New message"));
notification.SetIcon(fAvatar->Bitmap()); notification.SetIcon(fAvatar->Bitmap());
notification.SetContent(notify_message); notification.SetContent(notify_message);
notification.SetMessageID(fContactLinker->GetName()); notification.SetMessageID(fContact->GetName());
notification.Send(); notification.Send();
break; break;
@ -251,7 +251,7 @@ ChatWindow::ImMessage(BMessage* msg)
void void
ChatWindow::WindowActivated(bool active) ChatWindow::WindowActivated(bool active)
{ {
SetTitle(fContactLinker->GetName()); SetTitle(fContact->GetName());
fMessageCount=0; fMessageCount=0;
} }
@ -299,7 +299,7 @@ ChatWindow::ObserveInteger(int32 what, int32 val)
void void
ChatWindow::AppendStatus(CayaStatus status) ChatWindow::AppendStatus(CayaStatus status)
{ {
BString message(fContactLinker->GetName()); BString message(fContact->GetName());
switch (status) { switch (status) {
case CAYA_ONLINE: case CAYA_ONLINE:

View File

@ -14,12 +14,12 @@
#include "CayaConstants.h" #include "CayaConstants.h"
class BitmapView; class BitmapView;
class ContactLinker; class Contact;
class CayaRenderView; class CayaRenderView;
class ChatWindow : public BWindow, public Observer { class ChatWindow : public BWindow, public Observer {
public: public:
ChatWindow(ContactLinker* cl); ChatWindow(Contact* cl);
virtual void ShowWindow(); virtual void ShowWindow();
@ -39,7 +39,7 @@ public:
void AvoidFocus(bool avoid); void AvoidFocus(bool avoid);
private: private:
BTextView* fSendView; BTextView* fSendView;
ContactLinker* fContactLinker; Contact* fContact;
CayaRenderView* fReceiveView; CayaRenderView* fReceiveView;
BStringView* fStatus; BStringView* fStatus;
BTextView* fPersonalMessage; BTextView* fPersonalMessage;

View File

@ -7,7 +7,7 @@
* Andrea Anzani, andrea.anzani@gmail.com * Andrea Anzani, andrea.anzani@gmail.com
* Dario Casalinuovo * Dario Casalinuovo
*/ */
#include "ContactLinker.h" #include "Contact.h"
#include <libinterface/BitmapUtils.h> #include <libinterface/BitmapUtils.h>
@ -26,7 +26,7 @@
#include <stdio.h> #include <stdio.h>
ContactLinker::ContactLinker(BString id, BMessenger msgn) Contact::Contact(BString id, BMessenger msgn)
: :
fChatWindow(NULL), fChatWindow(NULL),
fID(id), fID(id),
@ -44,7 +44,7 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
ChatWindow* ChatWindow*
ContactLinker::GetChatWindow() Contact::GetChatWindow()
{ {
if (fChatWindow == NULL) if (fChatWindow == NULL)
CreateChatWindow(); CreateChatWindow();
@ -53,7 +53,7 @@ ContactLinker::GetChatWindow()
void void
ContactLinker::DeleteWindow() Contact::DeleteWindow()
{ {
if (fChatWindow != NULL) { if (fChatWindow != NULL) {
if (fChatWindow->Lock()) { if (fChatWindow->Lock()) {
@ -67,7 +67,7 @@ ContactLinker::DeleteWindow()
void void
ContactLinker::ShowWindow(bool typing, bool userAction) Contact::ShowWindow(bool typing, bool userAction)
{ {
if (fChatWindow == NULL) if (fChatWindow == NULL)
CreateChatWindow(); CreateChatWindow();
@ -96,7 +96,7 @@ ContactLinker::ShowWindow(bool typing, bool userAction)
void void
ContactLinker::HideWindow() Contact::HideWindow()
{ {
if ((fChatWindow != NULL) && !fChatWindow->IsHidden()) if ((fChatWindow != NULL) && !fChatWindow->IsHidden())
fChatWindow->Hide(); fChatWindow->Hide();
@ -104,7 +104,7 @@ ContactLinker::HideWindow()
void void
ContactLinker::ShowPopUp(BPoint where) Contact::ShowPopUp(BPoint where)
{ {
if (fPopUp == NULL) { if (fPopUp == NULL) {
fPopUp = new ContactPopUp(this); fPopUp = new ContactPopUp(this);
@ -117,7 +117,7 @@ ContactLinker::ShowPopUp(BPoint where)
void void
ContactLinker::HidePopUp() Contact::HidePopUp()
{ {
if ((fPopUp != NULL) && !fPopUp->IsHidden()) if ((fPopUp != NULL) && !fPopUp->IsHidden())
fPopUp->Hide(); fPopUp->Hide();
@ -125,7 +125,7 @@ ContactLinker::HidePopUp()
void void
ContactLinker::DeletePopUp() Contact::DeletePopUp()
{ {
if (fPopUp == NULL) if (fPopUp == NULL)
return; return;
@ -139,81 +139,81 @@ ContactLinker::DeletePopUp()
RosterItem* RosterItem*
ContactLinker::GetRosterItem() const Contact::GetRosterItem() const
{ {
return fRosterItem; return fRosterItem;
} }
BString BString
ContactLinker::GetId() const Contact::GetId() const
{ {
return fID; return fID;
} }
BMessenger BMessenger
ContactLinker::Messenger() const Contact::Messenger() const
{ {
return fMessenger; return fMessenger;
} }
void void
ContactLinker::SetMessenger(BMessenger messenger) Contact::SetMessenger(BMessenger messenger)
{ {
fMessenger = messenger; fMessenger = messenger;
} }
ProtocolLooper* ProtocolLooper*
ContactLinker::GetProtocolLooper() const Contact::GetProtocolLooper() const
{ {
return fLooper; return fLooper;
} }
BString BString
ContactLinker::GetName() const Contact::GetName() const
{ {
return fName; return fName;
} }
BBitmap* BBitmap*
ContactLinker::AvatarBitmap() const Contact::AvatarBitmap() const
{ {
return fAvatarBitmap; return fAvatarBitmap;
} }
BBitmap* BBitmap*
ContactLinker::ProtocolBitmap() const Contact::ProtocolBitmap() const
{ {
CayaProtocol* protocol = fLooper->Protocol(); CayaProtocol* protocol = fLooper->Protocol();
CayaProtocolAddOn* addOn CayaProtocolAddOn* addOn
= ProtocolManager::Get()->ProtocolAddOn(protocol->Signature()); = ProtocolManager::Get()->ProtocolAddOn(protocol->Signature());
return addOn->Icon(); return addOn->ProtoIcon();
} }
CayaStatus CayaStatus
ContactLinker::GetNotifyStatus() const Contact::GetNotifyStatus() const
{ {
return fStatus; return fStatus;
} }
BString BString
ContactLinker::GetNotifyPersonalStatus() const Contact::GetNotifyPersonalStatus() const
{ {
return fPersonalStatus; return fPersonalStatus;
} }
void void
ContactLinker::SetProtocolLooper(ProtocolLooper* looper) Contact::SetProtocolLooper(ProtocolLooper* looper)
{ {
if (looper) { if (looper) {
fLooper = looper; fLooper = looper;
@ -229,7 +229,7 @@ ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
void void
ContactLinker::SetNotifyName(BString name) Contact::SetNotifyName(BString name)
{ {
if (fName.Compare(name) != 0) { if (fName.Compare(name) != 0) {
fName = name; fName = name;
@ -239,7 +239,7 @@ ContactLinker::SetNotifyName(BString name)
void void
ContactLinker::SetNotifyAvatarBitmap(BBitmap* bitmap) Contact::SetNotifyAvatarBitmap(BBitmap* bitmap)
{ {
if ((fAvatarBitmap != bitmap) && (bitmap != NULL)) { if ((fAvatarBitmap != bitmap) && (bitmap != NULL)) {
fAvatarBitmap = bitmap; fAvatarBitmap = bitmap;
@ -251,7 +251,7 @@ ContactLinker::SetNotifyAvatarBitmap(BBitmap* bitmap)
void void
ContactLinker::SetNotifyStatus(CayaStatus status) Contact::SetNotifyStatus(CayaStatus status)
{ {
if (fStatus != status) { if (fStatus != status) {
fStatus = status; fStatus = status;
@ -261,7 +261,7 @@ ContactLinker::SetNotifyStatus(CayaStatus status)
void void
ContactLinker::SetNotifyPersonalStatus(BString personalStatus) Contact::SetNotifyPersonalStatus(BString personalStatus)
{ {
if (fPersonalStatus.Compare(personalStatus) != 0) { if (fPersonalStatus.Compare(personalStatus) != 0) {
fPersonalStatus = personalStatus; fPersonalStatus = personalStatus;
@ -271,7 +271,7 @@ ContactLinker::SetNotifyPersonalStatus(BString personalStatus)
void void
ContactLinker::CreateChatWindow() Contact::CreateChatWindow()
{ {
fChatWindow = new ChatWindow(this); fChatWindow = new ChatWindow(this);
WindowsManager::Get()->RelocateWindow(fChatWindow); WindowsManager::Get()->RelocateWindow(fChatWindow);

View File

@ -20,9 +20,9 @@ class ContactPopUp;
class ProtocolLooper; class ProtocolLooper;
class RosterItem; class RosterItem;
class ContactLinker : public Notifier { class Contact : public Notifier {
public: public:
ContactLinker(BString id, BMessenger msgn); Contact(BString id, BMessenger msgn);
ChatWindow* GetChatWindow(); ChatWindow* GetChatWindow();
void DeleteWindow(); void DeleteWindow();

View File

@ -163,7 +163,7 @@ MainWindow::MessageReceived(BMessage* message)
RosterMap map = fServer->RosterItems(); RosterMap map = fServer->RosterItems();
for (uint32 i = 0; i < map.CountItems(); i++) { for (uint32 i = 0; i < map.CountItems(); i++) {
ContactLinker* linker = map.ValueAt(i); Contact* linker = map.ValueAt(i);
RosterItem* item = linker->GetRosterItem(); RosterItem* item = linker->GetRosterItem();
// If the search filter has been deleted show all the items, // If the search filter has been deleted show all the items,
@ -190,7 +190,7 @@ MainWindow::MessageReceived(BMessage* message)
int index = message->FindInt32("index"); int index = message->FindInt32("index");
RosterItem* ritem = ItemAt(index); RosterItem* ritem = ItemAt(index);
if (ritem != NULL) if (ritem != NULL)
ritem->GetContactLinker()->ShowWindow(false, true); ritem->GetContact()->ShowWindow(false, true);
break; break;
} }
@ -319,7 +319,7 @@ MainWindow::ImMessage(BMessage* msg)
// Notify when contact is online or offline // Notify when contact is online or offline
if (status == CAYA_ONLINE) { if (status == CAYA_ONLINE) {
BString message; BString message;
message << rosterItem->GetContactLinker()->GetName(); message << rosterItem->GetContact()->GetName();
if (status == CAYA_ONLINE) if (status == CAYA_ONLINE)
message << " is available!"; message << " is available!";

View File

@ -38,7 +38,7 @@ SRCS = \
application/CayaProtocolAddOn.cpp \ application/CayaProtocolAddOn.cpp \
application/CayaUtils.cpp \ application/CayaUtils.cpp \
application/ChatWindow.cpp \ application/ChatWindow.cpp \
application/ContactLinker.cpp \ application/Contact.cpp \
application/EditingFilter.cpp \ application/EditingFilter.cpp \
application/ImageCache.cpp \ application/ImageCache.cpp \
application/Main.cpp \ application/Main.cpp \

View File

@ -42,7 +42,7 @@ Server::Server()
void void
Server::Quit() Server::Quit()
{ {
ContactLinker* linker = NULL; Contact* linker = NULL;
while ((linker = fRosterMap.ValueAt(0))) { while ((linker = fRosterMap.ValueAt(0))) {
linker->DeleteWindow(); linker->DeleteWindow();
@ -126,7 +126,7 @@ Server::Filter(BMessage* message, BHandler **target)
BString id = message->FindString("id"); BString id = message->FindString("id");
if (id.Length() > 0) { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
if (found) { if (found) {
ChatWindow* win = item->GetChatWindow(); ChatWindow* win = item->GetChatWindow();
item->ShowWindow(); item->ShowWindow();
@ -141,7 +141,7 @@ Server::Filter(BMessage* message, BHandler **target)
BString id = message->FindString("id"); BString id = message->FindString("id");
if (id.Length() > 0) { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
if (found) if (found)
item->HideWindow(); item->HideWindow();
@ -191,7 +191,7 @@ RosterItem*
Server::RosterItemForId(BString id) Server::RosterItemForId(BString id)
{ {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
return item ? item->GetRosterItem() : NULL; return item ? item->GetRosterItem() : NULL;
} }
@ -209,12 +209,12 @@ Server::ImMessage(BMessage* msg)
BString id; BString id;
while (msg->FindString("id", i++, &id) == B_OK) { while (msg->FindString("id", i++, &id) == B_OK) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
if (found) if (found)
continue; continue;
item = new ContactLinker(id.String(), Looper()); item = new Contact(id.String(), Looper());
item->SetProtocolLooper(_LooperFromMessage(msg)); item->SetProtocolLooper(_LooperFromMessage(msg));
fRosterMap.AddItem(id, item); fRosterMap.AddItem(id, item);
} }
@ -243,7 +243,7 @@ Server::ImMessage(BMessage* msg)
if (msg->FindInt32("status", &status) != B_OK) if (msg->FindInt32("status", &status) != B_OK)
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
ContactLinker* linker = _EnsureContactLinker(msg); Contact* linker = _EnsureContact(msg);
if (!linker) if (!linker)
break; break;
@ -257,7 +257,7 @@ Server::ImMessage(BMessage* msg)
} }
case IM_CONTACT_INFO: case IM_CONTACT_INFO:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); Contact* linker = _EnsureContact(msg);
if (!linker) if (!linker)
break; break;
@ -276,7 +276,7 @@ Server::ImMessage(BMessage* msg)
} }
case IM_EXTENDED_CONTACT_INFO: case IM_EXTENDED_CONTACT_INFO:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); Contact* linker = _EnsureContact(msg);
if (!linker) if (!linker)
break; break;
@ -292,7 +292,7 @@ Server::ImMessage(BMessage* msg)
} }
case IM_AVATAR_SET: case IM_AVATAR_SET:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); Contact* linker = _EnsureContact(msg);
if (!linker) if (!linker)
break; break;
@ -308,7 +308,7 @@ Server::ImMessage(BMessage* msg)
case IM_SEND_MESSAGE: case IM_SEND_MESSAGE:
{ {
// Route this message through the appropriate ProtocolLooper // Route this message through the appropriate ProtocolLooper
ContactLinker* linker = _EnsureContactLinker(msg); Contact* linker = _EnsureContact(msg);
if (linker->GetProtocolLooper()) if (linker->GetProtocolLooper())
linker->GetProtocolLooper()->PostMessage(msg); linker->GetProtocolLooper()->PostMessage(msg);
break; break;
@ -318,7 +318,7 @@ Server::ImMessage(BMessage* msg)
BString id = msg->FindString("id"); BString id = msg->FindString("id");
if (id.Length() > 0) { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
if (found) { if (found) {
ChatWindow* win = item->GetChatWindow(); ChatWindow* win = item->GetChatWindow();
item->ShowWindow(); item->ShowWindow();
@ -334,7 +334,7 @@ Server::ImMessage(BMessage* msg)
BString id = msg->FindString("id"); BString id = msg->FindString("id");
if (id.Length() > 0) { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); Contact* item = fRosterMap.ValueFor(id, &found);
if (found) { if (found) {
ChatWindow* win = item->GetChatWindow(); ChatWindow* win = item->GetChatWindow();
item->ShowWindow(true); item->ShowWindow(true);
@ -398,7 +398,6 @@ Server::ImMessage(BMessage* msg)
CayaProtocolAddOn* addOn CayaProtocolAddOn* addOn
= ProtocolManager::Get()->ProtocolAddOn(protocol); = ProtocolManager::Get()->ProtocolAddOn(protocol);
BNotification notification((notification_type)type); BNotification notification((notification_type)type);
notification.SetGroup(BString("Caya")); notification.SetGroup(BString("Caya"));
notification.SetTitle(title); notification.SetTitle(title);
@ -417,7 +416,7 @@ Server::ImMessage(BMessage* msg)
} }
ContactLinker* Contact*
Server::GetOwnContact() Server::GetOwnContact()
{ {
return fMySelf; return fMySelf;
@ -444,21 +443,21 @@ Server::_LooperFromMessage(BMessage* message)
} }
ContactLinker* Contact*
Server::_EnsureContactLinker(BMessage* message) Server::_EnsureContact(BMessage* message)
{ {
if (!message) if (!message)
return NULL; return NULL;
BString id = message->FindString("id"); BString id = message->FindString("id");
ContactLinker* item = NULL; Contact* item = NULL;
if (id.Length() > 0) { if (id.Length() > 0) {
bool found = false; bool found = false;
item = fRosterMap.ValueFor(id, &found); item = fRosterMap.ValueFor(id, &found);
if (!found) { if (!found) {
item = new ContactLinker(id.String(), Looper()); item = new Contact(id.String(), Looper());
item->SetProtocolLooper(_LooperFromMessage(message)); item->SetProtocolLooper(_LooperFromMessage(message));
fRosterMap.AddItem(id, item); fRosterMap.AddItem(id, item);
} }
@ -466,3 +465,5 @@ Server::_EnsureContactLinker(BMessage* message)
return item; return item;
} }

View File

@ -12,13 +12,13 @@
#include <libsupport/KeyMap.h> #include <libsupport/KeyMap.h>
#include "CayaConstants.h" #include "CayaConstants.h"
#include "ContactLinker.h" #include "Contact.h"
class CayaProtocol; class CayaProtocol;
class RosterItem; class RosterItem;
class ProtocolLooper; class ProtocolLooper;
typedef KeyMap<BString, ContactLinker*> RosterMap; typedef KeyMap<BString, Contact*> RosterMap;
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers; typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
class Server: public BMessageFilter { class Server: public BMessageFilter {
@ -43,16 +43,16 @@ public:
RosterItem* RosterItemForId(BString id); RosterItem* RosterItemForId(BString id);
// TODO: there should be a contact for each account. // TODO: there should be a contact for each account.
ContactLinker* GetOwnContact(); Contact* GetOwnContact();
private: private:
ProtocolLooper* _LooperFromMessage(BMessage* message); ProtocolLooper* _LooperFromMessage(BMessage* message);
ContactLinker* _EnsureContactLinker(BMessage* message); Contact* _EnsureContact(BMessage* message);
void _ReplicantStatusNotify(CayaStatus status); void _ReplicantStatusNotify(CayaStatus status);
RosterMap fRosterMap; RosterMap fRosterMap;
ProtocolLoopers fLoopers; ProtocolLoopers fLoopers;
ContactLinker* fMySelf; Contact* fMySelf;
}; };
#endif // _SERVER_H #endif // _SERVER_H

View File

@ -24,34 +24,34 @@
#include "CayaMessages.h" #include "CayaMessages.h"
#include "CayaProtocolMessages.h" #include "CayaProtocolMessages.h"
#include "ContactLinker.h" #include "Contact.h"
#include "CayaConstants.h" #include "CayaConstants.h"
#include "CayaRenderView.h" #include "CayaRenderView.h"
#include "CayaUtils.h" #include "CayaUtils.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
ContactInfoWindow::ContactInfoWindow(ContactLinker* linker) ContactInfoWindow::ContactInfoWindow(Contact* linker)
: :
BWindow(BRect(200, 200, 500, 400), BWindow(BRect(200, 200, 500, 400),
"Contact Informations", B_FLOATING_WINDOW, "Contact Informations", B_FLOATING_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE), B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fContactLinker(linker) fContact(linker)
{ {
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW); fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
B_ALIGN_MIDDLE)); B_ALIGN_MIDDLE));
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus()); fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
fPersonalMessage->SetExplicitMaxSize(BSize(200, 200)); fPersonalMessage->SetExplicitMaxSize(BSize(200, 200));
fPersonalMessage->MakeEditable(false); fPersonalMessage->MakeEditable(false);
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BString status(fContactLinker->GetName()); BString status(fContact->GetName());
status << CayaStatusToString(fContactLinker->GetNotifyStatus()); status << CayaStatusToString(fContact->GetNotifyStatus());
status << "\n\n ID : "; status << "\n\n ID : ";
status << fContactLinker->GetId(); status << fContact->GetId();
fStatus = new BTextView("status", B_WILL_DRAW); fStatus = new BTextView("status", B_WILL_DRAW);
fStatus->SetText(status); fStatus->SetText(status);
@ -65,7 +65,7 @@ ContactInfoWindow::ContactInfoWindow(ContactLinker* linker)
fAvatar->SetExplicitMinSize(BSize(50, 50)); fAvatar->SetExplicitMinSize(BSize(50, 50));
fAvatar->SetExplicitPreferredSize(BSize(50, 50)); fAvatar->SetExplicitPreferredSize(BSize(50, 50));
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
fAvatar->SetBitmap(fContactLinker->AvatarBitmap()); fAvatar->SetBitmap(fContact->AvatarBitmap());
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)

View File

@ -16,16 +16,16 @@
#include "CayaConstants.h" #include "CayaConstants.h"
class BitmapView; class BitmapView;
class ContactLinker; class Contact;
class ContactInfoWindow: public BWindow, public Observer { class ContactInfoWindow: public BWindow, public Observer {
public: public:
ContactInfoWindow(ContactLinker* linker); ContactInfoWindow(Contact* linker);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
private: private:
BTextView* fStatus; BTextView* fStatus;
ContactLinker* fContactLinker; Contact* fContact;
BTextView* fPersonalMessage; BTextView* fPersonalMessage;
BitmapView* fAvatar; BitmapView* fAvatar;

View File

@ -15,7 +15,7 @@
#include <libinterface/BitmapView.h> #include <libinterface/BitmapView.h>
#include "ContactLinker.h" #include "Contact.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
@ -24,7 +24,7 @@ const window_feel kMenuWindowFeel = window_feel(B_NORMAL_WINDOW_FEEL);
const int32 kNickChanged = 'NICH'; const int32 kNickChanged = 'NICH';
ContactPopUp::ContactPopUp(ContactLinker* contact) ContactPopUp::ContactPopUp(Contact* contact)
: BWindow(BRect(0, 0, 1, 1), "ContactPopUp", B_BORDERED_WINDOW_LOOK, : BWindow(BRect(0, 0, 1, 1), "ContactPopUp", B_BORDERED_WINDOW_LOOK,
kMenuWindowFeel, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_MINIMIZABLE | kMenuWindowFeel, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_MINIMIZABLE |
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS |

View File

@ -13,11 +13,11 @@ class BTextControl;
class BStringView; class BStringView;
class BitmapView; class BitmapView;
class ContactLinker; class Contact;
class ContactPopUp : public BWindow, public Observer { class ContactPopUp : public BWindow, public Observer {
public: public:
ContactPopUp(ContactLinker* contact); ContactPopUp(Contact* contact);
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);

View File

@ -13,12 +13,12 @@
#include "CayaUtils.h" #include "CayaUtils.h"
#include "CayaResources.h" #include "CayaResources.h"
#include "ContactLinker.h" #include "Contact.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
#include "RosterItem.h" #include "RosterItem.h"
RosterItem::RosterItem(const char* name, ContactLinker* contact) RosterItem::RosterItem(const char* name, Contact* contact)
: BStringItem(name), : BStringItem(name),
fBitmap(NULL), fBitmap(NULL),
fStatus(CAYA_OFFLINE), fStatus(CAYA_OFFLINE),

View File

@ -12,12 +12,12 @@
#include <String.h> #include <String.h>
#include "CayaConstants.h" #include "CayaConstants.h"
#include "ContactLinker.h" #include "Contact.h"
#include "Observer.h" #include "Observer.h"
class RosterItem : public BStringItem, public Observer { class RosterItem : public BStringItem, public Observer {
public: public:
RosterItem(const char* name, ContactLinker* contact); RosterItem(const char* name, Contact* contact);
~RosterItem(); ~RosterItem();
bool IsVisible() const { return fVisible; } bool IsVisible() const { return fVisible; }
@ -28,7 +28,7 @@ public:
void Update(BView *owner, const BFont *font); void Update(BView *owner, const BFont *font);
ContactLinker* GetContactLinker() { return contactLinker;} Contact* GetContact() { return contactLinker;}
CayaStatus Status() const { return fStatus; } CayaStatus Status() const { return fStatus; }
void SetStatus(CayaStatus status); void SetStatus(CayaStatus status);
@ -45,7 +45,7 @@ protected:
void ObserveInteger(int32 what, int32 val); void ObserveInteger(int32 what, int32 val);
private: private:
ContactLinker* contactLinker; Contact* contactLinker;
float fBaselineOffset; float fBaselineOffset;
BString fPersonalStatus; BString fPersonalStatus;
CayaStatus fStatus; CayaStatus fStatus;

View File

@ -17,7 +17,7 @@
#include <stdio.h> #include <stdio.h>
#include "ContactInfoWindow.h" #include "ContactInfoWindow.h"
#include "ContactLinker.h" #include "Contact.h"
#include "RosterItem.h" #include "RosterItem.h"
const int32 kAddPeople = 'ADPL'; const int32 kAddPeople = 'ADPL';
@ -33,8 +33,8 @@ compare_by_name(const void* _item1, const void* _item2)
RosterItem* item1 = *(RosterItem**)_item1; RosterItem* item1 = *(RosterItem**)_item1;
RosterItem* item2 = *(RosterItem**)_item2; RosterItem* item2 = *(RosterItem**)_item2;
return strcasecmp(item1->GetContactLinker()->GetName().String(), return strcasecmp(item1->GetContact()->GetName().String(),
item2->GetContactLinker()->GetName().String()); item2->GetContact()->GetName().String());
} }
@ -108,7 +108,7 @@ RosterListView::MessageReceived(BMessage* msg)
if (ritem == NULL) if (ritem == NULL)
return; return;
_InfoWindow(ritem->GetContactLinker()); _InfoWindow(ritem->GetContact());
break; break;
} }
@ -116,7 +116,7 @@ RosterListView::MessageReceived(BMessage* msg)
{ {
if (ritem == NULL) if (ritem == NULL)
return; return;
ContactLinker* link = ritem->GetContactLinker(); Contact* link = ritem->GetContact();
link->ShowWindow(false, true); link->ShowWindow(false, true);
break; break;
} }
@ -146,10 +146,10 @@ RosterListView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
// Hide previous item's popup // Hide previous item's popup
if ((fPrevItem != NULL) && (fPrevItem != ritem)) if ((fPrevItem != NULL) && (fPrevItem != ritem))
fPrevItem->GetContactLinker()->HidePopUp(); fPrevItem->GetContact()->HidePopUp();
// Show current item's popup // Show current item's popup
ritem->GetContactLinker()->ShowPopUp(ConvertToScreen(where)); ritem->GetContact()->ShowPopUp(ConvertToScreen(where));
// This will be the previous item // This will be the previous item
fPrevItem = ritem; fPrevItem = ritem;
@ -158,7 +158,7 @@ RosterListView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
case B_EXITED_VIEW: case B_EXITED_VIEW:
// Mouse cursor leaved this view, hide last item's popup // Mouse cursor leaved this view, hide last item's popup
if (fPrevItem != NULL) if (fPrevItem != NULL)
fPrevItem->GetContactLinker()->HidePopUp(); fPrevItem->GetContact()->HidePopUp();
break; break;
} }
} }
@ -221,7 +221,7 @@ RosterListView::Sort()
void void
RosterListView::_InfoWindow(ContactLinker* linker) RosterListView::_InfoWindow(Contact* linker)
{ {
ContactInfoWindow* win = new ContactInfoWindow(linker); ContactInfoWindow* win = new ContactInfoWindow(linker);
win->Show(); win->Show();

View File

@ -9,7 +9,7 @@
class BPopUpMenu; class BPopUpMenu;
class ContactLinker; class Contact;
class RosterItem; class RosterItem;
class RosterListView : public BOutlineListView class RosterListView : public BOutlineListView
@ -26,7 +26,7 @@ public:
private: private:
void _InfoWindow(ContactLinker* linker); void _InfoWindow(Contact* linker);
BPopUpMenu* fPopUp; BPopUpMenu* fPopUp;
RosterItem* fPrevItem; RosterItem* fPrevItem;