Fix crash when msn plugin is not installed.

When the protocol looper is set we get its CayaProtocolAddOn and retrieve the protocol add-on's icon that is used as the default icon for the contact.
This commit is contained in:
plfiorini 2010-05-28 17:20:02 +00:00
parent af48b464ef
commit 12852eb377

View File

@ -13,12 +13,14 @@
#include "ContactLinker.h" #include "ContactLinker.h"
#include "ContactPopUp.h" #include "ContactPopUp.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
#include "ProtocolLooper.h"
#include "ProtocolManager.h" #include "ProtocolManager.h"
#include "RosterItem.h" #include "RosterItem.h"
#include "WindowsManager.h" #include "WindowsManager.h"
#include "CayaPreferences.h" #include "CayaPreferences.h"
ContactLinker::ContactLinker(BString id, BMessenger msgn) ContactLinker::ContactLinker(BString id, BMessenger msgn)
: :
fChatWindow(NULL), fChatWindow(NULL),
@ -32,10 +34,6 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
// Create the roster item and register it as observer // Create the roster item and register it as observer
fRosterItem = new RosterItem(id.String(), this); fRosterItem = new RosterItem(id.String(), this);
RegisterObserver(fRosterItem); RegisterObserver(fRosterItem);
// By default we use protocol icon as avatar icon
CayaProtocolAddOn* addOn = ProtocolManager::Get()->ProtocolAddOn("msn");
fAvatarBitmap = addOn->Icon();
} }
@ -145,8 +143,15 @@ ContactLinker::GetProtocolLooper() const
void void
ContactLinker::SetProtocolLooper(ProtocolLooper* looper) ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
{ {
if (looper) if (looper) {
fLooper = looper; fLooper = looper;
// By default we use protocol icon as avatar icon
CayaProtocol* protocol = fLooper->Protocol();
CayaProtocolAddOn* addOn
= ProtocolManager::Get()->ProtocolAddOn(protocol->Signature());
fAvatarBitmap = addOn->Icon();
}
} }