MoonAppRecord * MoonInstallerService::GetAppRecord (Deployment *deployment) { const Uri *xap_uri = deployment->GetXapLocation (); const char *base_dir = GetBaseInstallDir (); const char *start, *inptr; MoonAppRecord *app; char *uid; if (!InitDatabase ()) return NULL; if (IsRunningOutOfBrowser (deployment)) { // we'll need to get the uid used by this app, which can be // extracted from the local path. start = xap_uri->GetPath () + strlen (base_dir); if (*start == '/') start++; inptr = start; while (*inptr != '/') inptr++; uid = g_strndup (start, inptr - start); app = db->GetAppRecordByUid (uid); g_free (uid); } else { app = db->GetAppRecordByOrigin (xap_uri); } return app; }
bool Application::InstallWithError (MoonError *error, bool user_initiated, bool unattended) { MoonInstallerService *installer = Runtime::GetInstallerService (); Deployment *deployment = Deployment::GetCurrent (); // application manifest must allow out-of-browser support OutOfBrowserSettings *settings = deployment->GetOutOfBrowserSettings (); if (!settings) { // FIXME - this fix a crasher but is not complete wrt MSDN return false; } if (!IsInstallable ()) { MoonError::FillIn (error, MoonError::INVALID_OPERATION, "Applications may only be installed from http, https or file URLs"); return false; } if (GetInstallState () == InstallStateInstalled || IsRunningOutOfBrowser ()) { MoonError::FillIn (error, MoonError::INVALID_OPERATION, "Application is already installed"); return false; } // the dialog is displayed only if the action leading to this call was initiated directly from the user if (!unattended && !user_initiated && !deployment->GetSurface ()->IsUserInitiatedEvent ()) return false; SetInstallState (InstallStateInstalling); if (installer->Install (deployment, unattended)) { SetInstallState (InstallStateInstalled); return true; } SetInstallState (InstallStateInstallFailed); return false; }