Ticket #7938: url_feature.diff
File url_feature.diff, 3.0 KB (added by , 12 years ago) |
---|
-
src/interface/Mainfrm.cpp
1 1 #include <filezilla.h> 2 2 #include "Mainfrm.h" 3 3 4 #include <wx/textfile.h> 5 #include <wx/url.h> 6 #include <wx/file.h> 7 #include <wx/sstream.h> 8 9 4 10 #include "LocalListView.h" 5 11 #include "LocalTreeView.h" 6 12 #include "queue.h" … … 725 731 if (m_pQueueView) 726 732 m_pQueueView->SetActive(event.IsChecked()); 727 733 } 734 735 else if (event.GetId() == XRCID("ID_MENU_TRANSFER_URL")) 736 { 737 wxString getUrl = wxGetTextFromUser(wxT("Enter URL (with http/https) :"), wxT("Enter URL")); 738 wxURL url(getUrl); 739 #define BUFSIZE 8192 740 if(url.GetError()==wxURL_NOERR) { 741 wxString getPath = wxGetTextFromUser(wxT("Enter Path (end with '/') :"), wxT("Path")); 742 wxString getName = wxGetTextFromUser(wxT("Save as (example.pdf) :"), wxT("Save")); 743 getName = getPath + getName; 744 wxFile outfile(getName, wxFile::write); 745 wxInputStream *in_stream = url.GetInputStream(); 746 if(in_stream && in_stream->IsOk()) { 747 unsigned char buffer[BUFSIZE]; 748 do { 749 in_stream->Read(buffer, BUFSIZE); 750 size_t bytes_read=in_stream->LastRead(); 751 if(bytes_read>0) 752 outfile.Write(buffer, bytes_read); 753 } while( !in_stream->Eof() ); 754 delete in_stream; 755 outfile.Close(); 756 wxMessageBox( wxT("Done!") ); 757 } 758 } 759 else 760 { 761 wxMessageBox( wxT("Error! Check Entered URL") ); 762 } 763 } 764 765 728 766 else if (event.GetId() == XRCID("ID_MENU_HELP_GETTINGHELP") || 729 767 event.GetId() == XRCID("ID_MENU_HELP_BUGREPORT")) 730 768 { -
src/interface/resources/menus.xrc
130 130 <checkable>1</checkable> 131 131 <accel>CTRL+P</accel> 132 132 </object> 133 134 <object class="wxMenuItem" name="ID_MENU_TRANSFER_URL"> 135 <label>&Download by URL...</label> 136 </object> 137 138 133 139 <object class="separator"/> 134 140 <object class="wxMenuItem" name="ID_MENU_TRANSFER_FILEEXISTS"> 135 141 <label>&Default file exists action...</label> … … 597 603 <label>&Configure speed limits...</label> 598 604 </object> 599 605 </object> 600 </resource> 601 No newline at end of file 606 </resource>