HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NET_MailNetworkRequest.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: NET_MailNetworkRequest.h
7  *
8  * COMMENTS:
9  *
10  *
11  */
12 
13 #ifndef __NET_MAILNETWORKREQUEST_H__
14 #define __NET_MAILNETWORKREQUEST_H__
15 
16 #include "NET_API.h"
17 
18 #include "NET_WebTypes.h"
19 
20 #include <UT/UT_BoostAsio.h>
21 #include <UT/UT_Url.h>
22 #include <UT/UT_StringHolder.h>
23 #include <UT/UT_Map.h>
24 
26 {
27 public:
30 };
31 
33 {
34 public:
36  {
38  INT_VERBOSE
39  };
41  {
42  };
43 
44  NET_MailNetworkRequest() { initDefaultAttributes_(); }
45  NET_MailNetworkRequest(const UT_Url& url) : myUrl(url)
46  {
47  initDefaultAttributes_();
48  }
49 
50  hboost::asio::executor executor() const { return myExecutor; }
51  void setExecutor(const hboost::asio::executor& executor)
52  {
53  myExecutor = executor;
54  }
55 
56  void setUrl(const UT_Url& url) { myUrl = url; }
57  const UT_Url& url() const { return myUrl; }
58 
60  {
61  myIntAttributes[attrib] = value;
62  }
64  {
65  myStringAttributes[attrib] = value;
66  }
68  {
69  return myIntAttributes;
70  }
72  {
73  return myStringAttributes;
74  }
75 
76  void setFrom(const UT_StringHolder& from)
77  {
78  myFrom = from;
79  extractAddresses(myFromAddress, from);
80  }
81  const UT_StringHolder& from() const { return myFrom; }
82 
83  void setTo(const UT_StringHolder& to)
84  {
85  myTo = to;
86  extractAddresses(myToAddresses, to);
87  }
88  const UT_StringHolder& to() const { return myTo; }
89 
90  void setCc(const UT_StringHolder& cc)
91  {
92  myCc = cc;
93  extractAddresses(myCcAddresses, cc);
94  }
95  const UT_StringHolder& cc() const { return myCc; }
96 
97  void setBcc(const UT_StringHolder& bcc)
98  {
99  myBcc = bcc;
100  extractAddresses(myBccAddresses, bcc);
101  }
102  const UT_StringHolder& bcc() const { return myBcc; }
103 
104  void setSubject(const UT_StringHolder& subject) { mySubject = subject; }
105  const UT_StringHolder& subject() const { return mySubject; }
106 
107  const UT_StringHolder& toAddress() const { return myToAddresses; }
108  const UT_StringHolder& fromAddress() const { return myFromAddress; }
109  const UT_StringHolder& ccAddress() const { return myCcAddresses; }
110  const UT_StringHolder& bccAddress() const { return myBccAddresses; }
111 
112  void setDate(time_t now) { myDate = dateToString(now); }
113  UT_StringHolder date() const { return myDate; }
114 
116  const UT_StringHolder& username,
117  const UT_StringHolder& password)
118  {
119  myUsername = username;
120  myPassword = password;
121  }
122  const UT_StringHolder& username() const { return myUsername; }
123  const UT_StringHolder& password() const { return myPassword; }
124 
125  static UT_StringHolder dateToString(time_t now);
126  /// When specifying email addresses we need the correctly formatted address
127  /// (eg. <email@email.com> and not email@email.com)
128  static bool isValidEmails(const UT_StringView& addr);
129  static bool extractAddresses(
130  UT_StringViewArray& addresses,
131  const UT_StringView& input);
132  static bool extractAddresses(
133  UT_StringHolder& addresses,
134  const UT_StringView& input);
135 
136 private:
137  void initDefaultAttributes_();
138 
139  UT_Url myUrl;
140 
141  UT_StringHolder mySubject;
142  UT_StringHolder myTo;
143  UT_StringHolder myToAddresses;
144  UT_StringHolder myCc;
145  UT_StringHolder myCcAddresses;
146  UT_StringHolder myBcc;
147  UT_StringHolder myBccAddresses;
148  UT_StringHolder myFrom;
149  UT_StringHolder myFromAddress;
150  UT_StringHolder myDate;
151  UT_StringHolder myUsername;
152  UT_StringHolder myPassword;
153 
154  UT_Map<IntAttribute, int64> myIntAttributes;
155  UT_Map<StrAttribute, UT_StringHolder> myStringAttributes;
156 
157  hboost::asio::executor myExecutor;
158 };
159 
160 #endif // __NET_MAILNETWORKREQUEST_H__
161 
void setAttribute(StrAttribute attrib, const UT_StringHolder &value)
UT_StringHolder date() const
hboost::asio::executor executor() const
void setUrl(const UT_Url &url)
const UT_StringHolder & to() const
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const UT_StringHolder & fromAddress() const
void setExecutor(const hboost::asio::executor &executor)
const UT_StringHolder & ccAddress() const
const UT_StringHolder & bcc() const
const UT_StringHolder & from() const
const UT_StringHolder & username() const
UT_StringHolder myErrorMsg
const UT_Url & url() const
const UT_Map< IntAttribute, int64 > & intAttributes() const
void setAttribute(IntAttribute attrib, int64 value)
#define NET_API
Definition: NET_API.h:9
A utility class to do read-only operations on a subset of an existing string.
Definition: UT_StringView.h:39
const UT_StringHolder & subject() const
const UT_StringHolder & bccAddress() const
Definition: UT_Url.h:22
long long int64
Definition: SYS_Types.h:116
std::error_code UT_ErrorCode
Definition: UT_ErrorCode.h:20
const UT_Map< StrAttribute, UT_StringHolder > & stringAttributes() const
void setBcc(const UT_StringHolder &bcc)
void setAuthentication(const UT_StringHolder &username, const UT_StringHolder &password)
void setTo(const UT_StringHolder &to)
void setFrom(const UT_StringHolder &from)
void setSubject(const UT_StringHolder &subject)
Definition: core.h:1131
NET_MailNetworkRequest(const UT_Url &url)
const UT_StringHolder & password() const
const UT_StringHolder & toAddress() const
const UT_StringHolder & cc() const
void setCc(const UT_StringHolder &cc)