Merge "[Package] Synchronously checking access to file" into tizen
[platform/core/api/webapi-plugins.git] / src / nfc / nfc_message_utils.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_NFC_NFC_MESSAGE_UTILS_H_
18 #define __TIZEN_NFC_NFC_MESSAGE_UTILS_H_
19
20 #include <network/nfc.h>
21
22 #include <string>
23 #include <vector>
24
25 #include "common/picojson.h"
26 #include "common/platform_result.h"
27
28 namespace extension {
29 namespace nfc {
30
31 typedef std::vector<unsigned char> UCharVector;
32
33 class NFCMessageUtils {
34  public:
35   static common::PlatformResult ToNdefRecords(const nfc_ndef_message_h message,
36                                               picojson::array& array);
37   static common::PlatformResult ReportNdefMessageFromData(unsigned char* data, unsigned long size,
38                                                           picojson::object& out);
39   static common::PlatformResult ReportNDEFMessage(const picojson::value& args,
40                                                   picojson::object& out);
41   static common::PlatformResult NDEFMessageToStruct(const picojson::array& records_array,
42                                                     const int size, nfc_ndef_message_h* message);
43   static common::PlatformResult NDEFMessageToByte(const picojson::value& args,
44                                                   picojson::object& out);
45   static common::PlatformResult ConstructNdefRecordFromRecordHandle(nfc_ndef_record_h record_handle,
46                                                                     picojson::object& out);
47   static common::PlatformResult ReportNdefRecordFromMessage(nfc_ndef_message_h message_handle,
48                                                             const int index, picojson::object& out);
49   static common::PlatformResult ReportNDEFRecord(const picojson::value& args,
50                                                  picojson::object& out);
51   static common::PlatformResult ReportNdefRecordTextFromMessage(nfc_ndef_message_h message_handle,
52                                                                 const int index,
53                                                                 picojson::object& out);
54   static common::PlatformResult ReportNDEFRecordText(const picojson::value& args,
55                                                      picojson::object& out);
56   static common::PlatformResult ReportNdefRecordURIFromMessage(nfc_ndef_message_h message_handle,
57                                                                const int index,
58                                                                picojson::object& out);
59   static common::PlatformResult ReportNDEFRecordURI(const picojson::value& args,
60                                                     picojson::object& out);
61   static common::PlatformResult ReportNdefRecordMediaFromMessage(nfc_ndef_message_h message_handle,
62                                                                  const int index,
63                                                                  picojson::object& out);
64   static common::PlatformResult ReportNDEFRecordMedia(const picojson::value& args,
65                                                       picojson::object& out);
66   static void RemoveMessageHandle(nfc_ndef_message_h message_handle);
67 };
68
69 }  // nfc
70 }  // extension
71
72 #endif  // __TIZEN_NFC_NFC_MESSAGE_UTILS_H_