Пример #1
0
void
CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CString data)
{
	size_t startPos = 0;
	size_t findResult1 = 0;
	size_t findResult2 = 0;
	dragFileList.clear();
	CString slash("\\");
	if (data.find("/", startPos) != -1) {
		slash = "/";
	}

	while (fileNum) {
		findResult1 = data.find('\0', startPos);
		findResult2 = data.find_last_of(slash, findResult1);

		if (findResult1 == startPos) {
			//TODO: file number does not match, something goes wrong
			break;
		}
		if (findResult1 - findResult2 > 1) {
			dragFileList.push_back(data.substr(findResult2 + 1, findResult1 - findResult2));
		}
		startPos = findResult1 + 1;
		--fileNum;
	}
}
Пример #2
0
CString CLevel::getSignCode(CString& pText)
{
	CString retVal;
	int txtLen = pText.length();
	for(int i = 0; i < txtLen; i++)
	{
		char letter = pText[i];
		if(letter == '#')
		{
			i ++;
			if(i < txtLen)
			{
				letter = pText[i];
				int code = signSymbols.find(letter);
				if(code >= 0)
				{
					for(int ii = 0; ii < ctablen[code]; ii++)
						retVal.writeChar(ctab[ctabindex[code] + ii] + 32);
				}
			}
		} else
		{
			int code = signText.find(letter);
			if(code >= 0)
				retVal.writeChar(code+32);
		}
	}
	return retVal;
}
Пример #3
0
void StepManiaLanServer::AnalizeChat(PacketFunctions &Packet, const unsigned int clientNum)
{
	CString message = Packet.ReadNT();
	if (message.at(0) == '/')
	{
		CString command = message.substr(1, message.find(" ")-1);
		if ((command.compare("list") == 0)||(command.compare("have") == 0))
		{
			if (command.compare("list") == 0)
			{
				Reply.ClearPacket();
				Reply.Write1(NSCCM + NSServerOffset);
				Reply.WriteNT(ListPlayers());
				SendNetPacket(clientNum, Reply);
			}
			else
			{
				message = "";
				message += Client[clientNum]->Player[0].name;
				if (Client[clientNum]->twoPlayers)
					message += "&";
				message += Client[clientNum]->Player[1].name;
				message += " forces has song.";
				Client[clientNum]->forceHas = true;
				ServerChat(message);
			}
		}
		else
		{
			if (clientNum == 0)
			{
				if (command.compare("force_start") == 0)
					ForceStart();
				if (command.compare("kick") == 0)
				{
					CString name = message.substr(message.find(" ")+1);
					Kick(name);
				}
				if (command.compare("ban") == 0)
				{
					CString name = message.substr(message.find(" ")+1);
					Ban(name);
				}
			}
			else
			{
				Reply.ClearPacket();
				Reply.Write1(NSCCM + NSServerOffset);
				Reply.WriteNT("You do not have permission to use server commands.");
				SendNetPacket(clientNum, Reply);
			}
		}
	}
	else
		RelayChat(message, clientNum);
}
Пример #4
0
 void HandleMessage(CNick& Nick, const CString& sMessage)
 {
     if (!m_sAuth.empty()
             && Nick.GetNick().CaseCmp("Q") == 0
             && Nick.GetHost().CaseCmp("CServe.quakenet.org")  == 0
             && sMessage.find("AUTH") != CString::npos
             && sMessage.find("authenticate") != CString::npos) {
         PutIRC("PRIVMSG [email protected] :auth " + m_sAuth);
     }
 }
void
CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CString data)
{
	size_t startPos = 0;
	size_t findResult1 = 0;
	size_t findResult2 = 0;
	dragFileList.clear();
	CString slash("\\");
	if (data.find("/", startPos) != string::npos) {
		slash = "/";
	}
	
	UInt32 index = 0;
	while (index < fileNum) {
		findResult1 = data.find(',', startPos);
		findResult2 = data.find_last_of(slash, findResult1);

		if (findResult1 == startPos) {
			//TODO: file number does not match, something goes wrong
			break;
		}
		
		// set filename
		if (findResult1 - findResult2 > 1) {
			CString filename = data.substr(findResult2 + 1,
				findResult1 - findResult2 - 1);
			CDragInformation di;
			di.setFilename(filename);
			dragFileList.push_back(di);
		}
		startPos = findResult1 + 1;
		
		//set filesize
		findResult2 = data.find(',', startPos);
		if (findResult2 - findResult1 > 1) {
			CString filesize = data.substr(findResult1 + 1,
										   findResult2 - findResult1 - 1);
			size_t size = stringToNum(filesize);
			dragFileList.at(index).setFilesize(size);
		}
		startPos = findResult1 + 1;
		
		++index;
	}

	LOG((CLOG_DEBUG "drag info received, total drag file number: %i",
		dragFileList.size()));

	for (size_t i = 0; i < dragFileList.size(); ++i) {
		LOG((CLOG_DEBUG2 "dragging file %i name: %s",
			i + 1,
			dragFileList.at(i).getFilename().c_str()));
	}
}
Пример #6
0
	void HandleMessage(CNick& Nick, const CString& sMessage)
	{
		if (!m_sPass.empty()
				&& Nick.GetNick().Equals("NickServ")
				&& (sMessage.find("msg") != CString::npos
				 || sMessage.find("authenticate") != CString::npos)
				&& sMessage.AsUpper().find("IDENTIFY") != CString::npos
				&& sMessage.find("help") == CString::npos) {
			PutIRC("PRIVMSG NickServ :IDENTIFY " + m_sPass);
		}
	}
Пример #7
0
void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
	CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
	switch (m->type()) {
		case kIpcCommand: {
			CIpcCommandMessage* cm = static_cast<CIpcCommandMessage*>(m);
			CString command = cm->command();
			LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));

			CString debugArg("--debug");
			UInt32 debugArgPos = static_cast<UInt32>(command.find(debugArg));
			if (debugArgPos != CString::npos) {
				UInt32 from = debugArgPos + static_cast<UInt32>(debugArg.size()) + 1;
				UInt32 nextSpace = static_cast<UInt32>(command.find(" ", from));
				CString logLevel(command.substr(from, nextSpace - from));
				
				try {
					// change log level based on that in the command string
					// and change to that log level now.
					ARCH->setting("LogLevel", logLevel);
					CLOG->setFilter(logLevel.c_str());
				}
				catch (XArch& e) {
					LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str()));
				}
			}

			try {
				// store command in system settings. this is used when the daemon
				// next starts.
				ARCH->setting("Command", command);

				// TODO: it would be nice to store bools/ints...
				ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
			}
			catch (XArch& e) {
				LOG((CLOG_ERR "failed to save settings, %s", e.what().c_str()));
			}

#if SYSAPI_WIN32
			// tell the relauncher about the new command. this causes the
			// relauncher to stop the existing command and start the new
			// command.
			m_relauncher->command(command, cm->elevate());
#endif
			break;
		}

		case kIpcHello:
			m_ipcLogOutputter->notifyBuffer();
			break;
	}
}
Пример #8
0
static size_t FindEndOfHeaders( const CString &buf )
{
	size_t iPos1 = buf.find( "\n\n" );
	size_t iPos2 = buf.find( "\r\n\r\n" );
	LOG->Trace("end: %u, %u", unsigned(iPos1), unsigned(iPos2));
	if( iPos1 != string::npos && (iPos2 == string::npos || iPos2 > iPos1) )
		return iPos1 + 2;
	else if( iPos2 != string::npos && (iPos1 == string::npos || iPos1 > iPos2) )
		return iPos2 + 4;
	else
		return string::npos;
}
Пример #9
0
bool CLogMod::OnLoad(const CString& sArgs, CString& sMessage)
{
	size_t uIndex = 0;
	if (sArgs.Token(0).Equals("-sanitize"))
	{
		m_bSanitize = true;
		++uIndex;
	}

	// Use load parameter as save path
	m_sLogPath = sArgs.Token(uIndex);

	// Add default filename to path if it's a folder
	if (GetType() == CModInfo::UserModule) {
		if (m_sLogPath.Right(1) == "/" || m_sLogPath.find("$WINDOW") == CString::npos || m_sLogPath.find("$NETWORK") == CString::npos) {
			if (!m_sLogPath.empty()) {
				m_sLogPath += "/";
			}
			m_sLogPath += "$NETWORK/$WINDOW/%Y-%m-%d.log";
		}
	} else if (GetType() == CModInfo::NetworkModule) {
		if (m_sLogPath.Right(1) == "/" || m_sLogPath.find("$WINDOW") == CString::npos) {
			if (!m_sLogPath.empty()) {
				m_sLogPath += "/";
			}
			m_sLogPath += "$WINDOW/%Y-%m-%d.log";
		}
	} else {
		if (m_sLogPath.Right(1) == "/" || m_sLogPath.find("$USER") == CString::npos || m_sLogPath.find("$WINDOW") == CString::npos || m_sLogPath.find("$NETWORK") == CString::npos) {
			if (!m_sLogPath.empty()) {
				m_sLogPath += "/";
			}
			m_sLogPath += "$USER/$NETWORK/$WINDOW/%Y-%m-%d.log";
		}
	}

	CString sRules = GetNV("rules");
	VCString vsRules = SplitRules(sRules);
	SetRules(vsRules);

	// Check if it's allowed to write in this path in general
	m_sLogPath = CDir::CheckPathPrefix(GetSavePath(), m_sLogPath);
	if (m_sLogPath.empty())
	{
		sMessage = "Invalid log path ["+m_sLogPath+"].";
		return false;
	} else {
		sMessage = "Logging to ["+m_sLogPath+"].";
		return true;
	}
}
Пример #10
0
        EModRet OnRaw(CString& sLine) {
                CString sCmd = sLine.Token(0).AsUpper();

                if(sCmd == "ERROR") {
                        CString sRest = sLine.Token(1, true).AsLower();

                        if(sRest.find("lined") != CString::npos || sRest.find("kill") != CString::npos) {
                                if(m_pUser) {
					SendAdmins(m_pUser->GetUserName() + " (killed: " + sLine + ")");
                                }
                        }
                }
                return CONTINUE;
        }
Пример #11
0
 void HandleMessage(CNick& Nick, const CString& sMessage) {
     CString sNickServName = (!GetNV("NickServName").empty())
                                 ? GetNV("NickServName")
                                 : "NickServ";
     if (!GetNV("Password").empty() && Nick.NickEquals(sNickServName) &&
         (sMessage.find("msg") != CString::npos ||
          sMessage.find("authenticate") != CString::npos ||
          sMessage.find("choose a different nickname") != CString::npos ||
          sMessage.find("please choose a different nick") != CString::npos ||
          sMessage.find("If this is your nick, identify yourself with") !=
              CString::npos ||
          sMessage.find("If this is your nick, type") != CString::npos ||
          sMessage.find("This is a registered nickname, please identify") !=
              CString::npos ||
          sMessage.StripControls_n().find(
              "type /NickServ IDENTIFY password") != CString::npos ||
          sMessage.StripControls_n().find(
              "type /msg NickServ IDENTIFY password") != CString::npos) &&
         sMessage.AsUpper().find("IDENTIFY") != CString::npos &&
         sMessage.find("help") == CString::npos) {
         MCString msValues;
         msValues["password"] = GetNV("Password");
         PutIRC(CString::NamedFormat(GetNV("IdentifyCmd"), msValues));
     }
 }
Пример #12
0
CString CLevel::getSignCode(CString& pText)
{
	CString retVal;
	int txtLen = pText.length();
	for(int i = 0; i < txtLen; i++)
	{
		char letter = pText[i];
		if(letter == '#')
		{
			i ++;
			if(i < txtLen)
			{
				letter = pText[i];
				int code = signSymbols.find(letter);
				if(code != -1)
				{
					for(int ii = 0; ii < ctablen[code]; ii++)
						retVal.writeChar(ctab[ctabindex[code] + ii] + 32);
					continue;
				} else letter = pText[--i];
			}
		}

		int code = signText.find(letter);
		if (letter == '#') code = 86;
		if(code != -1)
			retVal.writeChar(code+32);
		else
		{
			retVal.writeChar(86 +32);	// #
			retVal.writeChar(10 +32);	// K
			retVal.writeChar(69 +32);	// (

			char buf[10];
			memset(buf, 0, 10);
			sprintf(buf,"%d", code);
			CString scode(buf);
			for (int i = 0; i < scode.length(); ++i)
			{
				int c = signText.find(scode[i]);
				if (c != -1) retVal.writeChar(c +32);
			}

			retVal.writeChar(70 +32);	// )
		}
	}
	return retVal;
}
Пример #13
0
bool getline(CString &_str, CString &line){
  if(_str.size()==0)  return false;
  CString::size_type pLeft=0, pRight = _str.find('\n');
  line = _str.substr( pLeft, pRight );
  _str = _str.erase(0,pRight+1);
  return true;
};
Пример #14
0
/* Search for the commandline argument given; eg. "test" searches for
 * the option "--test".  All commandline arguments are getopt_long style:
 * --foo; short arguments (-x) are not supported.  (As commandline arguments
 * are not intended for common, general use, having short options isn't
 * needed.)  If argument is non-NULL, accept an argument. */
bool GetCommandlineArgument( const CString &option, CString *argument, int iIndex )
{
	const CString optstr = "--" + option;
	
	for( int arg = 1; arg < g_argc; ++arg )
	{
		const CString CurArgument = g_argv[arg];

		const size_t i = CurArgument.find( "=" );
		CString CurOption = CurArgument.substr(0,i);
		if( CurOption.CompareNoCase(optstr) )
			continue; /* no match */

		/* Found it. */
		if( iIndex )
		{
			--iIndex;
			continue;
		}

		if( argument )
		{
			if( i != CString::npos )
				*argument = CurArgument.substr( i+1 );
			else
				*argument = "";
		}
		
		return true;
	}

	return false;
}
Пример #15
0
CLevel::CLevel(CString& pFileName)
{
	map = NULL;
	baddyIds.add(0);
	levelIndex = 0;
	sparZone = opened = false;
	saveCounter = 5;
	memset(tiles, 0, sizeof(tiles));

	if(pFileName.find(".nw") >= 0)
	{
		if(!loadNW(pFileName))
			return;
	} else
	{
		if(!loadGraal(pFileName))
			return;
	}

	//Find our map id
	for(int i = 0; i < CMap::mapList.count(); i++)
	{
		CMap* m = (CMap*)CMap::mapList[i];
		if((levelIndex = m->getLevelpos(pFileName)) >= 0)
		{
			map = m;
			break;
		}
	}
	opened = true;
}
Пример #16
0
	EModRet OnRaw(CString& sLine)
	{
		if(sLine.Left(m_look.size()).Equals(m_look))
		{
			CString sChan = sLine.Token(2);
			CString sMsg = sLine.Token(3, true);
			sMsg.LeftChomp();

			if(sMsg.empty() || sMsg[0] != '<')
				return CONTINUE;

			CString::size_type uPos = sMsg.find('>');
			if(uPos == CString::npos)
				return CONTINUE;

			CString sTempNick = sMsg.substr(1, uPos - 1);
			CString sNick;
			for(size_t p = 0; p < sTempNick.size(); p++)
			{
				if(isalnum(sTempNick[p]) || std::string("[\\]^_-{|}").find(sTempNick[p]) != CString::npos)
				{
					sNick += sTempNick[p];
				}
			}

			sNick += "|S";

			sLine = ":" + sNick + "[email protected] PRIVMSG " + sChan + " :" + sMsg.substr(uPos + 2);
		}
		return CONTINUE;
	}
Пример #17
0
void CFileTreeCtrl::setSelectedFullPath(const std::wstring &sPath)
{
    populate();

    SetRedraw(FALSE);
    SetCursor(LoadCursor(NULL, IDC_WAIT));

    SelectItem(m_hRoot);
    Expand(m_hRoot, TVE_EXPAND);

    // Traverse Tree
    HTREEITEM hItem = m_hRoot;
    HTREEITEM hChildItem;
    HTREEITEM hNextItem;

    std::vector<std::wstring> tokens;
    std::vector<std::wstring>::const_iterator iterToken;
    Utils::tokenize(sPath, tokens, L"\\/");

    CString sItemValue;
    for(iterToken = tokens.begin(); iterToken != tokens.end(); ++iterToken)
    {
        hChildItem = GetChildItem(hItem);

        while (hChildItem != NULL)
        {
            hNextItem = GetNextItem(hChildItem, TVGN_NEXT);

            std::wstring sItemValue = GetItemText(hChildItem);
            std::wstring::size_type pos = sItemValue.find(L"\\", 0);
            if(pos != std::wstring::npos)
                sItemValue.erase(pos);

            if(sItemValue == *iterToken)
            {
                break;
            }

            hChildItem = hNextItem;
        }

        hItem = hChildItem;

        if(hItem != NULL)
        {
            // Found a matching item, select it and force expansion to populate tree
            SelectItem(hItem);
            Expand(hItem, TVE_EXPAND);
        }
        else
        {
            // Didn't find a matching item
            break;
        }
    }

    SetCursor(LoadCursor (NULL, IDC_ARROW));
    SetRedraw(TRUE);
}
Пример #18
0
void
CArgParser::splitCommandString(CString& command, std::vector<CString>& argv)
{
	if (command.empty()) {
		return ;
	}

	size_t leftDoubleQuote = 0;
	size_t rightDoubleQuote = 0;
	searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote);

	size_t startPos = 0;
	size_t space = command.find(" ", startPos);

	while (space != CString::npos) {
		bool ignoreThisSpace = false;

		// check if the space is between two double quotes
		if (space > leftDoubleQuote && space < rightDoubleQuote) {
			ignoreThisSpace = true;
		}
		else if (space > rightDoubleQuote){
			searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1);
		}
		
		if (!ignoreThisSpace) {
			CString subString = command.substr(startPos, space - startPos);

			removeDoubleQuotes(subString);
			argv.push_back(subString);
		}

		// find next space
		if (ignoreThisSpace) {
			space = command.find(" ", rightDoubleQuote + 1);
		}
		else {
			startPos = space + 1;
			space = command.find(" ", startPos);
		}
	}

	CString subString = command.substr(startPos, command.size());
	removeDoubleQuotes(subString);
	argv.push_back(subString);
}
Пример #19
0
bool CUser::SetStatusPrefix(const CString& s) {
	if ((!s.empty()) && (s.length() < 6) && (s.find(' ') == CString::npos)) {
		m_sStatusPrefix = (s.empty()) ? "*" : s;
		return true;
	}

	return false;
}
Пример #20
0
CString gs2ToGameMonkey(CString gs2Code)
{
	CString prefix;
	CString parsedCode;
	std::vector<CString> clean = gs2Code.tokenize("\xa7");
	int bracketCount = 0;
	for (std::vector<CString>::iterator i = clean.begin(); i != clean.end(); ++i)
	{
		CString line = *i;

		//Functions
		if (line.readChars(CString("function").length()) == "function")
		{
			CString fullFunction = line.subString(CString("function").length()+1);
			CString functionName = fullFunction.readString("(");
			CString prefix; 
			//this. or global?
			prefix << "." << functionName << " = function" << fullFunction.subString(functionName.length());
			parsedCode << prefix;
			bracketCount = 1;
		}
		else if (line.find("{") >= 0)
		{
			bracketCount++;
			parsedCode << line;
		}
		//Make sure this is ; on the end of }
		else if (line.find("}") >= 0)
		{
			bracketCount--;

			if (bracketCount > 1) 
			{
				parsedCode << line;
				continue;
			}

			CString semi;
			while(line.subString(line.find("}")+1,1) != ";")
			{
				if (line.subString(line.find("}")+1,1) != ";")
				{
					semi << line.subString(0,line.find("}")+1) << ";" << line.subString(line.find("}")+1);
					line = semi;
				}
			}
			if (semi.isEmpty()) 
				parsedCode << "};";
			else 
				parsedCode << semi;
		}
		else if(line.find("SPC") >= 0)
		{
			line.replaceAllI("SPC"," + \" \" + ");
			parsedCode << line;
		}
		else parsedCode << line;
	}
	return parsedCode;
}
Пример #21
0
Файл: q.cpp Проект: Adam-/znc
    void HandleNeed(const CChan& Channel, const CString& sPerms) {
        MCString::iterator it = m_msChanModes.find(Channel.GetName());
        if (it == m_msChanModes.end()) return;
        CString sModes = it->second;

        bool bMaster = (sModes.find("m") != CString::npos) ||
                       (sModes.find("n") != CString::npos);

        if (sPerms.find("o") != CString::npos) {
            bool bOp = (sModes.find("o") != CString::npos);
            bool bAutoOp = (sModes.find("a") != CString::npos);
            if (bMaster || bOp) {
                if (!bAutoOp) {
                    PutModule("RequestPerms: Requesting op on " +
                              Channel.GetName());
                    PutQ("OP " + Channel.GetName());
                }
                return;
            }
        }

        if (sPerms.find("v") != CString::npos) {
            bool bVoice = (sModes.find("v") != CString::npos);
            bool bAutoVoice = (sModes.find("g") != CString::npos);
            if (bMaster || bVoice) {
                if (!bAutoVoice) {
                    PutModule("RequestPerms: Requesting voice on " +
                              Channel.GetName());
                    PutQ("VOICE " + Channel.GetName());
                }
                return;
            }
        }
    }
Пример #22
0
bool
CConfig::isValidScreenName(const CString& name) const
{
	// name is valid if matches validname
	//  name      ::= [_A-Za-z0-9] | [_A-Za-z0-9][-_A-Za-z0-9]*[_A-Za-z0-9]
	//  domain    ::= . name
	//  validname ::= name domain*
	// we also accept names ending in . because many OS X users have
	// so misconfigured their systems.

	// empty name is invalid
	if (name.empty()) {
		return false;
	}

	// check each dot separated part
	CString::size_type b = 0;
	for (;;) {
		// accept trailing .
		if (b == name.size()) {
			break;
		}

		// find end of part
		CString::size_type e = name.find('.', b);
		if (e == CString::npos) {
			e = name.size();
		}

		// part may not be empty
		if (e - b < 1) {
			return false;
		}

		// check first and last characters
		if (!(isalnum(name[b]) || name[b] == '_') ||
			!(isalnum(name[e - 1]) || name[e - 1] == '_')) {
			return false;
		}

		// check interior characters
		for (CString::size_type i = b; i < e; ++i) {
			if (!isalnum(name[i]) && name[i] != '_' && name[i] != '-') {
				return false;
			}
		}

		// next part
		if (e == name.size()) {
			// no more parts
			break;
		}
		b = e + 1;
	}

	return true;
}
Пример #23
0
	inline bool isValidDir(const CString& dir)
	{
		for(int i=0; i< MAX_CHARS; i++)
		{
			if (dir.find(unSupportedChars[i]) !=CString::npos)
				return false;
		}
		return true;
	}
Пример #24
0
CString encodeSignCode(CString& pText)
{
	CString retVal;
	int txtLen = pText.length();
	for (int i = 0; i < txtLen; i++)
	{
		char letter = pText[i];
		if (letter == '#')
		{
			i++;
			if (i < txtLen)
			{
				letter = pText[i];
				int code = signSymbols.find(letter);
				if (code != -1)
				{
					for (int ii = 0; ii < ctablen[code]; ii++)
						retVal.writeGChar((char)ctab[ctabindex[code] + ii]);
					continue;
				}
				else letter = pText[--i];
			}
		}

		int code = signText.find(letter);
		if (letter == '#') code = 86;
		if (code != -1)
			retVal.writeGChar((char)code);
		else
		{
			if (letter != '\r')
			{
				// Write the character code directly into the sign.
				retVal >> (char)86 >> (char)10 >> (char)69;		// #K(
				CString scode((int)letter);
				for (int i = 0; i < scode.length(); ++i)
				{
					int c = signText.find(scode[i]);
					if (scode != -1) retVal.writeGChar((char)c);
				}
				retVal >> (char)70;								// )
			}
		}
	}
Пример #25
0
void
CPrimaryClient::setClipboard(ClipboardID id, const IClipboard* clipboard)
{
	LOG((CLOG_INFO "xCprimaryClient::setClipboard call. Name: %s", getName().c_str()));
	// ignore if this clipboard is already clean
	if (m_clipboardDirty[id]) {
		// this clipboard is now clean
		m_clipboardDirty[id] = false;
	CClipboard Clipboard;
	Clipboard.copy(&Clipboard,clipboard); 
	Clipboard.open(0);
			CString content, new_content;
			if(Clipboard.has(IClipboard::kFilePath)) 
			{
				CString prefix, source;
				content = Clipboard.get(IClipboard::kFilePath);
				size_t pos = content.find("\n");
				source = content.substr(0,pos);
				//content = content.substr(pos+1, content.size());
				CScreenMounts *map = ((CServerApp*) &ARCH->app())->args().m_config->getMounts(source, getName());
				LOG((CLOG_INFO "X_PAS1 setClipboard: %s %s",source.c_str(), content.c_str()));
				
				if (map!=NULL && !map->empty())
				{
					while (pos < content.size())
					{
						++pos;
						CString line = content.substr(pos, content.find("\n", pos)-pos+1);
						pos = content.find("\n", pos);
						LOG ((CLOG_INFO "X_PAS2 The line is: %s\n", line.c_str()));
						for( CScreenMounts::iterator it = map->begin(); it != map->end(); it++)
						{
							int p = line.find(it->first);
							
							if( p != std::string::npos)
							{
								line = it->second + line.substr(p + it->first.size() );
								
								break;
							}
						}
						LOG ((CLOG_INFO "it changed to: %s\n", line.c_str()));
						new_content.append(line);
					}
					Clipboard.add(IClipboard::kFilePath, new_content);
					LOG((CLOG_INFO "X_PAS3 setClipboard: %s %s",source.c_str(), Clipboard.get(IClipboard::kFilePath).c_str()));
				}
				LOG((CLOG_INFO "X_PAS4 Changed2 clipboard: %s", new_content.c_str()));
			}		
			Clipboard.close();
		// set clipboard
		m_screen->setClipboard(id, &Clipboard);
	}
}
Пример #26
0
	bool IncludesMentionKeyword(const CString& sMessage, const CString &sNick) const {
		bool bResult = false;

		for (VCString::const_iterator it = m_vMentionKeywords.begin();
				it != m_vMentionKeywords.end(); ++it) {
			const CString& sKeyword = *it;

			if (sKeyword.Equals("{nick}") && sMessage.find(sNick) != std::string::npos) {
				bResult = true;
				break;
			}

			if (sMessage.find(sKeyword) != std::string::npos) {
				bResult = true;
				break;
			}
		}

		return bResult;
	}
Пример #27
0
bool CServer::IsValidHostName(const CString& sHostName) {
	if (sHostName.empty()) {
		return false;
	}

	if (sHostName.find(' ') != CString::npos) {
		return false;
	}

	return true;
}
CString
CMSWindowsClipboardUTF16Converter::doToIClipboard(const CString& data) const
{
    // convert and strip nul terminator
    CString dst          = CUnicode::UTF16ToUTF8(data);
    CString::size_type n = dst.find('\0');
    if (n != CString::npos) {
        dst.erase(n);
    }
    return dst;
}
Пример #29
0
CString getFileExtension(CString& pFileName)
{
	CString retVal;
	int pos = pFileName.find('.');
	if(pos >= 0)
	{
		for(int i = pos; i < pFileName.length(); i++)
			retVal.writeChar(pFileName[i]);
	}
	return retVal;
}
Пример #30
0
bool CProtocol::Process ( const CString& szLine )
{
    bool bGotText = false;
    std::vector < CString > vec;

    // Separamos los tokens del comando
    size_t iPos = szLine.find ( ':' );
    if ( iPos != CString::npos )
    {
        bGotText = true;
        szLine.Split ( vec, ' ', 0, iPos - 1 );
        vec [ vec.size () - 1 ] = std::string ( szLine, iPos + 1 );
    }
    else
        szLine.Split ( vec, ' ' );


    if ( !m_bGotServer )
    {
        // El primer mensaje esperado es el de la información del servidor al que nos conectamos
        if ( bGotText && szLine.compare ( 0, 6, "SERVER" ) == 0 )
        {
            // Procesamos el mensaje
            CMessageSERVER message;
            message.SetSource ( NULL );
            if ( ! message.ProcessMessage ( szLine, vec ) )
                return false;

            // Generamos el numérico

            m_bGotServer = true;
            new CServer ( &m_me, message.GetYXX (), message.GetHost (), message.GetDesc (), message.GetFlags () );
            return true;
        }

        return false;
    }

    // Buscamos el orígen del mensaje
    CClient* pSource = 0;
    unsigned long ulNumeric = base64toint ( vec [ 0 ] );
    if ( ulNumeric > 4095 )
    {
        // Es un usuario
        CServer* pServer;

        if ( ulNumeric > 262143 )
        {
            // Servidor con numérico de dos dígitos
            pServer = m_me.GetServer ( ulNumeric >> 18 );
            if ( pServer )
                pSource = pServer->GetUser ( ulNumeric & 262143 );
        }