Skip to content

Commit

Permalink
[profiled] Use dbus-gmain instead of dbus-glib. JB#51115
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
  • Loading branch information
Thaodan committed Oct 5, 2020
1 parent 2629e32 commit b3ef808
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 25 deletions.
20 changes: 15 additions & 5 deletions .depend
Expand Up @@ -62,9 +62,6 @@ mainloop.o: mainloop.c \
server.h \
sighnd.h

profile-tracker.o: profile-tracker.c \
profile_dbus.h

profileclient.o: profileclient.c \
libprofile-internal.h \
libprofile.h \
Expand All @@ -77,6 +74,10 @@ profiled.o: profiled.c \
mainloop.h \
profiled_config.h

profile-tracker.o: profile-tracker.c \
profile_dbus.h \
dbus-gmain/dbus-gmain.h

profileval.o: profileval.c \
profiled_config.h \
profileval.h \
Expand All @@ -90,7 +91,8 @@ server.o: server.c \
profile_dbus.h \
profiled_config.h \
profileval.h \
server.h
server.h \
dbus-gmain/dbus-gmain.h

sighnd.o: sighnd.c \
logging.h \
Expand All @@ -109,7 +111,8 @@ tracker.o: tracker.c \
logging.h \
profile_dbus.h \
profiled_config.h \
profileval.h
profileval.h \
dbus-gmain/dbus-gmain.h

unique.o: unique.c \
profiled_config.h \
Expand All @@ -120,3 +123,10 @@ xutil.o: xutil.c \
profiled_config.h \
xutil.h

callbacks_without_mainloop.o: examples/callbacks_without_mainloop.c

delayed_session_bus.o: examples/delayed_session_bus.c \
examples/../dbus-gmain/dbus-gmain.h

multiple_callbacks.o: examples/multiple_callbacks.c

3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "dbus-gmain"]
path = dbus-gmain
url = https://github.com/sailfishos-mirror/dbus-glib
46 changes: 36 additions & 10 deletions Makefile
Expand Up @@ -33,6 +33,7 @@ CUD_DIR ?= /etc/osso-cud-scripts
RFS_DIR ?= /etc/osso-rfs-scripts

DOXYDIR := doxydir
DBUS_GMAIN_DIR := dbus-gmain

SO ?= .so.0

Expand Down Expand Up @@ -73,7 +74,7 @@ LDLIBS += -Wl,--as-needed

# flags from pkgtool

PKG_NAMES := dbus-glib-1 dbus-1 glib-2.0
PKG_NAMES := dbus-1 glib-2.0
PKG_CFLAGS := $(shell pkg-config --cflags $(PKG_NAMES))
PKG_LDLIBS := $(shell pkg-config --libs $(PKG_NAMES))

Expand Down Expand Up @@ -107,6 +108,23 @@ CPPFLAGS += -D LOGGING_CHECK1ST# level check before args eval
# Top Level Targets
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
# DBUS_GMAIN
# ----------------------------------------------------------------------------

# The dbus-gmain submodule contains sources that have
# issues and do not compile cleanly. As the content is
# what it is, silence warnings etc when compiling source
# files from there...

DBUS_GMAIN_CPPFLAGS += -I.
DBUS_GMAIN_CFLAGS += -Wno-unused-parameter
DBUS_GMAIN_CFLAGS += -Wno-cast-function-type
DBUS_GMAIN_CFLAGS += -Wno-missing-field-initializers

$(DBUS_GMAIN_DIR)/%.o : CPPFLAGS += $(DBUS_GMAIN_CPPFLAGS)
$(DBUS_GMAIN_DIR)/%.o : CFLAGS += $(DBUS_GMAIN_CFLAGS)

TARGETS += libprofile.a
TARGETS += libprofile$(SO)
TARGETS += profiled
Expand Down Expand Up @@ -259,8 +277,8 @@ profiled_src = \
xutil.c\
profileval.c

profiled_obj = $(profiled_src:.c=.o)

profiled_obj = $(profiled_src:.c=.o)
profiled_obj += $(DBUS_GMAIN_DIR)/dbus-gmain.o
profiled : $(profiled_obj)
profiled.cflow : $(profiled_src)

Expand All @@ -276,7 +294,8 @@ libprofile_src =\
profileval.c\
logging_client.c

libprofile_obj = $(libprofile_src:.c=.o)
libprofile_obj = $(libprofile_src:.c=.o)
libprofile_obj += $(DBUS_GMAIN_DIR)/dbus-gmain.o

libprofile$(SO) : $(libprofile_obj:.o=.pic.o)

Expand All @@ -286,9 +305,9 @@ libprofile.a : $(libprofile_obj)
# profileclient
# ----------------------------------------------------------------------------

profileclient_src = profileclient.c
profileclient_obj = $(profileclient_src:.c=.o)

profileclient_src = profileclient.c
profileclient_obj = $(profileclient_src:.c=.o)
profileclient_obj +=$(DBUS_GMAIN_DIR)/dbus-gmain.o
#profileclient : CFLAGS += -Wno-missing-prototypes
profileclient : $(profileclient_obj) libprofile$(SO)

Expand All @@ -304,14 +323,14 @@ profileclient.o: CFLAGS += -Wno-deprecated-declarations
profiletracker_src = profile-tracker.c logging.c
profiletracker_obj = $(profiletracker_src:.c=.o)

profile-tracker : $(profiletracker_obj) libprofile$(SO)
profile-tracker : $(profiletracker_obj) libprofile$(SO) $(DBUS_GMAIN_DIR)/dbus-gmain.o
profile-tracker.cflow : $(profiletracker_src) $(libprofile_src)

# ----------------------------------------------------------------------------
# camera-example1
# ----------------------------------------------------------------------------

camera-example1 : camera-example1.o libprofile$(SO)
camera-example1 : camera-example1.o libprofile$(SO) $(DBUS_GMAIN_DIR)/dbus-gmain.o

# ----------------------------------------------------------------------------
# profiled.deb
Expand Down Expand Up @@ -400,10 +419,13 @@ install-libprofile-doc:: $(addprefix install-libprofile-doc-, html man)
# Dependency Scanning
# ----------------------------------------------------------------------------

# All sources, except ones from gmain git submodule
DEPEND_SOURCES = $(filter-out $(DBUS_GMAIN_DIR)/%.c, $(wildcard *.c */*.c */*/*.c))

.PHONY: depend

depend::
gcc -MM $(CPPFLAGS) *.c | ./depend_filter.py > .depend
gcc -MM $(CPPFLAGS) $(DEPEND_SOURCES) | ./depend_filter.py > .depend

ifneq ($(MAKECMDGOALS),depend)
include .depend
Expand Down Expand Up @@ -452,3 +474,7 @@ normalize:
crlf -t -e -k debian/changelog
crlf -M examples/Makefile
crlf -a examples/*.[ch]

# Local Variables:
# indent-tabs-mode: t
# End:
1 change: 1 addition & 0 deletions dbus-gmain
Submodule dbus-gmain added at d42176
5 changes: 3 additions & 2 deletions examples/delayed_session_bus.c
Expand Up @@ -3,6 +3,7 @@
** This file is part of profile-qt
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2020 Jolla Ltd.
** All rights reserved.
**
** Contact: Sakari Poussa <sakari.poussa@nokia.com>
Expand Down Expand Up @@ -38,7 +39,7 @@
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "../dbus-gmain/dbus-gmain.h"
#include <profiled/libprofile.h>

static char *ex_busaddr = NULL;
Expand Down Expand Up @@ -69,7 +70,7 @@ ex_init(void)
goto cleanup;
}

dbus_connection_setup_with_g_main(ex_connection, NULL);
dbus_gmain_set_up_connection(ex_connection, NULL);
dbus_connection_set_exit_on_disconnect(ex_connection, 0);

res = 0;
Expand Down
5 changes: 3 additions & 2 deletions profile-tracker.c
Expand Up @@ -3,6 +3,7 @@
** This file is part of profile-qt
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2020 Jolla Ltd.
** All rights reserved.
**
** Contact: Sakari Poussa <sakari.poussa@nokia.com>
Expand Down Expand Up @@ -40,7 +41,7 @@
#include <string.h>
#include <stdlib.h>

#include <dbus/dbus-glib-lowlevel.h>
#include "dbus-gmain/dbus-gmain.h"

#include "profile_dbus.h"

Expand Down Expand Up @@ -134,7 +135,7 @@ tracker_init(void)
}
#endif

dbus_connection_setup_with_g_main(tracker_bus, NULL);
dbus_gmain_set_up_connection(tracker_bus, NULL);
dbus_connection_set_exit_on_disconnect(tracker_bus, 0);

/* - - - - - - - - - - - - - - - - - - - *
Expand Down
2 changes: 1 addition & 1 deletion profile.pc.tpl
Expand Up @@ -6,7 +6,7 @@ includedir=@INCDIR@
Name: profile
Description: profiled client library
Version: @VERS@
Requires: dbus-glib-1 dbus-1 glib-2.0
Requires: dbus-1 glib-2.0
Requires.private:
Cflags: -I@INCDIR@
Libs: -L@LIBDIR@ -lprofile
1 change: 0 additions & 1 deletion rpm/profiled.spec
Expand Up @@ -10,7 +10,6 @@ Requires: profiled-settings
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: doxygen

Expand Down
5 changes: 3 additions & 2 deletions server.c
Expand Up @@ -3,6 +3,7 @@
** This file is part of profile-qt
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2020 Jolla Ltd.
** All rights reserved.
**
** Contact: Sakari Poussa <sakari.poussa@nokia.com>
Expand Down Expand Up @@ -48,7 +49,7 @@
#include <string.h>
#include <stdlib.h>

#include <dbus/dbus-glib-lowlevel.h>
#include "dbus-gmain/dbus-gmain.h"

#ifndef DBUS_ERROR_INIT
# define DBUS_ERROR_INIT { NULL, NULL, TRUE, 0, 0, 0, 0, NULL }
Expand Down Expand Up @@ -972,7 +973,7 @@ server_init(void)
* attach connection to mainloop
* - - - - - - - - - - - - - - - - - - - */

dbus_connection_setup_with_g_main(server_bus, NULL);
dbus_gmain_set_up_connection(server_bus, NULL);
dbus_connection_set_exit_on_disconnect(server_bus, 0);

/* - - - - - - - - - - - - - - - - - - - *
Expand Down
5 changes: 3 additions & 2 deletions tracker.c
Expand Up @@ -3,6 +3,7 @@
** This file is part of profile-qt
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2020 Jolla Ltd.
** All rights reserved.
**
** Contact: Sakari Poussa <sakari.poussa@nokia.com>
Expand Down Expand Up @@ -40,7 +41,7 @@
#include <stdlib.h>
#include <stdbool.h>

#include <dbus/dbus-glib-lowlevel.h>
#include "dbus-gmain/dbus-gmain.h"

#include "codec.h"
#include "libprofile-internal.h"
Expand Down Expand Up @@ -437,7 +438,7 @@ profile_tracker_connect(void)
}

/* attach connection to glib mainloop */
dbus_connection_setup_with_g_main(profile_tracker_con, NULL);
dbus_gmain_set_up_connection(profile_tracker_con, NULL);

/* Register message filter */
if( !dbus_connection_add_filter(profile_tracker_con, profile_tracker_filter, 0, 0) )
Expand Down

0 comments on commit b3ef808

Please sign in to comment.