2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __CONTEXT_TYPES_INTERNAL_H__
18 #define __CONTEXT_TYPES_INTERNAL_H__
20 #include <tizen_error.h>
23 #define EXTAPI __attribute__ ((visibility("default")))
24 #define EMPTY_STRING ""
26 /* Internal Error Codes
27 * Please define the necessary error codes here.
28 * Note that, these error codes must be aligned with the error enums defined in all API headers.
30 #define ERR_NONE TIZEN_ERROR_NONE
31 #define ERR_INVALID_PARAMETER TIZEN_ERROR_INVALID_PARAMETER
32 #define ERR_INVALID_OPERATION TIZEN_ERROR_INVALID_OPERATION
33 #define ERR_OUT_OF_MEMORY TIZEN_ERROR_OUT_OF_MEMORY
34 #define ERR_PERMISSION_DENIED TIZEN_ERROR_PERMISSION_DENIED
35 #define ERR_NOT_SUPPORTED TIZEN_ERROR_NOT_SUPPORTED
36 #define ERR_NO_DATA TIZEN_ERROR_NO_DATA
37 #define ERR_ALREADY_STARTED (TIZEN_ERROR_CONTEXT | 0x01)
38 #define ERR_NOT_STARTED (TIZEN_ERROR_CONTEXT | 0x02)
39 #define ERR_OUT_OF_RANGE (TIZEN_ERROR_CONTEXT | 0x03)
40 #define ERR_OPERATION_FAILED (TIZEN_ERROR_CONTEXT | 0x04)
41 #define ERR_RULE_ENABLED (TIZEN_ERROR_CONTEXT | 0x05)
42 #define ERR_RULE_NOT_ENABLED (TIZEN_ERROR_CONTEXT | 0x06)
43 #define ERR_INVALID_RULE (TIZEN_ERROR_CONTEXT | 0x07)
44 #define ERR_RULE_NOT_EXIST (TIZEN_ERROR_CONTEXT | 0x08)
46 /* Logging and Error Handling */
51 #define _SI SECURE_SLOGI
52 #define _SD SECURE_SLOGD
53 #define _SW SECURE_LOGW
54 #define _SE SECURE_SLOGE
56 /* Color code for dlog */
57 #define RED(X) "\033[0;31m" X "\033[0m"
58 #define GREEN(X) "\033[0;32m" X "\033[0m"
59 #define YELLOW(X) "\033[0;33m" X "\033[0m"
60 #define BLUE(X) "\033[0;34m" X "\033[0m"
61 #define PURPLE(X) "\033[0;35m" X "\033[0m"
62 #define CYAN(X) "\033[0;36m" X "\033[0m"
64 #define REPLACE_NULL(X) ((X) ? (X) : "")
65 #define STR_EQ(X, Y) (g_strcmp0((X), (Y)) == 0)
67 #define IF_FAIL_RETURN_TAG(cond, ret, tag, fmt, arg...) \
68 do { if (!(cond)) { tag(fmt, ##arg); return ret; } } while (0)
70 #define IF_FAIL_RETURN(cond, ret) \
71 do { if (!(cond)) { return ret; } } while (0)
73 #define IF_FAIL_VOID_TAG(cond, tag, fmt, arg...) \
74 do { if (!(cond)) { tag(fmt, ##arg); return; } } while (0)
76 #define IF_FAIL_VOID(cond) \
77 do { if (!(cond)) { return; } } while (0)
79 #define IF_FAIL_CATCH_TAG(cond, tag, fmt, arg...) \
80 do { if (!(cond)) { tag(fmt, ##arg); goto CATCH; } } while (0)
82 #define IF_FAIL_CATCH(cond) \
83 do { if (!(cond)) { goto CATCH; } } while (0)
85 #define IS_FAILED(X) ((X) != ERR_NONE)
87 #define ASSERT_ALLOC(X) IF_FAIL_RETURN_TAG(X, ERR_OUT_OF_MEMORY, _E, "Memory allocation failed")
88 #define ASSERT_NOT_NULL(X) IF_FAIL_RETURN_TAG(X, ERR_INVALID_PARAMETER, _E, "Parameter null")
90 #define HANDLE_GERROR(Err) \
91 do { if ((Err)) { _E("GError: %s", Err->message); g_error_free(Err); Err = NULL; } } while (0)
95 #define DBUS_DEST "org.tizen.context"
96 #define DBUS_PATH "/org/tizen/context"
97 #define DBUS_IFACE "org.tizen.context"
98 #define DBUS_TIMEOUT 3000000
100 #define METHOD_REQUEST "Request"
101 #define METHOD_RESPOND "Respond"
102 #define SIGNAL_LAUNCHED "Launched"
113 #define ARG_REQTYPE "type"
114 #define ARG_COOKIE "cookie"
115 #define ARG_REQID "req_id"
116 #define ARG_SUBJECT "subject"
117 #define ARG_INPUT "input"
119 #define ARG_RESULT_ERR "r_err"
120 #define ARG_RESULT_ADD "r_add"
121 #define ARG_OUTPUT "output"
124 #endif /* __CONTEXT_TYPES_INTERNAL_H__ */