src/hbservers/hbdevicedialogappserver/main.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    30 #include <hbmainwindow.h>
    30 #include <hbmainwindow.h>
    31 #include <hbview.h>
    31 #include <hbview.h>
    32 #include <hbtransparentwindow.h>
    32 #include <hbtransparentwindow.h>
    33 #include <hbstackedlayout.h>
    33 #include <hbstackedlayout.h>
    34 #if defined (Q_OS_SYMBIAN)
    34 #if defined (Q_OS_SYMBIAN)
    35 #include <aknappui.h>
    35 #include <w32std.h>
       
    36 #include <coecntrl.h>
    36 #include <eikenv.h>
    37 #include <eikenv.h>
    37 #include <apgwgnam.h>
    38 #include <apgwgnam.h>
    38 #include <hbdevicedialogserverdefs_p.h>
    39 #include <hbdevicedialogserverdefs_p.h>
    39 #include "hbddappfactorysymbian_p.h"
    40 #include "hbddappfactorysymbian_p.h"
    40 #endif // Q_OS_SYMBIAN
    41 #endif // Q_OS_SYMBIAN
    98     TFullName name;
    99     TFullName name;
    99     return findHbServer.Next(name) == KErrNone;
   100     return findHbServer.Next(name) == KErrNone;
   100 }
   101 }
   101 #endif // Q_OS_SYMBIAN
   102 #endif // Q_OS_SYMBIAN
   102 
   103 
   103 #define USE_LOCKER 1
       
   104 int main(int arg, char *args[])
   104 int main(int arg, char *args[])
   105 {
   105 {
   106     INSTALL_MESSAGE_HANDLER
   106     INSTALL_MESSAGE_HANDLER
   107 
   107 
   108 #if defined (Q_OS_SYMBIAN)
   108 #if defined (Q_OS_SYMBIAN)
   141 
   141 
   142     HbView* view = new HbView;
   142     HbView* view = new HbView;
   143     view->hideItems(Hb::AllItems);
   143     view->hideItems(Hb::AllItems);
   144     view->setContentFullScreen();
   144     view->setContentFullScreen();
   145 
   145 
   146     HbMainWindow mainWindow(0, Hb::WindowFlagTransparent);
   146     HbMainWindow mainWindow(0, Hb::WindowFlagTransparent|Hb::WindowFlagNoBackground);
   147         
   147         
   148 #if defined (Q_OS_SYMBIAN)
   148 #if defined (Q_OS_SYMBIAN)
   149     CCoeControl *c = mainWindow.effectiveWinId();
   149     CCoeControl *c = mainWindow.effectiveWinId();
   150     RWindow *rw = static_cast<RWindow*>(c->DrawableWindow());
   150     RWindow *rw = static_cast<RWindow*>(c->DrawableWindow());
   151     rw->SetRequiredDisplayMode( EColor16MA );
   151     rw->SetRequiredDisplayMode( EColor16MA );
   161     view->setLayout(stackedLayout);
   161     view->setLayout(stackedLayout);
   162 
   162 
   163     mainWindow.addView(view);
   163     mainWindow.addView(view);
   164 
   164 
   165 #if defined (Q_OS_SYMBIAN)
   165 #if defined (Q_OS_SYMBIAN)
       
   166     _LIT(KCaption, "HbDeviceDialogAppServer");
   166     CEikonEnv* env = CEikonEnv::Static();
   167     CEikonEnv* env = CEikonEnv::Static();
   167 
   168 
   168     if (env) {
   169     if (env) {
       
   170         env->SetSystem(true);
   169         CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
   171         CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
   170         wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
   172         wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
   171         wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down
   173         wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down
   172         wgName->SetCaptionL(_L("HbDeviceDialogAppServer"));
   174         wgName->SetCaptionL(KCaption);
   173         wgName->SetAppUid(KNullUid);
   175         wgName->SetAppUid(KNullUid);
   174         wgName->SetWindowGroupName(env->RootWin());
   176         wgName->SetWindowGroupName(env->RootWin());
   175         CleanupStack::PopAndDestroy();       
   177         CleanupStack::PopAndDestroy(wgName);
   176     }
   178     }
   177 #endif // Q_OS_SYMBIAN
   179 #endif // Q_OS_SYMBIAN
   178 
   180 
   179     // HbApplication must be created before the server to have environment ready
   181     // HbApplication must be created before the server to have environment ready
   180     HbDeviceDialogServer server;
   182     HbDeviceDialogServer server;
   183 #if defined (Q_OS_SYMBIAN)
   185 #if defined (Q_OS_SYMBIAN)
   184     // Server is created, client may connect
   186     // Server is created, client may connect
   185     RProcess::Rendezvous(KErrNone);
   187     RProcess::Rendezvous(KErrNone);
   186 #endif // Q_OS_SYMBIAN
   188 #endif // Q_OS_SYMBIAN
   187 
   189 
   188     int returnValue = app.exec();
   190     // Unhandled exceptions mostly do not end up here. Instead they
       
   191     // go to Symbian exception handler which crashes the server.
       
   192     int returnValue = 0;
       
   193     bool hadException = true;
       
   194     try {
       
   195         returnValue = app.exec();
       
   196         hadException = false;
       
   197     } catch(...) {
       
   198 #if !defined (Q_OS_SYMBIAN)
       
   199         throw;
       
   200 #endif
       
   201     }
       
   202 
       
   203     TRACE_EXIT_ARGS("excep =" << hadException << "ret =" << returnValue);
       
   204 
       
   205 #if defined (Q_OS_SYMBIAN)
       
   206     // On exception, panic the server
       
   207     if (hadException) {
       
   208         _LIT(KCategory, "hbdevdialogsrv");
       
   209         User::Panic(KCategory, 0x100);
       
   210     }
       
   211 #endif // Q_OS_SYMBIAN
   189 
   212 
   190     UNINSTALL_MESSAGE_HANDLER
   213     UNINSTALL_MESSAGE_HANDLER
   191 
   214 
   192     return returnValue;
   215     return returnValue;
   193 }
   216 }