Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1989 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2012 Mattias Runge |
||
| 4 | * |
||
| 5 | * This program is free software; you can redistribute it and/or modify |
||
| 6 | * it under the terms of the GNU General Public License as published by |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or |
||
| 8 | * (at your option) any later version. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * |
||
| 15 | * You should have received a copy of the GNU General Public License along |
||
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | #ifndef NET_GETFILE_H |
||
| 22 | #define NET_GETFILE_H |
||
| 23 | |||
| 24 | #include "net/Manager.h" |
||
| 25 | |||
| 26 | #include "net/types.h" |
||
| 27 | #include "net/Url.h" |
||
| 28 | #include "net/Subscriber.h" |
||
| 29 | |||
| 30 | namespace atom { |
||
| 31 | namespace net { |
||
| 32 | |||
| 33 | class GetFile : public net::Subscriber |
||
| 34 | { |
||
| 35 | public: |
||
| 36 | typedef boost::shared_ptr<GetFile> Pointer; |
||
| 37 | typedef boost::signals2::signal<void(bool success, net::Url url, std::string temporary_filepath)> SignalOnComplete; |
||
| 38 | |||
| 39 | GetFile(); |
||
| 40 | virtual ~GetFile(); |
||
| 41 | |||
| 42 | void Start(Url url, const SignalOnComplete::slot_type& slot_on_complete); |
||
| 43 | |||
| 44 | protected: |
||
| 45 | typedef boost::shared_ptr<char> TrackerPointer; |
||
| 46 | |||
| 47 | net::Url url_; |
||
| 48 | net::SocketId socket_id_; |
||
| 49 | std::string filename_; |
||
| 50 | SignalOnComplete signal_on_complete_; |
||
| 51 | TrackerPointer tracker_; |
||
| 52 | bool header_received_; |
||
| 53 | bool status_; |
||
| 54 | |||
| 55 | void SlotOnNewStateHandler(net::SocketId id, net::ClientState client_state); |
||
| 56 | void SlotOnNewClientHandler(net::SocketId id, net::SocketId server_id); |
||
| 57 | void SlotOnNewDataHandler(net::SocketId id, common::Byteset data); |
||
| 58 | }; |
||
| 59 | |||
| 60 | }; // namespace net |
||
| 61 | }; // namespace atom |
||
| 62 | |||
| 63 | #endif // NET_GETFILE_H |