Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / 2 / lab.03.by mice / claw / client
.h/*******************************************************************************
* file: client.h *
* version: 0.0.1 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#ifndef CLIENT_INCLUDED
#define CLIENT_INCLUDED
#include <afx.h>
#include <afxwin.h>
#include <afxcmn.h>
#include <afxdlgs.h>
#include "resource.h"
#include <math.h>
#include "fake_socket.h"
#include "win_errors.h"
////////////////////////////////////////////////////////////////////////////////
// ccw_client declaration
class ccw_client: public CDialog {
public:
////////////////////////////////////////////////////////////////////////////
// ccw_client public constants
static const int MSG_DEL_CLIENT = WM_USER + 0xD0;
// WPARAM: (int)claw_id
// LPARAM: not used
ccw_client();
~ccw_client();
bool is_sender() const { return _is_sender; }
int change_mode(const bool is_sender = true);
HICON get_icon() const { return _hicon; }
void set_icon(const HICON hicon) { _hicon = hicon; }
CWnd * get_parent() const { return _parent; }
void set_parent(CWnd *const parent) { _parent = parent; }
int get_claw_id() const { return _claw_id; }
void set_claw_id(const int claw_id) {_claw_id = claw_id; }
int set_caption();
int update_recver();
CSocket *sock() { return &_sock; }
int give_life();
int take_life();
virtual BOOL OnInitDialog();
virtual void OnOK() {}
virtual void OnCancel() {}
virtual void OnClose();
int run();
int stop();
int pause();
int upause();
int wait(const int timeout = 0);
// net
int recv_header();
static ccw_client *mk_client(const int claw_id = 0, const bool is_sender = true);
static int rm_client(ccw_client *const clnt);
protected:
////////////////////////////////////////////////////////////////////////////
// controls
CEdit *_edit_host;
CEdit *_edit_ip;
CEdit *_edit_port;
CEdit *_edit_file;
CEdit *_edit_size;
CEdit *_edit_status;
CEdit *_edit_time;
CProgressCtrl *_progress_bar;
CButton *_btn_browse;
CButton *_btn_run;
CButton *_btn_pause;
CButton *_btn_exit;
////////////////////////////////////////////////////////////////////////////
// protected event handlers
DECLARE_MESSAGE_MAP();
void _on_btn_browse();
void _on_btn_run();
void _on_btn_pause();
void _on_btn_exit();
void _init_controls();
void _lock_edits();
void _ulock_edits();
void _lock_file_edit();
void _ulock_file_edit();
void _set_rbtn_state(const int st);
void _set_pbtn_state(const int st);
void _sender_browse();
void _recver_browse();
int _sender_proc();
int _recver_proc();
static int _client_proc_helper(ccw_client *const clnt) {
if (clnt->is_sender()) return clnt->_sender_proc();
else return clnt->_recver_proc();
}
private:
////////////////////////////////////////////////////////////////////////////
// ccw_client private constants
static const int READ_SZ_TIMEOUT = 5000;
static const int SOCK_IO_BUF_SZ = 0x7FFF;
bool _is_sender;
CWnd *_parent;
HICON _hicon;
HANDLE _run_mtx;
HANDLE _pause_mtx;
HANDLE _thread_h;
DWORD _thread_id;
bool _stoped;
bool _paused;
int _run_btn_state;
int _pause_btn_state;
CSocket _sock;
unsigned int _total_sz;
unsigned int _done_sz;
int _claw_id;
};
#endif
Соседние файлы в папке claw