Stripping myInfo in DCH++

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Quattro
Posts: 166
Joined: 2006-01-11 09:23

Stripping myInfo in DCH++

Post by Quattro » 2006-07-13 10:22

i'm trying to strip the myinfo in DCH++
i found this and changed it somewhat but it doesn't do anything (i think)

Code: Select all

case MAKE_CMP('M', 'y', 'I'):
		if( CHECK_REST4('N', 'F', 'O', ' ') ) {						// $MyINFO
			CHECK_USER();
			string::size_type j;
			i = 13;
			j = aLine.find(' ', i);
			if( (j == string::npos) || (j == i) )
				return;

			User* u = getUser();
			if( (aLine[getNick().length()+i] != ' ') ||
				(strncmp(getNick().c_str(), aLine.c_str() + i, getNick().size()) != 0) ) 
			{
				/** @todo Handle the bad myinfo somewhere else... */
				BAD_DATA();
			}
			i = j + 1;
			j = aLine.find('$', i);
			if(j == string::npos) {
				BAD_DATA();
			}
			u->setDescription(Util::emptyString);
			i = j + 3;
			j = aLine.find('$', i);
			if(j == string::npos) {
				BAD_DATA();
			}
			u->setConnection(aLine.substr(i, j-i-1));
			i = j + 1;
			j = aLine.find('$', i);
			if(j == string::npos) {
				BAD_DATA();
			}
			u->setEmail(aLine.substr(i, j-i));
			i = j + 1;
			j = aLine.find('$', i);
			if(j == string::npos) {
				BAD_DATA();
			}
			u->setShared(aLine.substr(i, j-i));
			
			u->setMyInfo(aLine);
			
			Util::stats.myInfos++;
			fire(ClientListener::MyInfo(), this);
			return;
		} 
		break;
this should set the description of people to emptystring was my understanding... where did i go wrong?
this is in Client.cpp in project hub
You can send a message around the world in 1/7 of a second; yet it may take several years to move a simple idea through a 1/4 inch of human skull.

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2006-07-13 22:39

From a first pass, you're not actually modifying the MyINFO string that it passed on, only the internal representation. So, the internal calls will work as you want them, and it will work if it has to manually rebuild the myinfo string, but nobody will actually see the changes.

Quattro
Posts: 166
Joined: 2006-01-11 09:23

Post by Quattro » 2006-07-14 12:24

could any one tell me where to look for because this seemed to be the right place to change the myinfo...
You can send a message around the world in 1/7 of a second; yet it may take several years to move a simple idea through a 1/4 inch of human skull.

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2006-07-14 18:45

u->setMyInfo(aLine);

aLine is never modified to represent the MyINFO without the description. You'll need to do an aLine.erase() when you find the point the description is at.

Quattro
Posts: 166
Joined: 2006-01-11 09:23

Post by Quattro » 2006-07-15 01:23

something like this?

Code: Select all

         u->setDescription(aLine.erase());
         i = j + 3;
         j = aLine.find('$', i);
         if(j == string::npos) {
            BAD_DATA();
         }
*edit
doesn't work, gives

Code: Select all

f:\dchpp-1.0\hub\Client.cpp(320): error C2663: '_STL::basic_string<_CharT>::erase' : 3 overloads have no legal conversion for 'this' pointer
        with
        [
            _CharT=char,
            _Traits=_STL::char_traits<char>,
            _Alloc=_STL::allocator<char>
        ]
would it be possible to change myinfo before it is being sent out.
place a function above this one that get's the MyInfo with getMyInfo.
change it and then call the modified myinfo from the code below?

Code: Select all

if(c->getState() == Client::STATE_MY_INFO) {
		clientValidated(c);
	} else {
		sendToAll(c->getUser()->getMyInfo());
	}
You can send a message around the world in 1/7 of a second; yet it may take several years to move a simple idea through a 1/4 inch of human skull.

Quattro
Posts: 166
Joined: 2006-01-11 09:23

Post by Quattro » 2006-08-27 04:57

i've decided that probably a plugin could do the trick, as long as it can intercept any communication from the hub to the users...
if that isn't the case i can forget writing a plugin :(
anybody have an idea if that is possible?
You can send a message around the world in 1/7 of a second; yet it may take several years to move a simple idea through a 1/4 inch of human skull.

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2006-08-29 00:01

It can in theory, but I don't know enough about the plugin API to know what it allows.

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2006-08-29 06:40

I know the API does, last time i discussed it with Sedulus. ;))
Everyone is supposed to download from the hubs, - I don´t know why, but I never do anymore.

Gabberworld
Posts: 9
Joined: 2004-11-02 12:42

Post by Gabberworld » 2006-08-29 08:51

Code: Select all

string ClientManager::myInfo(Client* c, bool desc, bool mail, bool conn, bool share) throw() {
	if(desc && mail && conn && share){
		return c->getUser()->getMyInfo();
	}else{
		string tmp = "$MyINFO $ALL ";
		tmp += c->getNick();
		tmp += " ";
		if(desc){tmp += c->getUser()->getDescription();}
		tmp += ("$ $");
		if(conn){tmp += (c->getUser()->getConnection());}
		tmp += ("$");
		if(mail){tmp += (c->getUser()->getEmail());}
		tmp += ("$");
		if(share){tmp += (Util::toString(c->getUser()->getShared()));}
		tmp += ("$|");
		return tmp;
	}
}

Locked