Version: 0.6.0
message.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Remote)
3  * Purpose: wxNetMessage class. Network message class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2008-2010,2012,2013 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/net/net.h"
24 
25 #include "wxgis/core/json/jsonval.h"
26 #include "wxgis/core/json/jsonreader.h"
27 #include "wxgis/core/json/jsonwriter.h"
28 
29 #include "wx/xml/xml.h"
30 
31 #define WXNETVER 3
32 
33 
42 class WXDLLIMPEXP_GIS_NET wxNetMessage : public wxObject
43 {
44  DECLARE_DYNAMIC_CLASS(wxNetMessage)
45 public:
51  wxNetMessage(const wxJSONValue& val);
52  wxNetMessage(wxGISNetCommand nNetCmd = enumGISNetCmdUnk, wxGISNetCommandState nNetCmdState = enumGISNetCmdStUnk, short nPriority = enumGISPriorityNormal, long nId = wxNOT_FOUND);
53 
54  bool IsOk() const;
55 
56  bool operator == ( const wxNetMessage& obj ) const;
57  bool operator != (const wxNetMessage& obj) const { return !(*this == obj); };
58  bool operator < (const wxNetMessage& obj) const;
59 
60  short GetPriority(void) const;
61  void SetPriority(short nPriority);
62  wxGISNetCommand GetCommand(void) const;
63  void SetCommand(wxGISNetCommand nCmd);
64  wxGISNetCommandState GetState(void) const;
65  void SetState(wxGISNetCommandState nState);
66 
67  long GetId(void) const;
68  void SetId(long nId);
69 
70  wxString GetMessage(void) const;
71  void SetMessage(const wxString& sMsg);
72 
73  void SetValue(wxJSONValue val);
74  wxJSONValue GetValue(void) const;
75  wxJSONValue GetInternalValue() const;
76  wxNetMessage Clone() const;
77 protected:
78  virtual wxObjectRefData *CreateRefData() const;
79  virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
80 };
81 
89 class wxNetMessageRefData : public wxObjectRefData
90 {
91  friend class wxNetMessage;
92 public:
94  wxNetMessageRefData( const wxJSONValue& val );
95  wxNetMessageRefData( wxGISNetCommand nNetCmd = enumGISNetCmdUnk, wxGISNetCommandState nNetCmdState = enumGISNetCmdStUnk, short nPriority = enumGISPriorityNormal, long nId = wxNOT_FOUND );
96  virtual ~wxNetMessageRefData();
97 
98  bool operator == (const wxNetMessageRefData& data) const;
99  bool IsOk(void);
100 
101  void SetPriority(short nPriority);
102  void SetState(wxGISNetCommandState nState);
103  void SetMessage(const wxString& sMsg);
104  void SetId(long nId);
105  void SetCommand(wxGISNetCommand nState);
106 protected:
107  wxJSONValue m_Val;
108  short m_nPriority;
109  wxGISNetCommand m_nCmd;
110  wxGISNetCommandState m_nState;
111  wxString m_sMessage;
112  long m_nId;
113 };
114 
115 #ifdef wxGIS_USE_EMAIL
116 
123 class WXDLLIMPEXP_GIS_NET wxMailMessage
124 {
125 public:
126  wxMailMessage(const wxString& subject, const wxString& body, const wxString& from = wxEmptyString, const wxString& attachment = wxEmptyString, const wxString& attachmentTitle = wxEmptyString);
127  wxMailMessage(void);
128 
130 
131  void AddAttachment(const wxString& attach, const wxString& title = wxEmptyString);
132 
133  void SetSubject(const wxString& subject);
134  void SetBody(const wxString& body);
135  void SetFrom(const wxString& from);
136 
137 public:
138  wxArrayString m_to; //Recipients
139  wxString m_from; //The From: email address (optional)
140  wxString m_subject; //The Subject of the message
141  wxString m_body; //The Body of the message
142  wxArrayString m_attachments; //Files to attach to the email
143  wxArrayString m_attachmentTitles; //Titles to use for the email file attachments
144 };
145 
146 #endif //wxGIS_USE_EMAIL
The JSON value class implementation.
Definition: jsonval.h:91
Definition: message.h:42
Definition: message.h:89