bool ShellCommandService::executeService(TasCommandModel& model, TasResponse& response)
{
    if(model.service() == serviceName() ){
        TasCommand* command = getCommandParameters(model, "shellCommand");
        if(command && !command->text().isEmpty()){
            if (command->parameter("detached") == "true"){
                detachedShellCommand(command->text(), response);
            }
            else if (command->parameter("threaded") == "true") {
                shellTask(command->text(), response);
            }
            else if (command->parameter("status") == "true") {
                TasCommand* command = getCommandParameters(model, "shellCommand");
                if(command && !command->text().isEmpty()){
                    qint64 pid = command->text().toInt();
                    if (command->parameter("kill") == "true") {
                        killTask(pid, response);
                    } else {
                        shellStatus(pid, response);
                    }
                }
            }
            else{
                shellCommand(command->text(), response);
            }
        }
        else{
            response.setErrorMessage(NO_COMMAND_TO_EXECUTE);
        }
        return true;
    }
    else{
        return false;
    }
}
Ejemplo n.º 2
0
bool RegisterService::executeService(TasCommandModel& model, TasResponse& response)
{
    if(model.service() == serviceName() ){
        TasCommand* command = getCommandParameters(model, COMMAND_REGISTER);
        if(command){
            ClientDetails client;
            bool ok;
            //this should not really ever fail (app pid used to generate in client side)
            quint64 clientPid = command->parameter(PLUGIN_ID).toULongLong(&ok); 
            client.processId = clientPid;
            client.processName = command->parameter(PLUGIN_NAME);
#ifdef Q_OS_SYMBIAN
            client.applicationUid = command->parameter(APP_UID);
#endif
            client.pluginType = command->parameter(PLUGIN_TYPE);
            client.socket = response.requester();
            registerPlugin(client);
        }
        else{
            command = getCommandParameters(model, COMMAND_UNREGISTER);
            if(command){
                unRegisterPlugin(*command);
            }
        }
        return true;
    }
    else{
        return false;
    }
}
bool ObjectService::executeService(TasCommandModel& model, TasResponse& response)
{
    if(model.service() == serviceName() ){
        performObjectService(model, response);
        return true;
    }
    else{
        return false;
    }
}
/*!
  Passes service directed to plugins on to the correct plugin.
 */
bool InfoService::executeService(TasCommandModel& model, TasResponse& response)
{
    if(model.service() == serviceName() ){
        mLogger->performLogService(model, response);   
        return true;
    }    
    else{
        return false;
    }
}
bool ScreenshotService::executeService(TasCommandModel& model, TasResponse& response)
{
    if(model.service() == serviceName() ){
        TasLogger::logger()->debug("ScreenshotService::executeService in");
        QGuiApplication *app = qobject_cast<QGuiApplication*>(qApp);
        if(app){
            getScreenshot(model, response);
        }
        else{
            TasLogger::logger()->debug("ScreenshotService::executeService application has no ui!");
            response.setErrorMessage(NO_UI_ERROR);
        }
        return true;
    }
    else{
        return false;
    }
}
Ejemplo n.º 6
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);
    }
}