Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I want to launch a Web GUI as soon as I plugged in the device to system. Is there any way by which we can do this. Is it possible using any web development language (e.g. PHP).

Regds
SNI
Posted
Comments
Sergey Alexandrovich Kryukov 6-Oct-13 9:41am    
Why? What do you mean by Web UI and "system", client or server side? What do you mean by "Web development language", client or server side? And what's the device, a network device or something else. So far, nothing is clear. It would be better if you start with your ultimate goal and explain the whole idea...
—SA
SNI 7-Oct-13 2:00am    
sorry...
I am developing Web UI for ADSL (device) like router, which allows user to view and modify settings of this device. What I want to try is to launch web UI as soon as I connected to system. I want to know whether it is possible using PHP or any other language like CGI or FastCGI?
Sergey Alexandrovich Kryukov 7-Oct-13 2:24am    
You are still not describing a scenario. If you mention PHP, you should have some server hosting PHP. Where it should be? What is the sequence of events? And so on...
—SA
SNI 7-Oct-13 4:52am    
fine....
It is dongle device for which I am developing this UI and web server would be lighttpd. We develop this UI and host it in dongle like most of the ADSL routers. As soon as user connects the dongle device then based on any browser installed on client m/c it shd pop up this Web UI to user to view or modify device settings.
Sergey Alexandrovich Kryukov 7-Oct-13 11:11am    
Okay, now I can write something more certain to answer you. Please see Solution 1.
—SA

1 solution

You cannot do it through a Web application. For apparent security reasons, Web is designed the way that it's not possible to write any remote application which could force a client to do any action. In particular, a Web application cannot get access to a client system, and everything happens by request of a client side. Moreover, if you mention that you want to do something "based on any browser installed", it should mean that it should not assume that any browser is even being executed at this moment, so what PHP can even be discussed?

One exclusion in Microsoft ActiveX. You can install an ActiveX component used on a Web page. But 1) this can work only on certain systems (almost exclusively Microsoft) and compatible browsers, so it is very limiting, please see below; you would have to forget "any browser installed"; 2) ActiveX components for the Web are considered as a very unsafe feature, as it contradicts the security principles mentioned above; 3) you would still need the browser running at the moment of detection.

You can solve such problems only if you develop some client-side software and distribute it to clients on their consent. (If a user get a dongle physically, it means that it is is possible to deliver some software with it.) This software should be installed in client side and it has nothing to do with Web applications. Now, in contrast to Web programming, the problem is that you would be able to develop such software only for limited set of different systems. If you wanted to make a browser plug-in (which would be only natural, imagine that mechanism works is a browser is working; when a user inserts a dongle, this is detected and then the browser will request something at some URI), you would be also limited to some set of browsers and their version. The detection of a dongle is quite possible (I hope this is an USB dongle); if you search Code Project you can find a number of articles on the detection of an USB device:
Detecting Hardware Insertion and/or Removal[^],
Hardware Change Detection[^],
find more: http://www.codeproject.com/search.aspx?q=USB+detect&doctypeid=1[^].

After all you should know, that if you insert, for example, a USB storage device in nearly any computer system with UI, you get a notification asking you about mounting, of formatting, or browsing the detected media. You can do the same. But again, you need to do it for some set of particular user's platforms, which is a very limiting factor.

[EDIT]

Yes, you can get the USB notification in a Windows Service as well. For development of the Windows Services, please start here:
http://msdn.microsoft.com/en-us/library/y817hyb6.aspx[^],
http://msdn.microsoft.com/en-us/library/40xe80wx%28v=vs.90%29.aspx[^].

This CodeProject article can also be helpful: Simple Windows Service in C++[^].

Remember that you will have to re-work your projects considerably, to make it a service. First of all, you cannot use any UI (as the service keeps running when everyone is logged off, so there is no a desktop to host any UI). The usual approach is having a separate UI application which communicate to the service application via IPC, when some user is logged on and the desktop is available.

I also developed a technique when the same application can be executed interactively or registered as a service to be executed under the Service Controller. Doing so is yet another known technique, but not so usual. In my case, the interactive part of application does have UI. A big part of debugging can then be done in the interactive mode.

—SA
 
Share this answer
 
v2
Comments
SNI 8-Oct-13 14:02pm    
Thanks, this answers my question. I did the same thing and as you mention creating an application in (may be VC++) which will detect device change event and then launch the web ui for that we need to make this app to act like a service. I was just trying to identify whether I could remove this overhead of creating such app.
One question if we create an app as I mentioned in MFC then is it possible to work as a windows service? whether this app will be able to get the device change event?
Sergey Alexandrovich Kryukov 8-Oct-13 14:07pm    
Yes, you can get the events in the same way as in regular application, but you will need to re-work your application to the Windows Service model. You need to use the documentation on Windows Services. You cannot use any UI in services...
—SA
Sergey Alexandrovich Kryukov 8-Oct-13 14:14pm    
I provided some more detail in the updated answer, please see after [EDIT].

As you say this already answers your question, will you accept it formally then (green "Accept" button)?
Still, your follow-up questions will be welcome.

—SA
SNI 12-Oct-13 3:30am    
Hi I am stuck to one point. I am using php to develop this UI for dongle device but I have a limitation of using PHP since it makes my device slower so that I am looking for another option that will help to develop UI. I have the following features needs to be provided in my Web UI:-
1) Reading from config file and show to user in specific time interval (say 5 secs)
2) Reading values from conf file and plotting a graph (with gradient effect)
3) Providing drawer effect to user on button click.
4) I have to update different parts of my Web UI.

Please suggest me which technology shd I opt for to develop this such UI (javascript/Ajax/....???).
I am using lighttpd as a web server.
Sergey Alexandrovich Kryukov 12-Oct-13 20:09pm    
You are trying to mix non-mixable things. PHP is the server-side, JavaScript with Ajax is client side, and the access to the device requires none of them, it should be a local application. It looks like the case where you cannot do in a Web application, need to develop a "real" local application. This way, forget PHP or JavaScript, you need to develop on a native platform, or anything on top of it, like .NET...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900