Ejemplo n.º 1
0
// Receive message function
void AIMNetManager::ReceiveMessage( SNAC_Object& snac ) {

	short i = 10;
	unsigned short temp, temp2;
	unsigned int languageValue;
	bool autoRespond = false;
	BMessage* incomingMsg = new BMessage(BEAIM_INCOMING_IM);
	DataContainer msg;
	
	// Grab the other person's info
	DecodeBuddyStuff( snac.data, i, incomingMsg );

	// This will be either 0x0002 or 0x0004 (autorespond mode?)
	temp = (unsigned short)GetWord( snac.data, i );
	i += 2;
	if( temp == 0x0004 ) {
		temp = (unsigned short)GetWord( snac.data, i );		// 0x0000
		temp = (unsigned short)GetWord( snac.data, i+2 );	// 0x0002
		autoRespond = true;
		i += 4;
	}

	if( autoRespond )
		printf( "AutoResponded IM...\n" );
	incomingMsg->AddBool( "autorespond", autoRespond );

	// Reality check
	if( temp != 0x0002 )
		printf( "RECV_MESSAGE ERROR: temp should be 0x0002, not 0x%X!\n", temp );
	
	// Get the message length (with 0x0D tacked on), and fixed value 0x0501
	temp = (unsigned short)GetWord( snac.data, i );
	temp = (unsigned short)GetWord( snac.data, i+2 );
	i += 4;
	
	// Another reality check
	if( temp != 0x0501 )
		printf( "RECV_MESSAGE ERROR: temp should be 0x0501, not 0x%X!\n", temp );
	
	// Grab the mysterious language value
	temp = (unsigned short)GetWord( snac.data, i );
	temp2 = (unsigned short)GetWord( snac.data, temp + i + 8 );
	languageValue = (temp2 << 16) + (unsigned short)GetWord( snac.data, temp + i + 6 );
	incomingMsg->AddInt32( "languagevalue", (int32)languageValue );
	i += 2;	
	
	printf( "Mysterious Language value: 0x%X\n", (unsigned)languageValue );
	
	// Get the message itself
	msg = snac.data.getrange( temp + i + 8 );
	msg << char(0);
	incomingMsg->AddString( "message", (char*)msg.c_ptr() );
	
	printf( "actual message: %s\n", msg.c_ptr() );
	
	// Send the message off its final resting place... the great bit-bucket in the sky
	incomingMsg->AddInt32( "wtype", (int32)USER_MESSAGE_TYPE );
	PostAppMessage( incomingMsg );
}
Ejemplo n.º 2
0
void AIMNetManager::ReceiveWarning( SNAC_Object& snac ) {

	BString warnMessage;
	char strNewWLevel[15];
	unsigned short wLevel, i=0;
	DataContainer screenName;
	bool anon = false;
	char snLength;

	wLevel = (unsigned short)( rint( (double)GetWord(snac.data,i) / 10.0 ) );
	i += 2;
	
	printf( "New warning level: %u%%\n", wLevel );
	printf( "... came from " );
	
	// 'twas an anonymous warning
	if( i >= snac.data.length() ) {
		anon = true;
		printf( "Anonymous\n" );
	}
	
	// grab the length, and then the screen name
	if( !anon ) {
		snLength = snac.data[i++];
		screenName = DataContainer( snac.data.getrange(i,snLength) );
		i += snLength;

		screenName << char(0);
		printf( "%s\n", screenName.c_ptr() );
	}
	
	// is our warning level going DOWN? if so, don't annoy the user by telling them about it
	if( wLevel < client->WarningLevel() ) {
		client->SetWarningLevel( wLevel );
		return;
	}

	// make the "warned" message
	client->SetWarningLevel( wLevel );
	sprintf( strNewWLevel, "%u%%", wLevel );
	warnMessage = BString( Language.get("ERR_GOT_WARNED") );
	warnMessage.ReplaceAll( "%WLEVEL", strNewWLevel );
	if( anon ) {
		BString anonLabel = "[";
		anonLabel.Append( Language.get("ANONYMOUS_LABEL") );
		anonLabel.Append( "]" );
		warnMessage.ReplaceAll( "%USER", anonLabel.String() );
	} else
		warnMessage.ReplaceAll( "%USER", screenName.c_ptr() );
	
	// now display it
	windows->ShowMessage( warnMessage, B_STOP_ALERT, Language.get("BEHAVE_LABEL"), WS_WARNED );
}
Ejemplo n.º 3
0
void AIMNetManager::ReceiveSearchResults( SNAC_Object& snac ) {

	DataContainer name;
	char actualName[50];	
	unsigned short length;
	BMessage* sndMessage;
	short i = 0;

	// is this the current search? If not, ignore it
	if( snac.GetRequestID() != emailSearchID )
		return;

	// go through and suck out all the search results
	while( (snac.data.length() - i) > 4 ) {

		// get 0x0001 (a constant), and the length of the screen name
		GetWord( snac.data, i );
		length = (unsigned short)GetWord( snac.data, i+2 );
		i += 4;
		
		printf( "SR---> SN length: %d chars\n", length );
		
		// get the screen name itself
		name = snac.data.getrange( i, length );
		strncpy( actualName, name.c_ptr(), length );
		actualName[length] = '\0';
		i += length;
		
		printf( "SR---> SN name: %s\n", name.c_ptr() );
		
		// send a message with this match
		sndMessage = new BMessage( BEAIM_EMAIL_SEARCH_RESULTS );
		sndMessage->AddString( "userid", actualName );
		PostAppMessage( sndMessage );
	}
}