Rename ContactLinker to Contact
This commit is contained in:
parent
4705d586f9
commit
fc16b9b090
|
@ -31,18 +31,18 @@
|
|||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "CayaPreferences.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "EditingFilter.h"
|
||||
#include "CayaConstants.h"
|
||||
#include "CayaRenderView.h"
|
||||
#include "NotifyMessage.h"
|
||||
|
||||
|
||||
ChatWindow::ChatWindow(ContactLinker* cl)
|
||||
ChatWindow::ChatWindow(Contact* cl)
|
||||
:
|
||||
BWindow(BRect(200, 200, 500, 500),
|
||||
cl->GetName().String(), B_TITLED_WINDOW, 0),
|
||||
fContactLinker(cl)
|
||||
fContact(cl)
|
||||
{
|
||||
fMessageCount = 0;
|
||||
|
||||
|
@ -63,7 +63,7 @@ ChatWindow::ChatWindow(ContactLinker* cl)
|
|||
fPersonalMessage->SetExplicitAlignment(
|
||||
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||
|
||||
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
||||
fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
|
||||
fPersonalMessage->SetExplicitMaxSize(BSize(400, 200));
|
||||
fPersonalMessage->MakeEditable(false);
|
||||
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
@ -77,9 +77,9 @@ ChatWindow::ChatWindow(ContactLinker* cl)
|
|||
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
||||
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
||||
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");
|
||||
protocolView->SetBitmap(protocolBitmap);
|
||||
|
||||
|
@ -120,8 +120,8 @@ bool
|
|||
ChatWindow::QuitRequested()
|
||||
{
|
||||
BMessage msg(CAYA_CLOSE_CHAT_WINDOW);
|
||||
msg.AddString("id", fContactLinker->GetId());
|
||||
fContactLinker->Messenger().SendMessage(&msg);
|
||||
msg.AddString("id", fContact->GetId());
|
||||
fContact->Messenger().SendMessage(&msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -129,9 +129,9 @@ ChatWindow::QuitRequested()
|
|||
void
|
||||
ChatWindow::UpdateAvatar()
|
||||
{
|
||||
if (fContactLinker->AvatarBitmap() != NULL) {
|
||||
if (fContact->AvatarBitmap() != NULL) {
|
||||
LockLooper();
|
||||
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
||||
fAvatar->SetBitmap(fContact->AvatarBitmap());
|
||||
UnlockLooper();
|
||||
}
|
||||
}
|
||||
|
@ -141,9 +141,9 @@ void
|
|||
ChatWindow::UpdatePersonalMessage()
|
||||
{
|
||||
|
||||
if (fContactLinker->GetNotifyPersonalStatus() != NULL) {
|
||||
if (fContact->GetNotifyPersonalStatus() != NULL) {
|
||||
LockLooper();
|
||||
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
||||
fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
|
||||
UnlockLooper();
|
||||
}
|
||||
}
|
||||
|
@ -163,9 +163,9 @@ ChatWindow::MessageReceived(BMessage* message)
|
|||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_SEND_MESSAGE);
|
||||
msg.AddString("id", fContactLinker->GetId());
|
||||
msg.AddString("id", fContact->GetId());
|
||||
msg.AddString("body", message);
|
||||
fContactLinker->Messenger().SendMessage(&msg);
|
||||
fContact->Messenger().SendMessage(&msg);
|
||||
|
||||
fSendView->SetText("");
|
||||
break;
|
||||
|
@ -204,7 +204,7 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
BString title = "[";
|
||||
title<<fMessageCount;
|
||||
title<<"] ";
|
||||
title<<fContactLinker->GetName();
|
||||
title<<fContact->GetName();
|
||||
SetTitle(title);
|
||||
}
|
||||
|
||||
|
@ -220,14 +220,14 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
} else {
|
||||
notify_message << " new messages from ";
|
||||
};
|
||||
notify_message << fContactLinker->GetName().String();
|
||||
notify_message << fContact->GetName().String();
|
||||
|
||||
BNotification notification(B_INFORMATION_NOTIFICATION);
|
||||
notification.SetGroup(BString("Caya"));
|
||||
notification.SetTitle(BString("New message"));
|
||||
notification.SetIcon(fAvatar->Bitmap());
|
||||
notification.SetContent(notify_message);
|
||||
notification.SetMessageID(fContactLinker->GetName());
|
||||
notification.SetMessageID(fContact->GetName());
|
||||
notification.Send();
|
||||
|
||||
break;
|
||||
|
@ -251,7 +251,7 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
void
|
||||
ChatWindow::WindowActivated(bool active)
|
||||
{
|
||||
SetTitle(fContactLinker->GetName());
|
||||
SetTitle(fContact->GetName());
|
||||
fMessageCount=0;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ ChatWindow::ObserveInteger(int32 what, int32 val)
|
|||
void
|
||||
ChatWindow::AppendStatus(CayaStatus status)
|
||||
{
|
||||
BString message(fContactLinker->GetName());
|
||||
BString message(fContact->GetName());
|
||||
|
||||
switch (status) {
|
||||
case CAYA_ONLINE:
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include "CayaConstants.h"
|
||||
|
||||
class BitmapView;
|
||||
class ContactLinker;
|
||||
class Contact;
|
||||
class CayaRenderView;
|
||||
|
||||
class ChatWindow : public BWindow, public Observer {
|
||||
public:
|
||||
ChatWindow(ContactLinker* cl);
|
||||
ChatWindow(Contact* cl);
|
||||
|
||||
virtual void ShowWindow();
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
void AvoidFocus(bool avoid);
|
||||
private:
|
||||
BTextView* fSendView;
|
||||
ContactLinker* fContactLinker;
|
||||
Contact* fContact;
|
||||
CayaRenderView* fReceiveView;
|
||||
BStringView* fStatus;
|
||||
BTextView* fPersonalMessage;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Andrea Anzani, andrea.anzani@gmail.com
|
||||
* Dario Casalinuovo
|
||||
*/
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
|
||||
#include <libinterface/BitmapUtils.h>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
ContactLinker::ContactLinker(BString id, BMessenger msgn)
|
||||
Contact::Contact(BString id, BMessenger msgn)
|
||||
:
|
||||
fChatWindow(NULL),
|
||||
fID(id),
|
||||
|
@ -44,7 +44,7 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
|
|||
|
||||
|
||||
ChatWindow*
|
||||
ContactLinker::GetChatWindow()
|
||||
Contact::GetChatWindow()
|
||||
{
|
||||
if (fChatWindow == NULL)
|
||||
CreateChatWindow();
|
||||
|
@ -53,7 +53,7 @@ ContactLinker::GetChatWindow()
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::DeleteWindow()
|
||||
Contact::DeleteWindow()
|
||||
{
|
||||
if (fChatWindow != NULL) {
|
||||
if (fChatWindow->Lock()) {
|
||||
|
@ -67,7 +67,7 @@ ContactLinker::DeleteWindow()
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::ShowWindow(bool typing, bool userAction)
|
||||
Contact::ShowWindow(bool typing, bool userAction)
|
||||
{
|
||||
if (fChatWindow == NULL)
|
||||
CreateChatWindow();
|
||||
|
@ -96,7 +96,7 @@ ContactLinker::ShowWindow(bool typing, bool userAction)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::HideWindow()
|
||||
Contact::HideWindow()
|
||||
{
|
||||
if ((fChatWindow != NULL) && !fChatWindow->IsHidden())
|
||||
fChatWindow->Hide();
|
||||
|
@ -104,7 +104,7 @@ ContactLinker::HideWindow()
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::ShowPopUp(BPoint where)
|
||||
Contact::ShowPopUp(BPoint where)
|
||||
{
|
||||
if (fPopUp == NULL) {
|
||||
fPopUp = new ContactPopUp(this);
|
||||
|
@ -117,7 +117,7 @@ ContactLinker::ShowPopUp(BPoint where)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::HidePopUp()
|
||||
Contact::HidePopUp()
|
||||
{
|
||||
if ((fPopUp != NULL) && !fPopUp->IsHidden())
|
||||
fPopUp->Hide();
|
||||
|
@ -125,7 +125,7 @@ ContactLinker::HidePopUp()
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::DeletePopUp()
|
||||
Contact::DeletePopUp()
|
||||
{
|
||||
if (fPopUp == NULL)
|
||||
return;
|
||||
|
@ -139,81 +139,81 @@ ContactLinker::DeletePopUp()
|
|||
|
||||
|
||||
RosterItem*
|
||||
ContactLinker::GetRosterItem() const
|
||||
Contact::GetRosterItem() const
|
||||
{
|
||||
return fRosterItem;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetId() const
|
||||
Contact::GetId() const
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
|
||||
BMessenger
|
||||
ContactLinker::Messenger() const
|
||||
Contact::Messenger() const
|
||||
{
|
||||
return fMessenger;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContactLinker::SetMessenger(BMessenger messenger)
|
||||
Contact::SetMessenger(BMessenger messenger)
|
||||
{
|
||||
fMessenger = messenger;
|
||||
}
|
||||
|
||||
|
||||
ProtocolLooper*
|
||||
ContactLinker::GetProtocolLooper() const
|
||||
Contact::GetProtocolLooper() const
|
||||
{
|
||||
return fLooper;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetName() const
|
||||
Contact::GetName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
ContactLinker::AvatarBitmap() const
|
||||
Contact::AvatarBitmap() const
|
||||
{
|
||||
return fAvatarBitmap;
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
ContactLinker::ProtocolBitmap() const
|
||||
Contact::ProtocolBitmap() const
|
||||
{
|
||||
CayaProtocol* protocol = fLooper->Protocol();
|
||||
CayaProtocolAddOn* addOn
|
||||
= ProtocolManager::Get()->ProtocolAddOn(protocol->Signature());
|
||||
|
||||
return addOn->Icon();
|
||||
return addOn->ProtoIcon();
|
||||
}
|
||||
|
||||
|
||||
CayaStatus
|
||||
ContactLinker::GetNotifyStatus() const
|
||||
Contact::GetNotifyStatus() const
|
||||
{
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ContactLinker::GetNotifyPersonalStatus() const
|
||||
Contact::GetNotifyPersonalStatus() const
|
||||
{
|
||||
return fPersonalStatus;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
|
||||
Contact::SetProtocolLooper(ProtocolLooper* looper)
|
||||
{
|
||||
if (looper) {
|
||||
fLooper = looper;
|
||||
|
@ -229,7 +229,7 @@ ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::SetNotifyName(BString name)
|
||||
Contact::SetNotifyName(BString name)
|
||||
{
|
||||
if (fName.Compare(name) != 0) {
|
||||
fName = name;
|
||||
|
@ -239,7 +239,7 @@ ContactLinker::SetNotifyName(BString name)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::SetNotifyAvatarBitmap(BBitmap* bitmap)
|
||||
Contact::SetNotifyAvatarBitmap(BBitmap* bitmap)
|
||||
{
|
||||
if ((fAvatarBitmap != bitmap) && (bitmap != NULL)) {
|
||||
fAvatarBitmap = bitmap;
|
||||
|
@ -251,7 +251,7 @@ ContactLinker::SetNotifyAvatarBitmap(BBitmap* bitmap)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::SetNotifyStatus(CayaStatus status)
|
||||
Contact::SetNotifyStatus(CayaStatus status)
|
||||
{
|
||||
if (fStatus != status) {
|
||||
fStatus = status;
|
||||
|
@ -261,7 +261,7 @@ ContactLinker::SetNotifyStatus(CayaStatus status)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::SetNotifyPersonalStatus(BString personalStatus)
|
||||
Contact::SetNotifyPersonalStatus(BString personalStatus)
|
||||
{
|
||||
if (fPersonalStatus.Compare(personalStatus) != 0) {
|
||||
fPersonalStatus = personalStatus;
|
||||
|
@ -271,7 +271,7 @@ ContactLinker::SetNotifyPersonalStatus(BString personalStatus)
|
|||
|
||||
|
||||
void
|
||||
ContactLinker::CreateChatWindow()
|
||||
Contact::CreateChatWindow()
|
||||
{
|
||||
fChatWindow = new ChatWindow(this);
|
||||
WindowsManager::Get()->RelocateWindow(fChatWindow);
|
|
@ -20,9 +20,9 @@ class ContactPopUp;
|
|||
class ProtocolLooper;
|
||||
class RosterItem;
|
||||
|
||||
class ContactLinker : public Notifier {
|
||||
class Contact : public Notifier {
|
||||
public:
|
||||
ContactLinker(BString id, BMessenger msgn);
|
||||
Contact(BString id, BMessenger msgn);
|
||||
|
||||
ChatWindow* GetChatWindow();
|
||||
void DeleteWindow();
|
|
@ -163,7 +163,7 @@ MainWindow::MessageReceived(BMessage* message)
|
|||
|
||||
RosterMap map = fServer->RosterItems();
|
||||
for (uint32 i = 0; i < map.CountItems(); i++) {
|
||||
ContactLinker* linker = map.ValueAt(i);
|
||||
Contact* linker = map.ValueAt(i);
|
||||
RosterItem* item = linker->GetRosterItem();
|
||||
|
||||
// If the search filter has been deleted show all the items,
|
||||
|
@ -190,7 +190,7 @@ MainWindow::MessageReceived(BMessage* message)
|
|||
int index = message->FindInt32("index");
|
||||
RosterItem* ritem = ItemAt(index);
|
||||
if (ritem != NULL)
|
||||
ritem->GetContactLinker()->ShowWindow(false, true);
|
||||
ritem->GetContact()->ShowWindow(false, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
// Notify when contact is online or offline
|
||||
if (status == CAYA_ONLINE) {
|
||||
BString message;
|
||||
message << rosterItem->GetContactLinker()->GetName();
|
||||
message << rosterItem->GetContact()->GetName();
|
||||
|
||||
if (status == CAYA_ONLINE)
|
||||
message << " is available!";
|
||||
|
|
|
@ -38,7 +38,7 @@ SRCS = \
|
|||
application/CayaProtocolAddOn.cpp \
|
||||
application/CayaUtils.cpp \
|
||||
application/ChatWindow.cpp \
|
||||
application/ContactLinker.cpp \
|
||||
application/Contact.cpp \
|
||||
application/EditingFilter.cpp \
|
||||
application/ImageCache.cpp \
|
||||
application/Main.cpp \
|
||||
|
|
|
@ -42,7 +42,7 @@ Server::Server()
|
|||
void
|
||||
Server::Quit()
|
||||
{
|
||||
ContactLinker* linker = NULL;
|
||||
Contact* linker = NULL;
|
||||
|
||||
while ((linker = fRosterMap.ValueAt(0))) {
|
||||
linker->DeleteWindow();
|
||||
|
@ -126,7 +126,7 @@ Server::Filter(BMessage* message, BHandler **target)
|
|||
BString id = message->FindString("id");
|
||||
if (id.Length() > 0) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
if (found) {
|
||||
ChatWindow* win = item->GetChatWindow();
|
||||
item->ShowWindow();
|
||||
|
@ -141,7 +141,7 @@ Server::Filter(BMessage* message, BHandler **target)
|
|||
BString id = message->FindString("id");
|
||||
if (id.Length() > 0) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
|
||||
if (found)
|
||||
item->HideWindow();
|
||||
|
@ -191,7 +191,7 @@ RosterItem*
|
|||
Server::RosterItemForId(BString id)
|
||||
{
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
return item ? item->GetRosterItem() : NULL;
|
||||
}
|
||||
|
||||
|
@ -209,12 +209,12 @@ Server::ImMessage(BMessage* msg)
|
|||
BString id;
|
||||
while (msg->FindString("id", i++, &id) == B_OK) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
|
||||
if (found)
|
||||
continue;
|
||||
|
||||
item = new ContactLinker(id.String(), Looper());
|
||||
item = new Contact(id.String(), Looper());
|
||||
item->SetProtocolLooper(_LooperFromMessage(msg));
|
||||
fRosterMap.AddItem(id, item);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ Server::ImMessage(BMessage* msg)
|
|||
if (msg->FindInt32("status", &status) != B_OK)
|
||||
return B_SKIP_MESSAGE;
|
||||
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
Contact* linker = _EnsureContact(msg);
|
||||
if (!linker)
|
||||
break;
|
||||
|
||||
|
@ -257,7 +257,7 @@ Server::ImMessage(BMessage* msg)
|
|||
}
|
||||
case IM_CONTACT_INFO:
|
||||
{
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
Contact* linker = _EnsureContact(msg);
|
||||
if (!linker)
|
||||
break;
|
||||
|
||||
|
@ -276,7 +276,7 @@ Server::ImMessage(BMessage* msg)
|
|||
}
|
||||
case IM_EXTENDED_CONTACT_INFO:
|
||||
{
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
Contact* linker = _EnsureContact(msg);
|
||||
if (!linker)
|
||||
break;
|
||||
|
||||
|
@ -292,7 +292,7 @@ Server::ImMessage(BMessage* msg)
|
|||
}
|
||||
case IM_AVATAR_SET:
|
||||
{
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
Contact* linker = _EnsureContact(msg);
|
||||
if (!linker)
|
||||
break;
|
||||
|
||||
|
@ -308,7 +308,7 @@ Server::ImMessage(BMessage* msg)
|
|||
case IM_SEND_MESSAGE:
|
||||
{
|
||||
// Route this message through the appropriate ProtocolLooper
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
Contact* linker = _EnsureContact(msg);
|
||||
if (linker->GetProtocolLooper())
|
||||
linker->GetProtocolLooper()->PostMessage(msg);
|
||||
break;
|
||||
|
@ -318,7 +318,7 @@ Server::ImMessage(BMessage* msg)
|
|||
BString id = msg->FindString("id");
|
||||
if (id.Length() > 0) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
if (found) {
|
||||
ChatWindow* win = item->GetChatWindow();
|
||||
item->ShowWindow();
|
||||
|
@ -334,7 +334,7 @@ Server::ImMessage(BMessage* msg)
|
|||
BString id = msg->FindString("id");
|
||||
if (id.Length() > 0) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
Contact* item = fRosterMap.ValueFor(id, &found);
|
||||
if (found) {
|
||||
ChatWindow* win = item->GetChatWindow();
|
||||
item->ShowWindow(true);
|
||||
|
@ -398,7 +398,6 @@ Server::ImMessage(BMessage* msg)
|
|||
CayaProtocolAddOn* addOn
|
||||
= ProtocolManager::Get()->ProtocolAddOn(protocol);
|
||||
|
||||
|
||||
BNotification notification((notification_type)type);
|
||||
notification.SetGroup(BString("Caya"));
|
||||
notification.SetTitle(title);
|
||||
|
@ -417,7 +416,7 @@ Server::ImMessage(BMessage* msg)
|
|||
}
|
||||
|
||||
|
||||
ContactLinker*
|
||||
Contact*
|
||||
Server::GetOwnContact()
|
||||
{
|
||||
return fMySelf;
|
||||
|
@ -444,21 +443,21 @@ Server::_LooperFromMessage(BMessage* message)
|
|||
}
|
||||
|
||||
|
||||
ContactLinker*
|
||||
Server::_EnsureContactLinker(BMessage* message)
|
||||
Contact*
|
||||
Server::_EnsureContact(BMessage* message)
|
||||
{
|
||||
if (!message)
|
||||
return NULL;
|
||||
|
||||
BString id = message->FindString("id");
|
||||
ContactLinker* item = NULL;
|
||||
Contact* item = NULL;
|
||||
|
||||
if (id.Length() > 0) {
|
||||
bool found = false;
|
||||
item = fRosterMap.ValueFor(id, &found);
|
||||
|
||||
if (!found) {
|
||||
item = new ContactLinker(id.String(), Looper());
|
||||
item = new Contact(id.String(), Looper());
|
||||
item->SetProtocolLooper(_LooperFromMessage(message));
|
||||
fRosterMap.AddItem(id, item);
|
||||
}
|
||||
|
@ -466,3 +465,5 @@ Server::_EnsureContactLinker(BMessage* message)
|
|||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
#include <libsupport/KeyMap.h>
|
||||
|
||||
#include "CayaConstants.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
|
||||
class CayaProtocol;
|
||||
class RosterItem;
|
||||
class ProtocolLooper;
|
||||
|
||||
typedef KeyMap<BString, ContactLinker*> RosterMap;
|
||||
typedef KeyMap<BString, Contact*> RosterMap;
|
||||
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
|
||||
|
||||
class Server: public BMessageFilter {
|
||||
|
@ -43,16 +43,16 @@ public:
|
|||
RosterItem* RosterItemForId(BString id);
|
||||
|
||||
// TODO: there should be a contact for each account.
|
||||
ContactLinker* GetOwnContact();
|
||||
Contact* GetOwnContact();
|
||||
|
||||
private:
|
||||
ProtocolLooper* _LooperFromMessage(BMessage* message);
|
||||
ContactLinker* _EnsureContactLinker(BMessage* message);
|
||||
Contact* _EnsureContact(BMessage* message);
|
||||
void _ReplicantStatusNotify(CayaStatus status);
|
||||
|
||||
RosterMap fRosterMap;
|
||||
ProtocolLoopers fLoopers;
|
||||
ContactLinker* fMySelf;
|
||||
Contact* fMySelf;
|
||||
};
|
||||
|
||||
#endif // _SERVER_H
|
||||
|
|
|
@ -24,34 +24,34 @@
|
|||
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "CayaConstants.h"
|
||||
#include "CayaRenderView.h"
|
||||
#include "CayaUtils.h"
|
||||
#include "NotifyMessage.h"
|
||||
|
||||
|
||||
ContactInfoWindow::ContactInfoWindow(ContactLinker* linker)
|
||||
ContactInfoWindow::ContactInfoWindow(Contact* linker)
|
||||
:
|
||||
BWindow(BRect(200, 200, 500, 400),
|
||||
"Contact Informations", B_FLOATING_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fContactLinker(linker)
|
||||
fContact(linker)
|
||||
{
|
||||
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
|
||||
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||
B_ALIGN_MIDDLE));
|
||||
|
||||
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
||||
fPersonalMessage->SetText(fContact->GetNotifyPersonalStatus());
|
||||
fPersonalMessage->SetExplicitMaxSize(BSize(200, 200));
|
||||
fPersonalMessage->MakeEditable(false);
|
||||
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
BString status(fContactLinker->GetName());
|
||||
status << CayaStatusToString(fContactLinker->GetNotifyStatus());
|
||||
BString status(fContact->GetName());
|
||||
status << CayaStatusToString(fContact->GetNotifyStatus());
|
||||
|
||||
status << "\n\n ID : ";
|
||||
status << fContactLinker->GetId();
|
||||
status << fContact->GetId();
|
||||
|
||||
fStatus = new BTextView("status", B_WILL_DRAW);
|
||||
fStatus->SetText(status);
|
||||
|
@ -65,7 +65,7 @@ ContactInfoWindow::ContactInfoWindow(ContactLinker* linker)
|
|||
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
||||
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
||||
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
|
||||
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
||||
fAvatar->SetBitmap(fContact->AvatarBitmap());
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
#include "CayaConstants.h"
|
||||
|
||||
class BitmapView;
|
||||
class ContactLinker;
|
||||
class Contact;
|
||||
|
||||
class ContactInfoWindow: public BWindow, public Observer {
|
||||
public:
|
||||
ContactInfoWindow(ContactLinker* linker);
|
||||
ContactInfoWindow(Contact* linker);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
private:
|
||||
BTextView* fStatus;
|
||||
ContactLinker* fContactLinker;
|
||||
Contact* fContact;
|
||||
BTextView* fPersonalMessage;
|
||||
BitmapView* fAvatar;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <libinterface/BitmapView.h>
|
||||
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "NotifyMessage.h"
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ const window_feel kMenuWindowFeel = window_feel(B_NORMAL_WINDOW_FEEL);
|
|||
const int32 kNickChanged = 'NICH';
|
||||
|
||||
|
||||
ContactPopUp::ContactPopUp(ContactLinker* contact)
|
||||
ContactPopUp::ContactPopUp(Contact* contact)
|
||||
: BWindow(BRect(0, 0, 1, 1), "ContactPopUp", B_BORDERED_WINDOW_LOOK,
|
||||
kMenuWindowFeel, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_MINIMIZABLE |
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS |
|
||||
|
|
|
@ -13,11 +13,11 @@ class BTextControl;
|
|||
class BStringView;
|
||||
|
||||
class BitmapView;
|
||||
class ContactLinker;
|
||||
class Contact;
|
||||
|
||||
class ContactPopUp : public BWindow, public Observer {
|
||||
public:
|
||||
ContactPopUp(ContactLinker* contact);
|
||||
ContactPopUp(Contact* contact);
|
||||
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
#include "CayaUtils.h"
|
||||
#include "CayaResources.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "NotifyMessage.h"
|
||||
#include "RosterItem.h"
|
||||
|
||||
|
||||
RosterItem::RosterItem(const char* name, ContactLinker* contact)
|
||||
RosterItem::RosterItem(const char* name, Contact* contact)
|
||||
: BStringItem(name),
|
||||
fBitmap(NULL),
|
||||
fStatus(CAYA_OFFLINE),
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
#include <String.h>
|
||||
|
||||
#include "CayaConstants.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "Observer.h"
|
||||
|
||||
class RosterItem : public BStringItem, public Observer {
|
||||
public:
|
||||
RosterItem(const char* name, ContactLinker* contact);
|
||||
RosterItem(const char* name, Contact* contact);
|
||||
~RosterItem();
|
||||
|
||||
bool IsVisible() const { return fVisible; }
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
void Update(BView *owner, const BFont *font);
|
||||
|
||||
ContactLinker* GetContactLinker() { return contactLinker;}
|
||||
Contact* GetContact() { return contactLinker;}
|
||||
|
||||
CayaStatus Status() const { return fStatus; }
|
||||
void SetStatus(CayaStatus status);
|
||||
|
@ -45,7 +45,7 @@ protected:
|
|||
void ObserveInteger(int32 what, int32 val);
|
||||
|
||||
private:
|
||||
ContactLinker* contactLinker;
|
||||
Contact* contactLinker;
|
||||
float fBaselineOffset;
|
||||
BString fPersonalStatus;
|
||||
CayaStatus fStatus;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "ContactInfoWindow.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "Contact.h"
|
||||
#include "RosterItem.h"
|
||||
|
||||
const int32 kAddPeople = 'ADPL';
|
||||
|
@ -33,8 +33,8 @@ compare_by_name(const void* _item1, const void* _item2)
|
|||
RosterItem* item1 = *(RosterItem**)_item1;
|
||||
RosterItem* item2 = *(RosterItem**)_item2;
|
||||
|
||||
return strcasecmp(item1->GetContactLinker()->GetName().String(),
|
||||
item2->GetContactLinker()->GetName().String());
|
||||
return strcasecmp(item1->GetContact()->GetName().String(),
|
||||
item2->GetContact()->GetName().String());
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@ RosterListView::MessageReceived(BMessage* msg)
|
|||
if (ritem == NULL)
|
||||
return;
|
||||
|
||||
_InfoWindow(ritem->GetContactLinker());
|
||||
_InfoWindow(ritem->GetContact());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ RosterListView::MessageReceived(BMessage* msg)
|
|||
{
|
||||
if (ritem == NULL)
|
||||
return;
|
||||
ContactLinker* link = ritem->GetContactLinker();
|
||||
Contact* link = ritem->GetContact();
|
||||
link->ShowWindow(false, true);
|
||||
break;
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ RosterListView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
|
|||
|
||||
// Hide previous item's popup
|
||||
if ((fPrevItem != NULL) && (fPrevItem != ritem))
|
||||
fPrevItem->GetContactLinker()->HidePopUp();
|
||||
fPrevItem->GetContact()->HidePopUp();
|
||||
|
||||
// Show current item's popup
|
||||
ritem->GetContactLinker()->ShowPopUp(ConvertToScreen(where));
|
||||
ritem->GetContact()->ShowPopUp(ConvertToScreen(where));
|
||||
|
||||
// This will be the previous item
|
||||
fPrevItem = ritem;
|
||||
|
@ -158,7 +158,7 @@ RosterListView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
|
|||
case B_EXITED_VIEW:
|
||||
// Mouse cursor leaved this view, hide last item's popup
|
||||
if (fPrevItem != NULL)
|
||||
fPrevItem->GetContactLinker()->HidePopUp();
|
||||
fPrevItem->GetContact()->HidePopUp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ RosterListView::Sort()
|
|||
|
||||
|
||||
void
|
||||
RosterListView::_InfoWindow(ContactLinker* linker)
|
||||
RosterListView::_InfoWindow(Contact* linker)
|
||||
{
|
||||
ContactInfoWindow* win = new ContactInfoWindow(linker);
|
||||
win->Show();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
class BPopUpMenu;
|
||||
|
||||
class ContactLinker;
|
||||
class Contact;
|
||||
class RosterItem;
|
||||
|
||||
class RosterListView : public BOutlineListView
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void _InfoWindow(ContactLinker* linker);
|
||||
void _InfoWindow(Contact* linker);
|
||||
|
||||
BPopUpMenu* fPopUp;
|
||||
RosterItem* fPrevItem;
|
||||
|
|
Ŝarĝante…
Reference in New Issue