Skip to content
Permalink
Browse files
[mms-engine] Added transfer progress API. Contributes to JB#34534
  • Loading branch information
monich committed Mar 13, 2016
1 parent e63539b commit 99d617c3aea8f5fe39dd621c6747d60353e5a763
Show file tree
Hide file tree
Showing 49 changed files with 1,818 additions and 135 deletions.
@@ -4,6 +4,7 @@
.PHONY: mms_lib_debug_lib mms_lib_release_lib
.PHONY: mms_connman_debug_lib mms_connman_release_lib
.PHONY: mms_handler_debug_lib mms_handler_release_lib
.PHONY: mms_transfers_debug_lib mms_transfers_release_lib
.PHONY: mms_settings_debug_lib mms_settings_release_lib

#
@@ -84,6 +85,16 @@ MMS_HANDLER_BUILD_DIR = $(MMS_HANDLER_DIR)/build
MMS_HANDLER_DEBUG_LIB = $(MMS_HANDLER_BUILD_DIR)/debug/$(MMS_HANDLER_LIB)
MMS_HANDLER_RELEASE_LIB = $(MMS_HANDLER_BUILD_DIR)/release/$(MMS_HANDLER_LIB)

#
# mms-transfer-list-dbus
#

MMS_TRANSFERS_LIB = libmms-transfer-list-dbus.a
MMS_TRANSFERS_DIR = ../mms-transfer-list-dbus
MMS_TRANSFERS_BUILD_DIR = $(MMS_TRANSFERS_DIR)/build
MMS_TRANSFERS_DEBUG_LIB = $(MMS_TRANSFERS_BUILD_DIR)/debug/$(MMS_TRANSFERS_LIB)
MMS_TRANSFERS_RELEASE_LIB = $(MMS_TRANSFERS_BUILD_DIR)/release/$(MMS_TRANSFERS_LIB)

#
# mms-settings-dconf
#
@@ -108,8 +119,8 @@ WARN = -Wall
BASE_FLAGS = -fPIC $(CFLAGS)
FULL_CFLAGS = $(BASE_FLAGS) -I. -I$(GEN_DIR) -I$(MMS_LIB_DIR)/include \
-I$(MMS_CONNMAN_DIR)/include -I$(MMS_HANDLER_DIR)/include \
-I$(MMS_SETTINGS_DIR)/include -MMD -MP \
$(shell pkg-config --cflags $(PKGS))
-I$(MMS_SETTINGS_DIR)/include -I$(MMS_TRANSFERS_DIR)/include \
-MMD -MP $(shell pkg-config --cflags $(PKGS))

ifndef KEEP_SYMBOLS
KEEP_SYMBOLS = 0
@@ -137,12 +148,14 @@ LIBS = $(shell pkg-config --libs $(LIB_PKGS)) -lmagic -ljpeg $(RESIZE_LIBS)
DEBUG_LIBS = \
$(MMS_CONNMAN_DEBUG_LIB) \
$(MMS_HANDLER_DEBUG_LIB) \
$(MMS_TRANSFERS_DEBUG_LIB) \
$(MMS_SETTINGS_DEBUG_LIB) \
$(MMS_LIB_DEBUG_LIB) \
$(LIBS)
RELEASE_LIBS = \
$(MMS_CONNMAN_RELEASE_LIB) \
$(MMS_HANDLER_RELEASE_LIB) \
$(MMS_TRANSFERS_RELEASE_LIB) \
$(MMS_SETTINGS_RELEASE_LIB) \
$(MMS_LIB_RELEASE_LIB) \
$(LIBS)
@@ -168,21 +181,25 @@ DEBUG_DEPS = \
mms_lib_debug_lib \
mms_connman_debug_lib \
mms_handler_debug_lib \
mms_transfers_debug_lib \
mms_settings_debug_lib
RELEASE_DEPS = \
mms_lib_release_lib \
mms_connman_release_lib \
mms_handler_release_lib \
mms_transfers_release_lib \
mms_settings_release_lib
DEBUG_EXE_DEPS = \
$(MMS_LIB_DEBUG_LIB) \
$(MMS_CONNMAN_DEBUG_LIB) \
$(MMS_HANDLER_DEBUG_LIB) \
$(MMS_TRANSFERS_DEBUG_LIB) \
$(MMS_SETTINGS_DEBUG_LIB)
RELEASE_EXE_DEPS = \
$(MMS_LIB_RELEASE_LIB) \
$(MMS_CONNMAN_RELEASE_LIB) \
$(MMS_HANDLER_RELEASE_LIB) \
$(MMS_TRANSFERS_RELEASE_LIB) \
$(MMS_SETTINGS_RELEASE_LIB)
DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
ifneq ($(MAKECMDGOALS),clean)
@@ -214,6 +231,7 @@ cleaner: clean
make -C $(MMS_LIB_DIR) $(SUBMAKE_OPTS) clean
make -C $(MMS_CONNMAN_DIR) $(SUBMAKE_OPTS) clean
make -C $(MMS_HANDLER_DIR) $(SUBMAKE_OPTS) clean
make -C $(MMS_TRANSFERS_DIR) $(SUBMAKE_OPTS) clean
make -C $(MMS_SETTINGS_DIR) $(SUBMAKE_OPTS) clean

$(GEN_DIR):
@@ -243,6 +261,12 @@ mms_handler_debug_lib:
mms_handler_release_lib:
make -C $(MMS_HANDLER_DIR) $(SUBMAKE_OPTS) release

mms_transfers_debug_lib:
make -C $(MMS_TRANSFERS_DIR) $(SUBMAKE_OPTS) debug

mms_transfers_release_lib:
make -C $(MMS_TRANSFERS_DIR) $(SUBMAKE_OPTS) release

mms_settings_debug_lib:
make -C $(MMS_SETTINGS_DIR) $(SUBMAKE_OPTS) debug

@@ -261,6 +285,10 @@ $(MMS_HANDLER_DEBUG_LIB): mms_handler_debug_lib

$(MMS_HANDLER_RELEASE_LIB): mms_handler_release_lib

$(MMS_TRANSFERS_DEBUG_LIB): mms_transfers_debug_lib

$(MMS_TRANSFERS_RELEASE_LIB): mms_transfers_release_lib

$(MMS_SETTINGS_DEBUG_LIB): mms_settings_debug_lib

$(MMS_SETTINGS_RELEASE_LIB): mms_settings_release_lib
@@ -23,12 +23,14 @@ DBUS_INTERFACE_DIR = $$_PRO_FILE_PWD_
MMS_LIB_DIR = $$_PRO_FILE_PWD_/../mms-lib
MMS_HANDLER_DIR = $$_PRO_FILE_PWD_/../mms-handler-dbus
MMS_SETTINGS_DIR = $$_PRO_FILE_PWD_/../mms-settings-dconf
MMS_TRANSFER_LIST_DIR = $$_PRO_FILE_PWD_/../mms-transfer-list-dbus
MMS_CONNMAN_DIR = $$_PRO_FILE_PWD_/../$$MMS_CONNMAN

INCLUDEPATH += $$MMS_LIB_DIR/include
INCLUDEPATH += $$MMS_HANDLER_DIR/include
INCLUDEPATH += $$MMS_SETTINGS_DIR/include
INCLUDEPATH += $$MMS_CONNMAN_DIR/include
INCLUDEPATH += $$MMS_TRANSFER_LIST_DIR/include

SOURCES += \
main.c \
@@ -47,12 +49,14 @@ CONFIG(debug, debug|release) {
DESTDIR = $$_PRO_FILE_PWD_/build/debug
LIBS += $$MMS_CONNMAN_DIR/build/debug/lib$${MMS_CONNMAN}.a
LIBS += $$MMS_HANDLER_DIR/build/debug/libmms-handler-dbus.a
LIBS += $$MMS_TRANSFER_LIST_DIR/build/debug/libmms-transfer-list-dbus.a
LIBS += $$MMS_LIB_DIR/build/debug/libmms-lib.a
LIBS += $$MMS_SETTINGS_DIR/build/debug/libmms-settings-dconf.a
} else {
DESTDIR = $$_PRO_FILE_PWD_/build/release
LIBS += $$MMS_CONNMAN_DIR/build/release/lib$${MMS_CONNMAN}.a
LIBS += $$MMS_HANDLER_DIR/build/release/libmms-handler-dbus.a
LIBS += $$MMS_TRANSFER_LIST_DIR/build/release/libmms-transfer-list-dbus.a
LIBS += $$MMS_LIB_DIR/build/release/libmms-lib.a
LIBS += $$MMS_SETTINGS_DIR/build/release/libmms-settings-dconf.a
}
@@ -19,6 +19,7 @@
#include "mms_lib_util.h"
#include "mms_handler_dbus.h"
#include "mms_settings_dconf.h"
#include "mms_transfer_list_dbus.h"
#include "mms_log.h"

#include <gutil_misc.h>
@@ -472,6 +473,7 @@ mms_engine_new(
MMSEngine* mms = g_object_new(MMS_TYPE_ENGINE, NULL);
MMSHandler* handler = mms_handler_dbus_new();
MMSSettings* settings = mms_settings_dconf_new(config);
MMSTransferList* txlist = mms_transfer_list_dbus_new();

if (flags & MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT) {
settings->flags |= MMS_SETTINGS_FLAG_OVERRIDE_USER_AGENT;
@@ -494,8 +496,9 @@ mms_engine_new(
settings->sim_defaults.data.max_pixels = override->max_pixels;
}

mms->dispatcher = mms_dispatcher_new(settings, cm, handler);
mms->dispatcher = mms_dispatcher_new(settings, cm, handler, txlist);
mms_handler_unref(handler);
mms_transfer_list_unref(txlist);
mms_dispatcher_set_delegate(mms->dispatcher,
&mms->dispatcher_delegate);

@@ -49,6 +49,7 @@ SRC = \
mms_task_read.c \
mms_task_retrieve.c \
mms_task_send.c \
mms_transfer_list.c \
mms_util.c

ifeq ($(MMS_RESIZE),Qt)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013-2014 Jolla Ltd.
* Copyright (C) 2013-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* 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
@@ -30,7 +31,8 @@ MMSDispatcher*
mms_dispatcher_new(
MMSSettings* settings,
MMSConnMan* cm,
MMSHandler* handler);
MMSHandler* handler,
MMSTransferList* transfers);

MMSDispatcher*
mms_dispatcher_ref(
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2015 Jolla Ltd.
* Copyright (C) 2013-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
#define MMS_LIB_LOG_MODULES(log) \
log(mms_dispatcher_log)\
log(mms_settings_log)\
log(mms_transfer_list_log)\
log(mms_handler_log)\
log(mms_message_log)\
log(mms_attachment_log)\
@@ -60,6 +60,7 @@ typedef struct mms_handler MMSHandler;
typedef struct mms_connman MMSConnMan;
typedef struct mms_dispatcher MMSDispatcher;
typedef struct mms_connection MMSConnection;
typedef struct mms_transfer_list MMSTransferList;
typedef struct mms_message MMSPdu;
typedef struct _mms_message MMSMessage;
typedef struct _mms_attachment MMSAttachment;
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* 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_TRANSFER_LIST_H
#define JOLLA_MMS_TRANSFER_LIST_H

#include "mms_message.h"

/* Instance */
struct mms_transfer_list {
GObject object;
};

/* Class */
typedef struct mms_transfer_list_class {
GObjectClass parent;
void (*fn_transfer_started)(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type); /* Transfer type */
void (*fn_transfer_finished)(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type); /* Transfer type */
void (*fn_send_progress)(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type, /* Transfer type */
guint bytes_sent, /* Bytes sent so far */
guint bytes_total); /* Total bytes to send */
void (*fn_receive_progress)(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type, /* Transfer type */
guint bytes_received, /* Bytes received so far */
guint bytes_total); /* Total bytes to receive*/
} MMSTransferListClass;

GType mms_transfer_list_get_type(void);
#define MMS_TYPE_TRANSFER_LIST (mms_transfer_list_get_type())

MMSTransferList*
mms_transfer_list_ref(
MMSTransferList* list);

void
mms_transfer_list_unref(
MMSTransferList* list);

void
mms_transfer_list_transfer_started(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type); /* Transfer type */

void
mms_transfer_list_transfer_finished(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type); /* Transfer type */

void
mms_transfer_list_transfer_send_progress(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type, /* Transfer type */
guint bytes_sent, /* Bytes sent so far */
guint bytes_total); /* Total bytes to send */

void
mms_transfer_list_transfer_receive_progress(
MMSTransferList* list, /* Instance */
char* id, /* Message ID */
char* type, /* Transfer type */
guint bytes_received, /* Bytes received so far */
guint bytes_total); /* Total bytes to receive*/

#endif /* JOLLA_MMS_TRANSFER_LIST_H */

/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
@@ -50,6 +50,7 @@ SOURCES += \
src/mms_task_read.c \
src/mms_task_retrieve.c \
src/mms_task_send.c \
src/mms_transfer_list.c \
src/mms_util.c

HEADERS += \
@@ -72,4 +73,5 @@ HEADERS += \
include/mms_lib_util.h \
include/mms_log.h \
include/mms_message.h \
include/mms_settings.h
include/mms_settings.h \
include/mms_transfer_list.h

0 comments on commit 99d617c

Please sign in to comment.