Developing Desktop slider

I developed desktop slider to practice my C skills. I learned some C in college and I didn't want that knownlodge to go to waste. So I started to study C by myself and developed this application in order to practice.

There were some programs like this at the time, but they were not working the way I wanted. This program proved to be quite useful when I was working on Windows specially when I had a lot opened windows.

The secret is that, instead of listing windows or grouping then like other solutions, I put windows in a place. For some reason is easier to remember in what direction the window is, instead of a position in a list.

I used win32 api to develop this application. This gave me a precious insigth on how programs in Windows work under the hood and allowed me to make the program small and fast. Today people use things like C# to develop windows applications, but you can bet that your library is using win32 to make things work for you.

Developing Exposer

Browsers and operating systems claim that web applications can behave and be used just like native applications. But when you start working with web applications, you realize that they have big limitations compared to regular applications even when they are located in the user machine.

In order to overcome those limitations I developed this program. It is a web server that shares the OS API in the local host. When you run it, it opens the browser poiting to a web application. The application can make requests to the server delegating normal application functionality to the server.

Different from nodejs and electron, there is no additional copy of JavaScript and layout engines attached to the application, the default browser is used to create the GUI and run the JavaScript, while the webserver is responsible for providing regular program functionality. Since the webserver is a program like any other and start the process, your application can behave like any other application.

Source code

Exposer API

Default browser

Exposer has different ways of finding the default browser in different systems.

Port

It looks for an available port starting at 1024.

Quiting

The server stops when all connections are closed and the message quit was received.

WEB application

The file named index.html and placed in the same folder as exposer is opened by the browser when the program starts.

API

To use an API send a request with the specific path. Each argument should be sent with the HTTP headers named arg0, arg1, and so on.

Paths in the API are relative to the working directory, paths outside the API, like paths to images in the HTML are relative to the folder where the server executable is. The word root can be used in the beginning of the path to refer to "/". Paths of folders end with a "/" on GNU/Linux or OSX and "\" on Windows.

A RESTful API was not used because it does not map well for things that goes beyond CRUD.

extern

This function is special, the argument is the portion of the URL path that follows extern.

This is meant to defeat the same origin policy. The part of the path after extern should specify an address in the Internet with the host. The server makes an HTTP request to that address and returns what it gets from the Internet. If a page was requested, then all the relatives URLs in it are going to be relative to extern, so they are all going to be valid API calls to extern also.

folder/get (path)

Retrieves a list of the files of the folder separated by new lines.

folder/set (path)

Creates a new folder.

folder/remove (path)

Removes a folder.

folder/rename (old, new)

Renames or moves a folder.

file/get (path)

Retrieves the content of a file.

file/set (path, data)

Sets the content of a file.

If used with POST, the body is used for data.

file/add (path, data)

Append content to a file.

If used with POST, the body is used for data.

file/remove (path)

Removes a file.

file/rename (old, new)

Renames or moves a file.

file/open (path)

Opens a file using the command start on Windows, xdg-open on GNU/Linux, and open on OSX.

shell (command)

Runs a command in the shell.

quit

Asks the server to quit after all connections have been closed.

argv

Retrieves the command line arguments separated by new lines.