bool SqLiteStorage::createDatabase( Configuration& configuration ) { bool success = createDatabaseTables(); if ( !success ) return false; // add installation id and user id: const QString userName = configuration.user.name(); configuration.user = makeUser( userName ); if ( ! configuration.user.isValid() ) { qDebug() << "SqLiteStorage::createDatabase: cannot store user name"; return false; } // make an installation: // FIXME make a useful name for it QString installationName = "Unnamed Installation"; Installation installation = createInstallation( installationName ); if ( ! installation.isValid() ) { qDebug() << "SqLiteStorage::createDatabase: cannot create default installation id"; return false; } else { configuration.installationId = installation.id(); } return true; }
int main(void) { bool vInstall = false; char* versionNumber; char* executionString; char* executionBase = "system(/Applications/Chromium.app/Contents/MacOS/Chromium_ --ppapi-flash-path=/Library/Internet\\\\ Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin/Contents/MacOS/PepperFlashPlayer --ppapi-flash-version="; char* executionTail = "\");\n"; char* chromiumName = "/Applications/Chromium.app/Contents/MacOS/Chromium_"; if (!existingInstallation(chromiumName)) { vInstall = verifyInstallation(false); if (!vInstall) { fprintf(stderr, "Installation declined\n"); exit(1); } } versionNumber = calloc(250, sizeof(char)); requestVersion(versionNumber); executionString = calloc(250, sizeof(char)); strcat(executionString, executionBase); strcat(executionString, versionNumber); strcat(executionString, executionTail); strcat(executionString, "\0"); createFile(executionString); vInstall = verifyInstallation(true); if (!vInstall) { fprintf(stderr, "Installation cancelled\n"); exit(1); } if (!existingInstallation(chromiumName)) { createInstallation(); } enableFlash(); free(versionNumber); free(executionString); return 0; }
void getInstallation(ParseClientInternal *parseClient) { // If we have both installation id and installation object id, don't do anything if ((strlen(parseClient->installationObjectId) > 0) && (strlen(parseClient->installationId) > 0)) { return; } char content[150]; // We have only installation object id or installation id if (strlen(parseClient->installationObjectId) > 0) { // This is just in case, we should never get in this branch in normal scenarios // as the device app will always give us installation id, and never installation object id snprintf(content, sizeof(content)-1, "/1/installations/%s", parseClient->installationObjectId); parseSendRequestInternal((ParseClient)parseClient, "GET", content, NULL, getInstallationCallback, FALSE); } else if (strlen(parseClient->installationId) > 0) { snprintf(content, sizeof(content)-1, "where=%%7b%%22installationId%%22%%3a+%%22%s%%22%%7d", parseClient->installationId); parseSendRequestInternal((ParseClient)parseClient, "GET", "/1/installations", content, getInstallationByIdCallback, FALSE); } // Go through create new installation, to catch the case we still don't have // an installation object id. This will be noop if we managed to get the installation // already createInstallation(parseClient); }