Commit d08067e2 authored by Slava Monich's avatar Slava Monich

Merge pull request #38 from monich/mms_settings

Support for persistent per-SIM settings
parents c8b209d7 5ac2cb8a
......@@ -19,7 +19,7 @@
#include "mms_ofono_log.h"
#include "mms_lib_log.h"
#include "mms_lib_util.h"
#include "mms_dispatcher.h"
#include "mms_settings.h"
#define RET_OK (0)
#define RET_ERR (1)
......@@ -27,10 +27,11 @@
/* Options configurable from the command line */
typedef struct mms_app_options {
GBusType bus_type;
gboolean keep_running;
int flags;
char* dir;
char* user_agent;
MMSConfig config;
MMSSettingsSimData settings;
} MMSAppOptions;
/* All known log modules */
......@@ -161,26 +162,18 @@ mms_app_parse_options(
#ifdef MMS_ENGINE_VERSION
gboolean print_version = FALSE;
#endif
gint size_limit_kb = opt->config.size_limit/1024;
gdouble megapixels = opt->config.max_pixels / 1000000.0;
gboolean keep_running = FALSE;
gint size_limit_kb = -1;
gdouble megapixels = -1;
char* root_dir_help = g_strdup_printf(
"Root directory for MMS files [%s]",
opt->config.root_dir);
char* user_agent_help = g_strdup_printf(
"User-Agent [%s]",
opt->config.user_agent);
char* retry_secs_help = g_strdup_printf(
"Retry period in seconds [%d]",
opt->config.retry_secs);
char* idle_secs_help = g_strdup_printf(
"Inactivity timeout in seconds [%d]",
opt->config.idle_secs);
char* size_limit_help = g_strdup_printf(
"Maximum size for outgoing messages [%d]",
size_limit_kb);
char* megapixels_help = g_strdup_printf(
"Maximum pixel count for outgoing images [%.1f]",
megapixels);
char* description = mms_log_description(mms_app_log_modules,
G_N_ELEMENTS(mms_app_log_modules));
......@@ -195,12 +188,12 @@ mms_app_parse_options(
{ "idle-secs", 'i', 0, G_OPTION_ARG_INT,
&opt->config.idle_secs, idle_secs_help, "SEC" },
{ "size-limit", 's', 0, G_OPTION_ARG_INT,
&size_limit_kb, size_limit_help, "KB" },
&size_limit_kb, "Maximum size for outgoing messages", "KB" },
{ "pix-limit", 'p', 0, G_OPTION_ARG_DOUBLE,
&megapixels, megapixels_help, "MPIX" },
&megapixels, "Maximum pixel count for outgoing images", "MPIX" },
{ "user-agent", 'u', 0, G_OPTION_ARG_STRING,
&opt->user_agent, user_agent_help, "STRING" },
{ "keep-running", 'k', 0, G_OPTION_ARG_NONE, &opt->keep_running,
&opt->user_agent, "User-Agent header", "STRING" },
{ "keep-running", 'k', 0, G_OPTION_ARG_NONE, &keep_running,
"Keep running after everything is done", NULL },
{ "keep-temp-files", 't', 0, G_OPTION_ARG_NONE,
&opt->config.keep_temp_files,
......@@ -228,37 +221,41 @@ mms_app_parse_options(
ok = g_option_context_parse(options, &argc, &argv, &error);
g_option_context_free(options);
g_free(root_dir_help);
g_free(user_agent_help);
g_free(retry_secs_help);
g_free(idle_secs_help);
g_free(size_limit_help);
g_free(megapixels_help);
g_free(description);
#ifdef MMS_ENGINE_VERSION
# define MMS_STRING__(x) #x
# define MMS_STRING_(x) MMS_STRING__(x)
# define MMS_VERVION_STRING MMS_STRING_(MMS_ENGINE_VERSION)
if (print_version) {
printf("MMS engine %s\n", MMS_STRING_(MMS_ENGINE_VERSION));
printf("MMS engine %s\n", MMS_VERVION_STRING);
*result = RET_OK;
return FALSE;
} else
#endif
if (ok) {
#ifdef MMS_ENGINE_VERSION
MMS_INFO("Version %s starting", MMS_VERVION_STRING);
#else
MMS_INFO("Starting");
#endif
if (size_limit_kb >= 0) {
opt->config.size_limit = size_limit_kb * 1024;
} else {
opt->config.size_limit = 0;
opt->settings.size_limit = size_limit_kb * 1024;
opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_SIZE_LIMIT;
}
if (megapixels >= 0) {
opt->config.max_pixels = (int)(megapixels*1000)*1000;
} else {
opt->config.max_pixels = 0;
opt->settings.max_pixels = (int)(megapixels*1000)*1000;
opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS;
}
if (opt->user_agent) {
opt->settings.user_agent = opt->user_agent;
opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT;
}
if (opt->dir) opt->config.root_dir = opt->dir;
if (opt->user_agent) opt->config.user_agent = opt->user_agent;
if (keep_running) opt->flags |= MMS_ENGINE_FLAG_KEEP_RUNNING;
if (session_bus) {
MMS_DEBUG("Attaching to session bus");
opt->bus_type = G_BUS_TYPE_SESSION;
......@@ -283,13 +280,12 @@ int main(int argc, char* argv[])
mms_lib_init(argv[0]);
mms_log_default.name = MMS_APP_LOG_PREFIX;
mms_lib_default_config(&opt.config);
mms_settings_sim_data_default(&opt.settings);
if (mms_app_parse_options(&opt, argc, argv, &result)) {
MMSEngine* engine;
unsigned int engine_flags = 0;
if (opt.keep_running) engine_flags |= MMS_ENGINE_FLAG_KEEP_RUNNING;
/* Create engine instance. This may fail */
engine = mms_engine_new(&opt.config, engine_flags,
engine = mms_engine_new(&opt.config, &opt.settings, opt.flags,
mms_app_log_modules, G_N_ELEMENTS(mms_app_log_modules));
if (engine) {
guint name_id;
......
......@@ -14,6 +14,7 @@
#include "mms_engine.h"
#include "mms_dispatcher.h"
#include "mms_settings.h"
#include "mms_lib_util.h"
#include "mms_ofono_connman.h"
#include "mms_handler_dbus.h"
......@@ -54,9 +55,9 @@ struct mms_engine {
typedef GObjectClass MMSEngineClass;
G_DEFINE_TYPE(MMSEngine, mms_engine, G_TYPE_OBJECT);
#define MMS_ENGINE_TYPE (mms_engine_get_type())
#define MMS_TYPE_ENGINE (mms_engine_get_type())
#define MMS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
MMS_ENGINE_TYPE, MMSEngine))
MMS_TYPE_ENGINE, MMSEngine))
inline static MMSEngine*
mms_engine_from_dispatcher_delegate(MMSDispatcherDelegate* delegate)
......@@ -408,15 +409,31 @@ mms_engine_handle_set_log_type(
MMSEngine*
mms_engine_new(
const MMSConfig* config,
const MMSSettingsSimData* override,
unsigned int flags,
MMSLogModule* log_modules[],
int log_count)
{
MMSConnMan* cm = mms_connman_ofono_new();
if (cm) {
MMSEngine* mms = g_object_new(MMS_ENGINE_TYPE, NULL);
MMSEngine* mms = g_object_new(MMS_TYPE_ENGINE, NULL);
MMSHandler* handler = mms_handler_dbus_new();
mms->dispatcher = mms_dispatcher_new(config, cm, handler);
MMSSettings* settings = mms_settings_default_new(config);
if (flags & MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT) {
g_free(settings->sim_defaults.user_agent);
settings->sim_defaults.data.user_agent =
settings->sim_defaults.user_agent = g_strdup(override->user_agent);
}
if (flags & MMS_ENGINE_FLAG_OVERRIDE_SIZE_LIMIT) {
settings->sim_defaults.data.size_limit = override->size_limit;
}
if (flags & MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS) {
settings->sim_defaults.data.max_pixels = override->max_pixels;
}
mms->dispatcher = mms_dispatcher_new(settings, cm, handler);
mms_settings_unref(settings);
mms_connman_unref(cm);
mms_handler_unref(handler);
mms_dispatcher_set_delegate(mms->dispatcher,
......
......@@ -15,22 +15,25 @@
#ifndef JOLLA_MMS_ENGINE_H
#define JOLLA_MMS_ENGINE_H
#include <glib.h>
#include <gio/gio.h>
#include "mms_lib_types.h"
#include "mms_settings.h"
#define MMS_APP_LOG_PREFIX "mms-engine"
#define MMS_ENGINE_SERVICE "org.nemomobile.MmsEngine"
#define MMS_ENGINE_PATH "/"
#define MMS_ENGINE_FLAG_KEEP_RUNNING (0x01)
#define MMS_ENGINE_FLAG_KEEP_RUNNING (0x01)
#define MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT (0x02)
#define MMS_ENGINE_FLAG_OVERRIDE_SIZE_LIMIT (0x04)
#define MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS (0x08)
typedef struct mms_engine MMSEngine;
MMSEngine*
mms_engine_new(
const MMSConfig* config,
const MMSSettingsSimData* settings,
unsigned int flags,
MMSLogModule* log_modules[],
int log_count);
......
......@@ -24,12 +24,31 @@ all: debug release
# Sources
#
SRC = mms_attachment.c mms_attachment_image.c mms_attachment_jpeg.c \
mms_codec.c mms_connection.c mms_connman.c mms_dispatcher.c mms_error.c \
mms_handler.c mms_lib_util.c mms_file_util.c mms_log.c mms_message.c \
mms_task.c mms_task_ack.c mms_task_decode.c mms_task_encode.c \
mms_task_http.c mms_task_notification.c mms_task_notifyresp.c \
mms_task_publish.c mms_task_read.c mms_task_retrieve.c mms_task_send.c \
SRC = \
mms_attachment.c \
mms_attachment_image.c \
mms_attachment_jpeg.c \
mms_codec.c \
mms_connection.c \
mms_connman.c \
mms_dispatcher.c \
mms_error.c \
mms_handler.c \
mms_lib_util.c \
mms_file_util.c \
mms_log.c mms_message.c \
mms_settings.c \
mms_task.c \
mms_task_ack.c \
mms_task_decode.c \
mms_task_encode.c \
mms_task_http.c \
mms_task_notification.c \
mms_task_notifyresp.c \
mms_task_publish.c \
mms_task_read.c \
mms_task_retrieve.c \
mms_task_send.c \
mms_util.c
ifeq ($(MMS_RESIZE),Qt)
......
......@@ -28,7 +28,7 @@ struct mms_dispatcher_delegate {
MMSDispatcher*
mms_dispatcher_new(
const MMSConfig* config,
MMSSettings* settings,
MMSConnMan* cm,
MMSHandler* handler);
......
......@@ -43,19 +43,6 @@
# define HAVE_REALPATH
#endif
/* Static configuration, chosen at startup and never changing since then */
typedef struct mms_config {
const char* root_dir; /* Root directory for storing MMS files */
const char* user_agent; /* User agent string */
int retry_secs; /* Retry timeout in seconds */
int idle_secs; /* Idle timeout */
gsize size_limit; /* Maximum size of m-Send.req PDU */
guint max_pixels; /* Pixel limit for outbound images */
gboolean keep_temp_files; /* Keep temporary files around */
gboolean attic_enabled; /* Keep unrecognized push message in attic */
gboolean send_dr; /* Allow sending delivery reports */
} MMSConfig;
/* Attachment information */
typedef struct mms_attachment_info {
const char* file_name; /* Full path name */
......@@ -64,6 +51,9 @@ typedef struct mms_attachment_info {
} MMSAttachmentInfo;
/* Types */
typedef struct mms_config MMSConfig;
typedef struct mms_settings MMSSettings;
typedef struct mms_settings_sim_data MMSSettingsSimData;
typedef struct mms_handler MMSHandler;
typedef struct mms_connman MMSConnMan;
typedef struct mms_log_module MMSLogModule;
......
/*
* Copyright (C) 2014 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
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* 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.
*
*/
#ifndef JOLLA_MMS_SETTINGS_H
#define JOLLA_MMS_SETTINGS_H
#include "mms_lib_types.h"
/* Static configuration, chosen at startup and never changing since then */
struct mms_config {
const char* root_dir; /* Root directory for storing MMS files */
int retry_secs; /* Retry timeout in seconds */
int idle_secs; /* Idle timeout */
gboolean keep_temp_files; /* Keep temporary files around */
gboolean attic_enabled; /* Keep unrecognized push message in attic */
};
/* Persistent mutable per-SIM settings */
struct mms_settings_sim_data {
const char* user_agent; /* User agent string */
unsigned int size_limit; /* Maximum size of m-Send.req PDU */
unsigned int max_pixels; /* Pixel limit for outbound images */
gboolean allow_dr; /* Allow sending delivery reports */
};
/* Copy of per-SIM settings */
typedef struct mms_settings_sim_data_copy {
MMSSettingsSimData data; /* Settings data */
char* user_agent; /* Allocated copy of user_agent */
} MMSSettingsSimDataCopy;
/* Instance */
struct mms_settings {
GObject object;
const MMSConfig* config;
MMSSettingsSimDataCopy sim_defaults;
};
/* Class */
typedef struct mms_settings_class {
GObjectClass parent;
const MMSSettingsSimData* (*fn_get_sim_data)(
MMSSettings* settings,
const char* imsi);
} MMSSettingsClass;
/* Default values */
#define MMS_SETTINGS_DEFAULT_USER_AGENT "Mozilla/5.0 (Sailfish; Jolla)"
#define MMS_SETTINGS_DEFAULT_SIZE_LIMIT (300*1024)
#define MMS_SETTINGS_DEFAULT_MAX_PIXELS (3000000)
#define MMS_SETTINGS_DEFAULT_ALLOW_DR TRUE
GType mms_settings_get_type(void);
#define MMS_TYPE_SETTINGS (mms_settings_get_type())
#define MMS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
MMS_TYPE_SETTINGS, MMSSettingsClass))
MMSSettings*
mms_settings_ref(
MMSSettings* settings);
void
mms_settings_unref(
MMSSettings* settings);
MMSSettings*
mms_settings_default_new(
const MMSConfig* config);
const MMSSettingsSimData*
mms_settings_get_sim_data(
MMSSettings* settings,
const char* imsi);
void
mms_settings_sim_data_default(
MMSSettingsSimData* data);
void
mms_settings_set_sim_defaults(
MMSSettings* settings,
const MMSSettingsSimData* data);
MMSSettingsSimDataCopy*
mms_settings_sim_data_copy_new(
const MMSSettingsSimData* data);
void
mms_settings_sim_data_copy_free(
MMSSettingsSimDataCopy* data);
#endif /* JOLLA_MMS_SETTINGS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
......@@ -39,6 +39,7 @@ SOURCES += \
src/mms_message.c \
src/mms_lib_util.c \
src/mms_log.c \
src/mms_settings.c \
src/mms_task.c \
src/mms_task_ack.c \
src/mms_task_decode.c \
......@@ -71,4 +72,5 @@ HEADERS += \
include/mms_lib_types.h \
include/mms_lib_util.h \
include/mms_log.h \
include/mms_message.h
include/mms_message.h \
include/mms_settings.h
......@@ -14,6 +14,7 @@
#include "mms_attachment.h"
#include "mms_file_util.h"
#include "mms_settings.h"
#include "mms_codec.h"
#ifdef HAVE_MAGIC
......@@ -344,12 +345,13 @@ mms_attachment_reset(
gboolean
mms_attachment_resize(
MMSAttachment* at)
MMSAttachment* at,
const MMSSettingsSimData* settings)
{
if (at) {
MMSAttachmentClass* klass = MMS_ATTACHMENT_GET_CLASS(at);
if (klass->fn_resize) {
return klass->fn_resize(at);
return klass->fn_resize(at, settings);
}
}
return FALSE;
......
......@@ -37,8 +37,11 @@ struct _mms_attachment {
typedef struct mms_attachment_class {
GObjectClass parent;
void (*fn_reset)(MMSAttachment* attachment);
gboolean (*fn_resize)(MMSAttachment* attachment);
void (*fn_reset)(
MMSAttachment* attachment);
gboolean (*fn_resize)(
MMSAttachment* attachment,
const MMSSettingsSimData* settings);
} MMSAttachmentClass;
GType mms_attachment_get_type(void);
......@@ -80,7 +83,8 @@ mms_attachment_guess_content_type(
gboolean
mms_attachment_resize(
MMSAttachment* attachment);
MMSAttachment* attachment,
const MMSSettingsSimData* settings);
#endif /* JOLLA_MMS_ATTACHMENT_H */
......
......@@ -13,6 +13,7 @@
*/
#include "mms_attachment_image.h"
#include "mms_settings.h"
#include "mms_file_util.h"
#ifdef MMS_RESIZE_IMAGEMAGICK
......@@ -32,13 +33,16 @@ G_DEFINE_TYPE(MMSAttachmentImage, mms_attachment_image, MMS_TYPE_ATTACHMENT);
int
mms_attachment_image_next_resize_step(
MMSAttachmentImage* image,
const MMSSettingsSimData* settings,
unsigned int columns,
unsigned int rows)
{
int next_step = image->resize_step + 1;
if (image->attachment.config->max_pixels > 0) {
const unsigned int max_pixels = settings ? settings->max_pixels :
MMS_SETTINGS_DEFAULT_MAX_PIXELS;
if (max_pixels > 0) {
unsigned int size = (columns/(next_step+1))*(rows/(next_step+1));
while (size > 0 && size > image->attachment.config->max_pixels) {
while (size > 0 && size > max_pixels) {
next_step++;
size = (columns/(next_step+1))*(rows/(next_step+1));
}
......@@ -70,7 +74,8 @@ mms_attachment_image_prepare_filename(
static
gboolean
mms_attachment_image_resize_default(
MMSAttachmentImage* image)
MMSAttachmentImage* image,
const MMSSettingsSimData* settings)
{
gboolean ok = FALSE;
#ifdef MMS_RESIZE_IMAGEMAGICK
......@@ -88,7 +93,7 @@ mms_attachment_image_resize_default(
const unsigned int src_cols = src->magick_columns;
const unsigned int src_rows = src->magick_rows;
const int next_step = mms_attachment_image_next_resize_step(image,
src_cols, src_rows);
settings, src_cols, src_rows);
const unsigned int cols = src_cols/(next_step+1);
const unsigned int rows = src_rows/(next_step+1);
Image* dest;
......@@ -119,7 +124,7 @@ mms_attachment_image_resize_default(
DestroyImageInfo(info);
#else
# ifdef MMS_RESIZE_QT
ok = mms_attachment_image_resize_qt(image);
ok = mms_attachment_image_resize_qt(image, settings);
# endif /* MMS_RESIZE_QT */
#endif /* MMS_RESIZE_IMAGEMAGICK */
return ok;
......@@ -128,7 +133,8 @@ mms_attachment_image_resize_default(
static
gboolean
mms_attachment_image_resize_type_specific(
MMSAttachmentImage* image)
MMSAttachmentImage* image,
const MMSSettingsSimData* settings)
{
/* If klass->fn_resize_new is not NULL, then we assume that all
* other callbacks are present as well */
......@@ -141,7 +147,7 @@ mms_attachment_image_resize_type_specific(
gboolean can_resize;
const char* fname = mms_attachment_image_prepare_filename(image);
const int next_step = mms_attachment_image_next_resize_step(image,
resize->image.width, resize->image.height);
settings, resize->image.width, resize->image.height);
MMSAttachmentImageSize image_size;
MMSAttachmentImageSize out_size;
image_size = resize->image;
......@@ -248,7 +254,8 @@ mms_attachment_image_resize_type_specific(
static
gboolean
mms_attachment_image_resize(
MMSAttachment* at)
MMSAttachment* at,
const MMSSettingsSimData* settings)
{
MMSAttachmentImage* image = MMS_ATTACHMENT_IMAGE(at);
gboolean ok;
......@@ -256,8 +263,8 @@ mms_attachment_image_resize(
g_mapped_file_unref(at->map);
at->map = NULL;
}
ok = mms_attachment_image_resize_type_specific(image);
if (!ok) ok = mms_attachment_image_resize_default(image);
ok = mms_attachment_image_resize_type_specific(image, settings);
if (!ok) ok = mms_attachment_image_resize_default(image, settings);
if (ok) {
GError* error = NULL;
GMappedFile* map = g_mapped_file_new(image->resized, FALSE, &error);
......
......@@ -74,6 +74,7 @@ typedef struct mms_attachment_image_class {
int
mms_attachment_image_next_resize_step(
MMSAttachmentImage* image,
const MMSSettingsSimData* settings,
unsigned int columns,
unsigned int rows);
......@@ -84,7 +85,8 @@ mms_attachment_image_prepare_filename(
#ifdef MMS_RESIZE_QT
gboolean
mms_attachment_image_resize_qt(
MMSAttachmentImage* image);
MMSAttachmentImage* image,
const MMSSettingsSimData* settings);
#endif
#endif /* JOLLA_MMS_ATTACHMENT_IMAGE_H */
......
......@@ -24,14 +24,15 @@ extern "C" {
gboolean
mms_attachment_image_resize_qt(
MMSAttachmentImage* image)
MMSAttachmentImage* image,
const MMSSettingsSimData* s)
{
gboolean ok = FALSE;
QImage qimage;
if (qimage.load(image->attachment.original_file)) {
const int w = qimage.width();
const int h = qimage.height();
const int step = mms_attachment_image_next_resize_step(image, w, h);
const int step = mms_attachment_image_next_resize_step(image, s, w, h);
const char* fname = mms_attachment_image_prepare_filename(image);
const int w1 = w/(step+1);
QImage scaled = qimage.scaledToWidth(w1, Qt::SmoothTransformation);
......
......@@ -14,6 +14,7 @@
#include "mms_dispatcher.h"
#include "mms_handler.h"
#include "mms_settings.h"
#include "mms_connection.h"
#include "mms_connman.h"
#include "mms_file_util.h"
......@@ -31,7 +32,7 @@ MMS_LOG_MODULE_DEFINE("mms-dispatcher");
struct mms_dispatcher {
gint ref_count;
const MMSConfig* config;
MMSSettings* settings;
MMSTask* active_task;
MMSTaskDelegate task_delegate;
MMSHandler* handler;
......@@ -162,7 +163,7 @@ mms_dispatcher_network_idle_check(
/* Schedule idle inactivity timeout callback */
MMS_VERBOSE("Network connection is inactive");
disp->network_idle_id = mms_dispatcher_timeout_callback_schedule(disp,
disp->config->idle_secs, mms_dispatcher_network_idle_run);
disp->settings->config->idle_secs, mms_dispatcher_network_idle_run);
}
}
......@@ -387,15 +388,15 @@ gboolean
mms_dispatcher_start(
MMSDispatcher* disp)
{
int err = g_mkdir_with_parents(disp->config->root_dir, MMS_DIR_PERM);
const char* root_dir = disp->settings->config->root_dir;
int err = g_mkdir_with_parents(root_dir, MMS_DIR_PERM);
if (!err || errno == EEXIST) {
if (!g_queue_is_empty(disp->tasks)) {
mms_dispatcher_next_run_schedule(disp);
return TRUE;
}
} else {
MMS_ERR("Failed to create %s: %s", disp->config->root_dir,
strerror(errno));
MMS_ERR("Failed to create %s: %s", root_dir, strerror(errno));
}
return FALSE;
}
......@@ -436,7 +437,7 @@ mms_dispatcher_handle_push(
GError** error)
{
return mms_dispatcher_queue_and_unref_task(disp,
mms_task_notification_new(disp->config, disp->handler,
mms_task_notification_new(disp->settings, disp->handler,
imsi, push, error));
}
......@@ -458,7 +459,7 @@ mms_dispatcher_receive_message(
MMS_ASSERT(pdu->type == MMS_MESSAGE_TYPE_NOTIFICATION_IND);
if (pdu->type == MMS_MESSAGE_TYPE_NOTIFICATION_IND) {
ok = mms_dispatcher_queue_and_unref_task(disp,
mms_task_retrieve_new(disp->config, disp->handler,
mms_task_retrieve_new(disp->settings, disp->handler,
id, imsi, pdu, error));
}
mms_message_free(pdu);
......@@ -482,7 +483,7 @@ mms_dispatcher_send_read_report(
GError** error)
{
return mms_dispatcher_queue_and_unref_task(disp,
mms_task_read_new(disp->config, disp->handler,
mms_task_read_new(disp->settings, disp->handler,
id, imsi, message_id, to, status, error));
}
......@@ -510,7 +511,7 @@ mms_dispatcher_send_message(
}
if (imsi) {
if (mms_dispatcher_queue_and_unref_task(disp,
mms_task_encode_new(disp->config, disp->handler, id, imsi,
mms_task_encode_new(disp->settings, disp->handler, id, imsi,
to, cc, bcc, subject, flags, parts, nparts, error))) {
return default_imsi ? default_imsi : g_strdup(imsi);
}
......@@ -611,13 +612,13 @@ mms_dispatcher_delegate_task_state_changed(
*/
MMSDispatcher*
mms_dispatcher_new(
const MMSConfig* config,
MMSSettings* settings,
MMSConnMan* cm,
MMSHandler* handler)
{
MMSDispatcher* disp = g_new0(MMSDispatcher, 1);
disp->ref_count = 1;
disp->config = config;
disp->settings = mms_settings_ref(settings);
disp->tasks = g_queue_new();
disp->handler = mms_handler_ref(handler);
disp->cm = mms_connman_ref(cm);
......@@ -639,9 +640,8 @@ mms_dispatcher_finalize(
MMSDispatcher* disp)
{
MMSTask* task;
char* msg_dir = g_strconcat(disp->config->root_dir,
"/" MMS_MESSAGE_DIR "/", NULL);
const char* root_dir = disp->settings->config->root_dir;
char* msg_dir = g_strconcat(root_dir, "/" MMS_MESSAGE_DIR "/", NULL);
MMS_VERBOSE_("");
mms_dispatcher_close_connection(disp);
while ((task = g_queue_pop_head(disp->tasks)) != NULL) {
......@@ -650,6 +650,7 @@ mms_dispatcher_finalize(
mms_task_unref(task);
}
g_queue_free(disp->tasks);
mms_settings_unref(disp->settings);
mms_handler_unref(disp->handler);
mms_connman_unref(disp->cm);
......
......@@ -78,9 +78,9 @@ mms_file_copy(
#define mms_message_dir(config,id) \
(g_strconcat((config)->root_dir, "/" MMS_MESSAGE_DIR "/" , id, NULL))
#define mms_task_dir(task) \
mms_message_dir((task)->config,(task)->id)
mms_message_dir(task_config(task),(task)->id)
#define mms_task_file(task,file) \
(g_strconcat((task)->config->root_dir, "/" MMS_MESSAGE_DIR "/" , \
(g_strconcat(task_config(task)->root_dir, "/" MMS_MESSAGE_DIR "/" , \
(task)->id, "/", file, NULL))
#endif /* JOLLA_MMS_FILE_UTIL_H */
......
......@@ -23,11 +23,8 @@
#endif
#define MMS_DEFAULT_ROOT_DIR "/tmp/mms"
#define MMS_DEFAULT_USER_AGENT "Mozilla/5.0 (Sailfish; Jolla)"
#define MMS_DEFAULT_RETRY_SECS (15)