NeuroKernel Display Manager

Display manager is a vital part of the system because it manages how to start the system. If the system is a multi-user system, then the display manager shows a login screen. Kernel directly initiates the display manager after it is ready. Sole purpose of a display manager could be just load the system information to the kernel from a resource file. In any case, kernel requires a display manager to start operating. Browser window is the display of the system. Server side applications send protocol requests to display server to render their user interface. It is possible to offer a list of servers to connect to or query them in a way so that user can easily change the server connected. The locale used can also be selectable if implemented. Developers can implement their own display managers.

Display manager class has methods to change the server or essentially display, or locale which we do not use on our default display manager. Large organizations may write custom display managers with a drop down option to choose a server or locale.

Default display manager of NeuroKernel /OS
Figure 1: Default display manager of NeuroKernel /OS showing the login options

1. A Simple Display Manager

A writing a display manager is a little bit more tedious job than writing a desktop manager. It is a vital part of the system so extra caution must be taken. Something similar to the default display manager of NeuroKernel would be a little bit too big to put on here so we are going to put a simple one. The display manager code below is the actual manager used by our web site. It actually does nothing but return system registry information from a server side XML file. First thing to do here is to extend the NDisplayManager class. We have to override functions that we do not need. The application will run in plugin mode by the kernel task, and must be named “dspmgrd” in the application registry.

As seen from the code, application wont run as a remote application, and it loads the registry data that lists the applications demos to run from the “dspmgrd” application directory as specified by the NeuroKernel recognized URL. The getURL method actually parses the URL/URI entry automatically, and you do not need to pass application class reference as usually done while creating the URL. Some URLs will be recognized by the rendering engine internally such as cached data URLs. Because our web site demo does not require multi user login, we have overridden the vital methods with empty methods.

import com.neurokernel.client.IObserver;
import com.neurokernel.client.annotation.Configure;
import com.neurokernel.client.annotation.Include;
import com.neurokernel.client.annotation.LoadResources;
import com.neurokernel.client.annotation.Executable;
import com.neurokernel.client.constants.CodeSegment;
import com.neurokernel.client.desktop.NDisplayManager;
import com.neurokernel.client.net.IConnection;
import com.neurokernel.client.system.IDisplay;
import com.neurokernel.client.net.IServiceListener;
 
@LoadResources(
    loadIcon = false
)
@Configure(
    compileIn = {
        @Include(CodeSegment.USER_INTERFACE),
        @Include(CodeSegment.PLUGIN),
        @Include(CodeSegment.SERVICES)
    }
)
@Executable("dspmgrd")
public final class WebSiteManager extends NDisplayManager {
    private static final long serialVersionUID = 1L;
 
    @Override
    public void main(int argc, String[] argv) {
        if(!getSystem().isRemoteTask()) {
            IDisplay display=getDisplay();
            display.setMobileFactor(display.isSmallFactor());
            getMainFrame().setVisible(true);
        } else {
            exit(0);
        }
    }
 
    @Override
    public void onRemoteLogin(String userId, String password, IServiceListener listener) {
    }
 
    @Override
    public void onLogout() {
    }
 
    @Override
    public void onLoadSystemData(final IObserver listener) {
      if(hasDesktopData()) {
            getResource(getURL("n:data/website.xml"),new IServiceListener() {
                  @Override
                  public void onError(IConnection connection) {
                      listener.setValue(null);
                  }
 
                  @Override
                  public void onRead(IConnection connection) {
                      listener.setValue(connection.readString());
                  }
            });
        }
    }
 
    @Override
    public void loginScreen(boolean show) {
    }
 
    @Override
    public void changePassword() {
    }
 
    @Override
    public void onReady() {
    }
}