bool CGPImporter::ImportTask(const CXmlItem* pXISrcTask, ITaskList8* pDestTaskFile, HTASKITEM htDestParent, BOOL bAndSiblings) { if (!pXISrcTask) return true; CString sName = pXISrcTask->GetItemValue(_T("name")); DWORD dwID = GetTDLTaskID(pXISrcTask->GetItemValueI(_T("id"))); ASSERT(dwID); HTASKITEM hTask = pDestTaskFile->NewTask(sName, htDestParent, dwID); ASSERT (hTask); if (!hTask) return false; // completion int nPercentDone = pXISrcTask->GetItemValueI(_T("complete")); pDestTaskFile->SetTaskPercentDone(hTask, (unsigned char)nPercentDone); // dates time_t tStart; if (CDateHelper::DecodeDate(pXISrcTask->GetItemValue(_T("start")), tStart)) { pDestTaskFile->SetTaskStartDate(hTask, tStart); int nDuration = pXISrcTask->GetItemValueI(_T("duration")); // only add duration to leaf tasks else it'll double up if (nDuration && !pXISrcTask->HasItem(_T("task"))) { if (nPercentDone == 100) { pDestTaskFile->SetTaskDoneDate(hTask, tStart + (nDuration - 1) * ONEDAY); // gp dates are inclusive pDestTaskFile->SetTaskTimeSpent(hTask, nDuration, 'D'); } else { pDestTaskFile->SetTaskDueDate(hTask, tStart + (nDuration - 1) * ONEDAY); // gp dates are inclusive pDestTaskFile->SetTaskTimeEstimate(hTask, nDuration, 'D'); } } } // priority int nPriority = pXISrcTask->GetItemValueI(_T("priority")); pDestTaskFile->SetTaskPriority(hTask, (unsigned char)(nPriority * 3 + 2)); // 2, 5, 8 // file ref CString sFileRef = pXISrcTask->GetItemValue(_T("webLink")); sFileRef.TrimLeft(); if (!sFileRef.IsEmpty()) { // decode file paths if (sFileRef.Find(_T("file://")) == 0) { sFileRef = sFileRef.Mid(7); sFileRef.Replace(_T("%20"), _T("")); } pDestTaskFile->SetTaskFileReferencePath(hTask, sFileRef); } // comments pDestTaskFile->SetTaskComments(hTask, pXISrcTask->GetItemValue(_T("notes"))); // dependency // do this after we've imported all the tasks because GP does it // the opposite way round to TDL // children if (!ImportTask(pXISrcTask->GetItem(_T("task")), pDestTaskFile, hTask, TRUE)) return false; // handle sibling tasks WITHOUT RECURSION if (bAndSiblings) { pXISrcTask = pXISrcTask->GetSibling(); while (pXISrcTask) { // FALSE == don't recurse on siblings if (!ImportTask(pXISrcTask, pDestTaskFile, htDestParent, FALSE)) return false; pXISrcTask = pXISrcTask->GetSibling(); } } return true; }
BOOL COcsNotifyUserApp::parseCommandLine() { CString csTimeOut; // /DEBUG if (isRequired( m_lpCmdLine, _T( "debug"))) m_pLogger->setLogLevel( LOG_PRIORITY_DEBUG); // Notification type if (isRequired( m_lpCmdLine, _T( "preinstall"))) { // Show preinstall dialog box /PREINSTALL m_uNotifcation = NOTIFY_TYPE_PREINSTALL; } else if (isRequired( m_lpCmdLine, _T( "asktag"))) { // Show askTag dialog box /ASKTAG m_uNotifcation = NOTIFY_TYPE_ASKTAG; // Ensure /FILE is provided if (isRequired( m_lpCmdLine, _T( "file"))) m_csFile = getParamValue( m_lpCmdLine, _T( "file")); else return FALSE; } else if (isRequired( m_lpCmdLine, _T( "postinstall"))) { // Show postinstall dialog box /POSTINSTALL m_uNotifcation = NOTIFY_TYPE_POSTINSTALL; } else { // Show default messagebox /MSGBOX m_uNotifcation = NOTIFY_TYPE_MSGBOX; } // /MSG=message (mandatory) if (isRequired( m_lpCmdLine, _T( "msg"))) m_csMessage = getParamValue( m_lpCmdLine, _T( "msg")); else return FALSE; // /NOCANCEL if (isRequired( m_lpCmdLine, _T( "nocancel"))) m_bCancel = FALSE; else m_bCancel = TRUE; // /DELAY if (isRequired( m_lpCmdLine, _T( "delay"))) m_bDelay = TRUE; else m_bDelay = FALSE; // /REBOOT if (isRequired( m_lpCmdLine, _T( "reboot"))) m_bReboot = TRUE; else m_bReboot = FALSE; // /TIMEOUT[=seconds] if (isRequired( m_lpCmdLine, _T( "timeout"))) csTimeOut = getParamValue( m_lpCmdLine, _T( "timeout")); else csTimeOut.Empty(); if (csTimeOut.IsEmpty()) m_uTimeOut = 0; else m_uTimeOut = _ttol( csTimeOut); return TRUE; }
CString CMediaTypeEx::ToString(IPin* pPin) { CString packing, type, codec, dim, rate, dur; // TODO if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) { packing = _T("Encrypted MPEG2 Pack"); } else if (majortype == MEDIATYPE_MPEG2_PACK) { packing = _T("MPEG2 Pack"); } else if (majortype == MEDIATYPE_MPEG2_PES) { packing = _T("MPEG2 PES"); } if (majortype == MEDIATYPE_Video) { type = _T("Video"); BITMAPINFOHEADER bih; bool fBIH = ExtractBIH(this, &bih); int w, h, arx, ary; bool fDim = ExtractDim(this, w, h, arx, ary); if (fBIH) { codec = GetVideoCodecName(subtype, bih.biCompression); } if (codec.IsEmpty()) { if (formattype == FORMAT_MPEGVideo) { codec = _T("MPEG1 Video"); } else if (formattype == FORMAT_MPEG2_VIDEO) { codec = _T("MPEG2 Video"); } else if (formattype == FORMAT_DiracVideoInfo) { codec = _T("Dirac Video"); } } if (fDim) { dim.Format(_T("%dx%d"), w, h); if (w * ary != h * arx) { dim.AppendFormat(_T(" (%d:%d)"), arx, ary); } } if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) { VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat; if (vih->AvgTimePerFrame) { rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame); rate.TrimRight(_T('0')); // remove trailing zeros rate.TrimRight(_T('.')); // remove the trailing dot rate += _T("fps "); } if (vih->dwBitRate) { rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000); } } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) { VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat; if (vih->AvgTimePerFrame) { rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame); rate.TrimRight(_T('0')); // remove trailing zeros rate.TrimRight(_T('.')); // remove the trailing dot rate += _T("fps "); } if (vih->dwBitRate) { rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000); } } rate.TrimRight(); if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) { type = _T("Subtitle"); codec = _T("DVD Subpicture"); } } else if (majortype == MEDIATYPE_Audio) { type = _T("Audio"); if (formattype == FORMAT_WaveFormatEx) { WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format(); if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/ || subtype != GUID_NULL) { codec = GetAudioCodecName(subtype, wfe->wFormatTag); dim.Format(_T("%dHz"), wfe->nSamplesPerSec); if (wfe->nChannels == 1) { dim += _T(" mono"); } else if (wfe->nChannels == 2) { dim += _T(" stereo"); } else { dim.AppendFormat(_T(" %dch"), wfe->nChannels); } if (wfe->nAvgBytesPerSec) { rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec * 8 / 1000); } } } else if (formattype == FORMAT_VorbisFormat) { VORBISFORMAT* vf = (VORBISFORMAT*)Format(); codec = GetAudioCodecName(subtype, 0); dim.Format(_T("%dHz"), vf->nSamplesPerSec); if (vf->nChannels == 1) { dim += _T(" mono"); } else if (vf->nChannels == 2) { dim += _T(" stereo"); } else { dim.AppendFormat(_T(" %dch"), vf->nChannels); } if (vf->nAvgBitsPerSec) { rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec / 1000); } } else if (formattype == FORMAT_VorbisFormat2) { VORBISFORMAT2* vf = (VORBISFORMAT2*)Format(); codec = GetAudioCodecName(subtype, 0); dim.Format(_T("%dHz"), vf->SamplesPerSec); if (vf->Channels == 1) { dim += _T(" mono"); } else if (vf->Channels == 2) { dim += _T(" stereo"); } else { dim.AppendFormat(_T(" %dch"), vf->Channels); } } } else if (majortype == MEDIATYPE_Text) { type = _T("Text"); } else if (majortype == MEDIATYPE_Subtitle) { type = _T("Subtitle"); codec = GetSubtitleCodecName(subtype); } else { type = _T("Unknown"); } if (CComQIPtr<IMediaSeeking> pMS = pPin) { REFERENCE_TIME rtDur = 0; if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) { rtDur /= 10000000; int s = rtDur % 60; rtDur /= 60; int m = rtDur % 60; rtDur /= 60; int h = (int)rtDur; if (h) { dur.Format(_T("%d:%02d:%02d"), h, m, s); } else if (m) { dur.Format(_T("%02d:%02d"), m, s); } else if (s) { dur.Format(_T("%ds"), s); } } } CString str; if (!codec.IsEmpty()) { str += codec + _T(" "); } if (!dim.IsEmpty()) { str += dim + _T(" "); } if (!rate.IsEmpty()) { str += rate + _T(" "); } if (!dur.IsEmpty()) { str += dur + _T(" "); } str.Trim(_T(" ,")); if (!str.IsEmpty()) { str = type + _T(": ") + str; } else { str = type; } return str; }
// here for <!ELEMENT blah> void CMUSHclientDoc::MXP_Element (CString strName, CString strTag) { static CArgumentList ArgumentList; // get arguments to !ELEMENT definition if (BuildArgumentList (ArgumentList, strTag)) { DELETE_LIST (ArgumentList); return; } CElement * pElement; bool bDelete = GetKeyword (ArgumentList, "delete"); strName.MakeLower (); // case-insensitive? // see if we know of this atom CAtomicElement * element_item; if (App.m_ElementMap.Lookup (strName, element_item)) { MXP_error (DBG_ERROR, errMXP_CannotRedefineElement, TFormat ("Cannot redefine built-in MXP element: <%s>" , (LPCTSTR) strName)); return; } // if element already defined, delete old one if (m_CustomElementMap.Lookup (strName, pElement)) { if (!bDelete) MXP_error (DBG_WARNING, wrnMXP_ReplacingElement, TFormat ("Replacing previously-defined MXP element: <%s>", (LPCTSTR) strName)); DELETE_LIST (pElement->ElementItemList); DELETE_LIST (pElement->AttributeList); delete pElement; } // end of existing element if (bDelete) return; // all done! // add new element to map m_CustomElementMap.SetAt (strName, pElement = new CElement); pElement->strName = strName; // get keywords first, so we won't mistake them for arguments // (eg. so OPEN doesn't become an argument) // look for keyword OPEN pElement->bOpen = GetKeyword (ArgumentList, "open"); // look for keyword EMPTY pElement->bCommand = GetKeyword (ArgumentList, "empty"); CString strArgument; // get definition ( <COLOR &col;> ) strArgument = GetArgument (ArgumentList, "", 1, false); // get definition // add atomic items here -------------------------- CString strAtom; const char * p = strArgument; const char * pStart; while (*p) { // check opening < if (*p != '<') { MXP_error (DBG_ERROR, errMXP_NoTagInDefinition, TFormat ("No opening \"<\" in MXP element definition \"%s\"", (LPCTSTR) strArgument)); return; } p++; // skip < pStart = p; // remember start of tag // skip <, look for > for (; *p && *p != '>'; p++) // look for closing tag { if (*p == '<') { MXP_error (DBG_ERROR, errMXP_UnexpectedDefinitionSymbol, TFormat ("Unexpected \"<\" in MXP element definition \"%s\"", (LPCTSTR) strArgument)); return; } if (*p == '\'' || *p == '\"') // quoted string? { char c = *p; // remember opening quote for (p++; *p && *p != c; p++) // look for closing quote ; // just keep looking if (*p != c) { MXP_error (DBG_ERROR, errMXP_NoClosingDefinitionQuote, TFormat ("No closing quote in MXP element definition \"%s\"", (LPCTSTR) strArgument)); return; } } // end of quoted string } // end of search for closing tag // check closing > if (*p != '>') { MXP_error (DBG_ERROR, errMXP_NoClosingDefinitionTag, TFormat ("No closing \">\" in MXP element definition \"%s\"", (LPCTSTR) strArgument)); return; } strAtom = CString (pStart, p - pStart); // build tag, excluding < and > CString strAtomName; if (GetWord (strAtomName, strAtom)) { MXP_error (DBG_ERROR, errMXP_NoDefinitionTag, TFormat ("No element name in MXP element definition \"<%s>\"", (LPCTSTR) CString (pStart, p - pStart))); return; } if (strAtomName == "/") { GetWord (strAtomName, strAtom); // try to get next word strAtomName.MakeLower (); // case insensitive? MXP_error (DBG_ERROR, errMXP_DefinitionCannotCloseElement, TFormat ("Element definitions cannot close other elements: </%s>" , (LPCTSTR) strAtomName)); return; } if (strAtomName == "!") { GetWord (strAtomName, strAtom); // try to get next word strAtomName.MakeLower (); // case insensitive? MXP_error (DBG_ERROR, errMXP_DefinitionCannotDefineElement, TFormat ("Element definitions cannot define other elements: <!%s>" , (LPCTSTR) strAtomName)); return; } strAtomName.MakeLower (); // case insensitive? // see if we know of this atom CAtomicElement * element_item; if (!App.m_ElementMap.Lookup (strAtomName, element_item)) { MXP_error (DBG_ERROR, errMXP_NoInbuiltDefinitionTag, TFormat ("Unknown MXP element: <%s>" , (LPCTSTR) strAtomName)); return; } // yes? add to list CElementItem * pElementItem = new CElementItem; if (BuildArgumentList (pElementItem->ArgumentList, strAtom)) // add arguments { // bad arguments DELETE_LIST (pElementItem->ArgumentList); delete pElementItem; return; } pElement->ElementItemList.AddTail (pElementItem ); pElementItem->pAtomicElement = element_item; // which atomic element p++; // skip > } // end of processing each atomic item // end of add atomic items -------------------------- // get attributes (COLOR=RED NAME=FRED) if (BuildArgumentList (pElement->AttributeList, GetArgument (ArgumentList, "att", 2, false))) { // bad arguments DELETE_LIST (pElement->AttributeList); return; } // get tag (TAG=22) strArgument = GetArgument (ArgumentList, "tag", 3, true); // get tag number if (IsNumeric (strArgument)) { int i = atoi (strArgument); if (i >= 20 && i <= 99) pElement->iTag = i; } // get tag (FLAG=roomname) strArgument = GetArgument (ArgumentList, "flag", 4, true); // get flag name if (!strArgument.IsEmpty ()) { /* // I won't check names right now ... if (strArgument == "roomname" || strArgument == "roomdesc" || strArgument == "roomexit" || strArgument == "roomnum" || strArgument == "prompt") pElement->strFlag = strArgument; else */ if (strArgument.Left (4) == "set ") pElement->strFlag = strArgument.Mid (4); // what variable to set else pElement->strFlag = strArgument; pElement->strFlag.TrimLeft (); pElement->strFlag.TrimRight (); // make things a bit easier - let spaces through but change to underscores pElement->strFlag.Replace (" ", "_"); // check variable name is OK if (CheckObjectName (pElement->strFlag) != eOK) { MXP_error (DBG_ERROR, errMXP_BadVariableName, TFormat ("Bad variable name \"%s\" - for MXP FLAG definition", (LPCTSTR) pElement->strFlag)); pElement->strFlag.Empty (); } } // end of having a flag DELETE_LIST (ArgumentList); } // end of CMUSHclientDoc::MXP_Element
void CDialog_Check::OnBnClickedBtbSave() { // TODO: 在此添加控件通知处理程序代码 m_date.m_material = m_allMaterial.at(m_mName_ctrl.GetCurSel()); if(m_date.m_material.GetId().empty()) { CRuntimeMessageBox::RunMessageBox("请选择正确的材料"); return; } CString tmp; m_mNum_ctrl.GetWindowText(tmp); if(tmp.IsEmpty() || tmp.SpanIncluding(_T("1234567890")) != tmp) { CRuntimeMessageBox::RunMessageBox("请输入正确的数目!"); return; } else { m_date.m_num = atoi((const char *)tmp.GetBuffer(tmp.GetLength())); double price = atof(m_dateChange.CStringtostring(m_date.m_material.m_price).c_str()); tmp.Format(_T("%.2lf"),m_date.m_num * price); m_total_ctrl.SetWindowText(tmp); m_date.m_total = price; } m_wName_ctrl.GetWindowText(m_date.m_operateWare); if(m_date.m_operateWare.IsEmpty()) { CRuntimeMessageBox::RunMessageBox("请输入正确的仓库"); return; } m_date.m_class = m_allClass.at(m_cName_ctrl.GetCurSel()); if(m_date.m_class.GetId().empty()) { CRuntimeMessageBox::RunMessageBox("请选择正确的部门名称"); return; } m_date.m_userInfo = m_allUser.at(m_pName_ctrl.GetCurSel()); if(m_date.m_userInfo.GetId().empty()) { if(m_checkModal) CRuntimeMessageBox::RunMessageBox("请输入正确的入库人员"); else CRuntimeMessageBox::RunMessageBox("请输入正确的出库人员"); return; } m_telPhone_ctrl.GetWindowText(m_date.m_tellPhone); if(m_date.m_tellPhone.IsEmpty()) { CRuntimeMessageBox::RunMessageBox("请输入正确的电话号码"); return; } m_detail_ctrl.GetWindowText(m_date.m_detail); m_date.m_checkModal = m_checkModal; CControl_check tmpc; int haveNum = tmpc.VerCheckMaterial(m_date.m_material.GetId()) ; if( !m_checkModal && haveNum < m_date.m_num) { CRuntimeMessageBox::RunMessageBox("保存失败:此材料库存不足,无法出库!"); return; } else if( !m_checkModal) { m_date.m_num -= haveNum; } else { m_date.m_num += haveNum; } tmpc.SetData(&m_date); if (tmpc.Save()) { CRuntimeMessageBox::RunMessageBox("保存成功!"); OnOK(); } else { CRuntimeMessageBox::RunMessageBox("保存失败!"); } }
void Config::LoadRegistry() { // Get first time variable. CString version = ObjModelHelper::GetVersion(); if (version == "7.10") m_dsFirstTime = AfxGetApp()->GetProfileInt("Config", "VS710FirstTime", true) != 0; else if (version == "7.00") m_dsFirstTime = AfxGetApp()->GetProfileInt("Config", "VS700FirstTime", true) != 0; else if (version == "6") m_dsFirstTime = AfxGetApp()->GetProfileInt("Config", "DS6FirstTime", true) != 0; else if (version == "5") m_dsFirstTime = AfxGetApp()->GetProfileInt("Config", "DS5FirstTime", true) != 0; else if (version == "EVC") m_dsFirstTime = AfxGetApp()->GetProfileInt("Config", "EVC3FirstTime", true) != 0; const WWhizCommands::CommandInfo* comList = WWhizCommands::GetCommandList(); int comCount = WWhizCommands::GetCommandCount(); for (int i = 1; i < comCount; i++) { CString keyStr = AfxGetApp()->GetProfileString( "Config\\Keys", CString(comList[i].m_name), ""); if (keyStr.IsEmpty()) { // Grab the default. m_keys[i].m_keyStr = comList[i].m_keyStr; m_keys[i].m_assignKey = m_keys[i].m_keyStr.IsEmpty() != TRUE; } else { // Find the pipe symbol. int sepPos = keyStr.ReverseFind('|'); if (keyStr[sepPos + 1] == '1') m_keys[i].m_assignKey = true; else m_keys[i].m_assignKey = false; m_keys[i].m_keyStr = keyStr.Left(sepPos); } } m_useFindTagAtCursorDialog = AfxGetApp()->GetProfileInt("Config", "UseFindTagAtCursorDialog", 1) == 1; /////////////////////////////////////////////////////////////////////////// // Load WWhizInterface info. /////////////////////////////////////////////////////////////////////////// WWhizConfig& config = g_wwhizInterface->GetConfig(); // Read in the extension list. CString extStr = AfxGetApp()->GetProfileString("Config", "ExtensionList", ""); if (extStr.IsEmpty()) { config.FilesExtReset(); } else { config.FilesExtRemoveAll(); int curPos = 0; int nextPos; while (true) { // See if there is a comma. nextPos = extStr.Find(',', curPos); if (nextPos == -1) break; CString ext = extStr.Mid(curPos, nextPos - curPos); curPos = nextPos + 1; config.FilesExtAdd(ext); } CString lastExt = extStr.Mid(curPos); if (!lastExt.IsEmpty()) config.FilesExtAdd(extStr.Mid(curPos)); } // Read in the tags extension list. extStr = AfxGetApp()->GetProfileString("Config", "TagsExtensionList", ""); if (extStr.IsEmpty()) { config.TagsExtReset(); } else { config.TagsExtRemoveAll(); int curPos = 0; int nextPos; while (true) { // See if there is a comma. nextPos = extStr.Find(',', curPos); if (nextPos == -1) break; CString ext = extStr.Mid(curPos, nextPos - curPos); curPos = nextPos + 1; config.TagsExtAdd(ext); } CString lastExt = extStr.Mid(curPos); if (!lastExt.IsEmpty()) config.TagsExtAdd(extStr.Mid(curPos)); } // Read in the ignore tokens list. CString tokenStr = AfxGetApp()->GetProfileString("Config", "IgnoreTokensList", ""); if (tokenStr.IsEmpty()) { config.IgnoreTokensReset(); } else { config.IgnoreTokensRemoveAll(); int curPos = 0; int nextPos; while (true) { // See if there is a comma. nextPos = tokenStr.Find(',', curPos); if (nextPos == -1) break; CString token = tokenStr.Mid(curPos, nextPos - curPos); curPos = nextPos + 1; config.IgnoreTokensAdd(token); } CString lastToken = tokenStr.Mid(curPos); if (!lastToken.IsEmpty()) config.IgnoreTokensAdd(tokenStr.Mid(curPos)); } config.SetTagAutoPackAmount(AfxGetApp()->GetProfileInt("Config", "AutoPackTagsAmount", 1000)); config.SetAutoRefreshTags(AfxGetApp()->GetProfileInt("Config", "AutoRefreshTags", 1) == 1); config.SetScanFilesTaskSwitch(AfxGetApp()->GetProfileInt("Config", "ScanFilesTaskSwitch", 1) == 1); m_autoSaveAllPerTagCommand = AfxGetApp()->GetProfileInt("Config", "AutoSaveAllPerTagCommand", 1) == 1; config.SetTagAutoSaveAmount(AfxGetApp()->GetProfileInt("Config", "AutoSaveTagsAmount", 100)); }
BOOL CUpdaterDlg::OnInitDialog() { CDialog::OnInitDialog(); CSVPToolBox svpTool; CString szLangDefault = svpTool.GetPlayerPath( _T("lang\\default") ); CString szLangSeting; m_nLanguage = 0; BOOL langSeted = false; //get default lang setting if(svpTool.ifFileExist(szLangDefault)){ szLangSeting = svpTool.fileGetContent(szLangDefault); if(!szLangSeting.IsEmpty()){ m_nLanguage = _wtoi( szLangSeting ); langSeted = true; } } if(!langSeted){ switch(GetSystemDefaultLangID()){ //http://www.science.co.il/Language/Locale-Codes.asp?s=codepage case 0x0804: case 0x1004: case 0x1404: case 0x0c04: case 0x0404: //Chinese m_nLanguage = 0; break; default: m_nLanguage = 1; break; } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon prg_total.SetRange(0, 1000); HDC hdc = ::GetDC(NULL); double dDefaultSize = 22; double dIntroSize = 14; m_scale = (double)GetDeviceCaps(hdc, LOGPIXELSY) / 96.0; double scale = 1.0; ::ReleaseDC(0, hdc); m_hBigFont.m_hObject = NULL; if(!(::GetVersion()&0x80000000)){ m_hBigFont.CreateFont(int(dDefaultSize * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("Microsoft Sans Serif")); m_hIntroFont.CreateFont(int(dIntroSize * scale), 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("Microsoft Sans Serif")); } if(!m_hBigFont.m_hObject){ m_hBigFont.CreateFont(int(dDefaultSize * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("MS Sans Serif")); m_hIntroFont.CreateFont(int(dIntroSize * scale), 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("MS Sans Serif")); } tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = this->m_hWnd; tnid.uID = IDR_MAINFRAME; tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; tnid.uCallbackMessage = WM_NOTIFYICON; tnid.hIcon = this->m_hIcon; if(m_nLanguage ){ SetWindowText(L"SPlayer Updater"); csCurTask.SetWindowText(L"Current Task:"); csTotalProgress.SetWindowText(L"Total:"); szSpeed.SetWindowText(L"Speed:"); cb_stop.SetWindowText(L"Cancel"); cslink.SetWindowText(L"<a href=\"http://blog.splayer.org\">ChangeLog...</a>"); cszSizeTotal.SetWindowText(L"Size:"); cs_stat.SetWindowText(_T("This program will update lastest SPlayer, will exit automaticly after finished.")); csCurTask.SetWindowText(_T("Current Task: Calc...")); wcscpy_s(tnid.szTip, _T("SPlayer Auto Updater")); szaIntro.Add(L"SPlayer support DXVA、DXVA2、EVR"); szaIntro.Add(_T("SPlayer optimization of a variety of creative techniques, smooth playback. Maximize the efficiency are always our mission ")); szaIntro.Add(_T("SPlayer mainly focused on user experience")); szaIntro.Add(_T("SPlayer is an open source software ")); szaIntro.Add(_T("Designer Raven from Milan created a set of interfaces. Beautiful skin can let you feel more comfortable while playing")); szaIntro.Add(_T("SPlayer is world's smallest and most sophisticated players, complete installation package only 5M, still as powerful as ever ...")); szaIntro.Add(_T("SPlayer origin from MPCHC ffmpeg and thanks everyone with them")); szaIntro.Add(_T("SPlayer can download subtitle aotomaticely, you can disable it in setting panel if you want")); }else{ cs_stat.SetWindowText(_T("本程序下载最新版的射手播放器,将在更新完成后5分钟内退出")); csCurTask.SetWindowText(_T("当前任务:正在计算下载量")); wcscpy_s(tnid.szTip, _T("射手影音播放器自动更新程序")); szaIntro.Add(_T("只要在设置中启用“智能拖拽”,鼠标拖住画面就可以方便的改变画面比例")); szaIntro.Add(_T("在界面设置中可以设置自定义的背景界面")); szaIntro.Add(_T("射手播放器无需安装额外解码包即可全能解码")); szaIntro.Add(_T("免配置智能启用硬件高清加速:DXVA、DXVA2、EVR和CUDA")); szaIntro.Add(_T("十余种画面效果功能组合,全新的视频观赏体验。")); szaIntro.Add(_T("全自动网络字幕匹配。抛弃浏览器,也不必再收集。只要一人播放过且同意共享,全球华人都可在播放时得到恰好匹配影片的字幕。")); szaIntro.Add(_T("双字幕显示,同时显示中英双语,共同学习提高。")); szaIntro.Add(_T("绿色版免安装,同时支持海量视频格式,永不流氓!")); szaIntro.Add(_T("与众不同的字幕默认字体与颜色,对抗视觉疲劳。")); szaIntro.Add(_T("智能识别简体或繁体字幕。告别乱码,也不用再手动转码。")); szaIntro.Add(_T("自动减小英文字码,双语字幕更美观优雅。")); szaIntro.Add(_T("根据使用习惯优化右键菜单,方便快速切换字幕和显示模式。")); szaIntro.Add(_T("更加易用、精简的控制面板,更方便且易于理解的设置选项。")); szaIntro.Add(_T("自动升级随时更新最新版本、体验最新功能。")); szaIntro.Add(_T("射手播放器拥护GPL授权协议,是开源软件。")); } SetTimer(IDT_START_CHECK, 1000, NULL); Shell_NotifyIcon(NIM_ADD, &tnid); if(bHide){ ShowWindow(SW_MINIMIZE); ShowWindow(SW_HIDE); }else{ notYetShow = false; ShowWindow(SW_SHOW); ShowWindow(SW_RESTORE); } return FALSE; // return TRUE unless you set the focus to a control }
SSearchParams* CSearchParamsWnd::GetParameters() { CString strExpression; m_ctlName.GetWindowText(strExpression); strExpression.Trim(); if (!IsValidEd2kString(strExpression)){ AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + GetResString(IDS_SEARCH_INVALIDCHAR), MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } CStringA strFileType; int iItem = m_ctlFileType.GetCurSel(); if (iItem != CB_ERR) { LPCSTR pszED2KFileType = (LPCSTR)m_ctlFileType.GetItemDataPtr(iItem); ASSERT( pszED2KFileType != NULL ); strFileType = pszED2KFileType; } CString strMinSize = m_ctlOpts.GetItemText(orMinSize, 1); uint64 ullMinSize = GetSearchAttrSize(strMinSize); if (ullMinSize == (uint64)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orMinSize, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } CString strMaxSize = m_ctlOpts.GetItemText(orMaxSize, 1); uint64 ullMaxSize = GetSearchAttrSize(strMaxSize); if (ullMaxSize == (uint64)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orMaxSize, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } if (ullMaxSize < ullMinSize){ ullMaxSize = 0; // TODO: Create a message box for that m_ctlOpts.SetItemText(orMaxSize, 1, _T("")); } CString strExtension; if ((m_ctlOpts.GetItemData(orExtension) & 1) == 0) { strExtension = m_ctlOpts.GetItemText(orExtension, 1); strExtension.Trim(); if (!strExtension.IsEmpty() && strExtension[0] == _T('.')) { strExtension = strExtension.Mid(1); m_ctlOpts.SetItemText(orExtension, 1, strExtension); } } UINT uAvailability = 0; if ((m_ctlOpts.GetItemData(orAvailability) & 1) == 0) { CString strAvailability = m_ctlOpts.GetItemText(orAvailability, 1); uAvailability = GetSearchAttrNumber(strAvailability); if (uAvailability == (UINT)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orAvailability, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } else if (uAvailability > 1000000) { uAvailability = 1000000; strAvailability.Format(_T("%u"), uAvailability); m_ctlOpts.SetItemText(orAvailability, 1, strAvailability); } } UINT uComplete = 0; if ((m_ctlOpts.GetItemData(orCompleteSources) & 1) == 0) { CString strComplete = m_ctlOpts.GetItemText(orCompleteSources, 1); uComplete = GetSearchAttrNumber(strComplete); if (uComplete == (UINT)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orCompleteSources, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } else if (uComplete > 1000000) { uComplete = 1000000; strComplete.Format(_T("%u"), uComplete); m_ctlOpts.SetItemText(orCompleteSources, 1, strComplete); } } CString strCodec; if ((m_ctlOpts.GetItemData(orCodec) & 1) == 0) strCodec = m_ctlOpts.GetItemText(orCodec, 1); strCodec.Trim(); ULONG ulMinBitrate = 0; if ((m_ctlOpts.GetItemData(orBitrate) & 1) == 0) { CString strMinBitrate = m_ctlOpts.GetItemText(orBitrate, 1); ulMinBitrate = GetSearchAttrNumber(strMinBitrate); if (ulMinBitrate == (ULONG)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orBitrate, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } else if (ulMinBitrate > 1000000) { ulMinBitrate = 1000000; strMinBitrate.Format(_T("%u"), ulMinBitrate); m_ctlOpts.SetItemText(orBitrate, 1, strMinBitrate); } } ULONG ulMinLength = 0; if ((m_ctlOpts.GetItemData(orLength) & 1) == 0) { CString strMinLength = m_ctlOpts.GetItemText(orLength, 1); ulMinLength = GetSearchAttrLength(strMinLength); if (ulMinLength == (ULONG)-1) { CString strError; strError.Format(GetResString(IDS_SEARCH_ATTRERR), m_ctlOpts.GetItemText(orLength, 0)); AfxMessageBox(GetResString(IDS_SEARCH_EXPRERROR) + _T("\n\n") + strError, MB_ICONWARNING | MB_HELP, eMule_FAQ_Search - HID_BASE_PROMPT); return NULL; } else if (ulMinLength > 3600*24) { ulMinLength = 3600*24; CString strValue; SecToTimeLength(ulMinLength, strValue); m_ctlOpts.SetItemText(orLength, 1, strValue); } } SSearchParams* pParams = new SSearchParams; pParams->strExpression = strExpression; pParams->eType = (ESearchType)m_ctlMethod.GetCurSel(); pParams->strFileType = strFileType; pParams->strMinSize = strMinSize; pParams->ullMinSize = ullMinSize; pParams->strMaxSize = strMaxSize; pParams->ullMaxSize = ullMaxSize; pParams->uAvailability = uAvailability; pParams->strExtension = strExtension; //pParams->bMatchKeywords = IsDlgButtonChecked(IDC_MATCH_KEYWORDS)!=0; pParams->uComplete = uComplete; pParams->strCodec = strCodec; pParams->ulMinBitrate = ulMinBitrate; pParams->ulMinLength = ulMinLength; if ((m_ctlOpts.GetItemData(orTitle) & 1) == 0) { pParams->strTitle = m_ctlOpts.GetItemText(orTitle, 1); pParams->strTitle.Trim(); } if ((m_ctlOpts.GetItemData(orAlbum) & 1) == 0) { pParams->strAlbum = m_ctlOpts.GetItemText(orAlbum, 1); pParams->strAlbum.Trim(); } if ((m_ctlOpts.GetItemData(orArtist) & 1) == 0) { pParams->strArtist = m_ctlOpts.GetItemText(orArtist, 1); pParams->strArtist.Trim(); } return pParams; }
void CuDlgIjaTable::RefreshPaneTable(LPCTSTR lpszNode, LPCTSTR lpszDatabase, LPCTSTR lpszDatabaseOwner, LPCTSTR lpszTable, LPCTSTR lpszTableOwner) { CWaitCursor doWaitCursor; BOOL bCleanSession = FALSE; CString strOldNode = m_queryTransactionInfo.GetNode(); CString strOldDatabase; CString strOldDatabaseOwner; m_queryTransactionInfo.GetDatabase(strOldDatabase, strOldDatabaseOwner); if (!strOldNode.IsEmpty() && strOldNode.CompareNoCase(lpszNode)!=0) bCleanSession = TRUE; if (!strOldDatabase.IsEmpty() && strOldDatabase.CompareNoCase(lpszDatabase)!=0) bCleanSession = TRUE; if (bCleanSession) theApp.GetSessionManager().Cleanup(); m_queryTransactionInfo.SetNode (lpszNode); m_queryTransactionInfo.SetDatabase (lpszDatabase, lpszDatabaseOwner); m_queryTransactionInfo.SetTable (lpszTable, lpszTableOwner); m_bViewButtonClicked = FALSE; m_cButtonSelectAll.ShowWindow (SW_HIDE); m_cButtonRedo.ShowWindow (SW_HIDE); m_cButtonRecover.ShowWindow (SW_HIDE); m_cListCtrl.ShowWindow (SW_HIDE); CleanListCtrl(); SYSTEMTIME st; if (m_cDatePickerAfter.SendMessage (DTM_GETSYSTEMTIME, 0 , (LPARAM)&st) == GDT_VALID) { m_timeAfter = CTime(st); m_strAfter = toAuditdbInputDate(m_timeAfter); //m_timeAfter.Format (_T("%d-%m-%Y:%H:%M:%S")); } else m_strAfter = _T(""); if (m_cDatePickerBefore.SendMessage (DTM_GETSYSTEMTIME, 0 , (LPARAM)&st) == GDT_VALID) { m_timeBefore = CTime(st); m_strBefore = toAuditdbInputDate(m_timeBefore); //m_timeBefore.Format (_T("%d-%m-%Y:%H:%M:%S")); } else m_strBefore = _T(""); m_strAfter.MakeLower(); m_strBefore.MakeLower(); TRACE1 ("before: %s\n", m_strBefore); TRACE1 ("after : %s\n", m_strAfter); #if defined (SIMULATION) return; #endif // // Initialize the columns of the table as the list control header: while (!m_listColumn.IsEmpty()) delete m_listColumn.RemoveHead(); if (!IJA_QueryColumn (&m_queryTransactionInfo, m_listColumn)) { m_bColumnHeaderOK = FALSE; return; } m_bColumnHeaderOK = TRUE; LV_COLUMN lvcolumn; memset (&lvcolumn, 0, sizeof(lvcolumn)); lvcolumn.mask = LVCF_TEXT; while (m_cListCtrl.GetColumn (nHeader, &lvcolumn)) { // // Avoid looping for ever ! if (!m_cListCtrl.DeleteColumn(nHeader)) break; } BOOL bTextExtend = FALSE; CString strColum; SIZE size; CDC* pDC = m_cListCtrl.GetDC(); lvcolumn.mask = LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH; m_nColumnHeaderCount = m_listColumn.GetCount(); int nCount = 0; CaColumn* pColumn = NULL; POSITION pos = m_listColumn.GetHeadPosition(); while (pos != NULL) { pColumn = m_listColumn.GetNext (pos); strColum = pColumn->GetName(); lvcolumn.fmt = pColumn->IsColumnText()? LVCFMT_LEFT: LVCFMT_RIGHT; lvcolumn.pszText = (LPTSTR)(LPCTSTR)strColum; lvcolumn.iSubItem = nHeader + nCount; bTextExtend = GetTextExtentPoint32 (pDC->m_hDC, strColum, strColum.GetLength(), &size); lvcolumn.cx = (bTextExtend && size.cx > 40)? size.cx+32: 40 +32; m_cListCtrl.InsertColumn (lvcolumn.iSubItem, &lvcolumn); nCount++; } #if defined (SORT_INDICATOR) CHeaderCtrl* pHdrCtrl= m_cListCtrl.GetHeaderCtrl(); if (pHdrCtrl) { int i, nHeaderCount = pHdrCtrl->GetItemCount(); pHdrCtrl->SetImageList(&m_ImageListOrder); HD_ITEM curItem; for (i=0; i<nHeaderCount; i++) { pHdrCtrl->GetItem(i, &curItem); curItem.mask= HDI_IMAGE | HDI_FORMAT; curItem.iImage= -1; curItem.fmt= HDF_LEFT | HDF_IMAGE | HDF_STRING /*|HDF_BITMAP_ON_RIGHT*/; pHdrCtrl->SetItem(i, &curItem); } } #endif // SORT_INDICATOR }
void CRenameDlg::OnBnClickedButtonBrowseRef() { CString ext; CString path; if (!m_originalName.IsEmpty()) { CTGitPath origname(m_sBaseDir); origname.AppendPathString(m_originalName); ext = origname.GetFileExtension(); path = origname.GetWinPathString(); } if (CAppUtils::FileOpenSave(path, nullptr, AFX_IDD_FILESAVE, 0, false, GetSafeHwnd(), ext.Mid(1), !path.IsEmpty())) { GetDlgItem(IDC_NAME)->SetFocus(); CTGitPath target(path); CString targetRoot; if (!target.HasAdminDir(&targetRoot) || g_Git.m_CurrentDir.CompareNoCase(targetRoot) != 0) { CMessageBox::Show(GetSafeHwnd(), IDS_ERR_MUSTBESAMEWT, IDS_APPNAME, MB_OK | MB_ICONEXCLAMATION); return; } CString relPath; m_sBaseDir.Replace(L"/", L"\\"); if (!PathRelativePathTo(CStrBuf(relPath, MAX_PATH), m_sBaseDir, FILE_ATTRIBUTE_DIRECTORY, path, FILE_ATTRIBUTE_DIRECTORY)) return; if (CStringUtils::StartsWith(relPath, L".\\")) relPath = relPath.Mid(static_cast<int>(wcslen(L".\\"))); m_name = relPath; UpdateData(FALSE); } }
bool CUserInfoSession::OnProcessMessage (const SArchonMessage &Msg) // OnProcessMessage // // We received a reply from Aeon { int i; // If this is an error, then we return the error back to the client if (IsError(Msg)) { SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, Msg.dPayload); return false; } // If we're waiting for the user record, then see if we can process it now. if (m_iState == stateWaitingForUserRecord) { // If we get back nil then the user does not exist. if (Msg.dPayload.IsNil()) { SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, strPattern(ERR_UNKNOWN_USERNAME, m_sUsername)); return false; } // Otherwise, we handle the result based on the original message else if (strEquals(GetOriginalMsg().sMsg, MSG_CRYPTOSAUR_CHECK_PASSWORD_SHA1)) { // Get the parameters from the original message CDatum dChallenge = GetOriginalMsg().dPayload.GetElement(1); CDatum dResponse = GetOriginalMsg().dPayload.GetElement(2); // Get the password has from the response CDatum dAuthDesc = Msg.dPayload.GetElement(FIELD_AUTH_DESC); CDatum dPasswordHash = dAuthDesc.GetElement(FIELD_CREDENTIALS); // Create a response to the challenge based on the password hash that // we have stored. CDatum dCorrect = CAI1Protocol::CreateSHAPasswordChallengeResponse(dPasswordHash, dChallenge); // Compare the correct response to the actual if ((const CIPInteger &)dResponse == (const CIPInteger &)dCorrect) return UpdateLoginSuccess(stateWaitingForSuccessUpdate); else return UpdateLoginFailure(); } // Cryptosaur.getUser else if (strEquals(GetOriginalMsg().sMsg, MSG_CRYPTOSAUR_GET_USER)) { CDatum dUserData = Msg.dPayload; if (dUserData.IsNil()) { SendMessageReply(MSG_REPLY_DATA, CDatum()); return false; } // Generate a sanitized user record CComplexStruct *pReply = new CComplexStruct; pReply->SetElement(FIELD_USERNAME, dUserData.GetElement(FIELD_USERNAME)); // Sanitize rights CDatum dRights = dUserData.GetElement(FIELD_RIGHTS); if (!m_sScope.IsEmpty()) { CComplexArray *pRights = new CComplexArray; for (i = 0; i < dRights.GetCount(); i++) if (strStartsWith(dRights.GetElement(i), m_sScope)) pRights->Insert(dRights.GetElement(i)); pReply->SetElement(FIELD_RIGHTS, CDatum(pRights)); } else pReply->SetElement(FIELD_RIGHTS, dRights); // Done SendMessageReply(MSG_REPLY_DATA, CDatum(pReply)); return false; } // Cryptosaur.hasRights else if (strEquals(GetOriginalMsg().sMsg, MSG_CRYPTOSAUR_HAS_RIGHTS)) { CDatum dRights = Msg.dPayload.GetElement(FIELD_RIGHTS); CDatum dRightsRequired = m_dPayload.GetElement(1); // Get the rights from the user CAttributeList Rights; dRights.AsAttributeList(&Rights); // Check for (i = 0; i < dRightsRequired.GetCount(); i++) { if (!Rights.HasAttribute(dRightsRequired.GetElement(i))) { SendMessageReply(MSG_REPLY_DATA, CDatum()); return false; } } // We have all rights SendMessageReply(MSG_REPLY_DATA, CDatum(CDatum::constTrue)); return false; } // Cryptosaur.loginUser else if (strEquals(GetOriginalMsg().sMsg, MSG_CRYPTOSAUR_LOGIN_USER)) { // Get the parameters from the original message CDatum dRequestAuthDesc = GetOriginalMsg().dPayload.GetElement(1); CDatum dCredentials = dRequestAuthDesc.GetElement(FIELD_CREDENTIALS); CDatum dChallengeCredentials = dRequestAuthDesc.GetElement(FIELD_CHALLENGE_CREDENTIALS); CDatum dPassword = dRequestAuthDesc.GetElement(FIELD_PASSWORD); m_bActual = !dRequestAuthDesc.GetElement(FIELD_ACTUAL).IsNil(); if (!dRequestAuthDesc.GetElement(FIELD_AUTH_TOKEN_INFINITE).IsNil()) m_dwAuthTokenLifetime = 0; else { m_dwAuthTokenLifetime = (DWORD)(int)dRequestAuthDesc.GetElement(FIELD_AUTH_TOKEN_LIFETIME); if (m_dwAuthTokenLifetime == 0) m_dwAuthTokenLifetime = DEFAULT_AUTH_TOKEN_TIMEOUT; } // If we're not actual and have no scope, then we can't continue if (!m_bActual && m_sScope.IsEmpty()) { SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_SCOPE_REQUIRED); return false; } // User data CDatum dUserData = Msg.dPayload; CDatum dAuthDesc; if (m_bActual) dAuthDesc = dUserData.GetElement(FIELD_AUTH_DESC); else dAuthDesc = dUserData.GetElement(strPattern("%s%s", m_sScope, FIELD_AUTH_DESC)); // If we have no authdesc, then we can't continue. This is likely // because the client is in a sandbox that the user has not registered // with. We treat it the same as a username/password failure. if (dAuthDesc.IsNil()) { SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_INVALID_USERNAME_OR_PASSWORD); return false; } // If we've failed more than 5 consecutive times, we may need to delay // the next login attempt. if ((int)dUserData.GetElement(FIELD_LOGIN_FAILURE_COUNT) > MAX_LOGIN_ATTEMPTS) { CDateTime LastLoginFailure = dUserData.GetElement(FIELD_LAST_LOGIN_FAILURE_ON); CTimeSpan TimeSinceLastFailure = timeSpan(LastLoginFailure, CDateTime(CDateTime::Now)); // If it has not been at least 1 hour, we return an error. if (TimeSinceLastFailure.Days() == 0 && TimeSinceLastFailure.Seconds() < LOGIN_TIMEOUT) { // Timeout SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_FAILURE_TIMEOUT); return false; } } // If we have straight credentials, then just compare bool bSuccess; if (!dCredentials.IsNil()) bSuccess = ((const CIPInteger &)dCredentials == (const CIPInteger &)dAuthDesc.GetElement(FIELD_CREDENTIALS)); // Otherwise, we compare against the challenge else if (!dChallengeCredentials.IsNil()) { // Get the challenge. If not provided then we get it from the user // record. CDatum dChallenge = GetOriginalMsg().dPayload.GetElement(2); if (dChallenge.IsNil()) { // Get the expiration time of the challenge const CDateTime &Expires = dAuthDesc.GetElement(FIELD_CHALLENGE_EXPIRATION); if (Expires < CDateTime(CDateTime::Now)) { SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_INVALID_USERNAME_OR_PASSWORD); return false; } dChallenge = dAuthDesc.GetElement(FIELD_CHALLENGE); } // Create a response to the challenge based on the password hash that // we have stored. CDatum dCorrectChallenge = CAI1Protocol::CreateSHAPasswordChallengeResponse( dAuthDesc.GetElement(FIELD_CREDENTIALS), dChallenge ); bSuccess = ((const CIPInteger &)dChallengeCredentials == (const CIPInteger &)dCorrectChallenge); } // Otherwise we expect a clear text password else if (!dPassword.IsNil()) { // We have to hash the password to compare with credentials. CIPInteger Credentials; CCryptosaurInterface::CreateCredentials(dUserData.GetElement(FIELD_USERNAME), dPassword, &Credentials); // Compare bSuccess = (Credentials == (const CIPInteger &)dAuthDesc.GetElement(FIELD_CREDENTIALS)); } else bSuccess = false; // Success or failure if (bSuccess) return UpdateLoginSuccess(stateWaitingForCredentials); else return UpdateLoginFailure(); } // Can never get here. else { ASSERT(false); return false; } } // Otherwise, if we're waiting for the user record update, then continue else if (m_iState == stateWaitingForSuccessUpdate) { // Since we succeeded, we send the user sanitized user record back. SendMessageReply(MSG_REPLY_DATA, CreateSanitizedUserRecord(Msg.dPayload)); return false; } // If we're waiting for credentials, compose them else if (m_iState == stateWaitingForCredentials) { // The mutation returns the full record CDatum dUserData = Msg.dPayload; // Compute the result CComplexStruct *pAuthToken = new CComplexStruct; pAuthToken->SetElement(FIELD_USERNAME, dUserData.GetElement(FIELD_USERNAME)); pAuthToken->SetElement(FIELD_RIGHTS, dUserData.GetElement(FIELD_RIGHTS)); if (!m_bActual) pAuthToken->SetElement(FIELD_SCOPE, m_sScope); CDatum dAuthToken = m_pEngine->GenerateAuthToken(CDatum(pAuthToken), m_dwAuthTokenLifetime); // Compose a basic user record CComplexStruct *pReply = new CComplexStruct; pReply->SetElement(FIELD_AUTH_TOKEN, dAuthToken); pReply->SetElement(FIELD_RIGHTS, dUserData.GetElement(FIELD_RIGHTS)); pReply->SetElement(FIELD_USERNAME, dUserData.GetElement(FIELD_USERNAME)); // Send the reply SendMessageReply(MSG_REPLY_DATA, CDatum(pReply)); // Done return false; } // Otherwise, failure else if (m_iState == stateWaitingForFailureUpdate) { CDatum dUserData = Msg.dPayload; // If we've exceeded our limit, log it int iAttempts = (int)dUserData.GetElement(FIELD_LOGIN_FAILURE_COUNT); if (iAttempts > MAX_LOGIN_ATTEMPTS) GetProcessCtx()->Log(MSG_LOG_INFO, strPattern(ERR_USERNAME_TIMEOUT, m_sUsername, iAttempts)); // Send a failure SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_INVALID_USERNAME_OR_PASSWORD); return false; } // Can never get here else { ASSERT(false); return false; } }
// 15.12.05 SIS >> // added parameter crstrIndex // to save index range bool CCeWatchElement::SaveToNode(CXMLNode& rtNode, CXMLDocument& rtDocument, const CString& crstrIndexRange) // 15.12.05 SIS << { bool bReturn = true; // don't forget to increment the version string if you change anything here CString str; if(m_bInitExpanded) { rtNode.SetAttribute(CEWATCH_XMLATTR_EXPANDED, _T("1")); } CString strExpression = m_Name; if(!crstrIndexRange.IsEmpty()) { strExpression.Format(_T("%s, %s"), m_Name, crstrIndexRange); } rtNode.SetAttribute(CEWATCH_XMLATTR_EXPRESSION, strExpression); if (m_Type.GetName().GetLength() > 0) { str.Format("%s;%d", m_Type.GetName(), (int)m_Type.GetVarKind()); rtNode.SetAttribute(CEWATCH_XMLATTR_TYPE, str); } rtNode.SetAttribute(CEWATCH_XMLATTR_VALUE, m_strValue); if (m_strFormat.GetLength() > 0) { rtNode.SetAttribute(CEWATCH_XMLATTR_FORMAT, m_strFormat); } // #2149 10.10.06 SIS >> // only save visible array elements int iNumChildren = GetChildrenCount(); int iChildStart = 0; int iChildStop = iNumChildren-1; if(m_Type.IsArray()) { VERIFY(ExtractArrayIndices(crstrIndexRange, iChildStart, iChildStop)); iChildStart = max(iChildStart - m_Type.GetArrayLowerBound(), 0); iChildStop = min(iChildStop - m_Type.GetArrayLowerBound(), iNumChildren-1); } CCeWatchElement* pElem = NULL; for (int iChild = iChildStart; iChild <= iChildStop; iChild++) // #2149 10.10.06 SIS << { CXMLNode tNodeChild; if(rtDocument.CreateNode(tNodeChild, CEWATCH_XMLTAG_VARNODE)) { pElem = GetChild(iChild); if(!pElem) { break; } bReturn &= pElem->SaveToNode(tNodeChild, rtDocument, _T("")); if(!bReturn) { break; } rtNode.AppendChild(tNodeChild); } } return bReturn; }
void CGnuLocal::OnReceive(int nErrorCode) { byte buffer[1024]; CString Host, LocalHost, NetworkPing, NetworkPong; CString LanName, IRCAddr, InfoURL; UINT Port, LocalPort, Leaves = 0; int buffLength = ReceiveFrom(buffer, 1024, Host, Port); GetSockName(LocalHost, LocalPort); // Handle Errors if(!buffLength || buffLength == SOCKET_ERROR) return; CString strBuffer((char*) buffer, 128); NetworkPing = m_pComm->m_NetworkName; NetworkPing += " PING\r\n"; NetworkPong = m_pComm->m_NetworkName; NetworkPong += " PONG\r\n"; // Handle Ping over LAN if(strBuffer.Find(NetworkPing) == 0) { if(Host == LocalHost) { m_pCore->LogError("UDP: Ping received from localhost"); //return; } // Send back pong only if not a leaf NetworkPong += "Port: " + NumtoStr(m_pNet->m_CurrentPort) + "\r\n"; if(m_pPrefs->m_LanMode) { NetworkPong += "LAN: " + m_pPrefs->m_LanName + "\r\n"; CString RandCache = m_pComm->m_pCache->GetRandWebCache(true); if(!RandCache.IsEmpty()) NetworkPing += "WebCache: " + RandCache + "\r\n"; } // Leaves header if(m_pComm->m_GnuClientMode ==GNU_ULTRAPEER) { int Leaves = m_pComm->CountLeafConnects(); if(Leaves) NetworkPong += "Leaves: " + NumtoStr(Leaves) + "\r\n"; } NetworkPong += "\r\n"; int pos = strBuffer.Find("\r\nPort: "); if(pos != -1) { pos += 2; sscanf((char*)buffer + pos, "Port: %d\r\n", &Port); } SendTo(NetworkPong, NetworkPong.GetLength(), UDP_PORT, Host); m_pCore->LogError("UDP: Pong Sent to " + Host + ":" + NumtoStr(Port)); } // Extract Data from ping/pong if(strBuffer.Find(NetworkPing) == 0 || strBuffer.Find(NetworkPong) == 0) { int pos, backpos; pos = strBuffer.Find("\r\nPort: "); if(pos != -1) { pos += 2; sscanf((char*)buffer + pos, "Port: %d\r\n", &Port); } pos = strBuffer.Find("\r\nLAN: "); if(pos != -1) { pos += 2; backpos = strBuffer.Find("\r\n", pos); LanName = strBuffer.Mid(pos + 5, backpos - pos - 5); } pos = strBuffer.Find("\r\nWebCache: "); if(pos != -1) { pos += 2; backpos = strBuffer.Find("\r\n", pos); CString NewWebCache = strBuffer.Mid(pos + 10, backpos - pos - 10); m_pComm->m_pCache->WebCacheAddCache(NewWebCache); } pos = strBuffer.Find("\r\nIRC: "); if(pos != -1) { pos += 2; backpos = strBuffer.Find("\r\n", pos); IRCAddr = strBuffer.Mid(pos + 5, backpos - pos - 5); } pos = strBuffer.Find("\r\nInfoURL: "); if(pos != -1) { pos += 2; backpos = strBuffer.Find("\r\n", pos); InfoURL = strBuffer.Mid(pos + 9, backpos - pos - 9); } pos = strBuffer.Find("\r\nLeaves: "); if(pos != -1) { pos += 2; backpos = strBuffer.Find("\r\n", pos); Leaves = atoi( strBuffer.Mid(pos + 8, backpos - pos - 8) ); } } // Handle Pong over LAN if(strBuffer.Find(NetworkPong) == 0) { CString Extra; if(Leaves) Extra = " with " + NumtoStr(Leaves) + " leaves"; m_pCore->LogError("UDP: Pong Received from " + Host + ":" + NumtoStr(Port) + Extra); } std::map<int, LanNode>::iterator itNode; for(itNode = m_LanNodeIDMap.begin(); itNode != m_LanNodeIDMap.end(); itNode++) if( itNode->second.Host == Host && itNode->second.Port == Port) return; LanNode LocalNode; LocalNode.Host = Host; LocalNode.Port = Port; LocalNode.Name = LanName; LocalNode.IRCserver = IRCAddr; LocalNode.InfoPage = InfoURL; LocalNode.Leaves = Leaves; int LanNodeID = m_NextLanID++; m_LanNodeIDMap[LanNodeID] = LocalNode; // If we're not in lan mode, just add to cache if(!m_pPrefs->m_LanMode) { Node PermNode; PermNode.Host = Host; PermNode.Port = Port; if(PermNode.Host != LocalHost) m_pComm->m_pCache->m_GnuPerm.push_back(PermNode); } CAsyncSocket::OnReceive(nErrorCode); }
void CuListCtrlLoggedEvent::NewMessageNewState (CaMessageNode* pNodeTarget, CaLoggedEvent* pMsg, CTreeCtrl* pTree) { CaMessageManager* pMsgEntry = m_pEventSettingFrame->GetMessageManager(); CaMessageNodeTree* pNewMessageNodeTree = NULL; CaMessageNodeInfo& nodeInfo = pNodeTarget->GetNodeInformation(); MSGSourceTarget t = nodeInfo.GetMsgSourceTarget(); HTREEITEM hParent = pTree->GetParentItem(nodeInfo.GetHTreeItem()); ASSERT (hParent); if (!hParent) return; CaMessageNode* pNodeParent = (CaMessageNode*)pTree->GetItemData(hParent); ASSERT (pNodeParent && pNodeParent->IsInternal()); if (!pNodeParent || (pNodeParent && !pNodeParent->IsInternal())) return; CaMessageNodeTreeInternal* pI = NULL; int nIdx = -1; CaMessageNode* pObj = NULL; POSITION pos = NULL; CString strItem; CString strPath = _T(""); CString strTemp = _T(""); CaTreeMessageCategory& treeCategoryView = m_pEventSettingFrame->GetTreeCategoryView(); CTypedPtrList<CObList, CaMessageNode*>* pLs = treeCategoryView.GetListSubNode(); CaMessage* pMessage = NULL; Imsgclass nClass = IMSG_NOTIFY; switch (t) { case SV_FA: case SV_UFA: case CV_UFA: nClass = IMSG_ALERT; break; case SV_FN: case SV_UFN: case CV_UFN: nClass = IMSG_NOTIFY; break; case SV_FD: case SV_UFD: case CV_UFD: nClass = IMSG_DISCARD; break; } switch (t) { case CV_UFA: case CV_UFN: case CV_UFD: if (!pNodeTarget->GetNodeInformation().GetHTreeItem()) break; hParent = pTree->GetParentItem(pNodeTarget->GetNodeInformation().GetHTreeItem()); pNodeParent = (CaMessageNode*)pTree->GetItemData(hParent); ASSERT (pNodeParent && pNodeParent->IsInternal()); if (!(pNodeParent && pNodeParent->IsInternal())) break; pI = (CaMessageNodeTreeInternal*)pNodeParent; pNewMessageNodeTree = CreateMessageNode(pMsgEntry, pMsg); if (!pNewMessageNodeTree) break; pMessage = pNewMessageNodeTree->GetMessageCategory(); if (pMessage) pMessage->SetClass (nClass); pI->AddMessage (pNewMessageNodeTree); pTree->GetParent()->SendMessage (WMUSRMSG_IVM_PAGE_UPDATING, 0, 0); GetParent()->SendMessage (WMUSRMSG_IVM_PAGE_UPDATING, (WPARAM)pMsg->GetCatType(), (LPARAM)pMsg->GetCode()); break; case SV_FA: // Ex: <Alert> case SV_UFA: // Ex: <Alert>\Folder1\Folder2 case SV_FN: case SV_UFN: case SV_FD: case SV_UFD: // // Find the equivalent path in the right tree: switch (pNodeTarget->GetNodeInformation().GetMsgSourceTarget() ) { case SV_UFA: case SV_UFN: case SV_UFD: strPath = pNodeTarget->GetNodeInformation().GetNodeTitle(); break; } while (pNodeParent->GetNodeInformation().GetMsgSourceTarget() != SV_R) { switch (pNodeParent->GetNodeInformation().GetMsgSourceTarget()) { case SV_UFA: case SV_UFN: case SV_UFD: strTemp = pNodeParent->GetNodeInformation().GetNodeTitle(); if (!strPath.IsEmpty()) strTemp += _T("/"); strTemp += strPath; strPath = strTemp; } hParent = pTree->GetParentItem(pNodeParent->GetNodeInformation().GetHTreeItem()); pNodeParent = (CaMessageNode*)pTree->GetItemData(hParent); } if (!pLs) break; strItem = strPath; nIdx = strPath.Find (_T('/')); if (nIdx != -1) { strItem = strPath.Left(nIdx); strPath = strPath.Mid (nIdx +1); } if (strItem.IsEmpty()) { pI = (CaMessageNodeTreeInternal*)&treeCategoryView; pNewMessageNodeTree = CreateMessageNode(pMsgEntry, pMsg); if (!pNewMessageNodeTree) break; pMessage = pNewMessageNodeTree->GetMessageCategory(); if (pMessage) pMessage->SetClass (nClass); pI->AddMessage (pNewMessageNodeTree); CvEventSettingRight* pRview = m_pEventSettingFrame->GetRightView(); (pRview->GetDialog())->SendMessage (WMUSRMSG_IVM_PAGE_UPDATING, 0, 0); GetParent()->SendMessage ( WMUSRMSG_IVM_PAGE_UPDATING, (WPARAM)pMsg->GetCatType(), (LPARAM)pMsg->GetCode()); break; } pos = pLs->GetHeadPosition(); while (pos != NULL) { pObj = pLs->GetNext (pos); if (pObj->GetNodeInformation().GetNodeTitle() != strItem) continue; ASSERT (pObj->IsInternal()); pI = (CaMessageNodeTreeInternal*)pObj; if (nIdx != -1) { strItem = strPath; nIdx = strPath.Find (_T('/')); if (nIdx != -1) { strItem = strPath.Left(nIdx); strPath = strPath.Mid (nIdx +1); } pLs = pI->GetListSubNode(); pos = pLs->GetHeadPosition(); } else { pNewMessageNodeTree = CreateMessageNode(pMsgEntry, pMsg); if (!pNewMessageNodeTree) break; pMessage = pNewMessageNodeTree->GetMessageCategory(); if (pMessage) pMessage->SetClass (nClass); pI->AddMessage (pNewMessageNodeTree); CvEventSettingRight* pRview = m_pEventSettingFrame->GetRightView(); (pRview->GetDialog())->SendMessage (WMUSRMSG_IVM_PAGE_UPDATING, 0, 0); GetParent()->SendMessage ( WMUSRMSG_IVM_PAGE_UPDATING, (WPARAM)pMsg->GetCatType(), (LPARAM)pMsg->GetCode()); } } break; default: break; } }
BOOL CTorrentBuilder::WriteOutput() { CBENode pRoot; if ( m_sTracker.GetLength() > 15 ) { CBENode* pAnnounce = pRoot.Add( "announce" ); pAnnounce->SetString( m_sTracker ); } if ( m_sTracker2.GetLength() > 15 && m_sTracker2 != m_sTracker ) { // Rough implementation. ToDo: Cleanup for more trackers CBENode* pAnnounceList = pRoot.Add( "announce-list" ); { BYTE* pBuffer = NULL; // Quick List Workaround CBENode* pList1 = pAnnounceList->Add( pBuffer, 1 ); { CBENode* pAnnounce = pList1->Add( pBuffer, 2 ); pAnnounce->SetString( m_sTracker ); } CBENode* pList2 = pAnnounceList->Add( pBuffer, 1 ); { CBENode* pAnnounce = pList2->Add( pBuffer, 2 ); pAnnounce->SetString( m_sTracker2 ); } } } { CBENode* pDate = pRoot.Add( "creation date" ); pDate->SetInt( (QWORD)time( NULL ) ); } { CBENode* pDate = pRoot.Add( "encoding" ); pDate->SetString( _T("UTF-8") ); } CBENode* pInfo = pRoot.Add( "info" ); { CBENode* pPL = pInfo->Add( "piece length" ); pPL->SetInt( m_nPieceSize ); } { CSHA::Digest* pPieceSHA1 = new CSHA::Digest[ m_nPieceCount ]; for ( DWORD i = 0 ; i < m_nPieceCount; ++i ) m_pPieceSHA1[ i ].GetHash( (uchar*)&pPieceSHA1[ i ][ 0 ] ); CBENode* pPieces = pInfo->Add( "pieces" ); pPieces->SetString( pPieceSHA1, m_nPieceCount * sizeof CSHA::Digest ); delete [] pPieceSHA1; } if ( m_bSHA1 ) { CSHA::Digest pDataSHA1; m_oDataSHA1.GetHash( (uchar*)&pDataSHA1[ 0 ] ); CBENode* pSHA1 = pInfo->Add( "sha1" ); pSHA1->SetString( &pDataSHA1, sizeof CSHA::Digest ); } if ( m_bED2K ) { CMD4::Digest pDataED2K; m_oDataED2K.GetRoot( (uchar*)&pDataED2K[ 0 ] ); CBENode* pED2K = pInfo->Add( "ed2k" ); pED2K->SetString( &pDataED2K, sizeof CMD4::Digest ); } if ( m_bMD5 ) { CMD5::Digest pDataMD5; m_oDataMD5.GetHash( (uchar*)&pDataMD5[ 0 ] ); CBENode* pMD5 = pInfo->Add( "md5sum" ); pMD5->SetString( &pDataMD5, sizeof CMD5::Digest ); } CString strFirst = m_pFiles.GetHead(); if ( m_pFiles.GetCount() == 1 ) { const int nPos = strFirst.ReverseFind( '\\' ); if ( nPos >= 0 ) strFirst = strFirst.Mid( nPos + 1 ); { CBENode* pName = pInfo->Add( "name" ); pName->SetString( strFirst ); } { CBENode* pLength = pInfo->Add( "length" ); pLength->SetInt( m_nTotalSize ); } } else { { CBENode* pName = pInfo->Add( "name" ); pName->SetString( m_sName ); } CBENode* pFiles = pInfo->Add( "files" ); int nCommonPath = 32000; int nFile = 0; POSITION pos = m_pFiles.GetHeadPosition(); for ( ; pos ; nFile++ ) { CString strThis = m_pFiles.GetNext( pos ); if ( nFile == 0 ) continue; LPCTSTR pszFirst = strFirst; LPCTSTR pszThis = strThis; for ( int nPos = 0, nSlash = 0 ; nPos < nCommonPath ; nPos++ ) { if ( pszThis[nPos] != pszFirst[nPos] || pszThis[nPos] == 0 || pszFirst[nPos] == 0 ) { nCommonPath = nSlash; break; } else if ( pszThis[nPos] == '\\' ) { nSlash = nPos; } } } nCommonPath ++; pos = m_pFiles.GetHeadPosition(); for ( nFile = 0 ; pos ; nFile++ ) { CString strFile = m_pFiles.GetNext( pos ); CBENode* pFile = pFiles->Add( NULL, NULL ); { CBENode* pLength = pFile->Add( "length" ); pLength->SetInt( m_pFileSize[ nFile ] ); } { CBENode* pPath = pFile->Add( "path" ); strFile = strFile.Mid( nCommonPath ); while ( ! strFile.IsEmpty() ) { CString strPart = strFile.SpanExcluding( _T("\\/") ); if ( strPart.IsEmpty() ) break; pPath->Add( NULL, NULL )->SetString( strPart ); strFile = strFile.Mid( strPart.GetLength() ); if ( ! strFile.IsEmpty() ) strFile = strFile.Mid( 1 ); } } if ( m_bSHA1 ) { CSHA::Digest pFileSHA1; m_pFileSHA1[ nFile ].GetHash( (uchar*)&pFileSHA1[ 0 ] ); CBENode* pSHA1 = pFile->Add( "sha1" ); pSHA1->SetString( &pFileSHA1, sizeof CSHA::Digest ); } if ( m_bED2K ) { CMD4::Digest pFileED2K; m_pFileED2K[ nFile ].GetRoot( (uchar*)&pFileED2K[ 0 ] ); CBENode* pED2K = pFile->Add( "ed2k" ); pED2K->SetString( &pFileED2K, sizeof CMD4::Digest ); } if ( m_bMD5 ) { CMD5::Digest pFileMD5; m_pFileMD5[ nFile ].GetHash( (uchar*)&pFileMD5[ 0 ] ); CBENode* pMD5 = pFile->Add( "md5sum" ); pMD5->SetString( &pFileMD5, sizeof CMD5::Digest ); } } } { CBENode* pAgent = pRoot.Add( "created by" ); CString strAgent = _T("PeerProject Wizard ") + theApp.m_sVersion; pAgent->SetString( strAgent ); } if ( ! m_sComment.IsEmpty() ) { CBENode* pComment = pRoot.Add( "comment" ); pComment->SetString( m_sComment ); } CBuffer pOutput; pRoot.Encode( &pOutput ); const CString strOutput = ( m_sOutput.GetLength() < MAX_PATH ) ? m_sOutput : ( CString( _T("\\\\?\\") ) + m_sOutput ); HANDLE hFile = CreateFile( strOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if ( hFile == INVALID_HANDLE_VALUE ) { CString strFormat; strFormat.LoadString( IDS_BUILDER_CANT_SAVE ); m_pSection.Lock(); m_sMessage.Format( strFormat, (LPCTSTR)m_sOutput ); m_bAbort = TRUE; m_pSection.Unlock(); return FALSE; } DWORD nWrote = 0; WriteFile( hFile, pOutput.m_pBuffer, pOutput.m_nLength, &nWrote, NULL ); CloseHandle( hFile ); return TRUE; }
void CClientListCtrl::DoClientspecNew(BOOL bUseDefTemplate, LPCTSTR defName ) { MainFrame()->ViewClients(); m_ClientNew.Empty(); m_OldClient= GET_P4REGPTR()->GetP4Client(); // let user type in the new name. if it's blank the user bailed. // CNewClientDlg newdlg; newdlg.SetNew( NEWCLIENT ); if (FindInListAll(m_Active) != -1) newdlg.m_Active = m_Active; if (defName) newdlg.m_Name = defName; if( newdlg.DoModal( ) == IDCANCEL ) return; if (newdlg.m_RunWizard) { CString txt; CString port = GET_P4REGPTR()->GetP4Port(); CString clientname = newdlg.GetName(); txt.FormatMessage( IDS_NOCLIENT_s_s_s, clientname, port, GET_P4REGPTR()->GetP4User() ); int i; if ((i = txt.Find(_T('\n'))) != -1) { txt = txt.Mid(i); txt.TrimLeft(); } CClientWizSheet dlg(LoadStringResource(IDS_CLIENTWORKSPACEWIZARD), this, 1); dlg.SetMsg(txt); dlg.SetName(clientname); dlg.SetPort(port); dlg.AllowBrowse(FALSE); int rc; while(1) { if( (rc = dlg.DoModal()) == IDCANCEL ) // user bailed { break; } if ( rc == IDIGNORE ) // user chose to browse existing clients { ViewUpdate(); break; } else // user clicked the Finish button on the create client page { CString newClient = dlg.GetName(); CString newRoot = dlg.GetRoot(); BOOL bEdit = dlg.IsEdit(); BOOL bTmpl = dlg.IsTmpl(); CString tmplate = dlg.GetTmpl(); while (m_UpdateState == LIST_UPDATING) Sleep(100); if (FindInListAll(newClient) != -1) { CString msg; msg.FormatMessage(IDS_CANT_RECREATE_EXISTING_CLIENT_s, newClient); AfxMessageBox( msg, MB_ICONSTOP ); } else if (!newClient.IsEmpty() && !newRoot.IsEmpty()) { if (AutoCreateClientSpec(newClient, newRoot, bEdit, bTmpl, tmplate)) break;; } } } return; } CString saveActive = m_Active; m_Active = newdlg.GetName( ) ; if ( m_Active.IsEmpty( ) ) return; if ( SetP4Client( TRUE ) ) { // rather than use the current directory as the default client root // switch to the drive's root and use that; switch back at the end. TCHAR buf[MAX_PATH+1]; TCHAR root[4]; if (GetCurrentDirectory(MAX_PATH, buf)) { _tcsncpy(root, buf, 3); root[3] = '\0'; SetCurrentDirectory(root); } else { buf[0] = _T('\0'); } // Get the edit of the new spec underway m_NewClient = (saveActive != m_Active); m_NewClicked = TRUE; OnEditSpec( m_Active, bUseDefTemplate ); m_ClientNew = m_Active; // restore previous working directory if (buf[0]) SetCurrentDirectory(buf); } }
void CStartupView::CreateWelcomeButtons() { BOOL bCreationSucces=FALSE; CMainFrameA* pMainFrame = CMainFrameA::GetCurrentInstance();; CRect rcButton; rcButton.SetRect(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT); CString csTitle; // Record PowerPoint button /*CString csPrefix = _T(""); csPrefix.LoadString(IDS_RECORD);*/ csTitle.LoadString(IDS_POWERPOINT); //csTitle = csPrefix + _T(" ") + csTitle; if (csTitle.IsEmpty() == false) { bCreationSucces = m_btnRecordPowerPoint.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, IDC_RECORDPOWERPOINT); } if (bCreationSucces==TRUE) { SetButtonImage(&m_btnRecordPowerPoint, IDR_RECORD_PPT, CSize(32,32)); SetButtonStyle(&m_btnRecordPowerPoint, xtThemeOffice2003, BS_XT_XPFLAT, &m_btnFont14, RGB(255, 255, 255)); } // Record Other button csTitle.LoadString(IDS_OTHERAPP); //csTitle = csPrefix + _T(" ") + csTitle; bCreationSucces = m_btnRecordOther.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, ID_START_RECORDING_STARTUP_PAGE); if (bCreationSucces == TRUE) { SetButtonImage(&m_btnRecordOther,IDR_RECORD_OTHER, CSize(32,32)); SetButtonStyle(&m_btnRecordOther, xtThemeOffice2003, BS_XT_XPFLAT, &m_btnFont14, RGB(255, 255, 255)); } // "New Source Document" button csTitle.LoadString(IDS_NEW_LSD); bCreationSucces = m_btnNewSourceDoc.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, ID_LSD_NEW); if (bCreationSucces == TRUE) { SetButtonImage(&m_btnNewSourceDoc,IDR_NEW_LSD, CSize(32, 32)); SetButtonStyle(&m_btnNewSourceDoc, xtThemeOffice2003, BS_XT_XPFLAT, &m_btnFont14, RGB(255, 255, 255)); } // "Open Source Document" button csTitle.LoadString(IDS_OPEN_LSD); bCreationSucces = m_btnOpenSourceDoc.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, ID_LSD_OPEN); if (bCreationSucces == TRUE) { SetButtonImage(&m_btnOpenSourceDoc,IDR_OPEN_LSD, CSize(32,32)); SetButtonStyle(&m_btnOpenSourceDoc, xtThemeOffice2003, BS_XT_XPFLAT, &m_btnFont14, RGB(255, 255, 255)); } // "Import PowerPoint" button csTitle.LoadString(IDS_IMPORT_PPT); bCreationSucces = m_btnImportPowerPoint.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, ID_PPT_IMPORT); if (bCreationSucces == TRUE) { SetButtonImage(&m_btnImportPowerPoint,IDR_IMPORT_PPT, CSize(32, 32)); SetButtonStyle(&m_btnImportPowerPoint, xtThemeOffice2003, BS_XT_XPFLAT, &m_btnFont14, RGB(255, 255, 255)); } CRect rcNewButtons; rcNewButtons.SetRect(0, 0, BUTTON_WIDTH1, BUTTON_HEIGHT1); // Tutorials button csTitle.LoadString(IDS_BUTTON_TUTORIALS); bCreationSucces = m_btnTutorial.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, IDS_SHOW_IMC_WEBPAGE_TUTORIALS); if(bCreationSucces) { SetButtonImage(&m_btnTutorial, IDR_PNG_TUTORIALS, CSize(32, 32)); SetButtonStyle(&m_btnTutorial, xtThemeOffice2003, BS_XT_XPFLAT /*| BS_XT_TRANSPARENT*/, &m_webBtnFont, RGB(233, 243, 249)); COLORREF clrWebButtons = 0x00333333; m_btnTutorial.SetColorText(clrWebButtons); } csTitle.LoadString(IDS_BUTTON_GUIDED); bCreationSucces = m_btnGuidedTour.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, IDS_SHOW_IMC_WEBPAGE_GUIDED_TOUR); if(bCreationSucces) { m_btnGuidedTour.SetTheme(xtThemeOffice2003); SetButtonImage(&m_btnGuidedTour, IDR_PNG_GUIDEDTOUR, CSize(32, 32)); SetButtonStyle(&m_btnGuidedTour, xtThemeOffice2003, BS_XT_XPFLAT /*| BS_XT_TRANSPARENT*/, &m_webBtnFont, RGB(233, 243, 249)); COLORREF clrWebButtons = 0x00333333; m_btnGuidedTour.SetColorText(clrWebButtons); } csTitle.LoadString(IDS_BUTTON_COMMUNITY); bCreationSucces = m_btnCommunity.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcButton, this, IDS_SHOW_IMC_WEBPAGE_COMUNITY); if(bCreationSucces) { SetButtonImage(&m_btnCommunity, IDR_PNG_COMMUNITY, CSize(32, 32)); COLORREF clrWebButtons = 0x00333333; m_btnCommunity.SetColorText(clrWebButtons); SetButtonStyle(&m_btnCommunity, xtThemeOffice2003, BS_XT_XPFLAT /*| BS_XT_TRANSPARENT*/, &m_webBtnFont, RGB(233, 243, 249)); } CString csOwnVersion; csOwnVersion.LoadString(IDS_VERSION); CSecurityUtils secure; int iVersionType = secure.GetVersionType(csOwnVersion); bool bIsEvaluation = (iVersionType & EVALUATION_VERSION) != 0; if (bIsEvaluation) { csTitle.LoadString(IDS_BUYNOW); bCreationSucces = m_btnBuyNow.Create(csTitle, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON /*| BS_MULTILINE*/, CRect(0,0, 190, 60), this, IDS_SHOW_IMC_WEBPAGE_BUYNOW); if (bCreationSucces) { SetButtonImage(&m_btnBuyNow, IDR_PNG_BUYNOW, CSize(54, 54)); SetButtonStyle(&m_btnBuyNow, xtThemeOffice2003, BS_XT_XPFLAT, &m_webBtnFont, RGB(190, 217, 239)); m_btnBuyNow.SetFontEx(&m_webBtnFont); } } }
void CClientListCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { // make sure window is active // GetParentFrame()->ActivateFrame(); /////////////////////////////// // See ContextMenuRules.txt for order of menu commands! // create an empty context menu // CP4Menu popMenu; popMenu.CreatePopupMenu(); int index; SetIndexAndPoint( index, point ); // Can always create a new client popMenu.AppendMenu( stringsON, ID_CLIENTSPEC_NEW ); // Only offer edit if no other client is selected if ( index == -1 || GetSelectedItemText() == GET_P4REGPTR()->GetP4Client() ) popMenu.AppendMenu( stringsON, ID_CLIENT_EDITMY ); if( index != -1 ) { // Make sure item gets selected SetItemState( index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED ); popMenu.AppendMenu( stringsON, ID_CLIENT_DESCRIBE ); //or client edit if user is the owner popMenu.AppendMenu( stringsON, ID_CLIENT_DELETE ); popMenu.AppendMenu( MF_SEPARATOR ); // Can only switch to a client if its not my current client if ( GetSelectedItemText() != GET_P4REGPTR()->GetP4Client() ) popMenu.AppendMenu( stringsON, ID_CLIENTSPEC_SWITCH ); else // can only set as default if it is my current client popMenu.AppendMenu( stringsON, ID_SETDEFCLIENT ); popMenu.AppendMenu( stringsON, ID_CLIENT_TEMPLATE ); if (GET_P4REGPTR()->LocalCliTemplateSw()) { popMenu.AppendMenu( MF_SEPARATOR ); popMenu.AppendMenu( stringsON, ID_CLIENT_USEASLOCALTEMPLATE, LoadStringResource(IDS_CLIENT_USEASLOCALTEMPLATE) ); popMenu.AppendMenu( stringsON, ID_CLIENT_CLEARLOCALTEMPLATE, LoadStringResource(IDS_CLIENT_CLEARLOCALTEMPLATE) ); } } popMenu.AppendMenu( MF_SEPARATOR ); popMenu.AppendMenu( stringsON, ID_FILTERCLIENTS, LoadStringResource(IDS_FILTERCLIENTS) ); popMenu.AppendMenu( stringsON, ID_CLEARCLIENTFILTER, LoadStringResource(IDS_CLEARCLIENTFILTER) ); popMenu.AppendMenu( MF_SEPARATOR ); CString txt = GetSelectedItemText(); if (txt.IsEmpty()) txt = GET_P4REGPTR()->GetP4Client( ); txt = LoadStringResource(IDS_CHGS_BY_CLIENT) + txt; txt = TruncateString(txt, 50); popMenu.AppendMenu( stringsON, ID_CHGS_BY_CLIENT, txt ); popMenu.AppendMenu( stringsON, ID_VIEW_UPDATE, LoadStringResource(IDS_REFRESH) ); MainFrame()->AddToolsToContextMenu(&popMenu); // put up the menu // popMenu.TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd( ) ); }
bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: { switch (HIWORD(wParam)) { case LBN_SELCHANGE: if ((HWND)lParam == m_pathlist.m_hWnd) { int i = m_pathlist.GetCurSel(); m_remove.EnableWindow(i >= 3 ? TRUE : FALSE); if (i >= 0) { CString path; m_pathlist.GetText(i, path); m_path.SetWindowText(path); } return true; } break; case LBN_SELCANCEL: if ((HWND)lParam == m_pathlist.m_hWnd) { m_remove.EnableWindow(FALSE); return true; } break; case BN_CLICKED: { switch (LOWORD(wParam)) { case IDC_BROWSE: { TCHAR pathbuff[MAX_PATH]; BROWSEINFO bi; bi.hwndOwner = m_Dlg; bi.pidlRoot = nullptr; bi.pszDisplayName = pathbuff; bi.lpszTitle = _T(""); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI; bi.lpfn = nullptr; bi.lParam = 0; bi.iImage = 0; LPITEMIDLIST iil = SHBrowseForFolder(&bi); if (iil) { SHGetPathFromIDList(iil, pathbuff); m_path.SetWindowText(pathbuff); } return true; } break; case IDC_REMOVE: { int i = m_pathlist.GetCurSel(); if (i >= 0) { m_pathlist.DeleteString(i); i = min(i, m_pathlist.GetCount() - 1); if (i >= 0 && m_pathlist.GetCount() > 0) { m_pathlist.SetCurSel(i); m_remove.EnableWindow(i >= 3 ? TRUE : FALSE); } } return true; } break; case IDC_ADD: { CString path; m_path.GetWindowText(path); if (!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) { m_pathlist.AddString(path); } return true; } break; } } break; } } break; } return false; }
void CModbusPollView::OnEnKillfocusEditName() { CString strText; m_edit_name.GetWindowTextW(strText); if (strText.IsEmpty()) { return; } m_MsDataGrid.put_TextMatrix(m_Current_Row,m_Current_Col,strText); int Index; if (m_Current_Col%3==0) { Index=(m_Current_Col/3-1)*(m_MsDataGrid.get_Rows()-1)+(m_Current_Row-1); } else { Index=(m_Current_Col/3)*(m_MsDataGrid.get_Rows()-1)+(m_Current_Row-1); } m_Alias[Index]=strText; int RegAddress=Get_Reg_Add(Index); CADO ado; ado.OnInitADOConn(); CString SqlText; if (m_cur_TableName.CompareNoCase(_T("CustomProductTable"))==0) { SqlText.Format(_T("Select * from CustomProductTable where ModelNo=%d and Reg_ID=%d"),m_cur_modelNo,RegAddress); ado.m_pRecordset=ado.OpenRecordset(SqlText); if (!ado.m_pRecordset->EndOfFile) { //strSql.Format(_T("update ALL_NODE set Hardware_Ver ='%s' where Serial_ID = '%s' and Bautrate = '%s'"),hw_instance,str_serialid,str_baudrate); //m_pCon->Execute(strSql.GetString(),NULL,adCmdText); SqlText.Format(_T("update CustomProductTable set Reg_Description='%s' where ModelNo=%d and Reg_ID=%d "),strText.GetBuffer(),m_cur_modelNo,RegAddress); try { ado.m_pConnection->Execute(SqlText.GetString(),NULL,adCmdText); } catch (_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } else { SqlText.Format(_T("Insert into CustomProductTable(Reg_Description,ModelNo,Reg_ID) values('%s',%d,%d)"),strText.GetBuffer(),m_cur_modelNo,RegAddress); try { ado.m_pConnection->Execute(SqlText.GetString(),NULL,adCmdText); } catch (_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } } else { SqlText.Format(_T("Select * from %s where %s=%d"),m_cur_TableName,m_cur_col_RegAddress,RegAddress); ado.m_pRecordset=ado.OpenRecordset(SqlText); if (!ado.m_pRecordset->EndOfFile) { SqlText.Format(_T("update %s set %s ='%s' where %s =%d "),m_cur_TableName,m_cur_Col_RegName,strText.GetBuffer(),m_cur_col_RegAddress,RegAddress); try { ado.m_pConnection->Execute(SqlText.GetString(),NULL,adCmdText); } catch (_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } } }
void CToolTipCtrlX::OnNMCustomDraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTTCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTTCUSTOMDRAW>(pNMHDR); if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT) { CWnd* pwnd = CWnd::FromHandle(pNMCD->nmcd.hdr.hwndFrom); CDC* pdc = CDC::FromHandle(pNMCD->nmcd.hdc); CString strText; pwnd->GetWindowText(strText); CRect rcWnd; pwnd->GetWindowRect(&rcWnd); CRect rcBorder; rcBorder.left = pNMCD->nmcd.rc.left - rcWnd.left; rcBorder.top = pNMCD->nmcd.rc.top - rcWnd.top; rcBorder.right = rcWnd.right - pNMCD->nmcd.rc.right; rcBorder.bottom = rcWnd.bottom - pNMCD->nmcd.rc.bottom; if (m_bCol1Bold && m_fontBold.m_hObject == NULL) { CFont* pFont = pwnd->GetFont(); if (pFont) { LOGFONT lf; pFont->GetLogFont(&lf); lf.lfWeight = FW_BOLD; VERIFY( m_fontBold.CreateFontIndirect(&lf) ); } } int iTextHeight = 0; int iMaxCol1Width = 0; int iMaxCol2Width = 0; int iMaxSingleLineWidth = 0; CSize sizText(0); int iPos = 0; while (iPos != -1) { CString strLine = GetNextString(strText, _T('\n'), iPos); int iColon = strLine.Find(_T(':')); if (iColon != -1) { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; CSize siz = pdc->GetTextExtent(strLine, iColon + 1); if (pOldFont) pdc->SelectObject(pOldFont); iMaxCol1Width = max(iMaxCol1Width, siz.cx); iTextHeight = siz.cy; // update height with 'col1' string, because 'col2' string might be empty and therefore has no height sizText.cy += siz.cy; LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1; while (_istspace(*pszCol2)) pszCol2++; if (*pszCol2 != _T('\0')) { siz = pdc->GetTextExtent(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2); iMaxCol2Width = max(iMaxCol2Width, siz.cx); } } else if (!strLine.IsEmpty()) { CSize siz = pdc->GetTextExtent(strLine); iMaxSingleLineWidth = max(iMaxSingleLineWidth, siz.cx); sizText.cy += siz.cy; } else { CSize siz = pdc->GetTextExtent(_T(" "), 1); sizText.cy += siz.cy; } } iMaxCol1Width = min(m_iScreenWidth4, iMaxCol1Width); iMaxCol2Width = min(m_iScreenWidth4*2, iMaxCol2Width); const int iMiddleMargin = 6; iMaxSingleLineWidth = max(iMaxSingleLineWidth, iMaxCol1Width + iMiddleMargin + iMaxCol2Width); sizText.cx = iMaxSingleLineWidth; rcWnd.right = rcWnd.left + rcBorder.left + sizText.cx + rcBorder.right; rcWnd.bottom = rcWnd.top + rcBorder.top + sizText.cy + rcBorder.bottom; if (rcWnd.left >= m_rcScreen.left) { if (rcWnd.right > m_rcScreen.right && rcWnd.Width() <= m_rcScreen.Width()) rcWnd.OffsetRect(-(rcWnd.right - m_rcScreen.right), 0); } if (rcWnd.top >= m_rcScreen.top) { if (rcWnd.bottom > m_rcScreen.bottom && rcWnd.Height() <= m_rcScreen.Height()) rcWnd.OffsetRect(0, -(rcWnd.bottom - m_rcScreen.bottom)); } pwnd->MoveWindow(&rcWnd); pwnd->ScreenToClient(&rcWnd); pdc->FillSolidRect(&rcWnd, m_crTooltipBkColor); CPoint ptText(pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top); iPos = 0; while (iPos != -1) { CString strLine = GetNextString(strText, _T('\n'), iPos); int iColon = strLine.Find(_T(':')); if (iColon != -1) { CRect rcDT(ptText.x, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight); // don't draw empty <col1> strings (they are still handy to use for skipping the <col1> space) if (iColon > 0) { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; pdc->DrawText(strLine, iColon + 1, &rcDT, m_dwCol1DrawTextFlags); if (pOldFont) pdc->SelectObject(pOldFont); } LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1; while (_istspace(*pszCol2)) pszCol2++; if (*pszCol2 != _T('\0')) { rcDT.left = ptText.x + iMaxCol1Width + iMiddleMargin; rcDT.right = rcDT.left + iMaxCol2Width; pdc->DrawText(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, &rcDT, m_dwCol2DrawTextFlags); } ptText.y += iTextHeight; } else { CSize siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, 0, NULL, 0); ptText.y += siz.cy; } } *pResult = CDRF_SKIPDEFAULT; return; } *pResult = CDRF_DODEFAULT; }
/** * fill grid cell by type. * following type to fil grid cell. * <PRE> * TYPE FORMAT RULE * TIME CTime * BOOL "Yes No" * </PRE> * @param -[in] int col: [column num] * @param -[in] int row: [row num] * @param -[in] CDBVariant* pVar: [argment] * * @version 05/09/2003 cuiyan Initial Version. */ CString CEdRptDoc::GetVarStr(CDBVariant* pVar, CString format) { CString str; switch(pVar->m_dwType) { case DBVT_BOOL: if (format.IsEmpty()) str = pVar->m_boolVal ? _T("Y") : _T("N"); else { str = pVar->m_boolVal ? format.Left(format.Find(' ')) : format.Right(format.GetLength() - format.Find(' ') - 1); str.TrimLeft(); str.TrimRight(); } break; case DBVT_UCHAR: if (format.IsEmpty()) str.Format("%c", pVar->m_chVal); else str.Format(format, pVar->m_chVal); break; case DBVT_SHORT: if (format.IsEmpty()) str.Format("%d", pVar->m_iVal); else str.Format(format, pVar->m_iVal); break; case DBVT_LONG: if (format.IsEmpty()) str.Format("%ld", pVar->m_lVal); else str.Format(format, pVar->m_lVal); break; case DBVT_SINGLE: if (format.IsEmpty()) str.Format("%g", pVar->m_fltVal); else str.Format(format, pVar->m_fltVal); break; case DBVT_DOUBLE: if (format.IsEmpty()) str.Format("%g", pVar->m_dblVal); else str.Format(format, pVar->m_dblVal); break; case DBVT_DATE: { CTime tm(pVar->m_pdate->year, pVar->m_pdate->month, pVar->m_pdate->day, pVar->m_pdate->hour, pVar->m_pdate->minute, pVar->m_pdate->second, pVar->m_pdate->fraction); if (format.IsEmpty()) str = tm.Format("%Y/%m/%d %H:%M:%S"); else str = tm.Format(format); } break; case DBVT_STRING: if (format.IsEmpty()) str = *pVar->m_pstring; else str.Format(format, *pVar->m_pstring); str.TrimRight(); break; case DBVT_BINARY: str = _T("Binary"); break; default: str = _T(""); break; } return str; }
// here for <!ENTITY blah> void CMUSHclientDoc::MXP_Entity (CString strName, CString strTag) { // case insensitive strName.MakeLower (); CString strEntityContents; if (App.m_EntityMap.Lookup (strName, strEntityContents)) { MXP_error (DBG_ERROR, errMXP_CannotRedefineEntity, TFormat ("Cannot redefine entity: &%s;", (LPCTSTR) strName)); return; } GetWord (strEntityContents, strTag); // blank contents deletes the entity if (strEntityContents.IsEmpty ()) m_CustomEntityMap.RemoveKey (strName); else { // look for entities imbedded in the definition, eg. <!EN blah '<Nick>'> const char * p = strEntityContents; const char * pStart; CString strFixedValue; CString strEntity; strFixedValue.Empty (); for ( ; *p; p++) { if (*p == '&') { p++; // skip ampersand pStart = p; // where entity starts for ( ; *p && *p != ';'; p++) // look for closing semicolon ; // just keep looking if (*p != ';') { MXP_error (DBG_ERROR, errMXP_NoClosingSemicolon, TFormat ("No closing \";\" in MXP entity argument \"%s\"", (LPCTSTR) strEntityContents)); return; } CString s (pStart, p - pStart); strFixedValue += MXP_GetEntity (s); // add to list } // end of having an ampersand else strFixedValue += *p; // just add ordinary characters to list } // end of processing the value // add entity to map m_CustomEntityMap.SetAt (strName, strFixedValue); // tell each plugin what we have received if (m_bPluginProcessesSetEntity) SendToAllPluginCallbacks (ON_PLUGIN_MXP_SETENTITY, CFormat ("%s=%s", (LPCTSTR) strName, (LPCTSTR) strFixedValue)); m_CurrentPlugin = NULL; } // check they didn't supply any other arguments strTag.TrimLeft (); while (!strTag.IsEmpty ()) { CString strKeyword; GetWord (strKeyword, strTag); strKeyword.MakeLower (); if (strKeyword == "desc") { GetWord (strKeyword, strTag); if (strKeyword != "=") GetWord (strKeyword, strTag); // get description } else if (strKeyword == "private") { // do nothing } else if (strKeyword == "publish") { // do nothing } else if (strKeyword == "delete") { m_CustomEntityMap.RemoveKey (strName); } else if (strKeyword == "add") { // do nothing } else if (strKeyword == "remove") { m_CustomEntityMap.RemoveKey (strName); } else { MXP_error (DBG_WARNING, errMXP_UnexpectedEntityArguments, TFormat ("Unexpected word \"%s\" in entity definition for &%s; ignored", (LPCTSTR) strKeyword, (LPCTSTR) strName)); return; } } // of processing optional words } // end of CMUSHclientDoc::MXP_Entity
void CEdRptDoc::GetStaticData(CRecordset &rc) { if (!rc.IsOpen()) return; CString csTmp; GV_ITEM Item; Item.mask = GVIF_TEXT|GVIF_FORMAT; Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX; Item.row = m_Grid.GetRowCount() - 1; Item.col = 0; Item.szText = "总计"; m_Grid.SetItem(&Item); CString csFormat; CODBCFieldInfo fi; for (Item.col = 1; Item.col < m_ColFmt.GetSize(); Item.col++) { if (m_ColFmt[Item.col].format.IsEmpty()) { rc.GetODBCFieldInfo(short(Item.col), fi); if (fi.m_nSQLType == SQL_NUMERIC || fi.m_nSQLType == SQL_DECIMAL) { if (fi.m_nScale == 0) { fi.m_nSQLType = SQL_INTEGER; csFormat.Format("%%%dd", fi.m_nPrecision); } else { fi.m_nSQLType = SQL_FLOAT; csFormat.Format("%%%d.%df", fi.m_nPrecision, fi.m_nScale); } } } else { csFormat = m_ColFmt[Item.col].format; if (csFormat.FindOneOf("dioux") > 0) fi.m_nSQLType = SQL_INTEGER; else if (csFormat.FindOneOf("eEfgG") > 0) fi.m_nSQLType = SQL_FLOAT; else fi.m_nSQLType = SQL_DATETIME; } switch(fi.m_nSQLType) { case SQL_INTEGER: case SQL_SMALLINT: case SQL_TINYINT: case SQL_BIGINT: fi.m_nSQLType = SQL_INTEGER; if (csFormat.IsEmpty()) csFormat = _T("%d"); break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: fi.m_nSQLType = SQL_FLOAT; if (csFormat.IsEmpty()) csFormat = _T("%f"); break; default: break; } double fSum = 0.0; if (fi.m_nSQLType == SQL_INTEGER || fi.m_nSQLType == SQL_FLOAT) { CString csTmp; for (int j = 1; j < m_Grid.GetRowCount() - 1; j++) { csTmp = m_Grid.GetItemText(j, Item.col); fSum += atof(csTmp); } } if (fi.m_nSQLType == SQL_INTEGER) Item.szText.Format(csFormat, (int)fSum); else if (fi.m_nSQLType == SQL_FLOAT) Item.szText.Format(csFormat, fSum); else Item.szText = "--:--"; Item.szText.TrimLeft(); Item.szText.TrimRight(); m_Grid.SetItem(&Item); } }
void CRevisionGraphDlg::OnViewFilter() { CSyncPointer<CAllRevisionGraphOptions> options (m_Graph.m_state.GetOptions()); CRevisionInRange* revisionRange = options->GetOption<CRevisionInRange>(); svn_revnum_t head = m_Graph.m_state.GetHeadRevision(); svn_revnum_t lowerLimit = revisionRange->GetLowerLimit(); svn_revnum_t upperLimit = revisionRange->GetUpperLimit(); CRemovePathsBySubString* pathFilter = options->GetOption<CRemovePathsBySubString>(); CRevGraphFilterDlg dlg; dlg.SetMaxRevision (head); dlg.SetFilterString (m_sFilter); dlg.SetRemoveSubTrees (pathFilter->GetRemoveSubTrees()); dlg.SetRevisionRange ( min (head, lowerLimit == -1 ? 1 : lowerLimit) , min (head, upperLimit == -1 ? head : upperLimit)); if (dlg.DoModal()==IDOK) { // user pressed OK to dismiss the dialog, which means // we have to accept the new filter settings and apply them svn_revnum_t minrev, maxrev; dlg.GetRevisionRange(minrev, maxrev); m_sFilter = dlg.GetFilterString(); revisionRange->SetLowerLimit (minrev); revisionRange->SetUpperLimit (maxrev == head ? revision_t (NO_REVISION) : maxrev); pathFilter->SetRemoveSubTrees (dlg.GetRemoveSubTrees()); std::set<std::string>& filterPaths = pathFilter->GetFilterPaths(); int index = 0; filterPaths.clear(); CString path = m_sFilter.Tokenize (L"*", index); while (!path.IsEmpty()) { filterPaths.insert (CUnicodeUtils::StdGetUTF8 ((LPCTSTR)path)); path = m_sFilter.Tokenize (L"*", index); } // update menu & toolbar CMenu * pMenu = GetMenu(); int tbstate = m_ToolBar.GetToolBarCtrl().GetState(ID_VIEW_FILTER); if (revisionRange->IsActive() || pathFilter->IsActive()) { if (pMenu != NULL) pMenu->CheckMenuItem(ID_VIEW_FILTER, MF_BYCOMMAND | MF_CHECKED); m_ToolBar.GetToolBarCtrl().SetState(ID_VIEW_FILTER, tbstate | TBSTATE_CHECKED); } else { if (pMenu != NULL) pMenu->CheckMenuItem(ID_VIEW_FILTER, MF_BYCOMMAND | MF_UNCHECKED); m_ToolBar.GetToolBarCtrl().SetState(ID_VIEW_FILTER, tbstate & (~TBSTATE_CHECKED)); } // re-run query StartWorkerThread(); } }
void CXMLDlg::CreateImageItem(HTREEITEM pItem, CAGPage* pPage, POINT& ptOffset) { HTREEITEM pChildItem = m_treeOutput.GetChildItem(pItem); if (!pChildItem) { ASSERT(false); return; } CString strFileName; CRect DestRect; double fAngle = 0.0; while (pChildItem) { CString szTitle; CString szValue; Separate(m_treeOutput.GetItemText(pChildItem), szTitle, szValue); if (!szTitle.CompareNoCase(_T("x")) ) { DestRect.left = INCHES(atof(szValue)); } else if (!szTitle.CompareNoCase(_T("y")) ) { DestRect.top = INCHES(atof(szValue)); } else if (!szTitle.CompareNoCase(_T("dx")) ) { DestRect.right = DestRect.left + INCHES(atof(szValue)); } else if (!szTitle.CompareNoCase(_T("dy")) ) { DestRect.bottom = DestRect.top + INCHES(atof(szValue)); } else if (!szTitle.CompareNoCase(_T("angle")) ) { fAngle = atof(szValue); } else if (!szTitle.CompareNoCase(_T("file")) ) { if (szValue.GetAt(1) == ':') strFileName = szValue; else strFileName = m_szProjectPath + szValue; } pChildItem = m_treeOutput.GetNextItem(pChildItem, TVGN_NEXT); } DestRect.OffsetRect(-ptOffset.x, -ptOffset.y); if (!strFileName.IsEmpty()) { bool bOK = HandleAddImage(pPage, &DestRect, strFileName, fAngle); } //j else //j ASSERT(false); }
/************************************************************************** * method CLocalProperties::InitProperties * * written by moonknit * * @history * created 2005-12-?? * * @Description * CLocalProperties의 멤버 변수들의 초기화 작업을 수행한다. * * @Parameters **************************************************************************/ void CLocalProperties::InitProperties() { // HWND initialize hSubscribeWnd = NULL; hMainWnd = NULL; szIRCID[0] = 0; bUserInit = FALSE; // 최초 실행 플래그 // Read First Start Flag CString tmp; tmp = ReadRegData(_T(""), REG_STR_FIRSTSTART); if(tmp != _T("")) bFirst = FALSE; else bFirst = TRUE; // Read Auto Start tmp = ReadRegData(_T(""), REG_STR_AUTOSTART); if(tmp == _T("1")) bAutoStart = TRUE; else bAutoStart = FALSE; tmp = ReadRegData(_T(""), REG_STR_CLOSEBTNEXIT); if(tmp == _T("1")) bCloseBtnExit = TRUE; else bCloseBtnExit = FALSE; if(_T("1") == ReadRegData(_T(""), REG_STR_SEARCHSAVE)) bSearchSave = TRUE; else bSearchSave = FALSE; tmp = ReadRegData(_T(""), REG_STR_IRCID); if(!tmp.IsEmpty()) { int len = tmp.GetLength(); #ifdef _UNICODE AnsiConvertWtoM((LPTSTR) (LPCTSTR) tmp, szIRCID, sizeof(szIRCID)); #else if(len < sizeof(szIRCID)) strcpy(szIRCID, tmp); #endif } TCHAR* stopstring; tmp = ReadRegData(_T(""), REG_STR_SWREAD); fSWRead = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWLINK); fSWLink = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWSCRAP); fSWScrap = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWFILTER); fSWFilter = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWHIT); fSWHit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWBASE); fSWBase = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); if(fSWBase == 0) fSWBase = 100; tmp = ReadRegData(_T(""), REG_STR_SWREADLIMIT); fSWReadLimit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWLINKLIMIT); fSWLinkLimit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWHITLIMIT); fSWHitLimit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWSCRAPLIMIT); fSWScrapLimit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); tmp = ReadRegData(_T(""), REG_STR_SWFILTERLIMIT); fSWFilterLimit = _tcstod ((LPTSTR) (LPCTSTR) tmp, &stopstring); UserPathTemp = ReadRegData(_T(""), REG_STR_USERPATH); // Read OPML Sync Information sUserID = ReadRegData(_T(""), REG_STR_LASTUSER); if(_T("") == sUserID) sUserID = DEFAULT_USERID; tmp = ReadRegData(_T(""), REG_STR_SAVEPASSWORD); if(tmp == _T("1")) bSavePassword = TRUE; else bSavePassword = FALSE; bAutoLogin = FALSE; sPassword = _T(""); if(bSavePassword) { tmp = ReadRegData(_T(""), REG_STR_ENCODEDPASS); if(tmp.GetLength() < 8) sPassword = _T(""); else sPassword = tmp; tmp = ReadRegData(_T(""), REG_STR_AUTOLOGIN); if(tmp == _T("1")) bAutoLogin = TRUE; } tmp = ReadRegData(_T(""), REG_STR_USEOPMLSYNC); if(tmp == _T("1")) bUseOPMLSync = TRUE; else bUseOPMLSync = FALSE; if(_T("1") == ReadRegData(_T(""), REG_STR_NOTUSEP2P)) bNotUseP2P = TRUE; else bNotUseP2P = FALSE; uSearchResultLimit = _ttoi(ReadRegData(_T(""), REG_STR_SRL)); if(uSearchResultLimit > MAX_SRL) uSearchResultLimit = MAX_SRL; else if(uSearchResultLimit < MIN_SRL) uSearchResultLimit = MIN_SRL; if(_T("1") == ReadRegData(_T(""), REG_STR_POSTAUTODELETE)) bPostAutoDelete = TRUE; else bPostAutoDelete = FALSE; if(_T("1") == ReadRegData(_T(""), REG_STR_LISTDESCSUMMARY)) bListDescSummary = TRUE; else bListDescSummary = FALSE; PaperStyleFile = ReadRegData(_T(""), REG_STR_PAPERSTYLE); // 기본 페이지 당 포스트 수 ppp = DEFAULT_PPP; // get time zone TIME_ZONE_INFORMATION tzi; GetTimeZoneInformation(&tzi); bias = tzi.Bias; spgmt.SetDateTimeSpan(0, 0, -bias, 0); // get favorites directory TCHAR szpath[_MAX_PATH]; if( SHGetSpecialFolderPath( NULL, szpath, CSIDL_FAVORITES, FALSE ) ) { sFavoritesDir = szpath; } // GET RUNNABLE PATH // TCHAR szModule[_MAX_PATH]; // GetModuleFileName(NULL, szModule, _MAX_PATH); // RunPath = szModule; #ifdef _UNICODE RunPath = __wargv[0]; #else RunPath = __argv[0]; #endif // TRACE(_T("RUN PAHT : %s\r\n"), RunPath); RunPath = RunPath.Mid(0, RunPath.ReverseFind('\\') + 1); // SET PARIAL PATH ENABLE PartialsInDir = true; // Set IRC ID NULL szIRCID[0] = '\0'; bIRCConnected = FALSE; bOPMLConnected = FALSE; if(bFirst) MakeFirstStart(); }
bool TemplateGroup::Refresh() { CString line; CStdioFile file; // Check the date and time stamp. CFileStatus fileStatus; if (!CFile::GetStatus(m_filename, fileStatus)) { return false; } if (m_timeStamp == fileStatus.m_mtime) { // Matches... don't reload. return false; } // Destroy the old stuff. for (size_t i = 0; i < m_templates.GetCount(); i++) delete m_templates[i]; m_templates.RemoveAll(); // Open the file. if (!file.Open(m_filename, CFile::modeRead)) { return false; } // Assign as the new time stamp. m_timeStamp = fileStatus.m_mtime; // Possible states. enum State { FINDTEMPLATE, PARSETEMPLATE, PARSECODE, PARSEMEMO, PARSEDIALOG, PARSEPARAMS, PARSEKEY, }; State state = FINDTEMPLATE; Template* curTemplate = NULL; CString* curDialog = NULL; // Read the template file name. file.ReadString(m_name); int lineNumber = 1; // Go until we're through. while (true) { // Read a line. lineNumber++; if (!file.ReadString(line)) { // End of file. break; } TopState: // Check the state. if (state == FINDTEMPLATE) { // Find the block. if (line.GetLength() >= 1 && line[0] == '[') { if (line[line.GetLength() - 1] == ']') { state = PARSETEMPLATE; curTemplate = WNEW Template(*this); curTemplate->m_lineNumber = lineNumber; m_templates.Add(curTemplate); curTemplate->m_name = line.Mid(1, line.GetLength() - 2); } } } /////////////////////////////////////////////////////////////////////// // Template parsing. /////////////////////////////////////////////////////////////////////// else if (state == PARSETEMPLATE) { ASSERT(curTemplate); // Did we find a new block? if (line.GetLength() >= 1 && line[0] == '[') { curTemplate = NULL; state = FINDTEMPLATE; goto TopState; } // Search for the template sub-type to process. if (line.CompareNoCase("!!code") == 0) { state = PARSECODE; continue; } else if (line.CompareNoCase("!!memo") == 0) { state = PARSEMEMO; continue; } else if (line.CompareNoCase("!!dialog") == 0) { state = PARSEDIALOG; continue; } else if (line.CompareNoCase("!!params") == 0) { state = PARSEPARAMS; continue; } else if (line.CompareNoCase("!!key") == 0) { state = PARSEKEY; continue; } } /////////////////////////////////////////////////////////////////////// // Code parsing /////////////////////////////////////////////////////////////////////// else if (state == PARSECODE) { if (line.CompareNoCase("!!end") == 0) { state = PARSETEMPLATE; continue; } // Add the line to our list. Template::OffsetInfo offsetInfo; offsetInfo.m_offset = curTemplate->m_code.GetLength(); offsetInfo.m_line = lineNumber; curTemplate->m_codeOffsets.Add(offsetInfo); curTemplate->m_code += line; curTemplate->m_code += "\n"; } /////////////////////////////////////////////////////////////////////// // Memo parsing /////////////////////////////////////////////////////////////////////// else if (state == PARSEMEMO) { if (line.CompareNoCase("!!end") == 0) { state = PARSETEMPLATE; continue; } // Add the line to our list. curTemplate->m_memo += line; curTemplate->m_memo += " "; } /////////////////////////////////////////////////////////////////////// // Dialog parsing /////////////////////////////////////////////////////////////////////// else if (state == PARSEDIALOG) { if (line.CompareNoCase("!!end") == 0) { curDialog = NULL; state = PARSETEMPLATE; continue; } if (!curDialog || line.CompareNoCase("!!next") == 0) { int index = curTemplate->m_pages.Add(CString("")); curDialog = &curTemplate->m_pages[index]; if (line.CompareNoCase("!!next") == 0) continue; } if (line.IsEmpty()) { line = "<br>"; } // Add the line to our list. *curDialog += line; *curDialog += " "; } /////////////////////////////////////////////////////////////////////// // Default parameters parsing /////////////////////////////////////////////////////////////////////// else if (state == PARSEPARAMS) { if (line.CompareNoCase("!!end") == 0) { state = PARSETEMPLATE; continue; } // Add the line to our list. LPCTSTR ptr = (LPCTSTR)line; CharArray buffer; CString param = ParseToken(ptr, NULL); while (*ptr != 0 && *ptr == ' ') ptr++; if (*ptr == 0) { // Error!!! } Template::DefaultInfo info; info.m_entry = param; info.m_value = ptr; curTemplate->m_defaults.AddTail(info); } /////////////////////////////////////////////////////////////////////// // Default parameters parsing /////////////////////////////////////////////////////////////////////// else if (state == PARSEKEY) { state = PARSETEMPLATE; // Get the keys. LPCTSTR ptr = (LPCTSTR)line; CharArray buffer; CString param = ParseToken(ptr, NULL); curTemplate->m_key = param; } } // Close the template file. file.Close(); return true; }
BOOL CCommUSB::download_data(CString file_path) { DWORD read_len = 0;// UINT usb_write_len = 0;// HANDLE hFile = NULL;// BOOL bDownloadNandBoot = FALSE;// BOOL bfirst = TRUE;// BYTE file_data[MAX_PACKET_LENGTH];// if(file_path.IsEmpty()) return FALSE; /* if(strcmp(file_path, config.nandboot_path) == 0) { bDownloadNandBoot = TRUE; } */ hFile = CreateFile(file_path , GENERIC_READ , FILE_SHARE_READ , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);// if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } while(1) { BOOL bResult = ReadFile(hFile, file_data, MAX_PACKET_LENGTH, &read_len, NULL);// if(!bResult) { CloseHandle(hFile); return FALSE; } /* if(bDownloadNandBoot && bfirst) { config_nandboot_parameter(file_data); bfirst = FALSE; } */ int write_len = read_len; if(write_len % MIN_PACKET_LENGTH != 0) write_len = read_len + (MIN_PACKET_LENGTH - read_len % MIN_PACKET_LENGTH);// // if( read_len > 0 && !m_usb.M3USB_DOWNLOAD(file_data, write_len, &usb_write_len))// { CloseHandle(hFile); return FALSE; } // download_file_len += read_len; // PostMessage(get_wnd(), ON_BURNFLASH_MESSAGE, WPARAM(get_id()+100), LPARAM(MESSAGE_DOWNLOAD_FILE_LEN) ); if(read_len < MAX_PACKET_LENGTH)//last packet { CloseHandle(hFile); if( !m_usb.M3USB_DOWNLOAD(end_pad, MIN_PACKET_LENGTH, &usb_write_len))// { return FALSE; } Sleep(200); if( read_transc_ack() != ACK_SUCCESS)// { return FALSE;// } break; } } return true; }
int CPlayerMgr::StartPlayer(const uchar * filehash, CString strFilename, UINT64 uFileSize, CString strExt) { if(! g_PlayerMgr) { g_hNotifyWnd = AfxGetMainWnd()->GetSafeHwnd(); g_PlayerMgr = (CPlayerMgr*)AfxBeginThread(RUNTIME_CLASS(CPlayerMgr)); // 开始成功端口侦听 while(g_PlayerMgr->GetListenPort()==0) { Sleep(100); } } if(strExt.IsEmpty() || filehash==NULL) return 1; CSKey key(filehash); CSingleLock lock(&CPlayerMgr::m_Mutex, true); TCHAR szBuf[_MAX_PATH], szBuf2[_MAX_PATH]; ULONG ulSize = _MAX_PATH; CString strExeFile; CRegKey reg; if(reg.Open(HKEY_CLASSES_ROOT, _T(".")+strExt)==ERROR_SUCCESS) { if(reg.QueryStringValue(NULL, szBuf, &ulSize)==ERROR_SUCCESS) { CString strCmd; strCmd.Format(_T("%s\\shell"), szBuf); if(reg.Open(HKEY_CLASSES_ROOT, strCmd)==ERROR_SUCCESS) { ulSize = _MAX_PATH; if(reg.QueryStringValue(NULL, szBuf2, &ulSize)==ERROR_SUCCESS) { strCmd.Format(_T("%s\\shell\\%s\\command"), szBuf, szBuf2); if(reg.Open(HKEY_CLASSES_ROOT, strCmd)==ERROR_SUCCESS) { ulSize = _MAX_PATH; if(reg.QueryStringValue(NULL, szBuf, &ulSize)==ERROR_SUCCESS) { strExeFile = szBuf; } } } } } } // 使用配置的播放器 if(strExeFile.IsEmpty()) { // todo return 2; } CString strCmdLine; DWORD * pKey=(DWORD*)key.m_key; strCmdLine.Format(_T("\"http://127.0.0.1:%d/%08x%08x%08x%08x/%s\""), g_PlayerMgr->GetListenPort(), pKey[0], pKey[1], pKey[2], pKey[3], strFilename); strExeFile.Replace(_T("\"%1\""), _T("")); strExeFile.Replace(_T("%1"), _T("")); strExeFile.Trim(); // 把参数剥出来 int nParamPos; CString strTmp = strExeFile; while((nParamPos = strTmp.ReverseFind(_T('.'))) >= 0) { LPCTSTR szExe = strTmp; if(_tcsnicmp(szExe + nParamPos, _T(".exe"), 4)==0) { nParamPos += 4; break; } else { strTmp = strTmp.Left(nParamPos); } } if(nParamPos==-1) { return 2; } CString strExeParam; if(nParamPos<strExeFile.GetLength()-1) { if(strExeFile.GetAt(nParamPos)==_T('\"')) nParamPos++; strExeParam = strExeFile.Mid(nParamPos); strExeFile = strExeFile.Left(nParamPos); } CPlayerTask * pTask = g_PlayerMgr->AddPlayerTask(key); pTask->m_uTotalFileSize = uFileSize; // CStringA strTmpA; // strTmpA.Format(httphead, dwFileSize); // pTask->SendData((void*)(const char*)strTmpA, strTmpA.GetLength()); //if(! pTask->m_fileToRead.Duplicate() Open(strFilepath, CFile::modeRead|CFile::shareDenyWrite)) //{ // g_PlayerMgr->RemovePlayerTask(key); // return 3; //} ShellExecute(NULL,_T("open"), strExeFile, strCmdLine + strExeParam, NULL, SW_SHOW); return 0; }