コード例 #1
0
void WriteThread::internalWrite()
{
    if(stopIt)
        return;
    //read one block
    if(theBlockList.size()<=0)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] End detected of the file");
        return;
    }
    else
    {
        QMutexLocker lock_mutex(&accessList);
        blockArray=theBlockList.first();
        theBlockList.removeFirst();
    }
    //write one block
    freeBlock.release();

    if(stopIt)
        return;
    #ifdef ULTRACOPIER_PLUGIN_DEBUG
    stat=Write;
    #endif
    bytesWriten=file.write(blockArray);
    #ifdef ULTRACOPIER_PLUGIN_DEBUG
    stat=Idle;
    #endif
    //mutex for stream this data
    if(CurentCopiedSize==0)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] emit writeIsStarted()");
        emit writeIsStarted();
    }
    CurentCopiedSize+=bytesWriten;
    if(stopIt)
        return;
    if(file.error()!=QFile::NoError)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Error in writing: %1 (%2)").arg(file.errorString()).arg(file.error()));
        errorString_internal=QString("Error in writing: %1 (%2)").arg(file.errorString()).arg(file.error());
        stopIt=true;
        emit error();
        return;
    }
    if(bytesWriten!=blockArray.size())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Error in writing, bytesWriten: %1, blockArray.size(): %2").arg(bytesWriten).arg(blockArray.size()));
        errorString_internal=QString("Error in writing, bytesWriten: %1, blockArray.size(): %2").arg(bytesWriten).arg(blockArray.size());
        stopIt=true;
        emit error();
        return;
    }
    lastGoodPosition+=bytesWriten;
}
コード例 #2
0
void SystrayIcon::reloadEngineList()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
    copyMenu->clear();
    if(engineEntryList.size()==0)
    {
        copyMenu->setEnabled(false);
        return;
    }
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"engineEntryList.size(): "+QString::number(engineEntryList.size()));
    copyMenu->setEnabled(true);
    if(engineEntryList.size()==1)
    {
        QAction *copy=new QAction(IconAdd,tr("Add &copy"),copyMenu);
        connect(copy,&QAction::triggered,this,&SystrayIcon::CatchCopyQuery);
        copy->setData(engineEntryList.first().name);
        copyMenu->addAction(copy);
        if(!engineEntryList.first().canDoOnlyCopy)
        {
            QAction *transfer=new QAction(IconAdd,tr("Add &transfer"),copyMenu);
            connect(transfer,&QAction::triggered,this,&SystrayIcon::CatchTransferQuery);
            transfer->setData(engineEntryList.first().name);
            copyMenu->addAction(transfer);
            QAction *move=new QAction(IconAdd,tr("Add &move"),copyMenu);
            connect(move,&QAction::triggered,this,&SystrayIcon::CatchMoveQuery);
            move->setData(engineEntryList.first().name);
            copyMenu->addAction(move);
        }
    }
    else
    {
        int index=0;
        while(index<engineEntryList.size())
        {
            QMenu * menu=new QMenu(engineEntryList.at(index).name);
            QAction *copy=new QAction(IconAdd,tr("Add &copy"),menu);
            connect(copy,&QAction::triggered,this,&SystrayIcon::CatchCopyQuery);
            copy->setData(engineEntryList.at(index).name);
            menu->addAction(copy);
            if(!engineEntryList.at(index).canDoOnlyCopy)
            {
                QAction *transfer=new QAction(IconAdd,tr("Add &transfer"),menu);
                connect(transfer,&QAction::triggered,this,&SystrayIcon::CatchTransferQuery);
                transfer->setData(engineEntryList.at(index).name);
                menu->addAction(transfer);
                QAction *move=new QAction(IconAdd,tr("Add &move"),menu);
                connect(move,&QAction::triggered,this,&SystrayIcon::CatchMoveQuery);
                move->setData(engineEntryList.at(index).name);
                menu->addAction(move);
            }
            copyMenu->addMenu(menu);
            index++;
        }
    }
}
コード例 #3
0
TransferModel::currentTransfertItem TransferModel::getCurrentTransfertItem()
{
    currentTransfertItem returnItem;
    returnItem.haveItem=startId.size()>0;
    if(returnItem.haveItem)
    {
        if(!internalRunningOperation.contains(*startId.constBegin()))
        {
            returnItem.haveItem=false;
            return returnItem;
        }
        const ItemOfCopyListWithMoreInformations &itemTransfer=internalRunningOperation[*startId.constBegin()];
        returnItem.from=itemTransfer.generalData.sourceFullPath;
        returnItem.to=itemTransfer.generalData.destinationFullPath;
        returnItem.current_file=itemTransfer.generalData.destinationFileName+", "+facilityEngine->sizeToString(itemTransfer.generalData.size);
        switch(itemTransfer.actionType)
        {
            case Ultracopier::CustomOperation:
            if(!itemTransfer.custom_with_progression)
                returnItem.progressBar_file=-1;
            else
            {
                if(itemTransfer.generalData.size>0)
                    returnItem.progressBar_file=((double)itemTransfer.currentProgression/itemTransfer.generalData.size)*65535;
                else
                    returnItem.progressBar_file=-1;
            }
            break;
            case Ultracopier::Transfer:
            if(itemTransfer.generalData.size>0)
                returnItem.progressBar_file=((double)itemTransfer.currentProgression/itemTransfer.generalData.size)*65535;
            else
                returnItem.progressBar_file=0;
            break;
            //should never pass here
            case Ultracopier::PostOperation:
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
                returnItem.progressBar_file=65535;
            break;
            //should never pass here
            case Ultracopier::PreOperation:
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("wrong action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
                returnItem.progressBar_file=0;
            break;
            default:
                returnItem.progressBar_file=0;
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("unknow action type for file %1: actionType: %2").arg(itemTransfer.generalData.id).arg(itemTransfer.actionType));
                break;
        }
    }
/*	else
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("No have running item"));*/
    return returnItem;
}
コード例 #4
0
ファイル: WriteThread.cpp プロジェクト: NotDead/Ultracopier
void WriteThread::postOperation()
{
    if(postOperationRequested)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("[")+QString::number(id)+QStringLiteral("] double event dropped"));
        return;
    }
    postOperationRequested=true;
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[")+QString::number(id)+QStringLiteral("] start"));
    emit internalStartClose();
}
コード例 #5
0
/* drag event processing

need setAcceptDrops(true); into the constructor
need implementation to accept the drop:
void dragEnterEvent(QDragEnterEvent* event);
void dragMoveEvent(QDragMoveEvent* event);
void dragLeaveEvent(QDragLeaveEvent* event);
*/
void Themes::dropEvent(QDropEvent *event)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
    const QMimeData* mimeData = event->mimeData();
    if(mimeData->hasUrls())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("hasUrls"));
        emit urlDropped(mimeData->urls());
        event->acceptProposedAction();
    }
}
コード例 #6
0
void Themes::dragEnterEvent(QDragEnterEvent* event)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
    // if some actions should not be usable, like move, this code must be adopted
    const QMimeData* mimeData = event->mimeData();
    if(mimeData->hasUrls())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("hasUrls"));
        event->acceptProposedAction();
    }
}
コード例 #7
0
/** \brief For catch an action on the systray icon
\param reason Why it activated
*/
void Themes::catchAction(QSystemTrayIcon::ActivationReason reason)
{
    if(reason==QSystemTrayIcon::DoubleClick || reason==QSystemTrayIcon::Trigger)
    {
        sysTrayIcon->hide();
        this->show();
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Double Click detected");
    }
    else
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,QStringLiteral("reason: %1").arg(reason));
}
コード例 #8
0
ファイル: WriteThread.cpp プロジェクト: dolanor/Ultracopier
void WriteThread::endIsDetected()
{
	if(endDetected)
	{
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"["+QString::number(id)+"] double event dropped");
		return;
	}
	endDetected=true;
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"["+QString::number(id)+"] start");
	emit internalStartEndOfFile();
}
コード例 #9
0
/// \brief To catch transfer menu action
void SystrayIcon::CatchTransferQuery()
{
    QAction * currentAction=qobject_cast<QAction *>(QObject::sender());
    if(currentAction==NULL)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"action not found");
        return;
    }
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+currentAction->data().toString());
    emit addWindowTransfer(currentAction->data().toString());
}
コード例 #10
0
ファイル: ReadThread.cpp プロジェクト: dsferruzza/Ultracopier
//reopen after an error
void ReadThread::reopen()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] start");
    if(isInReadLoop)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] try reopen where read is not finish");
        return;
    }
    stopIt=true;
    emit internalStartReopen();
}
コード例 #11
0
void WriteThread::postOperation()
{
    if(postOperationRequested)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"["+std::to_string(id)+"] double event dropped");
        return;
    }
    postOperationRequested=true;
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] start");
    emit internalStartClose();
}
コード例 #12
0
ファイル: factory.cpp プロジェクト: AutoRunWare/Ultracopier
QWidget * ThemesFactory::options()
{
    if(optionsEngine!=NULL)
    {
        bool ok;
        currentSpeed=optionsEngine->getOptionValue("currentSpeed").toUInt(&ok);
        if(!ok)
            currentSpeed=0;
        ui->comboBox_copyEnd->setCurrentIndex(optionsEngine->getOptionValue("comboBox_copyEnd").toUInt());
        ui->speedWithProgressBar->setChecked(optionsEngine->getOptionValue("speedWithProgressBar").toBool());
        ui->checkBoxShowSpeed->setChecked(optionsEngine->getOptionValue("checkBoxShowSpeed").toBool());
        ui->checkBoxStartWithMoreButtonPushed->setChecked(optionsEngine->getOptionValue("moreButtonPushed").toBool());
        ui->showDualProgression->setChecked(optionsEngine->getOptionValue("showDualProgression").toBool());
        ui->showProgressionInTheTitle->setChecked(optionsEngine->getOptionValue("showProgressionInTheTitle").toBool());
        ui->alwaysOnTop->setChecked(optionsEngine->getOptionValue("alwaysOnTop").toBool());
        ui->minimizeToSystray->setChecked(optionsEngine->getOptionValue("minimizeToSystray").toBool());

        progressColorWrite=optionsEngine->getOptionValue("progressColorWrite").value<QColor>();
        progressColorRead=optionsEngine->getOptionValue("progressColorRead").value<QColor>();
        progressColorRemaining=optionsEngine->getOptionValue("progressColorRemaining").value<QColor>();

        QPixmap pixmap(75,20);
        pixmap.fill(progressColorWrite);
        ui->progressColorWrite->setIcon(pixmap);
        pixmap.fill(progressColorRead);
        ui->progressColorRead->setIcon(pixmap);
        pixmap.fill(progressColorRemaining);
        ui->progressColorRemaining->setIcon(pixmap);
        updateSpeed();
        updateProgressionColorBar();

        connect(ui->alwaysOnTop,&QCheckBox::stateChanged,this,&ThemesFactory::alwaysOnTop);
        connect(ui->checkBoxShowSpeed,&QCheckBox::stateChanged,this,&ThemesFactory::checkBoxShowSpeed);
        connect(ui->minimizeToSystray,&QCheckBox::stateChanged,this,&ThemesFactory::minimizeToSystray);
        connect(ui->checkBox_limitSpeed,&QCheckBox::stateChanged,this,&ThemesFactory::uiUpdateSpeed);
        connect(ui->SliderSpeed,&QAbstractSlider::valueChanged,this,&ThemesFactory::on_SliderSpeed_valueChanged);
        connect(ui->limitSpeed,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),	this,	&ThemesFactory::uiUpdateSpeed);
        connect(ui->checkBoxShowSpeed,&QAbstractButton::toggled,this,&ThemesFactory::checkBoxShowSpeedHaveChanged);
        connect(ui->checkBoxStartWithMoreButtonPushed,&QAbstractButton::toggled,this,&ThemesFactory::checkBoxStartWithMoreButtonPushedHaveChanged);
        connect(ui->speedWithProgressBar,&QAbstractButton::toggled,this,&ThemesFactory::speedWithProgressBar);
        connect(ui->comboBox_copyEnd,	static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),		this,&ThemesFactory::comboBox_copyEnd);
        connect(ui->showDualProgression,&QCheckBox::stateChanged,this,&ThemesFactory::showDualProgression);
        connect(ui->showDualProgression,&QCheckBox::stateChanged,this,&ThemesFactory::updateProgressionColorBar);
        connect(ui->showProgressionInTheTitle,&QCheckBox::stateChanged,this,&ThemesFactory::setShowProgressionInTheTitle);
        connect(ui->progressColorWrite,&QAbstractButton::clicked,this,&ThemesFactory::progressColorWrite_clicked);
        connect(ui->progressColorRead,	&QAbstractButton::clicked,this,&ThemesFactory::progressColorRead_clicked);
        connect(ui->progressColorRemaining,&QAbstractButton::clicked,this,&ThemesFactory::progressColorRemaining_clicked);
    }
    else
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"internal error, crash prevented");
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"return the options");
    return tempWidget;
}
コード例 #13
0
/** \brief To get image into the current themes, or default if not found
\param filePath The file path to search, like toto.png resolved with the root of the current themes
\see currentStylePath */
QIcon ThemesManager::loadIcon(const QString &fileName)
{
    if(currentPluginIndex==-1)
        return QIcon();
    if(pluginList.at(currentPluginIndex).factory==NULL)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Try get icon when the factory is not loaded");
        return QIcon();
    }
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Send interface pixmap: "+fileName);
    return pluginList.at(currentPluginIndex).factory->getIcon(fileName);
}
コード例 #14
0
/// \brief Called when event loop is setup
void EventDispatcher::initFunction()
{
	if(core==NULL || copyEngineList==NULL)
	{
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"Unable to initialize correctly the software");
		return;
	}
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"Initialize the variable of event loop");
	connect(copyServer,	SIGNAL(newCopy(quint32,QStringList,QStringList)),			core,		SLOT(newCopy(quint32,QStringList,QStringList)));
	connect(copyServer,	SIGNAL(newCopy(quint32,QStringList,QStringList,QString,QString)),	core,		SLOT(newCopy(quint32,QStringList,QStringList,QString,QString)));
	connect(copyServer,	SIGNAL(newMove(quint32,QStringList,QStringList)),			core,		SLOT(newMove(quint32,QStringList,QStringList)));
	connect(copyServer,	SIGNAL(newMove(quint32,QStringList,QStringList,QString,QString)),	core,		SLOT(newMove(quint32,QStringList,QStringList,QString,QString)));
	connect(core,		SIGNAL(copyFinished(quint32,bool)),					copyServer,	SLOT(copyFinished(quint32,bool)));
	connect(core,		SIGNAL(copyCanceled(quint32)),						copyServer,	SLOT(copyCanceled(quint32)));
	if(localListener.tryConnect())
	{
		stopIt=true;
		//why before removed???
		QCoreApplication::quit();
		return;
	}
	localListener.listenServer();
	//load the systray icon
	if(backgroundIcon==NULL)
	{
		backgroundIcon=new SystrayIcon();
		//connect the slot
		//quit is for this object
//		connect(core,		SIGNAL(newCanDoOnlyCopy(bool)),					backgroundIcon,	SLOT(newCanDoOnlyCopy(bool)));
		connect(backgroundIcon,	SIGNAL(quit()),this,SLOT(quit()));
		//show option is for OptionEngine object
		connect(backgroundIcon,	SIGNAL(showOptions()),						&optionDialog,	SLOT(show()));
		connect(copyServer,	SIGNAL(listenerReady(ListeningState,bool,bool)),		backgroundIcon,	SLOT(listenerReady(ListeningState,bool,bool)));
		connect(copyServer,	SIGNAL(pluginLoaderReady(CatchState,bool,bool)),		backgroundIcon,	SLOT(pluginLoaderReady(CatchState,bool,bool)));
		connect(backgroundIcon,	SIGNAL(tryCatchCopy()),						copyServer,	SLOT(listen()));
		connect(backgroundIcon,	SIGNAL(tryUncatchCopy()),					copyServer,	SLOT(close()));
		if(options->getOptionValue("CopyListener","CatchCopyAsDefault").toBool())
			copyServer->listen();
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"copyServer.oneListenerIsLoaded(): "+QString::number(copyServer->oneListenerIsLoaded()));
		//backgroundIcon->readyToListen(copyServer.oneListenerIsLoaded());

		connect(backgroundIcon,	SIGNAL(addWindowCopyMove(CopyMode,QString)),				core,		SLOT(addWindowCopyMove(CopyMode,QString)));
		connect(backgroundIcon,	SIGNAL(addWindowTransfer(QString)),					core,		SLOT(addWindowTransfer(QString)));
		connect(copyEngineList,	SIGNAL(addCopyEngine(QString,bool)),					backgroundIcon,	SLOT(addCopyEngine(QString,bool)));
		connect(copyEngineList,	SIGNAL(removeCopyEngine(QString)),					backgroundIcon,	SLOT(removeCopyEngine(QString)));
		copyEngineList->setIsConnected();
		copyServer->resendState();
	}
	//conntect the last chance signal before quit
	connect(QCoreApplication::instance(),SIGNAL(aboutToQuit()),this,SLOT(quit()));
	//connect the slot for the help dialog
	connect(backgroundIcon,SIGNAL(showHelp()),&theHelp,SLOT(show()));
}
コード例 #15
0
ファイル: WriteThread.cpp プロジェクト: NotDead/Ultracopier
void WriteThread::flushBuffer()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[")+QString::number(id)+QStringLiteral("] start"));
    writeFull.release();
    writeFull.acquire();
    pauseMutex.release();
    {
        QMutexLocker lock_mutex(&accessList);
        theBlockList.clear();
    }
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[")+QString::number(id)+QStringLiteral("] stop"));
}
コード例 #16
0
ファイル: WriteThread.cpp プロジェクト: NotDead/Ultracopier
void WriteThread::endIsDetected()
{
    if(endDetected)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("[")+QString::number(id)+QStringLiteral("] double event dropped"));
        return;
    }
    endDetected=true;
    pauseMutex.release();
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[")+QString::number(id)+QStringLiteral("] start"));
    emit internalStartEndOfFile();
}
コード例 #17
0
ファイル: Core.cpp プロジェクト: blizzard4591/Ultracopier
void Core::newCopyWithoutDestination(const quint32 &orderId,const QStringList &protocolsUsedForTheSources,const QStringList &sources)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
    if(openNewCopyEngineInstance(Ultracopier::Copy,false,protocolsUsedForTheSources)==-1)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Unable to get a copy engine instance");
        QMessageBox::critical(NULL,tr("Error"),tr("Unable to get a copy engine instance"));
        return;
    }
    copyList.last().orderId<<orderId;
    copyList.last().engine->newCopy(sources);
    copyList.last().interface->haveExternalOrder();
}
コード例 #18
0
bool SessionLoader::getEnabled()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
    //return the value into the variable
    HKEY    ultracopier_regkey;
    bool temp=false;
    RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, 0, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, 0, &ultracopier_regkey, 0);
    DWORD kSize=254;
    if(RegQueryValueEx(ultracopier_regkey,TEXT("ultracopier"),NULL,NULL,(LPBYTE)0,&kSize) == ERROR_SUCCESS)
        temp=true;
    RegCloseKey(ultracopier_regkey);
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"return this value: "+QString::number(temp));
    return temp;
}
コード例 #19
0
void WriteThread::internalEndOfFile()
{
    if(!bufferIsEmpty())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] start the write");
        emit internalStartWrite();
    }
    else
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] writeIsStopped");
        flushBuffer();
        emit writeIsStopped();
    }
}
コード例 #20
0
ファイル: OptionEngine.cpp プロジェクト: dolanor/Ultracopier
/// \brief To add option group to options
bool OptionEngine::addOptionGroup(const QString &groupName,const QList<QPair<QString, QVariant> > &KeysList)
{
    ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start(\""+groupName+"\",[...])");
    //search if previous with the same name exists
    if(GroupKeysList.contains(groupName))
    {
        ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"group already used previously");
        return false;
    }
    //if the backend is file, enter into the group
    if(currentBackend==File)
        settings->beginGroup(groupName);
    //browse all key, and append it to the key
    index=0;
    QList<OptionEngineGroupKey> KeyListTemp;
    loop_size=KeysList.size();
    while(index<loop_size)
    {
        OptionEngineGroupKey theCurrentKey;
        theCurrentKey.defaultValue=KeysList.at(index).second;
        //if memory backend, load the default value into the current value
        if(currentBackend==Memory)
            theCurrentKey.currentValue=theCurrentKey.defaultValue;
        else
        {
            if(settings->contains(KeysList.at(index).first))//if file backend, load the default value from the file
                theCurrentKey.currentValue=settings->value(KeysList.at(index).first);
            else //or if not found load the default value and set into the file
            {
                theCurrentKey.currentValue=theCurrentKey.defaultValue;
                //to switch default value if is unchanged
                //settings->setValue(KeysList.at(index).first,theCurrentKey.defaultValue);
            }
            if(settings->status()!=QSettings::NoError)
            {
                ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Have writing error, switch to memory only options");
#ifdef ULTRACOPIER_VERSION_PORTABLE
                resources->disableWritablePath();
#endif // ULTRACOPIER_VERSION_PORTABLE
                currentBackend=Memory;
            }
        }
        GroupKeysList[groupName][KeysList.at(index).first]=theCurrentKey;
        index++;
    }
    //if the backend is file, leave into the group
    if(currentBackend==File)
        settings->endGroup();
    return true;
}
コード例 #21
0
/// \brief To get option value
QVariant OptionEngine::getOptionValue(const QString &groupName,const QString &variableName) const
{
    if(GroupKeysList.contains(groupName))
    {
        if(GroupKeysList.value(groupName).contains(variableName))
            return GroupKeysList.value(groupName).value(variableName).currentValue;
        QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(groupName).arg(variableName));
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"value not found, internal bug, groupName: "+groupName+", variableName: "+variableName);
        return QVariant();
    }
    QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(groupName).arg(variableName));
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QString("The variable was not found: %1 %2").arg(groupName).arg(variableName));
    //return default value
    return QVariant();
}
コード例 #22
0
bool MkPath::writeFileDateTime(const QFileInfo &destination)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"writeFileDateTime("+destination.absoluteFilePath()+")");
    /** Why not do it with Qt? Because it not support setModificationTime(), and get the time with Qt, that's mean use local time where in C is UTC time */
    #ifdef Q_OS_UNIX
        #ifdef Q_OS_LINUX
            return utime(destination.absoluteFilePath().toLatin1().data(),&butime)==0;
        #else //mainly for mac
            return utime(destination.absoluteFilePath().toLatin1().data(),&butime)==0;
        #endif
    #else
        #ifdef Q_OS_WIN32
            #ifdef ULTRACOPIER_PLUGIN_SET_TIME_UNIX_WAY
                return utime(destination.toLatin1().data(),&butime)==0;
            #else
                wchar_t filePath[65535];
                if(destination.absoluteFilePath().contains(regRead))
                    filePath[QDir::toNativeSeparators(QStringLiteral("\\\\?\\")+destination.absoluteFilePath()).toWCharArray(filePath)]=L'\0';
                else
                    filePath[QDir::toNativeSeparators(destination.absoluteFilePath()).toWCharArray(filePath)]=L'\0';
                HANDLE hFileDestination = CreateFileW(filePath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
                if(hFileDestination == INVALID_HANDLE_VALUE)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"open failed to write: "+QString::fromWCharArray(filePath)+", error: "+QString::number(GetLastError()));
                    return false;
                }
                FILETIME ftCreate, ftAccess, ftWrite;
                ftCreate.dwLowDateTime=this->ftCreateL;
                ftCreate.dwHighDateTime=this->ftCreateH;
                ftAccess.dwLowDateTime=this->ftAccessL;
                ftAccess.dwHighDateTime=this->ftAccessH;
                ftWrite.dwLowDateTime=this->ftWriteL;
                ftWrite.dwHighDateTime=this->ftWriteH;
                if(!SetFileTime(hFileDestination, &ftCreate, &ftAccess, &ftWrite))
                {
                    CloseHandle(hFileDestination);
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to set the file time");
                    return false;
                }
                CloseHandle(hFileDestination);
                return true;
            #endif
        #else
            return false;
        #endif
    #endif
    return false;
}
コード例 #23
0
void InternetUpdater::httpFinished()
{
    QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    if (!reply->isFinished())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("get the new update failed: not finished"));
        reply->deleteLater();
        return;
    }
    else if (reply->error())
    {
        newUpdateTimer.stop();
        newUpdateTimer.start(1000*3600*24);
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("get the new update failed: %1").arg(reply->errorString()));
        reply->deleteLater();
        return;
    } else if (!redirectionTarget.isNull()) {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("redirection denied to: %1").arg(redirectionTarget.toUrl().toString()));
        reply->deleteLater();
        return;
    }
    const QString &newVersion=QString::fromUtf8(reply->readAll());
    if(newVersion.isEmpty())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("version string is empty"));
        reply->deleteLater();
        return;
    }
    if(!newVersion.contains(QRegularExpression(QLatin1Literal("^[0-9]+(\\.[0-9]+)+$"))))
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("version string don't match: %1").arg(newVersion));
        reply->deleteLater();
        return;
    }
    if(newVersion==ULTRACOPIER_VERSION)
    {
        reply->deleteLater();
        return;
    }
    if(PluginsManager::compareVersion(newVersion,QStringLiteral("<="),ULTRACOPIER_VERSION))
    {
        reply->deleteLater();
        return;
    }
    newUpdateTimer.stop();
    emit newUpdate(newVersion);
    reply->deleteLater();
}
コード例 #24
0
QString PluginInformation::categoryToTranslation(const PluginType &category) const
{
    switch(category)
    {
        case PluginType_CopyEngine:
            return tr("Copy engine");
        break;
        case PluginType_Languages:
            return tr("Languages");
        break;
        case PluginType_Listener:
            return tr("Listener");
        break;
        case PluginType_PluginLoader:
            return tr("Plugin loader");
        break;
        case PluginType_SessionLoader:
            return tr("Session loader");
        break;
        case PluginType_Themes:
            return tr("Themes");
        break;
        default:
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"cat translation not found");
            return "Unknow";
        break;
    }
}
コード例 #25
0
/// \brief get translated text
QString PluginInformation::getTranslatedText(const PluginsAvailable &plugin,const QString &informationName,const QString &mainShortName)
{
    int index=0;
    QString TextFound;
    while(index<plugin.informations.size())
    {
        if(plugin.informations.at(index).size()==3)
        {
            if(plugin.informations.at(index).first()==informationName)
            {
                if(plugin.informations.at(index).at(1)==mainShortName)
                    return plugin.informations.at(index).last();
                else if(plugin.informations.at(index).at(1)=="en")
                    TextFound=plugin.informations.at(index).last();

            }
        }
        index++;
    }
    #ifdef ULTRACOPIER_DEBUG
    if(TextFound.isEmpty() || TextFound.isEmpty())
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"text is not found or empty for: "+informationName+", with the language: "+mainShortName+", for the plugin: "+plugin.path);
    #endif // ULTRACOPIER_DEBUG
    return TextFound;
}
コード例 #26
0
bool ProductKey::parseKey(QString orgkey)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"ultimate key");
    QString key=orgkey;
    if(orgkey.isEmpty())
        key=QString::fromStdString(OptionEngine::optionEngine->getOptionValue("Ultracopier","key"));
    if(!key.isEmpty())
    {
        QCryptographicHash hash(QCryptographicHash::Sha224);
        hash.addData(QStringLiteral("U2NgvbKVrVwlaXnx").toUtf8());
        hash.addData(key.toUtf8());
        const QByteArray &result=hash.result();
        if(!result.isEmpty() && result.at(0)==0x00 && result.at(1)==0x00)
        {
            if(!orgkey.isEmpty())
            OptionEngine::optionEngine->setOptionValue("Ultracopier","key",key.toStdString());
            ultimate=true;
        }
        else
            ultimate=false;
    }
    else
        ultimate=false;
    return ultimate;
}
コード例 #27
0
void MkPath::addPath(const QFileInfo& source, const QFileInfo& destination, const ActionType &actionType)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()));
    if(stopIt)
        return;
    emit internalStartAddPath(source,destination,actionType);
}
コード例 #28
0
void CopyListener::onePluginWillBeRemoved(const PluginsAvailable &plugin)
{
    if(plugin.category!=PluginType_Listener)
        return;
    int indexPlugin=0;
    while(indexPlugin<pluginList.size())
    {
        if((plugin.path+PluginsManager::getResolvedPluginName("listener"))==pluginList.at(indexPlugin).path)
        {
            int index=0;
            while(index<copyRunningList.size())
            {
                if(copyRunningList.at(index).listenInterface==pluginList.at(indexPlugin).listenInterface)
                    copyRunningList[index].listenInterface=NULL;
                index++;
            }
            if(pluginList.at(indexPlugin).listenInterface!=NULL)
            {
                pluginList.at(indexPlugin).listenInterface->close();
                delete pluginList.at(indexPlugin).listenInterface;
            }
            if(pluginList.at(indexPlugin).pluginLoader!=NULL)
            {
                pluginList.at(indexPlugin).pluginLoader->unload();
                delete pluginList.at(indexPlugin).options;
            }
            pluginList.removeAt(indexPlugin);
            sendState();
            return;
        }
        indexPlugin++;
    }
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"not found");
}
コード例 #29
0
void ThemesManager::newOptionValue(const QString &group,const QString &name,const QVariant &value)
{
    if(group=="Themes" && name=="Ultracopier_current_theme")
    {
        if(!PluginsManager::pluginsManager->allPluginHaveBeenLoaded())
            return;
        if(currentPluginIndex!=-1 && value.toString()!=pluginList.at(currentPluginIndex).plugin.name)
        {
            //int tempCurrentPluginIndex=currentPluginIndex;
            emit theThemeNeedBeUnloaded();
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("unload the themes: %1 (%2)").arg(pluginList.at(currentPluginIndex).plugin.name).arg(currentPluginIndex));
            /* Themes remain loaded for the options
             *if(pluginList.at(tempCurrentPluginIndex).options!=NULL)
            {
                delete pluginList.at(tempCurrentPluginIndex).options;
                pluginList[tempCurrentPluginIndex].options=NULL;
            }
            if(pluginList.at(tempCurrentPluginIndex).factory!=NULL)
            {
                delete pluginList.at(tempCurrentPluginIndex).factory;
                pluginList[tempCurrentPluginIndex].factory=NULL;
            }
            if(pluginList.at(tempCurrentPluginIndex).pluginLoader!=NULL)
            {
                pluginList.at(tempCurrentPluginIndex).pluginLoader->unload();
                delete pluginList.at(tempCurrentPluginIndex).pluginLoader;
                pluginList[tempCurrentPluginIndex].pluginLoader=NULL;
            } */
        }
        allPluginIsLoaded();
        //emit theThemeIsReloaded(); -> do into allPluginIsLoaded(); now
    }
}
コード例 #30
0
/// \brief Create the manager and load the defaults variables
ThemesManager::ThemesManager()
{
    //load the debug engine as external part because ThemesManager is base class
    stopIt=false;
    currentPluginIndex=-1;

    //connect the plugin management
    PluginsManager::pluginsManager->lockPluginListEdition();
    connect(this,   &ThemesManager::previouslyPluginAdded,			this,&ThemesManager::onePluginAdded,Qt::QueuedConnection);
    connect(PluginsManager::pluginsManager,&PluginsManager::onePluginAdded,			this,&ThemesManager::onePluginAdded,Qt::QueuedConnection);
    #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE
    connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved,		this,&ThemesManager::onePluginWillBeRemoved,Qt::DirectConnection);
    connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeUnloaded,		this,&ThemesManager::onePluginWillBeRemoved,Qt::DirectConnection);
    #endif
    connect(PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish,			this,&ThemesManager::allPluginIsLoaded,Qt::QueuedConnection);
    QList<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_Themes);
    foreach(PluginsAvailable currentPlugin,list)
        emit previouslyPluginAdded(currentPlugin);
    PluginsManager::pluginsManager->unlockPluginListEdition();

    //do the options
    QList<QPair<QString, QVariant> > KeysList;
    KeysList.append(qMakePair(QString("Ultracopier_current_theme"),QVariant(ULTRACOPIER_DEFAULT_STYLE)));
    OptionEngine::optionEngine->addOptionGroup("Themes",KeysList);

    //load the default and current themes path
    defaultStylePath=":/Themes/"+QString(ULTRACOPIER_DEFAULT_STYLE)+"/";
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Default style: "+defaultStylePath);
    currentStylePath=defaultStylePath;
    connect(OptionEngine::optionEngine,            &OptionEngine::newOptionValue,	this,		&ThemesManager::newOptionValue,Qt::QueuedConnection);
    connect(LanguagesManager::languagesManager,	&LanguagesManager::newLanguageLoaded,		&facilityEngine,&FacilityEngine::retranslate,Qt::QueuedConnection);
}