- Timestamp:
- 01/20/09 14:35:42 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/halSession.cpp
r687 r688 506 506 507 507 get(a.handle)->signals().torrent_paused(); 508 509 get(a.handle)->post_event(ev_paused_alert()); 508 510 } 509 511 510 512 void operator()(libt::save_resume_data_alert const& a) const 511 513 { 514 HAL_DEV_MSG(L"save_resume_data_alert"); 515 512 516 event_log.post(shared_ptr<EventDetail>( 513 517 new EventMsg((hal::wform(hal::app().res_wstr(HAL_WRITE_RESUME_ALERT)) -
trunk/src/halTorrent.cpp
r663 r688 662 662 return pimpl()->the_torrents_.exists(filename); 663 663 664 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "is Torrent")664 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "is_torrent") 665 665 666 666 return false; … … 678 678 pimpl()->the_torrents_.get(filename)->pause(); 679 679 680 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "pause Torrent")680 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "pause_torrent") 681 681 } 682 682 … … 692 692 pimpl()->the_torrents_.get(filename)->resume(); 693 693 694 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "resume Torrent")694 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "resume_torrent") 695 695 } 696 696 … … 706 706 pimpl()->the_torrents_.get(filename)->stop(); 707 707 708 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "stop Torrent")708 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "stop_torrent") 709 709 } 710 710 … … 720 720 return pimpl()->the_torrents_.get(filename)->is_active(); 721 721 722 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "is TorrentActive")722 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "is_torrent_active") 723 723 724 724 return false; // ??? is this correct … … 736 736 pimpl()->the_torrents_.get(filename)->handle().force_reannounce(); 737 737 738 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "reannounce Torrent")738 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "reannounce_torrent") 739 739 } 740 740 … … 751 751 pimpl()->the_torrents_.get(filename)->force_recheck(); 752 752 753 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "recheck Torrent")753 } HAL_GENERIC_TORRENT_EXCEPTION_CATCH(filename, "recheck_torrent") 754 754 } 755 755 -
trunk/src/halTorrentIntEvents.hpp
r687 r688 18 18 namespace sc = boost::statechart; 19 19 20 struct ev_remove_from_session : boost::statechart::event<ev_remove_from_session>20 struct ev_remove_from_session : sc::event<ev_remove_from_session> 21 21 { 22 22 public: … … 31 31 }; 32 32 33 struct ev_add_to_session : boost::statechart::event<ev_add_to_session>33 struct ev_add_to_session : sc::event<ev_add_to_session> 34 34 { 35 35 public: … … 48 48 49 49 struct ev_stop : sc::event< ev_stop > {}; 50 struct ev_resume : sc::event< ev_resume > {}; 50 51 51 struct ev_write_resume_data : sc::event< ev_ stop> {};52 struct ev_write_resume_data : sc::event< ev_write_resume_data > {}; 52 53 struct ev_resume_data_alert : sc::event< ev_resume_data_alert > {}; 53 54 -
trunk/src/halTorrentIntStates.cpp
r687 r688 22 22 } 23 23 24 sc::result in_the_session::react(const ev_remove_from_session& evt)25 {26 torrent_internal& t_i = context<torrent_internal>();27 28 if (evt.write_data())29 {30 HAL_DEV_MSG(L"requesting resume data");31 t_i.save_resume_data();32 33 return transit< leaving_session >();34 }35 else36 {37 HAL_DEV_MSG(L"removing handle from session");38 t_i.remove_torrent();39 40 assert(!t_i.in_session());41 HAL_DEV_MSG(L"Removed from session!");42 43 return transit< out_of_session >();44 }45 }46 47 24 in_the_session::~in_the_session() 48 {49 TORRENT_STATE_LOG(L"Exiting ~in_the_session()");50 }51 52 // -------- leaving_session --------53 54 leaving_session::leaving_session(base_type::my_context ctx) :55 base_type::my_base(ctx)56 {57 TORRENT_STATE_LOG(L"Entering leaving_session()");58 }59 60 leaving_session::~leaving_session()61 {62 TORRENT_STATE_LOG(L"Exiting ~leaving_session()");63 }64 65 sc::result leaving_session::react(const ev_add_to_session& evt)66 {67 torrent_internal& t_i = context<torrent_internal>();68 assert(t_i.in_session());69 70 return transit< in_the_session >();71 }72 73 sc::result leaving_session::react(const ev_resume_data_alert& evt)74 25 { 75 26 torrent_internal& t_i = context<torrent_internal>(); … … 79 30 HAL_DEV_MSG(L"Removed from session!"); 80 31 81 return transit< out_of_session >();32 TORRENT_STATE_LOG(L"Exiting ~in_the_session()"); 82 33 } 83 34 … … 121 72 p.paused = evt.pause(); 122 73 p.duplicate_is_error = false; 123 p.auto_managed = t_i.managed_;74 p.auto_managed = false;//t_i.managed_; 124 75 125 76 t_i.handle_ = t_i.the_session_->add_torrent(p); … … 127 78 t_i.in_session_ = true; 128 79 129 return transit< in_the_session >(); 80 if (evt.pause()) 81 return transit< paused >(); 82 else 83 return transit< active >(); 130 84 } 131 85 … … 134 88 { 135 89 TORRENT_STATE_LOG(L"Entering active()"); 90 91 torrent_internal& t_i = context<torrent_internal>(); 92 t_i.state(torrent_details::torrent_active); 136 93 } 137 94 … … 153 110 } 154 111 155 pausing::pausing() 112 pausing::pausing(base_type::my_context ctx) : 113 base_type::my_base(ctx) 156 114 { 157 115 TORRENT_STATE_LOG(L"Entering pausing()"); 116 117 torrent_internal& t_i = context<torrent_internal>(); 118 t_i.state(torrent_details::torrent_pausing); 158 119 } 159 120 … … 167 128 { 168 129 TORRENT_STATE_LOG(L"Entering paused()"); 130 131 torrent_internal& t_i = context<torrent_internal>(); 132 t_i.state(torrent_details::torrent_paused); 169 133 } 170 134 … … 174 138 } 175 139 176 stopping::stopping() 140 sc::result paused::react(const ev_resume& evt) 141 { 142 context<torrent_internal>().handle_.resume(); 143 144 return transit< active >(); 145 } 146 147 stopping::stopping(base_type::my_context ctx) : 148 base_type::my_base(ctx) 177 149 { 178 150 TORRENT_STATE_LOG(L"Entering stopping()"); … … 182 154 { 183 155 TORRENT_STATE_LOG(L"Exiting ~stopping()"); 156 157 torrent_internal& t_i = context<torrent_internal>(); 158 t_i.state(torrent_details::torrent_stopping); 184 159 } 185 160 … … 191 166 }*/ 192 167 193 stopped::stopped() 168 stopped::stopped(base_type::my_context ctx) : 169 base_type::my_base(ctx) 194 170 { 195 171 TORRENT_STATE_LOG(L"Entering stopped()"); 172 173 torrent_internal& t_i = context<torrent_internal>(); 174 t_i.state(torrent_details::torrent_stopped); 196 175 } 197 176 … … 201 180 } 202 181 182 sc::result stopped::react(const ev_resume& evt) 183 { 184 // torrent_internal& t_i = context<torrent_internal>(); 185 // assert(t_i.in_session()); 186 187 post_event(ev_add_to_session(false)); 188 189 // context<torrent_internal>().add_to_session(false); 190 191 return discard_event(); 192 } 193 203 194 resume_data_waiting::resume_data_waiting(base_type::my_context ctx) : 204 195 base_type::my_base(ctx) -
trunk/src/halTorrentIntStates.hpp
r687 r688 46 46 }; 47 47 48 struct leaving_session : sc::state<leaving_session, torrent_internal>49 {50 typedef sc::state<leaving_session, torrent_internal> base_type;51 52 typedef mpl::list<53 sc::custom_reaction< ev_add_to_session >,54 sc::custom_reaction< ev_resume_data_alert >55 > reactions;56 57 leaving_session(base_type::my_context ctx);58 ~leaving_session();59 60 sc::result react(const ev_resume_data_alert& evt);61 sc::result react(const ev_add_to_session& evt);62 };63 64 48 struct active; 65 49 struct pausing; … … 73 57 typedef sc::state<in_the_session, torrent_internal, mpl::list< resume_data_idling, paused > > base_type; 74 58 75 typedef mpl::list<76 sc::custom_reaction< ev_remove_from_session>77 > reactions;59 // typedef mpl::list< 60 // sc::transition< ev_paused_alert, paused > 61 // > reactions; 78 62 79 63 in_the_session(base_type::my_context ctx); 80 64 ~in_the_session(); 81 65 82 sc::result react(const ev_remove_from_session& evt);83 66 }; 84 67 … … 86 69 { 87 70 typedef mpl::list< 88 sc::transition< ev_ paused_alert, resume_data_waiting >71 sc::transition< ev_write_resume_data, resume_data_waiting > 89 72 > reactions; 90 73 … … 111 94 typedef mpl::list< 112 95 sc::custom_reaction< ev_pause >, 113 sc::custom_reaction< ev_stop > 96 sc::custom_reaction< ev_stop >, 97 sc::transition< ev_paused_alert, paused > 114 98 > reactions; 115 99 … … 121 105 }; 122 106 123 struct pausing : sc::s imple_state<pausing, in_the_session::orthogonal< 1 > >107 struct pausing : sc::state<pausing, in_the_session::orthogonal< 1 > > 124 108 { 109 typedef sc::state<pausing, in_the_session::orthogonal< 1 > > base_type; 110 125 111 typedef sc::transition< ev_paused_alert, paused > reactions; 126 112 127 pausing( );113 pausing(base_type::my_context ctx); 128 114 ~pausing(); 129 115 }; … … 133 119 typedef sc::state<paused, in_the_session::orthogonal< 1 > > base_type; 134 120 121 typedef mpl::list< 122 sc::transition< ev_stop, stopping >, 123 sc::custom_reaction< ev_resume > 124 > reactions; 125 135 126 paused(base_type::my_context ctx); 136 127 ~paused(); 128 129 sc::result react(const ev_resume& evt); 137 130 }; 138 131 139 struct stopping : sc::s imple_state<stopping, in_the_session::orthogonal< 1 > >132 struct stopping : sc::state<stopping, in_the_session::orthogonal< 1 > > 140 133 { 134 typedef sc::state<stopping, in_the_session::orthogonal< 1 > > base_type; 135 141 136 typedef mpl::list< 142 137 // sc::custom_reaction< ev_paused_alert >, 143 sc::transition< ev_ resume_data_alert, stopped >138 sc::transition< ev_paused_alert, stopped > 144 139 > reactions; 145 140 146 stopping( );141 stopping(base_type::my_context ctx); 147 142 ~stopping(); 148 143 … … 150 145 }; 151 146 152 struct stopped : sc::s imple_state<stopped, out_of_session>147 struct stopped : sc::state<stopped, out_of_session> 153 148 { 154 stopped(); 149 typedef sc::state<stopped, out_of_session> base_type; 150 151 typedef mpl::list< 152 sc::custom_reaction< ev_resume > 153 > reactions; 154 155 stopped(base_type::my_context ctx); 155 156 ~stopped(); 157 158 sc::result react(const ev_resume& evt); 156 159 }; 157 160 -
trunk/src/halTorrentInternal.hpp
r687 r688 350 350 351 351 #undef TORRENT_INTERNALS_DEFAULTS 352 353 ~torrent_internal() 354 { 355 terminate(); 356 } 352 357 353 358 torrent_details_ptr get_torrent_details_ptr() … … 590 595 HAL_DEV_MSG(L"Added to session"); 591 596 597 return; 598 592 599 if (handle_.is_paused()) 593 600 state(torrent_details::torrent_paused); … … 617 624 } 618 625 619 process_event( ev_remove_from_session(write_data));626 process_event(ev_remove_from_session(write_data)); 620 627 621 628 return true; … … 649 656 mutex_t::scoped_lock l(mutex_); 650 657 HAL_DEV_MSG(hal::wform(L"resume() - %1%") % name_); 658 659 process_event(ev_resume()); 660 661 return; 651 662 652 663 if (state() == torrent_details::torrent_stopped) … … 669 680 mutex_t::scoped_lock l(mutex_); 670 681 HAL_DEV_MSG(hal::wform(L"pause() - %1%") % name_); 682 683 process_event(ev_pause()); 684 685 return; 671 686 672 687 if (state() == torrent_details::torrent_stopped) … … 695 710 mutex_t::scoped_lock l(mutex_); 696 711 HAL_DEV_MSG(hal::wform(L"stop() - %1%") % name_); 697 698 HAL_DEV_MSG(hal::wform(L"stop() requesting")); 712 713 process_event(ev_stop()); 714 715 /* HAL_DEV_MSG(hal::wform(L"stop() requesting")); 699 716 700 717 if (state() != torrent_details::torrent_stopped) … … 719 736 } 720 737 } 738 */ 721 739 } 722 740
Note: See TracChangeset
for help on using the changeset viewer.