summaryrefslogtreecommitdiff
path: root/comm/ObexStream.h
blob: 6e83013245e47a49da7f83776c02df7772f94622 (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
/*
 *	Ivy League
 *
 *	OBEX protocol
 *
 *	Copyright 2000
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	by Stephane Chatty
 *
 *	$Id$
 *
 */

#ifndef ObexStream_H_
#define ObexStream_H_

#include "ivl/cplus_bugs.h"
#include "Stream.h"
class IvlAddress;
#include "ivl/List.h"
#include "Trigger.h"
#include "Scheduler.h"
#include "BufStream.h"
#include "Event.h"


class IvlObexStream : public IvlStream {
public:
	IvlTrigger	NewAgents;

		IvlObexStream (IvlAddress*, IvlBaseScheduler* = IvlScd);
		~IvlObexStream ();

	IvlChannel*	Copy () const;
	void		HandleRead ();
};

class IvlObexHeader;
class IvlObexObject;

class IvlObexAgent : public IvlBufStream {
private:
	IvlObexStream*	MyLink;
	void*	CurObj;
	IvlListOf<IvlObexHeader*>	OutHeaders;

	void	HandleRead ();
	void	ParseConnect (sword, bool);
	void	ParseDisconnect (sword, bool);
	void	ParseAbort (sword, bool);
	void	ParsePut (sword, bool);
	void	ParseGet (sword, bool);
	void	ParseSetPath (sword, bool);
	void	ParseHeaders (sword, bool);
	void	SendResponse ();
	void	SendHeader (byte, byte, const char*);

public:
		IvlObexAgent (int, IvlObexStream*);
		IvlObexAgent (IvlAddress*, IvlObexStream*);
		~IvlObexAgent ();
	void	SendObject (IvlObexObject&);
};

class IvlObexAgentEvent : public IvlEvent {
public:
static	IvlEventType*	ObexNewAgent, *ObexAgentBye;

protected:
	IvlObexAgent*	Agent;

public:
		IvlObexAgentEvent (IvlObexAgent*, IvlEventType*);
		~IvlObexAgentEvent ();

inline	IvlObexAgent*	GetAgent () const	{ return Agent;}
};

class IvlObexObject {
friend class IvlObexAgent;
protected:
	IvlString	Name;
	IvlString	Description;
	IvlString	Body;	// should not be a text string, actually
	lword	Class;

public:
		IvlObexObject ();
		~IvlObexObject ();
	void	SetName (const char*);
	void	SetDescription (const char*);
	void	SetBody (const char*);
	void	SetClass (lword);
};

#endif	/* ObexStream_H_ */