status_t ThemesAddon::AddNames(BMessage &names) { FENTRY; BString str; if (MessageName()) str = Name(); str << " settings"; names.AddString(MessageName(), str.String()); return B_OK; }
status_t ThemesAddon::SetMyMessage(BMessage &theme, BMessage &mine) { FENTRY; status_t err; BMessage msg; if (!MessageName()) return B_NAME_NOT_FOUND; err = theme.FindMessage(MessageName(), &msg); if (err) err = theme.AddMessage(MessageName(), &mine); else err = theme.ReplaceMessage(MessageName(), &mine); return err; }
status_t ThemesAddon::MyMessage(BMessage &theme, BMessage &mine) { FENTRY; BMessage msg; status_t err = B_NAME_NOT_FOUND; if (!MessageName()) goto error; err = theme.FindMessage(MessageName(), &msg); if (err) goto error; mine = msg; return B_OK; error: return err; }
/* by default, try to find the addon's specific message * and compare them. Some addons don't add any message, * they'll have to do comparison by hand. */ status_t ThemesAddon::CompareToCurrent(BMessage &theme) { FENTRY; BMessage current, a, b; BackupCurrent(current); status_t err; if (!MessageName()) return B_OK; err = theme.FindMessage(MessageName(), &a); if (err) return err; err = current.FindMessage(MessageName(), &b); if (err) return err; if (!CompareMessages(a, b)) return 1; return B_OK; }
int Base::Print(char * stream, unsigned size, unsigned maxDepth) const { int bytesTotal = 0; int bytes = 0; if (maxDepth == 0) { bytes = snprintf(stream, size, "%s{mMembers(%u), mOptionalMembers(%u)}", MessageName(), mMembers.size(), mOptionalMembers.size()); return bytes; } bytes = snprintf(stream, size, "{"); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; return bytesTotal; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } bool printedOne = false; MemberVector_t::const_iterator iterator; for (iterator=mMembers.begin(); iterator!=mMembers.end(); iterator++) { int bytes = 0; if (printedOne) { bytes = snprintf(stream, size, ", "); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; return bytesTotal; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } } else { printedOne = true; } const MemberInfo_t & memberInfo = *iterator; bytes = memberInfo.data->Print(stream, size, maxDepth-1); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; return bytesTotal; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } } for (iterator=mOptionalMembers.begin(); iterator!=mOptionalMembers.end(); iterator++) { int bytes = 0; if (printedOne) { bytes = snprintf(stream, size, ", "); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; return bytesTotal; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } } else { printedOne = true; } const MemberInfo_t & memberInfo = *iterator; bytes = memberInfo.data->Print(stream, size, maxDepth-1); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; return bytesTotal; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } } if (!soe::FailedToPrint(bytes, size)) { bytes = snprintf(stream, size, "}"); if (soe::FailedToPrint(bytes, size)) { bytesTotal = bytes; } else { stream += bytes; size -= bytes; bytesTotal += bytes; } } return bytesTotal; }