Initialize Tizen 2.3
[framework/osp/net.git] / src / inc / FNetHttp_HttpMultipartEntityImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FNetHttp_HttpMultipartEntityImpl.h
20  * @brief               This is the header file for the %_HttpMultipartEntityImpl class.
21  *
22  * This header file contains the declarations of the %_HttpMultipartEntityImpl class.
23  */
24
25 #ifndef _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_
26 #define _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_
27
28 #include <FBaseObject.h>
29 #include <FOspConfig.h>
30 #include <FNetHttpHttpTypes.h>
31 #include <FNetHttpIHttpEntity.h>
32
33 namespace Tizen { namespace Base
34 {
35 class String;
36 } }
37
38 namespace Tizen { namespace Text
39 {
40 class Encoding;
41 } }
42
43 namespace Tizen { namespace Net { namespace Http
44 {
45 class HttpMultipartEntity;
46 /**
47  * @class       _HttpMultipartEntityImpl
48  * @brief       This class represents a multipart/form-data entity as defined in RFC 2388.
49  *
50  * @since 2.1
51  */
52
53 class _OSP_EXPORT_ _HttpMultipartEntityImpl
54         : public Tizen::Base::Object
55         , public IHttpEntity
56 {
57
58 public:
59         /**
60          * This is the default constructor for this class.
61          *
62          * @since 2.1
63          * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
64          * @see                 Construct()
65          */
66         _HttpMultipartEntityImpl(void);
67
68         /**
69          * This is the destructor for this class.
70          *
71          * @since 2.1
72          */
73         virtual ~_HttpMultipartEntityImpl(void);
74
75         /**
76          * @see                 HttpMultipartEntity::Construct()
77          */
78         result Construct(void);
79
80         /**
81          * @see                 HttpMultipartEntity::Construct()
82          */
83         result Construct(const Tizen::Base::String& boundary);
84
85         /**
86          * @see                 HttpMultipartEntity::GetContentLength()
87          */
88         virtual long long GetContentLength(void) const;
89
90         /**
91          * @see                 HttpMultipartEntity::GetContentType()
92          */
93         virtual Tizen::Base::String GetContentType(void) const;
94
95         /**
96          * @see                 HttpMultipartEntity::AddStringPart()
97          */
98         result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text);
99
100         /**
101          * @see                 HttpMultipartEntity::AddStringPart()
102          */
103         result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
104
105         /**
106          * @see                 HttpMultipartEntity::AddFilePart()
107          */
108         result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath);
109
110         /**
111          * @see                 HttpMultipartEntity::AddFilePart()
112          */
113         result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath, const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
114
115         /**
116          * @see                 HttpMultipartEntity::AddFilePartByBuffer()
117          */
118         result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer);
119
120         /**
121          * @see                 HttpMultipartEntity::AddFilePartByBuffer()
122          */
123         result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
124
125 public:
126         /**
127          * Gets the Impl instance.
128          *
129          * @since 2.1
130          * @return                      The pointer to _HttpMultipartEntityImpl
131          * @param[in]   pHttpMultipartEntity            An instance of HttpMultipartEntity
132          */
133         static _HttpMultipartEntityImpl* GetInstance(HttpMultipartEntity& httpMultipartEntity);
134
135         /**
136          * Gets the Impl instance.
137          *
138          * @since 2.1
139          * @return                      The pointer to _HttpMultipartEntityImpl
140          * @param[in]   pHttpMultipartEntity            An instance of HttpMultipartEntity
141          */
142         static const _HttpMultipartEntityImpl* GetInstance(const HttpMultipartEntity& httpMultipartEntity);
143
144 public:
145         Tizen::Base::Collection::IList* GetStringPartList(void) const;
146
147         Tizen::Base::Collection::IList* GetFilePartList(void) const;
148
149         Tizen::Base::String GetBoundary(void) const;
150
151
152 protected:
153         /**
154          * @see                 HttpMultipartEntity::HasNextData()
155          */
156         virtual bool HasNextData(void);
157
158         /**
159          * @see                 HttpMultipartEntity::GetNextDataN()
160          */
161         virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
162
163 private:
164         _HttpMultipartEntityImpl(const _HttpMultipartEntityImpl& rhs);
165
166         _HttpMultipartEntityImpl& operator =(const _HttpMultipartEntityImpl& rhs);
167
168         Tizen::Base::String GenerateBoundary(void) const;
169
170 private:
171         Tizen::Base::String __boundary;
172         Tizen::Base::Collection::IList* __pStringPartList;
173         Tizen::Base::Collection::IList* __pFilePartList;
174
175         class _HttpMultipartConverter* __pHttpMultipartConverter;
176
177         friend class HttpMultipartEntity;
178
179 }; // _HttpMultipartEntityImpl
180
181 } } } // Tizen::Net::Http
182 #endif // _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_