val = xmlGetProp(node, (const xmlChar*)name);
if (val) {
- attr = strdup((char*)val);
+ attr = strdup(reinterpret_cast<char*>(val));
xmlFree(val);
}
static int _get_support_type_tag(xmlNode* node) {
unsigned int i;
+ unsigned int map_count;
- for (i = 0; i < (sizeof(__type_map) / sizeof(struct support_type_tag_map)); i++) {
+ map_count = sizeof(__type_map) / sizeof(struct support_type_tag_map);
+ for (i = 0; i < map_count; i++) {
if (!xmlStrcasecmp(node->name, (const xmlChar*)__type_map[i].name))
return __type_map[i].tag;
}
static const char* _get_bundle_key(const char* xml_element) {
unsigned int i;
+ unsigned int map_count;
- for (i = 0; i < (sizeof(__budle_key_map) / sizeof(struct xml_to_bundle_key_map)); i++) {
+ map_count = sizeof(__budle_key_map) / sizeof(struct xml_to_bundle_key_map);
+ for (i = 0; i < map_count; i++) {
if (strcmp(xml_element, __budle_key_map[i].xml_element) == 0)
return __budle_key_map[i].bundle_key;
}
}
time_t default_time = mktime(timeinfo);
- char num_str[32] = {0,};
+ char num_str[32] = {0, };
snprintf(num_str, sizeof(num_str), "%ld", default_time);
*default_value = num_str;
LOGD("%d/%d/%d %d:%d:%d (%s)",
if (prev_value)
bundle_del(default_data, TIME_KEY);
} else {
- default_value = (char*)tmpdata->children->content;
+ default_value = reinterpret_cast<char*>(tmpdata->children->content);
}
ret = bundle_add_str(default_data, bundle_key, default_value);
sqlite3_bind_text(stmt, idx++, providerid, -1, SQLITE_TRANSIENT);
if (lang)
- sqlite3_bind_text(stmt, idx++, (char*)lang, -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, idx++, reinterpret_cast<char*>(lang), -1,
+ SQLITE_TRANSIENT);
else
sqlite3_bind_text(stmt, idx++, "No Locale", -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, idx, (char*)node->children->content, -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, idx, reinterpret_cast<char*>(node->children->content),
+ -1, SQLITE_TRANSIENT);
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
return ret;
}
-static int _parse_privilege(xmlNode* node, sqlite3* db, const char* providerid) {
+static int _parse_privilege(xmlNode* node, sqlite3* db,
+ const char* providerid) {
int ret;
sqlite3_stmt* stmt = NULL;
xmlNode* tmp;
for (tmp = node->children; tmp; tmp = tmp->next) {
if (!xmlStrcasecmp(tmp->name, (const xmlChar*)"privilege")) {
sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_TRANSIENT);
- sqlite3_bind_text(stmt, 2, (char*)tmp->children->content, -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 2, (char*)tmp->children->content, -1,
+ SQLITE_TRANSIENT);
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
|| tmp->children->content == NULL)
return -1;
- period = atoi((char*)tmp->children->content);
+ period = atoi(reinterpret_cast<char*>(tmp->children->content));
if (period < 60)
period = 60;
} else if (!xmlStrcasecmp(tmp->name, (const xmlChar*)"label")) {
return result;
}
-int complication_parser_plugin_parse_manifest(xmlDocPtr doc, const char* pkgid) {
+int complication_parser_plugin_parse_manifest(xmlDocPtr doc,
+ const char* pkgid) {
xmlNode* root;
xmlNode* tmp;
* limitations under the License.
*/
-#ifndef __WIDGET_PLUGIN_PARSER_INTERNAL_H__
-#define __WIDGET_PLUGIN_PARSER_INTERNAL_H__
+#ifndef PARSER_COMPLICATION_PARSER_PLUGIN_INTERNAL_H_
+#define PARSER_COMPLICATION_PARSER_PLUGIN_INTERNAL_H_
#include <stdbool.h>
#include <sys/types.h>
sqlite3* open_db(uid_t uid);
int check_db(uid_t uid);
-#endif
+#endif // PARSER_COMPLICATION_PARSER_PLUGIN_INTERNAL_H_
return complication_parser_plugin_init();
}
-extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char* pkgid) {
+extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc,
+ const char* pkgid) {
if (complication_parser_plugin_parse_manifest(doc, pkgid)) {
LOGE("parse failed");
return -1;
return complication_parser_plugin_init();
}
-extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc, const char* pkgid) {
+extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc,
+ const char* pkgid) {
if (complication_parser_db_remove_complication(pkgid)) {
LOGE("remove db fail");
return -1;
return complication_parser_plugin_fini();
}
-extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char* pkgid) {
+extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(
+ const char* pkgid) {
return complication_parser_plugin_init();
}
-extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc, const char* pkgid) {
+extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc,
+ const char* pkgid) {
return complication_parser_db_remove_complication(pkgid);
}
-extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char* pkgid) {
+extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(
+ const char* pkgid) {
return complication_parser_plugin_fini();
}
#include "watchface-util.h"
#include "watchface-common.h"
-
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "WATCHFACE_COMPLICATION"
namespace watchface_complication {
- namespace util {
- static int __cynara_check(const char* client, const char* user, const char* privilege) {
+namespace util {
+ static int __cynara_check(const char* client, const char* user,
+ const char* privilege) {
int ret, cynara_ret;
cynara* p_cynara = NULL;
int CheckPrivilege(const char* privilege) {
int fd;
int ret;
- char subject_label[SMACK_LABEL_LEN + 1] = {0,};
- char uid[10] = {0,};
+ char subject_label[SMACK_LABEL_LEN + 1] = {0, };
+ char uid[10] = {0, };
fd = open("/proc/self/attr/current", O_RDONLY);
if (fd == -1) {
LOGE("read [%d] failed!", errno);
ret = WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
} else {
- snprintf(uid, 10, "%d", getuid());
+ snprintf(uid, sizeof(uid), "%d", getuid());
ret = __cynara_check(subject_label, uid, privilege);
}
goto out;
}
- LOGD("app_id(%s), client(%s), user(%s)", sender_appid.c_str(), client, user);
+ LOGD("appid(%s), client(%s), user(%s)", sender_appid.c_str(), client, user);
ret = __cynara_check(client, user, privilege.c_str());
return ret;
}
- std::string GetSenderAppid(GDBusConnection* conn, const std::string& sender_name) {
+ std::string GetSenderAppid(GDBusConnection* conn,
+ const std::string& sender_name) {
int ret = 0;
char buffer[MAX_PACKAGE_STR_SIZE + 1] = {0, };
int pid = GetSenderPid(conn, sender_name);
GVariant* body;
int pid = 0;
- msg = g_dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", "GetConnectionUnixProcessID");
+ msg = g_dbus_message_new_method_call("org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixProcessID");
if (!msg) {
LOGE("Can't allocate new method call");
goto out;
}
}
- } /* namespace util */
-} /* namespace watchface_complication */
+} // namespace util
+} // namespace watchface_complication
* limitations under the License.
*/
-#ifndef WATCHFACE_COMPLICATION_UTIL_H_
-#define WATCHFACE_COMPLICATION_UTIL_H_
+#ifndef WATCHFACE_COMMON_WATCHFACE_UTIL_H_
+#define WATCHFACE_COMMON_WATCHFACE_UTIL_H_
#include <gio/gio.h>
#include <string>
};
namespace watchface_complication {
- namespace util {
+namespace util {
int CheckPrivilege(const char* privilege);
int CheckPrivilege(std::string& privilege,
GDBusConnection *connection,
std::string& sender_name,
std::string& sender_appid);
int GetSenderPid(GDBusConnection *conn, const std::string& sender_name);
- std::string GetSenderAppid(GDBusConnection *conn, const std::string& sender_name);
+ std::string GetSenderAppid(GDBusConnection *conn,
+ const std::string& sender_name);
bool CheckSender(const char* sender_app_id,
const std::string& sender_name,
GDBusConnection* conn);
bool CheckComplicationType(int type);
- }
-} /* namespace watchface_complication */
+} // namespace util
+} // namespace watchface_complication
-#endif /* WATCHFACE_COMPLICATION_DB_MANAGER_H_ */
+#endif // WATCHFACE_COMMON_WATCHFACE_UTIL_H_
* limitations under the License.
*/
-#ifndef WATCHFACE_COMPLICATION_EXCEPTION_H_
-#define WATCHFACE_COMPLICATION_EXCEPTION_H_
+#ifndef WATCHFACE_COMMON_WATCHFACE_EXCEPTION_H_
+#define WATCHFACE_COMMON_WATCHFACE_EXCEPTION_H_
#include <string>
#include <exception>
#define THROW(error_code) throw Exception(error_code, __FILE__, __LINE__)
namespace watchface_complication {
- class Exception : public std::exception {
- public:
- Exception(int error_code, std::string file = __FILE__, int line = __LINE__ ) {
- _error_code = error_code;
- _whatMessage = file.substr(file.find_last_of("/") + 1) + ":"
- + std::to_string(line) + GetErrorString(error_code);
- }
- virtual ~Exception() {};
- virtual const char *what(void) const noexcept {
- return _whatMessage.c_str();
- }
- int GetErrorCode() {
- return _error_code;
- }
- private:
- int _error_code;
- std::string _whatMessage;
- std::string GetErrorString(int error_code) {
- switch (error_code) {
- case WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY:
- return ": OUT_OF_MEMORY";
- case WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER:
- return ": INVALID_PARAMETER";
- case WATCHFACE_COMPLICATION_ERROR_IO_ERROR:
- return ": IO_ERROR";
- case WATCHFACE_COMPLICATION_ERROR_NO_DATA:
- return ": NO_DATA";
- case WATCHFACE_COMPLICATION_ERROR_PERMISSION_DENIED:
- return ": PERMISSION_DENIED";
- case WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED:
- return ": NOT_SUPPORTED";
- case WATCHFACE_COMPLICATION_ERROR_DB:
- return ": DB_ERROR";
- case WATCHFACE_COMPLICATION_ERROR_DBUS:
- return ": DBUS_ERROR";
- case WATCHFACE_COMPLICATION_ERROR_EDIT_NOT_READY:
- return ": EDIT_NOT_READY";
- case WATCHFACE_COMPLICATION_ERROR_EXIST_ID:
- return ": EXIST_ID";
- case WATCHFACE_COMPLICATION_ERROR_NOT_EXIST:
- return ": NOT_EXIST";
- default :
- return "";
- }
+class Exception : public std::exception {
+ public:
+ Exception(int error_code, std::string file = __FILE__, int line = __LINE__ ) {
+ _error_code = error_code;
+ _whatMessage = file.substr(file.find_last_of("/") + 1) + ":"
+ + std::to_string(line) + GetErrorString(error_code);
}
- };
-}
+ virtual ~Exception() {}
+ virtual const char *what(void) const noexcept {
+ return _whatMessage.c_str();
+ }
+ int GetErrorCode() {
+ return _error_code;
+ }
+
+ private:
+ int _error_code;
+ std::string _whatMessage;
+ std::string GetErrorString(int error_code) {
+ switch (error_code) {
+ case WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY:
+ return ": OUT_OF_MEMORY";
+ case WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER:
+ return ": INVALID_PARAMETER";
+ case WATCHFACE_COMPLICATION_ERROR_IO_ERROR:
+ return ": IO_ERROR";
+ case WATCHFACE_COMPLICATION_ERROR_NO_DATA:
+ return ": NO_DATA";
+ case WATCHFACE_COMPLICATION_ERROR_PERMISSION_DENIED:
+ return ": PERMISSION_DENIED";
+ case WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED:
+ return ": NOT_SUPPORTED";
+ case WATCHFACE_COMPLICATION_ERROR_DB:
+ return ": DB_ERROR";
+ case WATCHFACE_COMPLICATION_ERROR_DBUS:
+ return ": DBUS_ERROR";
+ case WATCHFACE_COMPLICATION_ERROR_EDIT_NOT_READY:
+ return ": EDIT_NOT_READY";
+ case WATCHFACE_COMPLICATION_ERROR_EXIST_ID:
+ return ": EXIST_ID";
+ case WATCHFACE_COMPLICATION_ERROR_NOT_EXIST:
+ return ": NOT_EXIST";
+ default :
+ return "";
+ }
+ }
+};
+
+} // namespace watchface_complication
-#endif /* WATCHFACE_COMPLICATION_DB_MANAGER_H_ */
+#endif // WATCHFACE_COMMON_WATCHFACE_EXCEPTION_H_