How use QT WebChannel without webSockets - html

Is possible to use QT QWebChannel without websockets, but using WebKit ICP?
I only found examples using webSockets.

Unfortunately, the documentation states that:
It works on all browsers that support Qt WebSockets, [...]. Additionally, a custom transport mechanism can also be implemented using Qt WebSockets to support Qt WebChannel-based communication.
It seems that you cannot use it without WebSockets, and it would explain why all the examples you find actually use them.
Anyway, it also states that:
The transport mechanism is supported out of the box by the two popular web engines, Qt WebKit 2 and Qt WebEngine (experimental).
Despite the fact that it is experimental, it looks like an alternative to the WebSockets.
Actually, while digging into the linked documentation, I've found that page where it is said about WebKit that it implements internally the required interface and it can be used in place of the WebSockets, but no example is provided.
You can find spare information all throughout the linked page, as an example it is said that:
For HTML clients run inside Qt WebKit, you can load the file via qrc:///qtwebchannel/qwebchannel.js. For external clients you will need to copy the file to your webserver.
Then, it follows a brief description of the steps to be done to achieve the same on those clients, as far as I understand by using no WebSockets in this case.
That said, It seems to me that the solution based on the WebSockets is the suggested one, so probably you should reconsider you architecture and use them. Otherwise, be ready to deal with experimental and poor documented features.

Related

Not sure about the way to approach to the IndexDB API and wrapper libraries?

I have started a crash course of IndexDB API. I have heard from the author that the API is a little bit confusing. Primarily, as we have been working with the promise pattern as this API doesn’t use this pattern. Secondary, there are different wrappers, one of them seems is from Github author’s personal library so I suppose he have created it.
However looking for a different flavor, I found this one: http://dexie.org/. Also supports the Promise pattern. See http://dexie.org/docs/Promise/Promise, http://dexie.org/docs/API-Reference#query-items . It seems “promising”.
Also I found that the IndexDB 2.0 API was created post the video time. It is already being supported since beginning of 2017. From a Mozilla developer, I found since Firefox 51 (Jan 2017) it is already there. And he wrote what’s the differences among 1 and 2 versions https://hacks.mozilla.org/2016/10/whats-new-in-indexeddb-2-0/
So my question is if at this point is better to use the wrapper libraries or to use the native IndexDB API in terms of cross-browsing and support and better practices?
It all depends on what you want to do with indexeddb -
If you are learning indexeddb for your interest or for knowledge then you should go for plain indexeddb. Learn and research as much you can, because it has too many apis and you will have to write code for every type of situation.
You want to use indexeddb in your project and dont have much time to explore indexeddb. You only want to do some database operations and release your project. In this case - you should go for indexedd library. This way you dont need to worry about indexeddb code . You will just write simple code using the library.
For instance : check out this article - https://dzone.com/articles/crud-operation-in-indexeddb-using-jsstore. How a library makes indexeddb so easy.
Hope this will help you.

Flex realtime polyfill

I'm developing a service in flex which requires realtime invalidations and I was wondering which is the recommended method to add realtime support to Flex applications (any change to data models should be reflected to all subscribed clients).
Here are some concerns:
My server is written in python3 (tornado, sqlalchemy, redis) although I don't care adding another service written in other language as long at it is simple and not a resource hog (no java please :)). My client is written in Flex and this must be supported
I want to have multiple servers\processes to handle realtime
connections and I don't want to use sticky sessions (SPOF?). All of the processes will be behind a Load Balancer.
I don't
care about the transport method as long as it is not proprietary (no RTMP), it has fallbacks and it is well supported (mostly IE9 and above)
Currently, I use Tornadio2 and FlashSocket.IO but both are not maintained and not recommended.
I thought about using SockJS though It doesn't have Flex support (can I use it through the browser?), and it seems that beside FlashSocket.IO, there are no other libraries available. It should also be noted that this library doesn't have fallback capabilities.
During my research, I saw several relevant questions:
Real-Time communication between PHP and Flex application
Realtime update and Push Data in AS3
But they are 4 years old, and doesn't provide a good answer.
Any thoughts on the subject would be appreciated.
It seems that this topic is not hot (to say the least), but in case someone is interested, I managed to get around it by using SockJS on the flex html wrapper and communicating with it using external interface
I am doing something similar in Flex by using WebSockets (sockets.io) on the serverside. On the client side, I am using the AS3WebSockets library from https://github.com/theturtle32/AS3WebSocket
Works exceedingly well!

Should i use Lawnchair or localForage to maintain data offline

I'm writing an app using Ionic framework. I use mongodb as a datastore in the cloud but the lists are too comprehensive and is slowing the app down. After consuming millions of hours reading about client side storage I still dont have a clear answer.
I hoped it would be possible to serve these comprehensive json files native from the client, which is ios + android + windows phone but having not "server" to serve it that idea seemed to be a dud. Dont know if my limited understanding of the rest API in angular is at fault but logically that idea doesn't make sense.
Looking at on native sql clietn I investigated sqlite. Since sqlite implementation on these different platforms(ios + android + windows phone) will be a pain i looked at the different types of browser caching.
I dont want to go into to much detail but localstorage is to simple for my structures, and the other options are not being supported or deprecated. Its a mess. However, the two options regarding offline data solution i have found is Lawnchair and localForage.
What is the differences between these two as they provide the most comprehensive solution based on the client. Any one willing to suggest a beter / worse option.
Then there is the site files which i also want to cache using app cache but I'm not sure how to since I'm using https://www.npmjs.org/package/generator-ionic which is kick-ass by the way.
Lawnchair syntax is a bit more complicated than localForage and the project is no longer updated whereas localForage is (and it's developped by mozilla).
If you are using angular, then go with https://github.com/ocombe/angular-localForage which is my implementation of localForage for Angular, it will be really easy and you can force the driver you want to use if necessary (but on mobile local storage will never be choosen since all mobile smartphones support either websql or indexeddb).

Using Java/Python libraries in programming Firefox/Chrome Extensions

I have an idea of studying user behavior on the browser, for which I intend to make a Chrome/Firefox extension to study the behavior dynamically. I have some predefined libraries in Java and Python to analyze the results, which will be impossible to program in plain JavaScript.
Now for my question: is it possible to use third party libraries, especially those of Python or Java like plain function calls?
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. However, for a beginner, it all looks so scary. I started making Add-On for Firefox, but got lost somewhere in the huge API.
I found Programming Chrome extensions easier than Firefox, but I couldn't come across something similar to XPCOM in Chrome.
How can I decide which one to go for?
Chrome - seems easy but I am not sure of its power.
Firefox - Seems powerful, but is it really possible to use any Java/Python Library?
Additionally, I came across this link that may be useful: How does someone use thirdparty libraries to be included in Firefox addons/extensions?
But seems like it mostly talks about C++ and XPCOM.
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. But for a beginner, it all looks so scary.
I am not a beginner and JavaXPCOM/PyXPCOM are very scary (in addition to being barely maintained). As Firefox goes, it should be much easier to wrap your Java/Python library in an application and run it as an external process: https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIProcess. Note that you cannot get data back (other than an exit code) so the application should write it to a file that you can then read in your Firefox extension. Not very elegant but it has the advantage of being doable.
As to Chrome, its extensions run in a sandbox and using Java or Python isn't possible. Only option is adding an NPAPI plugin to your extension. It is binary code meaning that it could do anything.
When writing Chrome extensions, you're limited to JavaScript unless you choose to use an NPAPI plugin, which lets you do pretty much anything, but is not recommended.
The other approach you could take is to implement your Java or Python code on the server and make requests from the chrome extension's JavaScript.

Delphi with HTML/CSS interface

I want to develop a delphi application with an HTML/CSS graphical user interface, not necessarily running from within a web browser. I want to do this do create a richer graphical user interface with animations etc. and break away from normal VCL components / Windows look. Any suggestions?
HTML and CSS won't deliver animations or a Rich User Interface to your feet. Far from it in fact. Quite the opposite. You will need to invest in a toolkit to provide that sort of functionality and almost certainly involve JavaScript. And even if you don't want your eventual application hosted in a web browser, your application will itself have to host a web browser to render your HTML/CSS/JavaScript UI, and you will then have a much more difficult job of connecting your GUI to your application logic (unless you do actually embrace a web application architecture).
Delphi (or any Windows application development language for that matter) gets you much, much further down the road towards a more simply, effectively and quickly implemented Rich User Interface than HTML or CSS.
If you don't like the look and feel of the standard Delphi controls (which in essence is what you are saying) there are numerous alternative libraries available.
Also bear in mind however that when someone uses a Windows application they expect it to look and behave a certain way to a large extent. Using fancy, web based paradigm's in a desktop application simply for the sake of it is likely to confuse and frustrate users if taken too far.
I'm all for user interfaces breaking with convention where it leads to a more intuitive user interface, but simply being "prettier" does not necessarily lead in that direction and is just as misguided as dogmatically adhering to convention.
In one of my applications I have an an embedded browser and I have implemented the IDocHostUIHandler interface. This allows me to expose a COM object via the "GetExternal" method. I simply have a COM object that exposes methods and properties of my application which makes them available to the web pages hosted inside the embedded browser.
So the script in my web pages has lines like "external.DoSomething()" and "i=external.GetThisValue()". So, for example, behind button onclick events you can run a method of your application (implement in the main form, in the COM object itself, or whatever you like).
This site has lots of info on embedding a browser in your Delphi app:
http://www.delphidabbler.com/articles?article=22
It can certainly be cumbersome to implement a lot of this stuff and in many cases there are probably better options. But for my specific purpose I am able to offer a "home page" which can easily be modified to change its layout, look and even expose more (or less) functionality as required by myself or my users.
If you want a Delphi program with a better-looking interface, HTML is really not what you're looking for. What you really need are better-looking VCL controls.
Take a look at TMS Smooth Controls, for example. If you're on Delphi 2009 or 2010, you can get it as a free download here. That's one of many component libraries that can bring a slicker user interface to your program.
HTML / CSS offers some nice features which are (not yet?) available in Delphi and the VCL. They are also a good starting point for client/server programming, separating the user interface and the business logic is a key factor here.
One popular library for Delphi is the extpascal project:
ExtPascal is an Object Pascal (Delphi,
FreePascal/Lazarus) wrapper/binding
for Ext JS, a complete GUI Ajax
framework, made in JavaScript, for
Rich Internet Application (RIA)
development. ExtPascal lets you use
Ext JS from Object Pascal commands
issued by the server. It brings the
structure and strict syntax of the
Object Pascal for programming the web
browser. ExtPascal will wrap Draw2d
into future releases.
Some demos are online here and here.
p.s. and I really like the HTML / CSS support for element and font sizes in relative units (for exampe percent). Combined with browser zoom in / zoom out and WCAG, user interface ergonomy can not be much better.
HTML Option 1
If you relly want to use HTML+CSS(+JavaScript) to build a GUI, you can have a look at HTML Applications, a very fascinating concept from Microsoft. HTML Applications, .hta files, have been supported from Windows ME, if I remember correctly, and they are still supported on Windows 7.
You could create an HTML Application (i.e. an HTA file), and by so doing, creating a GUI using only HTML, CSS, and JavaScript. When the user double-clicks the HTA file, it will open like a program, but the GUI is entirely based on HTML; in fact, the entire Window is an Internet Explorer window in disguise.
And now comes the important part: you could create non-GUI Delphi applications (i.e., Delphi applications that are not console applications, but that have no forms either), and start them via hyperlinks (or JavaScript) from within your HTA GUI. (Well, it is probably better to create one such Delphi application, and use command-line arguments (ParamStrs) to communicate the desired action.)
Just an idea...
HTML Option 2
Alternatively, you could create a normal Delphi GUI application, but fill the entire main form with a TWebBrowser (a IE control), using Align := alClient. Then you could either load static HTML pages (stored in the Program Files folder or on the Internet), or you could use Delphi to dynamically create HTML pages to show. I think it is possible to intercept links from the control, so that you could respond to links using Delphi code.
What about OpenGL?
If you want to "break away" from the normal Windows look and feel, then I would recommend you to create your GUI using OpenGL. It is very easy to make a Delphi application with OpenGL (as long as you are familiar with OpenGL) - just add "OpenGL" to your uses list.
First this: I completely agree with Deltics' answer.
Having said that, if you master HTML and CSS (and JavaScript and AJAX etc etc) and you are looking for a way to use the power and speed of the Delphi compiler to run the dynamics of a website, this may be of interest.
I've created a project that uses the Delphi compiler to build a library that runs a website. The source-files combines HTML and Delphi, much like other web-scripting tools out there, but gets processed on a page-refresh, and compiled automatically. It uses a 'library handler' that plugs in the website library into pretty much anything you like: IIS, Apache, a stand-alone HTTP server (for hosting), or directly into InternetExplorer or FireFox (which is great for developing).
http://xxm.sourceforge.net/
New versions of Qt contain ability to use html/js for interfaces. I don't know if there is Qt library bindings for Delphi, but Qt is exactly what you want.
for Rich GUI and animation, have you looked at KSDev DXScen and VGScene ?
If you want to keep your delphi/Pascal Object 'background' and have a Web like RIA you also have a look to Morfik : link text