Permalink
Browse files

Make webappmanager compileable and usable

This is the actual code drop that makes the webappmanager
usable and compileable. There are certain structural
changes that aim for creating a reasonable lsm-common
module based on parts of this codebase. These changes
involve mostly Window, ApplicationDescription and
(Locale)Preferences.

Open-webOS-DCO-1.0-Signed-off-by: Jukka Honkela <jukka.honkela@palm.com>

Change-Id: I9244c14c2cf6889f00a7d53d69bccd1b5f65a3bb
  • Loading branch information...
1 parent caf0dd1 commit df8d33c51fc3a6926c8868da9b6335f20861f330 @jukkahonkela-owo jukkahonkela-owo committed Nov 29, 2012
Showing with 1,772 additions and 4,110 deletions.
  1. +21 −218 Src/Main.cpp
  2. +11 −126 Src/base/BackupManager.cpp
  3. +1 −3 Src/base/BackupManager.h
  4. +2 −2 Src/base/Localization.cpp
  5. +1 −411 Src/base/SystemUiController.h
  6. +0 −45 Src/base/Utils.cpp
  7. +0 −3 Src/base/Utils.h
  8. +35 −231 Src/base/WindowProperties.cpp
  9. +82 −225 Src/base/WindowProperties.h
  10. +23 −235 Src/base/WindowTypes.h
  11. +36 −0 Src/base/application/ApplicationDescription.cpp
  12. +33 −0 Src/base/application/ApplicationDescription.h
  13. +41 −1,164 Src/base/application/ApplicationDescriptionBase.cpp
  14. +29 −266 Src/base/application/ApplicationDescriptionBase.h
  15. +344 −0 Src/base/settings/DeviceInfo.cpp
  16. +104 −0 Src/base/settings/DeviceInfo.h
  17. +314 −870 Src/base/settings/LocalePreferences.cpp
  18. +31 −118 Src/base/settings/LocalePreferences.h
  19. +29 −29 Src/lunaui/WebAppFactoryLuna.cpp
  20. +3 −3 Src/lunaui/WebAppFactoryLuna.h
  21. +24 −26 Src/lunaui/cards/CardWebApp.cpp
  22. +2 −1 Src/lunaui/cards/CardWebApp.h
  23. +4 −3 Src/lunaui/dock/DockWebApp.cpp
  24. +2 −1 Src/lunaui/dock/DockWebApp.h
  25. +2 −1 Src/lunaui/notifications/AlertWebApp.cpp
  26. +1 −1 Src/lunaui/notifications/AlertWebApp.h
  27. +1 −2 Src/lunaui/notifications/DashboardWebApp.cpp
  28. +19 −20 Src/minimalui/WebAppFactoryMinimal.cpp
  29. +3 −3 Src/minimalui/WebAppFactoryMinimal.h
  30. +40 −0 Src/nyx/nyx.pri
  31. +0 −1 Src/sound/SoundPlayer.cpp
  32. +5 −5 Src/webbase/PalmSystem.cpp
  33. +11 −11 Src/webbase/ProcessManager.cpp
  34. +11 −11 Src/webbase/SysMgrWebBridge.cpp
  35. +13 −13 Src/webbase/WebAppFactory.cpp
  36. +6 −5 Src/webbase/WebAppFactory.h
  37. +45 −28 Src/webbase/WebAppManager.cpp
  38. +13 −9 Src/webbase/WebAppManager.h
  39. +13 −16 Src/webbase/WindowedWebApp.cpp
  40. +5 −4 Src/webbase/WindowedWebApp.h
  41. +50 −0 WebAppMgr.upstart
  42. +24 −0 service/com.palm.webappmgr.json.prv
  43. +19 −0 service/com.palm.webappmgr.json.pub
  44. +4 −0 service/com.palm.webappmgr.service.prv
  45. +4 −0 service/com.palm.webappmgr.service.pub
  46. +311 −0 webappmgr.pro
View
239 Src/Main.cpp
@@ -23,24 +23,10 @@
#include "HostBase.h"
#include "ApplicationDescription.h"
-#include "ApplicationManager.h"
-#include "BootupAnimation.h"
-#include "CpuAffinity.h"
//MDK-LAUNCHER #include "DockPositionManager.h"
-#include "HapticsController.h"
-#include "IpcServer.h"
#include "Localization.h"
-#include "WindowServer.h"
#include "WebAppManager.h"
-#include "WebAppMgrProxy.h"
-#include "MemoryMonitor.h"
#include "Settings.h"
-#include "SystemService.h"
-#include "ApplicationInstaller.h"
-#include "Preferences.h"
-#include "DeviceInfo.h"
-#include "Security.h"
-#include "EASPolicyManager.h"
#include "Logging.h"
#include <sys/time.h>
@@ -107,7 +93,7 @@ pid_t sysmgrPid;
pid_t bootAnimPid;
int bootAnimPipeFd=-1, sysmgrPipeFd=-1;
-int WebAppMgrPipeFd=-1, IpcServerPipeFd=-1;
+int WebAppMgrPipeFd=-1;
char msgOkToContinue = 0xAB;
// Safe printf that does not call malloc (to avoid re-entrancy issue when
@@ -495,130 +481,11 @@ static void generateGoodBacktraceTerminateHandler()
exit(-1);
}
-static int RunWebAppManagerTask(void* data)
-{
- // Install the handler for signals that we want to trap:
- // Note: We install the handlers after we initialize the setting because
- // we may do something different depending on the settings values.
- installOuterCrashHandler(SIGILL);
- installOuterCrashHandler(SIGSEGV);
- installOuterCrashHandler(SIGTERM);
-
- ::prctl(PR_SET_NAME, (unsigned long) "WebAppMgr", 0, 0, 0);
- ::prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
-
-
- char msg = 0x00;
- int len = 0;
-
- // block here until the IpcServer in the main process is ready
- while (len != 1 || msg != msgOkToContinue)
- len = ::read(IpcServerPipeFd, &msg, 1);
-
- ::close(IpcServerPipeFd);
- IpcServerPipeFd = -1;
-
- const HostInfo* info = &(HostBase::instance()->getInfo());
- WebAppManager::instance()->setHostInfo(info);
-
- initMallocStatsCb(WebAppManager::instance()->mainLoop(), s_mallocStatsInterval);
-
- logInit();
-
- // Start the Browser App Launcher
-#ifdef NO_WEBKIT_INIT
- WindowServer::instance()->bootupFinished();
-#else
- WebAppManager::instance()->run(); // Sync execution of the task
-#endif
-
- return 0;
-}
int appArgc = 0;
char** appArgv = 0;
-static int RunBootupAnimationTask(void* data)
-{
- ::prctl(PR_SET_NAME, (unsigned long) "BootupAnimation", 0, 0, 0);
- ::prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
-
- // Set "nice" property
- setpriority(PRIO_PROCESS,getpid(),1);
-
- const HostInfo* info = &(HostBase::instance()->getInfo());
- QCoreApplication bootApp(appArgc, appArgv);
-
-// BootupAnimation* bootAnim = new BootupAnimation(sysmgrPipeFd);
- //bootAnim->setFont(QFont("Prelude", 12));
-
- //bootAnim->resize(info->displayWidth,info->displayHeight);
- //bootAnim->show();
- //bootAnim->start();
-
- bootApp.exec();
-
- return 0;
-}
-
-pid_t spawnWebKitProcess()
-{
- int fd[2];
- ::pipe(fd);
-
- pid_t pid = ::fork();
- if (pid < 0)
- return pid;
-
-
- if (pid == 0) {
- // child closed the WRITE end of the pipe
- ::close(fd[1]);
- IpcServerPipeFd = fd[0];
- RunWebAppManagerTask((void*) 0);
- exit(-1);
- } else {
- // parent closes the READ end of the pipe
- ::close(fd[0]);
- WebAppMgrPipeFd = fd[1];
- }
-
- return pid;
-}
-
-pid_t spawnBootupAnimationProcess()
-{
- int fd[2];
- ::pipe(fd);
-
- pid_t pid = ::fork();
- if (pid < 0) {
- return pid;
- }
-
- if (pid == 0) {
- // child closed the WRITE end of the pipe
- ::close(fd[1]);
- sysmgrPipeFd = fd[0];
- RunBootupAnimationTask((void*) 0);
- exit(-1);
- } else {
- bootAnimPid = pid;
- // parent closed the READ end of the pipe
- ::close(fd[0]);
- bootAnimPipeFd = fd[1];
- }
-
- return pid;
-}
-
-gboolean finishBootup(gpointer data)
-{
- WindowServer::instance()->bootupFinished();
- return FALSE;
-}
-
int main( int argc, char** argv)
{
appArgc = argc;
@@ -641,8 +508,6 @@ int main( int argc, char** argv)
renderMode = "Software";
#endif
- WindowServer::markBootStart();
-
g_debug("SysMgr compiled against Qt %s, running on %s, %s render mode requested", QT_VERSION_STR, qVersion(), renderMode);
// Command-Line options
@@ -679,13 +544,6 @@ int main( int argc, char** argv)
// resolution may get picked up from the fb driver on arm
host->init(settings->displayWidth, settings->displayHeight);
-#if defined(TARGET_DEVICE)
- pid_t animPid= spawnBootupAnimationProcess();
- if(animPid < 0) { // failed to start the Animation process
- return -1;
- }
-#endif
-
#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
if (settings->forceSoftwareRendering)
::setenv("QT_QPA_PLATFORM", "palm-soft", 1);
@@ -702,85 +560,30 @@ int main( int argc, char** argv)
::setenv("QWS_DISPLAY", "egl", 1);
#endif
+ // Install the handler for signals that we want to trap:
+ // Note: We install the handlers after we initialize the setting because
+ // we may do something different depending on the settings values.
+ installOuterCrashHandler(SIGILL);
+ installOuterCrashHandler(SIGSEGV);
+ installOuterCrashHandler(SIGTERM);
- pid_t webKitPid= spawnWebKitProcess();
- if(webKitPid < 0) { // failed to start the WebKit process
- return -1;
- }
-
- // Tie LunaSysMgr to Processor 0
- setCpuAffinity(getpid(), 1);
-
- // Tie WebAppMgr to Processor 1
- setCpuAffinity(webKitPid, 0);
-
- // Safe to create logging threads now
- logInit();
-
- // Initialize Ipc Server
- (void) IpcServer::instance();
-
- // Ipc Server is ready, so signal the WebAppMgr process (via pipe) to go ahead and connect
- ::write(WebAppMgrPipeFd, &msgOkToContinue, 1);
- ::close(WebAppMgrPipeFd);
- WebAppMgrPipeFd = -1;
-
-
-#if !defined(TARGET_DESKTOP)
- // Set "nice" property
- setpriority(PRIO_PROCESS,getpid(),-1);
-#endif
-
- qInstallMsgHandler(qtMsgHandler);
- QApplication app(argc, argv);
- QApplication::setStartDragDistance(settings->tapRadius);
- QApplication::setDoubleClickInterval (Settings::LunaSettings()->tapDoubleClickDuration);
- host->show();
-
- initMallocStatsCb(HostBase::instance()->mainLoop(), s_mallocStatsInterval);
-
- // Initialize Preferences handler
- (void) Preferences::instance();
-
- // Initialize Localization handler
- (void) Localization::instance();
-
- //Register vibration/haptics support
- HapticsController::instance()->startService();
-
- (void) DeviceInfo::instance();
-
- // Initialize Security handler
- (void) Security::instance();
-
- // Initialize the System Service
- SystemService::instance()->init();
-
- // Initialize the application mgr
- ApplicationManager::instance()->init();
-
- // Initialize the Application Installer
- ApplicationInstaller::instance();
+ // Not needed anymore?
+ ::prctl(PR_SET_NAME, (unsigned long) "WebAppMgr", 0, 0, 0);
+ ::prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
- // Start the window manager
- WindowServer *windowServer = WindowServer::instance();
- windowServer->installEventFilter(windowServer);
+ const HostInfo* info = &(HostBase::instance()->getInfo());
+ WebAppManager::instance()->setHostInfo(info);
- // Initialize the SysMgr MemoryMonitor
- MemoryMonitor::instance();
+ initMallocStatsCb(WebAppManager::instance()->mainLoop(), s_mallocStatsInterval);
- // load all set policies
- EASPolicyManager::instance()->load();
+ logInit();
- // Launching of the System UI launcher and headless apps has been moved to WebAppMgrProxy::connectWebAppMgr
+ // Start the Browser App Launcher
+ #ifdef NO_WEBKIT_INIT
+ //WindowServer::instance()->bootupFinished();
+ #else
+ WebAppManager::instance()->run(); // Sync execution of the task
+ #endif
- // Did user specify an app to launch
- if (s_appToLaunchStr) {
- WebAppMgrProxy::setAppToLaunchUponConnection(s_appToLaunchStr);
- }
- else
- g_timeout_add(0, finishBootup, 0);
-
- app.exec();
- return 0;
+ return 0;
}
View
137 Src/base/BackupManager.cpp
@@ -29,9 +29,6 @@
#include "Logging.h"
#include <cjson/json.h>
-//for launcher3 saving
-#include "pagesaver.h"
-
/* BackupManager implementation is based on the API documented at https://wiki.palm.com/display/ServicesEngineering/Backup+and+Restore+2.0+API
* On the LunaSysMgr side, this backs up launcher, quick launch and dock mode settings
* On the WebAppMgr side, this backs up the sysmgr cookies
@@ -45,12 +42,6 @@ BackupManager* BackupManager::s_instance = NULL;
static const char * strCookieAppId = "com.palm.luna-sysmgr.cookies";
static const char * strCookieTempFile = "/tmp/com.palm.luna-sysmgr.cookies-html5-backup.sql";
-
-/* this is the browser db file that was previously backed up by sysmgr, but will now move to mojodb.
- * this is needed only for the first restore after the ota for blowfish
- */
-static const char * strBrowserDbFile = "/tmp/com.palm.app.browser-html5-backup.sql";
-static const char * strBrowserDbUrl = "file:///usr/palm/applications/com.palm.app.browser/index.html:0";
/*! \page com_palm_app_data_backup Service API com.palm.appDataBackup/
* Public methods:
* - \ref com_palm_app_data_backup_post_restore
@@ -125,55 +116,14 @@ bool BackupManager::init(GMainLoop* mainLoop)
BackupManager::~BackupManager()
{
if (m_serverService) {
- LSError error;
- LSErrorInit(&error);
-
- bool succeeded = LSUnregisterPalmService(m_serverService, &error);
- if (!succeeded) {
- g_warning("Failed unregistering backup service: %s", error.message);
- LSErrorFree(&error);
- }
- }
-}
-
-
-void BackupManager::initFilesForBackup()
-{
-// if (!m_backupFiles.empty())
-// return;
-
- g_message("%s: entry",__FUNCTION__);
- m_backupFiles.clear();
-
- if (m_doBackupFiles) {
- g_message("%s: adding files to backup list",__FUNCTION__);
- m_backupFiles.push_back ("/var/luna/preferences/launcher-cards.json");
- if (g_file_test(Settings::LunaSettings()->firstCardLaunch.c_str(), G_FILE_TEST_EXISTS))
- m_backupFiles.push_back (Settings::LunaSettings()->firstCardLaunch.c_str());
- if (g_file_test(Settings::LunaSettings()->quicklaunchUserPositions.c_str(), G_FILE_TEST_EXISTS))
- m_backupFiles.push_back (Settings::LunaSettings()->quicklaunchUserPositions.c_str());
- if (g_file_test(Settings::LunaSettings()->dockModeUserPositions.c_str(), G_FILE_TEST_EXISTS))
- m_backupFiles.push_back (Settings::LunaSettings()->dockModeUserPositions.c_str());
-
- QList<QString> fileList;
-
- DimensionsSystemInterface::PageSaver::filesForBackup(&fileList);
- for (QList<QString>::const_iterator file_it = fileList.constBegin();
- file_it != fileList.constEnd();file_it++)
- {
- if (!(file_it->isEmpty()))
- {
- if (g_file_test(file_it->toUtf8().constData(), G_FILE_TEST_EXISTS))
- {
- m_backupFiles.push_back(file_it->toUtf8().constData());
- g_message("%s: backing up signalled file: %s",__FUNCTION__,file_it->toUtf8().constData());
- }
- }
- }
- }
- else
- {
- g_message("%s: DID NOT add files to backup list (backup files? flag was false)",__FUNCTION__);
+ LSError error;
+ LSErrorInit(&error);
+
+ bool succeeded = LSUnregisterPalmService(m_serverService, &error);
+ if (!succeeded) {
+ g_warning("Failed unregistering backup service: %s", error.message);
+ LSErrorFree(&error);
+ }
}
}
@@ -267,23 +217,9 @@ bool BackupManager::preBackupCallback( LSHandle* lshandle, LSMessage *message, v
json_object_object_add (response, "description", json_object_new_string ("Backup of LunaSysMgr files for launcher, quicklaunch, dockmode and sysmgr cookies"));
json_object_object_add (response, "version", json_object_new_string ("1.0"));
- // adding the files for backup at the time of request.
- // if the user has created custom quicklaunch or dockmode settings, those files should be available now.
- pThis->initFilesForBackup();
-
struct json_object* files = json_object_new_array();
GFileTest fileTest = static_cast<GFileTest>(G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR);
- if (pThis->m_doBackupFiles) {
- std::list<std::string>::const_iterator i;
- for (i = pThis->m_backupFiles.begin(); i != pThis->m_backupFiles.end(); ++i) {
- if (g_file_test(i->c_str(), fileTest)) {
- json_object_array_add (files, json_object_new_string(i->c_str()));
- g_debug ("added file %s to the backup list", i->c_str());
- }
- }
- }
-
if (pThis->m_doBackupCookies) {
//FIXME-qtwebkit: bool succeeded = Palm::WebGlobal::startDatabaseDump (Palm::k_PhonyCookieUrl, "cookies", strCookieTempFile, NULL);
if (g_file_test(strCookieTempFile, fileTest)) {
@@ -372,58 +308,9 @@ bool BackupManager::postRestoreCallback( LSHandle* lshandle, LSMessage *message,
const char* str = LSMessageGetPayload(message);
if (!str)
- return true;
+ return true;
g_warning ("[BACKUPTRACE] %s: received %s", __func__, str);
- json_object* root = json_tokener_parse(str);
- if (!root || is_error(root))
- return true;
-
- json_object* files = json_object_object_get (root, "files");
- if (!files) {
- g_warning ("No files specified in postRestore message");
- return true;
- }
-
- array_list* fileArray = json_object_get_array (files);
- if (!fileArray) {
- g_warning ("files is not an array");
- return true;
- }
-
- int fileArrayLength = array_list_length (fileArray);
- int index = 0;
-
- g_debug ("%s: fileArrayLength = %d", __func__, fileArrayLength);
-
- if (pThis->m_doBackupCookies) {
- for (index = 0; index < fileArrayLength; ++index) {
- json_object* obj = (json_object*) array_list_get_idx (fileArray, index);
- if (!obj)
- continue;
-
- std::string path = json_object_get_string (obj);
- if (path == strCookieTempFile) {
- /*FIXME-qtwebkit: bool succeeded = Palm::WebGlobal::startDatabaseRestore(Palm::k_PhonyCookieUrl, "cookies", path, NULL);
- // this call is synchronous for cookies
- if (!succeeded) {
- g_warning ("Unable to restore the cookies");
- }
- else {
- g_debug ("cookies restored from %s to %s", path.c_str(), Palm::k_PhonyCookieUrl);
- }*/
- }
- if (path == strBrowserDbFile) {
- /*FIXME-qtwebkit: bool succeeded = Palm::WebGlobal::startDatabaseRestore(strBrowserDbUrl, "browser_data", path, NULL);
- if (!succeeded) {
- g_warning ("Unable to restore the browser_data database");
- }
- else {
- g_debug ("browser_data database restored");
- }*/
- }
- }
- }
// no work needed for regular files
LSError lserror;
@@ -434,13 +321,11 @@ bool BackupManager::postRestoreCallback( LSHandle* lshandle, LSMessage *message,
g_message ("Sending response to postRestoreCallback: %s", json_object_to_json_string (response));
if (!LSMessageReply (lshandle, message, json_object_to_json_string(response), &lserror )) {
- g_warning("Can't send reply to postRestoreCallback error: %s", lserror.message);
- LSErrorFree (&lserror);
+ g_warning("Can't send reply to postRestoreCallback error: %s", lserror.message);
+ LSErrorFree (&lserror);
}
-
json_object_put (response);
return true;
-
}
View
4 Src/base/BackupManager.h
@@ -77,10 +77,8 @@ class BackupManager
bool m_doBackupCookies;
std::list<std::string> m_backupFiles; ///< List of items I'm managing the backup/restore of.
- void initFilesForBackup();
-
static bool preBackupCallback( LSHandle* lshandle, LSMessage *message, void *user_data);
- static bool postRestoreCallback( LSHandle* lshandle, LSMessage *message, void *user_data);
+ static bool postRestoreCallback( LSHandle* lshandle, LSMessage *message, void *user_data);
};
View
4 Src/base/Localization.cpp
@@ -25,7 +25,7 @@
#include "Localization.h"
-#include "Preferences.h"
+#include "LocalePreferences.h"
#include "Settings.h"
#include <QVector>
@@ -60,7 +60,7 @@ void Localization::loadLocalizedStrings()
QVector<std::string> translations;
- std::string locale = Preferences::instance()->locale();
+ std::string locale = LocalePreferences::instance()->locale();
translations << Settings::LunaSettings()->lunaCustomizationLocalePath + "/" + locale + s_localeFile;
translations << Settings::LunaSettings()->lunaSystemLocalePath + "/" + locale + s_localeFile;
View
412 Src/base/SystemUiController.h
@@ -22,95 +22,9 @@
#ifndef SYSTEMUICONTROLLER_H
#define SYSTEMUICONTROLLER_H
-#include "Common.h"
-
-#include <string>
-#include <QEvent>
-#include <QKeyEvent>
-#include <QMouseEvent>
-#include <QObject>
-#include <QRect>
-#include <QSharedPointer>
-#include <QWeakPointer>
-
-#include "ApplicationDescription.h"
-#include "Event.h"
-#include "SuspendBlocker.h"
-#include "VariantAnimation.h"
-#include "Window.h"
-#include "CustomEvents.h"
-#include "StatusBar.h"
-
-class CardWindow;
-class SysMgrKeyEvent;
-
-QT_BEGIN_NAMESPACE
-class QPixmap;
-QT_END_NAMESPACE
-
-class QGesture;
-
-class SystemUiController : public QObject
+class SystemUiController
{
- Q_OBJECT
-
public:
-
- static SystemUiController* instance();
- ~SystemUiController();
-
- void init();
-
- bool handleEvent(QEvent *event);
- bool handleKeyEvent(QKeyEvent *event);
- bool handleMouseEvent(QMouseEvent *event);
- bool handleGestureEvent(QGestureEvent *event);
- bool handleCustomEvent(QEvent *event);
-
- void setCardWindowAboutToMaximize();
-
- void setCardWindowMaximized(bool val);
-
- void updateStatusBarTitle();
-
- void setLauncherShown(bool val);
-
- void setUniversalSearchShown(bool val);
-
- void setDockShown(bool val);
-
- void showOrHideUniversalSearch(bool show, bool showLauncher, bool speedDial);
-
- void showOrHideLauncher(bool show);
-
- void showOrHideDock(bool show);
-
- void setDashboardOpened(bool val, bool isSoftDismissable);
-
- void setDashboardHasContent(bool val);
-
- void setAlertVisible(bool val);
-
- void setEmergencyMode(bool enable);
-
- void setActiveCardWindow(Window* window);
-
- void setMaximizedCardWindow(Window* window);
-
- void setRequestedSystemOrientation(Event::Orientation orient, bool reasonCardMaximizing = false, bool skipAnimation = false);
-
- void setLauncherWindow(Window* window) { m_launcherWindow = window; }
-
- void setUniversalSearchWindow(Window* window) { m_universalSearchWindow = window; }
-
- void focusMaximizedCardWindow(bool enable);
-
- void enterOrExitCardReorder(bool entered);
-
- bool doesDashboardHaveContent() const {return m_dashboardHasContent;}
-
- void enterOrExitDockModeUi(bool enter);
-
// The order of the layers below defines their priorities in terms of direct rendering
enum DirectRenderingEnabledLayers
{
@@ -123,105 +37,6 @@ class SystemUiController : public QObject
NUMBER_OF_LAYERS
};
- void setDirectRenderingForWindow(DirectRenderingEnabledLayers layer, CardWindow* win, bool enable, bool force=false);
- void enableDirectRendering(bool enable);
-
- void setLauncherVisible(bool visible, bool fullyVisible);
- void setDockVisible(bool val);
- void setMenuVisible(bool val);
- void setDeviceLocked(bool val);
- void setDockMode(bool inDockMode);
- void setInLauncherReorder(bool reorder);
-
- void toggleCurrentAppMenu();
-
- void openDashboard();
- void closeDashboard(bool force);
-
- bool isCardWindowMaximized( ) const { return m_cardWindowMaximized; }
- bool isLauncherShown( ) const;
- bool isUniversalSearchShown() { return m_universalSearchShown; }
- bool isDockShown( ) const;
- bool isDashboardOpened( ) const { return m_dashboardOpened; }
- bool isInDockMode( ) const { return m_inDockMode; }
- bool isScreenLocked() const { return (m_deviceLocked); }
- bool isInEmergencyMode() const {return m_emergencyMode; }
- bool isInFullScreenMode();
- bool isModalWindowActive() {return m_modalCardWindowActive;}
-
- const Window* launcherWindow() const { return m_launcherWindow; }
- const Window* universalSearchWindow() const { return m_universalSearchWindow; }
-
- Window* activeCardWindow() const { return m_activeCardWindow; }
-
- Window* activeWindow() const;
-
- std::string activeApplicationName();
-
- Window* maximizedCardWindow() const { return m_maximizedCardWindow; }
-
- std::string maximizedApplicationName() const;
- std::string maximizedApplicationMenuName() const;
- std::string maximizedApplicationId() const;
-
- // this call lays out the positive and negative spaces
- void layout();
-
- bool okToResizeUi();
- void resizeAndRotateUi(int width, int height, int rotationAngle);
- void rotationStarting();
- void rotationComplete();
- bool isUiRotating() { return m_uiRotating; }
- int getRotationAngle() { return m_uiRotating ? m_rotationAngle : 0; }
-
- bool dashboardOwnsNegativeSpace() const { return m_dashboardOwnsNegativeSpace; }
-
- void setUiRootItemPtr(QGraphicsItem* ptr) { m_uiRootItemPtr = ptr; }
-
- int currentUiWidth() { return m_uiWidth; }
- int currentUiHeight() { return m_uiHeight; }
- bool isUiInPortraitMode() { return (m_uiWidth < m_uiHeight); }
-
- void setMinimumPositiveSpaceHeight(int val);
- void setMaximumPositiveSpaceHeight(int val);
- int minimumPositiveSpaceHeight() const;
- int maximumPositiveSpaceHeight() const;
- int minimumPositiveSpaceBottom() const;
- int maximumPositiveSpaceBottom() const;
- bool changeNegativeSpace(int newTop, bool openingDashboard, bool immediate=false);
-
- const QRect& positiveSpaceBounds() { return m_positiveSpace; }
- const QRect& negativeSpaceBounds() { return m_negativeSpace; }
-
- void hideStatusBarAndNotificationArea();
- void showStatusBarAndNotificationArea();
- bool statusBarAndNotificationAreaShown() const { return m_statusBarAndNotificationShown; }
-
- void setBootFinished();
- bool bootFinished() const;
-
- void updateProperties (Window* win, const WindowProperties& props);
-
- void notifyAlertActivated() { Q_EMIT signalAlertActivated(); }
- void notifyAlertDeactivated() { Q_EMIT signalAlertDeactivated(); }
- void notifyTransientAlertActivated() { Q_EMIT signalTransientAlertActivated(); }
- void notifyTransientAlertDeactivated() { Q_EMIT signalTransientAlertDeactivated(); }
- void notifyBannerActivated() { Q_EMIT signalBannerActivated(); }
- void notifyBannerDeactivated() { Q_EMIT signalBannerDeactivated(); }
- void notifyBannerAboutToUpdate(QRect& scrBounds) { Q_EMIT signalBannerAboutToUpdate(scrBounds); }
- void notifyModalWindowActivated(Window* modalParent);
- void notifyModalWindowDeactivated();
- Window* getModalParent() const {return m_parentOfModalWindow; }
- void notifyEditorFocusChanged(bool focus) { Q_EMIT signalEditorFocusChanged(focus); }
-
- QSharedPointer<QPixmap> loadingStrip();
- QSharedPointer<QPixmap> warningIcon();
-
- void aboutToSendSyncMessage();
-
- void setStatusBar(StatusBar* statusBar) { m_statusBarPtr = statusBar; }
- const StatusBar* statusBar() const { return m_statusBarPtr; }
-
enum ModalWinLaunchErrorReason {
LaunchUnknown = -1,
NoErr = 0,
@@ -247,23 +62,6 @@ class SystemUiController : public QObject
ActiveCardsSwitched,
UiMinimized,
};
-
- void setModalWindowDismissErrReason(ModalWinDismissErrorReason reason) { if(m_modalWindowDismissErr != reason) m_modalWindowDismissErr = reason; }
- void setModalWindowLaunchErrReason(ModalWinLaunchErrorReason reason) { if(m_modalWindowLaunchErr != reason) m_modalWindowLaunchErr = reason; }
-
- bool wasModalAddedSuccessfully() { return(m_modalWindowLaunchErr == NoErr)? true : false; }
-
- std::string getModalWindowLaunchErrReason();
- std::string getModalWindowDismissErrReason();
- int getModalWindowLaunchErrReasonCode() {return m_modalWindowLaunchErr; }
- int getModalWindowDismissErrReasonCode() {return m_modalWindowDismissErr; }
-
-public:
- void cardWindowAdded();
- void cardWindowTimeout();
-
-public:
-
enum LauncherOperations
{
LAUNCHEROP_ADDCARD,
@@ -281,214 +79,6 @@ class SystemUiController : public QObject
LAUNCHERACT_DBG_ACTIVATE_SCREEN_GRID,
LAUNCHERACT_DBG_DEACTIVATE_SCREEN_GRID,
};
-
- void launcherAction(LauncherActions act);
- void launcherMenuOp(LauncherOperations op);
- void launcherChangeCardTitle(int launcherCardId,const std::string& launcherCardLabel);
-
- void launcherDbgActionScreenGrid(LauncherActions act,int xspan=0,int yspan=0);
-
- uint32_t getOverlayNotificationPosition() { return m_overlayNotificationPosition; }
-
- // Signals
-
-Q_SIGNALS:
- void signalCardWindowAdded();
- void signalCardWindowTimeout();
-
- void signalPositiveSpaceChanged(const QRect& r);
- void signalPositiveSpaceAboutToChange(const QRect& r, bool fullScreen, bool screenResizing);
- void signalPositiveSpaceChangeFinished(const QRect& r);
- void signalNegativeSpaceChanged(const QRect& r);
- void signalNegativeSpaceAboutToChange(const QRect& r, bool fullScreen, bool screenResizing);
- void signalNegativeSpaceChangeFinished(const QRect& r);
- void signalEmergencyMode(bool enable);
- void signalEmergencyModeHomeButtonPressed();
-
- void signalFocusMaximizedCardWindow(bool enable);
- void signalMaximizedCardWindowChanged(Window* win);
- void signalMaximizeActiveCardWindow();
- void signalMinimizeActiveCardWindow();
- void signalCardWindowMaximized();
- void signalCardWindowMinimized();
- void signalChangeCardWindow(bool next);
-
- void signalHideMenu();
-
- void signalLauncherVisible(bool visible, bool fullyVisible);
- void signalLauncherShown(bool shown);
- void signalShowUniversalSearch();
- void signalHideUniversalSearch(bool showLauncher, bool speedDial);
- void signalUniversalSearchFocusChange(bool enabled);
-
- void signalShowLauncher();
- void signalHideLauncher();
- void signalToggleLauncher();
- void signalLauncherAddCard();
- void signalLauncherEnterReorderCardMode();
- void signalLauncherRenameCard(int,QString);
- void signalLauncherDeleteCard();
- void signalLauncherInvokeRenameCard();
-
- void signalLauncherActionEditingCardTitle();
- void signalLauncherActionAppInfoWindowActive();
- void signalLauncherActionMenuActive();
- void signalLauncherActionDbgScreenGrid(bool on,int xspan,int yspan);
-
- void signalLauncherMenuOpEnd();
- void signalLauncherActionEnd();
-
- void signalShowDock();
- void signalHideDock();
- void signalFadeDock(bool fadeOut);
-
- void signalOpenDashboard();
- void signalCloseDashboard(bool forceClose);
- void signalCloseAlert();
-
- void signalDockModeEnable(bool enabled);
- void signalChangeDockModeApp(bool next);
- void signalBackGestureRejectedDockMode();
-
- void signalBootFinished();
-
- void signalStatusBarAndNotificationShown(bool shown);
-
- void signalOverlayNotificationPositionChanged(uint32_t newPosition);
- void signalOverlayNotificationSuppressBannerMessages(bool suppress);
-
- void signalAlertActivated();
- void signalAlertDeactivated();
- void signalTransientAlertActivated();
- void signalTransientAlertDeactivated();
- void signalBannerActivated();
- void signalBannerDeactivated();
- void signalBannerAboutToUpdate(QRect& scrBounds);
-
- void signalEditorFocusChanged(bool focus);
-
- void signalAboutToSendSyncMessage();
-
- void signalDockModeStatusBarToggle();
-
- void signalModalWindowAdded();
-
- void signalModalWindowRemoved();
-
- void signalUiRotationAboutToStart();
- void signalUiRotationCompleted();
-
- void signalEmergencyModeWindowFocusChange(bool focus);
-
-private Q_SLOTS:
-
- void slotEnterBrickMode(bool val);
- void slotExitBrickMode();
-
- void slotCopy();
- void slotCut();
- void slotPaste();
- void slotSelectAll();
-
- void slotAnimFinished();
-
- void slotKeyEventRejected(const SysMgrKeyEvent& event);
-private:
-
- SystemUiController();
- void startPositiveSpaceAnimation(const QRect& start, const QRect& end);
- void stopPositiveSpaceAnimation();
- void animValueChanged(const QVariant& value);
- bool allowSuspend();
- void setSuspended(bool);
- void handleScreenEdgeFlickGesture(QGesture* gesture);
-
- Window* m_parentOfModalWindow;
- Window* m_activeCardWindow;
- Window* m_maximizedCardWindow;
- Window* m_launcherWindow;
- Window* m_universalSearchWindow;
-
- bool m_cardWindowAboutToMaximize;
- bool m_cardWindowMaximized;
- bool m_dashboardOpened;
- bool m_dashboardSoftDismissable;
- bool m_dashboardHasContent;
- bool m_alertVisible;
- const bool m_dashboardOwnsNegativeSpace;
- bool m_launcherShown;
- bool m_dockShown;
- bool m_inDockMode;
- bool m_universalSearchShown;
-
- bool m_emergencyMode;
-
- QGraphicsItem* m_uiRootItemPtr;
-
- QRect m_positiveSpace;
- QRect m_negativeSpace;
- int m_minimumPositiveSpaceHeight;
- int m_maximumPositiveSpaceHeight;
-
- bool m_launcherVisible;
- bool m_dockVisible;
- bool m_menuVisible;
- bool m_deviceLocked;
-
- bool m_started;
- int m_startCount;
-
- int m_dockBrightness;
- bool m_statusBarAndNotificationShown;
-
- int m_requestedNegativeSpaceTop;
-
- int m_uiWidth, m_uiHeight;
-
- VariantAnimation<SystemUiController>* m_anim;
-
- bool m_bootFinished;
-
- bool m_uiRotating;
- int m_rotationAngle;
-
- SuspendBlocker<SystemUiController> m_suspendBlocker;
-
- void applyWindowProperties (Window* win);
- void removeWindowProperties ();
- bool m_isBlockScreenTimeout;
- bool m_isSubtleLightbar;
- bool m_activeTouchpanel;
- bool m_alsDisabled;
- uint32_t m_overlayNotificationPosition;
- bool m_suppressBannerMessages;
- bool m_suppressGestures;
- bool m_modalCardWindowActive;
-
- // members used for Focus/DirectRendering control
- struct DirectRenderLayer {
- bool requestedDirectRendring;
- CardWindow* activeWindow;
- };
-
- DirectRenderLayer m_directRenderLayers[NUMBER_OF_LAYERS];
- int m_currentlyDirectRenderingLayer;
- CardWindow* m_currentlyDirectRenderingWindow;
-
- ModalWinLaunchErrorReason m_modalWindowLaunchErr;
- ModalWinDismissErrorReason m_modalWindowDismissErr;
-
-private:
-
- SystemUiController(const SystemUiController&);
- SystemUiController& operator=(const SystemUiController&);
-
- std::string getMenuTitleForMaximizedWindow(Window* win);
-
- QWeakPointer<QPixmap> m_iconProgressSurf;
- QWeakPointer<QPixmap> m_iconWarningSurf;
-
- StatusBar* m_statusBarPtr;
};
View
45 Src/base/Utils.cpp
@@ -40,9 +40,6 @@
#include <QByteArray>
#include <QtDebug>
-#include "ApplicationManager.h"
-#include "ApplicationDescription.h"
-#include "Preferences.h"
#include "Utils.h"
void setPosTopLeft(QGraphicsItem* item, int x, int y)
@@ -430,48 +427,6 @@ bool splitWindowIdentifierToAppAndProcessId(const std::string& id, std::string&
return true;
}
-std::string getResourcePathFromString(const std::string& entry, const std::string& appId,
- const std::string& systemResourceFolder)
-{
- if (entry.empty())
- return std::string();
-
- struct stat stBuf;
-
- // Absolute path?
- if (entry[0] == '/') {
-
- // check if it exists and is a regular file
- if (::stat(entry.c_str(), &stBuf) != 0 || !S_ISREG(stBuf.st_mode))
- return std::string();
-
- return entry;
- }
-
- // relative path. first check in the app folder
- ApplicationDescription* appDesc = ApplicationManager::instance()->getAppById(appId);
- if (appDesc) {
-
- // First check in the locale specific folder
- std::string filePath = appDesc->folderPath() + "/resources/" + Preferences::instance()->locale() + "/" + entry;
- if (::stat(filePath.c_str(), &stBuf) == 0 && (S_ISREG(stBuf.st_mode) || S_ISLNK(stBuf.st_mode)))
- return filePath;
-
- // Try in the standard app folder path
- filePath = appDesc->folderPath() + "/" + entry;
- if (::stat(filePath.c_str(), &stBuf) == 0 && (S_ISREG(stBuf.st_mode) || S_ISLNK(stBuf.st_mode)))
- return filePath;
- }
-
- // Look for it in the system folder
- std::string filePath = systemResourceFolder + "/" + entry;
- if (::stat(filePath.c_str(), &stBuf) == 0 && S_ISREG(stBuf.st_mode))
- return filePath;
-
- // ah well... we give up
- return std::string();
-}
-
//Should follow conventions for virtualHost naming in webkit: WebCore/platform/KURL.cpp
//CAUTION: modifying this to return strange paths is potentially dangerous. See ApplicationInstaller.cpp "remove" case where this fn is used
std::string getHtml5DatabaseFolderNameForApp(const std::string& appId,std::string appFolderPath)
View
3 Src/base/Utils.h
@@ -66,9 +66,6 @@ bool isNonErrorProcExit(int ecode,int normalCode=0);
std::string windowIdentifierFromAppAndProcessId(const std::string& appId, const std::string& processId);
bool splitWindowIdentifierToAppAndProcessId(const std::string& id, std::string& appId, std::string& processId);
-std::string getResourcePathFromString(const std::string& entry, const std::string& appId,
- const std::string& systemResourceFolder);
-
std::string getHtml5DatabaseFolderNameForApp(const std::string& appId,std::string appFolderPath);
void threadCleanup();
View
266 Src/base/WindowProperties.cpp
@@ -17,257 +17,61 @@
* LICENSE@@@ */
-
-
-#include "Common.h"
-
-#include <math.h>
-#include <QtDebug>
-
-#include "Window.h"
-
-#include "ApplicationManager.h"
-#include "WindowServer.h"
-
-Window::Window(Type type, const uint32_t bufWidth, const uint32_t bufHeight, bool hasAlpha)
- : m_type(type)
- , m_appDesc(0)
- , m_removed(false)
- , m_disableKeepAlive(false)
- , m_bufWidth(bufWidth)
- , m_bufHeight(bufHeight)
- , m_initialWidth(bufWidth)
- , m_initialHeight(bufHeight)
-{
- setVisibleDimensions(bufWidth, bufHeight);
-
- if (type != Type_QtNativePaintWindow)
- {
- //launcher windows have no backing store. They're purely natively drawn
- m_screenPixmap = QPixmap(m_bufWidth, m_bufHeight);
-
-#if defined(TARGET_DESKTOP) && defined(HAVE_OPENGL)
- hasAlpha = false;
-#endif
-
- QColor fillColor(255, 255, 255, hasAlpha ? 0 : 255);
- m_screenPixmap.fill(fillColor);
- }
- WindowServer::registerWindow(this);
-}
-
-Window::Window(Type type, const QPixmap& pix)
- : m_type(type)
- , m_appDesc(0)
- , m_removed(false)
- , m_disableKeepAlive(false)
- , m_screenPixmap(pix)
- , m_bufWidth(pix.width())
- , m_bufHeight(pix.height())
- , m_initialWidth(pix.width())
- , m_initialHeight(pix.height())
-{
- setVisibleDimensions(m_bufWidth, m_bufHeight);
-
- WindowServer::registerWindow(this);
-}
-
-Window::~Window()
-{
- WindowServer::unregisterWindow(this);
-}
-
-
-void Window::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
-{
- //lock();
-
- if (m_type == Type_QtNativePaintWindow)
- {
- g_critical("%s: window of type QtNativePaintWindow attempting base-class paint()!",__PRETTY_FUNCTION__);
- return;
- }
-
- const QPixmap* pix = acquireScreenPixmap();
- if (!pix) {
- g_critical("Failed to acquire screen pixmap");
- return;
- }
-
- painter->drawPixmap(m_visibleBounds.x(), m_visibleBounds.y(), *pix,
- 0, 0, m_visibleBounds.width(), m_visibleBounds.height());
-
- //unlock();
-}
-
-bool Window::mouseGrabbed() const
-{
- return (scene() != NULL) && (scene()->mouseGrabberItem() == this);
-}
-
-void Window::setMouseGrabbed(bool grabbed)
-{
- if (grabbed) {
- //qDebug() << "sm grabbing mouse";
- grabMouse();
- } else {
- //qDebug() << "sm ungrabbing mouse";
- ungrabMouse();
- }
-}
-
-void Window::setName(const std::string& name)
-{
- m_name = name;
-}
-
-std::string Window::name() const
-{
- return m_name;
-}
-
-
-void Window::setAppId(const std::string& id)
-{
- m_appId = id;
-}
-
-std::string Window::appId() const
-{
- return m_appId;
-}
-
-void Window::setProcessId(const std::string& id)
-{
- m_processId = id;
-}
-
-std::string Window::processId() const
-{
- return m_processId;
-}
-
-void Window::setLaunchingAppId(const std::string& id)
-{
- m_launchingAppId = id;
-}
-
-std::string Window::launchingAppId() const
-{
- return m_launchingAppId;
-}
-
-void Window::setLaunchingProcessId(const std::string& id)
-{
- m_launchingProcId = id;
-}
-
-std::string Window::launchingProcessId() const
-{
- return m_launchingProcId;
-}
-
-ApplicationDescription* Window::appDescription() const
-{
- if (m_appDesc)
- return m_appDesc;
-
- m_appDesc = ApplicationManager::instance()->getAppById(m_appId);
-
- return m_appDesc;
-}
-
-// ------------------------------------------------------------------
+#include "WindowProperties.h"
void WindowProperties::merge(const WindowProperties& props)
{
if (props.flags & isSetBlockScreenTimeout)
- setBlockScreenTimeout(props.isBlockScreenTimeout);
+ setBlockScreenTimeout(props.isBlockScreenTimeout);
- if (props.flags & isSetSubtleLightbar)
- setSubtleLightbar(props.isSubtleLightbar);
+ if (props.flags & isSetSubtleLightbar)
+ setSubtleLightbar(props.isSubtleLightbar);
- if (props.flags & isSetFullScreen)
- setFullScreen(props.fullScreen);
+ if (props.flags & isSetFullScreen)
+ setFullScreen(props.fullScreen);
- if (props.flags & isSetActiveTouchpanel)
- setActiveTouchpanel(props.activeTouchpanel);
+ if (props.flags & isSetActiveTouchpanel)
+ setActiveTouchpanel(props.activeTouchpanel);
- if (props.flags & isSetAlsDisabled)
- setAlsDisabled(props.alsDisabled);
+ if (props.flags & isSetAlsDisabled)
+ setAlsDisabled(props.alsDisabled);
- if (props.flags & isSetOverlayNotifications)
- setOverlayNotificationsPosition(props.overlayNotificationsPosition);
+ if (props.flags & isSetOverlayNotifications)
+ setOverlayNotificationsPosition(props.overlayNotificationsPosition);
- if (props.flags & isSetSuppressBannerMessages)
- setSuppressBannerMessages(props.suppressBannerMessages);
+ if (props.flags & isSetSuppressBannerMessages)
+ setSuppressBannerMessages(props.suppressBannerMessages);
- if (props.flags & isSetHasPauseUi)
- setHasPauseUi(props.hasPauseUi);
+ if (props.flags & isSetHasPauseUi)
+ setHasPauseUi(props.hasPauseUi);
- if (props.flags & isSetSuppressGestures)
- setSuppressGestures(props.suppressGestures);
+ if (props.flags & isSetSuppressGestures)
+ setSuppressGestures(props.suppressGestures);
- if (props.flags & isSetDashboardManualDragMode)
- setDashboardManualDragMode(props.dashboardManualDrag);
+ if (props.flags & isSetDashboardManualDragMode)
+ setDashboardManualDragMode(props.dashboardManualDrag);
- if (props.flags & isSetStatusBarColor)
- setStatusBarColor(props.statusBarColor);
+ if (props.flags & isSetStatusBarColor)
+ setStatusBarColor(props.statusBarColor);
- if (props.flags & isSetRotationLockMaximized)
- setRotationLockMaximized(props.rotationLockMaximized);
+ if (props.flags & isSetRotationLockMaximized)
+ setRotationLockMaximized(props.rotationLockMaximized);
- if (props.flags & isSetAllowResizeOnPositiveSpaceChange)
- setAllowResizeOnPositiveSpaceChange(props.allowResizeOnPositiveSpaceChange);
+ if (props.flags & isSetAllowResizeOnPositiveSpaceChange)
+ setAllowResizeOnPositiveSpaceChange(props.allowResizeOnPositiveSpaceChange);
- if (props.flags & isSetGyro)
- setAllowGyroEvents(props.gyroEnabled);
+ if (props.flags & isSetGyro)
+ setAllowGyroEvents(props.gyroEnabled);
- if (props.flags & isSetEnableCompassEvents)
- setCompassEvents(props.compassEnabled);
+ if (props.flags & isSetEnableCompassEvents)
+ setCompassEvents(props.compassEnabled);
}
void WindowProperties::setOverlayNotificationsPosition(unsigned int position)
{
- flags |= isSetOverlayNotifications;
- if (position > OverlayNotificationsBottom && position < OverlayNotificationsLast)
- overlayNotificationsPosition = position;
- else
- overlayNotificationsPosition = OverlayNotificationsBottom;
-}
-
-void Window::setVisibleDimensions(uint32_t width, uint32_t height)
-{
- if ((m_visibleBounds.width() == width && m_visibleBounds.height() == height) ||
- (height > m_bufHeight || width > m_bufWidth))
- return;
-
- prepareGeometryChange();
- m_visibleBounds.setRect(-(int)width/2, -(int)height/2, width, height);
-}
-
-QSize Window::getVisibleDimensions() const
-{
- return m_visibleBounds.size().toSize();
-}
-
-void Window::resize(int w, int h)
-{
- m_bufWidth = w;
- m_bufHeight = h;
-
- setVisibleDimensions(w, h);
-
- // preserve alpha
- bool hasAlpha = m_screenPixmap.hasAlpha();
- if (m_type != Type_QtNativePaintWindow)
- {
- m_screenPixmap = QPixmap(w, h);
-
- QColor fillColor(255, 255, 255, hasAlpha ? 0 : 255);
- m_screenPixmap.fill(fillColor);
- }
-// g_debug("%s: Window resized to %d x %d", __PRETTY_FUNCTION__,
-// m_bufWidth, m_bufHeight);
+ flags |= isSetOverlayNotifications;
+ if (position > OverlayNotificationsBottom && position < OverlayNotificationsLast)
+ overlayNotificationsPosition = position;
+ else
+ overlayNotificationsPosition = OverlayNotificationsBottom;
}
-
View
307 Src/base/WindowProperties.h
@@ -16,242 +16,99 @@
*
* LICENSE@@@ */
-
-
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include "Common.h"
-
-#include <stdint.h>
-#include <string>
-#include <glib.h>
-
-#include <QGraphicsObject>
-#include <QSize>
-
-
-class ApplicationDescription;
-class WindowManagerBase;
-struct WindowProperties;
-
-/**
- * Mandatory Qt signal/slot connection between another object's signal
- * and this object's slot.
- */
-#define QM_CONNECT(source, sSignal, tSlot) \
- do { \
- if (!connect(source, sSignal, tSlot)) { \
- qFatal("Failed to connect signal %s::%s to this::%s", \
- #source, sSignal, tSlot); \
- } \
- } while (0)
-
-/**
- * Mandatory Qt signal/slot connection between the target slot and the source
- * signal.
- */
-#define QM_CONNECT_EX(target, source, sSignal, tSlot) \
- do { \
- if (target == NULL) qFatal("Cannot connect to NULL object"); \
- if (!(target)->connect(source, sSignal, tSlot)) { \
- qFatal("Failed to connect signal %s::%s to %s::%s", \
- #source, sSignal, #target, tSlot); \
- } \
- } while (0)
-
-class Window : public QGraphicsObject
-{
- Q_OBJECT
- Q_PROPERTY(bool grabMouse READ mouseGrabbed WRITE setMouseGrabbed)
-public:
-
- enum Type {
- Type_Invalid = UserType + 1,
- Type_StatusBar = UserType + 2,
- Type_Card = UserType + 3,
- Type_ChildCard = UserType + 4,
- Type_Overlay = UserType + 5,
- Type_Launcher = UserType + 6,
- Type_Dashboard = UserType + 7,
- Type_PopupAlert = UserType + 8,
- Type_BannerAlert = UserType + 9,
- Type_Menu = UserType + 10,
- Type_PIN = UserType + 11,
- Type_Emergency = UserType + 12,
- Type_QtNativePaintWindow = UserType + 13,
- Type_DockModeWindow = UserType + 14,
- Type_DockModeLoadingWindow = UserType + 15,
- Type_ModalChildWindowCard = UserType + 16,
- Type_None = UserType + 32 // arbitrary, can be as large as 0xFFFEFFFF
- };
-
- Window(Type type, const uint32_t bufWidth, const uint32_t bufHeight, bool hasAlpha=false);
- Window(Type type, const QPixmap& pix);
- virtual ~Window();
-
- // QGraphicsItem::type
- virtual int type() const { return m_type; } // has-base-impl
-
- // QGraphicsItem::boundingRect
- virtual QRectF boundingRect() const { return m_visibleBounds; } // has-base-impl
-
- virtual bool mouseGrabbed() const; // has-base-impl
- virtual void setMouseGrabbed(bool grabbed); // has-base-impl
-
- // QGraphicsItem::paint
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); // has-base-impl
-
- virtual bool isIpcWindow() const { return false; } // has-base-impl
-
- void setName(const std::string& name);
- std::string name() const;
- virtual void setAppId(const std::string& id);
- std::string appId() const;
- void setProcessId(const std::string& id);
- std::string processId() const;
- void setLaunchingAppId(const std::string& id);
- std::string launchingAppId() const;
- void setLaunchingProcessId(const std::string& id);
- std::string launchingProcessId() const;
- ApplicationDescription* appDescription() const;
-
- void setRemoved() { m_removed = true; }
- bool removed() const { return m_removed; }
-
- void setDisableKeepAlive() { m_disableKeepAlive = true; }
- bool disableKeepAlive() const { return m_disableKeepAlive; }
-
- virtual void setWindowProperties (const WindowProperties& attr) { }
-
- virtual void setVisibleDimensions(uint32_t width, uint32_t height); // has-base-impl
- virtual QSize getVisibleDimensions() const; // has-base-impl
-
- virtual void resize(int w, int h); //has-base-impl
-
- virtual const QPixmap* acquireScreenPixmap() { return &m_screenPixmap; }
-
- inline int initialWidth() const { return m_initialWidth; }
- inline int initialHeight() const { return m_initialHeight; }
-
-protected:
-
- virtual void lock() {}
- virtual void unlock() {}
-
- Type m_type;
- std::string m_name;
- std::string m_appId;
- std::string m_processId;
- std::string m_launchingAppId;
- std::string m_launchingProcId;
- mutable ApplicationDescription* m_appDesc;
- bool m_removed;
- bool m_disableKeepAlive;
- uint32_t m_bufWidth;
- uint32_t m_bufHeight;
- int m_initialWidth;
- int m_initialHeight;
- QRectF m_visibleBounds;
- QPixmap m_screenPixmap;
-
- friend class HostWindow;
-
- Window(const Window&);
- Window& operator=(const Window&);
-};
-
-
+#ifndef WINDOWPROPERTIES_H
+#define WINDOWPROPERTIES_H
struct WindowProperties {
enum {
- isSetNothing = 0,
- isSetBlockScreenTimeout = 1 << 0,
- isSetSubtleLightbar = 1 << 1,
- isSetFullScreen = 1 << 2,
- isSetFastAccelerometer = 1 << 3,
- isSetOverlayNotifications = 1 << 4,
- isSetSuppressBannerMessages = 1 << 5,
- isSetHasPauseUi = 1 << 6,
- isSetSuppressGestures = 1 << 7,
- isSetDashboardManualDragMode = 1 << 9,
- isSetStatusBarColor = 1 << 10,
- isSetRotationLockMaximized = 1 << 11,
- isSetAllowResizeOnPositiveSpaceChange = 1 << 12,
- isSetEnableCompassEvents = 1 << 13,
- isSetGyro = 1 << 14,
- isSetActiveTouchpanel = 1 << 15,
- isSetAlsDisabled = 1 << 16,
- isSetLast
+ isSetNothing = 0,
+ isSetBlockScreenTimeout = 1 << 0,
+ isSetSubtleLightbar = 1 << 1,
+ isSetFullScreen = 1 << 2,
+ isSetFastAccelerometer = 1 << 3,
+ isSetOverlayNotifications = 1 << 4,
+ isSetSuppressBannerMessages = 1 << 5,
+ isSetHasPauseUi = 1 << 6,
+ isSetSuppressGestures = 1 << 7,
+ isSetDashboardManualDragMode = 1 << 9,
+ isSetStatusBarColor = 1 << 10,
+ isSetRotationLockMaximized = 1 << 11,
+ isSetAllowResizeOnPositiveSpaceChange = 1 << 12,
+ isSetEnableCompassEvents = 1 << 13,
+ isSetGyro = 1 << 14,
+ isSetActiveTouchpanel = 1 << 15,
+ isSetAlsDisabled = 1 << 16,
+ isSetLast
};
- enum {
- OverlayNotificationsBottom = 0,
- OverlayNotificationsLeft,
- OverlayNotificationsRight,
- OverlayNotificationsTop,
- OverlayNotificationsLast
- };
+ enum {
+ OverlayNotificationsBottom = 0,
+ OverlayNotificationsLeft,
+ OverlayNotificationsRight,
+ OverlayNotificationsTop,
+ OverlayNotificationsLast
+ };
unsigned int flags;
- bool isBlockScreenTimeout;
- bool isSubtleLightbar;
- bool fullScreen;
- bool activeTouchpanel;
- bool alsDisabled;
- unsigned int overlayNotificationsPosition;
- bool suppressBannerMessages;
- bool hasPauseUi;
- bool suppressGestures;
- bool dashboardManualDrag;
- unsigned int dockBrightness;
- unsigned int statusBarColor;
- bool rotationLockMaximized;
- bool allowResizeOnPositiveSpaceChange;
- bool gyroEnabled;
- bool compassEnabled;
+ bool isBlockScreenTimeout;
+ bool isSubtleLightbar;
+ bool fullScreen;
+ bool activeTouchpanel;
+ bool alsDisabled;
+ unsigned int overlayNotificationsPosition;
+ bool suppressBannerMessages;
+ bool hasPauseUi;
+ bool suppressGestures;
+ bool dashboardManualDrag;
+ unsigned int dockBrightness;
+ unsigned int statusBarColor;
+ bool rotationLockMaximized;
+ bool allowResizeOnPositiveSpaceChange;
+ bool gyroEnabled;
+ bool compassEnabled;
WindowProperties()
- : flags(0)
- , isBlockScreenTimeout(false)
- , isSubtleLightbar(false)
- , fullScreen(false)
- , activeTouchpanel(false)
- , alsDisabled (false)
- , overlayNotificationsPosition(OverlayNotificationsBottom)
- , suppressBannerMessages(false)
- , hasPauseUi(false)
- , suppressGestures(false)
- , dockBrightness(100)
- , dashboardManualDrag(false)
- , statusBarColor(0x00000000)
- , rotationLockMaximized(false)
- , allowResizeOnPositiveSpaceChange(true)
- , gyroEnabled(false)
- , compassEnabled(false)
- {
- }
-
- void merge(const WindowProperties& props);
+ : flags(0)
+ , isBlockScreenTimeout(false)
+ , isSubtleLightbar(false)
+ , fullScreen(false)
+ , activeTouchpanel(false)
+ , alsDisabled (false)
+ , overlayNotificationsPosition(OverlayNotificationsBottom)
+ , suppressBannerMessages(false)
+ , hasPauseUi(false)
+ , suppressGestures(false)
+ , dockBrightness(100)
+ , dashboardManualDrag(false)
+ , statusBarColor(0x00000000)
+ , rotationLockMaximized(false)
+ , allowResizeOnPositiveSpaceChange(true)
+ , gyroEnabled(false)
+ , compassEnabled(false)
+ {
+ }
+
+ void merge(const WindowProperties& props);
// convenience functions
- void setBlockScreenTimeout (bool enable) { flags |= isSetBlockScreenTimeout; isBlockScreenTimeout = enable; }
- void setSubtleLightbar (bool enable) { flags |= isSetSubtleLightbar; isSubtleLightbar = enable; }
- void setActiveTouchpanel(bool enable) { flags |= isSetActiveTouchpanel; activeTouchpanel = enable; }
- void setAlsDisabled(bool disable) { flags |= isSetAlsDisabled; alsDisabled = disable; }
- void setFullScreen(bool enable) { flags |= isSetFullScreen; fullScreen = enable; }
- void setOverlayNotificationsPosition(unsigned int position);
- void setSuppressBannerMessages(bool enable) { flags |= isSetSuppressBannerMessages; suppressBannerMessages = enable; }
- void setHasPauseUi(bool val) { flags |= isSetHasPauseUi; hasPauseUi = val; }
- void setSuppressGestures(bool val) { flags |= isSetSuppressGestures; suppressGestures = val; }
- void setDashboardManualDragMode(bool isManual) { flags |= isSetDashboardManualDragMode; dashboardManualDrag = isManual; }
- void setStatusBarColor(unsigned int color) { flags |= isSetStatusBarColor; statusBarColor = color; }
- void setRotationLockMaximized(bool enable) { flags |= isSetRotationLockMaximized; rotationLockMaximized = enable;}
- void setAllowResizeOnPositiveSpaceChange(bool allow) { flags |= isSetAllowResizeOnPositiveSpaceChange; allowResizeOnPositiveSpaceChange = allow; }
- void setAllowGyroEvents(bool allow) { flags |= isSetGyro; gyroEnabled = allow; }
- void setCompassEvents(bool enable) { flags |= isSetEnableCompassEvents; compassEnabled = enable; }
+ void setBlockScreenTimeout (bool enable) { flags |= isSetBlockScreenTimeout; isBlockScreenTimeout = enable; }
+ void setSubtleLightbar (bool enable) { flags |= isSetSubtleLightbar; isSubtleLightbar = enable; }
+ void setActiveTouchpanel(bool enable) { flags |= isSetActiveTouchpanel; activeTouchpanel = enable; }
+ void setAlsDisabled(bool disable) { flags |= isSetAlsDisabled; alsDisabled = disable; }
+ void setFullScreen(bool enable) { flags |= isSetFullScreen; fullScreen = enable; }
+ void setOverlayNotificationsPosition(unsigned int position);
+ void setSuppressBannerMessages(bool enable) { flags |= isSetSuppressBannerMessages; suppressBannerMessages = enable; }
+ void setHasPauseUi(bool val) { flags |= isSetHasPauseUi; hasPauseUi = val; }
+ void setSuppressGestures(bool val) { flags |= isSetSuppressGestures; suppressGestures = val; }
+ void setDashboardManualDragMode(bool isManual) { flags |= isSetDashboardManualDragMode; dashboardManualDrag = isManual; }
+ void setStatusBarColor(unsigned int color) { flags |= isSetStatusBarColor; statusBarColor = color; }
+ void setRotationLockMaximized(bool enable) { flags |= isSetRotationLockMaximized; rotationLockMaximized = enable;}
+ void setAllowResizeOnPositiveSpaceChange(bool allow) { flags |= isSetAllowResizeOnPositiveSpaceChange; allowResizeOnPositiveSpaceChange = allow; }
+ void setAllowGyroEvents(bool allow) { flags |= isSetGyro; gyroEnabled = allow; }
+ void setCompassEvents(bool enable) { flags |= isSetEnableCompassEvents; compassEnabled = enable; }
};
-#endif /* WINDOW_H */
+
+
+#endif // WINDOWPROPERTIES_H
View
258 Src/base/WindowTypes.h
@@ -16,242 +16,30 @@
*
* LICENSE@@@ */
-
-
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include "Common.h"
-
-#include <stdint.h>
-#include <string>
-#include <glib.h>
+#ifndef WINDOWTYPES_H
+#define WINDOWTYPES_H
#include <QGraphicsObject>
-#include <QSize>
-
-
-class ApplicationDescription;
-class WindowManagerBase;
-struct WindowProperties;
-
-/**
- * Mandatory Qt signal/slot connection between another object's signal
- * and this object's slot.
- */
-#define QM_CONNECT(source, sSignal, tSlot) \
- do { \
- if (!connect(source, sSignal, tSlot)) { \
- qFatal("Failed to connect signal %s::%s to this::%s", \
- #source, sSignal, tSlot); \
- } \
- } while (0)
-
-/**
- * Mandatory Qt signal/slot connection between the target slot and the source
- * signal.
- */
-#define QM_CONNECT_EX(target, source, sSignal, tSlot) \
- do { \
- if (target == NULL) qFatal("Cannot connect to NULL object"); \
- if (!(target)->connect(source, sSignal, tSlot)) { \
- qFatal("Failed to connect signal %s::%s to %s::%s", \
- #source, sSignal, #target, tSlot); \
- } \
- } while (0)
-
-class Window : public QGraphicsObject
-{
- Q_OBJECT
- Q_PROPERTY(bool grabMouse READ mouseGrabbed WRITE setMouseGrabbed)
-public:
-
- enum Type {
- Type_Invalid = UserType + 1,
- Type_StatusBar = UserType + 2,
- Type_Card = UserType + 3,
- Type_ChildCard = UserType + 4,
- Type_Overlay = UserType + 5,
- Type_Launcher = UserType + 6,
- Type_Dashboard = UserType + 7,
- Type_PopupAlert = UserType + 8,
- Type_BannerAlert = UserType + 9,
- Type_Menu = UserType + 10,
- Type_PIN = UserType + 11,
- Type_Emergency = UserType + 12,
- Type_QtNativePaintWindow = UserType + 13,
- Type_DockModeWindow = UserType + 14,
- Type_DockModeLoadingWindow = UserType + 15,
- Type_ModalChildWindowCard = UserType + 16,
- Type_None = UserType + 32 // arbitrary, can be as large as 0xFFFEFFFF
- };
-
- Window(Type type, const uint32_t bufWidth, const uint32_t bufHeight, bool hasAlpha=false);
- Window(Type type, const QPixmap& pix);
- virtual ~Window();
-
- // QGraphicsItem::type
- virtual int type() const { return m_type; } // has-base-impl
-
- // QGraphicsItem::boundingRect
- virtual QRectF boundingRect() const { return m_visibleBounds; } // has-base-impl
-
- virtual bool mouseGrabbed() const; // has-base-impl
- virtual void setMouseGrabbed(bool grabbed); // has-base-impl
-
- // QGraphicsItem::paint
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); // has-base-impl
-
- virtual bool isIpcWindow() const { return false; } // has-base-impl
-
- void setName(const std::string& name);
- std::string name() const;
- virtual void setAppId(const std::string& id);
- std::string appId() const;
- void setProcessId(const std::string& id);
- std::string processId() const;
- void setLaunchingAppId(const std::string& id);
- std::string launchingAppId() const;
- void setLaunchingProcessId(const std::string& id);
- std::string launchingProcessId() const;
- ApplicationDescription* appDescription() const;
-
- void setRemoved() { m_removed = true; }
- bool removed() const { return m_removed; }
-
- void setDisableKeepAlive() { m_disableKeepAlive = true; }
- bool disableKeepAlive() const { return m_disableKeepAlive; }
- virtual void setWindowProperties (const WindowProperties& attr) { }
-
- virtual void setVisibleDimensions(uint32_t width, uint32_t height); // has-base-impl
- virtual QSize getVisibleDimensions() const; // has-base-impl
-
- virtual void resize(int w, int h); //has-base-impl
-
- virtual const QPixmap* acquireScreenPixmap() { return &m_screenPixmap; }
-
- inline int initialWidth() const { return m_initialWidth; }
- inline int initialHeight() const { return m_initialHeight; }
-
-protected:
-
- virtual void lock() {}
- virtual void unlock() {}
-
- Type m_type;
- std::string m_name;
- std::string m_appId;
- std::string m_processId;
- std::string m_launchingAppId;
- std::string m_launchingProcId;
- mutable ApplicationDescription* m_appDesc;
- bool m_removed;
- bool m_disableKeepAlive;
- uint32_t m_bufWidth;
- uint32_t m_bufHeight;
- int m_initialWidth;
- int m_initialHeight;
- QRectF m_visibleBounds;
- QPixmap m_screenPixmap;
-
- friend class HostWindow;
-
- Window(const Window&);
- Window& operator=(const Window&);
-};
-
-
-
-struct WindowProperties {
- enum {
- isSetNothing = 0,
- isSetBlockScreenTimeout = 1 << 0,
- isSetSubtleLightbar = 1 << 1,
- isSetFullScreen = 1 << 2,
- isSetFastAccelerometer = 1 << 3,
- isSetOverlayNotifications = 1 << 4,
- isSetSuppressBannerMessages = 1 << 5,
- isSetHasPauseUi = 1 << 6,
- isSetSuppressGestures = 1 << 7,
- isSetDashboardManualDragMode = 1 << 9,
- isSetStatusBarColor = 1 << 10,
- isSetRotationLockMaximized = 1 << 11,
- isSetAllowResizeOnPositiveSpaceChange = 1 << 12,
- isSetEnableCompassEvents = 1 << 13,
- isSetGyro = 1 << 14,
- isSetActiveTouchpanel = 1 << 15,
- isSetAlsDisabled = 1 << 16,
- isSetLast
+namespace WindowType {
+ enum Type {
+ Type_Invalid = QGraphicsObject::UserType + 1,
+ Type_StatusBar = QGraphicsObject::UserType + 2,
+ Type_Card = QGraphicsObject::UserType + 3,
+ Type_ChildCard = QGraphicsObject::UserType + 4,
+ Type_Overlay = QGraphicsObject::UserType + 5,
+ Type_Launcher = QGraphicsObject::UserType + 6,
+ Type_Dashboard = QGraphicsObject::UserType + 7,
+ Type_PopupAlert = QGraphicsObject::UserType + 8,
+ Type_BannerAlert = QGraphicsObject::UserType + 9,
+ Type_Menu = QGraphicsObject::UserType + 10,
+ Type_PIN = QGraphicsObject::UserType + 11,
+ Type_Emergency = QGraphicsObject::UserType + 12,
+ Type_QtNativePaintWindow = QGraphicsObject::UserType + 13,
+ Type_DockModeWindow = QGraphicsObject::UserType + 14,
+ Type_DockModeLoadingWindow = QGraphicsObject::UserType + 15,
+ Type_ModalChildWindowCard = QGraphicsObject::UserType + 16,
+ Type_None = QGraphicsObject::UserType + 32 // arbitrary, can be as large as 0xFFFEFFFF
};
-
- enum {
- OverlayNotificationsBottom = 0,
- OverlayNotificationsLeft,
- OverlayNotificationsRight,
- OverlayNotificationsTop,
- OverlayNotificationsLast
- };
-
- unsigned int flags;
-
- bool isBlockScreenTimeout;
- bool isSubtleLightbar;
- bool fullScreen;
- bool activeTouchpanel;
- bool alsDisabled;
- unsigned int overlayNotificationsPosition;
- bool suppressBannerMessages;
- bool hasPauseUi;
- bool suppressGestures;
- bool dashboardManualDrag;
- unsigned int dockBrightness;
- unsigned int statusBarColor;
- bool rotationLockMaximized;
- bool allowResizeOnPositiveSpaceChange;
- bool gyroEnabled;
- bool compassEnabled;
-
- WindowProperties()
- : flags(0)
- , isBlockScreenTimeout(false)
- , isSubtleLightbar(false)
- , fullScreen(false)
- , activeTouchpanel(false)
- , alsDisabled (false)
- , overlayNotificationsPosition(OverlayNotificationsBottom)
- , suppressBannerMessages(false)
- , hasPauseUi(false)
- , suppressGestures(false)
- , dockBrightness(100)
- , dashboardManualDrag(false)
- , statusBarColor(0x00000000)
- , rotationLockMaximized(false)
- , allowResizeOnPositiveSpaceChange(true)
- , gyroEnabled(false)
- , compassEnabled(false)
- {
- }
-
- void merge(const WindowProperties& props);
-
- // convenience functions
- void setBlockScreenTimeout (bool enable) { flags |= isSetBlockScreenTimeout; isBlockScreenTimeout = enable; }
- void setSubtleLightbar (bool enable) { flags |= isSetSubtleLightbar; isSubtleLightbar = enable; }
- void setActiveTouchpanel(bool enable) { flags |= isSetActiveTouchpanel; activeTouchpanel = enable; }
- void setAlsDisabled(bool disable) { flags |= isSetAlsDisabled; alsDisabled = disable; }
- void setFullScreen(bool enable) { flags |= isSetFullScreen; fullScreen = enable; }
- void setOverlayNotificationsPosition(unsigned int position);
- void setSuppressBannerMessages(bool enable) { flags |= isSetSuppressBannerMessages; suppressBannerMessages = enable; }
- void setHasPauseUi(bool val) { flags |= isSetHasPauseUi; hasPauseUi = val; }
- void setSuppressGestures(bool val) { flags |= isSetSuppressGestures; suppressGestures = val; }
- void setDashboardManualDragMode(bool isManual) { flags |= isSetDashboardManualDragMode; dashboardManualDrag = isManual; }
- void setStatusBarColor(unsigned int color) { flags |= isSetStatusBarColor; statusBarColor = color; }
- void setRotationLockMaximized(bool enable) { flags |= isSetRotationLockMaximized; rotationLockMaximized = enable;}
- void setAllowResizeOnPositiveSpaceChange(bool allow) { flags |= isSetAllowResizeOnPositiveSpaceChange; allowResizeOnPositiveSpaceChange = allow; }
- void setAllowGyroEvents(bool allow) { flags |= isSetGyro; gyroEnabled = allow; }
- void setCompassEvents(bool enable) { flags |= isSetEnableCompassEvents; compassEnabled = enable; }
-};
-
-#endif /* WINDOW_H */
+}
+#endif // WINDOWTYPES_H
View
36 Src/base/application/ApplicationDescription.cpp
@@ -0,0 +1,36 @@
+/* @@@LICENSE
+*
+* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* LICENSE@@@ */
+
+
+#include "Common.h"
+
+#include <cjson/json.h>
+
+#include "ApplicationDescription.h"
+
+
+ApplicationDescription::ApplicationDescription()
+{
+}
+
+ApplicationDescription* ApplicationDescription::fromJsonString(const char* jsonStr, ApplicationDescription* base)
+{
+ ApplicationDescription* appDesc = base;
+ if (!appDesc) appDesc = new ApplicationDescription();
+ return ApplicationDescriptionBase::fromJsonString(jsonStr, static_cast<ApplicationDescriptionBase*>(appDesc));
+}
View
33 Src/base/application/ApplicationDescription.h
@@ -0,0 +1,33 @@
+/* @@@LICENSE
+*
+* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* LICENSE@@@ */
+
+#ifndef APPLICATIONDESCRIPTION_H
+#define APPLICATIONDESCRIPTION_H
+
+#include "ApplicationDescriptionBase.h"
+
+class ApplicationDescription : public ApplicationDescriptionBase
+{
+public:
+ ApplicationDescription();
+ virtual ~ApplicationDescription() {}
+
+ static ApplicationDescription* fromJsonString(const char* jsonStr, ApplicationDescription* base=NULL);
+};
+
+#endif /* APPLICATIONDESCRIPTION_H */
View
1,205 Src/base/application/ApplicationDescriptionBase.cpp
@@ -16,1197 +16,74 @@
*
* LICENSE@@@ */
-
-
-
-#include "Common.h"
-
-#include <stdio.h>
-#include <glib.h>
-
#include <cjson/json.h>
+#include <stdio.h>
-#include "ApplicationDescription.h"
-#include "ApplicationStatus.h"
-#include "LaunchPoint.h"
+#include "Common.h"
+#include "ApplicationDescriptionBase.h"
#include "Utils.h"
-#include "QtUtils.h"
-#include "Settings.h"
-#include "MimeSystem.h"
-#include "ApplicationManager.h"
-#include <QMetaMethod>
-#include <QMetaObject>
-#include "Preferences.h"
-
-ApplicationDescription::ApplicationDescription()
- : m_splashIconName()
- , m_splashBackgroundName()
- , m_launchInNewGroup(false)
- , m_tapToShareSupported(false)
- , m_handlesRelaunch(false)
-{
- m_isHeadLess = false;
- m_hasTransparentWindows = false;
- m_entryPoint = "index.html";
- m_miniIconName = "miniicon.png";
- m_category = "";
- m_version = std::string("1.0"); // default version
- m_executionLock = false;
- m_flaggedForRemoval = false;
- m_isRemovable = false;
- m_isUserHideable = false;
- m_progress = 0;
- m_isVisible = true;
- m_hardwareFeaturesNeeded = HardwareFeaturesNeeded_None;
- m_type = Type_Web;
- m_status = Status_Ready;
- m_hasAccounts = false;
- m_dockMode = false;
- m_appSize = 0;
- m_fsBlockSize = 0;
- m_runtimeMemoryRequired = 0;
- m_universalSearchJsonStr = "";
- m_pBuiltin_launcher = 0;
- m_requestedWindowOrientation = "";
-}
-ApplicationDescription::~ApplicationDescription()
+ApplicationDescriptionBase::ApplicationDescriptionBase()
{
- for (LaunchPointList::const_iterator it = m_launchPoints.begin();
- it != m_launchPoints.end(); ++it) {
- delete (*it);
- }
- if (m_pBuiltin_launcher)
- delete m_pBuiltin_launcher;
+ m_isHeadLess = false;
+ m_requestedWindowOrientation = "";
}
-ApplicationDescription* ApplicationDescription::fromFile(const std::string& filePath, const std::string& folderPath)
+ApplicationDescriptionBase* ApplicationDescriptionBase::fromJsonString(const char* jsonStr, ApplicationDescriptionBase* base)
{
- bool success = false;
- ApplicationDescription* appDesc = 0;
- char* jsonStr = 0;
- const gchar* palmAppDirPrefix = "/usr/palm/applications/";
- std::vector<MimeRegInfo> extractedMimeTypes;
- std::string launchParams;
-
- std::string builtinEntrypt;
- std::string builtinArgs;
-
- jsonStr = readFile(filePath.c_str());
- if (!jsonStr || !g_utf8_validate(jsonStr, -1, NULL))
- {
- return 0;
- }
-
- struct json_object* root=0;
- struct json_object* label=0;
-
- std::string title, icon, dirPath;
- gchar* dirPathCStr;
-
- dirPathCStr = g_path_get_dirname(filePath.c_str());
- dirPath = dirPathCStr;
- dirPath += "/";
- g_free(dirPathCStr);
-
- root = json_tokener_parse( jsonStr );
- if( !root || is_error( root ) )
- {
- g_warning("%s: Failed to parse '%s' into a JSON string", __FUNCTION__, filePath.c_str() );
- goto Done;
- }
-
- appDesc = new ApplicationDescription();
-
- appDesc->m_folderPath = folderPath;
-
- // ID: mandatory
- label = json_object_object_get(root, "id");
- if( label && !is_error(label) )
- {
- appDesc->m_id = json_object_get_string(label);
- }
- else
- {
- g_warning("%s: App %s does not have an ID", __FUNCTION__, filePath.c_str() );
- goto Done;
- }
-
-
- // MAIN: optional
- label = json_object_object_get(root, "main");
- if( label && !is_error(label) )
- {
- appDesc->m_entryPoint = json_object_get_string(label);
- }
- else
- {
- appDesc->m_entryPoint = "index.html";
- }
-
- if (!strstr(appDesc->m_entryPoint.c_str(), "://"))
- appDesc->m_entryPoint = std::string("file://") + dirPath + appDesc->m_entryPoint;
-
-
- // TITLE: mandatory
- label = json_object_object_get(root, "title");
- if( label && !is_error(label) )
- {
- appDesc->m_title = json_object_get_string(label);
- }
- else
- {
- g_warning("%s: App %s does not have a title",__FUNCTION__, filePath.c_str() );
- goto Done;
- }
-
- // SHORT NAME: optional
- label = json_object_object_get(root,"appmenu");
- if ( label && !is_error(label))
- {
- appDesc->m_appmenuName = json_object_get_string(label);
- }
- else
- appDesc->m_appmenuName = appDesc->m_title;
-
- // KEYWORDS: optional
- label = json_object_object_get(root,"keywords");
- if ( label && !is_error(label)) {
- appDesc->m_keywords.addKeywords(label);
- }
-
- //MIME HANDLING REGISTRATIONS: optional
- label = json_object_object_get(root,"mimeTypes");
- if ( label && !is_error(label)) {
- if (utilExtractMimeTypes(label,extractedMimeTypes)) {
- //found some!
- for (std::vector<MimeRegInfo>::iterator it = extractedMimeTypes.begin();
- it != extractedMimeTypes.end();
- ++it)
- {
- if ((*it).mimeType.size()) {
- // ADD BY MIME TYPE. The extension that is appropriate for this mimeType will be automatically filled in into "extension" if successful
- if (MimeSystem::instance()->addResourceHandler((*it).extension,(*it).mimeType,!((*it).stream),appDesc->id(),NULL,false) > 0)
- appDesc->m_mimeTypes.push_back(ResourceHandler((*it).extension,(*it).mimeType,appDesc->id(),(*it).stream)); //success adding to mime system, so add it to this app descriptor for bookeeping purposes
- }
- else if ((*it).extension.size()) {
- // ADD BY EXTENSION... count on the extension->mime mapping to already exist, or this will fail
- if (MimeSystem::instance()->addResourceHandler((*it).extension,!((*it).stream),appDesc->id(),NULL,false) > 0) {
- //get the mime type
- MimeSystem::instance()->getMimeTypeByExtension((*it).extension,(*it).mimeType);
- appDesc->m_mimeTypes.push_back(ResourceHandler((*it).extension,(*it).mimeType,appDesc->id(),(*it).stream));
- }
- }
- else if ((*it).scheme.size()) { //TODO: fix this so it's more robust; it should check if the way the appinfo file specified the scheme is in fact a valid "scheme form" regexp and if not, make it one
- // ADD REDIRECT: THIS IS A SCHEME or "COMMAND" FORM.... (e.g. "tel://")
- (*it).scheme = std::string("^")+(*it).scheme+std::string(":");
- if (MimeSystem::instance()->addRedirectHandler((*it).scheme,appDesc->id(),NULL,true,false) > 0) {
- appDesc->m_redirectTypes.push_back(RedirectHandler((*it).scheme,appDesc->id(),true));
- }
- }
- else if ((*it).urlPattern.size()) {
- // ADD REDIRECT: THIS IS A PURE REDIRECT FORM... (e.g. "^[^:]+://www.youtube.com/watch\\?v="
- if (MimeSystem::instance()->addRedirectHandler((*it).urlPattern,appDesc->id(),NULL,false,false) > 0) {
- appDesc->m_redirectTypes.push_back(RedirectHandler((*it).urlPattern,appDesc->id(),false));
- }
- }
- }
- }
- }
-
- // ICON: we have a default if this is not present.
- label = json_object_object_get(root, "icon");
- if( label && !is_error(label) )
- {
- icon = dirPath + json_object_get_string(label);
- }
- else
- icon = dirPath + "icon.png";
-
- // Optional parameters
- success = true;
-
- // Type: optional (defaults to Type_Web)
- label = json_object_object_get(root, "type");
- if (label && !is_error(label) && json_object_is_type(label, json_type_string)) {
- if (strncmp(json_object_get_string(label), "game", 4) == 0)
- appDesc->m_type = Type_Native;
- else if (strncmp(json_object_get_string(label), "pdk", 3) == 0)
- appDesc->m_type = Type_PDK;
- else if (strncmp(json_object_get_string(label), "qt", 2) == 0)
- appDesc->m_type = Type_Qt;
- else if (strncmp(json_object_get_string(label), "sysmgrbuiltin" , 13 ) == 0)
- appDesc->m_type = Type_SysmgrBuiltin;
- else
- appDesc->m_type = Type_Web;
- }
-
- // SPLASH ICON: optional (Used for loading/splash screen for cards)
- label = json_object_object_get(root, "splashicon");
- if (label && !is_error(label)) {
- appDesc->m_splashIconName = dirPath + json_object_get_string(label);
- }
- // SPLASH BACKGROUND: optional (Used for loading/splash screen for cards)
- label = json_object_object_get(root, "splashBackground");
- if (label && !is_error(label) && json_object_is_type(label, json_type_string)) {
- appDesc->m_splashBackgroundName = dirPath + json_object_get_string(label);
- }
- else {
- label = json_object_object_get(root, "splashbackground");
- if (label && !is_error(label) && json_object_is_type(label, json_type_string)) {
- appDesc->m_splashBackgroundName = dirPath + json_object_get_string(label);
- }
- }
-
- // MINI ICON: optional (Used for notification banner area)
- label = json_object_object_get(root, "miniicon");
- if( label && !is_error(label) )
- {
- appDesc->m_miniIconName = json_object_get_string(label);
- }
- else
- appDesc->m_miniIconName = "miniicon.png";
-
- appDesc->m_miniIconName = dirPath + appDesc->m_miniIconName;
- // LAUNCH IN NEW GROUP: optional (Used to prevent app from launching in current card stack)
- label = json_object_object_get(root, "launchinnewgroup");
- if( label && !is_error(label) )
- {
- appDesc->m_launchInNewGroup = json_object_get_boolean(label);
- }
- else
- appDesc->m_launchInNewGroup = false;
+ ApplicationDescriptionBase* appDesc = NULL;
+ if (base) appDesc = base;
+ else
+ appDesc = new ApplicationDescriptionBase();
- // CATEGORY: optional
- label = json_object_object_get(root, "category");
- if( label && !is_error(label) )
- {
- appDesc->m_category = json_object_get_string(label);
- }
+ struct json_object* root=0;
- // VENDOR: optional
- label = json_object_object_get(root, "vendor");
- if( label && !is_error(label) )
- {
- appDesc->m_vendorName = json_object_get_string(label);
- }
- else if (g_str_has_prefix(dirPath.c_str(), palmAppDirPrefix)) {
- appDesc->m_vendorName = "Palm, Inc.";
- }
-
- // VENDOR URL: optional
- label = json_object_object_get(root, "vendorurl");
- if( label && !is_error(label) )
- {
- appDesc->m_vendorUrl = json_object_get_string(label);
- }
-
- // SIZE: optional
- label = json_object_object_get(root, "appsize");
- if( label && !is_error(label) )
- {
- appDesc->m_appSize = (unsigned int) json_object_get_int(label);
- }
-