[-]
[+]
|
Changed |
_service:tar_git:ofono.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:ofono.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://git.merproject.org/slava/ofono.git</param>
<param name="branch">master</param>
- <param name="revision">d65bbc</param>
+ <param name="revision">5e2345</param>
</service>
</services>
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/Makefile.am
^
|
@@ -618,7 +618,7 @@
builtin_libadd += @WSPCODEC_LIBS@
endif
-if LOGCONTROL
+if DEBUGLOG
builtin_modules += debuglog
builtin_sources += plugins/debuglog.c
endif
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/configure.ac
^
|
@@ -252,10 +252,16 @@
AC_SUBST(WSPCODEC_LIBS)
fi
-AC_ARG_ENABLE(logcontrol,
- AC_HELP_STRING([--enable-logcontrol], [enable log control plugin]),
- [enable_logcontrol=${enableval}], [enable_logcontrol="no"])
-AM_CONDITIONAL(LOGCONTROL, test "${enable_logcontrol}" != "no")
+AC_ARG_ENABLE(debuglog,
+ AC_HELP_STRING([--enable-debuglog], [enable log control plugin]),
+ [enable_debuglog=${enableval}], [enable_debuglog="no"])
+AM_CONDITIONAL(DEBUGLOG, test "${enable_debuglog}" != "no")
+if (test "${enable_debuglog}" = "yes"); then
+ PKG_CHECK_MODULES(DBUSLOG, libdbuslogserver-dbus, dummy=yes,
+ AC_MSG_ERROR(libdbuslogserver-dbus is required))
+ CFLAGS="$CFLAGS $DBUSLOG_CFLAGS"
+ LIBS="$LIBS $DBUSLOG_LIBS"
+fi
if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/drivers/ril/ril_plugin.c
^
|
@@ -148,15 +148,24 @@
GLOG_MODULE_DEFINE("rilmodem");
+static const char ril_debug_trace_name[] = "ril_trace";
+
+static GLogModule ril_debug_trace_module = {
+ .name = ril_debug_trace_name,
+ .max_level = GLOG_LEVEL_VERBOSE,
+ .level = GLOG_LEVEL_VERBOSE,
+ .flags = GLOG_FLAG_HIDE_NAME
+};
+
static struct ofono_debug_desc ril_debug_trace OFONO_DEBUG_ATTR = {
- .name = "ril_trace",
- .flags = OFONO_DEBUG_FLAG_DEFAULT,
+ .name = ril_debug_trace_name,
+ .flags = OFONO_DEBUG_FLAG_DEFAULT | OFONO_DEBUG_FLAG_HIDE_NAME,
.notify = ril_debug_trace_notify
};
static struct ofono_debug_desc ril_debug_dump OFONO_DEBUG_ATTR = {
.name = "ril_dump",
- .flags = OFONO_DEBUG_FLAG_DEFAULT,
+ .flags = OFONO_DEBUG_FLAG_DEFAULT | OFONO_DEBUG_FLAG_HIDE_NAME,
.notify = ril_debug_dump_notify
};
@@ -699,12 +708,7 @@
static void ril_plugin_trace(GRilIoChannel *io, GRILIO_PACKET_TYPE type,
guint id, guint code, const void *data, guint data_len, void *user_data)
{
- /* Turn prefix off */
- static GLogModule log_module = {
- .max_level = GLOG_LEVEL_VERBOSE,
- .level = GLOG_LEVEL_VERBOSE
- };
-
+ static const GLogModule* log_module = &ril_debug_trace_module;
const char *prefix = io->name ? io->name : "";
const char dir = (type == GRILIO_PACKET_REQ) ? '<' : '>';
const char *scode;
@@ -717,21 +721,21 @@
} else {
scode = ril_request_to_string(code);
}
- gutil_log(&log_module, GLOG_LEVEL_VERBOSE, "%s%c [%08x] %s",
+ gutil_log(log_module, GLOG_LEVEL_VERBOSE, "%s%c [%08x] %s",
prefix, dir, id, scode);
break;
case GRILIO_PACKET_RESP:
- gutil_log(&log_module, GLOG_LEVEL_VERBOSE, "%s%c [%08x] %s",
+ gutil_log(log_module, GLOG_LEVEL_VERBOSE, "%s%c [%08x] %s",
prefix, dir, id, ril_error_to_string(code));
break;
case GRILIO_PACKET_UNSOL:
- gutil_log(&log_module, GLOG_LEVEL_VERBOSE, "%s%c %s",
+ gutil_log(log_module, GLOG_LEVEL_VERBOSE, "%s%c %s",
prefix, dir, ril_unsol_event_to_string(code));
break;
}
}
-static void ril_debug_dump_update_slot(struct ril_slot *slot)
+static void ril_debug_dump_update(struct ril_slot *slot)
{
if (slot->io) {
if (ril_debug_dump.flags & OFONO_DEBUG_FLAG_PRINT) {
@@ -747,7 +751,7 @@
}
}
-static void ril_debug_trace_update_slot(struct ril_slot *slot)
+static void ril_debug_trace_update(struct ril_slot *slot)
{
if (slot->io) {
if (ril_debug_trace.flags & OFONO_DEBUG_FLAG_PRINT) {
@@ -765,7 +769,7 @@
slot->dump_id);
slot->dump_id = 0;
}
- ril_debug_dump_update_slot(slot);
+ ril_debug_dump_update(slot);
}
} else if (slot->trace_id) {
grilio_channel_remove_logger(slot->io, slot->trace_id);
@@ -965,8 +969,8 @@
DBG("%s %s", slot->sockpath, slot->sub);
slot->io = grilio_channel_new_socket(slot->sockpath, slot->sub);
if (slot->io) {
- ril_debug_trace_update_slot(slot);
- ril_debug_dump_update_slot(slot);
+ ril_debug_trace_update(slot);
+ ril_debug_dump_update(slot);
if (slot->name) {
grilio_channel_set_name(slot->io, slot->name);
@@ -1522,19 +1526,19 @@
slot->pub.enabled = TRUE;
}
-struct ril_plugin_priv *ril_plugin = NULL;
+static struct ril_plugin_priv *ril_plugin = NULL;
static void ril_debug_trace_notify(struct ofono_debug_desc *desc)
{
if (ril_plugin) {
- ril_plugin_foreach_slot(ril_plugin, ril_debug_trace_update_slot);
+ ril_plugin_foreach_slot(ril_plugin, ril_debug_trace_update);
}
}
static void ril_debug_dump_notify(struct ofono_debug_desc *desc)
{
if (ril_plugin) {
- ril_plugin_foreach_slot(ril_plugin, ril_debug_dump_update_slot);
+ ril_plugin_foreach_slot(ril_plugin, ril_debug_dump_update);
}
}
@@ -1561,7 +1565,22 @@
DBG("");
GASSERT(!ril_plugin);
- /* ofono core calls openlog() */
+ /*
+ * Log categories (accessible via D-Bus) are generated from
+ * ofono_debug_desc structures, while libglibutil based log
+ * functions receive the log module name. Those should match
+ * otherwise the client receiving the log won't get the category
+ * information.
+ */
+ grilio_hexdump_log.name = ril_debug_dump.name;
+ grilio_log.name = grilio_debug.name;
+
+ /*
+ * Debug log plugin hooks gutil_log_func2 while we replace
+ * gutil_log_func, they don't interfere with each other.
+ *
+ * Note that ofono core calls openlog(), so we don't need to.
+ */
gutil_log_func = gutil_log_syslog;
ril_plugin_switch_user();
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/drivers/ril/ril_voicecall.c
^
|
@@ -21,9 +21,9 @@
#include "common.h"
-/* Amount of ms we wait between CLCC calls */
+#include <gutil_ring.h>
+
#define FLAG_NEED_CLIP 1
-#define MAX_DTMF_BUFFER 32
enum ril_voicecall_events {
VOICECALL_EVENT_CALL_STATE_CHANGED,
@@ -43,7 +43,7 @@
ofono_voicecall_cb_t cb;
void *data;
guint timer_id;
- gchar *tone_queue;
+ GUtilRing* dtmf_queue;
guint send_dtmf_id;
guint clcc_poll_id;
gulong event_id[VOICECALL_EVENT_COUNT];
@@ -596,11 +596,6 @@
vd->send_dtmf_id = 0;
if (status == RIL_E_SUCCESS) {
- /* Remove sent DTMF character from queue */
- gchar *tmp = g_strdup(vd->tone_queue + 1);
- g_free(vd->tone_queue);
- vd->tone_queue = tmp;
-
/* Send the next one */
ril_voicecall_send_one_dtmf(vd);
} else {
@@ -611,12 +606,15 @@
static void ril_voicecall_send_one_dtmf(struct ril_voicecall *vd)
{
- if (!vd->send_dtmf_id && vd->tone_queue && vd->tone_queue[0]) {
+ if (!vd->send_dtmf_id && gutil_ring_size(vd->dtmf_queue) > 0) {
GRilIoRequest *req = grilio_request_sized_new(4);
+ const char dtmf_char = (char)
+ GPOINTER_TO_UINT(gutil_ring_get(vd->dtmf_queue));
/* RIL wants just one character */
- DBG("%c", vd->tone_queue[0]);
- grilio_request_append_utf8_chars(req, vd->tone_queue, 1);
+ GASSERT(dtmf_char);
+ DBG("%c", dtmf_char);
+ grilio_request_append_utf8_chars(req, &dtmf_char, 1);
vd->send_dtmf_id = grilio_queue_send_request_full(vd->q, req,
RIL_REQUEST_DTMF, ril_voicecall_send_dtmf_cb, NULL, vd);
grilio_request_unref(req);
@@ -629,23 +627,23 @@
struct ril_voicecall *vd = ril_voicecall_get_data(vc);
struct ofono_error error;
- DBG("Queue '%s'",dtmf);
-
/*
- * Queue any incoming DTMF (up to MAX_DTMF_BUFFER characters),
- * send them to RIL one-by-one, immediately call back
- * core with no error
+ * Queue any incoming DTMF, send them to RIL one-by-one,
+ * immediately call back core with no error
*/
- g_strlcat(vd->tone_queue, dtmf, MAX_DTMF_BUFFER);
- ril_voicecall_send_one_dtmf(vd);
+ DBG("Queue '%s'", dtmf);
+ while (*dtmf) {
+ gutil_ring_put(vd->dtmf_queue, GUINT_TO_POINTER(*dtmf));
+ dtmf++;
+ }
+ ril_voicecall_send_one_dtmf(vd);
cb(ril_error_ok(&error), data);
}
static void ril_voicecall_clear_dtmf_queue(struct ril_voicecall *vd)
{
- g_free(vd->tone_queue);
- vd->tone_queue = g_strnfill(MAX_DTMF_BUFFER + 1, '\0');
+ gutil_ring_clear(vd->dtmf_queue);
if (vd->send_dtmf_id) {
grilio_channel_cancel_request(vd->io, vd->send_dtmf_id, FALSE);
vd->send_dtmf_id = 0;
@@ -817,6 +815,7 @@
vd = g_new0(struct ril_voicecall, 1);
vd->io = grilio_channel_ref(ril_modem_io(modem));
vd->q = grilio_queue_new(vd->io);
+ vd->dtmf_queue = gutil_ring_new();
vd->vc = vc;
vd->timer_id = g_idle_add(ril_delayed_register, vd);
if (modem->ecclist_file) {
@@ -847,7 +846,7 @@
grilio_channel_unref(vd->io);
grilio_queue_cancel_all(vd->q, FALSE);
grilio_queue_unref(vd->q);
- g_free(vd->tone_queue);
+ gutil_ring_unref(vd->dtmf_queue);
g_free(vd);
}
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/include/log.h
^
|
@@ -3,6 +3,7 @@
* oFono - Open Telephony stack for Linux
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013-2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -22,6 +23,8 @@
#ifndef __OFONO_LOG_H
#define __OFONO_LOG_H
+#include <stdarg.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -50,6 +53,7 @@
const char *file;
#define OFONO_DEBUG_FLAG_DEFAULT (0)
#define OFONO_DEBUG_FLAG_PRINT (1 << 0)
+#define OFONO_DEBUG_FLAG_HIDE_NAME (1 << 1)
unsigned int flags;
void (*notify)(struct ofono_debug_desc* desc);
} __attribute__((aligned(OFONO_DEBUG_ALIGN)));
@@ -67,10 +71,20 @@
.file = __FILE__, .flags = OFONO_DEBUG_FLAG_DEFAULT, \
}; \
if (__ofono_debug_desc.flags & OFONO_DEBUG_FLAG_PRINT) \
- ofono_debug("%s:%s() " fmt, \
- __FILE__, __FUNCTION__ , ## arg); \
+ __ofono_dbg(&__ofono_debug_desc, "%s() " fmt, \
+ __FUNCTION__ , ## arg); \
} while (0)
+void __ofono_dbg(const struct ofono_debug_desc *desc, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+typedef void (*ofono_log_hook_cb_t)(const struct ofono_debug_desc *desc,
+ int priority, const char *format, va_list va);
+
+extern ofono_log_hook_cb_t ofono_log_hook;
+extern struct ofono_debug_desc __start___debug[];
+extern struct ofono_debug_desc __stop___debug[];
+
#ifdef __cplusplus
}
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/plugins/debuglog.c
^
|
@@ -2,7 +2,7 @@
*
* oFono - Open Source Telephony
*
- * Copyright (C) 2015 Jolla Ltd. All rights reserved.
+ * Copyright (C) 2015-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -13,261 +13,243 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <gdbus.h>
-#include <string.h>
-
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
+#include <ofono/dbus.h>
#include <ofono/log.h>
-#include <ofono.h>
-#define DEBUGLOG_INTERFACE OFONO_SERVICE ".DebugLog"
-#define DEBUGLOG_PATH "/"
-#define DEBUGLOG_CHANGED_SIGNAL "Changed"
+#include <dbuslog_server_dbus.h>
+#include <gutil_log.h>
+
+#include <string.h>
+#include <syslog.h>
+
+#define DEBUGLOG_PATH "/"
-static DBusConnection *connection = NULL;
+enum _debug_server_event {
+ DEBUG_EVENT_CATEGORY_ENABLED,
+ DEBUG_EVENT_CATEGORY_DISABLED,
+ DEBUG_EVENT_COUNT
+};
-extern struct ofono_debug_desc __start___debug[];
-extern struct ofono_debug_desc __stop___debug[];
+static DBusLogServer *debuglog_server;
+static GLogProc2 debuglog_default_log_proc;
+static gulong debuglog_event_id[DEBUG_EVENT_COUNT];
-static void debuglog_signal(DBusConnection *conn, const char *name,
- guint flags)
+static void debuglog_ofono_log_hook(const struct ofono_debug_desc *desc,
+ int priority, const char *format, va_list va)
{
- DBusMessage *signal = dbus_message_new_signal(DEBUGLOG_PATH,
- DEBUGLOG_INTERFACE, DEBUGLOG_CHANGED_SIGNAL);
+ DBUSLOG_LEVEL dbuslevel;
+ const char *category;
- if (signal) {
- DBusMessageIter iter;
- const dbus_bool_t on = (flags & OFONO_DEBUG_FLAG_PRINT) != 0;
-
- dbus_message_iter_init_append(signal, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &on);
- g_dbus_send_message(conn, signal);
+ if (desc) {
+ category = desc->name ? desc->name : desc->file;
+ } else {
+ category = NULL;
}
+
+ /* ofono is only using these four priorities: */
+ switch (priority) {
+ case LOG_ERR:
+ dbuslevel = DBUSLOG_LEVEL_ERROR;
+ break;
+ case LOG_WARNING:
+ dbuslevel = DBUSLOG_LEVEL_WARNING;
+ break;
+ case LOG_INFO:
+ dbuslevel = DBUSLOG_LEVEL_INFO;
+ break;
+ case LOG_DEBUG:
+ dbuslevel = DBUSLOG_LEVEL_DEBUG;
+ break;
+ default:
+ dbuslevel = DBUSLOG_LEVEL_UNDEFINED;
+ break;
+ }
+
+ dbus_log_server_logv(debuglog_server, dbuslevel, category, format, va);
}
-static GHashTable *debuglog_update_flags_hash(GHashTable *hash,
- const char *name, guint flags)
+static void debuglog_gutil_log_func(const GLogModule* log, int level,
+ const char* format, va_list va)
{
- if (name) {
- gpointer key = (gpointer)name;
- guint value;
- if (!hash) {
- hash = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, NULL);
- }
+ DBUSLOG_LEVEL loglevel;
- value = GPOINTER_TO_INT(g_hash_table_lookup(hash, key));
- value |= flags;
- g_hash_table_insert(hash, key, GINT_TO_POINTER(value));
+ switch (level) {
+ case GLOG_LEVEL_ERR:
+ loglevel = DBUSLOG_LEVEL_ERROR;
+ break;
+ case GLOG_LEVEL_WARN:
+ loglevel = DBUSLOG_LEVEL_WARNING;
+ break;
+ case GLOG_LEVEL_INFO:
+ loglevel = DBUSLOG_LEVEL_INFO;
+ break;
+ case GLOG_LEVEL_DEBUG:
+ loglevel = DBUSLOG_LEVEL_DEBUG;
+ break;
+ case GLOG_LEVEL_VERBOSE:
+ loglevel = DBUSLOG_LEVEL_VERBOSE;
+ break;
+ default:
+ loglevel = DBUSLOG_LEVEL_UNDEFINED;
+ break;
}
- return hash;
+ dbus_log_server_logv(debuglog_server, loglevel, log->name, format, va);
+ if (debuglog_default_log_proc) {
+ debuglog_default_log_proc(log, level, format, va);
+ }
}
-static gboolean debuglog_match(const char* name, const char* pattern)
+static gboolean debuglog_match(const char* s1, const char* s2)
{
- return name && g_pattern_match_simple(pattern, name);
+ return s1 && s2 && !strcmp(s1, s2);
}
-static void debuglog_update(DBusConnection *conn, const char* pattern,
- guint set_flags, guint clear_flags)
+static void debuglog_update_flags(const char* name, guint set, guint clear)
{
- const guint flags = set_flags | clear_flags;
+ const guint flags = set | clear;
struct ofono_debug_desc *start = __start___debug;
struct ofono_debug_desc *stop = __stop___debug;
- struct ofono_debug_desc *desc;
- GHashTable *hash = NULL;
- if (!start || !stop)
- return;
+ if (start && stop) {
+ struct ofono_debug_desc *desc;
+ for (desc = start; desc < stop; desc++) {
+ const char *matched = NULL;
- for (desc = start; desc < stop; desc++) {
- const char *matched = NULL;
-
- if (debuglog_match(desc->file, pattern)) {
- matched = desc->file;
- } else if (debuglog_match(desc->name, pattern)) {
- matched = desc->name;
- }
+ if (debuglog_match(desc->file, name)) {
+ matched = desc->file;
+ } else if (debuglog_match(desc->name, name)) {
+ matched = desc->name;
+ }
- if (matched) {
- const guint old_flags = (desc->flags & flags);
- desc->flags |= set_flags;
- desc->flags &= ~clear_flags;
- if ((desc->flags & flags) != old_flags) {
- hash = debuglog_update_flags_hash(hash,
- matched, desc->flags);
- if (desc->notify) {
+ if (matched) {
+ const guint old_flags = (desc->flags & flags);
+ desc->flags |= set;
+ desc->flags &= ~clear;
|
[-]
[+]
|
Changed |
_service:tar_git:ofono-1.17+git27.tar.bz2/ofono/src/log.c
^
|
@@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013-2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -37,6 +38,9 @@
#include "ofono.h"
+ofono_log_hook_cb_t ofono_log_hook;
+static GString *ofono_debug_str;
+
static const char *program_exec;
static const char *program_path;
@@ -56,6 +60,12 @@
vsyslog(LOG_INFO, format, ap);
va_end(ap);
+
+ if (ofono_log_hook) {
+ va_start(ap, format);
+ ofono_log_hook(NULL, LOG_INFO, format, ap);
+ va_end(ap);
+ }
}
/**
@@ -74,6 +84,12 @@
vsyslog(LOG_WARNING, format, ap);
va_end(ap);
+
+ if (ofono_log_hook) {
+ va_start(ap, format);
+ ofono_log_hook(NULL, LOG_WARNING, format, ap);
+ va_end(ap);
+ }
}
/**
@@ -92,6 +108,12 @@
vsyslog(LOG_ERR, format, ap);
va_end(ap);
+
+ if (ofono_log_hook) {
+ va_start(ap, format);
+ ofono_log_hook(NULL, LOG_ERR, format, ap);
+ va_end(ap);
+ }
}
/**
@@ -113,6 +135,37 @@
vsyslog(LOG_DEBUG, format, ap);
va_end(ap);
+
+ if (ofono_log_hook) {
+ va_start(ap, format);
+ ofono_log_hook(NULL, LOG_DEBUG, format, ap);
+ va_end(ap);
+ }
+}
+
+void __ofono_dbg(const struct ofono_debug_desc *desc, const char *format, ...)
+{
+ va_list ap;
+
+ if (!(desc->flags & OFONO_DEBUG_FLAG_PRINT))
+ return;
+
+ va_start(ap, format);
+
+ if (ofono_debug_str) {
+ g_string_vprintf(ofono_debug_str, format, ap);
+ syslog(LOG_DEBUG, "%s:%s", desc->file, ofono_debug_str->str);
+ } else {
+ vsyslog(LOG_DEBUG, format, ap);
+ }
+
+ va_end(ap);
+
+ if (ofono_log_hook) {
+ va_start(ap, format);
+ ofono_log_hook(desc, LOG_DEBUG, format, ap);
+ va_end(ap);
+ }
}
#ifdef __GLIBC__
@@ -306,6 +359,7 @@
program_exec = program;
program_path = getcwd(path, sizeof(path));
+ ofono_debug_str = g_string_sized_new(127);
if (debug != NULL)
enabled = g_strsplit_set(debug, ":, ", 0);
@@ -339,4 +393,6 @@
#endif
g_strfreev(enabled);
+ g_string_free(ofono_debug_str, TRUE);
+ ofono_debug_str = NULL;
}
|