diff --git a/Makefile b/Makefile index b245a45..d98b0c1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CXX = $(shell wx-config --cxx) -Wno-c++11-compat-deprecated-writable-strings TARGET = build/Tyro -LDLIBS = $(shell wx-config --libs all) +LDLIBS = $(shell wx-config --libs all) -lssh2 WX_CXXFLAGS = -I./src -I./include -static $(shell wx-config --cxxflags) DEV_CXXFLAGS = -g -Wall -Wextra $(WX_CXXFLAGS) CXXFLAGS = -Os -s $(WX_CXXFLAGS) diff --git a/Tyro.cbp b/Tyro.cbp deleted file mode 100644 index 4efbad2..0000000 --- a/Tyro.cbp +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - diff --git a/src/EditPane.cpp b/src/EditPane.cpp index baacef8..4ababea 100644 --- a/src/EditPane.cpp +++ b/src/EditPane.cpp @@ -24,4 +24,19 @@ EditPane::EditPane( } -EditPane::~EditPane() {} \ No newline at end of file +EditPane::~EditPane() {} + +void EditPane::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event)) +{ + wxFileDialog *OpenDialog = new wxFileDialog(this, _T("Choose a file"), _(""), _(""), _("*.*"), wxFD_OPEN); + + if (OpenDialog->ShowModal() == wxID_OK) + { + // Load the file into a new notebook tab and styled text control + } + OpenDialog->Close(); +} + +void EditPane::OnMenuFileSave(wxCommandEvent &WXUNUSED(event)) +{ +} \ No newline at end of file diff --git a/src/EditPane.h b/src/EditPane.h index b0a1ab5..4546715 100644 --- a/src/EditPane.h +++ b/src/EditPane.h @@ -19,6 +19,8 @@ public: wxVSCROLL ); ~EditPane(); + void OnMenuFileOpen(wxCommandEvent &event); + void OnMenuFileSave(wxCommandEvent &event); private: DECLARE_EVENT_TABLE() }; diff --git a/src/Main.cpp b/src/Main.cpp index b447599..0a8d431 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -12,8 +12,8 @@ BEGIN_EVENT_TABLE(MainFrame, wxFrame) EVT_CLOSE(MainFrame::OnClose) EVT_MENU(wxID_NEW, MainFrame::OnMenuFileNew) - EVT_MENU(wxID_OPEN, MainFrame::OnMenuFileOpen) - EVT_MENU(wxID_SAVE, MainFrame::OnMenuFileSave) + EVT_MENU(wxID_OPEN, EditPane::OnMenuFileOpen) + EVT_MENU(wxID_SAVE, EditPane::OnMenuFileSave) EVT_MENU(wxID_EXIT, MainFrame::OnQuit) EVT_MENU(wxID_ABOUT, MainFrame::OnAbout) END_EVENT_TABLE() @@ -108,9 +108,9 @@ void MainFrame::SetupMenu() helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show info about this application")); // Add the menus to the menubar - mbar->Append(fileMenu, _("&File")); - mbar->Append(editMenu, _("&Edit")); - mbar->Append(helpMenu, _("&Help")); + mbar->Append(fileMenu, _T("&File")); + mbar->Append(editMenu, _T("&Edit")); + mbar->Append(helpMenu, _T("&Help")); #ifdef __WXMAC__ wxMenuBar::MacSetCommonMenuBar(mbar); @@ -135,21 +135,6 @@ void MainFrame::OnMenuFileNew(wxCommandEvent &WXUNUSED(event)) notebook->AddTab(); } -void MainFrame::OnMenuFileOpen(wxCommandEvent &WXUNUSED(event)) -{ - wxFileDialog *OpenDialog = new wxFileDialog(this, _T("Choose a file"), _(""), _(""), _("*.*"), wxFD_OPEN); - - if (OpenDialog->ShowModal() == wxID_OK) - { - // Load the file into a new notebook tab and styled text control - } - OpenDialog->Close(); -} - -void MainFrame::OnMenuFileSave(wxCommandEvent &WXUNUSED(event)) -{ -} - void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event)) { Destroy(); diff --git a/src/Main.h b/src/Main.h index a712527..dfc03dc 100644 --- a/src/Main.h +++ b/src/Main.h @@ -25,8 +25,6 @@ class MainFrame: public wxFrame void SetupToolbar(); void SetupStatusBar(); void OnMenuFileNew(wxCommandEvent &event); - void OnMenuFileOpen(wxCommandEvent &event); - void OnMenuFileSave(wxCommandEvent &event); void OnClose(wxCloseEvent &event); void OnQuit(wxCommandEvent &event); void OnAbout(wxCommandEvent &event); diff --git a/src/SFTP.cpp b/src/SFTP.cpp new file mode 100644 index 0000000..7e3348e --- /dev/null +++ b/src/SFTP.cpp @@ -0,0 +1,45 @@ +#include "SFTP.h" + +SFTP::SFTP(const char *host, string user, string pass) { + struct addrinfo host_info; + struct addrinfo *host_info_list; + int sock; + int status; + int rc; + + // Clear out memory in addr structure + memset(&host_info, 0, sizeof host_info); + + host_info.ai_family = AF_UNSPEC; + host_info.ai_socktype = SOCK_STREAM; + + status = getaddrinfo(host, "22", &host_info, &host_info_list); + + if (status != 0) + { + cout << "getaddrinfo error" << gai_strerror(status) << endl; + } + + // Start libssh2 + rc = libssh2_init(0); + + if (rc != 0) + { + cout << "Libssh2 initialization failed " << "(" << rc << ")" << endl; + return; + } + + sock = socket(AF_INET, SOCK_STREAM, 0); + + session = libssh2_session_init(); + + /* Since we have set non-blocking, tell libssh2 we are blocking */ + libssh2_session_set_blocking(session, 1); + + // Actually do the ssh handshake + rc = libssh2_session_handshake(session, sock); +}; + +SFTP::~SFTP() { + +}; diff --git a/src/SFTP.h b/src/SFTP.h new file mode 100644 index 0000000..049089d --- /dev/null +++ b/src/SFTP.h @@ -0,0 +1,34 @@ +/* + * File: SFTP.h + * Author: twarren + * + * Created on April 6, 2015, 2:22 PM + */ + +#ifndef SFTP_H +#define SFTP_H + +#define LIBSSH_STATIC 1 +#include "common.h" + +// libssh2 includes +#include +#include + +// Socket includes +#include +#include +#include + +class SFTP { +public: + SFTP(const char *host, string user, string pass); + ~SFTP(); +private: + LIBSSH2_SESSION *session; + LIBSSH2_SFTP *sftp_session; + unsigned long hostaddr; +}; + +#endif /* SFTP_H */ + diff --git a/src/common.h b/src/common.h index 5c43657..fbfb206 100644 --- a/src/common.h +++ b/src/common.h @@ -13,6 +13,7 @@ using namespace std; +#include #include #endif // TYRO_COMMON_H