示例#1
0
Status StatusParser::parse(QString data) {
    data = stripResponseHeader(data);
    QStringList playerList = data.split("\n");

    QString variableData = playerList.first();
    playerList.removeFirst();
    QStringList variableList = variableData.split("\\", QString::SkipEmptyParts);
    QStringListIterator it(variableList);
    Status status;
    while (it.hasNext()) {
        QString key = it.next();
        if(it.hasNext()) {
            QString value = it.next();
            status.variables.insert(key, value);
        }
    }

    QStringListIterator itP(playerList);
    while (itP.hasNext()) {
        QString line = itP.next();
        QStringList playerData = line.split(" ");
        if(playerData.size() >= 3) {
            QString playerName = QStringList(playerData.mid(2)).join(" ");
            playerName.chop(1); // remove first "
            playerName.remove(0, 1); // remove last "
            status.players.append(std::move(Player(playerName,
                                                   playerData[0].toInt(),
                                                   playerData[1].toInt())));
        }
    }

    return status;
}
示例#2
0
int main(int argc, char* argv[])
{

	GString strNetworkConnections(32767);
	GetNetworkConnections(strNetworkConnections,NET_FLAG_REDUCE_INFO|NET_FLAG_NO_UDP);

	GString strWanIP, strNoWanIPError; 
	ExternalIP(&strWanIP, &strNoWanIPError);

	CSmtp mail;
	GString strMailServer("smtp.gmail.com");


	// ------- GMail TLS --------
	// Note about GMail - login, then under "My Account" go to "Sign-In & Security" and set "Allow Less Secure Apps": to ON.  
	// This enables TLS and non-google apps(not insecure apps).  AOL, HotMail, and Yahoo enable the SMTP over TLS relay for
	// the paid email account services with no ads and higher mail/data limits.
	//
	mail.SetSMTPServer(strMailServer,587);
	mail.SetSecurityType(USE_TLS);

#include <"Do.not.compile">  // add your own Gmail account in the next two lines..... then delete this line   (and set the recipient)

	// Note about GMail - login, then under "My Account" go to "Sign-In & Security" and set "Allow Less Secure Apps": to ON.  
//	mail.SetLogin("*****@*****.**");
//	mail.SetPassword("MyOwnPassword");


	mail.SetSenderName("My Application");
	mail.SetSenderMail("*****@*****.**");
	mail.SetReplyTo("*****@*****.**");
	
	GString strSubject(g_strThisHostName);
	strSubject << " Stats";
	mail.SetSubject(strSubject);

	mail.AddRecipient("*****@*****.**");   //<---------------------------------------------------------- Who to send the email to
//	mail.AddRecipient("*****@*****.**");


  	mail.SetXPriority(XPRIORITY_NORMAL);
  	mail.SetXMailer("Professional (v7.77) Pro");
  	

	mail.AddMsgLine("----------------------------Wan IP----------------------------------------");
	mail.AddMsgLine(strWanIP);

	mail.AddMsgLine("----------------------Network Interfaces----------------------------------");
	GString strThisHost("Host:");
	strThisHost << g_strThisHostName;
	mail.AddMsgLine(strThisHost);
	GStringList lstBoundIPAddresses;
	InternalIPs(&lstBoundIPAddresses);
	GStringIterator it2(&lstBoundIPAddresses);
	while(it2())
	{
		mail.AddMsgLine(it2++);
	}

	mail.AddMsgLine("----------------------Network Connections----------------------------------");
	GStringList l("\n",strNetworkConnections); // each row divided by "\n"
	GStringIterator it(&l);
	while(it())
	{
		mail.AddMsgLine(it++);
	}


	mail.AddMsgLine("------------------------Processes-------------------------------------------");
	GString strRunningProcessData;
	GetProcessList( &strRunningProcessData );
	GStringList lstProcess("\n",strRunningProcessData); // each row divided by "\n"
	GStringIterator itP(&lstProcess);
	while(itP())
	{
		//mail.AddMsgLine(itP++);								// write it out -  raw
		GProcessListRow *pRow = new GProcessListRow(itP++);		// or use the already written code to parse process information

		GString strProcess;										// write onluy the data we want into this GString 
		strProcess << "pid:" << pRow->strPID << "   " << pRow->strName  << "     [" << pRow->strBinaryPath << "]";
		mail.AddMsgLine(strProcess);							// then write it out - formatted.
	}
	
  	//mail.AddAttachment("../test1.jpg");
  	//mail.AddAttachment("c:\\test2.exe");
	//mail.AddAttachment("c:\\test3.txt");
	mail.Send();



	return 0;
}