Changeset 437
- Timestamp:
- 05/12/08 20:17:16 (12 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/res/Halite.rc
r436 r437 538 538 MENUITEM SEPARATOR 539 539 MENUITEM "Open Download Folder",ID_LVM_DOWNLOAD_FOLDER 540 MENUITEM "Edit Download Folders",ID_LVM_EDIT_FOLDERS 540 541 END 541 542 END -
trunk/src/AddTorrentDialog.hpp
r436 r437 8 8 9 9 #define ID_ADD_TORRENT_BEGIN 11000 10 #define IDC_ADDT_DEFFLD_TEXT ID_ADD_TORRENT_BEGIN + 6 11 #define IDC_ADDT_NOTE_TEXT ID_ADD_TORRENT_BEGIN + 8 12 #define HAL_ADJUST_DLG_HOLDER ID_ADD_TORRENT_BEGIN + 9 10 #define HAL_ADJUST_DLG_HOLDER ID_ADD_TORRENT_BEGIN + 1 13 11 14 12 #ifndef RC_INVOKED … … 39 37 { Load(); } 40 38 41 ~AddTorrentDialog() { Save(); } 39 ~AddTorrentDialog() 40 { Save(); } 42 41 43 42 enum { IDD = IDD_ADD_TORRENT }; -
trunk/src/ConfigOptions.cpp
r433 r437 1 1 2 // Copyright Eóin O'Callaghan 2006 - 200 7.2 // Copyright Eóin O'Callaghan 2006 - 2008. 3 3 // Distributed under the Boost Software License, Version 1.0. 4 4 // (See accompanying file LICENSE_1_0.txt or copy at -
trunk/src/HaliteListView.cpp
r429 r437 10 10 #include "HaliteListView.hpp" 11 11 #include "HaliteWindow.hpp" 12 #include "HaliteListViewDlg.hpp" 13 12 14 #include "halTorrent.hpp" 13 15 … … 27 29 array<int, 21> widths = {100,110,60,60,60,42,45,61,45,45,45,45,45,45,45,45,45,45,45,45,45}; 28 30 array<int, 21> order = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; 29 array<bool, 21> visible = {true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}; 31 array<bool, 21> visible = {true,true,true,true,true,true,true,true,true,true,true,\ 32 true,true,true,true,true,true,true,true,true,true}; 30 33 31 34 SetDefaults(names, widths, order, visible); … … 214 217 } 215 218 219 LRESULT HaliteListViewCtrl::OnEditFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 220 { 221 HAL_DEV_MSG(L"OnEditFolders"); 222 223 hal::BitTorrent::torrent t = hal::bittorrent().get(manager_.selected()); 224 225 wstring saveDirectory = static_cast<wpath>(t.save_directory).native_file_string(); 226 wstring moveToDirectory = static_cast<wpath>(t.move_to_directory).native_file_string(); 227 bool useMoveTo = (L"" != moveToDirectory); 228 229 HaliteListViewAdjustDlg addTorrent(L"Hello", saveDirectory, moveToDirectory, useMoveTo); 230 231 if (IDOK == addTorrent.DoModal()) 232 { 233 t.save_directory = saveDirectory; 234 235 if (useMoveTo) 236 t.move_to_directory = moveToDirectory; 237 else 238 t.move_to_directory = L""; 239 } 240 241 return 0; 242 } 243 216 244 //LRESULT HaliteListViewCtrl::OnDeleteItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) 217 245 //{ -
trunk/src/HaliteListView.hpp
r436 r437 10 10 #define ID_LVM_DOWNLOAD_FOLDER HAL_MAIN_LISTVIEW_BEGIN + 1 11 11 #define ID_LVM_RECHECK HAL_MAIN_LISTVIEW_BEGIN + 2 12 #define ID_LVM_EDIT_FOLDERS HAL_MAIN_LISTVIEW_BEGIN + 3 12 13 13 14 #ifndef RC_INVOKED … … 346 347 COMMAND_ID_HANDLER(ID_LVM_REMOVE_TD, OnRemoveWipeFiles) 347 348 COMMAND_ID_HANDLER(ID_LVM_DOWNLOAD_FOLDER, OnDownloadFolder) 349 COMMAND_ID_HANDLER(ID_LVM_EDIT_FOLDERS, OnEditFolders) 348 350 349 351 CHAIN_MSG_MAP(listClass) … … 364 366 LRESULT OnRemoveWipeFiles(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); 365 367 LRESULT OnDownloadFolder(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); 368 LRESULT OnEditFolders(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); 366 369 367 370 friend class boost::serialization::access; -
trunk/src/HaliteListViewDlg.hpp
r436 r437 14 14 #define IDC_ADDT_MOVETO_BROWSE HAL_ADJUST_DLG_BEGIN + 2 15 15 #define IDC_ADDT_MOVETO_CHECK HAL_ADJUST_DLG_BEGIN + 3 16 #define IDC_ADDT_DEFFLD_TEXT HAL_ADJUST_DLG_BEGIN + 4 17 #define IDC_ADDT_NOTE_TEXT HAL_ADJUST_DLG_BEGIN + 5 16 18 17 19 #ifndef RC_INVOKED -
trunk/src/HaliteWindow.cpp
r436 r437 357 357 if (!boost::filesystem::exists(saveDirectory)) 358 358 boost::filesystem::create_directory(saveDirectory); 359 360 /* HaliteListViewAdjustDlg addTorrent(L"Hello", saveDirectory, moveToDirectory, useMoveTo); 361 362 if (IDOK != addTorrent.DoModal()) 363 return; 364 return; 365 */ 359 366 360 if (hal::config().savePrompt) 367 361 { -
trunk/src/advtabs/Torrent.cpp
r392 r437 110 110 hal::bittorrent().setTorrentLimit(torrentName, totalConnections_, uploadConnections_); 111 111 hal::bittorrent().setTorrentRatio(torrentName, ratio_); 112 113 // hal::BitTorrent::torrent t = hal::bittorrent().get(torrent->name()); 114 115 // t.ratio = ratio_; 112 116 } 113 117 -
trunk/src/global/string_conv.hpp
r429 r437 111 111 }; 112 112 113 114 115 113 template<typename str_t> 116 inline std::wstring to_wstr_shim(str_t& s)114 inline const std::wstring to_wstr_shim(str_t& s) 117 115 { 118 116 return s; … … 120 118 121 119 template<> 122 inline std::wstring to_wstr_shim<const wchar_t *const>(const wchar_t *const& s)120 inline const std::wstring to_wstr_shim<const wchar_t *const>(const wchar_t *const& s) 123 121 { 124 122 return std::wstring(s); … … 126 124 127 125 template<> 128 inline std::wstring to_wstr_shim<const wchar_t *>(const wchar_t *& s)126 inline const std::wstring to_wstr_shim<const wchar_t *>(const wchar_t *& s) 129 127 { 130 128 return std::wstring(s); … … 132 130 133 131 template<> 134 inline std::wstring to_wstr_shim<const char *>(const char *& s)132 inline const std::wstring to_wstr_shim<const char *>(const char *& s) 135 133 { 136 134 return from_utf8_safe(s); … … 138 136 139 137 template<> 140 inline std::wstring to_wstr_shim<const char *const>(const char *const& s)138 inline const std::wstring to_wstr_shim<const char *const>(const char *const& s) 141 139 { 142 140 return from_utf8_safe(s); … … 144 142 145 143 template<> 146 inline std::wstring to_wstr_shim<const std::string>(const std::string& s)144 inline const std::wstring to_wstr_shim<const std::string>(const std::string& s) 147 145 { 148 146 return from_utf8_safe(s); … … 150 148 151 149 template<> 152 inline std::wstring to_wstr_shim<std::string>(std::string& s)150 inline const std::wstring to_wstr_shim<std::string>(std::string& s) 153 151 { 154 152 return from_utf8_safe(s); … … 156 154 157 155 template<> 158 inline std::wstring to_wstr_shim<const boost::wformat>(const boost::wformat& f)156 inline const std::wstring to_wstr_shim<const boost::wformat>(const boost::wformat& f) 159 157 { 160 158 return f.str(); … … 162 160 163 161 template<> 164 inline std::wstring to_wstr_shim<boost::wformat>(boost::wformat& f)162 inline const std::wstring to_wstr_shim<boost::wformat>(boost::wformat& f) 165 163 { 166 164 return f.str(); … … 168 166 169 167 template<> 170 inline std::wstring to_wstr_shim<const boost::format>(const boost::format& f)168 inline const std::wstring to_wstr_shim<const boost::format>(const boost::format& f) 171 169 { 172 170 return from_utf8_safe(f.str()); … … 174 172 175 173 template<> 176 inline std::wstring to_wstr_shim<boost::format>(boost::format& f)174 inline const std::wstring to_wstr_shim<boost::format>(boost::format& f) 177 175 { 178 176 return from_utf8_safe(f.str()); -
trunk/src/halTorrent.cpp
r432 r437 28 28 29 29 #include "halTorrent.hpp" 30 #include "halTypes.hpp" 30 31 #include "halEvent.hpp" 31 32 #include "halSignaler.hpp" … … 73 74 } 74 75 76 template<class Archive, class String, class Traits> 77 void save(Archive& ar, const boost::filesystem::basic_path<String, Traits>& p, const unsigned int version) 78 { 79 String str = p.string(); 80 ar & BOOST_SERIALIZATION_NVP(str); 81 } 82 83 template<class Archive, class String, class Traits> 84 void load(Archive& ar, boost::filesystem::basic_path<String, Traits>& p, const unsigned int version) 85 { 86 String str; 87 ar & BOOST_SERIALIZATION_NVP(str); 88 89 p = str; 90 } 91 92 template<class Archive, class String, class Traits> 93 inline void serialize( 94 Archive & ar, 95 boost::filesystem::basic_path<String, Traits>& p, 96 const unsigned int file_version 97 ){ 98 split_free(ar, p, file_version); 99 } 100 75 101 template<class Archive, class address_type> 76 102 void serialize(Archive& ar, libtorrent::ip_range<address_type>& addr, const unsigned int version) … … 116 142 namespace hal 117 143 { 118 libtorrent::session* TorrentInternal::the_session_ = 0;119 wpath _t TorrentInternal::workingDir_;144 libtorrent::session* torrent_internal::the_session_ = 0; 145 wpath torrent_internal::workingDir_; 120 146 } 121 147 … … 123 149 { 124 150 125 namespace lbt = libtorrent; 126 namespace fs = boost::filesystem; 127 namespace pt = boost::posix_time; 128 129 typedef std::wstring wstring_t; 130 typedef std::string string_t; 131 132 typedef boost::wformat wformat_t; 133 typedef boost::format format_t; 134 135 typedef boost::filesystem::wpath wpath_t; 136 typedef boost::filesystem::path path_t; 137 138 using boost::serialization::make_nvp; 139 using boost::shared_ptr; 140 using boost::bind; 151 141 152 142 153 BitTorrent& bittorrent() … … 324 335 { 325 336 event().post(shared_ptr<EventDetail>( 326 new EventMsg((wformat _t(hal::app().res_wstr(LBT_EVENT_TORRENT_FINISHED))337 new EventMsg((wformat(hal::app().res_wstr(LBT_EVENT_TORRENT_FINISHED)) 327 338 % get(a.handle)->name()), 328 339 Event::info, a.timestamp()))); … … 334 345 { 335 346 event().post(shared_ptr<EventDetail>( 336 new EventMsg((wformat _t(hal::app().res_wstr(LBT_EVENT_TORRENT_PAUSED))347 new EventMsg((wformat(hal::app().res_wstr(LBT_EVENT_TORRENT_PAUSED)) 337 348 % get(a.handle)->name()), 338 349 Event::info, a.timestamp()))); … … 345 356 event().post(shared_ptr<EventDetail>( 346 357 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 347 wformat _t(hal::app().res_wstr(HAL_PEER_ALERT))358 wformat(hal::app().res_wstr(HAL_PEER_ALERT)) 348 359 % hal::from_utf8_safe(a.msg()) 349 360 % hal::from_utf8_safe(a.ip.address().to_string())) … … 355 366 event().post(shared_ptr<EventDetail>( 356 367 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 357 wformat _t(hal::app().res_wstr(HAL_PEER_BAN_ALERT))368 wformat(hal::app().res_wstr(HAL_PEER_BAN_ALERT)) 358 369 % get(a.handle)->name() 359 370 % hal::from_utf8_safe(a.ip.address().to_string())) … … 365 376 event().post(shared_ptr<EventDetail>( 366 377 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 367 wformat _t(hal::app().res_wstr(HAL_HASH_FAIL_ALERT))378 wformat(hal::app().res_wstr(HAL_HASH_FAIL_ALERT)) 368 379 % get(a.handle)->name() 369 380 % a.piece_index) … … 375 386 event().post(shared_ptr<EventDetail>( 376 387 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 377 wformat _t(hal::app().res_wstr(HAL_URL_SEED_ALERT))388 wformat(hal::app().res_wstr(HAL_URL_SEED_ALERT)) 378 389 % get(a.handle)->name() 379 390 % hal::from_utf8_safe(a.url) … … 386 397 event().post(shared_ptr<EventDetail>( 387 398 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 388 wformat _t(hal::app().res_wstr(HAL_TRACKER_WARNING_ALERT))399 wformat(hal::app().res_wstr(HAL_TRACKER_WARNING_ALERT)) 389 400 % get(a.handle)->name() 390 401 % hal::from_utf8_safe(a.msg())) … … 395 406 { 396 407 event().post(shared_ptr<EventDetail>( 397 new EventMsg((wformat _t(hal::app().res_wstr(HAL_TRACKER_ANNOUNCE_ALERT))408 new EventMsg((wformat(hal::app().res_wstr(HAL_TRACKER_ANNOUNCE_ALERT)) 398 409 % get(a.handle)->name()), 399 410 Event::info, a.timestamp()))); … … 404 415 event().post(shared_ptr<EventDetail>( 405 416 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 406 wformat _t(hal::app().res_wstr(HAL_TRACKER_ALERT))417 wformat(hal::app().res_wstr(HAL_TRACKER_ALERT)) 407 418 % get(a.handle)->name() 408 419 % hal::from_utf8_safe(a.msg()) … … 416 427 event().post(shared_ptr<EventDetail>( 417 428 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 418 wformat _t(hal::app().res_wstr(HAL_TRACKER_REPLY_ALERT))429 wformat(hal::app().res_wstr(HAL_TRACKER_REPLY_ALERT)) 419 430 % get(a.handle)->name() 420 431 % hal::from_utf8_safe(a.msg()) … … 427 438 event().post(shared_ptr<EventDetail>( 428 439 new EventGeneral(lbtAlertToHalEvent(a.severity()), a.timestamp(), 429 wformat _t(hal::app().res_wstr(HAL_FAST_RESUME_ALERT))440 wformat(hal::app().res_wstr(HAL_FAST_RESUME_ALERT)) 430 441 % get(a.handle)->name() 431 442 % hal::from_utf8_safe(a.msg())) … … 437 448 event().post(shared_ptr<EventDetail>( 438 449 new EventGeneral(Event::debug, a.timestamp(), 439 wformat _t(hal::app().res_wstr(HAL_PIECE_FINISHED_ALERT))450 wformat(hal::app().res_wstr(HAL_PIECE_FINISHED_ALERT)) 440 451 % get(a.handle)->name() 441 452 % a.piece_index) … … 447 458 event().post(shared_ptr<EventDetail>( 448 459 new EventGeneral(Event::debug, a.timestamp(), 449 wformat _t(hal::app().res_wstr(HAL_BLOCK_FINISHED_ALERT))460 wformat(hal::app().res_wstr(HAL_BLOCK_FINISHED_ALERT)) 450 461 % get(a.handle)->name() 451 462 % a.block_index … … 458 469 event().post(shared_ptr<EventDetail>( 459 470 new EventGeneral(Event::debug, a.timestamp(), 460 wformat _t(hal::app().res_wstr(HAL_BLOCK_DOWNLOADING_ALERT))471 wformat(hal::app().res_wstr(HAL_BLOCK_DOWNLOADING_ALERT)) 461 472 % get(a.handle)->name() 462 473 % a.block_index … … 478 489 event().post(shared_ptr<EventDetail>( 479 490 new EventGeneral(Event::info, a.timestamp(), 480 wformat _t(hal::app().res_wstr(HAL_LISTEN_FAILED_ALERT))491 wformat(hal::app().res_wstr(HAL_LISTEN_FAILED_ALERT)) 481 492 % hal::from_utf8_safe(a.msg())) 482 493 ) ); … … 488 499 event().post(shared_ptr<EventDetail>( 489 500 new EventGeneral(Event::info, a.timestamp(), 490 wformat _t(hal::app().res_wstr(HAL_LISTEN_SUCCEEDED_ALERT))501 wformat(hal::app().res_wstr(HAL_LISTEN_SUCCEEDED_ALERT)) 491 502 % hal::from_utf8_safe(a.msg())) 492 503 ) ); … … 499 510 event().post(shared_ptr<EventDetail>( 500 511 new EventGeneral(Event::debug, a.timestamp(), 501 wformat _t(hal::app().res_wstr(HAL_IPFILTER_ALERT))512 wformat(hal::app().res_wstr(HAL_IPFILTER_ALERT)) 502 513 % hal::from_utf8_safe(a.ip.to_string()) 503 514 % hal::from_utf8_safe(a.msg())) … … 515 526 BitTorrent_impl& bit_impl_; 516 527 517 TorrentInternal_ptr get(lbt::torrent_handle h) const528 torrent_internal_ptr get(lbt::torrent_handle h) const 518 529 { 519 530 return bit_impl_.theTorrents.get(from_utf8_safe(h.get_torrent_info().name())); … … 593 604 float defTorrentUpload() { return defTorrentUpload_; } 594 605 595 const wpath _tworkingDir() { return workingDirectory; };606 const wpath workingDir() { return workingDirectory; }; 596 607 597 608 private: … … 612 623 dht_on_(false) 613 624 { 614 TorrentInternal::the_session_ = &theSession;615 TorrentInternal::workingDir_ = workingDir();625 torrent_internal::the_session_ = &theSession; 626 torrent_internal::workingDir_ = workingDir(); 616 627 617 628 theSession.set_severity_level(lbt::alert::debug); … … 640 651 TorrentMap torrents; 641 652 boost::archive::xml_wiarchive ia(ifs); 642 ia >> make_nvp("torrents", torrents);653 ia >> slz::make_nvp("torrents", torrents); 643 654 644 655 theTorrents = torrents; … … 646 657 647 658 event().post(shared_ptr<EventDetail>(new EventMsg( 648 wformat _t(L"Total %1%.") % theTorrents.size())));659 wformat(L"Total %1%.") % theTorrents.size()))); 649 660 650 661 fs::rename(workingDirectory/L"Torrents.xml", workingDirectory/L"Torrents.xml.safe.to.delete"); … … 671 682 672 683 { lbt::session_settings settings = theSession.settings(); 673 settings.user_agent = string _t("Halite ") + HALITE_VERSION_STRING;684 settings.user_agent = string("Halite ") + HALITE_VERSION_STRING; 674 685 theSession.set_settings(settings); 675 686 } … … 692 703 i != e; ++i) 693 704 { 694 HAL_DEV_MSG(wformat _t(L"file path: %1%, size: %2%") % (*i).first % (*i).second);705 HAL_DEV_MSG(wformat(L"file path: %1%, size: %2%") % (*i).first % (*i).second); 695 706 t_info->add_file(to_utf8((*i).first.string()), (*i).second); 696 707 } … … 706 717 i != e; ++i) 707 718 { 708 HAL_DEV_MSG(wformat _t(L"URL: %1%, Tier: %2%") % (*i).url % (*i).tier);719 HAL_DEV_MSG(wformat(L"URL: %1%, Tier: %2%") % (*i).url % (*i).tier); 709 720 t_info->add_tracker(to_utf8((*i).url), (*i).tier); 710 721 } … … 714 725 i != e; ++i) 715 726 { 716 HAL_DEV_MSG(wformat _t(L"URL: %1%") % (*i).url);727 HAL_DEV_MSG(wformat(L"URL: %1%") % (*i).url); 717 728 t_info->add_url_seed(to_utf8((*i).url)); 718 729 } … … 722 733 i != e; ++i) 723 734 { 724 HAL_DEV_MSG(wformat _t(L"URL: %1%, port: %2%") % (*i).url % (*i).port);735 HAL_DEV_MSG(wformat(L"URL: %1%, port: %2%") % (*i).url % (*i).port); 725 736 t_info->add_node(hal::make_pair(to_utf8((*i).url), (*i).port)); 726 737 } … … 748 759 lbt::entry e = t_info->create_torrent(); 749 760 halencode(out_file, e); 750 }751 catch(const std::exception& e)752 {753 event().post(shared_ptr<EventDetail>(754 new EventStdException(Event::fatal, e, L"create_torrent")));755 }756 } 757 758 std::pair<lbt::entry, lbt::entry> prepTorrent(wpath _t filename, wpath_tsaveDirectory);759 void removalThread( TorrentInternal_ptr pIT, bool wipeFiles);761 } 762 catch(const std::exception& e) 763 { 764 event().post(shared_ptr<EventDetail>( 765 new EventStdException(Event::fatal, e, L"create_torrent"))); 766 } 767 } 768 769 std::pair<lbt::entry, lbt::entry> prepTorrent(wpath filename, wpath saveDirectory); 770 void removalThread(torrent_internal_ptr pIT, bool wipeFiles); 760 771 761 772 lbt::session theSession; … … 764 775 bool keepChecking_; 765 776 766 static wpath _tworkingDirectory;777 static wpath workingDirectory; 767 778 ini_file bittorrentIni; 768 779 TorrentManager theTorrents; … … 790 801 }; 791 802 792 wpath _tBitTorrent_impl::workingDirectory = hal::app().working_directory();803 wpath BitTorrent_impl::workingDirectory = hal::app().working_directory(); 793 804 794 805 BitTorrent::BitTorrent() : … … 828 839 } 829 840 841 BitTorrent::torrent BitTorrent::get_wstr(const std::wstring& filename) 842 { 843 return BitTorrent::torrent(pimpl->theTorrents.get(filename)); 844 } 845 830 846 bool BitTorrent::listenOn(std::pair<int, int> const& range) 831 847 { … … 957 973 958 974 event().post(shared_ptr<EventDetail>(new EventMsg( 959 wformat _t(L"Set Timeouts, peer %1%, tracker %2%") % peers % tracker)));975 wformat(L"Set Timeouts, peer %1%, tracker %2%") % peers % tracker))); 960 976 } 961 977 … … 966 982 967 983 event().post(shared_ptr<EventDetail>(new EventMsg( 968 wformat _t(L"Set connections totals %1% and uploads %2%.")984 wformat(L"Set connections totals %1% and uploads %2%.") 969 985 % maxConn % maxUpload))); 970 986 } … … 978 994 979 995 event().post(shared_ptr<EventDetail>(new EventMsg( 980 wformat _t(L"Set session rates at download %1% and upload %2%.")996 wformat(L"Set session rates at download %1% and upload %2%.") 981 997 % pimpl->theSession.download_rate_limit() % pimpl->theSession.upload_rate_limit()))); 982 998 } … … 1093 1109 hal::event().post(shared_ptr<hal::EventDetail>( 1094 1110 new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified, 1095 (wformat _t(hal::app().res_wstr(HAL_INCORRECT_ENCODING_LEVEL)) % enc_level).str())));1111 (wformat(hal::app().res_wstr(HAL_INCORRECT_ENCODING_LEVEL)) % enc_level).str()))); 1096 1112 } 1097 1113 … … 1112 1128 hal::event().post(shared_ptr<hal::EventDetail>( 1113 1129 new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified, 1114 (wformat _t(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str())));1130 (wformat(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str()))); 1115 1131 } 1116 1132 … … 1131 1147 hal::event().post(shared_ptr<hal::EventDetail>( 1132 1148 new hal::EventGeneral(hal::Event::warning, hal::Event::unclassified, 1133 (wformat _t(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str())));1149 (wformat(hal::app().res_wstr(HAL_INCORRECT_CONNECT_POLICY)) % in_enc_policy).str()))); 1134 1150 } 1135 1151 … … 1211 1227 boost::smatch m; 1212 1228 1213 string _tip_address_line;1229 string ip_address_line; 1214 1230 while (!std::getline(ifs, ip_address_line).eof()) 1215 1231 { … … 1227 1243 if (boost::regex_match(ip_address_line, m, reg)) 1228 1244 { 1229 string _tfirst = m[1];1230 string _tlast = m[2];1245 string first = m[1]; 1246 string last = m[2]; 1231 1247 1232 1248 if (octalFix) … … 1234 1250 if (boost::regex_match(first, m, ip_reg)) 1235 1251 { 1236 first = ((m.length(1) != 0) ? m[1] : string _t("0")) + "." +1237 ((m.length(2) != 0) ? m[2] : string _t("0")) + "." +1238 ((m.length(3) != 0) ? m[3] : string _t("0")) + "." +1239 ((m.length(4) != 0) ? m[4] : string _t("0"));1252 first = ((m.length(1) != 0) ? m[1] : string("0")) + "." + 1253 ((m.length(2) != 0) ? m[2] : string("0")) + "." + 1254 ((m.length(3) != 0) ? m[3] : string("0")) + "." + 1255 ((m.length(4) != 0) ? m[4] : string("0")); 1240 1256 } 1241 1257 if (boost::regex_match(last, m, ip_reg)) 1242 1258 { 1243 last = ((m.length(1) != 0) ? m[1] : string _t("0")) + "." +1244 ((m.length(2) != 0) ? m[2] : string _t("0")) + "." +1245 ((m.length(3) != 0) ? m[3] : string _t("0")) + "." +1246 ((m.length(4) != 0) ? m[4] : string _t("0"));1259 last = ((m.length(1) != 0) ? m[1] : string("0")) + "." + 1260 ((m.length(2) != 0) ? m[2] : string("0")) + "." + 1261 ((m.length(3) != 0) ? m[3] : string("0")) + "." + 1262 ((m.length(4) != 0) ? m[4] : string("0")); 1247 1263 } 1248 1264 } … … 1257 1273 hal::event().post(shared_ptr<hal::EventDetail>( 1258 1274 new hal::EventDebug(hal::Event::info, 1259 from_utf8((format _t("Invalid IP range: %1%-%2%.") % first % last).str()))));1275 from_utf8((format("Invalid IP range: %1%-%2%.") % first % last).str())))); 1260 1276 } 1261 1277 } … … 1299 1315 1300 1316 event().post(shared_ptr<EventDetail>(new EventMsg( 1301 wformat _t(L"Set half-open connections limit to %1%.") % pimpl->theSession.max_half_open_connections())));1317 wformat(L"Set half-open connections limit to %1%.") % pimpl->theSession.max_half_open_connections()))); 1302 1318 } 1303 1319 … … 1308 1324 1309 1325 event().post(shared_ptr<EventDetail>(new EventMsg( 1310 wformat _t(L"Set torrent connections total %1% and uploads %2%.") % maxConn % maxUpload)));1326 wformat(L"Set torrent connections total %1% and uploads %2%.") % maxConn % maxUpload))); 1311 1327 1312 1328 pimpl->defTorrentDownload_ = download; … … 1314 1330 1315 1331 event().post(shared_ptr<EventDetail>(new EventMsg( 1316 wformat _t(L"Set torrent default rates at %1$.2fkb/s down and %2$.2fkb/s upload.") % download % upload)));1317 } 1318 1319 std::pair<lbt::entry, lbt::entry> BitTorrent_impl::prepTorrent(wpath _t filename, wpath_tsaveDirectory)1332 wformat(L"Set torrent default rates at %1$.2fkb/s down and %2$.2fkb/s upload.") % download % upload))); 1333 } 1334 1335 std::pair<lbt::entry, lbt::entry> BitTorrent_impl::prepTorrent(wpath filename, wpath saveDirectory) 1320 1336 { 1321 1337 lbt::entry metadata = haldecode(filename); 1322 1338 lbt::torrent_info info(metadata); 1323 1339 1324 wstring _ttorrentName = hal::from_utf8_safe(info.name());1340 wstring torrentName = hal::from_utf8_safe(info.name()); 1325 1341 if (!boost::find_last(torrentName, L".torrent")) 1326 1342 torrentName += L".torrent"; 1327 1343 1328 wpath _ttorrentFilename = torrentName;1329 const wpath _tresumeFile = workingDirectory/L"resume"/torrentFilename.leaf();1344 wpath torrentFilename = torrentName; 1345 const wpath resumeFile = workingDirectory/L"resume"/torrentFilename.leaf(); 1330 1346 1331 1347 // vvv Handle old naming style! 1332 const wpath _toldResumeFile = workingDirectory/L"resume"/filename.leaf();1348 const wpath oldResumeFile = workingDirectory/L"resume"/filename.leaf(); 1333 1349 1334 1350 if (filename.leaf() != torrentFilename.leaf() && exists(oldResumeFile)) … … 1365 1381 } 1366 1382 1367 void BitTorrent::addTorrent(wpath _t file, wpath_tsaveDirectory, bool startStopped, bool compactStorage,1383 void BitTorrent::addTorrent(wpath file, wpath saveDirectory, bool startStopped, bool compactStorage, 1368 1384 boost::filesystem::wpath moveToDirectory, bool useMoveTo) 1369 1385 { 1370 1386 try 1371 1387 { 1372 TorrentInternal_ptr TIp;1388 torrent_internal_ptr TIp; 1373 1389 1374 1390 std::pair<std::string, std::string> names = extract_names(file); 1375 wstring _txml_name = from_utf8(names.first) + L".xml";1391 wstring xml_name = from_utf8(names.first) + L".xml"; 1376 1392 1377 1393 if (fs::exists(file.branch_path()/xml_name)) … … 1386 1402 { 1387 1403 if (useMoveTo) 1388 TIp.reset(new TorrentInternal(file, saveDirectory, compactStorage, moveToDirectory));1404 TIp.reset(new torrent_internal(file, saveDirectory, compactStorage, moveToDirectory)); 1389 1405 else 1390 TIp.reset(new TorrentInternal(file, saveDirectory, compactStorage));1406 TIp.reset(new torrent_internal(file, saveDirectory, compactStorage)); 1391 1407 1392 1408 TIp->setTransferSpeed(bittorrent().defTorrentDownload(), bittorrent().defTorrentUpload()); … … 1399 1415 if (p.second) 1400 1416 { 1401 TorrentInternal_ptr me = pimpl->theTorrents.get(TIp->name());1417 torrent_internal_ptr me = pimpl->theTorrents.get(TIp->name()); 1402 1418 1403 1419 if (!startStopped) … … 1429 1445 } 1430 1446 1431 void BitTorrent::newTorrent(wpath _t filename, wpath_tfiles)1447 void BitTorrent::newTorrent(wpath filename, wpath files) 1432 1448 { 1433 1449 /* try … … 1479 1495 } 1480 1496 1481 const TorrentDetails& BitTorrent::updateTorrentDetails(const wstring _t& focused, const std::set<wstring_t>& selected)1497 const TorrentDetails& BitTorrent::updateTorrentDetails(const wstring& focused, const std::set<wstring>& selected) 1482 1498 { 1483 1499 try { … … 1490 1506 for (TorrentManager::torrentByName::iterator i=pimpl->theTorrents.begin(), e=pimpl->theTorrents.end(); i != e; ++i) 1491 1507 { 1492 wstring _tutf8Name = (*i).torrent->name();1508 wstring utf8Name = (*i).torrent->name(); 1493 1509 TorrentDetail_ptr pT = (*i).torrent->getTorrentDetail_ptr(); 1494 1510 … … 1518 1534 for (TorrentManager::torrentByName::iterator i=pimpl->theTorrents.begin(), e=pimpl->theTorrents.end(); i != e;) 1519 1535 { 1520 wpath _t file = wpath_t(pimpl->workingDirectory)/L"torrents"/(*i).torrent->filename();1536 wpath file = wpath(pimpl->workingDirectory)/L"torrents"/(*i).torrent->filename(); 1521 1537 1522 1538 if (exists(file)) … … 1579 1595 if ((*i).torrent->inSession()) 1580 1596 { 1581 // HAL_DEV_MSG(wformat _t(L"Internalling pausing writeData=%1%") % writeData);1597 // HAL_DEV_MSG(wformat(L"Internalling pausing writeData=%1%") % writeData); 1582 1598 (*i).torrent->handle().pause(); // Internal pause, not registered in Torrents.xml 1583 1599 } … … 1620 1636 client(hal::from_utf8_safe(peerInfo.client)) 1621 1637 { 1622 std::vector<wstring _t> status_vec;1638 std::vector<wstring> status_vec; 1623 1639 1624 1640 #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES 1625 1641 if (peerInfo.country[0] != 0 && peerInfo.country[1] != 0) 1626 country = (wformat _t(L"(%1%)") % hal::from_utf8_safe(string_t(peerInfo.country, 2))).str().c_str();1642 country = (wformat(L"(%1%)") % hal::from_utf8_safe(string(peerInfo.country, 2))).str().c_str(); 1627 1643 #endif 1628 1644 … … 1820 1836 } 1821 1837 1822 void BitTorrent_impl::removalThread( TorrentInternal_ptr pIT, bool wipeFiles)1838 void BitTorrent_impl::removalThread(torrent_internal_ptr pIT, bool wipeFiles) 1823 1839 { 1824 1840 try { … … 1845 1861 , end(m_info.end_files(true)); i != end; ++i) 1846 1862 { 1847 std::string p = (hal:: to_utf8(pIT->saveDirectory()) / i->path).string();1863 std::string p = (hal::path_to_utf8(pIT->saveDirectory()) / i->path).string(); 1848 1864 fs::path bp = i->path.branch_path(); 1849 1865 … … 1853 1869 { 1854 1870 std::pair<std::set<std::string>::iterator, bool> ret = 1855 directories.insert((hal:: to_utf8(pIT->saveDirectory()) / bp).string());1871 directories.insert((hal::path_to_utf8(pIT->saveDirectory()) / bp).string()); 1856 1872 bp = bp.branch_path(); 1857 1873 } … … 1883 1899 try { 1884 1900 1885 TorrentInternal_ptr pTI = pimpl->theTorrents.get(filename);1901 torrent_internal_ptr pTI = pimpl->theTorrents.get(filename); 1886 1902 lbt::torrent_handle handle = pTI->handle(); 1887 1903 pimpl->theTorrents.erase(filename); … … 1915 1931 try { 1916 1932 1917 TorrentInternal_ptr pTI = pimpl->theTorrents.get(filename);1933 torrent_internal_ptr pTI = pimpl->theTorrents.get(filename); 1918 1934 lbt::torrent_handle handle = pTI->handle(); 1919 1935 pimpl->theTorrents.erase(filename); … … 1966 1982 } 1967 1983 1968 void BitTorrent::torrent::set_ratio(float new_ratio) 1969 { 1970 try { 1971 1972 ptr->setRatio(ratio); 1984 1985 BitTorrent::torrent::torrent(boost::shared_ptr<torrent_internal> p) : 1986 ptr(p) 1987 {} 1988 1989 BitTorrent::torrent::exec_around_ptr::proxy::proxy(torrent_internal* t) : 1990 t_(t), 1991 l_(t->mutex_) 1992 { 1993 HAL_DEV_MSG(L"Ctor proxy"); 1994 } 1995 1996 BitTorrent::torrent::exec_around_ptr::proxy::~proxy() 1997 { 1998 HAL_DEV_MSG(L"Dtor proxy"); 1999 } 2000 2001 float BitTorrent::torrent::get_ratio() const 2002 { 2003 try { 2004 2005 return ptr->get_ratio(); 2006 2007 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::get_ratio") 2008 2009 return 0; 2010 } 2011 2012 void BitTorrent::torrent::set_ratio(float r) 2013 { 2014 try { 2015 2016 ptr->set_ratio(r); 1973 2017 1974 2018 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::set_ratio") 1975 2019 } 1976 2020 1977 float BitTorrent::torrent::get_ratio() const 1978 { 1979 try { 1980 1981 return ptr->getRatio(); 1982 1983 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::get_ratio") 1984 1985 return 0; 2021 wpath BitTorrent::torrent::get_save_directory() const 2022 { 2023 try { 2024 2025 return ptr->get_save_directory(); 2026 2027 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::get_save_directory") 2028 2029 return L""; 2030 } 2031 2032 void BitTorrent::torrent::set_save_directory(const wpath& s) 2033 { 2034 try { 2035 2036 ptr->set_save_directory(s); 2037 2038 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::set_save_directory") 2039 } 2040 2041 wpath BitTorrent::torrent::get_move_to_directory() const 2042 { 2043 try { 2044 2045 return ptr->get_move_to_directory(); 2046 2047 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::get_save_directory") 2048 2049 return L""; 2050 } 2051 2052 void BitTorrent::torrent::set_move_to_directory(const wpath& m) 2053 { 2054 try { 2055 2056 ptr->set_move_to_directory(m); 2057 2058 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(L"Me", "torrent::set_move_to_directory") 1986 2059 } 1987 2060 … … 1995 2068 try { 1996 2069 1997 pimpl->theTorrents.get(filename)->set Ratio(ratio);2070 pimpl->theTorrents.get(filename)->set_ratio(ratio); 1998 2071 1999 2072 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "setTorrentRatio") … … 2009 2082 try { 2010 2083 2011 return pimpl->theTorrents.get(filename)->get Ratio();2084 return pimpl->theTorrents.get(filename)->get_ratio(); 2012 2085 2013 2086 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "getTorrentRatio") -
trunk/src/halTorrent.hpp
r432 r437 411 411 412 412 class BitTorrent_impl; 413 class TorrentInternal;413 class torrent_internal; 414 414 415 415 class BitTorrent 416 416 { 417 public: 418 417 419 class torrent 418 420 { … … 420 422 421 423 public: 424 class exec_around_ptr 425 { 426 public: 427 class proxy 428 { 429 public: 430 explicit proxy(torrent_internal* t); 431 432 torrent_internal* operator->() 433 { 434 return t_; 435 } 436 437 ~proxy (); 438 439 private: 440 torrent_internal* t_; 441 mutex_t::scoped_lock l_; 442 }; 443 444 exec_around_ptr(boost::shared_ptr<torrent_internal> p) : ptr(p) {} 445 446 proxy operator->() const 447 { 448 return proxy(&(*ptr)); 449 } 450 451 private: 452 boost::shared_ptr<torrent_internal> ptr; 453 }; 454 455 torrent(boost::shared_ptr<torrent_internal> p); 456 457 float get_ratio() const; 422 458 void set_ratio(float new_ratio); 423 float get_ratio() const; 459 460 wpath get_save_directory() const; 461 void set_save_directory(const wpath&); 462 wpath get_move_to_directory() const; 463 void set_move_to_directory(const wpath&); 424 464 425 465 public: 426 466 STLSOFT_METHOD_PROPERTY_GETSET_EXTERNAL(float, float, class_type, 427 467 get_ratio, set_ratio, ratio); 468 469 STLSOFT_METHOD_PROPERTY_GETSET_EXTERNAL(wpath, const wpath&, class_type, 470 get_save_directory, set_save_directory, save_directory); 471 STLSOFT_METHOD_PROPERTY_GETSET_EXTERNAL(wpath, const wpath&, class_type, 472 get_move_to_directory, set_move_to_directory, move_to_directory); 428 473 429 474 private: 430 boost::shared_ptr<TorrentInternal>ptr;475 exec_around_ptr ptr; 431 476 }; 432 477 433 public:434 478 enum mappings 435 479 { … … 443 487 444 488 void create_torrent(const create_torrent_params& params, fs::wpath out_file, progress_callback fn); 489 490 template<typename T> 491 torrent get(T t) 492 { 493 return get_wstr(to_wstr_shim(t)); 494 } 495 496 torrent get_wstr(const std::wstring& filename); 445 497 446 498 bool listenOn(std::pair<int, int> const& portRange); -
trunk/src/halTorrentInternal.hpp
r431 r437 83 83 84 84 #include "halIni.hpp" 85 #include "halTypes.hpp" 85 86 #include "halSignaler.hpp" 86 87 … … 88 89 { 89 90 class TorrentInternalOld; 90 class TorrentInternal;91 class torrent_internal; 91 92 } 92 93 93 94 BOOST_CLASS_VERSION(hal::TorrentInternalOld, 9) 94 BOOST_CLASS_VERSION(hal:: TorrentInternal, 2)95 BOOST_CLASS_VERSION(hal::torrent_internal, 2) 95 96 96 97 namespace hal … … 98 99 99 100 namespace lbt = libtorrent; 100 namespace fs = boost::filesystem; 101 namespace pt = boost::posix_time; 102 103 typedef std::wstring wstring_t; 104 typedef std::string string_t; 105 106 typedef boost::wformat wformat_t; 107 typedef boost::format format_t; 108 109 typedef boost::filesystem::wpath wpath_t; 110 typedef boost::filesystem::path path_t; 111 112 using boost::serialization::make_nvp; 113 using boost::shared_ptr; 114 using boost::bind; 115 116 lbt::entry haldecode(const wpath_t &file) 101 102 lbt::entry haldecode(const wpath &file) 117 103 { 118 104 fs::ifstream ifs(file, fs::ifstream::binary); … … 125 111 } 126 112 127 bool halencode(const wpath _t&file, const lbt::entry &e)113 bool halencode(const wpath &file, const lbt::entry &e) 128 114 { 129 115 fs::ofstream ofs(file, fs::ofstream::binary); … … 136 122 } 137 123 138 std::pair<std::string, std::string> extract_names(const wpath_t &file) 124 inline path path_to_utf8(const wpath& wp) 125 { 126 return path(to_utf8(wp.string())); 127 } 128 129 inline wpath path_from_utf8(const path& p) 130 { 131 return wpath(from_utf8(p.string())); 132 } 133 134 std::pair<std::string, std::string> extract_names(const wpath &file) 139 135 { 140 136 if (fs::exists(file)) … … 149 145 150 146 event().post(shared_ptr<EventDetail>(new EventMsg( 151 wformat _t(L"Loaded names: %1%, %2%") % from_utf8(name) % from_utf8(filename))));147 wformat(L"Loaded names: %1%, %2%") % from_utf8(name) % from_utf8(filename)))); 152 148 153 149 return std::make_pair(name, filename); … … 160 156 { 161 157 public: 162 invalidTorrent(const wstring _t& who) :158 invalidTorrent(const wstring& who) : 163 159 who_(who) 164 160 {} … … 166 162 virtual ~invalidTorrent() throw () {} 167 163 168 wstring _twho() const throw ()164 wstring who() const throw () 169 165 { 170 166 return who_; … … 172 168 173 169 private: 174 wstring _twho_;170 wstring who_; 175 171 }; 176 172 … … 219 215 void serialize(Archive& ar, const unsigned int version) 220 216 { 221 ar & make_nvp("total", total_);217 ar & slz::make_nvp("total", total_); 222 218 } 223 219 … … 256 252 void serialize(Archive& ar, const unsigned int version) 257 253 { 258 ar & make_nvp("total", total_);254 ar & slz::make_nvp("total", total_); 259 255 } 260 256 … … 273 269 void serialize(Archive& ar, const unsigned int version) 274 270 { 275 ar & make_nvp("transferLimit", transferLimit_);276 ar & make_nvp("connections", connections_);277 ar & make_nvp("uploads", uploads_);271 ar & slz::make_nvp("transferLimit", transferLimit_); 272 ar & slz::make_nvp("connections", connections_); 273 ar & slz::make_nvp("uploads", uploads_); 278 274 279 275 if (version > 6) { 280 ar & make_nvp("filename", filename_);276 ar & slz::make_nvp("filename", filename_); 281 277 } 282 278 else 283 279 { 284 wstring _toriginalFilename;285 ar & make_nvp("filename", originalFilename);280 wstring originalFilename; 281 ar & slz::make_nvp("filename", originalFilename); 286 282 287 283 updatePreVersion7Files(originalFilename); 288 284 } 289 285 290 ar & make_nvp("saveDirectory", save_directory_);286 ar & slz::make_nvp("saveDirectory", save_directory_); 291 287 292 288 if (version > 7) { 293 ar & make_nvp("payloadUploaded_", payloadUploaded_);294 ar & make_nvp("payloadDownloaded_", payloadDownloaded_);295 ar & make_nvp("uploaded_", uploaded_);296 ar & make_nvp("downloaded_", downloaded_);297 ar & make_nvp("ratio", ratio_);289 ar & slz::make_nvp("payloadUploaded_", payloadUploaded_); 290 ar & slz::make_nvp("payloadDownloaded_", payloadDownloaded_); 291 ar & slz::make_nvp("uploaded_", uploaded_); 292 ar & slz::make_nvp("downloaded_", downloaded_); 293 ar & slz::make_nvp("ratio", ratio_); 298 294 } 299 295 else if (version > 3) { 300 ar & make_nvp("payloadUploaded_", payloadUploaded_);301 ar & make_nvp("payloadDownloaded_", payloadDownloaded_);302 ar & make_nvp("uploaded_", uploaded_);303 ar & make_nvp("downloaded_", downloaded_);296 ar & slz::make_nvp("payloadUploaded_", payloadUploaded_); 297 ar & slz::make_nvp("payloadDownloaded_", payloadDownloaded_); 298 ar & slz::make_nvp("uploaded_", uploaded_); 299 ar & slz::make_nvp("downloaded_", downloaded_); 304 300 } 305 301 else if (version > 1) 306 302 { 307 ar & make_nvp("totalUploaded", totalUploaded_);308 ar & make_nvp("ratio", ratio_);303 ar & slz::make_nvp("totalUploaded", totalUploaded_); 304 ar & slz::make_nvp("ratio", ratio_); 309 305 310 306 payloadUploaded_.reset(totalUploaded_); … … 312 308 313 309 if (version > 0) { 314 ar & make_nvp("trackerUsername", trackerUsername_);315 ar & make_nvp("trackerPassword", trackerPassword_);310 ar & slz::make_nvp("trackerUsername", trackerUsername_); 311 ar & slz::make_nvp("trackerPassword", trackerPassword_); 316 312 } 317 313 if (version > 1) { 318 ar & make_nvp("state", state_);319 ar & make_nvp("trackers", trackers_);314 ar & slz::make_nvp("state", state_); 315 ar & slz::make_nvp("trackers", trackers_); 320 316 } 321 317 322 318 if (version > 2) { 323 ar & make_nvp("resolve_countries", resolve_countries_);319 ar & slz::make_nvp("resolve_countries", resolve_countries_); 324 320 } 325 321 if (version > 4) { 326 ar & make_nvp("file_priorities", filePriorities_);322 ar & slz::make_nvp("file_priorities", filePriorities_); 327 323 } 328 324 if (version > 5) { 329 ar & make_nvp("startTime", startTime_);330 ar & make_nvp("activeDuration", activeDuration_);331 ar & make_nvp("seedingDuration", seedingDuration_);325 ar & slz::make_nvp("startTime", startTime_); 326 ar & slz::make_nvp("activeDuration", activeDuration_); 327 ar & slz::make_nvp("seedingDuration", seedingDuration_); 332 328 } 333 329 if (version > 6) { 334 ar & make_nvp("name", name_);335 ar & make_nvp("compactStorage", compactStorage_);336 ar & make_nvp("finishTime", finishTime_);330 ar & slz::make_nvp("name", name_); 331 ar & slz::make_nvp("compactStorage", compactStorage_); 332 ar & slz::make_nvp("finishTime", finishTime_); 337 333 } 338 334 if (version > 8) { 339 ar & make_nvp("progress", progress_);335 ar & slz::make_nvp("progress", progress_); 340 336 } 341 337 } … … 351 347 352 348 event().post(shared_ptr<EventDetail>(new EventMsg( 353 wformat _t(L"Loaded names: %1%, %2%") % name_ % filename_)));354 } 355 356 void updatePreVersion7Files(wstring _toriginalFilename)349 wformat(L"Loaded names: %1%, %2%") % name_ % filename_))); 350 } 351 352 void updatePreVersion7Files(wstring originalFilename) 357 353 { 358 354 try 359 355 { 360 356 361 wpath _toldFile = app().working_directory()/L"torrents"/originalFilename;357 wpath oldFile = app().working_directory()/L"torrents"/originalFilename; 362 358 363 359 if (fs::exists(oldFile)) 364 360 extractNames(haldecode(oldFile)); 365 361 366 wpath _toldResumeFile = app().working_directory()/L"resume"/originalFilename;362 wpath oldResumeFile = app().working_directory()/L"resume"/originalFilename; 367 363 368 364 if (filename_ != originalFilename) … … 391 387 bool resolve_countries_; 392 388 393 wstring _tfilename_;394 wstring _tname_;395 wstring _tsave_directory_;396 wstring _toriginalFilename_;389 wstring filename_; 390 wstring name_; 391 wstring save_directory_; 392 wstring originalFilename_; 397 393 lbt::torrent_handle handle_; 398 394 … … 400 396 lbt::entry resumedata_; 401 397 402 wstring _ttrackerUsername_;403 wstring _ttrackerPassword_;398 wstring trackerUsername_; 399 wstring trackerPassword_; 404 400 405 401 boost::int64_t totalUploaded_; … … 438 434 439 435 440 class TorrentInternal;441 typedef shared_ptr< TorrentInternal> TorrentInternal_ptr;436 class torrent_internal; 437 typedef shared_ptr<torrent_internal> torrent_internal_ptr; 442 438 443 439 struct torrent_standalone : … … 451 447 {} 452 448 453 torrent_standalone( TorrentInternal_ptr t) :449 torrent_standalone(torrent_internal_ptr t) : 454 450 iniClass("torrent"), 455 451 torrent(t), … … 457 453 {} 458 454 459 TorrentInternal_ptr torrent;455 torrent_internal_ptr torrent; 460 456 pt::ptime save_time; 461 457 … … 464 460 void serialize(Archive& ar, const unsigned int version) 465 461 { 466 ar &make_nvp("torrent", torrent);467 ar &make_nvp("save_time", save_time);462 ar & slz::make_nvp("torrent", torrent); 463 ar & slz::make_nvp("save_time", save_time); 468 464 } 469 465 }; 470 466 471 class TorrentInternal :472 public boost::enable_shared_from_this< TorrentInternal>,467 class torrent_internal : 468 public boost::enable_shared_from_this<torrent_internal>, 473 469 private boost::noncopyable 474 470 { 475 471 friend class BitTorrent_impl; 472 friend class BitTorrent::torrent::exec_around_ptr::proxy; 473 476 474 public: 477 475 #define TORRENT_INTERNALS_DEFAULTS \ … … 488 486 in_session_(false) 489 487 490 TorrentInternal() :488 torrent_internal() : 491 489 TORRENT_INTERNALS_DEFAULTS, 492 490 compactStorage_(true), … … 494 492 {} 495 493 496 TorrentInternal(wpath_t filename, wpath_t saveDirectory, bool compactStorage, wpath_tmove_to_directory=L"") :494 torrent_internal(wpath filename, wpath saveDirectory, bool compactStorage, wpath move_to_directory=L"") : 497 495 TORRENT_INTERNALS_DEFAULTS, 498 496 save_directory_(saveDirectory.string()), … … 505 503 } 506 504 507 TorrentInternal(const TorrentInternalOld& t) :505 torrent_internal(const TorrentInternalOld& t) : 508 506 transferLimit_(t.transferLimit_), 509 507 state_(t.state_), … … 550 548 std::pair<int, int> getConnectionLimit(); 551 549 552 const wstring _t& name() const { return name_; }553 554 void set Ratio(float ratio)550 const wstring& name() const { return name_; } 551 552 void set_ratio(float ratio) 555 553 { 556 554 if (ratio < 0) ratio = 0; 557 555 ratio_ = ratio; 558 556 559 apply Ratio();560 } 561 562 float get Ratio()557 apply_ratio(); 558 } 559 560 float get_ratio() 563 561 { 564 562 return ratio_; … … 573 571 assert(the_session_ != 0); 574 572 575 HAL_DEV_MSG(wformat _t(L"addToSession() paused=%1%") % paused);573 HAL_DEV_MSG(wformat(L"addToSession() paused=%1%") % paused); 576 574 577 575 if (!inSession()) 578 576 { 579 string_t dir =to_utf8(save_directory_);577 path dir = path_to_utf8(save_directory_); 580 578 581 579 lbt::storage_mode_t storage = lbt::storage_mode_sparse; … … 618 616 assert(inSession()); 619 617 620 HAL_DEV_MSG(wformat _t(L"removeFromSession() writeData=%1%") % writeData);618 HAL_DEV_MSG(wformat(L"removeFromSession() writeData=%1%") % writeData); 621 619 622 620 if (writeData) … … 689 687 handle_.pause(); 690 688 signals().torrent_paused.disconnect_all_once(); 691 signals().torrent_paused.connect_once(bind(& TorrentInternal::completed_pause, this));689 signals().torrent_paused.connect_once(bind(&torrent_internal::completed_pause, this)); 692 690 693 691 state_ = TorrentDetail::torrent_pausing; … … 706 704 707 705 signals().torrent_paused.disconnect_all_once(); 708 signals().torrent_paused.connect_once(bind(& TorrentInternal::completed_stop, this));706 signals().torrent_paused.connect_once(bind(&torrent_internal::completed_stop, this)); 709 707 handle_.pause(); 710 708 … … 742 740 case TorrentDetail::torrent_active: 743 741 signals().torrent_paused.disconnect_all_once(); 744 signals().torrent_paused.connect_once(bind(& TorrentInternal::handle_recheck, this));742 signals().torrent_paused.connect_once(bind(&torrent_internal::handle_recheck, this)); 745 743 handle_.pause(); 746 744 state_ = TorrentDetail::torrent_pausing; … … 755 753 { 756 754 HAL_DEV_MSG(L"writeResumeData()"); 757 wpath _tresumeDir = workingDir_/L"resume";755 wpath resumeDir = workingDir_/L"resume"; 758 756 759 757 if (!exists(resumeDir)) … … 767 765 void clearResumeData() 768 766 { 769 wpath _tresumeFile = workingDir_/L"resume"/filename_;767 wpath resumeFile = workingDir_/L"resume"/filename_; 770 768 771 769 if (exists(resumeFile)) … … 774 772 resumedata_ = lbt::entry(); 775 773 } 774 775 const wpath get_save_directory() 776 { 777 return save_directory_; 778 } 779 780 void set_save_directory(wpath s) 781 { 782 if (inSession() && !is_finished() && 783 s != path_from_utf8(handle_.save_path())) 784 { 785 handle_.move_storage(path_to_utf8(s)); 786 save_directory_ = s; 787 } 788 } 789 790 const wpath get_move_to_directory() 791 { 792 return move_to_directory_; 793 } 794 795 void set_move_to_directory(wpath m) 796 { 797 if (is_finished() && !m.empty()) 798 { 799 if (m != path_from_utf8(handle_.save_path())) 800 { 801 handle_.move_storage(path_to_utf8(m)); 802 save_directory_ = move_to_directory_ = m; 803 } 804 } 805 else 806 { 807 move_to_directory_ = m; 808 } 809 } 810 811 bool is_finished() 812 { 813 if (inSession()) 814 { 815 lbt::torrent_status::state_t s = handle_.status().state; 816 817 return (s == lbt::torrent_status::seeding || 818 s == lbt::torrent_status::finished); 819 } 820 else return false; 821 } 776 822 777 823 void finished() … … 780 826 finishTime_ = boost::posix_time::second_clock::universal_time(); 781 827 782 // Only move seeding torrents for the mo!783 if (inSession() && handle_.status().state == lbt::torrent_status::seeding)784 {785 if (move_to_directory_ != L"" && move_to_directory_ != save_directory_)828 if (is_finished()) 829 { 830 if (!move_to_directory_.empty() && 831 move_to_directory_ != path_from_utf8(handle_.save_path())) 786 832 { 787 handle_.move_storage( to_utf8(move_to_directory_));833 handle_.move_storage(path_to_utf8(move_to_directory_)); 788 834 save_directory_ = move_to_directory_; 789 835 } … … 795 841 unsigned state() const { return state_; } 796 842 797 void setTrackerLogin(wstring _t username, wstring_tpassword)843 void setTrackerLogin(wstring username, wstring password) 798 844 { 799 845 trackerUsername_ = username; … … 803 849 } 804 850 805 std::pair<wstring _t, wstring_t> getTrackerLogin() const851 std::pair<wstring, wstring> getTrackerLogin() const 806 852 { 807 853 return make_pair(trackerUsername_, trackerPassword_); 808 854 } 809 855 810 const wstring _t& filename() const { return filename_; }811 812 const wstring _t& originalFilename() const { return originalFilename_; }856 const wstring& filename() const { return filename_; } 857 858 const wstring& originalFilename() const { return originalFilename_; } 813 859 814 860 const lbt::torrent_handle& handle() const { return handle_; } … … 857 903 } 858 904 859 const w string_t& saveDirectory() { return save_directory_; }905 const wpath& saveDirectory() { return save_directory_; } 860 906 861 907 friend class boost::serialization::access; … … 864 910 { 865 911 if (version > 1) { 866 ar & make_nvp("transfer_limits", transferLimit_);867 ar & make_nvp("connection_limits", connections_);868 ar & make_nvp("upload_limits", uploads_);869 870 ar & make_nvp("name", name_);871 ar & make_nvp("filename", filename_);872 873 ar & make_nvp("ratio", ratio_);874 ar & make_nvp("progress", progress_);875 ar & make_nvp("state", state_);876 ar & make_nvp("compact_storage", compactStorage_);877 ar & make_nvp("resolve_countries", resolve_countries_);878 879 ar & make_nvp("tracker_username", trackerUsername_);880 ar & make_nvp("tracker_password", trackerPassword_);881 ar & make_nvp("trackers", trackers_);882 883 ar & make_nvp("save_directory", save_directory_);884 ar & make_nvp("move_to_directory", move_to_directory_);885 886 ar & make_nvp("payload_uploaded", payloadUploaded_);887 ar & make_nvp("payload_downloaded", payloadDownloaded_);888 ar & make_nvp("uploaded", uploaded_);889 ar & make_nvp("downloaded", downloaded_);912 ar & slz::make_nvp("transfer_limits", transferLimit_); 913 ar & slz::make_nvp("connection_limits", connections_); 914 ar & slz::make_nvp("upload_limits", uploads_); 915 916 ar & slz::make_nvp("name", name_); 917 ar & slz::make_nvp("filename", filename_); 918 919 ar & slz::make_nvp("ratio", ratio_); 920 ar & slz::make_nvp("progress", progress_); 921 ar & slz::make_nvp("state", state_); 922 ar & slz::make_nvp("compact_storage", compactStorage_); 923 ar & slz::make_nvp("resolve_countries", resolve_countries_); 924 925 ar & slz::make_nvp("tracker_username", trackerUsername_); 926 ar & slz::make_nvp("tracker_password", trackerPassword_); 927 ar & slz::make_nvp("trackers", trackers_); 928 929 ar & slz::make_nvp("save_directory", save_directory_); 930 ar & slz::make_nvp("move_to_directory", move_to_directory_); 931 932 ar & slz::make_nvp("payload_uploaded", payloadUploaded_); 933 ar & slz::make_nvp("payload_downloaded", payloadDownloaded_); 934 ar & slz::make_nvp("uploaded", uploaded_); 935 ar & slz::make_nvp("downloaded", downloaded_); 890 936 891 ar & make_nvp("file_priorities", filePriorities_);892 893 ar & make_nvp("start_time", startTime_);894 ar & make_nvp("finish_time", finishTime_);895 ar & make_nvp("active_duration", activeDuration_);896 ar & make_nvp("seeding_duration", seedingDuration_);937 ar & slz::make_nvp("file_priorities", filePriorities_); 938 939 ar & slz::make_nvp("start_time", startTime_); 940 ar & slz::make_nvp("finish_time", finishTime_); 941 ar & slz::make_nvp("active_duration", activeDuration_); 942 ar & slz::make_nvp("seeding_duration", seedingDuration_); 897 943 898 944 } 899 945 else 900 946 { 901 ar & make_nvp("transferLimit", transferLimit_); 902 ar & make_nvp("connections", connections_); 903 ar & make_nvp("uploads", uploads_); 904 ar & make_nvp("filename", filename_); 905 ar & make_nvp("saveDirectory", save_directory_); 947 ar & slz::make_nvp("transferLimit", transferLimit_); 948 ar & slz::make_nvp("connections", connections_); 949 ar & slz::make_nvp("uploads", uploads_); 950 ar & slz::make_nvp("filename", filename_); 951 if (version == 0) { 952 wstring s; 953 ar & slz::make_nvp("saveDirectory", save_directory_); 954 save_directory_ = s; 955 } else { 956 ar & slz::make_nvp("saveDirectory", save_directory_); 957 } 958 906 959 if (version > 0) { 907 ar & make_nvp("moveToDirectory", move_to_directory_); 960 wstring m; 961 ar & slz::make_nvp("moveToDirectory", m); 962 move_to_directory_ = m; 908 963 } else { 909 964 move_to_directory_ = save_directory_; 910 965 } 911 966 912 ar & make_nvp("payloadUploaded_", payloadUploaded_);913 ar & make_nvp("payloadDownloaded_", payloadDownloaded_);914 ar & make_nvp("uploaded_", uploaded_);915 ar & make_nvp("downloaded_", downloaded_);916 ar & make_nvp("ratio", ratio_);917 ar & make_nvp("trackerUsername", trackerUsername_);918 ar & make_nvp("trackerPassword", trackerPassword_);919 920 ar & make_nvp("state", state_);921 ar & make_nvp("trackers", trackers_);922 923 ar & make_nvp("resolve_countries", resolve_countries_);924 925 ar & make_nvp("file_priorities", filePriorities_);926 927 ar & make_nvp("startTime", startTime_);928 ar & make_nvp("activeDuration", activeDuration_);929 ar & make_nvp("seedingDuration", seedingDuration_);930 931 ar & make_nvp("name", name_);932 ar & make_nvp("compactStorage", compactStorage_);933 ar & make_nvp("finishTime", finishTime_);934 935 ar & make_nvp("progress", progress_);967 ar & slz::make_nvp("payloadUploaded_", payloadUploaded_); 968 ar & slz::make_nvp("payloadDownloaded_", payloadDownloaded_); 969 ar & slz::make_nvp("uploaded_", uploaded_); 970 ar & slz::make_nvp("downloaded_", downloaded_); 971 ar & slz::make_nvp("ratio", ratio_); 972 ar & slz::make_nvp("trackerUsername", trackerUsername_); 973 ar & slz::make_nvp("trackerPassword", trackerPassword_); 974 975 ar & slz::make_nvp("state", state_); 976 ar & slz::make_nvp("trackers", trackers_); 977 978 ar & slz::make_nvp("resolve_countries", resolve_countries_); 979 980 ar & slz::make_nvp("file_priorities", filePriorities_); 981 982 ar & slz::make_nvp("startTime", startTime_); 983 ar & slz::make_nvp("activeDuration", activeDuration_); 984 ar & slz::make_nvp("seedingDuration", seedingDuration_); 985 986 ar & slz::make_nvp("name", name_); 987 ar & slz::make_nvp("compactStorage", compactStorage_); 988 ar & slz::make_nvp("finishTime", finishTime_); 989 990 ar & slz::make_nvp("progress", progress_); 936 991 } 937 992 } … … 1007 1062 for(size_t i=0, e=files.size(); i<e; ++i) 1008 1063 { 1009 wstring _tfullPath = hal::from_utf8(files[i].path.string());1064 wstring fullPath = hal::from_utf8(files[i].path.string()); 1010 1065 boost::int64_t size = static_cast<boost::int64_t>(files[i].size); 1011 1066 … … 1029 1084 } 1030 1085 1031 void prepare(wpath _tfilename)1086 void prepare(wpath filename) 1032 1087 { 1033 1088 mutex_t::scoped_lock l(mutex_); … … 1038 1093 extractNames(metadata_); 1039 1094 1040 const wpath _tresumeFile = workingDir_/L"resume"/filename_;1041 const wpath _ttorrentFile = workingDir_/L"torrents"/filename_;1095 const wpath resumeFile = workingDir_/L"resume"/filename_; 1096 const wpath torrentFile = workingDir_/L"torrents"/filename_; 1042 1097 1043 1098 event().post(shared_ptr<EventDetail>(new EventMsg( 1044 wformat _t(L"File: %1%, %2%.") % resumeFile % torrentFile)));1099 wformat(L"File: %1%, %2%.") % resumeFile % torrentFile))); 1045 1100 1046 1101 if (exists(resumeFile)) … … 1074 1129 1075 1130 event().post(shared_ptr<EventDetail>(new EventMsg( 1076 wformat _t(L"Loaded names: %1%, %2%") % name_ % filename_)));1131 wformat(L"Loaded names: %1%, %2%") % name_ % filename_))); 1077 1132 } 1078 1133 … … 1097 1152 applyTransferSpeed(); 1098 1153 applyConnectionLimit(); 1099 apply Ratio();1154 apply_ratio(); 1100 1155 applyTrackers(); 1101 1156 applyTrackerLogin(); … … 1115 1170 handle_.set_upload_limit(up); 1116 1171 1117 HAL_DEV_MSG(wformat _t(L"Applying Transfer Speed %1% - %2%") % down % up);1172 HAL_DEV_MSG(wformat(L"Applying Transfer Speed %1% - %2%") % down % up); 1118 1173 } 1119 1174 } … … 1127 1182 handle_.set_max_uploads(uploads_); 1128 1183 1129 HAL_DEV_MSG(wformat _t(L"Applying Connection Limit %1% - %2%") % connections_ % uploads_);1130 } 1131 } 1132 1133 void apply Ratio()1184 HAL_DEV_MSG(wformat(L"Applying Connection Limit %1% - %2%") % connections_ % uploads_); 1185 } 1186 } 1187 1188 void apply_ratio() 1134 1189 { 1135 1190 mutex_t::scoped_lock l(mutex_); … … 1138 1193 handle_.set_ratio(ratio_); 1139 1194 1140 HAL_DEV_MSG(wformat _t(L"Applying Ratio %1%") % ratio_);1195 HAL_DEV_MSG(wformat(L"Applying Ratio %1%") % ratio_); 1141 1196 } 1142 1197 } … … 1178 1233 } 1179 1234 1180 HAL_DEV_MSG(wformat _t(L"Applying Tracker Login User: %1%, Pass: %2%") % trackerUsername_ % trackerPassword_ );1235 HAL_DEV_MSG(wformat(L"Applying Tracker Login User: %1%, Pass: %2%") % trackerUsername_ % trackerPassword_ ); 1181 1236 } 1182 1237 } … … 1201 1256 handle_.resolve_countries(resolve_countries_); 1202 1257 1203 HAL_DEV_MSG(wformat _t(L"Applying Resolve Countries %1%") % resolve_countries_);1258 HAL_DEV_MSG(wformat(L"Applying Resolve Countries %1%") % resolve_countries_); 1204 1259 } 1205 1260 } … … 1247 1302 1248 1303 static lbt::session* the_session_; 1249 static wpath _tworkingDir_;1304 static wpath workingDir_; 1250 1305 1251 1306 mutable mutex_t mutex_; … … 1260 1315 bool resolve_countries_; 1261 1316 1262 wstring _tfilename_;1263 wstring _tname_;1264 w string_tsave_directory_;1265 w string_tmove_to_directory_;1266 wstring _toriginalFilename_;1317 wstring filename_; 1318 wstring name_; 1319 wpath save_directory_; 1320 wpath move_to_directory_; 1321 wstring originalFilename_; 1267 1322 lbt::torrent_handle handle_; 1268 1323 … … 1270 1325 lbt::entry resumedata_; 1271 1326 1272 wstring _ttrackerUsername_;1273 wstring _ttrackerPassword_;1327 wstring trackerUsername_; 1328 wstring trackerPassword_; 1274 1329 1275 1330 boost::int64_t totalUploaded_; … … 1311 1366 struct TorrentHolder 1312 1367 { 1313 mutable TorrentInternal_ptr torrent;1314 1315 wstring _tfilename;1316 wstring _tname;1368 mutable torrent_internal_ptr torrent; 1369 1370 wstring filename; 1371 wstring name; 1317 1372 1318 1373 TorrentHolder() 1319 1374 {} 1320 1375 1321 explicit TorrentHolder( TorrentInternal_ptr t) :1376 explicit TorrentHolder(torrent_internal_ptr t) : 1322 1377 torrent(t), filename(torrent->filename()), name(torrent->name()) 1323 1378 {} … … 1330 1385 { 1331 1386 TorrentInternalOld t; 1332 ar & make_nvp("torrent", t);1387 ar & slz::make_nvp("torrent", t); 1333 1388 1334 torrent.reset(new TorrentInternal(t));1389 torrent.reset(new torrent_internal(t)); 1335 1390 } 1336 1391 else 1337 1392 { 1338 ar & make_nvp("torrent", torrent);1393 ar & slz::make_nvp("torrent", torrent); 1339 1394 } 1340 1395 1341 ar & make_nvp("filename", filename);1342 ar & make_nvp("name", name);1396 ar & slz::make_nvp("filename", filename); 1397 ar & slz::make_nvp("name", name); 1343 1398 } 1344 1399 }; … … 1353 1408 boost::multi_index::tag<byFilename>, 1354 1409 boost::multi_index::member< 1355 TorrentHolder, wstring _t, &TorrentHolder::filename>1410 TorrentHolder, wstring, &TorrentHolder::filename> 1356 1411 >, 1357 1412 boost::multi_index::ordered_unique< 1358 1413 boost::multi_index::tag<byName>, 1359 1414 boost::multi_index::member< 1360 TorrentHolder, wstring _t, &TorrentHolder::name>1415 TorrentHolder, wstring, &TorrentHolder::name> 1361 1416 > 1362 1417 > … … 1377 1432 for (TorrentMap::const_iterator i=map.begin(), e=map.end(); i != e; ++i) 1378 1433 { 1379 TorrentInternal_ptr TIp(new TorrentInternal((*i).second));1434 torrent_internal_ptr TIp(new torrent_internal((*i).second)); 1380 1435 1381 1436 event().post(shared_ptr<EventDetail>(new EventMsg( 1382 wformat _t(L"Converting %1%.") % TIp->name())));1437 wformat(L"Converting %1%.") % TIp->name()))); 1383 1438 1384 1439 torrents_.insert(TorrentHolder(TIp)); … … 1393 1448 } 1394 1449 1395 std::pair<torrentByName::iterator, bool> insert( TorrentInternal_ptr t)1450 std::pair<torrentByName::iterator, bool> insert(torrent_internal_ptr t) 1396 1451 { 1397 1452 return insert(TorrentHolder(t)); 1398 1453 } 1399 1454 1400 TorrentInternal_ptr getByFile(const wstring_t& filename)1455 torrent_internal_ptr getByFile(const wstring& filename) 1401 1456 { 1402 1457 torrentByFilename::iterator it = torrents_.get<byFilename>().find(filename); … … 1410 1465 } 1411 1466 1412 TorrentInternal_ptr get(const wstring_t& name)1467 torrent_internal_ptr get(const wstring& name) 1413 1468 { 1414 1469 torrentByName::iterator it = torrents_.get<byName>().find(name); … … 1432 1487 } 1433 1488 1434 size_t erase(const wstring _t& name)1489 size_t erase(const wstring& name) 1435 1490 { 1436 1491 return torrents_.get<byName>().erase(name); 1437 1492 } 1438 1493 1439 bool exists(const wstring _t& name)1494 bool exists(const wstring& name) 1440 1495 { 1441 1496 torrentByName::iterator it = torrents_.get<byName>().find(name); … … 1454 1509 void serialize(Archive& ar, const unsigned int version) 1455 1510 { 1456 ar & make_nvp("torrents", torrents_);1511 ar & slz::make_nvp("torrents", torrents_); 1457 1512 } 1458 1513 … … 1461 1516 }; 1462 1517 1463 void TorrentInternal::setConnectionLimit(int maxConn, int maxUpload)1518 void torrent_internal::setConnectionLimit(int maxConn, int maxUpload) 1464 1519 { 1465 1520 mutex_t::scoped_lock l(mutex_); … … 1471 1526 } 1472 1527 1473 std::pair<int, int> TorrentInternal::getConnectionLimit()1528 std::pair<int, int> torrent_internal::getConnectionLimit() 1474 1529 { 1475 1530 return std::make_pair(connections_, uploads_); 1476 1531 } 1477 1532 1478 void TorrentInternal::setTransferSpeed(float download, float upload)1533 void torrent_internal::setTransferSpeed(float download, float upload) 1479 1534 { 1480 1535 mutex_t::scoped_lock l(mutex_); … … 1485 1540 } 1486 1541 1487 std::pair<float, float> TorrentInternal::getTransferSpeed()1542 std::pair<float, float> torrent_internal::getTransferSpeed() 1488 1543 { 1489 1544 return transferLimit_; 1490 1545 } 1491 1546 1492 TorrentDetail_ptr TorrentInternal::getTorrentDetail_ptr()1547 TorrentDetail_ptr torrent_internal::getTorrentDetail_ptr() 1493 1548 { 1494 1549 mutex_t::scoped_lock l(mutex_); … … 1511 1566 } 1512 1567 1513 wstring _tstate;1568 wstring state; 1514 1569 1515 1570 switch (state_) … … 1587 1642 boost::tuple<size_t, size_t, size_t, size_t> connections = updatePeers(); 1588 1643 1589 return TorrentDetail_ptr(new TorrentDetail(name_, filename_, saveDirectory() , state, hal::from_utf8(statusMemory_.current_tracker),1644 return TorrentDetail_ptr(new TorrentDetail(name_, filename_, saveDirectory().string(), state, hal::from_utf8(statusMemory_.current_tracker), 1590 1645 std::pair<float, float>(statusMemory_.download_payload_rate, statusMemory_.upload_payload_rate), 1591 1646 progress_, statusMemory_.distributed_copies, statusMemory_.total_wanted_done, statusMemory_.total_wanted, uploaded_, payloadUploaded_, … … 1604 1659 } 1605 1660 1606 return TorrentDetail_ptr(new TorrentDetail(name_, filename_, saveDirectory() , app().res_wstr(HAL_TORRENT_STOPPED), app().res_wstr(HAL_NA)));1661 return TorrentDetail_ptr(new TorrentDetail(name_, filename_, saveDirectory().string(), app().res_wstr(HAL_TORRENT_STOPPED), app().res_wstr(HAL_NA))); 1607 1662 } 1608 1663 -
trunk/src/halTypes.hpp
r429 r437 17 17 namespace pt = boost::posix_time; 18 18 namespace xp = boost::xpressive; 19 namespace sl = boost::serialization; 19 namespace slz = boost::serialization; 20 21 using std::wstring; 22 using std::string; 20 23 21 24 using std::pair; 22 25 using std::make_pair; 23 using boost::tuple;24 26 25 27 typedef boost::int64_t size_type; 26 28 typedef boost::recursive_mutex mutex_t; 27 29 typedef boost::thread thread_t; 30 31 using boost::tuple; 32 using boost::shared_ptr; 33 using boost::bind; 34 35 using boost::wformat; 36 using boost::format; 37 38 using fs::wpath; 39 using fs::path; 28 40 }
Note: See TracChangeset
for help on using the changeset viewer.