Misc. tweaks, no functional change

This commit is contained in:
Jaidyn Ann 2021-08-01 06:37:25 -05:00
parent 803a2f20bd
commit 9f05ce1136
15 changed files with 46 additions and 52 deletions

View File

@ -59,6 +59,4 @@ private:
typedef KeyMap<BString, ChatCommand*> CommandMap;
#endif // CHAT_COMMAND_H

View File

@ -52,9 +52,8 @@ ImageCache::~ImageCache()
ImageCache*
ImageCache::Get()
{
if (fInstance == NULL) {
if (fInstance == NULL)
fInstance = new ImageCache();
}
return fInstance;
}
@ -103,8 +102,10 @@ ImageCache::Release()
void
ImageCache::_LoadResource(int identifier, const char* key)
{
BResources* res = ChatResources();
BBitmap* bitmap = IconFromResources(res, identifier, B_LARGE_ICON);
BResources res = ChatResources();
if (res.InitCheck() != B_OK)
return;
BBitmap* bitmap = IconFromResources(&res, identifier, B_LARGE_ICON);
if (bitmap != NULL && bitmap->IsValid() == true)
fBitmaps.AddItem(BString(key), bitmap);
}

View File

@ -89,14 +89,16 @@ ProtocolLooper::ConversationById(BString id)
void
ProtocolLooper::AddConversation(Conversation* chat)
{
fChatMap.AddItem(chat->GetId(), chat);
if (chat != NULL)
fChatMap.AddItem(chat->GetId(), chat);
}
void
ProtocolLooper::RemoveConversation(Conversation* chat)
{
fChatMap.RemoveItemFor(chat->GetId());
if (chat != NULL)
fChatMap.RemoveItemFor(chat->GetId());
}
@ -118,13 +120,16 @@ ProtocolLooper::ContactById(BString id)
void
ProtocolLooper::AddContact(Contact* contact)
{
fRosterMap.AddItem(contact->GetId(), contact);
if (contact != NULL)
fRosterMap.AddItem(contact->GetId(), contact);
}
void
ProtocolLooper::RemoveContact(Contact* contact)
{
if (contact == NULL)
return;
fRosterMap.RemoveItemFor(contact->GetId());
fUserMap.AddItem(contact->GetId(), (User*)contact);
}
@ -159,7 +164,8 @@ ProtocolLooper::UserById(BString id)
void
ProtocolLooper::AddUser(User* user)
{
fUserMap.AddItem(user->GetId(), user);
if (user != NULL)
fUserMap.AddItem(user->GetId(), user);
}
@ -187,7 +193,8 @@ ProtocolLooper::GetOwnContact()
void
ProtocolLooper::SetOwnContact(Contact* contact)
{
fMySelf = contact;
if (contact != NULL)
fMySelf = contact;
}
@ -203,7 +210,7 @@ ProtocolLooper::GetListItem()
{
if (fListItem == NULL)
fListItem = new ConversationAccountItem(fProtocol->GetName(),
fInstance);
fInstance);
return fListItem;
}

View File

@ -42,7 +42,7 @@ ProtocolTemplate::ProtocolTemplate(ChatProtocol* protocol, const char* type)
if (settingsTemplate.IsEmpty() == true) {
size_t size;
const void* buff =
ChatResources()->LoadResource(B_MESSAGE_TYPE, type, &size);
ChatResources().LoadResource(B_MESSAGE_TYPE, type, &size);
if (buff != NULL)
settingsTemplate.Unflatten((const char*)buff);

View File

@ -29,7 +29,7 @@ public:
{
}
BString fTitle;
const char* fTitle;
int32 fPerms; // Permissions afforded to role, as described above.
int32 fPriority; // 'Rank' of role, with higher being greater priority.
// I.E., a user with a priority of 11 can't kick a user

View File

@ -55,13 +55,15 @@ Server::Server()
|| fCommands.CountItems() > 0)
return;
BResources* res = ChatResources();
BResources res = ChatResources();
if (res.InitCheck() != B_OK)
return;
// Loading user pop-up items
for (int i = 0; i < 6; i++) {
size_t size;
BMessage temp;
const void* buff = res->LoadResource(B_MESSAGE_TYPE, 1100 + i, &size);
const void* buff = res.LoadResource(B_MESSAGE_TYPE, 1100 + i, &size);
temp.Unflatten((const char*)buff);
fUserItems.AddItem(new BMessage(temp));
}
@ -69,7 +71,7 @@ Server::Server()
// Loading room pop-up items
BMessage leave;
size_t leaveSize;
const void* leaveBuff = res->LoadResource(B_MESSAGE_TYPE, 1120, &leaveSize);
const void* leaveBuff = res.LoadResource(B_MESSAGE_TYPE, 1120, &leaveSize);
leave.Unflatten((const char*)leaveBuff);
fChatItems.AddItem(new BMessage(leave));
@ -77,7 +79,7 @@ Server::Server()
for (int i = 0; i < 9; i++) {
size_t size;
BMessage temp;
const void* buff = res->LoadResource(B_MESSAGE_TYPE, 1140 + i, &size);
const void* buff = res.LoadResource(B_MESSAGE_TYPE, 1140 + i, &size);
temp.Unflatten((const char*)buff);
ChatCommand* cmd = new ChatCommand(&temp);
fCommands.AddItem(cmd->GetName(), cmd);

View File

@ -95,7 +95,6 @@ TheApp::ReadyToRun()
return;
}
}
fMainWin->Start();
fMainWin->Show();
}

View File

@ -264,18 +264,18 @@ User::_SetCachedAvatar(BBitmap* bitmap)
{
_EnsureCachePath();
BFile cacheFile(fCachePath.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (cacheFile.InitCheck() != B_OK)
return;
BBitmapStream* stream = new BBitmapStream(bitmap);
BBitmapStream stream(bitmap);
BTranslatorRoster* roster = BTranslatorRoster::Default();
int32 format_count;
translator_info info;
const translation_format* formats = NULL;
roster->Identify(stream, new BMessage(), &info, 0, "image");
roster->Identify(&stream, new BMessage(), &info, 0, "image");
roster->GetOutputFormats(info.translator, &formats, &format_count);
roster->Translate(info.translator, stream, new BMessage(), &cacheFile,
roster->Translate(info.translator, &stream, NULL, &cacheFile,
formats[0].type);
}

View File

@ -79,7 +79,6 @@ protected:
UserItem* fListItem;
BString fID;
bigtime_t fInstance;
BString fName;
BString fPersonalStatus;
BBitmap* fAvatarBitmap;

View File

@ -91,23 +91,16 @@ CommandArgs(BString line)
}
BResources*
BResources
ChatResources()
{
BResources res;
image_info info;
if (our_image(info) != B_OK)
return NULL;
BFile file(info.name, B_READ_ONLY);
if (file.InitCheck() != B_OK)
return NULL;
BResources* res = new BResources(&file);
if (res->InitCheck() != B_OK) {
delete res;
return NULL;
if (our_image(info) == B_OK) {
BFile file(info.name, B_READ_ONLY);
if (file.InitCheck() == B_OK)
res.SetTo(&file);
}
return res;
}

View File

@ -29,7 +29,7 @@ bool IsCommand(BString line);
BString CommandName(BString line);
BString CommandArgs(BString line);
BResources* ChatResources();
BResources ChatResources();
const char* SettingsPath();

View File

@ -57,8 +57,8 @@ ReplicantMenuItem::IsCustom() const
void
ReplicantMenuItem::SetIcon()
{
BResources* res = ChatResources();
if (!res)
BResources res = ChatResources();
if (res.InitCheck() != B_OK)
return;
int32 num = 0;
@ -84,8 +84,6 @@ ReplicantMenuItem::SetIcon()
break;
}
BBitmap* bitmap = IconFromResources(res, num, B_MINI_ICON);
BBitmap* bitmap = IconFromResources(&res, num, B_MINI_ICON);
SetBitmap(bitmap);
delete res;
}

View File

@ -97,7 +97,6 @@ ReplicantStatusView::ReplicantStatusView(BMessage* archive)
ReplicantStatusView::~ReplicantStatusView()
{
delete fResources;
delete fCayaMsg;
delete fReplicantHandler;
delete fReplicantMenu;
@ -300,7 +299,7 @@ ReplicantStatusView::_Init()
BBitmap*
ReplicantStatusView::_GetIcon(const uint32 id)
{
BBitmap* icon = IconFromResources(fResources, id, B_MINI_ICON);
BBitmap* icon = IconFromResources(&fResources, id, B_MINI_ICON);
return icon;
}

View File

@ -63,7 +63,7 @@ private:
BBitmap* fExitMenuIcon;
BBitmap* fPreferencesIcon;
BResources* fResources;
BResources fResources;
BPopUpMenu* fReplicantMenu;

View File

@ -54,8 +54,8 @@ StatusMenuItem::IsCustom() const
void
StatusMenuItem::SetIcon()
{
BResources* res = ChatResources();
if (!res)
BResources res = ChatResources();
if (res.InitCheck() != B_OK)
return;
int32 num = 0;
@ -81,8 +81,6 @@ StatusMenuItem::SetIcon()
break;
}
BBitmap* bitmap = IconFromResources(res, num, B_MINI_ICON);
BBitmap* bitmap = IconFromResources(&res, num, B_MINI_ICON);
SetBitmap(bitmap);
delete res;
}