/*
  icqcontact.h  -  ICQ Contact

  Copyright (c) 2003 by Stefan Gehn  <metz AT gehn.net>
  Copyright (c) 2003 by Olivier Goffart
  Copyright (c) 2004 by Richard Smith               <kde@metafoo.co.uk>
  Kopete    (c) 2002-2004 by the Kopete developers  <kopete-devel@kde.org>

  *************************************************************************
  *                                                                       *
  * 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.                                   *
  *                                                                       *
  *************************************************************************
  */

#ifndef ICQCONTACT_H
#define ICQCONTACT_H

#include "oscarcontact.h"
#include "userdetails.h"

class OscarEncodingSelectionDialog;
class TDEAction;
class TDEToggleAction;
namespace Kopete { class ChatSession; }
namespace Kopete { class OnlineStatus; }
class ICQProtocol;
class ICQAccount;
class OscarAccount;
class ICQUserInfo; // user info dialog
class ICQReadAway;

class ICQGeneralUserInfo;
class ICQWorkUserInfo;
class ICQUserInfoWidget;
class ICQInterestInfoWidget;

/**
 * Contact for ICQ over Oscar protocol
 * @author Stefan Gehn
 * @author Richard Smith
 * @author Matt Rogers
 */
class ICQContact : public OscarContact
{
Q_OBJECT
  

public:

	/** Normal ICQ constructor */
	ICQContact( ICQAccount *account, const TQString &name, Kopete::MetaContact *parent,
	            const TQString& icon = TQString(), const Oscar::SSI& ssiItem = Oscar::SSI()  );
	virtual ~ICQContact();

	/**
	 * Returns a set of custom menu items for
	 * the context menu
	 */
	virtual TQPtrList<TDEAction> *customContextMenuActions();

	/** Return whether or not this contact is reachable. */
	virtual bool isReachable();


	//virtual const TQString awayMessage();
	//virtual void setAwayMessage(const TQString &message);

public slots:
	virtual void slotUserInfo();
	virtual void updateSSIItem();
	void userInfoUpdated( const TQString& contact, const UserDetails& details );

	void userOnline( const TQString& userId );
	void userOffline( const TQString& userID );
	void loggedIn();

	void requestShortInfo();

signals:
	void haveBasicInfo( const ICQGeneralUserInfo& );
	void haveWorkInfo( const ICQWorkUserInfo& );
	void haveEmailInfo( const ICQEmailInfo& );
	void haveMoreInfo( const ICQMoreUserInfo& );
	void haveInterestInfo( const ICQInterestInfo& );

private:
	bool cachedBuddyIcon( TQByteArray hash );
	bool m_buddyIconDirty;
	
	bool m_requestingNickname;
	ICQProtocol *mProtocol;
	ICQUserInfoWidget* m_infoWidget;
	/*
	ICQReadAway *awayMessageDialog;
	TDEAction *actionReadAwayMessage;
	*/
	TDEAction *actionRequestAuth;
	TDEAction *actionSendAuth;
    TDEAction *m_selectEncoding;
	
	TDEToggleAction *m_actionIgnore;
	TDEToggleAction *m_actionVisibleTo;
	TDEToggleAction *m_actionInvisibleTo;

	/*
	bool mInvisible;
	*/

    OscarEncodingSelectionDialog* m_oesd;

protected slots:
	virtual void slotSendMsg(Kopete::Message& message, Kopete::ChatSession *);
	virtual void updateFeatures();

private slots:
	/** Request authorization from this contact */
	void slotRequestAuth();

	/** Authorize this contact */
	void slotSendAuth();

	void slotAuthReplyDialogOkClicked();

	/** We have received an auth request */
	void slotGotAuthRequest( const TQString& contact, const TQString& reason );

	/** We have received an auth reply */
	void slotGotAuthReply( const TQString& contact, const TQString& reason, bool granted );

	void closeUserInfoDialog();

	void receivedLongInfo( const TQString& contact );
	void receivedShortInfo( const TQString& contact );

    void changeContactEncoding();
    void changeEncodingDialogClosed( int );

	void requestBuddyIcon();
	void haveIcon( const TQString&, TQByteArray );
	void receivedStatusMessage( const TQString &contact, const TQString &message );
	void receivedStatusMessage( const Oscar::Message &message );

//void slotCloseAwayMessageDialog();
	//void slotReadAwayMessage();

	void slotIgnore();
	void slotVisibleTo();
	void slotInvisibleTo();
};

#endif
