forked from sailfishos/ofono
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
301b880a87 | ||
|
|
933525829f | ||
|
|
d8df18c80c | ||
|
|
47fd559c1b | ||
|
|
8fa9a7068f | ||
|
|
10c1d7ac75 |
@@ -2,6 +2,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2018-2022 Jolla Ltd. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
@@ -52,6 +53,11 @@ typedef struct GAtResult GAtResult;
|
||||
|
||||
#define HFP_AG_DRIVER "hfp-ag-driver"
|
||||
|
||||
struct watch_fd {
|
||||
guint id;
|
||||
int fd;
|
||||
};
|
||||
|
||||
static gboolean hfp_ag_enabled;
|
||||
static guint service_watch_id;
|
||||
static guint modemwatch_id;
|
||||
@@ -145,11 +151,12 @@ static struct ofono_handsfree_card_driver hfp_ag_driver = {
|
||||
|
||||
static void connection_destroy(gpointer data)
|
||||
{
|
||||
int fd = GPOINTER_TO_INT(data);
|
||||
struct watch_fd *watch = data;
|
||||
|
||||
DBG("fd %d", fd);
|
||||
DBG("fd %d", watch->fd);
|
||||
|
||||
close(fd);
|
||||
g_source_remove(watch->id);
|
||||
g_free(watch);
|
||||
}
|
||||
|
||||
static gboolean io_hup_cb(GIOChannel *io, GIOCondition cond, gpointer data)
|
||||
@@ -169,7 +176,8 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||
DBusMessageIter entry;
|
||||
const char *device;
|
||||
GIOChannel *io;
|
||||
int fd, fd_dup;
|
||||
int fd;
|
||||
struct watch_fd *watch;
|
||||
struct sockaddr_rc saddr;
|
||||
socklen_t optlen;
|
||||
struct ofono_emulator *em;
|
||||
@@ -252,10 +260,12 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||
emulator = em;
|
||||
ofono_emulator_register(em, fd);
|
||||
|
||||
fd_dup = dup(fd);
|
||||
io = g_io_channel_unix_new(fd_dup);
|
||||
g_io_add_watch_full(io, G_PRIORITY_DEFAULT, G_IO_HUP, io_hup_cb,
|
||||
g_strdup(device), g_free);
|
||||
watch = g_new(struct watch_fd, 1);
|
||||
watch->fd = dup(fd);
|
||||
io = g_io_channel_unix_new(watch->fd);
|
||||
g_io_channel_set_close_on_unref(io, TRUE);
|
||||
watch->id = g_io_add_watch_full(io, G_PRIORITY_DEFAULT, G_IO_HUP,
|
||||
io_hup_cb, g_strdup(device), g_free);
|
||||
g_io_channel_unref(io);
|
||||
|
||||
card = ofono_handsfree_card_create(0,
|
||||
@@ -269,8 +279,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
|
||||
|
||||
ofono_emulator_set_handsfree_card(em, card);
|
||||
|
||||
g_hash_table_insert(connection_hash, g_strdup(device),
|
||||
GINT_TO_POINTER(fd_dup));
|
||||
g_hash_table_insert(connection_hash, g_strdup(device), watch);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
|
||||
@@ -304,7 +313,7 @@ static DBusMessage *profile_disconnection(DBusConnection *conn,
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
const char *device;
|
||||
gpointer fd;
|
||||
struct watch_fd *watch;
|
||||
|
||||
DBG("Profile handler RequestDisconnection");
|
||||
|
||||
@@ -318,11 +327,11 @@ static DBusMessage *profile_disconnection(DBusConnection *conn,
|
||||
|
||||
DBG("%s", device);
|
||||
|
||||
fd = g_hash_table_lookup(connection_hash, device);
|
||||
if (fd == NULL)
|
||||
watch = g_hash_table_lookup(connection_hash, device);
|
||||
if (watch == NULL)
|
||||
goto invalid;
|
||||
|
||||
shutdown(GPOINTER_TO_INT(fd), SHUT_RDWR);
|
||||
shutdown(watch->fd, SHUT_RDWR);
|
||||
|
||||
g_hash_table_remove(connection_hash, device);
|
||||
|
||||
|
||||
@@ -771,7 +771,7 @@ static void sim_cbmi_read_cb(int ok, int length, int record,
|
||||
|
||||
mi = (data[i] << 8) + data[i+1];
|
||||
|
||||
if (mi > 999)
|
||||
if (mi > CBS_MAX_TOPIC)
|
||||
continue;
|
||||
|
||||
range = g_new0(struct cbs_topic_range, 1);
|
||||
@@ -818,7 +818,7 @@ static void sim_cbmir_read_cb(int ok, int length, int record,
|
||||
min = (data[i] << 8) + data[i+1];
|
||||
max = (data[i+2] << 8) + data[i+3];
|
||||
|
||||
if (min > 999 || max > 999 || min > max)
|
||||
if (min > CBS_MAX_TOPIC || max > CBS_MAX_TOPIC || min > max)
|
||||
continue;
|
||||
|
||||
range = g_new0(struct cbs_topic_range, 1);
|
||||
|
||||
@@ -262,8 +262,7 @@ static void ims_registration_check(struct ofono_ims *ims)
|
||||
/* Any state is acceptable */
|
||||
DBG("ims is enabled, no action needed");
|
||||
return;
|
||||
case IMS_REG_DEFAULT:
|
||||
/* IMS_REG_AUTO */
|
||||
case IMS_REG_AUTO:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -4593,13 +4593,11 @@ out:
|
||||
GSList *cbs_optimize_ranges(GSList *ranges)
|
||||
{
|
||||
struct cbs_topic_range *range;
|
||||
unsigned char bitmap[125];
|
||||
unsigned char *bitmap = g_malloc0(CBS_MAX_TOPIC / 8 + 1);
|
||||
GSList *l;
|
||||
unsigned short i;
|
||||
GSList *ret = NULL;
|
||||
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
for (l = ranges; l; l = l->next) {
|
||||
range = l->data;
|
||||
|
||||
@@ -4613,7 +4611,7 @@ GSList *cbs_optimize_ranges(GSList *ranges)
|
||||
|
||||
range = NULL;
|
||||
|
||||
for (i = 0; i <= 999; i++) {
|
||||
for (i = 0; i <= CBS_MAX_TOPIC; i++) {
|
||||
int byte_offset = i / 8;
|
||||
int bit = i % 8;
|
||||
|
||||
@@ -4641,6 +4639,7 @@ GSList *cbs_optimize_ranges(GSList *ranges)
|
||||
|
||||
ret = g_slist_reverse(ret);
|
||||
|
||||
g_free(bitmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -4653,10 +4652,10 @@ GSList *cbs_extract_topic_ranges(const char *ranges)
|
||||
GSList *tmp;
|
||||
|
||||
while (next_range(ranges, &offset, &min, &max) == TRUE) {
|
||||
if (min < 0 || min > 999)
|
||||
if (min < 0 || min > CBS_MAX_TOPIC)
|
||||
return NULL;
|
||||
|
||||
if (max < 0 || max > 999)
|
||||
if (max < 0 || max > CBS_MAX_TOPIC)
|
||||
return NULL;
|
||||
|
||||
if (max < min)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ofono/types.h>
|
||||
|
||||
#define CBS_MAX_GSM_CHARS 93
|
||||
#define CBS_MAX_TOPIC 9999
|
||||
#define SMS_MSGID_LEN 20
|
||||
|
||||
enum sms_type {
|
||||
|
||||
@@ -92,9 +92,9 @@ def set_topics(cbs):
|
||||
break
|
||||
|
||||
if topicTemp:
|
||||
if int(topicTemp) > 999:
|
||||
if int(topicTemp) > 9999:
|
||||
invalidData = True
|
||||
print("Invalid Topic ID %s (range 0-999). \
|
||||
print("Invalid Topic ID %s (range 0-9999). \
|
||||
\nCould not register." % topicTemp)
|
||||
|
||||
index = index + 1
|
||||
|
||||
@@ -1589,7 +1589,7 @@ static void test_cbs_padding_character(void)
|
||||
static const char *ranges[] = { "1-5, 2, 3, 600, 569-900, 999",
|
||||
"0-20, 33, 44, 50-60, 20-50, 1-5, 5, 3, 5",
|
||||
NULL };
|
||||
static const char *inv_ranges[] = { "1-5, 3333", "1-5, afbcd", "1-5, 3-5,,",
|
||||
static const char *inv_ranges[] = { "1-5, 33333", "1-5, afbcd", "1-5, 3-5,,",
|
||||
"1-5, 3-5, c", NULL };
|
||||
|
||||
static void test_range_minimizer(void)
|
||||
|
||||
2
upstream
2
upstream
Submodule upstream updated: 5e597b599c...fe9d22374e
Reference in New Issue
Block a user