2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef TIZENAPIS_PLATFORM_APPLICATION_UTIL_H_
19 #define TIZENAPIS_PLATFORM_APPLICATION_UTIL_H_
21 #include <CommonsJavaScript/Converter.h>
22 #include <PlatformException.h>
26 namespace Application {
30 explicit ApplicationUtil(JSContextRef context,
31 JSValueRef* exception = NULL);
32 virtual ~ApplicationUtil();
34 bool isObject(const JSValueRef& arg);
35 bool isString(const JSValueRef& arg);
36 bool isFunction(const JSValueRef& arg);
37 bool isArray(const JSValueRef& arg);
38 bool isNullOrString(const JSValueRef& arg);
39 bool isNullOrObject(const JSValueRef& arg);
40 bool isNullOrFunction(const JSValueRef& arg);
41 bool isNullOrArray(const JSValueRef& arg);
42 bool isNullOrUndefined(const JSValueRef& arg);
43 bool isNullOrUndefinedOrString(const JSValueRef& arg);
44 bool isNullOrUndefinedOrObject(const JSValueRef& arg);
45 bool isNullOrUndefinedOrFunction(const JSValueRef& arg);
46 bool isNullOrUndefinedOrArray(const JSValueRef& arg);
48 static std::string getApplicationMessage(const int errorCode);
49 static std::string getApplicationManagerMessage(const int errorCode);
50 static std::string getApplicationPkgmgrinfoMessage(const int errorCode);
51 static std::string getApplicationPackageManagerMessage(const int errorCode);
52 static std::string getApplicationAulMessage(const int errorCode);
54 static std::string getApplicationErrorMessage(const int errorCode,
55 const std::string &hint,
56 std::string (*function)(const int));
59 static void throwApplicationException(
61 const std::string &hint,
62 std::string (*function)(const int))
65 std::string ss = getApplicationErrorMessage(errorCode, hint, function);
66 LOGE("%s", ss.c_str());
67 ThrowMsg(T, ss.c_str());
71 JSContextRef m_context;
72 JSValueRef* m_exception;