-#Copyright (c) 2013 GitHub, Inc.
-#
-#Permission is hereby granted, free of charge, to any person obtaining a
-#copy of this software and associated documentation files (the "Software"),
-#to deal in the Software without restriction, including without limitation
-#the rights to use, copy, modify, merge, publish, distribute, sublicense,
-#and/or sell copies of the Software, and to permit persons to whom the
-#Software is furnished to do so, subject to the following conditions:
-#
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-#DEALINGS IN THE SOFTWARE.
-#
-# https://github.com/github/gitignore
+.*
+!.gitignore
+*~
+
+*~
+\#*\#
+/.emacs.desktop
+/.emacs.desktop.lock
+.elc
+auto-save-list
+tramp
+.\#*
+
+# Org-mode
+.org-id-locations
+*_archive
# Object files
*.o
*.out
*.app
-# CMake
-CMakeCache.txt
-CMakeFiles
-Makefile
-cmake_install.cmake
-install_manifest.txt
-
-# Emacs
-*~
-\#*\#
-/.emacs.desktop
-/.emacs.desktop.lock
-.elc
-auto-save-list
-tramp
-.\#*
-
-# Org-mode
-.org-id-locations
-*_archive
-
-# Linux
-.*
-!.gitignore
-*~
-
-# Vim
-*.s[a-w][a-z]
-*.un~
-Session.vim
-.netrwhist
-*~
-
-# Eclipse
-*.pydevproject
-.project
-.metadata
-bin/**
-tmp/**
-tmp/**/*
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.classpath
-.settings/
-.loadpath
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
+# Patches
+*.patch
+*.diff
--- /dev/null
+Jongman Park <jman.park@samsung.com>
+Ja-young Gu <jygu@samsung.com>
+Kyeongchul Kim <kyeongchul.kim@samsung.com>
+DongHoo Park <donghoo.park@samsung.>
+Youngman Park <youngman.park@samsung.com>
+Inho Oh <inho48.oh@samsung.com>
# Set required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 gobject-2.0 tcore tel-headers dlog libsystemd-daemon)
+pkg_check_modules(pkgs REQUIRED glib-2.0 vconf tcore dlog)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
+SET(ADDITIONAL_CFLAGS "-Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wcast-qual")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_CFLAGS}")
ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG")
ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"DAEMON\"")
ADD_DEFINITIONS("-DDAEMON_VERSION=\"${VERSION}\"")
ADD_DEFINITIONS("-DDEFAULT_PLUGINS_PATH=\"/usr/lib/telephony/plugins/\"")
-IF (ENABLE_MONITOR)
- ADD_DEFINITIONS("-DENABLE_MONITOR")
-ENDIF (ENABLE_MONITOR)
+IF (TIZEN_DEBUG_ENABLE)
+ ADD_DEFINITIONS ("-DTIZEN_DEBUG_ENABLE")
+ENDIF (TIZEN_DEBUG_ENABLE)
+
MESSAGE(${CMAKE_C_FLAGS})
MESSAGE(${pkgs_LDFLAGS})
-IF (ENABLE_MONITOR)
+IF (TIZEN_DEBUG_ENABLE)
SET(SRCS
- src/main.c
- src/monitor.c
+ src/main.c
+ src/monitor.c
)
-ELSE (ENABLE_MONITOR)
+ELSE (TIZEN_DEBUG_ENABLE)
SET(SRCS
- src/main.c
+ src/main.c
)
-ENDIF (ENABLE_MONITOR)
+ENDIF (TIZEN_DEBUG_ENABLE)
# binary build
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl")
-
# install
INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
-
INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME telephony-daemon)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/systemd/telephony.service DESTINATION /usr/lib/systemd/system)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/telephony-daemon.service DESTINATION /usr/lib/systemd/system)
--- /dev/null
+## Restart Telephony Daemon
+systemctl restart telephony-daemon.service
+
+## Stop Telephony Daemon
+systemctl stop telephony-daemon.service
+
+++ /dev/null
-<manifest>
- <assign>
- <filesystem path="/usr/lib/systemd/system/telephony.service" label="_" exec_label="none" />
- <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/telephony.service" label="_" exec_label="none" />
- </assign>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
--- /dev/null
+[Unit]
+Description=Telephony daemon
+Requires=dbus.socket
+After=factory-reset.service secure-storage.service dlog_logger.service shutdown.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/telephony-daemon
+Restart=always
+RestartSec=0
+KillMode=none
+
+[Install]
+WantedBy=multi-user.target
-%define major 3
-%define minor 0
-%define patchlevel 1
+%define major 1
+%define minor 3
+%define patchlevel 24
-Name: telephony-daemon
+Name: telephony-daemon
Version: %{major}.%{minor}.%{patchlevel}
Release: 1
-License: Apache-2.0
-Summary: Telephony daemon
-Group: System/Telephony
-Source0: %{name}-%{version}.tar.gz
-Source1001: telephony-daemon.manifest
+License: Apache
+Summary: Telephony Daemon
+Group: System/Telephony
+Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(tcore)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libsystemd-daemon)
-BuildRequires: pkgconfig(tel-headers)
+BuildRequires: pkgconfig(vconf)
Requires(post): sys-assert
-%{?systemd_requires}
%description
-Description: Telephony daemon
+Description: Telephony Daemon
%prep
%setup -q
-cp %{SOURCE1001} .
%build
-%cmake . -DVERSION=%{version}
-make %{?jobs:-j%jobs}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \
+ -DTIZEN_DEBUG_ENABLE=1 \
+
+make %{?_smp_mflags}
%install
+
%make_install
-mkdir -p %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants
-ln -s ../telephony.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants/telephony.service
-mkdir -p %{buildroot}/usr/share/license
-cp LICENSE %{buildroot}/usr/share/license/%{name}
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+ln -s %{_libdir}/systemd/system/telephony-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/telephony-daemon.service
+
+%post -p /sbin/ldconfig
%files
-%manifest %{name}.manifest
+%manifest telephony-daemon.manifest
%defattr(-,root,root,-)
%{_bindir}/telephony-daemon
-%{_prefix}/lib/systemd/system/telephony.service
-%{_prefix}/lib/systemd/system/multi-user.target.wants/telephony.service
-/usr/share/license/%{name}
+%attr(644,root,root) %{_libdir}/systemd/system/telephony-daemon.service
+%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/telephony-daemon.service
+%{_datadir}/license/telephony-daemon
+++ /dev/null
-[Unit]
-Description=Telephony daemon
-After=modem.service vconf-setup.service
-
-[Service]
-Type=simple
-ExecStart=/usr/bin/telephony-daemon
-
-[Install]
-WantedBy=multi-user.target
+++ /dev/null
-#!/bin/sh
-
-dlogutil -b radio -v time -f /var/log/seq.radio.log -r 4000 -n 3 &
-
-if [ ! -e /opt/etc/.hib_capturing ]; then
-/usr/bin/telephony-daemon &
-fi
-
+++ /dev/null
-../init.d/telephony-daemon
\ No newline at end of file
+++ /dev/null
-../init.d/telephony-daemon
\ No newline at end of file
/*
* telephony-daemon
*
- * Copyright 2013 Samsung Electronics Co. Ltd.
- * Copyright 2013 Intel Corporation.
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* limitations under the License.
*/
+#ifdef TIZEN_DEBUG_ENABLE
+#include "monitor.h"
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/sysinfo.h>
-#include <systemd/sd-daemon.h>
#include <glib.h>
#include <dlog.h>
-
-#ifdef ENABLE_MONITOR
-#include "monitor.h"
-#endif
+#include <vconf.h>
#include <tcore.h>
-#include <server.h>
#include <plugin.h>
+#include <server.h>
#ifndef DAEMON_VERSION
#define DAEMON_VERSION "unknown"
#define DEFAULT_PLUGINS_PATH "/usr/lib/telephony/plugins/"
#endif
+/* Internal vconf to maintain telephony load info (Number of times telephony daemon is loaded) */
+#define VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT "memory/private/telephony/daemon_load_count"
+
#define NOTUSED(var) (var = var)
static Server *_server = NULL;
-static void __usage_info(const gchar *exec)
+static void __usage_info(const char *exec)
{
printf("Usage: %s [OPTION]... [PLUGIN_PATH]\n", exec);
printf("\n");
printf("\n");
}
-void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const gchar *tag, const gchar *fmt, ...)
+void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const char *tag, const char *fmt, ...)
{
va_list ap;
- gchar buf[1024];
+ char buf[1024];
+
+ switch (type) {
+ case TCORE_LOG_TYPE_RADIO: {
+ if (priority >= TCORE_LOG_INFO) {
+ va_start(ap, fmt);
+ vsnprintf(buf, 1023, fmt, ap);
+ va_end(ap);
+ __dlog_print(LOG_ID_RADIO, priority, tag, buf);
+ } else {
+ #ifdef TIZEN_DEBUG_ENABLE
+ va_start(ap, fmt);
+ vsnprintf(buf, 1023, fmt, ap);
+ va_end(ap);
+ __dlog_print(LOG_ID_RADIO, priority, tag, buf);
+ #endif
+ }
+ } break;
- va_start(ap, fmt);
- vsnprintf(buf, 1023, fmt, ap);
- va_end(ap);
+ case TCORE_LOG_TYPE_TIME_CHECK: {
+ #ifdef TIZEN_DEBUG_ENABLE /* User Mode should not log performance data */
+ float a = 0.00, b = 0.00;
+ int next = 0;
+ FILE *fp = fopen("/proc/uptime", "r");
+ g_return_if_fail(NULL != fp);
+
+ if(fscanf(fp, "%f %f", &a, &b)){};
+ fclose(fp);
+ next = sprintf(buf, "[UPTIME] %f ", a);
+ if (next < 0)
+ return;
+
+ va_start(ap, fmt);
+ vsnprintf(buf + next, 1023 - next, fmt, ap);
+ va_end(ap);
+ __dlog_print(LOG_ID_RADIO, priority, tag, buf);
+ #endif
+ } break;
- __dlog_print(type, priority, tag, buf);
+ default:
+ break;
+ }
}
static void glib_log(const gchar *log_domain, GLogLevelFlags log_level,
__dlog_print (LOG_ID_RADIO, DLOG_ERROR, "GLIB", msg);
}
-#ifdef ENABLE_MONITOR
-static void telephony_signal_handler(gint signo)
+#ifdef TIZEN_DEBUG_ENABLE
+static void telephony_signal_handler(int signo)
{
- if (_server == NULL) {
- err("Server is NULL");
+ if (!_server)
return;
- }
switch (signo) {
case SIGUSR1: {
} break;
case SIGTERM: {
- tcore_server_free(_server);
+ tcore_server_exit(_server);
} break;
default: {
warn("*~*~*~* Unhandled Signal: [%d] *~*~*~*", signo);
} break;
} /* end switch */
+
+ return;
}
#endif
float a = 0.00, b = 0.00;
FILE *fp = fopen("/proc/uptime", "r");
g_return_if_fail(NULL != fp);
-
- info("Scanned %d items", fscanf(fp, "%f %f", &a, &b));
+ info("scanned %d items", fscanf(fp, "%f %f", &a, &b));
info("proc uptime = %f idletime = %f\n", a, b);
-
fclose(fp);
}
{
const struct tcore_plugin_define_desc *desc = tcore_plugin_get_description(plugin);
- if ((desc == NULL) || (desc->init == NULL)) {
- err("desc: [%p] desc->init: [%p]", desc, (desc ? desc->init : NULL));
+ if (!desc || !desc->init)
return FALSE;
- }
- if (desc->init(plugin) == FALSE) { /* TODO: Remove plugin from server */
- gchar *plugin_name = tcore_plugin_get_filename(plugin);
- if (plugin_name != NULL) {
- err("Plug-in '%s' init failed!!!", plugin_name);
- tcore_free(plugin_name);
+ if (!desc->init(plugin)) { /* TODO: Remove plugin from server */
+ char *plugin_name = tcore_plugin_get_filename(plugin);
+ if (NULL != plugin_name) {
+ err("plugin(%s) init failed.", plugin_name);
+ free(plugin_name);
}
return FALSE;
}
list = g_slist_next(list);
}
- info("[TIME_CHECK] plugin init finished");
return TRUE;
}
static void *__load_plugin(const gchar *filename, struct tcore_plugin_define_desc **desc_out)
{
- void *handle;
- struct tcore_plugin_define_desc *desc;
+ void *handle = NULL;
+ struct tcore_plugin_define_desc *desc = NULL;
struct stat stat_buf;
- gchar file_date[27];
+ char file_date[27];
- handle = dlopen(filename, RTLD_NOW);
+ handle = dlopen(filename, RTLD_LAZY);
if (G_UNLIKELY(NULL == handle)) {
- err("Failed to open '%s': %s", filename, dlerror());
+ err("fail to load '%s': %s", filename, dlerror());
return NULL;
}
desc = dlsym(handle, "plugin_define_desc");
if (G_UNLIKELY(NULL == desc)) {
- err("Failed to load symbol: %s", dlerror());
-
+ err("fail to load symbol: %s", dlerror());
dlclose(handle);
return NULL;
}
- dbg("'%s' plugin", desc->name);
+ dbg("%s plugin", desc->name);
dbg(" - path = %s", filename);
dbg(" - version = %d", desc->version);
dbg(" - priority = %d", desc->priority);
memset(&stat_buf, 0x00, sizeof(stat_buf));
memset(&file_date, '\0', sizeof(file_date));
- if (stat(filename, &stat_buf) == 0) {
- if (ctime_r(&stat_buf.st_mtime, file_date) != NULL) {
- if (strlen(file_date) > 1)
+ if (0 == stat(filename, &stat_buf)) {
+ if (NULL != ctime_r(&stat_buf.st_mtime, file_date)) {
+ if (1 < strlen(file_date))
file_date[strlen(file_date)-1] = '\0';
-
dbg(" - date = %s", file_date);
}
}
if (G_LIKELY(desc->load)) {
- if (G_UNLIKELY(desc->load() == FALSE)) {
- warn("Failed to load Plug-in");
-
+ if (G_UNLIKELY(FALSE == desc->load())) {
+ warn("false return from load(). skip this plugin");
dlclose(handle);
return NULL;
}
}
- if (desc_out != NULL)
+ if (NULL != desc_out)
*desc_out = desc;
return handle;
}
-static gboolean load_plugins(Server *s, const gchar *path, gboolean flag_test_load)
+static gboolean load_plugins(Server *s, const char *path, gboolean flag_test_load)
{
const gchar *file = NULL;
gchar *filename = NULL;
void *handle = NULL;
struct tcore_plugin_define_desc *desc = NULL;
- if ((path == NULL) || (s == NULL)) {
- err("path: [%p] s: [%p]", path, s);
+ if (!path || !s)
return FALSE;
- }
dir = g_dir_open(path, 0, NULL);
- if (dir == NULL) {
- err("Failed to open directory '%s'", path);
+ if (!dir)
return FALSE;
- }
while ((file = g_dir_read_name(dir)) != NULL) {
if (g_str_has_prefix(file, "lib") == TRUE
- || g_str_has_suffix(file, ".so") == FALSE)
+ || g_str_has_suffix(file, ".so") == FALSE)
continue;
filename = g_build_filename(path, file, NULL);
/* Don't add to server if flag_test_load */
if (flag_test_load) {
- dbg("Loading '%s' - Successful", filename);
-
+ dbg("success to load '%s'", filename);
dlclose(handle);
g_free(filename);
continue;
}
- /* Add Plug-in to Server Plug-in list */
tcore_server_add_plugin(s, tcore_plugin_new(s, desc, filename, handle));
- dbg("'%s' added", desc->name);
+ dbg("%s added", desc->name);
g_free(filename);
}
-
g_dir_close(dir);
- info("[TIME_CHECK] Plug-in load finished");
return TRUE;
}
-gint main(gint argc, gchar *argv[])
+int main(int argc, char *argv[])
{
-#ifdef ENABLE_MONITOR
+#ifdef TIZEN_DEBUG_ENABLE
struct sigaction sigact;
#endif
- Server *s;
+ Server *s = NULL;
gboolean flag_test_load = FALSE;
- gint opt = 0, opt_index = 0, ret_code = EXIT_SUCCESS;
+ int opt = 0, opt_index = 0, ret_code = EXIT_SUCCESS;
+ int daemon_load_count = 0;
struct option options[] = {
{ "help", 0, 0, 0 },
{ "testload", 0, &flag_test_load, 1 },
{ 0, 0, 0, 0 }
};
- gchar *plugin_path = DEFAULT_PLUGINS_PATH;
- gchar *tcore_ver = NULL;
+ const char *plugin_path = DEFAULT_PLUGINS_PATH;
+ char *tcore_ver = NULL;
struct sysinfo sys_info;
+ TIME_CHECK("Starting Telephony");
+
/* System Uptime */
- if (sysinfo(&sys_info) == 0)
+ if (0 == sysinfo(&sys_info))
info("uptime: %ld secs", sys_info.uptime);
__log_uptime();
tcore_ver = tcore_util_get_version();
info("daemon version: %s", DAEMON_VERSION);
info("libtcore version: %s", tcore_ver);
- tcore_free(tcore_ver);
+ free(tcore_ver);
info("glib version: %u.%u.%u", glib_major_version, glib_minor_version, glib_micro_version);
-#ifdef ENABLE_MONITOR
+ /* Telephony reset handling*/
+ vconf_get_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT,&daemon_load_count);
+ daemon_load_count++;
+ vconf_set_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT,daemon_load_count);
+ dbg("daemon load count = [%d]", daemon_load_count);
+
+#ifdef TIZEN_DEBUG_ENABLE
/* Signal Registration */
sigact.sa_handler = telephony_signal_handler;
sigemptyset(&sigact.sa_mask);
warn("sigaction(SIGTERM) failed.");
if (sigaction(SIGUSR1, &sigact, NULL) < 0)
warn("sigaction(SIGUSR1) failed.");
-
- /* Additional signals for dedugging the cause of Telephony crash */
- if (sigaction(SIGINT, &sigact, NULL) < 0)
- warn("sigaction(SIGINT) failed.");
- if (sigaction(SIGABRT, &sigact, NULL) < 0)
- warn("sigaction(SIGABRT) failed.");
- if (sigaction(SIGHUP, &sigact, NULL) < 0)
- warn("sigaction(SIGHUP) failed.");
- if (sigaction(SIGSEGV, &sigact, NULL) < 0)
- warn("sigaction(SIGSEGV) failed.");
- if (sigaction(SIGXCPU, &sigact, NULL) < 0)
- warn("sigaction(SIGXCPU) failed.");
- if (sigaction(SIGQUIT, &sigact, NULL) < 0)
- warn("sigaction(SIGQUIT) failed.");
#endif
/* Commandline option parser TODO: Replace with GOptionContext */
while (TRUE) {
opt = getopt_long(argc, argv, "hT", options, &opt_index);
- if (opt == -1)
+
+ if (-1 == opt)
break;
switch (opt) {
__usage_info(argv[0]);
return 0;
} break;
+ default: {
+ warn("unhandled opt_index.");
+ } break;
} /* end switch */
} break;
case 'T': {
flag_test_load = TRUE;
} break;
+ default: {
+ warn("unhandled opt case.");
+ } break;
} /* end switch */
}
s = tcore_server_new();
if (G_UNLIKELY(NULL == s)) {
err("server_new failed.");
- return EXIT_FAILURE;
+ ret_code = EXIT_FAILURE;
+ goto END;
}
_server = s;
g_log_set_default_handler(glib_log, s);
/* Load Plugins */
- if (G_UNLIKELY(FALSE == load_plugins(s, (const gchar *)plugin_path, flag_test_load))) {
+ if (G_UNLIKELY(FALSE == load_plugins(s, (const char *)plugin_path, flag_test_load))) {
err("load_plugins failed.");
ret_code = EXIT_FAILURE;
goto END;
}
+ TIME_CHECK("Loading Plugins Complete");
+
if (flag_test_load) {
ret_code = EXIT_SUCCESS;
goto END;
goto END;
}
- info("Server mainloop start");
+ info("server mainloop start");
+ TIME_CHECK("Initializing Plugins Complete. Starting Daemon");
- /* Notification to systemd */
- sd_notify(0, "READY=1");
-
- /* Server Run */
- if (G_UNLIKELY(FALSE == tcore_server_run(s))) {
- err("Server_run - Failed!!!");
+ if (G_UNLIKELY(TCORE_RETURN_SUCCESS != tcore_server_run(s))) {
+ err("server_run failed.");
ret_code = EXIT_FAILURE;
}
END:
- tcore_server_free(s);
-
+ tcore_server_free(s); _server = NULL;
return ret_code;
}
/*
* telephony-daemon
*
- * Copyright 2013 Samsung Electronics Co. Ltd.
- * Copyright 2013 Intel Corporation.
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* limitations under the License.
*/
-#include <stdlib.h>
+#include "monitor.h"
+#include <stdlib.h>
#include <glib.h>
-#include "monitor.h"
-
-#include <server.h>
#include <communicator.h>
+#include <user_request.h>
+#include <storage.h>
+#include <server.h>
#include <plugin.h>
-//#include <hal.h>
-#include <core_object.h>
#include <queue.h>
-#include <storage.h>
+#include <hal.h>
+#include <core_object.h>
#define NOTUSED(var) (var = var)
static void _monitor_core_objects(GSList *list)
{
CoreObject *co;
- GHashTable *prop = NULL;
+ GHashTable *prop;
- while (list) {
+ do {
co = list->data;
- msg(" Type: 0x%x", tcore_object_get_type(co));
+ msg(" Name: [%s]", tcore_object_ref_name(co));
msg(" - addr: %p", co);
- //msg(" - hal: %p", tcore_object_get_hal(co));
+ msg(" - type: %p", tcore_object_get_type(co));
+ msg(" - hal: %p", tcore_object_get_hal(co));
- //prop = tcore_object_ref_property_hash(co);
+ prop = tcore_object_ref_property_hash(co);
if (prop) {
msg(" - Properties: %d", g_hash_table_size(prop));
g_hash_table_foreach(prop, _hash_dump, NULL);
}
- list = g_slist_next(list);
- }
+ list = list->next;
+ } while(list);
}
static void _monitor_plugin(Server *s)
{
GSList *list;
- GSList *co_list = NULL;
- TcorePlugin *plugin;
+ GSList *co_list;
+ TcorePlugin *p;
char *str;
msg("-- Plugins --");
list = tcore_server_ref_plugins(s);
- while (list) {
- plugin = list->data;
- if (plugin != NULL) {
- msg("Name: [%s]", tcore_plugin_get_description(plugin)->name);
-
- str = tcore_plugin_get_filename(plugin);
- if (str) {
- msg(" - file: %s", str);
- tcore_free(str);
- }
+ if (!list)
+ return;
- msg(" - addr: %p", plugin);
- msg(" - userdata: %p", tcore_plugin_ref_user_data(plugin));
+ do {
+ p = list->data;
- co_list = tcore_plugin_ref_core_objects(plugin);
- if (co_list) {
- msg(" - core_object list: %d", g_slist_length(co_list));
+ msg("Name: [%s]", tcore_plugin_get_description(p)->name);
- _monitor_core_objects(co_list);
- g_slist_free(co_list);
- }
+ str = tcore_plugin_get_filename(p);
+ if (str) {
+ msg(" - file: %s", str);
+ free(str);
+ }
- msg("");
+ msg(" - addr: %p", p);
+ msg(" - userdata: %p", tcore_plugin_ref_user_data(p));
+
+ co_list = tcore_plugin_get_core_objects(p);
+ if (co_list) {
+ msg(" - core_object list: %d", g_slist_length(co_list));
+
+ _monitor_core_objects(co_list);
+ g_slist_free(co_list);
}
- list = g_slist_next(list);
- }
+ msg("");
+
+ list = list->next;
+ } while(list);
}
static void _monitor_storage(Server *s)
{
GSList *list;
- TcoreStorage *strg;
+ Storage *strg;
msg("-- Storages --");
list = tcore_server_ref_storages(s);
- while (list) {
+ if (!list)
+ return;
+
+ do {
strg = list->data;
- if (strg != NULL) {
- msg("Name: [%s]", tcore_storage_ref_name(strg));
- msg(" - addr: %p", strg);
- msg("");
- }
- list = g_slist_next(list);
- }
+ msg("Name: [%s]", tcore_storage_ref_name(strg));
+ msg(" - addr: %p", strg);
+ msg("");
+
+ list = list->next;
+ } while(list);
}
static void _monitor_communicator(Server *s)
GSList *list;
Communicator *comm;
- msg("-- Communicators --");
+ msg("-- Coomunicators --");
list = tcore_server_ref_communicators(s);
- while (list) {
+ if (!list)
+ return;
+
+ do {
comm = list->data;
- if (comm != NULL) {
- msg("Name: [%s]", tcore_communicator_ref_name(comm));
- msg(" - addr: %p", comm);
- msg(" - parent_plugin: %p", tcore_communicator_ref_plugin(comm));
- msg(" - userdata: %p", tcore_communicator_ref_user_data(comm));
- msg("");
- }
- list = g_slist_next(list);
- }
+ msg("Name: [%s]", tcore_communicator_ref_name(comm));
+ msg(" - addr: %p", comm);
+ msg(" - parent_plugin: %p", tcore_communicator_ref_plugin(comm));
+ msg(" - userdata: %p", tcore_communicator_ref_user_data(comm));
+ msg("");
+
+ list = list->next;
+ } while(list);
}
-static void _monitor_modems(Server *s)
+static void _monitor_hal(Server *s)
{
GSList *list;
- TcorePlugin *plugin;
+ TcoreHal *h;
+ TcoreQueue *q;
+ TcorePending *pending;
+ UserRequest *ur;
+ char *str;
+ int qlen;
+ int i;
+ void *data;
+ unsigned int data_len;
- msg("-- Modems --");
+ msg("-- Hals --");
- list = tcore_server_ref_plugins(s);
- while (list) {
- plugin = list->data;
- if (plugin != NULL)
- tcore_server_print_modems(plugin);
+ list = tcore_server_ref_hals(s);
+ if (!list)
+ return;
+
+ do {
+ h = list->data;
+
+ str = tcore_hal_get_name(h);
+ if (str) {
+ msg("Name: [%s]", str);
+ free(str);
+ }
+ msg(" - addr: %p", h);
+ msg(" - parent_plugin: %p", tcore_hal_ref_plugin(h));
+ msg(" - userdata: %p", tcore_hal_ref_user_data(h));
+
+ q = tcore_hal_ref_queue(h);
+ if (!q) {
+ msg("");
+ list = list->next;
+ continue;
+ }
+
+ if (!(q->gq)) {
+ msg("");
+ list = list->next;
+ continue;
+ }
+
+ qlen = tcore_queue_get_length(q);
+ msg(" - queue: %p, length: %d", q, qlen);
+ msg(" queue_head: %p", g_queue_peek_head(q->gq));
+ for (i = 0; i < qlen; i++) {
+ pending = g_queue_peek_nth(q->gq, i);
+ ur = tcore_pending_ref_user_request(pending);
+ msg(" [%02d] pending=%p, id=0x%x, ur=%p", i, pending, tcore_pending_get_id(pending), ur);
+ if (ur) {
+ msg(" ur request command = 0x%x", tcore_user_request_get_command(ur));
+ }
+ data_len = 0;
+ data = tcore_pending_ref_request_data(pending, &data_len);
+ msg(" data=%p, data_len=%d", data, data_len);
+ }
+ msg(" queue_tail: %p", g_queue_peek_tail(q->gq));
+ msg("");
- list = g_slist_next(list);
- }
+ list = list->next;
+ } while(list);
}
void monitor_server_state(Server *s)
_monitor_plugin(s);
_monitor_storage(s);
_monitor_communicator(s);
- _monitor_modems(s);
+ _monitor_hal(s);
}
/*
* telephony-daemon
*
- * Copyright 2013 Samsung Electronics Co. Ltd.
- * Copyright 2013 Intel Corporation.
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
+++ /dev/null
-[Unit]
-Description=Telephony daemon
-After=modem.service vconf-setup.service
-
-[Service]
-Type=notify
-ExecStart=/usr/bin/telephony-daemon
-
-[Install]
-WantedBy=multi-user.target
--- /dev/null
+<manifest>
+ <define>
+ <domain name="telephony_framework" policy="restricted"/>
+ <provide>
+ <label name="telephony_framework::db"/>
+ <label name="telephony_framework::api_manager"/>
+ <label name="telephony_framework::api_call"/>
+ <label name="telephony_framework::api_gps"/>
+ <label name="telephony_framework::api_modem"/>
+ <label name="telephony_framework::api_network"/>
+ <label name="telephony_framework::api_phonebook"/>
+ <label name="telephony_framework::api_sap"/>
+ <label name="telephony_framework::api_sat"/>
+ <label name="telephony_framework::api_sim"/>
+ <label name="telephony_framework::api_sms"/>
+ <label name="telephony_framework::api_ss"/>
+ <label name="telephony_framework::api_ps_public"/>
+ <label name="telephony_framework::api_ps_profile"/>
+ <label name="telephony_framework::api_ps_private"/>
+ <label name="telephony_framework::api_private"/>
+ <label name="telephony_framework::vconf"/>
+ <label name="telephony_framework::properties"/>
+ </provide>
+ <request>
+ <smack request="telephony_framework::db" type="rwx"/>
+ <smack request="telephony_framework::api_manager" type="rwx"/>
+ <smack request="telephony_framework::api_call" type="rwx"/>
+ <smack request="telephony_framework::api_gps" type="rwx"/>
+ <smack request="telephony_framework::api_modem" type="rwx"/>
+ <smack request="telephony_framework::api_network" type="rwx"/>
+ <smack request="telephony_framework::api_phonebook" type="rwx"/>
+ <smack request="telephony_framework::api_sap" type="rwx"/>
+ <smack request="telephony_framework::api_sat" type="rwx"/>
+ <smack request="telephony_framework::api_sim" type="rwx"/>
+ <smack request="telephony_framework::api_sms" type="rwx"/>
+ <smack request="telephony_framework::api_ss" type="rwx"/>
+ <smack request="telephony_framework::api_ps_public" type="rwx"/>
+ <smack request="telephony_framework::api_ps_profile" type="rwx"/>
+ <smack request="telephony_framework::api_ps_private" type="rwx"/>
+ <smack request="telephony_framework::api_private" type="rwx"/>
+ <smack request="telephony_framework::vconf" type="rwx"/>
+ <smack request="telephony_framework::properties" type="rwx"/>
+ <smack request="dbus" type="rwx"/>
+ <smack request="sys-assert::core" type="rwxat"/>
+ <smack request="system::use_internet" type="rwx"/>
+ <smack request="secure-storage::telephony_sim" type="rw"/>
+ <smack request="security-server::api-privilege-by-pid" type="w"/>
+ <smack request="deviced::display" type="rw"/>
+ <smack request="system::vconf" type="rwxat"/>
+ <smack request="system::vconf_system" type="rwxat"/>
+ </request>
+ <permit>
+ <smack permit="dbus" type="rwx"/>
+ <smack permit="system::use_internet" type="rwx"/>
+ </permit>
+ </define>
+ <assign>
+ <filesystem path="/usr/lib/systemd/system/telephony-daemon.service" label="_"/>
+ <filesystem path="/usr/lib/systemd/system/tizen-system.target.wants/telephony-daemon.service" label="_"/>
+ <filesystem path="db/telephony" label="telephony_framework::db"/>
+ <dbus name="org.tizen.telephony" own="telephony_framework" bus="system">
+ <node name="/org/tizen/telephony">
+ <interface name="org.freedesktop.DBus.Properties">
+ <annotation name="com.tizen.smack" value="telephony_framework::properties"/>
+ </interface>
+ </node>
+ </dbus>
+ </assign>
+ <request>
+ <domain name="telephony_framework"/>
+ </request>
+</manifest>