Arduino DLNA Server
Loading...
Searching...
No Matches
Action.h
Go to the documentation of this file.
1#pragma once
4
5namespace tiny_dlna {
6
11class Argument {
12 public:
13 Argument() = default;
14 Argument(const char* nme, const char* val) {
15 name = nme;
16 value = val;
17 }
18 const char* name = nullptr;
19 Str value = "";
20};
21
43 public:
44 ActionReply(bool valid = true) { is_valid = valid; }
46 operator bool() { return is_valid; }
47 bool isValid() const { return is_valid; }
48 void setValid(bool flag) { is_valid = flag; }
49 void add(ActionReply alt) {
50 if (!alt) setValid(false);
51 for (auto& arg : alt.arguments) {
52 arguments.push_back(arg);
53 }
54 }
55 void clear() { arguments.clear(); }
57 for (auto& a : arguments) {
58 if (StrView(a.name).equals(arg.name)) {
59 a.value = arg.value;
60 return;
61 }
62 }
63 arguments.push_back(arg);
64 }
65
66
67 protected:
68 bool is_valid = true;
69};
70
80 public:
81 ActionRequest() = default;
82
83 ActionRequest(DLNAServiceInfo& srv, const char* act) {
84 p_service = &srv;
85 action = act;
86 }
87
88 void addArgument(Argument arg) { arguments.push_back(arg); }
89 void addArgument(const char* name, const char* value) {
90 Argument arg{name, value};
91 addArgument(arg);
92 }
93
95 const char* action = nullptr;
97 int result_count = 0;
98 operator bool() { return p_service != nullptr && action != nullptr && p_service->service_type!=nullptr; }
99 const char* getServiceType() { return p_service->service_type; }
100
101};
102
103} // namespace tiny_dlna
Represents the result of invoking a DLNA service Action.
Definition: Action.h:42
ActionReply(bool valid=true)
Definition: Action.h:44
bool isValid() const
Definition: Action.h:47
void add(ActionReply alt)
Definition: Action.h:49
void clear()
Definition: Action.h:55
void setValid(bool flag)
Definition: Action.h:48
Vector< Argument > arguments
Definition: Action.h:45
void addArgument(Argument arg)
Definition: Action.h:56
bool is_valid
Definition: Action.h:68
Represents a request to invoke a remote DLNA service action.
Definition: Action.h:79
void addArgument(Argument arg)
Definition: Action.h:88
Vector< Argument > arguments
Definition: Action.h:96
int result_count
Definition: Action.h:97
const char * getServiceType()
Definition: Action.h:99
void addArgument(const char *name, const char *value)
Definition: Action.h:89
DLNAServiceInfo * p_service
Definition: Action.h:94
ActionRequest(DLNAServiceInfo &srv, const char *act)
Definition: Action.h:83
const char * action
Definition: Action.h:95
DLNA Service: Action Argument.
Definition: Action.h:11
Str value
Definition: Action.h:19
Argument(const char *nme, const char *val)
Definition: Action.h:14
const char * name
Definition: Action.h:18
Attributes needed for the DLNA Service Definition.
Definition: DLNAServiceInfo.h:16
const char * service_type
Definition: DLNAServiceInfo.h:33
A simple wrapper to provide string functions on char*. If the underlying char* is a const we do not a...
Definition: StrView.h:19
virtual bool equals(const char *str)
checks if the string equals indicated parameter string
Definition: StrView.h:178
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
Vector implementation which provides the most important methods as defined by std::vector....
Definition: Vector.h:21
Definition: Allocator.h:6