Arduino DLNA Server
Action.h
Go to the documentation of this file.
1 #pragma once
2 #include "State.h"
3 #include "dlna/DLNAServiceInfo.h"
4 #include "dlna/xml/XMLPrinter.h"
5 
6 namespace tiny_dlna {
7 
8 // enum class Direction { In, Out };
9 // const char* direction_str[] = {"in", "out"};
10 
15 class Argument {
16  public:
17  Argument() = default;
18  Argument(const char* nme, const char* val) {
19  name = nme;
20  value = val;
21  }
22  const char* name;
23  // Direction direction;
24  // StateInformation* related_state;
26 };
27 
28 // /**
29 // * @brief DLNA Service: Action
30 // * @author Phil Schatzmann
31 // */
32 // class Action {
33 // const char* name;
34 // Vector<Argument> in;
35 // Vector<Argument> out;
36 // };
37 
38 class ActionReply {
39  public:
40  ActionReply(bool valid = true) { is_valid = valid; }
42  operator bool() { return is_valid; }
43  void setValid(bool flag) { is_valid = flag; }
44  void add(ActionReply alt) {
45  if (!alt) setValid(false);
46  for (auto& arg : alt.arguments) {
47  arguments.push_back(arg);
48  }
49  }
50 
51  protected:
52  bool is_valid = true;
53 };
54 
56  public:
57  ActionRequest() = default;
58 
59  ActionRequest(DLNAServiceInfo& srv, const char* act) {
60  p_service = &srv;
61  action = act;
62  }
63 
64  void addArgument(Argument arg) { arguments.push_back(arg); }
65  void addArgument(const char* name, const char* value) {
66  Argument arg{name, value};
67  addArgument(arg);
68  }
69 
71  const char* action;
73  int result_count = 0;
74  operator bool() { return is_valid; }
75  const char* getServiceType() { return p_service->service_type; }
76 
77  protected:
78  bool is_valid = false;
79 };
80 
81 } // namespace tiny_dlna
Definition: Action.h:38
ActionReply(bool valid=true)
Definition: Action.h:40
void add(ActionReply alt)
Definition: Action.h:44
void setValid(bool flag)
Definition: Action.h:43
Vector< Argument > arguments
Definition: Action.h:41
bool is_valid
Definition: Action.h:52
Definition: Action.h:55
bool is_valid
Definition: Action.h:78
void addArgument(Argument arg)
Definition: Action.h:64
Vector< Argument > arguments
Definition: Action.h:72
int result_count
Definition: Action.h:73
void addArgument(const char *name, const char *value)
Definition: Action.h:65
const char * getServiceType()
Definition: Action.h:75
DLNAServiceInfo * p_service
Definition: Action.h:70
ActionRequest(DLNAServiceInfo &srv, const char *act)
Definition: Action.h:59
const char * action
Definition: Action.h:71
DLNA Service: Action Argument.
Definition: Action.h:15
Str value
Definition: Action.h:25
Argument(const char *nme, const char *val)
Definition: Action.h:18
const char * name
Definition: Action.h:22
Attributes needed for the DLNA Service Definition.
Definition: DLNAServiceInfo.h:16
const char * service_type
Definition: DLNAServiceInfo.h:33
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