Ejemplo n.º 1
0
/*!
 * \brief Readds a Waiter that is set to repeat.
 * \param waiter The waiter to remove, as it has been copied.
 * \param title The title of the waiter to readd
 * \param datetime The time of the waiter to readd.
 * \param repeat The time to repeat.
 */
void WaiterDialog::repeatWaiter(WaiterWidget *waiter, QString title,
                                QDateTime datetime,
                                const WaiterCronOccurance &repeat)
{
  const auto oldDate = ui->EntryDate->selectedDate();
  const auto oldTime = ui->EntryTime->time();
  const auto oldText = ui->EventTitle->text();
  ui->EntryDate->setSelectedDate(datetime.date());
  ui->EntryTime->setTime(datetime.time());
  ui->EventTitle->setText(title);

  addWaiter(repeat);

  ui->EntryDate->setSelectedDate(oldDate);
  ui->EntryTime->setTime(oldTime);
  ui->EventTitle->setText(oldText);

  removeWaiter(waiter);
}
Ejemplo n.º 2
0
/*!
  Servers servicemanager first looks for a client to relay the message to. If none found then use the servers command chain
  to handle the service request.
*/
void TasServerServiceManager::handleServiceRequest(TasCommandModel& commandModel, TasSocket* requester, qint32 responseId)
{
    TasLogger::logger()->debug("TasServerServiceManager::handleServiceRequest: " + commandModel.service() + ": " + commandModel.id());
    TasClient* targetClient = 0;
    if (!commandModel.id().isEmpty() && commandModel.id() != "1"){
        bool ok;
        quint64 clientPid = commandModel.id().toULongLong(&ok);  
        targetClient = mClientManager->findByProcessId(clientPid);

        //no registered client check for platform specific handles for the process id
        if(!targetClient && extensionHandled(commandModel, requester, responseId)){            
            return;        
        }

        if(!targetClient){
            TasLogger::logger()->debug("TasServerServiceManager::handleServiceRequest: no target client send error...");
            TasResponse response(responseId);
            response.setIsError(true);
            response.setErrorMessage("The application with Id " + commandModel.id() + " is no longer available.");
            requester->sendMessage(response);
            return;
        }

    }

    if(!targetClient && (commandModel.service() == APPLICATION_STATE || commandModel.service() == SCREEN_SHOT 
                         || commandModel.service() == FIND_OBJECT_SERVICE)){
        targetClient = mClientManager->findClient(commandModel);
    }
    else if (commandModel.service() == RESOURCE_LOGGING_SERVICE){
        targetClient = mClientManager->logMemClient();
    }
    else{
    }

    if(targetClient){
        TasLogger::logger()->debug("TasServerServiceManager::handleServiceRequest client is: " + targetClient->processId() +
                                   "," + targetClient->applicationName());
        int timeout = 10000;
        if(!commandModel.parameter("plugin_timeout").isEmpty()){
            TasLogger::logger()->debug("TasServerServiceManager::handleServiceRequest set timeout " + commandModel.parameter("plugin_timeout"));
            timeout = commandModel.parameter("plugin_timeout").toInt();
        }

        ResponseWaiter* waiter = new ResponseWaiter(responseId, requester, timeout);
        if(commandModel.service() == CLOSE_APPLICATION){
            waiter->setResponseFilter(new CloseFilter(commandModel));        
        }
        connect(waiter, SIGNAL(responded(qint32)), this, SLOT(removeWaiter(qint32)));
        mResponseQueue.insert(responseId, waiter);
        if(commandModel.service() == APPLICATION_STATE || commandModel.service() == FIND_OBJECT_SERVICE){
            commandModel.addDomAttribute("needFragment", "true");
            //send request for qt uistate to client
            targetClient->socket()->sendRequest(responseId, commandModel.sourceString(false));                        
            //in the meantime process native
            getNativeUiState(responseId, commandModel);
        }
        else{
            //can respond as soon as response from qt side
            waiter->okToRespond();
            targetClient->socket()->sendRequest(responseId, commandModel.sourceString());            
        }
    }        
    else{
        handleClientLess(commandModel, requester, responseId);
    }
}