When moving files around locally within my project I'm able to use
return QFile::copy(fromPath, toPath);
I need to do something similar but with the fromPath being located on the web.
What is the best way to accomplish this?
QFile works with local file only.
If you want to copy remote file from web, then you need to download it using QNetworkAccessManager
Install on your source and destination machine ssh. Then do a scp via QProcess.
This is one way. The best? Depends on your requirements. You can also write a program for your destination machine, which accepts incoming TCP connections from your source machine. Then you connect via QTcpSocket and send your data. Qt4 has a QFtp class. Never used it. Is also a dead end, since it does not exist anymore in Qt5. But maybe it is good enough for your current needs.
I hope you did not expect a more specific answer. There is not 'remoteQFile::copy' command. And there is no general 'best way'.
Related
I'm trying to make an application which sends a directory which contains a tree of files/directories from one computer to another one.
I've searched but I couldn't find much. Is there any ready function?
How do I to proceed with this please?
Thanks a lot !
EDIT:
OS: Windows 7 SP1.
IDE: VS2013.
I think using FTP can be a good method.
WinInet and libcurl have function relative FTP.
Many developers have been recommanding using libcurl rather than using WinInet.
However, it depends complexity and scale of your application.
The by far easiest would be to use a network share resp. share a directory on the target computer. That would work with *nix systems as well, using Samba. If that's possible the operation boils down to simple file system copies. If that's not possible:
I think you must create an archive of the directory tree before you can send it through a network connection. You could call that serializing. .NET 4.5 has built-in support for creating zip files, cf. http://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive%28v=vs.110%29.aspx.
How to traverse a dorectory tree is shown in http://msdn.microsoft.com/en-us/library/07wt70x2%28v=vs.110%29.aspx.
How to use FTP programmatically is shown in http://msdn.microsoft.com/en-us/library/ms229715%28v=vs.110%29.aspx. But you'll need a running FTP server on the remote machine.
The remaining problem is how to unzip the file at the destination. For that you'll need a logon.
Is there an idea to handle that file downloaded by any browser or moved or copied from another location (not downloading or moving or coping)?
Safari and Chrome add .(.*)download extension, so download finishing easily handled.
Moving or coping are rapid processes so they can be handled by file size difference after some delay. But it also can be unreliable in some cases like firefox download process.
Also I want cross-platform solution. I use Qt framework.
I am not sure exactly what your question is, but perhaps QFileSystemWatcher is what you are looking for.
From the documentation:
The QFileSystemWatcher class provides an interface for monitoring
files and directories for modifications
(I Use Ubuntu)
I'm looking for some pointers for writing a firewall program which denies every port/ip at first and creates rules by asking you whenever a program wants to access the internet, much like the discontinued product Kaspersky Anti Hacker for Windows. I especially want to use it on web browsing. So if my web browser wants to access stackoverflow.com the program should ask me if it should make a connection to stackoverflow.com's ip address, or when torrent client wants to connect a peer It should ask to either allow that port or allow that ip/port only.
I have used gufw but I have to know the port/ip before adding the rules so it isn't as I want it to be. I'm also trying to stay out of Firestarter since the last release was in 2005. So I have decided to write my own.
I just need some pointers on this subject. It can be a terminal command to see the connections I make with other computers, or a way to prompt before making connections, an open source project that sounds like this, or a c++ library/shell program that I can use to write a program for this... Any lead at all would suffice.
If you could point me in the right direction, I would appreciate it.
PS. I am familiar with c++ and shell and php but that's irrelevant.
Hmm, you seem to be interested in Windows only. If so, you might wish to look at Windows Layered Socket Providers (LSP) infrastructure.
In short, you can write DLL, which would be automatically loaded into any application that uses Winsock. This DLL can intercept calls to any Winsock function like connect(), send() and etc. When such call is intercepted you can show user some window asking if he wish to connect to this address.
So, this can be used to build such firewall application you are thinking of.
There should be a lot of documentation on how to create LSP's on Microsoft site, but i remember especially nice example by Komodia company - http://www.komodia.com/lsp/lsp-sample.
My main goal is to create an advanced program for manipulating the packets that route within my network via the router. Let my program have total control over the router. Set the download/upload speeds to my inputs, apply the effect to certain devices within in my network. Block upload or download traffic. Set second delay for either the upload or download speed. Specify % of loss packets, and the list goes on.
The problem is that I don't know where to start. I know most languages at the very most basic level. I'd like to create this program in either C, C++ or C# but I don't know yet. What else do I need to know before creating this program? Winsock or something? Winpcap APIs?
This goal is my motivation to learn programming to the extreme, and I'm really looking forward to it.
Thanks in advance!
Hmmm I guess you would want to look at pcap(?):
pcap
Check out:
http://beej.us/guide/bgnet/html/multi/index.html
'Beej's Guide to Network Programming
Using Internet Sockets'
All you could possibly need to know about programming sockets for capture and manipulation.
If I were you I'd write it in C, I'm writing a similar project at the moment in C++ and it's hell but too late to stop and start again.
Hope that helps.
Bear in mind that you either need a router that you can re-program or you need to use your PC as a router to do this.
Either way you want to look into how IPTABLES are implemented.
I've never seen Desktop Windows used as a router only Windows Server, though it may still be possible. libpcap is for packet capture, but not interception as I understand it. Programs like Wireshark use it to monitor copies of packets, but not to modify them. If you want to attempt this, my impression has been that there is a lot more documentation and tools for doing something like this with NetFilter/IPTables on Linux. You can even install something like OpenWRT on a compatible router and get a small, cheap Linux router, though having Desktop Linux will probably help for development. The NetFilter QUEUE library can be used with some IPTables firewall rules to redirects specific (or all) packets to a regular user program. That program can then read the packet and modify it or even request it to be dropped.
http://www.netfilter.org/projects/libnetfilter_queue/
If you want to manipulate network traffic on a Windows machine (as you mentioned), you will need some extra software. This operating system wont give you the full control over itself, which is fine for some reasons.
I think what you want to do, should be done with either winpcap or win10pcap if you are using Win10. These packages contains a windows driver and the libpcap user space library.
i am trying to create a C++ program on Windows machine which has to execute a program on remote machine, transfer the generated file to local machine. The remote machine is also windows.
Is there any efficient method to implement it without using MFC? Is it possible to do it without server/client component?
Regards,
Adil
I don't recommend coding your solution since other solutions already exist. One of them is Rsync, which is pretty popular in *nix circles.
A Windows friendly version also exists, and it's called DeltaCopy.
Unless you're trying to improve your skills, or have the time, or you believe you can do better, stick with proven solutions.
There are any number of windows remote shell solutions that will allow you to do this without programming. You can also use a remote desktop client.
use ftp command from c++ or Cleint/Server.