Beispiel #1
0
void CopyApp::doUpdate()
{
    static int partial = 0;
    if(partial == 0) {
        if(!checkPermissions(destination)) {
            startAsSudo();
            QApplication::quit();
            return;
        }
    }
    partial += 500;
    if(timeToWait != 0) {
        ui->progressBar->setValue(partial * 100 / timeToWait);
        if(partial < timeToWait) {
            QTimer::singleShot(500, this, SLOT(doUpdate()));
            return;
        }
    }
    emit currentOperation(tr("Looking for local file list info"));
    QStringList destinationFileList = processFileList(destination);
    emit currentOperation(tr("Looking for remote file list info"));
    QStringList remoteFileList = processFileList(origin);
    if(destinationFileList.isEmpty() || remoteFileList.isEmpty())
        return;
    emit currentOperation(tr("Deleting old files..."));
    bool result = true;
    result &= deleteFiles(destinationFileList, destination);
    emit currentOperation(tr("Copying new files..."));
    result &= copyFiles(remoteFileList, origin, destination);
    QString resultStr;
    if(result)
        resultStr = tr("Update finished successfully. ");
    else
        resultStr = tr("Update finished with errors. ");
    if(!appToRun.isEmpty())
        resultStr = resultStr + tr("Click ok to restart application");
    QMessageBox::information(this, tr("Update finished"), resultStr);
    if(!appToRun.isEmpty()) {
 #ifdef Q_OS_OSX
        QProcess::startDetached("open", QStringList() << QDir(destination).filePath(appToRun));
#else
        QProcess::startDetached(QDir(destination).filePath(appToRun));
#endif
    }
    QApplication::quit();
}
/**
 * Prints the desired results and actual view update results
 * @param aDesiredData  desired view update information
 * @param aActualData actual view update information
 */
void CContactViews::PrintDetailsL(TContactViewValidationData& aDesiredData, TContactViewValidationData& aActualData)
	{
	_LIT(KCurrentOperation, "The current CRUD operations being performed is ::::: %S \n");
	_LIT(KDesiredViewCount, "The desired view count %d \n");
	_LIT(KActualViewCount, "The actual view count is %d \n");
	_LIT(KDesiredViewUnAvailableNotifications, "The total number of desired view unavailable notifications are %d \n");
	_LIT(KActualViewUnAvailableNotifications,  "The total number of actual view unavailable notifications are %d \n");
	_LIT(KDesiredViewReadyNotifications, "The total number of desired view ready notifications are %d \n");
	_LIT(KActualViewReadyNotifications,  "The total number of actual view ready notifications are %d \n");
	_LIT(KDesiredViewSortOrderChangedNotifications, "The total number of desired view sort order changed notifications are %d \n");
	_LIT(KActualViewSortOrderChangedNotifications,  "The total number of actual view sort order changed notifications are %d \n");
	_LIT(KDesiredViewSortErrorNotifications, "The total number of desired View Sort ErrorNotifications are %d \n");
	_LIT(KActualViewSortErrorNotifications, "The total number of actual View Sort Error Notifications are %d \n");
	_LIT(KDesiredContactServerErrorNotifications, "The total number of desired Contact Server Error Notificationsare %d \n");
	_LIT(KActualContactServerErrorNotifications, "The total number of actual Contact Server Error Notifications are %d \n");
	_LIT(KDesiredViewIndexingErrorNotifications, "The total number of desired view indexing notifications are %d \n");
	_LIT(KActualViewIndexingErrorNotifications, "The total number of actual view indexing notifications are %d \n");
	_LIT(KDesiredItemAddedNotifications, "The total number of desired item added notifications are %d \n");
	_LIT(KActualItemAddedNotifications, "The total number of actual item added notifications are %d \n");
	_LIT(KDesiredItemRemovedNotifications, "The total number of desired item removed notifications are %d \n");
	_LIT(KActualItemRemovedNotifications, "The total number of actual item removed notifications are %d \n");
	_LIT(KDesiredGroupChangedNotifications, "The total number of desired group changed notifications are %d \n");
	_LIT(KActualGroupChangedNotifications, "The total number of actual group changed notifications are %d \n");

	TPtrC currentOperation(aDesiredData.CurrentOperationInfoInStringFormatL()); 
	TestStepReference().INFO_PRINTF2(KCurrentOperation, &currentOperation);

	TestStepReference().INFO_PRINTF2(KDesiredViewCount, aDesiredData.ViewCount());
	TestStepReference().INFO_PRINTF2(KActualViewCount, aActualData.ViewCount());

	TestStepReference().INFO_PRINTF2(KDesiredViewUnAvailableNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications));
	TestStepReference().INFO_PRINTF2(KActualViewUnAvailableNotifications, aActualData.NotificationsCount(TContactViewValidationData::EUnAvailableNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredViewReadyNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications));
	TestStepReference().INFO_PRINTF2(KActualViewReadyNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewReadyNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredViewSortOrderChangedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications));
	TestStepReference().INFO_PRINTF2(KActualViewSortOrderChangedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewSortOrderChangedNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredViewSortErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications));
	TestStepReference().INFO_PRINTF2(KActualViewSortErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewSortErrorNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredContactServerErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications));
	TestStepReference().INFO_PRINTF2(KActualContactServerErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EContactServerErrorNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredViewIndexingErrorNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications));
	TestStepReference().INFO_PRINTF2(KActualViewIndexingErrorNotifications, aActualData.NotificationsCount(TContactViewValidationData::EViewIndexingErrorNotifications));


	TestStepReference().INFO_PRINTF2(KDesiredItemAddedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications));
	TestStepReference().INFO_PRINTF2(KActualItemAddedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EItemAddedNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredItemRemovedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications));
	TestStepReference().INFO_PRINTF2(KActualItemRemovedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EItemRemovedNotifications));

	TestStepReference().INFO_PRINTF2(KDesiredGroupChangedNotifications, aDesiredData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications));
	TestStepReference().INFO_PRINTF2(KActualGroupChangedNotifications, aActualData.NotificationsCount(TContactViewValidationData::EGroupChangedNotifications));
	}
/**
* Adds contact cards and groups in the database
*/
void CTestContactViewCRUDOperationsStep::CreateContactItemsL()
	{
	_LIT(KAddContacts, "add");
	TBool addContacts = EFalse;
	GetBoolFromConfig(ConfigSection(), KAddContacts, addContacts);

	if(!addContacts)
		{
		return;
		}

	// Add contacts and groups in the main thread and validate the view count and view notifications
	// in the contact views thread
	TPtrC currentOperation(KAddContactOperations);
	SetCurrentOperation(currentOperation);
	AddContactEntriesL();
	CloseDatabaseL();
	OpenDataBaseL();
	ResumeContactViewsThreadL();
	}
/**
* Deletes contact items in the database
*/
void CTestContactViewCRUDOperationsStep::RemoveContactItemsL()
	{
	_LIT(KDeleteContacts, "delete");
	TBool deleteContacts = EFalse;
	GetBoolFromConfig(ConfigSection(), KDeleteContacts, deleteContacts);

	if(!deleteContacts)
		{
		return;
		}

	// Delete Contacts in the main thread and validate the view count and view notifications
	// in the contact views thread
	TPtrC currentOperation(KRemoveContactsOperations);
	SetCurrentOperation(currentOperation);
	DeleteContactCardsL();
	CloseDatabaseL();
	OpenDataBaseL();
	ResumeContactViewsThreadL();
	}