|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbServers module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #include "hbdevicedialogserver_p.h" |
|
27 |
|
28 #include "hbdevicedialogtrace_p.h" |
|
29 #include <hbapplication.h> |
|
30 #include <hbmainwindow.h> |
|
31 #include <hbview.h> |
|
32 #include <hbtransparentwindow.h> |
|
33 #include <hbstackedlayout.h> |
|
34 #include <QTranslator> |
|
35 #if defined (Q_OS_SYMBIAN) |
|
36 #include <aknappui.h> |
|
37 #include <eikenv.h> |
|
38 #include <apgwgnam.h> |
|
39 #endif // Q_OS_SYMBIAN |
|
40 |
|
41 // QApplication calls RProcess::Rendezvous() before server has been created. |
|
42 // Semaphores are signaled when server initialization is done. |
|
43 #if defined (Q_OS_SYMBIAN) |
|
44 static void SignalClientSemaphores() |
|
45 { |
|
46 // Initialisation complete, now signal client(s) |
|
47 _LIT(KFindPattern, "hbdevdlgcli_?*"); |
|
48 TFindSemaphore find(KFindPattern); |
|
49 RSemaphore sema; |
|
50 TFullName findResult; |
|
51 while(find.Next(findResult) == KErrNone) { |
|
52 sema.Open(find); |
|
53 sema.Signal(); |
|
54 sema.Close(); |
|
55 } |
|
56 } |
|
57 #endif // Q_OS_SYMBIAN |
|
58 |
|
59 int main(int arg, char *args[]) |
|
60 { |
|
61 INSTALL_MESSAGE_HANDLER |
|
62 |
|
63 #if defined (Q_OS_SYMBIAN) |
|
64 // Guard against starting multiple copies of the server |
|
65 RSemaphore serverExistsSema; |
|
66 _LIT(KSemaName, "hbdevdlgsrv"); |
|
67 TInt error = serverExistsSema.CreateGlobal(KSemaName, 0); |
|
68 if (error != KErrNone) { |
|
69 RProcess::Rendezvous(error); |
|
70 return error; |
|
71 } |
|
72 #endif // Q_OS_SYMBIAN |
|
73 |
|
74 HbApplication app(arg, args, Hb::NoSplash); |
|
75 |
|
76 //QTranslator translator; |
|
77 //QString lang_id = QLocale::system().name(); |
|
78 //translator.load(path_to + "common_" + lang_id); |
|
79 //app.installTranslator(&translator); |
|
80 |
|
81 HbView* view = new HbView; |
|
82 view->hideItems(Hb::AllItems); |
|
83 view->setContentFullScreen(); |
|
84 |
|
85 // Workaround to get device dialogs visible until transparency works |
|
86 HbMainWindow mainWindow(0); //, Hb::WindowFlagTransparent); |
|
87 |
|
88 HbTransparentWindow *transparentWindow = new HbTransparentWindow; |
|
89 HbStackedLayout *stackedLayout = new HbStackedLayout; |
|
90 stackedLayout->addItem(transparentWindow); |
|
91 view->setLayout(stackedLayout); |
|
92 |
|
93 mainWindow.addView(view); |
|
94 |
|
95 HbDeviceDialogServer server; |
|
96 server.setMainWindow(&mainWindow); |
|
97 |
|
98 #if defined (Q_OS_SYMBIAN) |
|
99 CEikonEnv* env = CEikonEnv::Static(); |
|
100 |
|
101 if ( env ) |
|
102 { |
|
103 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
|
104 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
|
105 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
|
106 wgName->SetCaptionL(_L("HbDeviceDialogAppServer")); |
|
107 wgName->SetAppUid(KNullUid); |
|
108 wgName->SetWindowGroupName(env->RootWin()); |
|
109 CleanupStack::PopAndDestroy(); |
|
110 |
|
111 } |
|
112 SignalClientSemaphores(); |
|
113 #endif // Q_OS_SYMBIAN |
|
114 |
|
115 int returnValue = app.exec(); |
|
116 |
|
117 #if defined (Q_OS_SYMBIAN) |
|
118 serverExistsSema.Close(); |
|
119 #endif // Q_OS_SYMBIAN |
|
120 |
|
121 UNINSTALL_MESSAGE_HANDLER |
|
122 |
|
123 return returnValue; |
|
124 } |