<commit_before>/*
  oscarsocket.aim.cpp  -  AIM specific part of Oscarsocket

  Kopete    (c) 2003 by the Kopete developers  <<EMAIL>>

  *************************************************************************
  *                                                                       *
  * This program is free software; you can redistribute it and/or modify  *
  * it under the terms of the GNU General Public License as published by  *
  * the Free Software Foundation; either version 2 of the License, or     *
  * (at your option) any later version.                                   *
  *                                                                       *
  *************************************************************************
*/

extern "C"
{
#include "md5.h"
};

#include "oscarsocket.h"

#include "oscarprotocol.h"
#include "oscaraccount.h"
#include "oscardebugdialog.h"

#include <kdebug.h>

// ----------------------------------------------------------------------------------------

#define AIM_MD5_STRING 				"AOL Instant Messenger (SM)"
#define AIM_CLIENTSTRING			"AOL Instant Messenger (SM), version 4.8.2790/WIN32"

#define AIM_CLIENTID					0x0109
#define AIM_MAJOR						0x0004
#define AIM_MINOR						0x0008
#define AIM_POINT						0x0000
#define AIM_BUILD						0x0ae6
static const char AIM_OTHER[] = { 0x00, 0x00, 0x00, 0xbb };
#define AIM_COUNTRY					"us"
#define AIM_LANG						"en"

// ----------------------------------------------------------------------------------------

// Sends login information, actually logs onto the server
void OscarSocket::sendLoginAIM(void)
{
	kdDebug(14150) << k_funcinfo << "Sending AIM login info..." << endl;;
	unsigned char digest[16];
	digest[16] = '\0';  //do this so that addTLV sees a NULL-terminator

	Buffer outbuf;
	outbuf.addSnac(0x0017,0x0002,0x0000,0x00000000);
	outbuf.addTLV(0x0001,getSN().length(),getSN().latin1());

	encodePassword(digest);

	outbuf.addTLV(0x0025,16,(char *)digest);
	outbuf.addTLV(0x0003,0x32,AIM_CLIENTSTRING);
	outbuf.addTLV16(0x0016,AIM_CLIENTID);
	outbuf.addTLV16(0x0017,AIM_MAJOR);
	outbuf.addTLV16(0x0018,AIM_MINOR);
	outbuf.addTLV16(0x0019,AIM_POINT);
	outbuf.addTLV16(0x001a,AIM_BUILD);
	outbuf.addTLV(0x0014,0x0004,AIM_OTHER);
	outbuf.addTLV(0x000f,0x0002,AIM_LANG);
	outbuf.addTLV(0x000e,0x0002,AIM_COUNTRY);

	//if set, old-style buddy lists will not work... you will need to use SSI
	outbuf.addTLV8(0x004a,0x01);

	sendBuf(outbuf,0x02);
	kdDebug(14150) << k_funcinfo << "emitting connectionChanged" << endl;
//	emit connectionChanged(3,"Sending username and password...");
}

// Parses a minityping notification from the server
void OscarSocket::parseMiniTypeNotify(Buffer &inbuf)
{
	kdDebug(14150) << k_funcinfo << "RECV (SRV_TYPINGNOTIFY) SNAC(4,20)" << endl;
	// Throw away 8 bytes which are all zeros
	inbuf.getDWord();
	inbuf.getDWord();

	// Throw away two bytes (0x0001) which are always there
	inbuf.getWord();

	// The length of the screen name
	int snlen = inbuf.getByte();
	kdDebug(14150) << "Trying to find username of length: " << snlen << endl;

	// The screen name
	char *sn = inbuf.getBlock(snlen);
	QString screenName = QString::fromLatin1(sn);
	delete [] sn;

	// Get the actual notification
	WORD notification = inbuf.getWord();

	kdDebug(14150) << "[OSCAR] Determining Minitype from user '" << screenName << "'" << endl;

	switch(notification)
	{
		case 0x0000:
			emit gotMiniTypeNotification(screenName, 0);
			break;
		case 0x0001:
			// Text Typed
			emit gotMiniTypeNotification(screenName, 1);
			break;
		case 0x0002:
			// Typing Started
			emit gotMiniTypeNotification(screenName, 2);
			break;
		default:
			kdDebug(14150) << "[OSCAR] MiniType Error: " << notification << endl;
	}
}

void OscarSocket::sendMiniTypingNotify(QString screenName, TypingNotify notifyType)
{
	kdDebug(14150) << k_funcinfo << "Sending Typing notify " << endl;

	//look for direct connection before sending through server
	OscarConnection *dc = mDirectIMMgr->findConnection(screenName);
	if(dc)<commit_msg>Comment<commit_after>/*
  oscarsocket.aim.cpp  -  AIM specific part of Oscarsocket

  Kopete    (c) 2003 by the Kopete developers  <<EMAIL>>

  *************************************************************************
  *                                                                       *
  * This program is free software; you can redistribute it and/or modify  *
  * it under the terms of the GNU General Public License as published by  *
  * the Free Software Foundation; either version 2 of the License, or     *
  * (at your option) any later version.                                   *
  *                                                                       *
  *************************************************************************
*/

extern "C"
{
#include "md5.h"
};

#include "oscarsocket.h"

#include "oscarprotocol.h"
#include "oscaraccount.h"
#include "oscardebugdialog.h"

#include <kdebug.h>

// ----------------------------------------------------------------------------------------

#define AIM_MD5_STRING 				"AOL Instant Messenger (SM)"
#define AIM_CLIENTSTRING			"AOL Instant Messenger (SM), version 4.8.2790/WIN32"

#define AIM_CLIENTID					0x0109
#define AIM_MAJOR						0x0004
#define AIM_MINOR						0x0008
#define AIM_POINT						0x0000
#define AIM_BUILD						0x0ae6
static const char AIM_OTHER[] = { 0x00, 0x00, 0x00, 0xbb };
#define AIM_COUNTRY					"us"
#define AIM_LANG						"en"

// ----------------------------------------------------------------------------------------

// Sends login information, actually logs onto the server
void OscarSocket::sendLoginAIM(void)
{
	kdDebug(14150) << k_funcinfo << "Sending AIM login info..." << endl;;
	unsigned char digest[16];
	digest[16] = '\0';  //do this so that addTLV sees a NULL-terminator

	Buffer outbuf;
	outbuf.addSnac(0x0017,0x0002,0x0000,0x00000000);
	outbuf.addTLV(0x0001,getSN().length(),getSN().latin1());

	encodePassword(digest);

	outbuf.addTLV(0x0025,16,(char *)digest);
	outbuf.addTLV(0x0003,0x32,AIM_CLIENTSTRING);
	outbuf.addTLV16(0x0016,AIM_CLIENTID);
	outbuf.addTLV16(0x0017,AIM_MAJOR);
	outbuf.addTLV16(0x0018,AIM_MINOR);
	outbuf.addTLV16(0x0019,AIM_POINT);
	outbuf.addTLV16(0x001a,AIM_BUILD);
	outbuf.addTLV(0x0014,0x0004,AIM_OTHER);
	outbuf.addTLV(0x000f,0x0002,AIM_LANG);
	outbuf.addTLV(0x000e,0x0002,AIM_COUNTRY);

	//if set, old-style buddy lists will not work... you will need to use SSI
	outbuf.addTLV8(0x004a,0x01);

	sendBuf(outbuf,0x02);
	kdDebug(14150) << k_funcinfo << "emitting connectionChanged" << endl;
//	emit connectionChanged(3,"Sending username and password...");
}

// Parses a minityping notification from the server
void OscarSocket::parseMiniTypeNotify(Buffer &inbuf)
{
	kdDebug(14150) << k_funcinfo << "RECV (SRV_TYPINGNOTIFY) SNAC(4,20)" << endl;
	// Throw away 8 bytes which are all zeros
	inbuf.getDWord();
	inbuf.getDWord();

	// Throw away two bytes (0x0001) which are always there
	inbuf.getWord();

	// The length of the screen name
	int snlen = inbuf.getByte();
	kdDebug(14150) << "Trying to find username of length: " << snlen << endl;

	// The screen name
	char *sn = inbuf.getBlock(snlen);
	QString screenName = QString::fromLatin1(sn);
	delete [] sn;

	// Get the actual notification
	WORD notification = inbuf.getWord();

	kdDebug(14150) << "[OSCAR] Determining Minitype from user '" << screenName << "'" << endl;

	switch(notification)
	{
		case 0x0000:
			// Typing finished
			emit gotMiniTypeNotification(screenName, 0);
			break;
		case 0x0001:
			// Text Typed
			emit gotMiniTypeNotification(screenName, 1);
			break;
		case 0x0002:
			// Typing Started
			emit gotMiniTypeNotification(screenName, 2);
			break;
		default:
			kdDebug(14150) << "[OSCAR] MiniType Error: " << notification << endl;
	}
}

void OscarSocket::sendMiniTypingNotify(QString screenName, TypingNotify notifyType)
{
	kdDebug(14150) << k_funcinfo << "Sending Typing notify " << endl;

	//look for direct connection before sending through server
	OscarConnection *dc = mDirectIMMgr->findConnection(screenName);
	if(dc)
{'fraction_non_alphanumeric': 0.18838421444527179, 'fraction_numerical': 0.0583271283196823, 'mean_word_length': 3.0154459392127553, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6880793', 'n_tokens_mistral': 3107, 'n_tokens_neox': 2665, 'n_words': 637}