Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / src / FCnt_ContentTransferEvent.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                        FCntContentTransferEvent.h
18  * @brief               This is the header file for the %ContentTransferEvent class.
19  *
20  */
21 #ifndef _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_
22 #define _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_
23
24 #include <unique_ptr.h>
25 #include <FBaseRt_Event.h>
26 #include <FBaseRtIEventArg.h>
27
28 namespace Tizen { namespace Content
29 {
30
31 //
32 // @enum ContentTransferEventType
33 // @brief This represents  ContentTransfer's event type.
34 //
35 enum  ContentTransferEventType
36 {
37         CONTENT_TRANSFER_EVENT_NONE,                    // Event None
38         CONTENT_TRANSFER_EVENT_DOWNLOAD_COMPLETED,                  // Event None
39         CONTENT_TRANSFER_EVENT_CANCELED,
40         CONTENT_TRANSFER_EVENT_DOWNLOAD_TO_BUFFER_COMPLETED,
41         CONTENT_TRANSFER_EVENT_TRANSFER_IN_PROGRESS
42 };
43
44 class _ContentTransferEvent
45         : public Tizen::Base::Runtime::_Event
46 {
47 public:
48         _ContentTransferEvent(void);
49         virtual ~_ContentTransferEvent(void);
50
51 protected:
52         /**
53          *      Finds out and invokes the method of listener corresponding to the specified event argument.
54          *
55          * @return              The error code.
56          * @param[in]   pListener                       An event listener to be invoked. This must be an instance of ICameraEventListener.
57          * @param[in]   arg                                     An argument to be fired.
58          * @exception   E_SUCCESS                       - This method is successful.
59          * @exception   E_OUT_OF_MEMORY         - Failed to allocate the required/requested memory.
60          * @exception   E_INVALID_STATE         - The current state of the camera is inappropriate or invalid for this method.
61          * @exception   E_INVALID_ARG           - The argument passed to a method contains an invalid value.
62          */
63         virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
64
65 private:
66         _ContentTransferEvent(const _ContentTransferEvent& rhs);
67         _ContentTransferEvent& operator =(const _ContentTransferEvent& rhs);
68
69 };  // class _ContentTransferEvent
70
71
72 class _ContentTransferEventArg
73         : public Tizen::Base::Runtime::IEventArg
74 {
75 public:
76         _ContentTransferEventArg(void);
77         virtual ~_ContentTransferEventArg(void);
78
79 public:
80         /**
81         *       Get the event type.
82         *
83         *       @return ContentTransfer Event type of this argument.
84         */
85         ContentTransferEventType GetEventType(void) const;
86
87         result GetResult(void) const;
88
89         Tizen::Base::String GetErrorMsg(void) const;
90
91         Tizen::Base::String GetErrorCode(void) const;
92
93         RequestId GetRequestId(void) const;
94
95         ContentId GetContentId(void) const;
96
97         int GetTotalTransferedSize(void) const;
98
99         Tizen::Base::ByteBuffer* GetBuffer(void) const;
100
101         /**
102         *       Set the event type.
103         */
104         void SetEventType(ContentTransferEventType eType);
105
106         void SetResult(result res);
107
108         void SetErrorMsg(const Tizen::Base::String& ErrorCode, const Tizen::Base::String& ErrorMsg);
109
110         void SetRequestId(RequestId requestId);
111
112         void SetContentId(const ContentId& contentId);
113
114         void SetTotalTransferedSize(int totalSize);
115
116         void SetBuffer(Tizen::Base::ByteBuffer* pBuffer);
117
118 private:
119         _ContentTransferEventArg(const _ContentTransferEventArg& rhs);
120         _ContentTransferEventArg& operator =(const _ContentTransferEventArg& rhs);
121
122 private:
123         RequestId __requestId;
124         ContentId __contentId;
125         ContentTransferEventType __contentTransferEventType;
126         int __totalSize;
127         result __res;
128         Tizen::Base::String __errorMsg;
129         Tizen::Base::String __errorCode;
130         std::unique_ptr<Tizen::Base::ByteBuffer> __pBuffer;
131 };  // class _ContentTransferEventArg
132
133 }}  // Tizen::Content
134
135 #endif // _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_