本文整理汇总了C++中BNode::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BNode::GetSize方法的具体用法?C++ BNode::GetSize怎么用?C++ BNode::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNode
的用法示例。
在下文中一共展示了BNode::GetSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
void
MailDaemonApp::SendPendingMessages(BMessage* msg)
{
BVolumeRoster roster;
BVolume volume;
map<int32, send_mails_info> messages;
int32 account = -1;
if (msg->FindInt32("account", &account) != B_OK)
account = -1;
if (!msg->HasString("message_path")) {
while (roster.GetNextVolume(&volume) == B_OK) {
BQuery query;
query.SetVolume(&volume);
query.PushAttr(B_MAIL_ATTR_FLAGS);
query.PushInt32(B_MAIL_PENDING);
query.PushOp(B_EQ);
query.PushAttr(B_MAIL_ATTR_FLAGS);
query.PushInt32(B_MAIL_PENDING | B_MAIL_SAVE);
query.PushOp(B_EQ);
if (account >= 0) {
query.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
query.PushInt32(account);
query.PushOp(B_EQ);
query.PushOp(B_AND);
}
query.PushOp(B_OR);
query.Fetch();
BEntry entry;
while (query.GetNextEntry(&entry) == B_OK) {
if (_IsEntryInTrash(entry))
continue;
BNode node;
while (node.SetTo(&entry) == B_BUSY)
snooze(1000);
if (!_IsPending(node))
continue;
int32 messageAccount;
if (node.ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0,
&messageAccount, sizeof(int32)) < 0)
messageAccount = -1;
off_t size = 0;
node.GetSize(&size);
entry_ref ref;
entry.GetRef(&ref);
messages[messageAccount].files.push_back(ref);
messages[messageAccount].totalSize += size;
}
}
} else {
const char* path;
if (msg->FindString("message_path", &path) != B_OK)
return;
off_t size = 0;
if (BNode(path).GetSize(&size) != B_OK)
return;
BEntry entry(path);
entry_ref ref;
entry.GetRef(&ref);
messages[account].files.push_back(ref);
messages[account].totalSize += size;
}
map<int32, send_mails_info>::iterator iter = messages.begin();
for (; iter != messages.end(); iter++) {
OutboundProtocolThread* protocolThread = _FindOutboundProtocol(
iter->first);
if (!protocolThread)
continue;
send_mails_info& info = iter->second;
if (info.files.size() == 0)
continue;
MailProtocol* protocol = protocolThread->Protocol();
protocolThread->Lock();
protocol->SetTotalItems(info.files.size());
protocol->SetTotalItemsSize(info.totalSize);
protocolThread->Unlock();
protocolThread->SendMessages(iter->second.files, info.totalSize);
}
}