summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/msn/msnchatsession.h
blob: 72d4714748560e9aa704a53196d215786570651c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
    msnchatsession.h - MSN Message Manager

    Copyright (c) 2002-2005 by Olivier Goffart        <ogoffart @ kde.org>

    Kopete    (c) 2002-2005 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 MSNMESSAGEMANAGER_H
#define MSNMESSAGEMANAGER_H

#include "kopetechatsession.h"

class MSNSwitchBoardSocket;
class TDEActionCollection;
class MSNInvitation;
class MSNContact;
class TDEActionMenu;
class TQLabel;


/**
 * @author Olivier Goffart
 */
class KOPETE_EXPORT MSNChatSession : public Kopete::ChatSession
{
	Q_OBJECT
  

public:
	MSNChatSession( Kopete::Protocol *protocol, const Kopete::Contact *user, Kopete::ContactPtrList others, const char *name = 0 );
	~MSNChatSession();

	void createChat( const TQString &handle, const TQString &address, const TQString &auth, const TQString &ID = TQString() );

	MSNSwitchBoardSocket *service() { return m_chatService; };

	void sendFile( const TQString &fileLocation, const TQString &fileName,
		long unsigned int fileSize );

	/**
	 * append an invitation in the invitation map, and send the first invitation message
	 */
	void initInvitation(MSNInvitation* invitation);
	
	virtual void inviteContact(const TQString& );

public slots:
	void slotCloseSession();
	void slotInviteOtherContact();

	void invitationDone( MSNInvitation*  );

	void slotRequestPicture();

	/**
	 * this is a reimplementation of ChatSesstion slot.
	 * the original slot is not virtual, but that's not a problem because it's a slot.
	 */
	virtual void receivedTypingMsg( const TQString &, bool );
	
	void slotConnectionTimeout();

private slots:
	void slotMessageSent( Kopete::Message &message, Kopete::ChatSession *kmm );
	void slotMessageReceived( Kopete::Message &message );

	void slotUserJoined( const TQString &handle, const TQString &publicName, bool IRO );
	void slotUserLeft( const TQString &handle, const TQString &reason );
	void slotSwitchBoardClosed();
	void slotInviteContact( Kopete::Contact *contact );
	void slotAcknowledgement( unsigned int id, bool ack );
	void slotInvitation( const TQString &handle, const TQString &msg );

	void slotActionInviteAboutToShow();

	void slotDisplayPictureChanged();

	/**
	 * (debug)
	 */
	void slotDebugRawCommand();

	void slotSendNudge();
	void slotWebcamReceive();
	void slotWebcamSend();
	void slotSendFile();

	void slotNudgeReceived(const TQString& handle);

private:

	MSNSwitchBoardSocket *m_chatService;
	TQString otherString;
	TDEActionMenu *m_actionInvite;
	TQPtrList<TDEAction> m_inviteactions;
	TDEAction *m_actionNudge;
	TDEAction *m_actionWebcamReceive;
	TDEAction *m_actionWebcamSend;

	//Messages sent before the ending of the connection are queued
	TQValueList<Kopete::Message> m_messagesQueue;
	void sendMessageQueue();
	void cleanMessageQueue( const TQString &reason);
	void startChatSession();

	TQMap<unsigned int, Kopete::Message> m_messagesSent;

	TQMap<long unsigned int, MSNInvitation*> m_invitations;


	/**
	 * weither or not the "has opened a new chat" message need to be sent if the user is typing
	 */
	bool m_newSession;

	TQLabel *m_image;
	TQTimer *m_timeoutTimer;
	uint m_connectionTry;


signals:
	/*
	 * This signal is relayed to the protocol and after, to plugins
	 */
	void invitation(MSNInvitation*& invitation,  const TQString &bodyMSG , long unsigned int cookie , MSNChatSession* msnMM , MSNContact* c );
};

#endif