summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/ioprocessor/modality/MMIProtoBridge.cpp
blob: c649a1702d64815c2f99335a7eb63f283fc742de (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
/**
 *  @file
 *  @author     2012-2013 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
 *  @copyright  Simplified BSD
 *
 *  @cond
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the FreeBSD license as published by the FreeBSD
 *  project.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  You should have received a copy of the FreeBSD license along with this
 *  program. If not, see <http://www.opensource.org/licenses/bsd-license>.
 *  @endcond
 */

#include "MMIProtoBridge.h"

#define INIT_PROTO_LIFE_CYCLE_EVENT(type) \
::LifeCycleEvent lifeCycleEvent; \
lifeCycleEvent.set_type(type); \
lifeCycleEvent.set_requestid(mmiEvent.requestId); \
lifeCycleEvent.set_source(mmiEvent.source); \
lifeCycleEvent.set_target(mmiEvent.target);

namespace uscxml {

::LifeCycleEvent MMIProtoBridge::toProto(const NewContextRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_NEW_CONTEXT_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const NewContextResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_NEW_CONTEXT_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const PrepareRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_PREPARE_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const PrepareResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_PREPARE_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const StartRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_START_REQUEST);

	::LifeCycleRequest* lifeCycleRequest = lifeCycleEvent.MutableExtension(::LifeCycleRequest::Request);
	lifeCycleRequest->set_context(mmiEvent.context);

	::StartRequest* startRequest = lifeCycleRequest->MutableExtension(::StartRequest::Request);
	startRequest->set_content(mmiEvent.content);
	startRequest->set_contenturl(mmiEvent.contentURL.href);

	::StartRequestData* startRequestData = startRequest->MutableExtension(::StartRequestData::Request);
	startRequestData->set_data(mmiEvent.data);

	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const StartResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_START_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const DoneNotification& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_DONE_NOTIFICATION);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const CancelRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_CANCEL_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const CancelResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_CANCEL_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const PauseRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_PAUSE_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const PauseResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_PAUSE_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const ResumeRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_RESUME_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const ResumeResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_RESUME_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const ExtensionNotification& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_EXTENSION_NOTIFICATION);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const ClearContextRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_CLEAR_CONTEXT_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const ClearContextResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_CLEAR_CONTEXT_RESPONSE);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const StatusRequest& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_STATUS_REQUEST);
	return lifeCycleEvent;
}

::LifeCycleEvent MMIProtoBridge::toProto(const StatusResponse& mmiEvent) {
	INIT_PROTO_LIFE_CYCLE_EVENT(::LifeCycleEvent_LifeCycleEventType_STATUS_RESPONSE);
	return lifeCycleEvent;
}

}