#ifndef __ftpro_H__
#define __ftpro_H__
#include <wx/wx.h>
#include <wx/wxhtml.h>
#include <wx/bitmap.h>
#include <wx/dnd.h>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <functional>
#include "cs_ftp.h"
#include "cs_strtok.h"
#include "splash.h"
#include "dialogs.h"
class LocalList : public wxListCtrl
{
public:
LocalList(wxWindow* parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition,const wxSize& size = wxDefaultSize,
long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
const wxString& name = "listCtrl") : wxListCtrl(parent,id,pos,size,style,validator,name){}
private:
void OnRightDown(wxMouseEvent &event);
DECLARE_EVENT_TABLE()
};
class RemoteList : public wxListCtrl
{
public:
RemoteList(wxWindow* parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition,const wxSize& size = wxDefaultSize,
long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
const wxString& name = "listCtrl") : wxListCtrl(parent,id,pos,size,style,validator,name){}
void OnRightDown(wxMouseEvent &event);
private:
DECLARE_EVENT_TABLE()
};
class TransferList : public wxListCtrl
{
public:
TransferList(wxWindow* parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition,const wxSize& size = wxDefaultSize,
long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
const wxString& name = "listCtrl") : wxListCtrl(parent,id,pos,size,style,validator,name){}
void OnRightDown(wxMouseEvent &event);
private:
void OnAbort();
void OnResume();
void OnClear();
void OnClearAll();
DECLARE_EVENT_TABLE()
};
class MyPopupMenu : public wxMenu
{
public:
MyPopupMenu(const wxString& title);
};
class MyFrame: public wxFrame
{
public:
MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE );
void OnAbout();
private:
void CreateMyMenuBar();
void CreateMyToolBar();
private:
void OnConnect();
void OnQuickConnect();
void OnHtml();
void OnBeam();
void OnQuit();
void OnSettingsSettings();
void OnSettingsHelp();
private:
DECLARE_EVENT_TABLE()
};
class MyApp: public wxApp
{
public:
MyApp(){}
virtual bool OnInit();
};
class HtmlDialog: public wxDialog
{
public:
HtmlDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE );
private:
void OnGet( wxCommandEvent &event );
void OnCancel(){EndModal(1);}
private:
DECLARE_EVENT_TABLE()
};
class HelpDialog: public wxDialog
{
public:
HelpDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE );
void OnOk(){EndModal(1);}
private:
DECLARE_EVENT_TABLE()
};
class SetupDialog: public wxDialog
{
public:
SetupDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE );
private:
void OnSettingsCancel( );
void OnSettingsOk( );
void OnSettingsReditorFind();
void OnSettingsReditorDefault();
void OnSettingsPeditorFind();
void OnSettingsPeditorDefault();
void OnSettingsHomeFind();
void OnSettingsHomeDefault();
void OnSettingsStartQC();
void OnSettingsStartRC();
void OnManageAdd();
private:
wxTextCtrl* peditor_tc;
wxTextCtrl* reditor_tc;
wxTextCtrl* home_tc;
wxString s_peditor,s_reditor,s_home;
int start_style;
DECLARE_EVENT_TABLE()
};
class QuickConnectEditDialog: public wxDialog
{
public:
QuickConnectEditDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE );
void SetInfo(vector<string> x, string name);
private:
wxTextCtrl *name_tc;
wxTextCtrl *user_tc;
wxTextCtrl *password_tc;
wxTextCtrl *host_tc;
wxComboBox *port_cb;
vector<string> info;
void OnOk();
void OnCancel(){EndModal(1);}
DECLARE_EVENT_TABLE()
};
class ConnectionDialog: public wxDialog
{
public:
ConnectionDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE );
private:
void OnConnect( wxCommandEvent &event );
void OnCancel();
void OnOk( wxCommandEvent &event );
void OnAnonymous( wxCommandEvent &event );
void OnQuickConnect();
void OnQuickEdit();
void OnQuickRemove();
void OnSOIConnect();
void OnSOICancel();
void OnSOIInfo();
wxTextCtrl* host_tc;
wxTextCtrl* user_tc;
wxTextCtrl* password_tc;
wxComboBox* port_cb;
wxCheckBox* encrypt_cx;
wxCheckBox* anonymous_cx;
wxCheckBox* qc_cx;
wxRadioButton* qc_rb;
wxTextCtrl* qc_tc;
std::map<std::string, std::vector<std::string> > QCList;
// Quick & Site stuff
wxListBox* qc_listbox;
wxListBox* site_listbox;
wxString info[10];
private:
DECLARE_EVENT_TABLE()
};
class HarborDialog: public wxDialog
{
public:
HarborDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
bool SortList(vector<wxString> &T, int num);
void OnQuitAll(){exit(0);}
//Getters
wxString GetLastHarborError(){return s_error;}
wxString GetLastResponse(){return s_response;}
wxString GetUser(){return s_user;}
wxString GetPassword(){return s_password;}
wxString GetHost(){return host_string;}
wxString GetRegularEditor(){return s_reditor;}
wxString GetProgrammingEditor(){return s_peditor;}
wxString GetHome(){return s_home;}
int GetStyle(){return style_type;}
FTP GetFTP(){return F_current;}
//Setters
void SetLastError(const wxString &x){s_error = x;}
void SetLastResponse(const wxString &x){s_response = x;}
void SetUser(const wxString &x){s_user = x;}
void SetPassword(const wxString&x){s_password = x;}
void SetHost(const wxString &x){host_string = x;}
void SetStyle(const int &x){style_type = x;}
void SetProgrammingEditor(const wxString&x){s_peditor = x;}
void SetRegularEditor(const wxString&x){s_reditor = x;}
void SetHome(const wxString &x){s_home = x;}
void SetStyle(int &x){style_type = x;}
void SetFTP(const FTP &x){F_current = x;}
//for status page
// for DND
int GetSelected(wxListCtrl* list);
int GetSelected(wxListCtrl* list,vector<int> &v);
void GetLocalFiles(wxString);
static TransferList* transfer_list;
static RemoteList* remote_list;
static LocalList* local_list;
static wxGauge *transfer_gauges[12];
static wxString FileTypes[39];
static wxTextCtrl *harbor_text;
static unsigned int downloads_left[10];
static unsigned int download_status[10];
// WDR: handler declarations for HarborDialog
// Others
//Local
void OnLocalRefresh(){GetLocalFiles(wxGetCwd());}
void OnLocalPWD( wxCommandEvent &event );
void OnLocalCdup( wxCommandEvent &event );
void OnLocalHome( wxCommandEvent &event );
void OnLocalPWDTextChange();
void OnLocalBeginDrag( wxListEvent &event );
void OnLocalRightClick( wxMouseEvent &event );
void OnLocalActivated( wxListEvent &event );
void OnLocalPut();
void OnLocalNewDir();
void OnLocalNewFile();
void OnLocalRemove();
void OnLocalRegularOpen();
void OnLocalProgrammerOpen();
//remote
void OnRemoteProgrammersOpen();
void OnRemoteRegularOpen();
void OnRemoteList();
void OnRemoteRefresh();
void OnRemoteOwner();
void OnRemoteGetMany();
void OnRemoteCdup( wxCommandEvent &event );
void OnRemoteHome( wxCommandEvent &event );
void OnRemotePWD( wxCommandEvent &event );
void OnRemoteBeginDrag( wxListEvent &event );
void OnRemoteRightClicked( wxListEvent &event );
void OnRemoteActivated( wxListEvent &event );
void OnRemoteNewDir();
void OnRemoteRemove();
void OnRemotePWDRC();
void OnRemoteStatus();
void UpdateRemotePWD();
void GetRemoteFiles();
wxString GetRemoteDir(){return s_remotedir;}
wxString GetPreviousRemoteDir(){return s_previousremotedir;}
void SetPreviousRemoteDir(const wxString &x){s_previousremotedir = x;}
void SetRemoteDir(const wxString &x){s_remotedir = x;}
void OnHelp( wxCommandEvent &event );
void OnQuit( wxCommandEvent &event );
//preferences
void OnSetupStyle( wxCommandEvent &event );
//transfer
void OnTransferResume( wxCommandEvent &event );
void OnTransferAbort( wxCommandEvent &event );
void OnTransferRightClick( wxListEvent &event );
void OnReset( wxCommandEvent &event );
void OnDisconnect( wxCommandEvent &event );
void OnConnect( wxCommandEvent &event );
private:
FTP F_current;
wxListCtrl* status_list;
wxComboBox* local_pwd_cb;
wxComboBox* remote_pwd_cb;
wxRadioBox* style_radio;
wxString s_error, s_response;
wxString s_peditor,s_reditor, s_home;
wxString s_user, s_password, host_string;
wxString s_remotedir;
wxString s_previousremotedir;
int style_type : 1;
DECLARE_EVENT_TABLE()
};
// doesnt work very well, will do it later
struct NoCaseSort
: public std::binary_function<wxString ,wxString, bool>
{
bool operator()(const wxString& a, const wxString& b)
{
return ((a.CmpNoCase(b) < 1) ? true : false);
}
};
#endif