⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafprocessservice.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        // Construct map class for returned file information    fReturnFileMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/ReturnFileInfo");    fReturnFileMapClass->addKey("rc",   "Return Code");    fReturnFileMapClass->addKey("data", "Data");    // Construct map class for querying process information    fProcessInfoMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/ProcessInfo");    fProcessInfoMapClass->addKey("handle",         "Handle");    fProcessInfoMapClass->addKey("handleName",     "Handle Name");    fProcessInfoMapClass->addKey("title",          "Title");    fProcessInfoMapClass->addKey("workload",       "Workload");    fProcessInfoMapClass->addKey("shell",          "Shell");    fProcessInfoMapClass->addKey("command",        "Command");    fProcessInfoMapClass->addKey("parms",          "Parms");    fProcessInfoMapClass->addKey("workdir",        "Workdir");    fProcessInfoMapClass->addKey("focus",          "Focus");    fProcessInfoMapClass->addKey("userName",       "User Name");    fProcessInfoMapClass->addKey("key",            "Key");    fProcessInfoMapClass->addKey("pid",            "PID");    fProcessInfoMapClass->addKey("startMode",      "Start Mode");    fProcessInfoMapClass->addKey("startTimestamp", "Start Date-Time");    fProcessInfoMapClass->addKey("endTimestamp",   "End Date-Time");    fProcessInfoMapClass->addKey("rc",             "Return Code");    // Construct map class for listing processes information    fListProcessMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/ProcessListInfo");    fListProcessMapClass->addKey("handle", "Handle");    fListProcessMapClass->setKeyProperty(        "handle", "display-short-name", "H#");    fListProcessMapClass->addKey("command", "Command");    fListProcessMapClass->addKey("startTimestamp", "Start Date-Time");    fListProcessMapClass->setKeyProperty(        "startTimestamp", "display-short-name", "Start D-T");    fListProcessMapClass->addKey("endTimestamp", "End Date-Time");    fListProcessMapClass->setKeyProperty(        "endTimestamp", "display-short-name", "End D-T");    fListProcessMapClass->addKey("rc", "Return Code");    fListProcessMapClass->setKeyProperty(        "rc", "display-short-name", "RC");    // Construct map class for listing processes information    fListLongProcessMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/ProcessListLong");    fListLongProcessMapClass->addKey("handle", "Handle");    fListLongProcessMapClass->setKeyProperty(        "handle", "display-short-name", "H#");    fListLongProcessMapClass->addKey("workload", "Workload");    fListLongProcessMapClass->addKey("command", "Command");    fListLongProcessMapClass->addKey("pid", "PID");    fListLongProcessMapClass->addKey("startTimestamp", "Start Date-Time");    fListLongProcessMapClass->setKeyProperty(        "startTimestamp", "display-short-name", "Start D-T");    fListLongProcessMapClass->addKey("endTimestamp", "End Date-Time");    fListLongProcessMapClass->setKeyProperty(        "endTimestamp", "display-short-name", "End D-T");    fListLongProcessMapClass->addKey("rc", "Return Code");    fListLongProcessMapClass->setKeyProperty(        "rc", "display-short-name", "RC");    // Construct map class for listing operational settings information    fSettingsMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/Settings");    fSettingsMapClass->addKey("defaultStopUsing", "Default Stop Using Method");    fSettingsMapClass->addKey("defaultConsoleMode", "Default Console Mode");    fSettingsMapClass->addKey("defaultFocus", "Default Focus");    fSettingsMapClass->addKey("processAuthMode", "Process Auth Mode");    fSettingsMapClass->addKey("defaultAuthUsername", "Default Auth Username");    fSettingsMapClass->addKey("defaultAuthPassword", "Default Auth Password");    fSettingsMapClass->addKey("defaultAuthDisabledAction",                               "Default Auth Disabled Action");    fSettingsMapClass->addKey("defaultShell", "Default Shell");    fSettingsMapClass->addKey("defaultNewConsoleShell",                              "Default New Console Shell");    fSettingsMapClass->addKey("defaultSameConsoleShell",                              "Default Same Console Shell");    // Construct map class for freed process information    fFreeMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/FreeInfo");    fFreeMapClass->addKey("freedProcesses", "Freed Processes");    fFreeMapClass->addKey("totalProcesses", "Total Processes");        // Construct map class for stopped process information    fStopMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/StopInfo");    fStopMapClass->addKey("stoppedProcesses", "Stopped Processes");    fStopMapClass->addKey("totalProcesses",   "Total Processes");    // Construct map class for notify list information    fNotifieeMapClass = STAFMapClassDefinition::create(        "STAF/Service/Process/Notifiee");    fNotifieeMapClass->addKey("priority",   "Priority");    fNotifieeMapClass->setKeyProperty("priority", "display-short-name", "P");    fNotifieeMapClass->addKey("machine",    "Machine");    fNotifieeMapClass->addKey("notifyBy",   "Notify By");    fNotifieeMapClass->addKey("notifiee",   "Notifiee");    // Set the default stop method and the environment variable case    // sensitive flag    STAFConfigInfo configInfo;    STAFString_t errorBufferT = 0;    unsigned int osRC = 0;    if (STAFUtilGetConfigInfo(&configInfo, &errorBufferT, &osRC) != kSTAFOk)    {        STAFString errorMsg = STAFString(errorBufferT, STAFString::kShallow) +            ", RC: " + STAFString(osRC);        STAFTrace::trace(            kSTAFTraceError, errorMsg.toCurrentCodePage()->buffer());    }    else    {        STAFProcessService::fDefaultStopMethod =            configInfo.defaultProcessStopMethod;        STAFProcessService::fEnvVarCaseSensitive =            configInfo.envVarCaseSensitive;    }    // Set the temporary directory used for storing temporary stdout/stderr    // files when starting a process if RETURNSTDOUT/RETURNSTDERR option is    // specified, but not a STDOUT/STDERR option    STAFProcessService::setTempDirectory(        *gSTAFWriteLocationPtr + *gFileSeparatorPtr + "tmp");}STAFProcessService::~STAFProcessService(){    /* Do Nothing */}STAFString STAFProcessService::info(unsigned int) const{    return name() + ": Internal";}void STAFProcessService::processTerminationCallback(         STAFProcessID_t pid, STAFProcessHandle_t procHandle,         unsigned int retCode, void *){    processService->handleProcessTermination(pid, retCode);}unsigned int STAFProcessService::sendNotificationCallback(void *){    try    {        processService->sendNotification();    }    catch (STAFException &se)    {        se.trace("STAFProcessService::sendNotificationCallback()");    }    catch (...)    {        STAFTrace::trace(            kSTAFTraceError,            "Caught unknown exception in "            "STAFProcessService::sendNotificationCallback()");    }    return 0;}STAFString STAFProcessService::getTempDirectory(){    return fTempDirectory;}STAFRC_t STAFProcessService::setTempDirectory(const STAFString &tempDirectory){    // Get exclusive access to fTempDirectory    STAFMutexSemLock lock(sTempDirectorySem);    fTempDirectory = tempDirectory;    return kSTAFOk;}STAFRC_t STAFProcessService::getStopMethodFromString(    STAFProcessStopMethod_t &stopMethod,    const STAFString &methodString){    static STAFString sSigKill("SIGKILL");    static STAFString sSigKillAll("SIGKILLALL");    static STAFString sSigTerm("SIGTERM");    static STAFString sSigInt("SIGINT");    static STAFString sWM_CLOSE("WM_CLOSE");    STAFString upperMode = methodString.toUpperCase();    if (upperMode == sSigKill)        stopMethod = kSTAFProcessStopWithSigKill;    else if (upperMode == sSigKillAll)        stopMethod = kSTAFProcessStopWithSigKillAll;    else if (upperMode == sSigTerm)        stopMethod = kSTAFProcessStopWithSigTerm;    else if (upperMode == sSigInt)        stopMethod = kSTAFProcessStopWithSigInt;    else if (upperMode == sWM_CLOSE)        stopMethod = kSTAFProcessStopWithWM_CLOSE;    else return kSTAFInvalidValue;    return kSTAFOk;}STAFRC_t STAFProcessService::setDefaultStopMethod(    STAFProcessStopMethod_t stopMethod){    if (STAFProcess::isValidStopMethod(stopMethod) != kSTAFOk)        return kSTAFInvalidValue;    // Get exclusive access to fDefaultStopMethod    STAFMutexSemLock lock(sDefaultStopUsingSem);    fDefaultStopMethod = stopMethod;    return kSTAFOk;}STAFProcessStopMethod_t STAFProcessService::getDefaultStopMethod(){    return fDefaultStopMethod;}STAFString STAFProcessService::getDefaultStopMethodAsString(){    static STAFString sSigKill("SigKill");    static STAFString sSigKillAll("SigKillAll");    static STAFString sSigTerm("SigTerm");    static STAFString sSigInt("SigInt");    static STAFString sWM_CLOSE("WM_Close");    STAFString stopMethodString;        if (fDefaultStopMethod == kSTAFProcessStopWithSigKill)        return sSigKill;    else if (fDefaultStopMethod == kSTAFProcessStopWithSigKillAll)        return sSigKillAll;    else if (fDefaultStopMethod == kSTAFProcessStopWithSigTerm)        return sSigTerm;    else if (fDefaultStopMethod == kSTAFProcessStopWithSigInt)        return sSigInt;    else // fDefaultStopMethod == kSTAFProcessStopWithWM_CLOSE        return sWM_CLOSE;    return kSTAFOk;}STAFRC_t STAFProcessService::getConsoleFocusFromString(    STAFProcessConsoleFocus_t &consoleFocus,    const STAFString &focusString){    static STAFString sBackground("BACKGROUND");    static STAFString sForeground("FOREGROUND");    static STAFString sMinimized("MINIMIZED");    STAFString upperFocus = focusString.toUpperCase();    if (upperFocus == sBackground)        consoleFocus = kSTAFProcessBackground;    else if (upperFocus == sForeground)        consoleFocus = kSTAFProcessForeground;    else if (upperFocus == sMinimized)        consoleFocus = kSTAFProcessMinimized;    else return kSTAFInvalidValue;    return kSTAFOk;}STAFRC_t STAFProcessService::setDefaultConsoleFocus(    STAFProcessConsoleFocus_t consoleFocus){    // Get exclusive access to fDefaultConsoleFocus    STAFMutexSemLock lock(sDefaultConsoleFocusSem);    fDefaultConsoleFocus = consoleFocus;    return kSTAFOk;}STAFProcessConsoleFocus_t STAFProcessService::getDefaultConsoleFocus(){    return fDefaultConsoleFocus;}STAFString STAFProcessService::getDefaultConsoleFocusAsString(){    return getConsoleFocusAsString(fDefaultConsoleFocus);}STAFString STAFProcessService::getConsoleFocusAsString(    STAFProcessConsoleFocus_t consoleFocus){    static STAFString sBackground("Background");    static STAFString sForeground("Foreground");    static STAFString sMinimized("Minimized");        if (consoleFocus == kSTAFProcessBackground)        return sBackground;    else if (consoleFocus == kSTAFProcessForeground)        return sForeground;    else // consoleFocus == kSTAFProcessMinimized        return sMinimized;}STAFRC_t STAFProcessService::getAuthModeFromString(    STAFProcessAuthenticationMode_t &authMode, const STAFString &modeString){    static STAFString sDisabled("DISABLED");    static STAFString sNone("NONE");    static STAFString sWindows("WINDOWS");    STAFString upperMode = modeString.toUpperCase();    if      (upperMode == sDisabled) authMode = kSTAFProcessAuthDisabled;    else if (upperMode == sNone)     authMode = kSTAFProcessAuthNone;    else if (upperMode == sWindows)  authMode = kSTAFProcessAuthWindows;    else return kSTAFInvalidValue;    return kSTAFOk;}STAFRC_t STAFProcessService::setAuthMode(    STAFProcessAuthenticationMode_t authMode, unsigned int &osRC){    if (STAFProcess::isValidAuthMode(authMode) != kSTAFOk)        return kSTAFInvalidValue;    // Get exclusive access to fAuthMode    STAFMutexSemLock lock(sProcessAuthModeSem);    fAuthMode = authMode;    return kSTAFOk;}STAFProcessAuthenticationMode_t STAFProcessService::getAuthMode(){    return fAuthMode;}STAFString STAFProcessService::getAuthModeAsString(){    static STAFString sDisabled("Disabled");    static STAFString sNone("None");    static STAFString sWindows("Windows");    if (fAuthMode == kSTAFProcessAuthDisabled)        return sDisabled;    else if (fAuthMode == kSTAFProcessAuthNone)        return sNone;    else // fAuthMode == kSTAFProcesAuthWindows        return sWindows;}STAFRC_t STAFProcessService::getDefaultDisabledAuthActionFromString(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -