<commit_before>/*
   Kopete Oscar Protocol
   Send extended status info to the server

   Copyright (c) 2004 <NAME> <<EMAIL>>

   Kopete (c) 2002-2004 by the Kopete developers <<EMAIL>>

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

#include <kdebug.h>
#include "connection.h"
#include "buffer.h"
#include "oscarsettings.h"
#include "oscartypes.h"
#include "oscarutils.h"
#include "transfer.h"

SendDCInfoTask::SendDCInfoTask(Task* parent, Oscar::DWORD status): Task(parent), mStatus(status)
{
}


SendDCInfoTask::~SendDCInfoTask()
{
}


void SendDCInfoTask::onGo()
{
	FLAP f = { 0x02, 0, 0 };
	SNAC s = { 0x0001, 0x001E, 0x0000, client()->snacSequence() };
	Buffer* buffer = new Buffer();
	
	kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Sending DC Info" << endl;

	/** \TODO Support something more than online in the status flags
	 *  \TODO Support something more than DC Disabled in the status flags
	 */
	/*
	if (status & ICQ_STATUS_SET_INVIS)
		sendChangeVisibility(0x03);
	else
		sendChangeVisibility(0x04);
	*/

	/* This is TLV 0x06 */
	//### Don't hardcode this value
	//Right now, it's always coded to not support DC
	Oscar::DWORD statusFlag = 0x01000000;
	if ( client()->settings()->webAware() )
	{
		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "setting web aware on" << endl;
		statusFlag |= 0x00010000;
	}
	if ( !client()->settings()->hideIP() )
	{
		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "setting show ip on" << endl;
		statusFlag |= 0x00020000;
	}
	Buffer tlv06;
	tlv06.addDWord( statusFlag | mStatus );
	buffer->addTLV( 0x0006, tlv06.buffer() );

	/* Fill in the DC Info 
	 * We don't support Direct Connection yet. So fill in some
	 * dummy values
	 */
	Buffer tlv0C;
	tlv0C.addDWord( 0x00000000 );
	tlv0C.addWord( 0x0000 );
	tlv0C.addWord( 0x0000 );

	tlv0C.addByte( 0x00 ); // Mode, TODO: currently fixed to "Direct Connection disabled"
	tlv0C.addWord( ICQ_TCP_VERSION ); // icq tcp protocol version, v8 currently

	tlv0C.addDWord( 0x00000000 ); // Direct Connection Cookie
	tlv0C.addDWord( 0x00000050 ); // web front port
	tlv0C.addDWord( 0x00000003 ); // number of following client features<commit_msg>Forwardport fix for bug 145199: ICQ "Hide IP address" feature not working<commit_after>/*
   Kopete Oscar Protocol
   Send extended status info to the server

   Copyright (c) 2004 <NAME> <<EMAIL>>

   Kopete (c) 2002-2004 by the Kopete developers <<EMAIL>>

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

#include <kdebug.h>
#include "connection.h"
#include "buffer.h"
#include "oscarsettings.h"
#include "oscartypes.h"
#include "oscarutils.h"
#include "transfer.h"

SendDCInfoTask::SendDCInfoTask(Task* parent, Oscar::DWORD status): Task(parent), mStatus(status)
{
}


SendDCInfoTask::~SendDCInfoTask()
{
}


void SendDCInfoTask::onGo()
{
	FLAP f = { 0x02, 0, 0 };
	SNAC s = { 0x0001, 0x001E, 0x0000, client()->snacSequence() };
	Buffer* buffer = new Buffer();
	
	kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Sending DC Info" << endl;

	/** \TODO Support something more than online in the status flags
	 *  \TODO Support something more than DC Disabled in the status flags
	 */
	/*
	if (status & ICQ_STATUS_SET_INVIS)
		sendChangeVisibility(0x03);
	else
		sendChangeVisibility(0x04);
	*/

	/* This is TLV 0x06 */
	//### Don't hardcode this value
	//Right now, it's always coded to not support DC
	Oscar::DWORD statusFlag = 0x01000000;
	if ( client()->settings()->webAware() )
	{
		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "setting web aware on" << endl;
		statusFlag |= 0x00010000;
	}
	if ( client()->settings()->hideIP() )
	{
		kDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "setting hide ip on" << endl;
		statusFlag |= 0x10000000;  // Direct connection upon authorization, hides IP
	}
	Buffer tlv06;
	tlv06.addDWord( statusFlag | mStatus );
	buffer->addTLV( 0x0006, tlv06.buffer() );

	/* Fill in the DC Info 
	 * We don't support Direct Connection yet. So fill in some
	 * dummy values
	 */
	Buffer tlv0C;
	tlv0C.addDWord( 0x00000000 );
	tlv0C.addWord( 0x0000 );
	tlv0C.addWord( 0x0000 );

	tlv0C.addByte( 0x00 ); // Mode, TODO: currently fixed to "Direct Connection disabled"
	tlv0C.addWord( ICQ_TCP_VERSION ); // icq tcp protocol version, v8 currently

	tlv0C.addDWord( 0x00000000 ); // Direct Connection Cookie
	tlv0C.addDWord( 0x00000050 ); // web front port
	tlv0C.addDWord( 0x00000003 ); // number of following client features
{'fraction_non_alphanumeric': 0.1627027027027027, 'fraction_numerical': 0.05081081081081081, 'mean_word_length': 3.1425373134328356, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 7, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3864407', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1717, 'n_words': 514}