Download from a URL with C++ - c++

I'm playing around with C++ for the first time in years. Making an app using Qt, with the Qt IDE. I want to make an app to integrate with the Flickr API. I've got to the point where i need to make a call to a URL.
Flickr API:
http://flickr.com/services/rest/?method=flickr.people.getInfo&api_key=987654321&auth_token=9765984&api_sig=8f3870be274f6c49b3e31a0c6728957f
Right then ..... I'm used to .NET so this would normally be easy. Is there something built into Qt to allow me to do this or do i need a C++ web API. If I do need an API can you recommend one that would do the job.
Kind Regards

Use QNetworkAccessManager. The page has an example.

we do use Qt but ended up using the cURLpp C++ wrapper for libCURL (http://curlpp.org/) for a similar project.

Related

Play Scala - Native access

I am developing an web application using the Play framework in Scala language. In my application I have to access the native methods which is written in C++ and converted into .so by using swig.
My aim is to call the native method which is in .so file from the Controller class. I have searched in the internet, but I didn't get any documentation for this.
I have seen some links which is used by scala language.
https://code.google.com/p/scala-native-access/
https://code.google.com/p/bridj/wiki/Download#Specialized_subsets_(smaller_JARs_!)
https://github.com/xudongyang/scala-native-access
But they didn't mention how exactly use this in the Play framework.
Can anybody have the documentation for Play scala native access?
Can anybody have the sample applcation for the same?
Like in any JVM language, JNA/JNI gives you native access. Be aware that because of Play's use of class loaders, you'll need to make sure you access from the same class. See fail to load a native library using activator (Play Framework)
This is hard to answer in general. Play! is just a Scala library and framework, some any tool that allows you to use native calls in Scala will work similarly with play. From the first link that you pointed to, there are instructions to integrate with SBT (the Scala Build Tool) which also manages your Play framework. You will need to make the changes they mention to your build.sbt file which you can find in the top level of your Play project folder.

Using Qt to implement a C++ HTTPS SOAP client on Linux

After having some issues using OpenSSL and gSOAP, I have been looking into the use of other options for the HTTPS transport mechanism for SOAP requests. Something that caught my eye was QNetworkRequest that I believe is part of Qt. I have never used Qt before but from the research I have done I get the impression that it is geared towards the development of GUI applications. My application is not a GUI, so my question is is it possible for me to access the functionality of QNetworkRequest outside of the Qt development environment ?. Is it possible via linking to an appropriate library and appropriate header file inclusions or must I develop a full blown application inside the Qt IDE in order to access the functionality? If I have to import my project into the Qt IDE then this option is not for me so before I spend weeks reading manuals and web tutorials I would like to see if experienced users of Qt can tell me if what I want is possible or if I need to look elsewhere. Thanks.
In general GUI frameworks are highly coupled; especially those written in C++.
I'm sure you could decouple QNetworkRequest, but it would probably take a long time to do.
If you use a different library which has the functionality you're after (e.g.: Apache Axis) you'll be much better off.

How to run C++ applications on a webpage?

Are there any tools to run C++ applications written in QT on standard web browsers?
My C++ app has to run from a webpage, do some math, and return the result back to the webpage.
Check out NaCl (Native Client). No Qt, but you can use c++.
You can't. You can write the server side in a web app in C++, of course, but the Qt GUI framework is only for applications that show their user interface on the machine they are running on. (With the usual caveats in the case of remote X11 connections and so forth, but that won't help you for a web app).
I have read about a sample application like this. I think you can search for this term "Qt WebKit Hybrid application". In that example, the user interface is written in HTML and Javascript and the backend in C++. Even, the C++ objects ownerships can be transferred to Javascript. I'm not sure I'm correct but I'm partially correct.
EDIT:
Here is the link.
https://developer.qt.nokia.com/wiki/Server-Driven_UI_with_Hybrid_QtWebkit
It's possible to compile C++ code to JavaScript using Emscripten, and then call compiled C++ functions from JavaScript, as explained here. This will allow you to run C++ code in a web browser or other JavaScript environment, without any additional plugins.
There is one more solution to this, you can write a browser plugin. I think that this is better then ActiveX and NaCl. For details on how to write plugins check this: How to write a C++ FireFox 3 plugin (not extension) on Windows?
Maybe you could embed the code in an ActiveX control.

Controlling Firefox from C/C++

I'm thinking of creating an application that can use Firefox as a download manager. Is there any way to control Firefox (add downloads, start/stop downloads, etc) from an external program in C/C++?
If that is not possible, then perhaps an extension that can do that? If an extension is the only way, then how do I communicate with the extension from outside of Firefox?
You're starting with a solution, not a problem. The easier idea is to use XulRunner, the platform on which FireFox is built. You'd effectively implement your own application as a XulRunner plugin and use Necko (the network layer of XulRunner and FireFox) from there.
First of all I suggest that you familiarize yourself with developer.mozilla.org
As far as I understand, most Mozilla platform functions are available through a cross language API known as XPCOM. There's also a plugin API but it's primary aim is to visualize stuff (used by Flash, etc.).
Take a look at Gecko API. It allows third party developers to use the same technology as found in Mozilla.
For downloading files no need to use Firefox. Consider using libcurl.
Take a look at wget.

What embedded browser for C++ project?

Is there any browser I could embedd in C++ application on Windows?
I need all features typical browser has (HTTP client, cookies support, DOM style HTML parser, JavaScript engine) except rendering.
Because I don't need rendering capability (and that's rather big part of a browser) I would prefer a browser with non monolithic design so I wouldn't have to include rendering stuff into my project.
It would be nice if it had C++ rather than C API.
I need this embedded browser mainly because I have much trouble finding C++ HTML parser which could handle broken HTML like browsers do.
If you know any, please answer Library Recommendation: C++ HTML Parser SO question or at least vote on it to increase a chance someone will give a good answer.
Sounds like all you need is something like libcurl which is an HTTP library and will let you do GET/POST/etc.
When I think browser I generally think rendering/JavaScript and not HTTP library.
Edit
In that case I'd look at WebKit (which I think has a C++ API) and hope you don't have to pull too much in.
Edit Again
On second thought (since rendering is such a big part of what browsers do), you might be better off using a stand-alone JS engine like SpiderMonkey and a stand-alone XML parser like Xerces-C (plus maybe tidy to make your HTML into XML).
I'm a bit confused by your question regarding embedding a web browser for which you don't need rendering capabilities. A web browser is rendering web pages by definition, unless you just need HTTP and XML with JavaScript capabilities which is a subset of a browser functionalities?
If you need a web browser to embed in your C++ application, I would suggest to consider Qt that comes with the WebKit plugin. It is C++, LGPL and has a very nice IDE (Qt Creator). I tried Qt with Qt Creator on unix (Ubuntu) and it was very impressive. The debugger is a bit light but it is just the first version. The adapter of Qt into visual c++ 2008 is now free.
You might also want to check out Awesomium-- it's free for non-commercial use and has all of the features you're looking for (if you don't need rendering, simply don't use it).
There is a project called CEF = The Chromium Embedded Framework - it is:
a simple framework for
embedding Chromium-based browsers in other applications. It is a
BSD-licensed open source project founded by Marshall Greenblatt in
2008 and based on the Google Chromium project. Unlike the Chromium
project itself, which focuses mainly on Google Chrome application
development, CEF focuses on facilitating embedded browser use cases in
third-party applications.
and yes:
The base CEF framework includes support for the C and C++ programming
languages.
Including javascript support and html parsing makes this non-trivial task - you have to use one of the available browsers.
IE is usable through its COM model - you can create instance of it in your window be it invisible or not and call its javascript/html capabilities.
It has been designed to be used like that since the beginning and certainly it is working fine.
The other options are:
Gecko/Mozilla - a couple of years ago it wasn't usable like this, currently I think it is.
WebKit/V8 - no public API has been released for chrome yet, you could use webkit itself, but it doesn't have javascript engine. Another option is to take a look at the Chrome codebase and see if you could get out of it what you need.
I would probably go for IE, since it is maybe the easiest option and I have already used it. The other options seem to me more like building a browser instead of just using it.
How about Gecko ? You may not need the entire engine but you may find some its components useful like SpiderMonkey which is a JavaScript engine written in C.
I'd recommend picking up Qt for C++ programming. It has a built-in library that embeds Webkit with all the bells'n'whistles, and Qt is a great C++ library in general.
Old question, I know, but take a look on
http://msdn.microsoft.com/en-us/library/ky29ffxd%28v=vs.94%29.aspx
IActiveScript and family COM interfaces allows script execution (not only JS, any language that registers as script interpeter, for that matter) in-memory.