* More NULL checks for ContactLinkers.

* When you edit an account in the preferences dialog, this is not readded to the list anymore and so its login is not triggered another time.
This commit is contained in:
plfiorini 2010-05-30 04:28:04 +00:00
parent 9d075c91a0
commit 95657d52ba
5 changed files with 29 additions and 23 deletions

View File

@ -240,6 +240,7 @@ MainWindow::ImMessage(BMessage* msg)
} }
case IM_AVATAR_SET: case IM_AVATAR_SET:
case IM_CONTACT_INFO: case IM_CONTACT_INFO:
case IM_EXTENDED_CONTACT_INFO:
{ {
RosterItem* rosterItem RosterItem* rosterItem
= fServer->RosterItemForId(msg->FindString("id")); = fServer->RosterItemForId(msg->FindString("id"));

View File

@ -219,15 +219,18 @@ Server::ImMessage(BMessage* msg)
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
ContactLinker* linker = _EnsureContactLinker(msg); ContactLinker* linker = _EnsureContactLinker(msg);
if (linker) { if (!linker)
break;
linker->SetNotifyStatus((CayaStatus)status); linker->SetNotifyStatus((CayaStatus)status);
linker->SetNotifyPersonalStatus(msg->FindString("message")); linker->SetNotifyPersonalStatus(msg->FindString("message"));
}
break; break;
} }
case IM_CONTACT_INFO: case IM_CONTACT_INFO:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); ContactLinker* linker = _EnsureContactLinker(msg);
if (!linker)
break;
const char* name = NULL; const char* name = NULL;
@ -239,9 +242,11 @@ Server::ImMessage(BMessage* msg)
case IM_EXTENDED_CONTACT_INFO: case IM_EXTENDED_CONTACT_INFO:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); ContactLinker* linker = _EnsureContactLinker(msg);
if (!linker)
break;
if (linker->GetName().Length() > 0) if (linker->GetName().Length() > 0)
return result; break;
const char* name = NULL; const char* name = NULL;
@ -253,17 +258,16 @@ Server::ImMessage(BMessage* msg)
case IM_AVATAR_SET: case IM_AVATAR_SET:
{ {
ContactLinker* linker = _EnsureContactLinker(msg); ContactLinker* linker = _EnsureContactLinker(msg);
if (!linker)
break;
entry_ref ref; entry_ref ref;
if (linker) {
if (msg->FindRef("ref", &ref) == B_OK) { if (msg->FindRef("ref", &ref) == B_OK) {
// BPath fullPath(&ref);
// BBitmap* bitmap = ImageCache::GetImage(
// BString(fullPath.Path()), BString(fullPath.Path()));
BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref); BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref);
linker->SetNotifyAvatarBitmap(bitmap); linker->SetNotifyAvatarBitmap(bitmap);
} else } else
linker->SetNotifyAvatarBitmap(NULL); linker->SetNotifyAvatarBitmap(NULL);
}
break; break;
} }
case IM_SEND_MESSAGE: { case IM_SEND_MESSAGE: {

View File

@ -84,9 +84,10 @@ AccountDialog::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case kOK: { case kOK: {
// Are we renaming settings? // Are we renaming or adding?
bool renaming = ((fAccount.Length() > 0) bool renaming = ((fAccount.Length() > 0)
&& (fAccount != fAccountName->Text())); && (fAccount != fAccountName->Text()));
bool adding = fAccount.Length() == 0;
// Rename account settings // Rename account settings
if (renaming) { if (renaming) {
@ -102,9 +103,9 @@ AccountDialog::MessageReceived(BMessage* msg)
// Save account settings // Save account settings
if (fSettings->Save(fAccountName->Text(), fTop) == B_OK) { if (fSettings->Save(fAccountName->Text(), fTop) == B_OK) {
if (fTarget) { if (fTarget && (adding || renaming)) {
BMessage* saveMsg = new BMessage(renaming BMessage* saveMsg = new BMessage(renaming
? kAccountRenamed : kAccountSaved); ? kAccountRenamed : kAccountAdded);
saveMsg->AddPointer("settings", fSettings); saveMsg->AddPointer("settings", fSettings);
if (renaming) { if (renaming) {
saveMsg->AddString("from", fAccount.String()); saveMsg->AddString("from", fAccount.String());

View File

@ -13,7 +13,7 @@ class BTextControl;
class AccountView; class AccountView;
class ProtocolSettings; class ProtocolSettings;
const uint32 kAccountSaved = 'acsd'; const uint32 kAccountAdded = 'acad';
const uint32 kAccountRenamed = 'acrd'; const uint32 kAccountRenamed = 'acrd';
class AccountDialog : public BWindow { class AccountDialog : public BWindow {

View File

@ -164,7 +164,7 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
} }
break; break;
} }
case kAccountSaved: case kAccountAdded:
case kAccountRenamed: { case kAccountRenamed: {
void* pointer = NULL; void* pointer = NULL;
BString account; BString account;
@ -172,7 +172,7 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
if (msg->FindPointer("settings", &pointer) != B_OK) if (msg->FindPointer("settings", &pointer) != B_OK)
return; return;
if (msg->what == kAccountSaved) { if (msg->what == kAccountAdded) {
if (msg->FindString("account", &account) != B_OK) if (msg->FindString("account", &account) != B_OK)
return; return;
} else { } else {
@ -187,7 +187,7 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
if (!settings) if (!settings)
return; return;
if (msg->what == kAccountSaved) { if (msg->what == kAccountAdded) {
// Add list item // Add list item
AccountListItem* listItem AccountListItem* listItem
= new AccountListItem(settings, account.String()); = new AccountListItem(settings, account.String());