void CIrcWnd::OnBnClickedIrcConnect() { if (!m_bConnected) { CString sInput = thePrefs.GetIRCNick(); sInput.Trim(); sInput = sInput.SpanExcluding(_T(" !@#$%^&*():;<>,.?{}~`+=-")); sInput = sInput.Left(25); while (sInput.IsEmpty() || sInput.CompareNoCase(_T("emule")) == 0 || stristr(sInput, _T("emuleirc")) != NULL) { InputBox inputBox; inputBox.SetLabels(GetResString(IDS_IRC_NEWNICK), GetResString(IDS_IRC_NEWNICKDESC), sInput); if (inputBox.DoModal() == IDOK) { sInput = inputBox.GetInput(); sInput.Trim(); sInput = sInput.SpanExcluding(_T(" !@#$%^&*():;<>,.?{}~`+=-")); sInput = sInput.Left(25); } else return; } thePrefs.SetIRCNick(sInput); //if not connected, connect.. m_pIrcMain->Connect(); } else { //If connected, disconnect.. m_pIrcMain->Disconnect(); m_wndChanList.ResetServerChannelList(); } }
BOOL CVersionChecker::UndertakeRequest(CString& strPost) { m_pRequest.SetURL( _T("http://update.trillinux.org/version/beta.php?") + strPost ); //Remember to set the update server for final releases. if ( ! m_pRequest.Execute( FALSE ) ) return FALSE; int nStatusCode = m_pRequest.GetStatusCode(); if ( nStatusCode < 200 || nStatusCode > 299 ) return FALSE; CString strResponse = m_pRequest.GetResponseString(); CString strHack = theApp.GetProfileString( _T("VersionCheck"), _T("TestResponse"), _T("") ); if ( strHack.GetLength() ) strResponse = strHack; for ( strResponse += '&' ; strResponse.GetLength() ; ) { CString strItem = strResponse.SpanExcluding( _T("&") ); strResponse = strResponse.Mid( strItem.GetLength() + 1 ); CString strKey = strItem.SpanExcluding( _T("=") ); if ( strKey.GetLength() == strItem.GetLength() ) continue; strItem = CTransfer::URLDecode( strItem.Mid( strKey.GetLength() + 1 ) ); strItem.TrimLeft(); strItem.TrimRight(); m_pResponse.SetAt( strKey, strItem ); } return TRUE; }
bool CLightWizard::LoadList() { try { //Load LightWiz.ini CString csFile; csFile.Format("%sLightWiz.ini",Main->m_csRootDirectory); CStdioFile pFile; if ( !pFile.Open(csFile, CFile::modeRead | CFile::shareDenyNone) ) { Main->m_log.Add(1,"ERROR: Unable to open file %s", csFile); return false; } BOOL bStatus = TRUE; while ( bStatus ) { CString csLine; bStatus = pFile.ReadString(csLine); if ( !bStatus ) break; csLine = csLine.SpanExcluding("//"); csLine.Trim(); if ( csLine != "" ) { CLightObj * pLight = new (CLightObj); pLight->m_csName = csLine.SpanExcluding(":"); csLine = csLine.Mid(csLine.Find(":") + 1); pLight->m_Light.Add(csLine.SpanExcluding(",")); while (csLine.Find(",") != -1) { csLine = csLine.Mid(csLine.Find(",") + 1); pLight->m_Light.Add(csLine.SpanExcluding(",")); } m_aLights.Add(pLight); } } } catch (CFileException *e) { Main->m_log.Add(1,"ERROR: Caught an exception while reading the file %s. Cause code = %ld", e->m_strFileName, e->m_cause); e->Delete(); } return true; }
void CSubmountsDlg::OnDelete() { HOURGLASS hourglass; int nIndex = m_SubmtList.GetCurSel(); ASSERT(nIndex >= 0); CString strSubmt; CString strShareName; m_SubmtList.GetText(nIndex, strSubmt); ASSERT(!strSubmt.IsEmpty()); strShareName = strSubmt.SpanExcluding(_T("=")); if (ShowMessageBox(IDS_REALLY_DELETE_SUBMT, MB_YESNO | MB_ICONQUESTION, IDS_REALLY_DELETE_SUBMT, strShareName) != IDYES) return; m_SubmtList.DeleteString(nIndex); if (m_SubmtList.GetCount() == 0) { m_Delete.EnableWindow(FALSE); m_Change.EnableWindow(FALSE); } CSubmountInfo *pInfo = new CSubmountInfo(); pInfo->SetShareName(strShareName); pInfo->SetStatus(SIS_DELETED); AddWork(pInfo); }
BOOL CChatWnd::OnLocalText(const CString& sText) { // Save history m_pHistory.Add( sText ); if ( m_pHistory.GetSize() > EDIT_HISTORY ) m_pHistory.RemoveAt( 0 ); m_nHistory = static_cast< int >( m_pHistory.GetSize() ); if ( sText.GetAt( 0 ) == _T('/') ) { CString strCommand = sText.SpanExcluding( _T(" \t") ).Trim(); if ( strCommand.CompareNoCase( _T("/me") ) == 0 ) { // Action text return OnLocalMessage( true, sText.Mid( 4 ) ); } else if ( OnLocalCommand( strCommand, sText.Mid( strCommand.GetLength() + 1 ).Trim() ) ) { // Handled command return TRUE; } } else if ( sText.GetAt( 0 ) == _T('*') && ( sText.GetAt( 1 ) == _T(' ') || sText.GetAt( 1 ) == _T('\t') ) ) { // Action text return OnLocalMessage( true, sText.Mid( 2 ) ); } // Regular text return OnLocalMessage( false, sText ); }
bool CPatch::Read(CStdioFile& fp) { CString s; int Version; if (!fp.ReadString(s) || _stscanf(s, FILE_ID, &Version) != 1) return(FALSE); SetDefaults(); // in case some lines are missing while (fp.ReadString(s)) { s.TrimLeft(); CString Name = s.SpanExcluding(_T(" \t")); CString Arg = s.Mid(Name.GetLength()); int i; for (i = 0; i < ROWS; i++) { if (Name == m_RowData[i].Name) { ROW *r = &m_Row[i]; _stscanf(Arg, _T("%lf %d %lf %lf %lf"), &r->Val, &r->Wave, &r->Amp, &r->Freq, &r->PW); break; } } if (i >= ROWS) { // not a parm row, assume it's a state member for (i = 0; m_LineInfo[i].Name != NULL; i++) { if (Name == m_LineInfo[i].Name) { CFormatIO::StrToVal(m_LineInfo[i].Type, Arg, ((char *)this) + m_LineInfo[i].Offset); break; } } } } return(TRUE); }
INT_PTR CRemoteWnd::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { if ( CmdButton* pButton = HitTestButtons( point ) ) { CString strTip; if ( LoadString( strTip, pButton->m_nID ) ) { if ( LPCTSTR pszBreak = _tcschr( strTip, '\n' ) ) { pTI->lpszText = _tcsdup( pszBreak + 1 ); } else { strTip = strTip.SpanExcluding( L"." ); pTI->lpszText = _tcsdup( strTip ); } } pTI->hwnd = GetSafeHwnd(); pTI->uId = pButton->m_nID; pTI->uFlags = pTI->uFlags & ~TTF_IDISHWND; pTI->rect = pButton->m_rc; return pTI->uId; } return CWnd::OnToolHitTest( point, pTI ); }
void CIrcWnd::OnBnClickedBnIrcconnect() { if(!m_bConnected) { if( thePrefs.GetIRCNick().MakeLower() == _T("emule") || thePrefs.GetIRCNick().MakeLower().Find(_T("emuleirc")) != -1 ) { InputBox inputbox; inputbox.SetLabels(GetResString(IDS_IRC_NEWNICK), GetResString(IDS_IRC_NEWNICKDESC), _T("eMule")); if (inputbox.DoModal() == IDOK) { CString input = inputbox.GetInput(); input.Trim(); input = input.SpanExcluding(_T(" !@#$%^&*():;<>,.?{}~`+=-")); if( input != "" ) thePrefs.SetIRCNick(input.GetBuffer()); } } //if not connected, connect.. m_pIrcMain->Connect(); } else { //If connected, disconnect.. m_pIrcMain->Disconnect(); } }
void CXMLDlg::Separate(const CString& szItemType, CString& szTitle, CString& szValue) { szTitle = szItemType.SpanExcluding(_T("=")); szTitle.TrimLeft(); szTitle.TrimRight(); szValue = szItemType.Mid(szItemType.Find('=')+1); }
unsigned int CBeep::GetFrequency() { CString FrequencyString; m_Frequency.GetWindowText(FrequencyString); CString Frequency = FrequencyString.SpanExcluding(" hz"); return atoi(Frequency); }
bool CHtmlDialog::GetControlValue(const CString& strControlName, CString& szValue) { if (!m_varReturn.bstrVal) return false; CString szReturnString(m_varReturn.bstrVal); do { if (szReturnString == _T("\0") || !szReturnString.GetLength()) break; CString szControlValuePair = szReturnString.SpanExcluding(_T(";")); CString szControlName = szControlValuePair.SpanExcluding(_T("=")); if (!szControlName.CompareNoCase(strControlName)) { szValue = szControlValuePair.Right(szControlValuePair.GetLength() - (szControlName.GetLength() + 1)); return true; } CString szTemp = szReturnString.Right(szReturnString.GetLength() - (szControlValuePair.GetLength() + 1)); szReturnString = szTemp; } while (true); return false; }
BOOL CXphoneApp::CheckUsage(CString& xUserId, CString& xPassword) { CString xCmdLine = m_lpCmdLine; xCmdLine.MakeLower(); if ( m_lpCmdLine && xCmdLine.Find( "-u:") >= 0 ) { xUserId = xCmdLine.Mid( xCmdLine.Find( "-u:" ) + 3 ); xUserId = xUserId.SpanExcluding( _T("|;, ") ); } if ( m_lpCmdLine && xCmdLine.Find( "-p:") >= 0 ) { xPassword = xCmdLine.Mid( xCmdLine.Find( "-p:" ) + 3 ); xPassword = xPassword.SpanExcluding( _T("|;, ") ); } return ! (xUserId.IsEmpty() | xPassword.IsEmpty()); }
CString CTripLightApp::GetAppPath() { CString s = GetCommandLine(); s.TrimLeft(); // trim leading whitespace just in case if (s[0] == '"') // if first char is a quote s = s.Mid(1).SpanExcluding(_T("\"")); // span to next quote else s = s.SpanExcluding(_T(" \t")); // span to next whitespace return(s); }
BOOL CXuser32App::CheckUsage(CString& xUserId, CString& xPassword, BOOL& bTestor) { CString xCmdLine = m_lpCmdLine; xCmdLine.MakeLower(); if ( m_lpCmdLine && xCmdLine.Find( "-t") >= 0 ) { bTestor = TRUE; } if ( m_lpCmdLine && xCmdLine.Find( "-u:") >= 0 ) { xUserId = xCmdLine.Mid( xCmdLine.Find( "-u:" ) + 3 ); xUserId = xUserId.SpanExcluding( _T("|;, ") ); } if ( m_lpCmdLine && xCmdLine.Find( "-p:") >= 0 ) { xPassword = xCmdLine.Mid( xCmdLine.Find( "-p:" ) + 3 ); xPassword = xPassword.SpanExcluding( _T("|;, ") ); } return ! (xUserId.IsEmpty() ^ xPassword.IsEmpty()); }
BOOL CArrayMatrix::SetStringName(CString &DataString,CString & sName) { int pos; pos=DataString.Find(_T("=")); if(pos==-1||pos==0) return FALSE; CString tpName=sName; sName=DataString.SpanExcluding("=");//取等号作边的字符串为变量的名字 sName.TrimLeft(); sName.TrimRight(); if(sName.GetLength()==0||sName.Find(_T(" "))!=-1) //当m_name为空格或则里面存在空格时返回假 { sName=tpName; return FALSE; } DataString=DataString.Right(lstrlen(DataString)-pos-1);//把DataString改成等号右边的字符串 return TRUE; }
void CSubmountsDlg::OnChange() { CAddSubmtDlg dlg; HOURGLASS hourglass; dlg.SetAddMode(FALSE); int nIndex = m_SubmtList.GetCurSel(); ASSERT(nIndex >= 0); CString strSubmt; CString strShareName; m_SubmtList.GetText(nIndex, strSubmt); ASSERT(!strSubmt.IsEmpty()); strShareName = strSubmt.SpanExcluding(_T("=")); CSubmountInfo *pInfo = FindWork(strShareName); if (pInfo != 0) // Make a copy we can free below pInfo = new CSubmountInfo(*pInfo); else pInfo = ReadSubmtInfo(strShareName); if (!pInfo) { ShowMessageBox(IDS_GET_SUBMT_INFO_ERROR, MB_ICONEXCLAMATION, IDS_GET_SUBMT_INFO_ERROR, strShareName); return; } dlg.SetSubmtInfo(pInfo); delete pInfo; if (dlg.DoModal() != IDOK) return; pInfo = dlg.GetSubmtInfo(); m_SubmtList.DeleteString(nIndex); m_SubmtList.InsertString(nIndex, pInfo->GetShareName() + "=" + pInfo->GetPathName()); AddWork(pInfo); }
BOOL CPlaySettingsPage::LockJob(LPCTSTR pszText) { CString strValue = pszText; for ( strValue += '|' ; strValue.GetLength() ; ) { CString str = strValue.SpanExcluding( _T("|;,") ); strValue = strValue.Mid( str.GetLength() + 1 ); str.TrimLeft(); str.TrimRight(); if ( str.IsEmpty() ) continue; LockWith( _ttoi(str) ); } return TRUE; }
void CDlgDialbox::OnBnClickedDialboxConnect() { CString sComPort = ""; const int iItem = m_ComPort.GetCurSel(); if (iItem < 0) return; m_ComPort.GetLBText(iItem, sComPort); if (sComPort.IsEmpty()) return; int err = OpenDialboxBluetoothSPP("\\\\.\\" + sComPort.SpanExcluding(" ")); if (err) { AfxMessageBox( "Error on connecting the device.\r\n1. Is the selected device placed near your PC? Is it turned on?\r\n" "2. If this error repeatedly occurs even when the correct device is selected, " "go to the Bluetooth config window and remove the device and do pairing again." ); } EnableCtrl(); }
BOOL CSecureRule::FromGnucleusString(CString& str) { int x[4] = {}; int nPos = str.Find( L':' ); if ( nPos < 1 ) return FALSE; CString strAddress = str.Left( nPos ); str = str.Mid( nPos + 1 ); if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 ) return FALSE; m_nIP[0] = (BYTE)x[0]; m_nIP[1] = (BYTE)x[1]; m_nIP[2] = (BYTE)x[2]; m_nIP[3] = (BYTE)x[3]; nPos = strAddress.Find( L'-' ); if ( nPos >= 0 ) { strAddress = strAddress.Mid( nPos + 1 ); if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 ) return FALSE; for ( int nByte = 0; nByte < 4; nByte++ ) { BYTE nTop = (BYTE)x[ nByte ], nBase = (BYTE)x[ nByte ]; for ( BYTE nValue = m_nIP[ nByte ]; nValue < nTop; nValue++ ) { m_nMask[ nByte ] &= ~( nValue ^ nBase ); } } } m_nType = srAddress; m_nAction = srDeny; m_nExpire = srIndefinite; m_sComment = str.SpanExcluding( L":" ); MaskFix(); return TRUE; }
BOOL CInfoChannel::IsOnlyUserId(LPCTSTR xRemoteId) { CSettings::Item* pItem = Settings.GetSetting( _T("Play.OnlyUser") ); if ( *pItem->m_pDword == FALSE ) return TRUE; pItem = Settings.GetSetting( _T("Play.OnlyUserId") ); CString strValue = *pItem->m_pString; for ( strValue += '|' ; strValue.GetLength() ; ) { CString str = strValue.SpanExcluding( _T("|;,") ); strValue = strValue.Mid( str.GetLength() + 1 ); if ( ! _tcsncmp( str, xRemoteId, str.GetLength() ) ) return TRUE; } return FALSE; }
BOOL CCallerChannel::IsNotUserTime() { CRegistry pRegistry; if ( ! pRegistry.GetInt( "Caller", "NoUser" ) ) return FALSE; CString strValue = pRegistry.GetString( "Caller", "UserTime" ); CString str = strValue.SpanExcluding( _T("-") ); WORD nLTime = _ttoi( str ); strValue = strValue.Mid( str.GetLength() + 1 ); WORD nHTime = _ttoi( strValue ); CTime tNow = CTime::GetCurrentTime(); WORD nNowTime = tNow.GetHour()* 100 + tNow.GetMinute(); return nNowTime < nLTime || nNowTime > nHTime; }
/////////////////////////////////////////////////////////////////////////////// // Function: ParseString // Purpose: Actually breaks a string of words into individual pieces // Arguments: Source string in, array to put the words and the count /////////////////////////////////////////////////////////////////////////////// void ParseString(char *buffer,CStringArray *words,int *cnt) { /// Local Variables /////////////////////////////////////////////////////////// CString in = buffer, temp; /////////////////////////////////////////////////////////////////////////////// in.TrimLeft(); in.TrimRight(); *cnt = 0; do { temp = in.SpanExcluding(" \t"); // GET UP TO THE NEXT SPACE OR TAB words->Add(temp); if (temp == in) break; in = in.Right(in.GetLength() - temp.GetLength()); in.TrimLeft(); *cnt = *cnt + 1; } while (1); *cnt = *cnt + 1; }
CString CRemote::GetKey(LPCTSTR pszName) { int nStart = 0; CString strPair = m_sHandshake.Tokenize( L"&?", nStart ); while ( ! strPair.IsEmpty() ) { CString strName = strPair.SpanExcluding( L"=" ); if ( strName.CompareNoCase( pszName ) == 0 ) { strName = strPair.Mid( strName.GetLength() + 1 ); return URLDecode( strName ); } strPair = m_sHandshake.Tokenize( L"&?", nStart ); } return CString(); }
int CCoolBarCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { CRect rcItem; CCoolBarItem* pItem = HitTest( point, &rcItem ); if ( pItem == NULL ) return -1; if ( ! pTI ) return 1; pTI->uFlags = 0; pTI->hwnd = GetSafeHwnd(); pTI->uId = (UINT)pItem->m_nID; pTI->rect = rcItem; pTI->lpszText = LPSTR_TEXTCALLBACK; if ( pItem->m_sTip.GetLength() ) { pTI->lpszText = _tcsdup( pItem->m_sTip ); } else { CString strTip; if ( LoadString( strTip, pTI->uId ) ) { if ( LPCTSTR pszBreak = _tcschr( strTip, '\n' ) ) { pTI->lpszText = _tcsdup( pszBreak + 1 ); } else { strTip = strTip.SpanExcluding( _T(".") ); pTI->lpszText = _tcsdup( strTip ); } } } return pTI->uId; }
BOOL CCallerChannel::PutForwardRing(CXMLElement* pXML, CChannel*& pChannel) { CString strValue = pXML->GetAttributeValue( "Forward" ); for ( strValue += '|' ; strValue.GetLength() ; ) { CString str = strValue.SpanExcluding( _T("|;,") ); strValue = strValue.Mid( str.GetLength() + 1 ); if ( pChannel = Network.LookOutPhs( (LPCTSTR)str ) ) { CDialPacket* pPacket = new CDialPacket; pPacket->SetLocalId( "96031" ); pPacket->SetRemoteId( str ); pPacket->SetCallerId( pXML->GetAttributeValue( "ID" ) ); pPacket->SetFeeNumber( pXML->GetAttributeValue( "ID" ) ); pChannel->OnDialPacket( pPacket ); pPacket->Release(); SetLinker( pChannel->m_nChan ); } break; } return TRUE; }
CString GetColumnFromLine(CString strBuffer, int nColumn) { int nLen = strBuffer.GetLength(); TCHAR ch; CString strOut = _T(""); if(nColumn == 999) { int index = strBuffer.ReverseFind(' '); if(index >= 0) { strOut = strBuffer.Right(strBuffer.GetLength() - index - 1); return strOut; } } else { for (int i = 0; i < nLen; i++) { ch = strBuffer.GetAt(i); if (ch == 0x20) continue; nColumn--; strOut = strBuffer.Right(nLen - i); strOut = strOut.SpanExcluding(" "); if (nColumn == 0) { return strOut; } i += strOut.GetLength(); } } return _T(""); }
void CVersionChecker::ProcessResponse() { int nDays = VERSIONCHECKER_FREQUENCY; CString strValue; if ( m_pResponse.Lookup( _T("Message"), strValue ) || m_pResponse.Lookup( _T("MessageBox"), strValue ) ) { m_sMessage = strValue; } if ( m_pResponse.Lookup( _T("Quote"), strValue ) ) { m_sQuote = strValue; theApp.WriteProfileString( _T("VersionCheck"), _T("Quote"), m_sQuote ); } if ( m_pResponse.Lookup( _T("SystemMsg"), strValue ) ) { for ( strValue += '\n' ; strValue.GetLength() ; ) { CString strLine = strValue.SpanExcluding( _T("\r\n") ); strValue = strValue.Mid( strLine.GetLength() + 1 ); if ( strLine.GetLength() ) theApp.Message( MSG_SYSTEM, strLine ); } } if ( m_pResponse.Lookup( _T("UpgradePrompt"), strValue ) ) { m_sUpgradePrompt = strValue; m_pResponse.Lookup( _T("UpgradeFile"), m_sUpgradeFile ); m_pResponse.Lookup( _T("UpgradeSHA1"), m_sUpgradeSHA1 ); m_pResponse.Lookup( _T("UpgradeTiger"), m_sUpgradeTiger ); m_pResponse.Lookup( _T("UpgradeSize"), m_sUpgradeSize ); m_pResponse.Lookup( _T("UpgradeSources"), m_sUpgradeSources ); m_pResponse.Lookup( _T("UpgradeVersion"), m_sUpgradeVersion ); // Old name if ( ! m_sUpgradeSHA1.GetLength() ) m_pResponse.Lookup( _T("UpgradeHash"), m_sUpgradeSHA1 ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradePrompt"), m_sUpgradePrompt ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeFile"), m_sUpgradeFile ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSHA1"), m_sUpgradeSHA1 ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeTiger"), m_sUpgradeTiger); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSize"), m_sUpgradeSize ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSources"), m_sUpgradeSources ); theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeVersion"), m_sUpgradeVersion ); m_bUpgrade = TRUE; } else { theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradePrompt"), _T("") ); m_bUpgrade = FALSE; } if ( m_pResponse.Lookup( _T("AddDiscovery"), strValue ) ) { strValue.TrimLeft(); strValue.TrimRight(); DiscoveryServices.Add( strValue, CDiscoveryService::dsWebCache ); } if ( m_pResponse.Lookup( _T("NextCheck"), strValue ) ) { _stscanf( strValue, _T("%lu"), &nDays ); } SetNextCheck( nDays ); PostMessage( m_hWndNotify, WM_VERSIONCHECK, 0, 0 ); }
BOOL CPPgIRC::OnApply() { // if prop page is closed by pressing ENTER we have to explicitly commit any possibly pending // data from an open edit control m_ctrlTreeOptions.HandleChildControlLosingFocus(); if (!UpdateData()) return FALSE; thePrefs.m_bIRCAddTimeStamp = m_bTimeStamp; thePrefs.m_bIRCPlaySoundEvents = m_bSoundEvents; thePrefs.m_bIRCIgnoreMiscMessages = m_bMiscMessage; thePrefs.m_bIRCIgnoreJoinMessages = m_bJoinMessage; thePrefs.m_bIRCIgnorePartMessages = m_bPartMessage; thePrefs.m_bIRCIgnoreQuitMessages = m_bQuitMessage; thePrefs.m_bIRCIgnoreEmuleAddFriendMsgs = m_bEmuleAddFriend; thePrefs.m_bIRCAllowEmuleAddFriend = m_bEmuleAllowAddFriend; thePrefs.m_bIRCIgnoreEmuleSendLinkMsgs = m_bEmuleSendLink; thePrefs.m_bIRCAcceptLinks = m_bAcceptLinks; thePrefs.m_bIRCAcceptLinksFriendsOnly = m_bIRCAcceptLinksFriendsOnly; thePrefs.m_bIRCJoinHelpChannel = m_bHelpChannel; thePrefs.m_bIRCGetChannelsOnConnect = m_bChannelsOnConnect; bool bOldSmileys = thePrefs.GetIRCEnableSmileys(); thePrefs.m_bIRCEnableSmileys = m_bIRCEnableSmileys; if (bOldSmileys != thePrefs.GetIRCEnableSmileys()) theApp.emuledlg->ircwnd->EnableSmileys(thePrefs.GetIRCEnableSmileys()); if(IsDlgButtonChecked(IDC_IRC_USECHANFILTER)) thePrefs.m_bIRCUseChannelFilter = true; else thePrefs.m_bIRCUseChannelFilter = false; if(IsDlgButtonChecked(IDC_IRC_USEPERFORM)) thePrefs.m_bIRCUsePerform = true; else thePrefs.m_bIRCUsePerform = false; TCHAR buffer[510]; if (GetDlgItem(IDC_IRC_NICK_BOX)->GetWindowTextLength()) { GetDlgItem(IDC_IRC_NICK_BOX)->GetWindowText(buffer, 20); if (_tcscmp(buffer, thePrefs.m_strIRCNick) != 0) { CString input; input.Format(_T("%s"), buffer); input.Trim(); input = input.SpanExcluding(_T(" !@#$%^&*():;<>,.?{}~`+=-")); if (input != _T("")) { theApp.emuledlg->ircwnd->SendString(_T("NICK ") + input); thePrefs.m_strIRCNick = input; } } } if (GetDlgItem(IDC_IRC_SERVER_BOX)->GetWindowTextLength()) GetDlgItem(IDC_IRC_SERVER_BOX)->GetWindowText(thePrefs.m_strIRCServer); GetDlgItem(IDC_IRC_NAME_BOX)->GetWindowText(thePrefs.m_strIRCChannelFilter); GetDlgItem(IDC_IRC_PERFORM_BOX)->GetWindowText(thePrefs.m_strIRCPerformString); if(GetDlgItem(IDC_IRC_MINUSER_BOX)->GetWindowTextLength()) { GetDlgItem(IDC_IRC_MINUSER_BOX)->GetWindowText(buffer,6); thePrefs.m_uIRCChannelUserFilter = _tstoi(buffer); } else thePrefs.m_uIRCChannelUserFilter = 0; LoadSettings(); SetModified(FALSE); return CPropertyPage::OnApply(); }
bool CLogWnd::plug_IncomingData(IPlug *lpFrom, IPlug *lpTo, bool bSendEvent) { String str; if(!(m_hWnd)) return false; lpFrom->getValue(str); if(!str.empty()) { m_lastlogstr = str; CString strbuff(str.c_str()); int pos, img; do { img = 0; // // Get a line // CString aaa = strbuff.SpanExcluding("\n"); // // Find a header // pos = aaa.Find(">>"); if(pos > 0) { CString header; header = aaa.Left(pos); aaa = aaa.Right(aaa.GetLength() - pos-2); img = GetImageId(header); } // // Insert it into the list of messages // if(aaa.GetLength() > 0) { CString bbb = aaa.SpanExcluding("||"); int ic = m_ListLog.GetItemCount(); m_ListLog.InsertItem(ic , bbb, img); // For now let's do it once... int subi = aaa.Find("||",0); if(subi >= 0) { bbb = aaa.Right(aaa.GetLength() - subi - 2); m_ListLog.SetItemText(ic, 1, bbb); } } // // Go to next one. // pos = strbuff.Find("\n",0); if(pos >= 0) { aaa = strbuff.Right(strbuff.GetLength() - pos-1); strbuff = aaa; } } while(pos >= 0); m_ListLog.EnsureVisible(m_ListLog.GetItemCount()-1, TRUE); } // tell the connected readers that data changed. Set bSendEvent=false if you decide to send this // method by your own. if(bSendEvent) lpTo->flush(); return false; }
IWindowLog* CLogWnd::AddMessage(LPCSTR fmt, ...) { //TODO: Add a way to free this up, later ! static char *fmt2 = NULL; static size_t fmt2_sz = 0; va_list vlist; // Get output string va_start(vlist, fmt); int retval; //size_t sz = strlen(fmt)+1; if(!fmt2) { fmt2_sz = 2048; fmt2 = (char*)malloc(fmt2_sz); } while((retval = _vsnprintf(fmt2, fmt2_sz, fmt, vlist)) < 0) // means there wasn't anough room { fmt2_sz *= 2; if(fmt2) free(fmt2); fmt2 = (char*)malloc(fmt2_sz); } #ifdef USEPLUGS m_pluglogstr.setValue(fmt2); #else m_lastlogstr = fmt2; CString strbuff(m_lastlogstr.c_str()); int pos, img; do { img = 0; // // Get a line // CString aaa = strbuff.SpanExcluding("\n"); // // Find a header // pos = aaa.Find(">>"); if(pos > 0) { CString header; header = aaa.Left(pos); aaa = aaa.Right(aaa.GetLength() - pos-2); img = GetImageId(header); } // // Insert it into the list of messages // if(aaa.GetLength() > 0) { CString bbb = aaa.SpanExcluding("||"); int ic = m_ListLog.GetItemCount(); m_ListLog.InsertItem(ic , bbb, img); // For now let's do it once... int subi = aaa.Find("||",0); if(subi >= 0) { bbb = aaa.Right(aaa.GetLength() - subi - 2); m_ListLog.SetItemText(ic, 1, bbb); } } // // Go to next one. // pos = strbuff.Find("\n",0); if(pos >= 0) { aaa = strbuff.Right(strbuff.GetLength() - pos-1); strbuff = aaa; } } while(pos >= 0); m_ListLog.EnsureVisible(m_ListLog.GetItemCount()-1, TRUE); #endif va_end(vlist); //PeekMyself(); return this; }