bool StreamToFileManager::startStreamingToFile(QString targetFilePath, bool isRemoveTargetFileIfExists)
{
    if(isRemoveTargetFileIfExists)
    {
        // check whether the target-file exists
        QFile resourceTargetFile(targetFilePath);
        if(resourceTargetFile.exists()) {
            if( !resourceTargetFile.remove() ) {
                WLog("Cannot remove the file:") << targetFilePath;
                _isStreamingAborted = true;
    //            Q_EMIT streamingFinishedWithError(targetFilePath, "File cannot be removed.");
                return false;
            }
        }
    }

    AW_QOBJECT_SAFE_DELETE(_targetFile);
    _targetFile = new QFile(targetFilePath, this);
    if(!_targetFile->open(QIODevice::WriteOnly | QIODevice::Append)) {
        WLog("Cannot open the file: ") << _targetFile->errorString();
        _isStreamingAborted = true;
//        Q_EMIT streamingFinishedWithError(targetFilePath, "File cannot be opened.");
        return false;
    }

    DLog("File opened");
    _isStreamingAborted = false;
    _isStreamClosing = false;
    _targetFilePath = targetFilePath;

    return true;
}
void CleverApplicationIconPresenterSortingDelegate::_loadSortingDatabase(QString sortingDatabasePath)
{
    if(sortingDatabasePath.isEmpty()) {
        WLog("Given sorting database path is empty. Cannot load it.");
        return;
    }

    if(!this->_isFilterMapLoadedFromDatabase)
    {
        QMutex mutex;
        mutex.lock();

        if(!this->_isFilterMapLoadedFromDatabase) {
            // load
            SortingDatabaseManager *sortingDbManager = new SortingDatabaseManager(sortingDatabasePath);
            bool isSuccess = sortingDbManager->getAllFilterKeyValuePairs(this->_filterKeyValueMap);
            delete sortingDbManager;

            // flag
            if(isSuccess) {
                this->_currSortingDatabasePath = sortingDatabasePath;
                this->_isFilterMapLoadedFromDatabase = true;
            }
            else {
                WLog("Couldn't get the filter key-values. Probably invalid database-path.");
            }
        }

        mutex.unlock();
    }
}
bool PathManager::copyOnlyFilesOfDirectory(QString sourceDirPath, QString destDirPath)
{
    FLAG_FOR_REVIEW_WITH_HINT("Should copy symlink / shortcut files as well?? Temporarily removed / turned off.");

    QDir sourceDir(sourceDirPath);

    QStringList files = sourceDir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
    for(int i = 0; i < files.count(); i++)
    {
        QString srcName = PathManager::combineAndCleanPathes(sourceDirPath, files[i]);
        QString destName = PathManager::combineAndCleanPathes(destDirPath, files[i]);

        // QFile cannot copy the file, when destName exists
        if(QFileInfo(srcName).isSymLink()) {
            // tmp, do nothing
            WLog(QString("The file [%1] is a symlink to file [%2]").arg(srcName).arg( QFileInfo(srcName).symLinkTarget() ));
        }
        else {
            if(!QFile::copy(srcName, destName)) {
                WLogS << " ! Cannot copy the file from: " << srcName << " to: " << destName;
                WLog(QString(" ! Cannot copy file from [%1] to [%2]").arg(srcName).arg(destName));
                return false;
            }
            else {
#ifdef ENABLE_PATH_MANAGER_LOGGING
                DLog(QString("Copy succeeded - file from [%1] to [%2]").arg(srcName).arg(destName));
#endif
            }
        }
    }
    files.clear();

    return true;
}
bool PathManager::deleteThisDirectoryAndEverythingBelow(QString topDirPath)
{
    {
        QDir topDir(topDirPath);

        if (!topDir.exists()) {
            WLog(QString("The given topDir does not exists: %1").arg(topDirPath));
            return true;
        }

        //First delete any files in the current directory
        QFileInfoList files = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden | QDir::System/* | QDir::NoSymLinks*/);
        for(int i = 0; i < files.count(); i++)
        {
            QString currFileInPath = files.at(i).fileName();
            /*QString currFileAbsolutePath = files.at(i).absoluteFilePath();
        if(QFileInfo(currFileAbsolutePath).isSymLink()) {
            // it's a symlink simply remove it
            PATH_MANAGER_INTERNAL_LOG_TO_DATABASE(QString("The dir is a symlink file [%1]. Simply remove it.").arg(currDirAbsolutePath));
            QDir().remove(currDirAbsolutePath);
        }
        else */

            if( !topDir.remove(currFileInPath) ) {
                WLogS << " ! The specified file cannot be removed: " << currFileInPath;
                WLog(QString("The specified file cannot be removed: %1").arg(files.at(i).absoluteFilePath()));
                return false;
            }
        }

        //Now recursively delete any child directories
        QFileInfoList dirs = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs);
        for(int i = 0; i < dirs.count(); i++)
        {
            QString currDirAbsolutePath = dirs.at(i).absoluteFilePath();
            if(QFileInfo(currDirAbsolutePath).isSymLink()) {
                // it's a symlink to a dir, simply remove this symlink file
                WLog(QString("The dir is a symlink file [%1]. Simply remove it.").arg(currDirAbsolutePath));
                QDir().remove(currDirAbsolutePath);
            }
            else if( !PathManager::deleteThisDirectoryAndEverythingBelow( currDirAbsolutePath ) ) {
                return false;
            }
        }
    }

    //Finally, remove empty top directory

//    if( !topDir.rmdir(topDir.path()) ) {
    if( !QDir().rmdir(topDirPath) ) {
        WLog(QString("The specified directory cannot be removed: %1. Maybe it's still not empty.").arg(topDirPath));
        return false;
    }

    return true;
}
bool Background_ClientInstaller::tryToBackup()
{
    // remove the previous backup
    if(!PathHelper::deleteThisDirectoryAndEverythingBelow(AppSpecificPathHelper::getTmp_ClientSelfUpdate_OldVersionBackupFolder())) {
        WLog("Failed to clear the backup folder.");
        return false;
    }
    else {
        DLog("Backup folder cleared.");
    }

#ifdef Q_OS_WIN
    // do the new backup
    if(!PathHelper::copyWholeDirectory(this->_clientRootPath, AppSpecificPathHelper::getTmp_ClientSelfUpdate_OldVersionBackupFolder(), true, PathHelper::SHM_UseAsFile)) {
        WLog("Failed to do the backup.");
        return false;
    }
    else {
        DLog("Backup finished.");
    }
#endif

#ifdef Q_OS_MAC
   // Get apps with *.appwhirr.bitfall bundle identifier and delete them
    QDir root(this->_clientRootPath);

    QStringList dirs = root.entryList(QDir::NoDotAndDotDot | QDir::Dirs);

    QString dir;
    Q_FOREACH(dir, dirs) {
        if (dir.endsWith(".app", Qt::CaseInsensitive)) {
            QString path = PathHelper::combineAndCleanPathes(this->_clientRootPath, dir);
            if (PathHelper::getBundleIdentifier(path).endsWith(".appwhirr.bitfall")) {
                // do the new backup
                if(!PathHelper::copyWholeDirectory(path, AppSpecificPathHelper::getTmp_ClientSelfUpdate_OldVersionBackupFolder(), false, PathHelper::SHM_UseAsFile)) {
                    WLog("Failed to do the backup.");
                    return false;
                }
                else {
                    DLog("Backup finished.");
                }
            }
        }
    }
#endif

    return true;
}
void CommunicationDescriptionGateway::requestReceived(QByteArray response) {
    if(networkRequest == NULL) {
        WLog("Response recieved, but request is already deleted! Cannot parse the response! This should never happen.");
        return;
    }

    Q_EMIT _receivedResponseData(response);

    networkResponse = networkRequest->getResponseParser();
    if (!networkResponse) {
        QList<BaseNetworkEntity*> emptyList;
        Q_EMIT this->finished(emptyList);
        _finishedWithCommunicationStep();
        return;
    }


    connect(networkResponse, SIGNAL(finished()), this, SLOT(responseFinished()));
    connect(networkResponse, SIGNAL(parsingFinished(QList<BaseNetworkEntity*>)), this, SIGNAL(finished(QList<BaseNetworkEntity*>)));
    connect(networkResponse, SIGNAL(parsingFailed(QString)), this, SIGNAL(failedToRetrieveDescription(QString)));

    //
    // parse in background
    QThreadPool::globalInstance()->start(networkResponse);
}
Example #7
0
VixMntMsgQue::VixMntMsgQue(const char *msg_name,
                           bool readOnly) {

   // readOnly is unused now.
   this->readOnly = readOnly;

   if (!msg_name) {
      this->vixMntMsgMapFileName = VixMntMsgQue::vixMntMsgName;
   } else {
      this->vixMntMsgMapFileName = msg_name;
   }


   this->vixMntMsgID =
      mq_open(this->vixMntMsgMapFileName.c_str(), O_CREAT | O_RDWR, 0644, NULL);

   if (this->vixMntMsgID < 0) {
      if (errno == EEXIST) {
         WLog("exist mqid : %d | mq_name : %s", this->getVixMntMsgID(),
              vixMntMsgMapFileName.c_str());
      } else {
         ELog("open mesage queue error %s ", strerror(errno));
      }
   }

   assert(this->vixMntMsgID > 0);
   VixMntMsgQue::vixMntMsgMap[this->vixMntMsgMapFileName] = this->vixMntMsgID;
}
// Q_SLOT
void NotificationManager::itemHiddenAndSafeToRemove(QWidget *widget) {
    int currDeletingItemCnt = this->_currDeletingTimeoutedNotifWidgets.size();
    bool isFound = false;
    for(int i = 0; i < currDeletingItemCnt && !isFound; i++) {
        if(_currDeletingTimeoutedNotifWidgets[i] == widget) {
            isFound = true;
        }
    }

    if(isFound) {
        // remove from layout -> not necessary - this method is called by the layout

        // remove from the tmp "deleting" collection
        NotificationWidget *castedWidget = dynamic_cast<NotificationWidget *>(widget);
        if(castedWidget != NULL) {
            this->_currDeletingTimeoutedNotifWidgets.removeOne(castedWidget);

            // and delete the notification widget
            AW_QOBJECT_SAFE_DELETE(widget);
        }
        else {
            WLog("Cannot cast the widget to the desired type. This should never happen!");
        }
    }
    else {
//        DLog("Item not found int _currDeletingTimeoutedNotifWidgets. It's only temporarily swapped-out from the layout.");
    }
}
void AppUninstaller::_cleanUpFailedWithError(QString errorMessage)
{
    WLog("Clean-up failed with error: ") << errorMessage;
    PathHelper::logLastOSSpecificFileSystemHandlingError();
    // backup cleanup is not a critical action in uninstall - everything else succeeded so the uninstall did succeed
    this->_currentUninstallFinishedWithSuccess();
}
void AppUninstaller::_appRemoveFailedWithError(QString errorMessage)
{
    WLog("App remove failed with error: ") << errorMessage;
    PathHelper::logLastOSSpecificFileSystemHandlingError();
//    Q_EMIT uninstallSuspendedInternally(this->_uninstallQueue.head());
    this->_currentUninstallFailedWithError("App remove failed.");
}
void AppUninstaller::_backupFolderClearFinished()
{
    DLog("--- do backup");

    // step 2: do backup
    if(!QDir(this->_uninstallQueue.head().getDynamicDescription_ReadOnly()->getInstalledRootPath()).exists()) {
        WLog("Application is not installed - it's installed root path does not exists here: ") << this->_uninstallQueue.head().getDynamicDescription_ReadOnly()->getInstalledRootPath();

        // will emit success to allow the GUI to refresh as not-installed
        this->_currentUninstallFinishedWithSuccess();
        return;
    }
    QString appId = this->_uninstallQueue.head().getDynamicDescription_ReadOnly()->getAppId();
    Q_EMIT progressStateMessage(appId, tr("Performing app backup"));

#if 0
    QString appIntalledDirPath = this->_uninstallQueue.head().getDynamicDescription_ReadOnly()->getInstalledRootPath();
    Runnable_CopyDirectory *backupWorker = new Runnable_CopyDirectory(appIntalledDirPath, AppSpecificPathHelper::getTmp_UninstallBackupDirectoryPath(), true, PathHelper::SHM_UseAsFile, true);
    connect(backupWorker, SIGNAL(failedWithError(QString)), this, SLOT(_backupFailedWithError(QString)));
    connect(backupWorker, SIGNAL(finishedWithSuccess()), this, SLOT(_backupFinished()));
    QThreadPool::globalInstance()->start(backupWorker);
#endif

    if( !PathHelper::renameFileOrFolder(this->getCurrentAppInstalledRootDirFileInfo(),
                                        this->getCurrentAppTargetBackupDirName()) )
    {
        this->_backupFailedWithError(tr("Cannot backup the app"));
    }
    else {
        this->_backupFinished();
    }
}
void AWUninstallPerformerTask::removeAppWhirrClient()
{
    Q_EMIT uninstallStateMessage(tr("Removing AppWhirr app..."));

    QFileInfo clientAppFolderFileInfo(_uninstallConfigs->getAppWhirrClientAppFolderPath());

#ifdef Q_OS_MAC
    QString clientAppFolderDirName( QDir(clientAppFolderFileInfo.absoluteFilePath()).dirName() );
    if( clientAppFolderDirName != "AppWhirrData" ) {
        // fail for security reasons (don't delete any other folder, especially not the Applications folder)
        WLog("Because of security reasons the AppWhirr client have to be in the 'AppWhirrData' folder - and it's not. Won't delete the client. => Detected dir-name: ") << clientAppFolderDirName;
        _uninstallConfigs->addFailedUninstallStep(UninstallDeleteSteps::RemoveAppWhirrClientFiles);
        Q_EMIT uninstallStateMessage(tr("Failed to remove the AppWhirr app..."));
        this->finishedWithRemoveAppWhirrClient();
        return;
    }
    else {
        DLog("AppWhirr is in the 'AppWhirrData' folder - uninstall can be performed");
    }
#endif

    if(clientAppFolderFileInfo.exists()) {
        if( !this->deleteFileOrFolderWithBackup(QFileInfo(_uninstallConfigs->getAppWhirrClientAppFolderPath())) ) {
            _uninstallConfigs->addFailedUninstallStep(UninstallDeleteSteps::RemoveAppWhirrClientFiles);
            Q_EMIT uninstallStateMessage(tr("Failed to remove the AppWhirr app..."));
        }
    }

    this->finishedWithRemoveAppWhirrClient();
}
void AppUninstaller::_revertBackupFailedWithError(QString errorMessage)
{
    WLog("Revert backup failed with error: ") << errorMessage;
    PathHelper::logLastOSSpecificFileSystemHandlingError();

    // don't store anything, revert backup is not that crucial
    this->_currentUninstallFailedWithError(tr("Cannot remove the application."));
}
void SameSizeLayoutSnapshotChangeDelegateBase::changeSnapshot(WidgetListSnapshot sourceSnapshot, WidgetListSnapshot targetSnapshot)
{
    // check whether a change is currently in progress so we should only store (and compress)
    //  this change or we should make it right now (if we are not busy right now)
    if(isProcessingSnapshotChangeFlag)
    {
#ifdef ENABLE_SNAPSHOT_HANDLING_LOGGING
        DLog("isProcessingSnapshotChangeFlag = true");
        DLogS << "sourceSnapshot cnt: " << sourceSnapshot.getOrderedItemCount();
        DLogS << "targetSnapshot cnt: " << targetSnapshot.getOrderedItemCount();
#endif
        //snapshotQueue.enqueue(SnapshotQueueItem(sourceSnapshot, targetSnapshot));

        isCompactSnapshotChangeAvailable = true;
        if(isCompactSnapshotSourceNotYetDefined)
        {
            isCompactSnapshotSourceNotYetDefined = false;
            compactSnapshotChange.setSourceSnapshot(sourceSnapshot);
        }

        compactSnapshotChange.setTargetSnapshot(targetSnapshot);

        return;
    }

    DynamicDelegateBasedHighPerformanceSameSizeLayoutBase *castedParent = this->getCastedParentLayout();
    if(castedParent == NULL)
    {
        WLog("Parent is not the type we need.");
        return;
    }

    QSize currentOptimalSize = castedParent->getCalculatedOptimalSize();

    isProcessingSnapshotChangeFlag = true; // block until it finished - queue the requests
    SameSizeHorizontalLayoutingInformations layoutInformations = castedParent->getLayoutingInformations();

    // force-recalculate the sizes before layout-blocking
    // -> the layout has the required informations about the new-state (new item cound, size, ...)
//    castedParent->recalculateMinimalAndOptimalSizesByTotalLayoutWidth(castedParent->getCachedLastReceivedRect().width());
    castedParent->_recalculateOptimalSizeByLastReceivedWidth();

    QSize predictedOptimalSizeAfterLayoutChange = castedParent->getCalculatedOptimalSize();

    Q_EMIT layoutChangeStarted(currentOptimalSize, predictedOptimalSizeAfterLayoutChange);
    castedParent->setLayoutUpdateBlocked(true, false);

    // clear the current animation set - it's allowed here, we are not in a change-progress (animation)
    this->clearCurrentAnimationGroup();

    //
    // calculate and create the change-animations
    this->_changeSnapshotImplementation(sourceSnapshot, targetSnapshot, layoutInformations);

    //
    // and start the change-animations
    this->startCurrentAnimationGroup();
}
bool ApplicationDescriptionModel::isUpdateAvailable()
{
    if(this->getDynamicDescription_ReadOnly()->getAppState() == AppWhirr::ApplicationGrabStates::Installed)
    {
        if(this->getDynamicDescription_ReadOnly()->getInstalledVersion() != this->getDynamicDescription_ReadOnly()->getNewestAvailableVersionForThisPlatform())
        {
            if(this->getDynamicDescription_ReadOnly()->getNewestAvailableVersionForThisPlatform().isEmpty()) {
                WLog("Newest available version - is empty!");
                return false;
            }
            if(this->getDynamicDescription_ReadOnly()->getInstalledVersion().isEmpty()) {
                WLog("Installed version - is empty!");
            }
            return true;
        }
    }

    return false;
}
SameSizeHorizontalLayoutingInformations SameSizeLayoutSnapshotChangeDelegateBase::getLayoutingInformations() {
    DynamicDelegateBasedHighPerformanceSameSizeLayoutBase *castedParent = this->getCastedParentLayout();
    if(castedParent == NULL)
    {
        WLog("Parent is not the type we need.");
        return SameSizeHorizontalLayoutingInformations::CreateEmpty();
    }

    return castedParent->getLayoutingInformations();
}
void CleverApplicationIconPresenterSortingDelegate::addOrSetValueForKey(QString filterKey, QString filterValue)
{
    if(_currSortingDatabasePath.isEmpty()) {
        WLog("Sorting database path is empty - probably you forgot to call _loadSortingDatabase");
        return;
    }

    this->_filterKeyValueMap[filterKey] = filterValue;
    SortingDatabaseManager *sortingDbManager = new SortingDatabaseManager(_currSortingDatabasePath);
    sortingDbManager->setValueForKey(filterKey, filterValue);
    delete sortingDbManager;
}
void AppUninstaller::_currentUninstallFailedWithError(QString errorMessage)
{
    // remove the item
    ApplicationDescriptionModel appDescr = this->_uninstallQueue.dequeue();
    WLog(" -- Uninstall failed for item: ") << appDescr.getDynamicDescription_ReadOnly()->getAppId() << appDescr.getDynamicDescription_ReadOnly()->getAppName();
    // emit the error
    Q_EMIT failedWithError(appDescr, errorMessage);

    // and try to start the next uninstall
    _isInUninstallProcess = false;
    this->_tryToStartNextUninstallInQueue();
}
bool Background_ClientInstaller::copyNewVersion()
{
    // recreate the directory
    if(!PathHelper::ensureDirectoryCreated(this->_clientRootPath)) {
        WLog("Failed to recreate target client directory.");
        return false;
    }
    else {
        DLog("Target client directory recreated.");
    }

    if(!PathHelper::copyWholeDirectory(AppSpecificPathHelper::getTmp_ClientSelfUpdate_UncompressedNewVersionPath(), this->_clientRootPath, true, PathHelper::SHM_UseAsFile)) {
        WLog("Failed to copy the new version to it's final place.");
        return false;
    }
    else {
        DLog("New version copied to it's final place.");
    }

    return true;
}
void SameSizeLayoutSnapshotChangeDelegateBase::layoutChangeAnimationsFinished()
{
    DynamicDelegateBasedHighPerformanceSameSizeLayoutBase *castedParent = this->getCastedParentLayout();
    if(castedParent == NULL)
    {
        WLog("Parent is not the type we need.");
        return;
    }

    //castedParent->setLayoutUpdateBlocked(false, false);

    this->_hideAndSendSignalAboutDeletedItems();

    //
    // THIS IS REQUIRED !!! -> the changeSnapshot method will use it and may modify it
    //  for myself (Viktor): do a favor for yourself - don't modify this, or at least check whether it's used anywhere else as well in this code before optimization
    isProcessingSnapshotChangeFlag = false;

#if 0
    //
    // chech for another layout change (happened during the animation-block)
    if(!snapshotQueue.isEmpty())
    {
        //DLog(" ! there are other queued changes");
        // another snapshot is in the queue -> do it
        SnapshotQueueItem snapshotItem = snapshotQueue.dequeue();
        this->changeSnapshot(snapshotItem.getSourceSnapshot(), snapshotItem.getTargetSnapshot());
    }
#endif

    // ! this is an optimized solution
    //      it eliminates the quene and compresses the change to only
    //      one SnapshotChange item - it's source is the first unprocessed source
    //      and it's target is the last unprocessed target snapshot
    if(isCompactSnapshotChangeAvailable)
    {
        isCompactSnapshotChangeAvailable = false;
        isCompactSnapshotSourceNotYetDefined = true;
        this->changeSnapshot(compactSnapshotChange.getSourceSnapshot(), compactSnapshotChange.getTargetSnapshot());
    }

    if(!isProcessingSnapshotChangeFlag)
    {
        // no more snapshots, hurray!!
#ifdef ENABLE_SNAPSHOT_HANDLING_LOGGING
        DLog(" no more changes in the queue");
#endif
        castedParent->setLayoutUpdateBlocked(false, true);
        castedParent->update();

        Q_EMIT layoutChangeFinished();
    }
}
bool Background_ClientInstaller::setRequiredPermissionsForTheNewVersion()
{
#ifdef Q_OS_WIN
    // set execution permission first
    if (!PathHelper::setPermissionForFilesOfDirectory(this->_clientRootPath, QFile::ExeGroup | QFile::ExeOther | QFile::ExeOwner | QFile::ExeUser, true, true)) {
        WLog("Failed to set required permissions.");
        return false;
    }
    else {
        DLog("Permissions set.");
        return true;
    }
#endif

#ifdef Q_OS_MAC
   // Get apps with *.appwhirr.bitfall bundle identifier and delete them
    QDir root(this->_clientRootPath);

    QStringList dirs = root.entryList(QDir::NoDotAndDotDot | QDir::Dirs);

    QString dir;
    Q_FOREACH(dir, dirs) {
        if (dir.endsWith(".app", Qt::CaseInsensitive)) {
            QString path = PathHelper::combineAndCleanPathes(this->_clientRootPath, dir);
            if (PathHelper::getBundleIdentifier(path).endsWith(".appwhirr.bitfall")) {
                // set execution permission first
                if (!PathHelper::setPermissionForFilesOfDirectory(path, QFile::ExeGroup | QFile::ExeOther | QFile::ExeOwner | QFile::ExeUser, true, true)) {
                    WLog("Failed to set required permissions.");
                    return false;
                }
                else {
                    DLog("Permissions set.");
                }
            }
        }
    }

    return true;
#endif
}
bool AutoStartupDelegate::makeItAutoStartAtSystemStartup() {

    if(!DesktopShortcutCreator::createShortcut(AppSpecificPathHelper::getWinAndWinUserSpecAppWhirrClientAutoStartupFilePath(), AppSpecificPathHelper::getClientExecutablePath(), QString(), "Start AppWhirr client", true))
    {
        WLog("Cannot create the desktop-shortcut to path: ") << AppSpecificPathHelper::getWinAndWinUserSpecAppWhirrClientAutoStartupFilePath();
        return false;
    } else {
//        DLog("SUccess!!");
        return true;
    }

//    bool isSucceeded = true;

//    // Get the file path
//    QString qAppPath = QCoreApplication::applicationFilePath();

//    // Check if we have already in the autostarup list
//    if (willStartAtSystemStartup(qAppPath)) {
//        return true;
//    }

//    QString easyAppsWindowStartupFilePath = this->getEasyAppsStartupFile_WinAndUserSpecific();
//    DLogS << "startup file path: " << easyAppsWindowStartupFilePath;

//    if(!easyAppsWindowStartupFilePath.isEmpty())
//    {
//        qDebug(easyAppsWindowStartupFilePath.toAscii());

//        QFile f(easyAppsWindowStartupFilePath);
//        if (!f.open(QFile::WriteOnly | QIODevice::Text)) {
//            qDebug("FAILED to open the startup file");
//            return false;
//        }

//        QFileInfo fi(QApplication::applicationFilePath());

//        f.write("@ECHO OFF\n");
//        // the proper syntax to "start app without waiting to finish" with working dir:
//        //  example: start /d "E:\My Dropbox\EasyApps\Releases\V1\PreAlpha" EasyPortableApps_AppLauncher.exe
//        QString startCommand = QString("start /d %1 %2").arg(
//                PathManager::quotePath(QDir::toNativeSeparators(QApplication::applicationDirPath())),
//                fi.fileName());
//        f.write(startCommand.toAscii());
//        f.close();

//        qDebug(startCommand.toAscii());
//    } else {
//        qDebug("Cannot get the startup-folder. Sorry.");
//    }

//    return isSucceeded;
}
void CommunicationDescriptionGateway::performThisRequest(BaseNetworkRequest *requestToPerform)
{
    if(_isRequestActive) {
        WLog("Active request found! Only one request can be active!");
        return;
    }

    _isRequestActive = true;
    _finishedSteps = 0;
    this->networkRequest = requestToPerform;
    setupRequestConnections();
    networkRequest->startThisRequest();
}
bool Background_ClientInstaller::tryToRemoveOldVersion() {
#ifdef Q_OS_WIN
    // remove the current version
    if(!PathHelper::deleteThisDirectoryAndEverythingBelow(this->_clientRootPath)) {
        WLog("Failed to remove the old version.");
        return false;
    }
    else {
        DLog("Old version removed.");
    }
#endif

#ifdef Q_OS_MAC
   // Get apps with *.appwhirr.bitfall bundle identifier and delete them
    QDir root(this->_clientRootPath);

    QStringList dirs = root.entryList(QDir::NoDotAndDotDot | QDir::Dirs);

    QString dir;
    Q_FOREACH(dir, dirs) {
        if (dir.endsWith(".app", Qt::CaseInsensitive)) {
            QString path = PathHelper::combineAndCleanPathes(this->_clientRootPath, dir);
            if (PathHelper::getBundleIdentifier(path).endsWith(".appwhirr.bitfall")) {
                // It's an AW app, remove it.
                if(!PathHelper::deleteThisDirectoryAndEverythingBelow(path)) {
                    WLog("Failed to remove the old version.");
                    return false;
                }
                else {
                    DLog("Old version removed.");
                }
            }
        }
    }

#endif

    return true;
}
void MainWindow::_startDeleteTest()
{
    DLog("-- start DELETE test: ") << _testSrcDirLineEdit->text();

    if(!PathHelper::deleteThisDirectoryAndEverythingBelow(_testSrcDirLineEdit->text())) {
        WLog("delete FAILED!");
    }
    else {
        DLog(" - delete test SUCCESS");
    }

    DLog(" -> end of DELETE test");
}
void MainWindow::_startCopyTest()
{
    DLog("-- start COPY test: ") << _testSrcDirLineEdit->text() << "|" << _testDestDirLineEdit->text();

    if(!PathHelper::copyWholeDirectory(_testSrcDirLineEdit->text(), _testDestDirLineEdit->text(), false, PathHelper::SHM_UseAsFile)) {
        WLog("Copy FAILED!");
    }
    else {
        DLog(" -> copy test SUCCESS!");
    }

    DLog(" -> end of COPY test");
}
bool AutoStartupDelegate::removeItFromAutoStartList() {
    bool isSucceeded = true;

    QString appwhirrWindowStartupFilePath = AppSpecificPathHelper::getWinAndWinUserSpecAppWhirrClientAutoStartupFilePath();
    if( QFile::exists(appwhirrWindowStartupFilePath) ) {
        if( QFile(appwhirrWindowStartupFilePath).remove() ) {
            DLog("Auto-startup file removed");
        }
        else {
            WLog("Auto-startup file found but cannot be removed");
            isSucceeded = false;
        }
    }

    return isSucceeded;
}
void Background_GrabSyncPerformer::run() {
    DLog("Background grab-sync started");
    LocalAppDatabaseManager *localAppDatabaseManager = GlobalObjectRegistry::sharedGlobalObjectRegistry()->getLocalAppDatabaseManager();
//    connect(this, SIGNAL(newAppGrabbedSignal(QString,QString,QString)), localAppDatabaseManager, SLOT(_addGrabbedApp(QString,QString,QString)));
//    localAppDatabaseManager->startBatchGrabApplicationAdd();

    int userGrabbedAppsSesultListCnt = _resultList.size();
    DLog("Grabbed list - count: ") << userGrabbedAppsSesultListCnt;
    for(int i = 0; i < userGrabbedAppsSesultListCnt; i++) {
        AW::Common::Communication::BaseNetworkEntity* currUserGrabbedAppEntity = _resultList[i];
        ApplicationBaseInfosNetworkEntity *currCastedUserGrabbedGrabEntity = dynamic_cast<ApplicationBaseInfosNetworkEntity *>(currUserGrabbedAppEntity);

        if(currCastedUserGrabbedGrabEntity == NULL) {
            WLog("Invalid communication entity - cannot cast it!");
        }

        else
        {
            QString appName = currCastedUserGrabbedGrabEntity->getApplicationName();
            QString appId = currCastedUserGrabbedGrabEntity->getApplicationID();
//            QString appSupportedPlatformFlags = PlatformFlagsHelper::_convertIntBasedFlagsToStringBased(currCastedUserGrabbedGrabEntity->getApplicationVersionSummedFlags());
            FLAG_FOR_REVIEW_WITH_HINT("After code revision: it's not a summed flag, it's just an OS flag indicator for the current OS (whether the current platform is supported or not)");
            QString appSupportedPlatformFlags = PlatformFlagsHelper::_convertIntBasedFlagsToStringBased(currCastedUserGrabbedGrabEntity->getApplicationVersionSummedFlags());

            QString appNewestVersionForThisPlatform = currCastedUserGrabbedGrabEntity->getApplicationVersion();
            DLogS << QString("Newest version of app (%1) (%2): %3").arg(appId).arg(appName).arg(appNewestVersionForThisPlatform);
//            DLogS << QString("Found user-grabbed app: %1 [with appId:%2]").arg(appName).arg(appId);

            AppWhirr::ApplicationStatusInStore::ApplicationStatusInStoreEnum appStatusInStore = currCastedUserGrabbedGrabEntity->getAppStatusInStore();
            DLog("App status in store: ") << appStatusInStore;

//            Q_EMIT newAppGrabbedSignal(appId, appName, appSupportedPlatformFlags);
            localAppDatabaseManager->addOrUpdateGrabbedApp(appId, appName, appSupportedPlatformFlags, appNewestVersionForThisPlatform, appStatusInStore);
        }
    }

//    localAppDatabaseManager->commitBatchGrabApplicationAdd();
//    disconnect(this, SIGNAL(newAppGrabbedSignal(QString,QString,QString)), localAppDatabaseManager, SLOT(_addGrabbedApp(QString,QString,QString)));
    DLog("Background grab-sync ended");

    Q_EMIT finished();
}
Example #29
0
runall_result test_feature()
{
	vector<accelerator> devices = get_available_devices(); // all but CPU devices

	runall_result result;
	for (size_t i = 0; i < devices.size(); i++)
	{
		accelerator& device = devices[i];

		WLog() << "Device " << i << ": " << device.description << " (" << device.device_path << ")" << std::endl;
		Log() << "  Version: " << device.get_version() << "; Memory: " << device.get_dedicated_memory() << std::endl;
		Log() << "  Debug: " << device.get_is_debug() << "; Emulated: " << device.get_is_emulated() << "; Has Display: " << device.get_has_display() << std::endl;

        result &= REPORT_RESULT((test_accl_staging_buffer_constructor<_type, _rank, accelerator_view>(device.default_view, device.default_view)));
        result &= REPORT_RESULT((test_accl_staging_buffer_constructor<_type, _rank, accelerator_view>(device.create_view(queuing_mode_immediate), device.create_view(queuing_mode_automatic))));
        result &= REPORT_RESULT((test_accl_staging_buffer_constructor<_type, _rank, accelerator_view>(device.create_view(queuing_mode_automatic), device.create_view(queuing_mode_immediate))));
		Log_writeline();
	}

	return result;
}
void StreamToFileManager::_chunkWriteToFileFailedWithError(QString errorMessage)
{
    WLog("Chunk write to file FAILED:") << _targetFilePath << "error:" << errorMessage;
    this->abortStreaming();
}