summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/msn/webcam.h
blob: d11f8b024f06d5d6ce5f66c7bbd5b50d7f4cd78b (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
/*
    Copyright (c) 2005 by Olivier Goffart        <ogoffart@ 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 P2PWEBCAM_H
#define P2PWEBCAM_H

#include "p2p.h"

#if MSN_WEBCAM

namespace KNetwork{ class KServerSocket; class KBufferedSocket;  }

class MimicWrapper;
class TQLabel;
class MSNWebcamDialog;
class TQTimerEvent;

namespace P2P {


class Webcam  : public TransferContext
{  Q_OBJECT
  
	public:
		enum Who { wProducer , wViewer };
		
		Webcam( Who who , const TQString& to, Dispatcher *parent, TQ_UINT32 sessionID);
		~Webcam( );

		virtual void processMessage(const Message& message);
		
	public slots:
		void askIncommingInvitation();
		virtual void acknowledged();
		void sendBYEMessage();
	
	private:
		void makeSIPMessage(const TQString &message, TQ_UINT8 XX=0, TQ_UINT8 YY=9 , TQ_UINT8 ZZ=0);
		void sendBigP2PMessage( const TQByteArray& dataMessage );
		void closeAllOtherSockets();
		TQString m_content;
		
		TQString xml(uint session , uint rid);
		int getAvailablePort();

		
		KNetwork::KServerSocket   *m_listener;
		KNetwork::KBufferedSocket *m_webcamSocket;
		
		enum WebcamStatus { wsNegotiating , wsConnecting, wsConnected, wsTransfer  } ;
		
		Who m_who;
		
		TQString m_myAuth;
		TQString m_peerAuth;
		
		MimicWrapper *m_mimic;
		MSNWebcamDialog *m_widget;
				
		TQValueList<KNetwork::KBufferedSocket* > m_allSockets;
		TQMap<KNetwork::KBufferedSocket*, WebcamStatus> m_webcamStates;
		
		int m_timerId;
		int m_timerFps;

	private slots:
		void slotListenError(int errorCode);
		void slotAccept();
		void slotSocketRead();
		void slotSocketClosed();
		void slotSocketError(int errorCode);
		void slotSocketConnected();
//		void slotReadyWrite();
	protected:
		virtual void timerEvent( TQTimerEvent * );
};

}

#endif

#endif