status_t TeamRow::_SetTo(TeamInfo* info) { fTeamInfo = *info; app_info appInfo; status_t status = be_roster->GetRunningAppInfo(fTeamInfo.TeamID(), &appInfo); if (status != B_OK) { // Not an application known to be_roster if (fTeamInfo.TeamID() == B_SYSTEM_TEAM) { // Get icon and name from kernel image system_info systemInfo; get_system_info(&systemInfo); BPath kernelPath; find_directory(B_BEOS_SYSTEM_DIRECTORY, &kernelPath); kernelPath.Append(systemInfo.kernel_name); get_ref_for_path(kernelPath.Path(), &appInfo.ref); } else BPrivate::get_app_ref(fTeamInfo.TeamID(), &appInfo.ref); } BBitmap* icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32); status = BNodeInfo::GetTrackerIcon(&appInfo.ref, icon, B_MINI_ICON); if (status != B_OK) { BMimeType genericAppType(B_APP_MIME_TYPE); status = genericAppType.GetIcon(icon, B_MINI_ICON); } if (status != B_OK) { delete icon; icon = NULL; } BString tmp; tmp << fTeamInfo.TeamID(); SetField(new BBitmapStringField(icon, fTeamInfo.Arguments()), kNameColumn); SetField(new BStringField(tmp), kIDColumn); return status; }
BBitmap* AutoIcon::Bitmap() { if (fBitmap == NULL) { fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); if (fSignature) { entry_ref ref; be_roster->FindApp (fSignature, &ref); if (BNodeInfo::GetTrackerIcon(&ref, fBitmap, B_MINI_ICON) != B_OK) { BMimeType genericAppType(B_APP_MIME_TYPE); genericAppType.GetIcon(fBitmap, B_MINI_ICON); } } if (fbits) fBitmap->SetBits(fbits, 256, 0, B_CMAP8); } return fBitmap; }
bool get_team_name_and_icon(info_pack& infoPack, bool icon) { BPath systemPath; find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath); bool nameFromArgs = false; bool tryTrackerIcon = true; for (int len = strlen(infoPack.team_info.args) - 1; len >= 0 && infoPack.team_info.args[len] == ' '; len--) { infoPack.team_info.args[len] = 0; } app_info info; status_t status = be_roster->GetRunningAppInfo(infoPack.team_info.team, &info); if (status != B_OK) { if (infoPack.team_info.team == B_SYSTEM_TEAM) { // Get icon and name from kernel image system_info systemInfo; get_system_info(&systemInfo); BPath kernelPath(systemPath); kernelPath.Append(systemInfo.kernel_name); get_ref_for_path(kernelPath.Path(), &info.ref); nameFromArgs = true; } else { #ifdef __HAIKU__ status = BPrivate::get_app_ref(infoPack.team_info.team, &info.ref); nameFromArgs = true; #else BEntry entry(infoPack.team_info.args, true); status = entry.GetRef(&info.ref); if (status != B_OK || strncmp(infoPack.team_info.args, systemPath.Path(), strlen(systemPath.Path())) != 0) nameFromArgs = true; #endif tryTrackerIcon = (status == B_OK); } } strncpy(infoPack.team_name, nameFromArgs ? infoPack.team_info.args : info.ref.name, B_PATH_NAME_LENGTH - 1); if (icon) { #ifdef __HAIKU__ infoPack.team_icon = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); #else infoPack.team_icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); #endif if (!tryTrackerIcon || BNodeInfo::GetTrackerIcon(&info.ref, infoPack.team_icon, B_MINI_ICON) != B_OK) { BMimeType genericAppType(B_APP_MIME_TYPE); status = genericAppType.GetIcon(infoPack.team_icon, B_MINI_ICON); } } else infoPack.team_icon = NULL; return true; }