virtual std::wstring msg() { if (event_logger::noEvent != code()) return (wform(hal::app().res_wstr(code())) % msg_).str(); else return msg_; }
bool remove_empty_directories_recur(const fs::path& p, std::vector<fs::path>& dirs) { if (!fs::exists(p)) return false; bool ret = true; for (fs::directory_iterator i = fs::directory_iterator(p), e = fs::directory_iterator(); i != e; ++i) { if (!fs::is_directory(*i)) ret = false; else { if (!remove_empty_directories(*i)) ret = false; } } if (ret) { HAL_DEV_MSG(wform(L"Removing directory: %1%") % p.wstring()); dirs.push_back(p); } return ret; }
std::wstring peer_detail::to_wstring(size_t index) const { switch (index) { case ip_address_e: return ip_address; case port_e: return (wform(L"%1%") % port).str(); case country_e: return country; case speed_down_e: return to_bytes_size(speed.first, true); case speed_up_e: return to_bytes_size(speed.second, true); case seed_e: return seed ? L"Seed" : L""; case client_e: return client; case status_e: return status; default: return L"(Undefined)"; // ??? }; }
std::wstring file_details::to_wstring(size_t index) { switch (index) { case branch_e: return branch.wstring(); case filename_e: return filename.wstring(); case type_e: return L"(Undefined)"; // ??? case size_e: return to_bytes_size(size, false); case progress_e: return (wform(L"%1$.2f%%") % (static_cast<double>(progress)/size*100)).str(); case priority_e: { switch (priority) { case 0: return hal::app().res_wstr(HAL_FILE_PRIORITY_0); case 1: return hal::app().res_wstr(HAL_FILE_PRIORITY_1); case 2: return hal::app().res_wstr(HAL_FILE_PRIORITY_2); case 3: return hal::app().res_wstr(HAL_FILE_PRIORITY_3); case 4: return hal::app().res_wstr(HAL_FILE_PRIORITY_4); case 5: return hal::app().res_wstr(HAL_FILE_PRIORITY_5); case 6: return hal::app().res_wstr(HAL_FILE_PRIORITY_6); case 7: return hal::app().res_wstr(HAL_FILE_PRIORITY_7); default: return hal::app().res_wstr(HAL_FILE_PRIORITY_0); }; } default: return L"(Undefined)"; // ??? }; }
virtual std::wstring msg() { return (wform(hal::app().res_wstr(code())) % msg_).str(); }
virtual std::wstring msg() { return (wform(hal::app().res_wstr(code())) % exception_ % from_).str(); }
virtual std::wstring msg() { return (wform(hal::app().res_wstr(code())) % id_ % function_).str(); }
virtual std::wstring msg() { return (wform(hal::app().res_wstr(HAL_EVENT_XML_EXP)) % exp_ % msg_).str(); }
virtual std::wstring msg() { return (wform(L"Code %1%") % code()).str(); }
std::wstring torrent_details::to_wstring(size_t index) { switch (index) { case name_e: return name_; case state_e: return state_; case progress_e: return (wform(L"%1$.2f%%") % (completion_*100)).str(); case speed_down_e: return to_bytes_size(speed_.first, true); case speed_up_e: return to_bytes_size(speed_.second, true); case distributed_copies_e: { float copies = distributed_copies_; if (copies < 0) return L"Seeding"; else return (hal::wform(L"%1$.2f") % copies).str(); } case remaining_e: { return to_bytes_size(total_wanted_-total_wanted_done_, false); //(wform(L"%1$.2fMB") % (static_cast<float>()/(1024*1024))).str(); } case completed_e: return to_bytes_size(total_wanted_done_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_wanted_done_)/(1024*1024))).str(); case total_wanted_e: { return to_bytes_size(total_wanted_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_wanted_)/(1024*1024))).str(); } case uploaded_e: { return to_bytes_size(total_payload_uploaded_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_payload_uploaded_)/(1024*1024))).str(); } case downloaded_e: { return to_bytes_size(total_payload_downloaded_, false); //(wform(L"%1$.2fMB") % (static_cast<float>(total_payload_downloaded_)/(1024*1024))).str(); } case peers_e: return (wform(L"%1% (%2%)") % connected_peers_ % peers_).str(); case seeds_e: return (wform(L"%1% (%2%)") % connected_seeds_ % seeds_).str(); case ratio_e: { float ratio = (total_payload_downloaded_) ? static_cast<float>(total_payload_uploaded_) / static_cast<float>(total_payload_downloaded_) : 0; return (wform(L"%1$.2f") % ratio).str(); } case eta_e: { if (!estimated_time_left_.is_special()) return hal::from_utf8( boost::posix_time::to_simple_string(estimated_time_left_)); else return app().res_wstr(HAL_INF); } case tracker: return currentTracker_; case update_tracker_in_e: { if (!update_tracker_in_.is_special()) return from_utf8( boost::posix_time::to_simple_string(update_tracker_in_)); else return app().res_wstr(HAL_INF); } case active_time_e: { if (!active_.is_special()) return from_utf8( boost::posix_time::to_simple_string(active_)); else return app().res_wstr(HAL_INF); } case seeding_time_e: { if (!seeding_.is_special()) return from_utf8( boost::posix_time::to_simple_string(seeding_)); else return app().res_wstr(HAL_INF); } case start_time_e: { if (!start_time_.is_special()) return from_utf8( boost::posix_time::to_simple_string(start_time_)); else return app().res_wstr(IDS_NA); } case finish_time_e: { if (!finish_time_.is_special()) return from_utf8( boost::posix_time::to_simple_string(finish_time_)); else return app().res_wstr(IDS_NA); } case queue_position_e: { if (queue_position_ != -1) return (wform(L"%1%") % queue_position_).str(); else return app().res_wstr(IDS_NA); } case managed_e: return managed_ ? L"Yes" : L"No"; case uuid_e: { std::wstringstream ss; ss << uuid_; return ss.str(); } case hash_e: return hash_; default: return L"(Undefined)"; // ??? }; }