void XBPyThread::Process() { CLog::Log(LOGDEBUG,"Python thread: start processing"); int m_Py_file_input = Py_file_input; // get the global lock PyEval_AcquireLock(); PyThreadState* state = Py_NewInterpreter(); if (!state) { PyEval_ReleaseLock(); CLog::Log(LOGERROR,"Python thread: FAILED to get thread state!"); return; } // swap in my thread state PyThreadState_Swap(state); m_pExecuter->InitializeInterpreter(addon); CLog::Log(LOGDEBUG, "%s - The source file to load is %s", __FUNCTION__, m_source); // get path from script file name and add python path's // this is used for python so it will search modules from script path first CStdString scriptDir; URIUtils::GetDirectory(_P(m_source), scriptDir); URIUtils::RemoveSlashAtEnd(scriptDir); CStdString path = scriptDir; // add on any addon modules the user has installed ADDON::VECADDONS addons; ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons); for (unsigned int i = 0; i < addons.size(); ++i) #ifdef TARGET_WINDOWS { CStdString strTmp(_P(addons[i]->LibPath())); g_charsetConverter.utf8ToStringCharset(strTmp); path += PY_PATH_SEP + strTmp; } #else path += PY_PATH_SEP + _P(addons[i]->LibPath()); #endif // and add on whatever our default path is path += PY_PATH_SEP; // we want to use sys.path so it includes site-packages // if this fails, default to using Py_GetPath PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete if( pathObj && PyList_Check(pathObj) ) { for( int i = 0; i < PyList_Size(pathObj); i++ ) { PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete if( e && PyString_Check(e) ) { path += PyString_AsString(e); // returns internal data, don't delete or modify path += PY_PATH_SEP; } } } else { path += Py_GetPath(); } Py_DECREF(sysMod); // release ref to sysMod // set current directory and python's path. if (m_argv != NULL) PySys_SetArgv(m_argc, m_argv); CLog::Log(LOGDEBUG, "%s - Setting the Python path to %s", __FUNCTION__, path.c_str()); PySys_SetPath((char *)path.c_str()); CLog::Log(LOGDEBUG, "%s - Entering source directory %s", __FUNCTION__, scriptDir.c_str()); PyObject* module = PyImport_AddModule((char*)"__main__"); PyObject* moduleDict = PyModule_GetDict(module); // when we are done initing we store thread state so we can be aborted PyThreadState_Swap(NULL); PyEval_ReleaseLock(); // we need to check if we was asked to abort before we had inited bool stopping = false; { CSingleLock lock(m_pExecuter->m_critSection); m_threadState = state; stopping = m_stopping; } PyEval_AcquireLock(); PyThreadState_Swap(state); if (!stopping) { if (m_type == 'F') { // run script from file // We need to have python open the file because on Windows the DLL that python // is linked against may not be the DLL that xbmc is linked against so // passing a FILE* to python from an fopen has the potential to crash. PyObject* file = PyFile_FromString((char *) _P(m_source).c_str(), (char*)"r"); FILE *fp = PyFile_AsFile(file); if (fp) { PyObject *f = PyString_FromString(_P(m_source).c_str()); PyDict_SetItemString(moduleDict, "__file__", f); if (addon.get() != NULL) { PyObject *pyaddonid = PyString_FromString(addon->ID().c_str()); PyDict_SetItemString(moduleDict, "__xbmcaddonid__", pyaddonid); CStdString version = ADDON::GetXbmcApiVersionDependency(addon); PyObject *pyxbmcapiversion = PyString_FromString(version.c_str()); PyDict_SetItemString(moduleDict, "__xbmcapiversion__", pyxbmcapiversion); CLog::Log(LOGDEBUG,"Instantiating addon using automatically obtained id of \"%s\" dependent on version %s of the xbmc.python api",addon->ID().c_str(),version.c_str()); } Py_DECREF(f); PyRun_FileExFlags(fp, _P(m_source).c_str(), m_Py_file_input, moduleDict, moduleDict,1,NULL); } else CLog::Log(LOGERROR, "%s not found!", m_source); } else { //run script PyRun_String(m_source, m_Py_file_input, moduleDict, moduleDict); } } if (!PyErr_Occurred()) CLog::Log(LOGINFO, "Scriptresult: Success"); else if (PyErr_ExceptionMatches(PyExc_SystemExit)) CLog::Log(LOGINFO, "Scriptresult: Aborted"); else { PyObject* exc_type; PyObject* exc_value; PyObject* exc_traceback; PyObject* pystring; pystring = NULL; PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); if (exc_type == 0 && exc_value == 0 && exc_traceback == 0) { CLog::Log(LOGINFO, "Strange: No Python exception occured"); } else { if (exc_type != NULL && (pystring = PyObject_Str(exc_type)) != NULL && (PyString_Check(pystring))) { PyObject *tracebackModule; CLog::Log(LOGINFO, "-->Python script returned the following error<--"); CLog::Log(LOGERROR, "Error Type: %s", PyString_AsString(PyObject_Str(exc_type))); if (PyObject_Str(exc_value)) CLog::Log(LOGERROR, "Error Contents: %s", PyString_AsString(PyObject_Str(exc_value))); tracebackModule = PyImport_ImportModule((char*)"traceback"); if (tracebackModule != NULL) { PyObject *tbList, *emptyString, *strRetval; tbList = PyObject_CallMethod(tracebackModule, (char*)"format_exception", (char*)"OOO", exc_type, exc_value == NULL ? Py_None : exc_value, exc_traceback == NULL ? Py_None : exc_traceback); emptyString = PyString_FromString(""); strRetval = PyObject_CallMethod(emptyString, (char*)"join", (char*)"O", tbList); CLog::Log(LOGERROR, "%s", PyString_AsString(strRetval)); Py_DECREF(tbList); Py_DECREF(emptyString); Py_DECREF(strRetval); Py_DECREF(tracebackModule); } CLog::Log(LOGINFO, "-->End of Python script error report<--"); } else { pystring = NULL; CLog::Log(LOGINFO, "<unknown exception type>"); } CGUIDialogKaiToast *pDlgToast = (CGUIDialogKaiToast*)g_windowManager.GetWindow(WINDOW_DIALOG_KAI_TOAST); if (pDlgToast) { CStdString desc; CStdString path; CStdString script; URIUtils::Split(m_source, path, script); if (script.Equals("default.py")) { CStdString path2; URIUtils::RemoveSlashAtEnd(path); URIUtils::Split(path, path2, script); } desc.Format(g_localizeStrings.Get(2100), script); pDlgToast->QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(257), desc); } } Py_XDECREF(exc_type); Py_XDECREF(exc_value); // caller owns all 3 Py_XDECREF(exc_traceback); // already NULL'd out Py_XDECREF(pystring); } PyObject *m = PyImport_AddModule((char*)"xbmc"); if(!m || PyObject_SetAttrString(m, (char*)"abortRequested", PyBool_FromLong(1))) CLog::Log(LOGERROR, "Scriptresult: failed to set abortRequested"); // make sure all sub threads have finished for(PyThreadState* s = state->interp->tstate_head, *old = NULL; s;) { if(s == state) { s = s->next; continue; } if(old != s) { CLog::Log(LOGINFO, "Scriptresult: Waiting on thread %"PRIu64, (uint64_t)s->thread_id); old = s; } CPyThreadState pyState; Sleep(100); pyState.Restore(); s = state->interp->tstate_head; } // pending calls must be cleared out PyXBMC_ClearPendingCalls(state); PyThreadState_Swap(NULL); PyEval_ReleaseLock(); { CSingleLock lock(m_pExecuter->m_critSection); m_threadState = NULL; } PyEval_AcquireLock(); PyThreadState_Swap(state); m_pExecuter->DeInitializeInterpreter(); Py_EndInterpreter(state); PyThreadState_Swap(NULL); PyEval_ReleaseLock(); }
bool KTrashOnekeyTask::StartClean(int nTask,const char* szTask) { CConfigData::DirWorkArray::iterator iter ; bool bResult = TRUE; if(m_pCallBack != NULL) m_pCallBack->OnBegin(); Initialize(); TaskMap[L"IE_TEMP"] = false; TaskMap[L"BROWER_SOGO"] = false; TaskMap[L"BROWER_MATHRON"] = false; TaskMap[L"BROWER_FIREFOX"] = false; TaskMap[L"BROWER_CHROME"] = false; TaskMap[L"BROWER_OPERA"] = false; TaskMap[L"WIN_TEMP"] = false; TaskMap[L"WIN_HUISHOUZHAN"] = false; TaskMap[L"WIN_LOG"] = false; TaskMap[L"WIN_UPDATE"] = false; TaskMap[L"OFFICE_CACHE"] = false; TaskMap[L"WIN_PRE"] = false; TaskMap[L"WIN_DOWNLOAD"] = false; TaskMap[L"U_TEMP"] = false; TaskMap[L"SYS_DRIVE"] = false; TaskMap[L"WIN_ERRPORT"] = false; TaskMap[L"WIN_LOG"] = false; TaskMap[L"WIN_SUOLIETU"] = false; if (szTask == NULL) goto Exit0; { std::wstring strTmp(KANSI_TO_UTF16(szTask)); std::vector<std::wstring> TaskVector; SplitStrTask(strTmp, TaskVector); for(std::vector<std::wstring>::iterator iter_str = TaskVector.begin(); iter_str!=TaskVector.end(); iter_str++) { std::map<std::wstring,bool>::iterator mapiter = TaskMap.find(*iter_str); if (mapiter != TaskMap.end()) { mapiter->second = true; } } } if (IsCleaning()) { bResult = FALSE; goto Exit0; } m_ulTotalJunkFileSize = 0; m_FileListData.m_nTotalsize = 0; for (size_t nIndex = 0; nIndex < m_FileListData.m_itemArray.size(); nIndex++) { m_FileListData.m_itemArray.at(nIndex).ulAllFileSize = 0; m_FileListData.m_itemArray.at(nIndex).itemArray.clear(); m_FileListData.m_itemArray.at(nIndex).strfileList = L""; } m_DirWorks.resize(m_config.GetConfigData().size()); m_DirWorks.clear(); std::copy(m_config.GetConfigData().begin(), m_config.GetConfigData().end(), back_inserter(m_DirWorks)); size_t i = 0; iter = m_DirWorks.begin(); while (iter != m_DirWorks.end() && i < m_DirWorks.size()) { if(TaskMap[TaskVector.at(i)]) iter->bDefaultSelect = TRUE; else iter->bDefaultSelect = FALSE; iter++; i++; } g_bStop[1] = FALSE; m_hThread = CreateThread( NULL, 0, CleanFileThread, (LPVOID)this, NULL, &m_dwThreadID ); if (m_hThread == NULL) bResult = FALSE; Exit0: return bResult; }
void XBPyThread::Process() { CLog::Log(LOGDEBUG,"Python thread: start processing"); int m_Py_file_input = Py_file_input; // get the global lock PyEval_AcquireLock(); PyThreadState* state = Py_NewInterpreter(); if (!state) { PyEval_ReleaseLock(); CLog::Log(LOGERROR,"Python thread: FAILED to get thread state!"); return; } // swap in my thread state PyThreadState_Swap(state); XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> languageHook(new XBMCAddon::Python::LanguageHook(state->interp)); languageHook->RegisterMe(); m_pExecuter->InitializeInterpreter(addon); CLog::Log(LOGDEBUG, "%s - The source file to load is %s", __FUNCTION__, m_source); // get path from script file name and add python path's // this is used for python so it will search modules from script path first CStdString scriptDir; URIUtils::GetDirectory(CSpecialProtocol::TranslatePath(m_source), scriptDir); URIUtils::RemoveSlashAtEnd(scriptDir); CStdString path = scriptDir; // add on any addon modules the user has installed ADDON::VECADDONS addons; ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons); for (unsigned int i = 0; i < addons.size(); ++i) #ifdef TARGET_WINDOWS { CStdString strTmp(CSpecialProtocol::TranslatePath(addons[i]->LibPath())); g_charsetConverter.utf8ToSystem(strTmp); path += PY_PATH_SEP + strTmp; } #else path += PY_PATH_SEP + CSpecialProtocol::TranslatePath(addons[i]->LibPath()); #endif // and add on whatever our default path is path += PY_PATH_SEP; // we want to use sys.path so it includes site-packages // if this fails, default to using Py_GetPath PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete if( pathObj && PyList_Check(pathObj) ) { for( int i = 0; i < PyList_Size(pathObj); i++ ) { PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete if( e && PyString_Check(e) ) { path += PyString_AsString(e); // returns internal data, don't delete or modify path += PY_PATH_SEP; } } } else { path += Py_GetPath(); } Py_DECREF(sysMod); // release ref to sysMod // set current directory and python's path. if (m_argv != NULL) PySys_SetArgv(m_argc, m_argv); CLog::Log(LOGDEBUG, "%s - Setting the Python path to %s", __FUNCTION__, path.c_str()); PySys_SetPath((char *)path.c_str()); CLog::Log(LOGDEBUG, "%s - Entering source directory %s", __FUNCTION__, scriptDir.c_str()); PyObject* module = PyImport_AddModule((char*)"__main__"); PyObject* moduleDict = PyModule_GetDict(module); // when we are done initing we store thread state so we can be aborted PyThreadState_Swap(NULL); PyEval_ReleaseLock(); // we need to check if we was asked to abort before we had inited bool stopping = false; { CSingleLock lock(m_critSec); m_threadState = state; stopping = m_stopping; } PyEval_AcquireLock(); PyThreadState_Swap(state); if (!stopping) { try { if (m_type == 'F') { // run script from file // We need to have python open the file because on Windows the DLL that python // is linked against may not be the DLL that xbmc is linked against so // passing a FILE* to python from an fopen has the potential to crash. PyObject* file = PyFile_FromString((char *) CSpecialProtocol::TranslatePath(m_source).c_str(), (char*)"r"); FILE *fp = PyFile_AsFile(file); if (fp) { PyObject *f = PyString_FromString(CSpecialProtocol::TranslatePath(m_source).c_str()); PyDict_SetItemString(moduleDict, "__file__", f); if (addon.get() != NULL) { PyObject *pyaddonid = PyString_FromString(addon->ID().c_str()); PyDict_SetItemString(moduleDict, "__xbmcaddonid__", pyaddonid); CStdString version = ADDON::GetXbmcApiVersionDependency(addon); PyObject *pyxbmcapiversion = PyString_FromString(version.c_str()); PyDict_SetItemString(moduleDict, "__xbmcapiversion__", pyxbmcapiversion); CLog::Log(LOGDEBUG,"Instantiating addon using automatically obtained id of \"%s\" dependent on version %s of the xbmc.python api",addon->ID().c_str(),version.c_str()); } Py_DECREF(f); XBMCAddon::Python::PyContext pycontext; // this is a guard class that marks this callstack as being in a python context PyRun_FileExFlags(fp, CSpecialProtocol::TranslatePath(m_source).c_str(), m_Py_file_input, moduleDict, moduleDict,1,NULL); } else CLog::Log(LOGERROR, "%s not found!", m_source); } else { //run script PyRun_String(m_source, m_Py_file_input, moduleDict, moduleDict); } } catch (const XbmcCommons::Exception& e) { e.LogThrowMessage(); } catch (...) { CLog::Log(LOGERROR, "failure in %s", m_source); } } bool systemExitThrown = false; if (!PyErr_Occurred()) CLog::Log(LOGINFO, "Scriptresult: Success"); else if (PyErr_ExceptionMatches(PyExc_SystemExit)) { systemExitThrown = true; CLog::Log(LOGINFO, "Scriptresult: Aborted"); } else { PythonBindings::PythonToCppException e; e.LogThrowMessage(); { CPyThreadState releaseGil; CSingleLock gc(g_graphicsContext); CGUIDialogKaiToast *pDlgToast = (CGUIDialogKaiToast*)g_windowManager.GetWindow(WINDOW_DIALOG_KAI_TOAST); if (pDlgToast) { CStdString desc; CStdString path; CStdString script; URIUtils::Split(m_source, path, script); if (script.Equals("default.py")) { CStdString path2; URIUtils::RemoveSlashAtEnd(path); URIUtils::Split(path, path2, script); } desc.Format(g_localizeStrings.Get(2100), script); pDlgToast->QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(257), desc); } } } PyObject *m = PyImport_AddModule((char*)"xbmc"); if(!m || PyObject_SetAttrString(m, (char*)"abortRequested", PyBool_FromLong(1))) CLog::Log(LOGERROR, "Scriptresult: failed to set abortRequested"); // make sure all sub threads have finished for(PyThreadState* s = state->interp->tstate_head, *old = NULL; s;) { if(s == state) { s = s->next; continue; } if(old != s) { CLog::Log(LOGINFO, "Scriptresult: Waiting on thread %"PRIu64, (uint64_t)s->thread_id); old = s; } CPyThreadState pyState; Sleep(100); pyState.Restore(); s = state->interp->tstate_head; } // pending calls must be cleared out XBMCAddon::RetardedAsynchCallbackHandler::clearPendingCalls(state); PyThreadState_Swap(NULL); PyEval_ReleaseLock(); //set stopped event - this allows ::stop to run and kill remaining threads //this event has to be fired without holding m_critSec // //Also the GIL (PyEval_AcquireLock) must not be held //if not obeyed there is still no deadlock because ::stop waits with timeout (smart one!) stoppedEvent.Set(); { CSingleLock lock(m_critSec); m_threadState = NULL; } PyEval_AcquireLock(); PyThreadState_Swap(state); m_pExecuter->DeInitializeInterpreter(); // run the gc before finishing // // if the script exited by throwing a SystemExit excepton then going back // into the interpreter causes this python bug to get hit: // http://bugs.python.org/issue10582 // and that causes major failures. So we are not going to go back in // to run the GC if that's the case. if (!m_stopping && languageHook->HasRegisteredAddonClasses() && !systemExitThrown && PyRun_SimpleString(GC_SCRIPT) == -1) CLog::Log(LOGERROR,"Failed to run the gc to clean up after running prior to shutting down the Interpreter %s",m_source); Py_EndInterpreter(state); // If we still have objects left around, produce an error message detailing what's been left behind if (languageHook->HasRegisteredAddonClasses()) CLog::Log(LOGWARNING, "The python script \"%s\" has left several " "classes in memory that we couldn't clean up. The classes include: %s", m_source, getListOfAddonClassesAsString(languageHook).c_str()); // unregister the language hook languageHook->UnregisterMe(); PyEval_ReleaseLock(); }
void CNDCardCreditDlg::OnBnClickedButtonCredit() { UpdateData(); if (!CLocalServer::GetInstance()->ActiveMemberList.IsAllowCredit(m_nMemberId)) { return; } if (m_strPwd.IsEmpty() || m_strCardId.IsEmpty()) { return; } NS_SERVLET::CCardCreditMethod CardCredit; CString strTmp(_T("XN")); if (m_cboCardType.GetCurSel() == 1) { strTmp = (_T("ZS")); } CardCredit.SetCategory(strTmp); CardCredit.SetCardPwd(m_strPwd); CardCredit.SetMemberId(_ttoi(m_strMemberID)); CardCredit.SetCardSerial(m_strCardId); double dblAmount = _tstof(m_strMoney); INT nTmp = dblAmount * 100; CardCredit.SetAmount(nTmp); theApp.GetCurCashier()->DoCardCredit(CardCredit); if (CardCredit.GetStatusCode() == 0) { m_CreditCard.DeleteCreditCard(); {//写入数据库 CCreditInfoDB CreditInfo; CreditInfo.SetCardSerial(m_strCardId); CreditInfo.SetCreditDate(CIBAHelpper::FormatCenterTime(CardCredit.GetTranTime())); CreditInfo.SetRefNo(CardCredit.GetRefNo()); CreditInfo.SetCreditPresent(CardCredit.GetCreditPresent()); CreditInfo.SetCreditAmount(nTmp); CreditInfo.SetOperator(theApp.GetCurCashier()->GetName()); CreditInfo.SetNetBarId(CNetBarConfig::GetInstance()->GetNetBarId()); CreditInfo.SetCashRegisterID(CIBAConfig::GetInstance()->GetCashRegisterID()); CreditInfo.SetMemberId(_ttoi(m_strMemberID)); CreditInfo.SetSerialNo(CardCredit.GetLocalSerialNo()); CreditInfo.SetCassId(m_nUserClassID); CreditInfo.SetCategory(strTmp); CIBADAL::GetInstance()->AddCardCreditRecord(CreditInfo); } m_strPwd.Empty(); m_strMoney.Empty(); m_strCardId.Empty(); UpdateData(FALSE); GetDlgItem(IDC_BUTTON_CREDIT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_READCARD)->EnableWindow(FALSE); OnBnClickedButtonQuery(); } SetToolTipPos(IDC_BUTTON_CREDIT); ShowToolTip(CardCredit.GetStatusMessage(), CardCredit.GetStatusCode() != 0); }
int CTranCmn::fnAPP_IBK_MANAGEMENT_InputProc() { CString ManagerOpPassword("00000000"); CString KtLinKusOpPassword("0000"); CString strReturn(""); CString strTmp(""); int nGetCnt = 0; CString strAcceptLen("0"); ///////////////////////////////////////////////////////////////////////////// Accept.AuthFlag = 0; ///////////////////////////////////////////////////////////////////////////// m_pDevCmn->fnSCR_DisplayScreen(3200, K_30_WAIT, PIN_MENU_MODE1); // 환경 업체선택 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == "NICE") { ManagerOpPassword.Format("%8.8s", GetDate()); Accept.AuthFlag = 1; strAcceptLen = "8"; } else if (strReturn == "KT LINKUS") { KtLinKusOpPassword = "******"; Accept.AuthFlag = 2; strAcceptLen = "4"; } else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else { fnAPP_CancelProc(T_INPUTOVER); } while (TRUE) { if(nGetCnt > 2) fnAPP_CancelProc(T_INPUTOVER); m_pDevCmn->fnSCR_DisplayString(1, strAcceptLen); // #0115 m_pDevCmn->fnSCR_DisplayScreen(3202, K_30_WAIT, PIN_NUMERIC_MODE); strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if (strReturn == S_CLEAR) { nGetCnt++; continue; } else { if (Accept.AuthFlag == 2) { if (strReturn == KtLinKusOpPassword) { break; } else { nGetCnt++; continue; } } else { if (strReturn == ManagerOpPassword) { break; } else { nGetCnt++; continue; } } } } strReturn = ""; ///////////////////////////////////////////////////////////////////////////// memset(Accept.JiroElecNum, '0', sizeof(Accept.JiroElecNum)); // 환경점검내용 ///////////////////////////////////////////////////////////////////////////// //#N0214 strTmp = IniGetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO","00000000000000"); //#N0199 환경점검 이전 내용 표시 //#N0213 환경점검 시 초기 상태 무조건 비정상 //strTmp = "11111111111111"; //#N0214 m_pDevCmn->fnSCR_DisplayString(1, strTmp); m_pDevCmn->fnSCR_DisplayScreen(3201, K_120_WAIT, PIN_MENU_MODE1); // 환경점검내용 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if ((strReturn.GetLength() != 14) || // 자료검증 (!IsNum(strReturn.GetBuffer(0), strReturn.GetLength())) ) fnAPP_CancelProc(T_INPUTERROR); else { Accept.JiroElecNumSize = strReturn.GetLength(); memcpy(Accept.JiroElecNum, strReturn.GetBuffer(0), strReturn.GetLength()); strTmp.Empty(); strTmp = strReturn; IniSetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO", strReturn.GetBuffer(0)); //#N0199 환경점검 이전 내용 표시 -> #N0214 } strReturn = ""; ///////////////////////////////////////////////////////////////////////////// Accept.TelNumSize = 0; // 직원번호 memset(Accept.TelNum, ' ', sizeof(Accept.TelNum)); // 직원번호 ///////////////////////////////////////////////////////////////////////////// m_pDevCmn->fnSCR_DisplayScreen(3203, K_30_WAIT, PIN_NUMERIC_MODE); //// 직원번호 strReturn = m_pDevCmn->fstrSCR_GetKeyString(); if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_CANCEL) fnAPP_CancelProc(T_CANCEL); else if (strReturn == S_TIMEOVER) fnAPP_CancelProc(T_TIMEOVER); else if (strReturn == S_INPUTOVER) fnAPP_CancelProc(T_INPUTOVER); else if ((!strReturn.GetLength()) || // 자료검증 (strReturn.GetLength() > sizeof(Accept.TelNum)) || (!IsNum(strReturn.GetBuffer(0), strReturn.GetLength())) || (IsZero(strReturn.GetBuffer(0), strReturn.GetLength()))) fnAPP_CancelProc(T_INPUTERROR); else { Accept.TelNumSize = strReturn.GetLength(); memcpy(Accept.TelNum, strReturn.GetBuffer(0), strReturn.GetLength()); IniSetStr(_TRANS_INI, TRANS_SEC, "IBK_MANAGEMENT_INFO", strTmp); //#N0199 환경점검 이전 내용 표시 } return T_OK; }
void CEmoticonRichEditCtrl::FormatTextRange(int nStart, int nEnd) { BOOL bEmoticon = FALSE; if (nStart >= nEnd) { TRACE("\nreturn!!\n"); return; } m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); TRACE("crOldSel MIN [%d] MAX [%d] \n", crOldSel.cpMin, crOldSel.cpMax ); HideSelection(TRUE, FALSE); TCHAR *pBuffer = NULL; //char *pBuffer = NULL; try { TRACE("FormatTextRange : nStart [%d] nEnd [%d] \n", nStart, nEnd); SetSel(nStart, nEnd); pBuffer = new TCHAR[nEnd - nStart + 1]; //pBuffer = new char[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer); pBuffer[nLen] = 0; TRACE("new [%d] pBuffer [%S]\n", nEnd - nStart + 1, pBuffer); //ASSERT(nLen <= nEnd - nStart); TCHAR *pStart, *pPtr, *pSymbolStart ; //char* pStart = NULL, *pPtr = NULL; //char* pSymbolStart = NULL; pStart = pPtr = pBuffer; while (*pPtr != 0) { TCHAR ch = *pPtr; //char ch = *pPtr; if ( _istalpha(ch) || ch == '_') { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; //TRACE("pSymbolStart [%s]\n", pSymbolStart ); int nPos = IsEmoticon(pSymbolStart); if (nPos >= 0) { bEmoticon = TRUE; SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG); //TRACE("이모티콘!!! [%s]\n", pSymbolStart ); SetSel(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); ReplaceSel(" "); TRACE("이모티콘영역 [%d] [%d]\n", nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); CString strTmp(pSymbolStart); int nIndex = atoi( (LPCSTR)strTmp.Mid(2,2) ) ; HBITMAP hBitmap = GetImage( m_imgListFaces , nIndex ); if (hBitmap) { CString strOutID; strOutID.Empty(); CImageDataObject::InsertBitmap(m_pRichEditOle, hBitmap, strOutID ); // strTmp => ec01 , strOutID = 12232132321 if(m_nRole == ROLE_SEND_INPUT ) { char* pszID = new char[10+1]; char* pszVal = new char[10+1]; strncpy(pszID, (LPCSTR)strOutID, 10); strcpy(pszVal, pSymbolStart); TRACE("WM_EMOTICON_MAP : pszID [%s] pszVal [%s]\n", pszID, pszVal ); GetParent()->SendMessage( WM_EMOTICON_MAP, (WPARAM) pszID , (LPARAM) pszVal) ; } } ReplaceSel(" "); pStart = pPtr; pSymbolStart = 0; } else { pSymbolStart = NULL; } *pPtr = ch; } else { pPtr++; } } } catch(...) { //delete [] pBuffer; //pBuffer = NULL ; } delete [] pBuffer; if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } SetSel(crOldSel); if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } HideSelection(FALSE, FALSE); //UnlockWindowUpdate(); SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG ); m_bInForcedChange = FALSE; }
void CIBADoc::SetTitle(LPCTSTR lpszTitle) { CString strTmp(_T("Íø°ÉÃû³Æ.txt")); CDocument::SetTitle(strTmp); }
void CComputerListView::OnClientShortMessage(SHORT_MESSAGE_INFO& shortMsgInfo) { //{ 2011/11/15-8210-gxx: CString str = CA2T(shortMsgInfo.shortMsg.message); int nSpl = str.Find(_T('|')); if (nSpl > 0 && str.Left(nSpl).CompareNoCase(_T("p-ddnparam")) == 0) { // 购买点卡的消息 CString strTmp(CA2T(shortMsgInfo.shortMsg.message)); strTmp = strTmp.Mid(11); CString strTerm(CA2T(shortMsgInfo.shortMsg.termID)); if (strTmp.Find(_T('?')) >= 0) { strTmp.AppendFormat(_T("&TermId=%s"), strTerm); } else { strTmp.AppendFormat(_T("?TermId=%s"), strTerm); } CActiveMember ActiveMember; if (CLocalServer::GetInstance()->ActiveMemberList.GetActiveMember(shortMsgInfo.shortMsg.memberID,ActiveMember)) { strTmp.AppendFormat(_T("&UserName=%s"), ActiveMember.GetUserName()); } else { strTmp += _T("&UserName=未知姓名"); } IBA_LOG(_T("客户端请求购买点卡,URL=%s"), strTmp); CCashierHelper::CashSellDianka(strTmp); } //} else if (shortMsgInfo.shortMsg.messageType !=2 ) // 非余额不足消息 { //弹出式 CBCGPPopupWindow* pPopup = new CMsgPopupWindow; //这里不需要删除,框架会自动删除的 // Create indirect: CBCGPPopupWndParams params;//设置窗口参数 CString strMsg, strTermId, strTermIP, strTmp; strTermId = CA2W(shortMsgInfo.shortMsg.termID);//终端ID // 2011/06/17-gxx: 打补丁,IP长度等于15时,拷贝字符串出问题 char IP[LEN_IPADDR+1]; memcpy(IP, shortMsgInfo.shortMsg.computerIP, LEN_IPADDR); IP[LEN_IPADDR] = '\0'; strTermIP = CA2W(IP);//终端IP strTermId.Trim(); strTermIP.Trim(); if (!strTermIP.IsEmpty())//IP 不是空 表示是客户端信息 { strTmp = LOAD_STRING(IDS_CLIENTINFO); strMsg.Format(LOAD_STRING(IDS_FORMTERMIP), strTermId, strTermIP);//设置终端的URL params.m_nURLCmdID = (UINT)CLocalServer::GetInstance()->ComputerList.Find(strTermId, strTermIP); params.m_hIcon = AfxGetApp()->LoadIcon(IDR_UDO); } else { params.m_nURLCmdID = 10000; strTmp = LOAD_STRING(IDS_CASHIERINFO); params.m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } //接受客户端消息 strMsg.Append(CA2W(shortMsgInfo.shortMsg.message)); params.m_strText = strMsg; RECT rt = {-1, -1, -1, -1}; if (CIBAConfig::GetInstance()->GetMsgLeftBottom())// 从左下角弹出 { SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0); } if (!CIBAConfig::GetInstance()->GetMsgAutoHide()) { pPopup->SetAutoCloseTime(0); } pPopup->Create(NULL, params, 0, CPoint(rt.left, rt.bottom));//创建窗体 pPopup->SetWindowText(strTmp);//显示消息 } CClientShortMessage csm; csm.SetMemberId( shortMsgInfo.shortMsg.memberID); csm.SetMsgBody( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.message)); csm.SetMsgID( shortMsgInfo.shortMsg.ID); csm.SetMsgType( shortMsgInfo.shortMsg.messageType); csm.SetRevTime( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.sendTime)); csm.SetTermID( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.termID)); csm.SetTermIP( (LPCTSTR)CA2T(shortMsgInfo.shortMsg.computerIP)); if (csm.GetMsgType() == 2) { if (CNetBarConfig::GetInstance()->GetReminderBalance()) { static DWORD nTimeCount = GetTickCount() - 10000; if (GetTickCount()-nTimeCount > 10000)// 防止在10秒连续播放 { NS_TTS::CIBATTS::GetInstance()->SpeakReminderBalance(csm.GetTermID()); nTimeCount = GetTickCount(); } } csm.SetMsgBody(LOAD_STRING(IDS_BALANCE_REMINDER)); // 余额不足 } //写到信息对话框中 //((CMainFrame*)AfxGetMainWnd())->m_wndOutput.UpdateMsgLog(); ((CMainFrame*)AfxGetMainWnd())->m_wndOutput.AddMsgLog(csm); }
void EnumFiles(VMenu2& Menu, const string& Str) { if(!Str.empty()) { string strStr(Str); size_t Pos = 0; if(std::count(ALL_CONST_RANGE(strStr), L'"') & 1) // odd quotes count { Pos = strStr.rfind(L'"'); } else { for(Pos=strStr.size()-1; Pos!=static_cast<size_t>(-1); Pos--) { if(strStr[Pos]==L'"') { Pos--; while(strStr[Pos]!=L'"' && Pos!=static_cast<size_t>(-1)) { Pos--; } } else if(strStr[Pos]==L' ') { Pos++; break; } } } if(Pos==static_cast<size_t>(-1)) { Pos=0; } bool StartQuote=false; if(Pos < strStr.size() && strStr[Pos]==L'"') { Pos++; StartQuote=true; } string strStart(strStr.data(),Pos); Unquote(strStr.erase(0, Pos)); if(!strStr.empty()) { string strExp = os::env::expand_strings(strStr); os::fs::enum_file Find(strExp+L"*"); bool Separator=false; std::for_each(CONST_RANGE(Find, i) { const wchar_t* FileName=PointToName(strStr); bool NameMatch=!StrCmpNI(FileName, i.strFileName.data(), StrLength(FileName)), AltNameMatch = NameMatch? false : !StrCmpNI(FileName, i.strAlternateFileName.data(), StrLength(FileName)); if(NameMatch || AltNameMatch) { strStr.resize(FileName-strStr.data()); string strAdd (strStr + (NameMatch ? i.strFileName : i.strAlternateFileName)); if (!StartQuote) QuoteSpace(strAdd); string strTmp(strStart+strAdd); if(StartQuote) strTmp += L'"'; if(!Separator) { if(Menu.GetItemCount()) { MenuItemEx Item; Item.strName = MSG(MCompletionFilesTitle); Item.Flags=LIF_SEPARATOR; Menu.AddItem(Item); } else { Menu.SetTitle(MSG(MCompletionFilesTitle)); } Separator=true; } Menu.AddItem(strTmp); } });
/** * Handles the log sub-command. * * @returns Suitable exit code. * @param pArgs The handler arguments. * @param pDebugger Pointer to the debugger interface. * @param pszSubCmd The sub command. */ static RTEXITCODE handleDebugVM_LogXXXX(HandlerArg *pArgs, IMachineDebugger *pDebugger, const char *pszSubCmd) { /* * Parse arguments. */ bool fRelease = false; com::Utf8Str strSettings; RTGETOPTSTATE GetState; RTGETOPTUNION ValueUnion; /* * NB: don't use short options to prevent log specifications like * "-drv_foo" from being interpreted as options. */ # define DEBUGVM_LOG_DEBUG (VINF_GETOPT_NOT_OPTION + 'd') # define DEBUGVM_LOG_RELEASE (VINF_GETOPT_NOT_OPTION + 'r') static const RTGETOPTDEF s_aOptions[] = { { "--debug", DEBUGVM_LOG_DEBUG, RTGETOPT_REQ_NOTHING }, { "--release", DEBUGVM_LOG_RELEASE, RTGETOPT_REQ_NOTHING } }; int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, /* * Note: RTGETOPTINIT_FLAGS_NO_STD_OPTS is needed to not get into an infinite hang in the following * while-loop when processing log groups starting with "h", * e.g. "VBoxManage debugvm <VM Name> log --debug -hex". */ RTGETOPTINIT_FLAGS_OPTS_FIRST | RTGETOPTINIT_FLAGS_NO_STD_OPTS); AssertRCReturn(rc, RTEXITCODE_FAILURE); while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0) { switch (rc) { case DEBUGVM_LOG_RELEASE: fRelease = true; break; case DEBUGVM_LOG_DEBUG: fRelease = false; break; /* Because log strings can start with "-" (like "-all+dev_foo") * we have to take everything we got as a setting and apply it. * IPRT will take care of the validation afterwards. */ default: if (strSettings.length() == 0) strSettings = ValueUnion.psz; else { strSettings.append(' '); strSettings.append(ValueUnion.psz); } break; } } if (fRelease) { com::Utf8Str strTmp(strSettings); strSettings = "release:"; strSettings.append(strTmp); } com::Bstr bstrSettings(strSettings); if (!strcmp(pszSubCmd, "log")) CHECK_ERROR2I_RET(pDebugger, ModifyLogGroups(bstrSettings.raw()), RTEXITCODE_FAILURE); else if (!strcmp(pszSubCmd, "logdest")) CHECK_ERROR2I_RET(pDebugger, ModifyLogDestinations(bstrSettings.raw()), RTEXITCODE_FAILURE); else if (!strcmp(pszSubCmd, "logflags")) CHECK_ERROR2I_RET(pDebugger, ModifyLogFlags(bstrSettings.raw()), RTEXITCODE_FAILURE); else AssertFailedReturn(RTEXITCODE_FAILURE); return RTEXITCODE_SUCCESS; }