Merge lp:~dobey/ubuntuone-client/slay-the-C-beast into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 1396
Merged at revision: 1396
Proposed branch: lp:~dobey/ubuntuone-client/slay-the-C-beast
Merge into: lp:ubuntuone-client
Diff against target: 8810 lines (+7/-8515)
48 files modified
Makefile.am (+1/-1)
autogen.sh (+1/-1)
configure.ac (+5/-52)
docs/Makefile.am (+0/-1)
docs/reference/Makefile.am (+0/-62)
docs/reference/libsyncdaemon-docs.sgml (+0/-48)
libsyncdaemon/Makefile.am (+0/-114)
libsyncdaemon/libsyncdaemon-1.0.pc.in (+0/-11)
libsyncdaemon/libsyncdaemon.h (+0/-50)
libsyncdaemon/syncdaemon-authentication.c (+0/-298)
libsyncdaemon/syncdaemon-authentication.h (+0/-75)
libsyncdaemon/syncdaemon-config-interface.c (+0/-276)
libsyncdaemon/syncdaemon-config-interface.h (+0/-83)
libsyncdaemon/syncdaemon-credentials.c (+0/-215)
libsyncdaemon/syncdaemon-credentials.h (+0/-75)
libsyncdaemon/syncdaemon-daemon.c (+0/-1477)
libsyncdaemon/syncdaemon-daemon.h (+0/-172)
libsyncdaemon/syncdaemon-events-interface.c (+0/-130)
libsyncdaemon/syncdaemon-events-interface.h (+0/-71)
libsyncdaemon/syncdaemon-file-info.c (+0/-236)
libsyncdaemon/syncdaemon-file-info.h (+0/-78)
libsyncdaemon/syncdaemon-filesystem-interface.c (+0/-190)
libsyncdaemon/syncdaemon-filesystem-interface.h (+0/-84)
libsyncdaemon/syncdaemon-folder-info.c (+0/-176)
libsyncdaemon/syncdaemon-folder-info.h (+0/-73)
libsyncdaemon/syncdaemon-folders-interface.c (+0/-494)
libsyncdaemon/syncdaemon-folders-interface.h (+0/-76)
libsyncdaemon/syncdaemon-interface.c (+0/-274)
libsyncdaemon/syncdaemon-interface.h (+0/-70)
libsyncdaemon/syncdaemon-marshal.list (+0/-5)
libsyncdaemon/syncdaemon-metadata.c (+0/-284)
libsyncdaemon/syncdaemon-metadata.h (+0/-79)
libsyncdaemon/syncdaemon-publicfiles-interface.c (+0/-259)
libsyncdaemon/syncdaemon-publicfiles-interface.h (+0/-73)
libsyncdaemon/syncdaemon-share-info.c (+0/-357)
libsyncdaemon/syncdaemon-share-info.h (+0/-91)
libsyncdaemon/syncdaemon-shares-interface.c (+0/-497)
libsyncdaemon/syncdaemon-shares-interface.h (+0/-79)
libsyncdaemon/syncdaemon-status-info.c (+0/-259)
libsyncdaemon/syncdaemon-status-info.h (+0/-80)
libsyncdaemon/syncdaemon-status-interface.c (+0/-448)
libsyncdaemon/syncdaemon-status-interface.h (+0/-71)
libsyncdaemon/syncdaemon-transfer-info.c (+0/-247)
libsyncdaemon/syncdaemon-transfer-info.h (+0/-78)
libsyncdaemon/test-libsyncdaemon.c (+0/-536)
libsyncdaemon/utils.c (+0/-60)
libsyncdaemon/utils.h (+0/-48)
po/POTFILES.in (+0/-1)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/slay-the-C-beast
Reviewer Review Type Date Requested Status
Brian Curtin (community) Approve
Mike McCracken (community) Approve
Review via email: mp+167631@code.launchpad.net

Commit message

Drop libsyncdaemon from the tree.

Description of the change

This branch removes libsyncdaemon and the necessary related parts from the tree and build. It doesn't move away from autotools yet, as that is a very large change, and would be best done in a branch after this.

To post a comment you must log in.
Revision history for this message
Mike McCracken (mikemc) :
review: Approve
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Looks good.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (3.3 KiB)

The attempt to merge lp:~dobey/ubuntuone-client/slay-the-C-beast into lp:ubuntuone-client failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.69
checking for automake >= 1.10...
  testing automake-1.12... not found.
  testing automake-1.11... found 1.11.6
checking for intltool >= 0.30...
  testing intltoolize... found 0.50.2
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.26
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running intltoolize...
Running aclocal-1.11...
Running autoconf...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... yes
checking whether NLS is requested... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... none
checking for intltool >= 0.40.0... 0.50.2 found
checking for intltool-update... /usr/bin/intltool-update
checking for intltool-merge... /usr/bin/intltool-merge
checking for intltool-extract... /usr/bin/intltool-extract
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for perl... /usr/bin/perl
checking for perl >= 5.8.1... 5.14.2
checking for XML::Parser... ok
checking for lndir... /usr/bin/lndir
checking development series build... no
checking for a Python interpreter with version >= 2.6... python
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.7/dist-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/dist-packages
checking for ubuntu-sso-client... using system path
checking for ubuntuone-storage-protocol... using system path
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for DBUS... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating data/Makefile
config.status: creating po/Makefile.in
config.status: creating docs/Makefile
config.status: executing depfiles commands
config.status: executing po/stamp-it commands
Now type `make' to compile ubuntuone-client

configure.ac:8: installing `./install-sh'
configure.ac:8: installing `./missing'
conf...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2013-05-29 13:45:19 +0000
+++ Makefile.am 2013-06-05 20:11:30 +0000
@@ -1,4 +1,4 @@
1SUBDIRS = data libsyncdaemon po docs1SUBDIRS = data po docs
22
3# Shut libtoolize up3# Shut libtoolize up
4ACLOCAL_AMFLAGS = -I m44ACLOCAL_AMFLAGS = -I m4
55
=== modified file 'autogen.sh'
--- autogen.sh 2012-01-03 12:52:20 +0000
+++ autogen.sh 2013-06-05 20:11:30 +0000
@@ -17,5 +17,5 @@
17 echo "You need to install gnome-common from the GNOME source repository"17 echo "You need to install gnome-common from the GNOME source repository"
18 exit 118 exit 1
19}19}
2020mkdir -p "$srcdir/m4"
21USE_GNOME2_MACROS=1 . gnome-autogen.sh21USE_GNOME2_MACROS=1 . gnome-autogen.sh
2222
=== modified file 'configure.ac'
--- configure.ac 2013-02-21 20:59:11 +0000
+++ configure.ac 2013-06-05 20:11:30 +0000
@@ -3,17 +3,16 @@
33
4# We need to omit the trailing newline when catting the VERSION file4# We need to omit the trailing newline when catting the VERSION file
5AC_INIT([ubuntuone-client], m4_esyscmd([cat VERSION | tr -d '\012']))5AC_INIT([ubuntuone-client], m4_esyscmd([cat VERSION | tr -d '\012']))
6AC_CONFIG_SRCDIR([config.h.in])6AC_CONFIG_SRCDIR([VERSION])
77
8AM_INIT_AUTOMAKE([1.10 foreign tar-ustar])8AM_INIT_AUTOMAKE([1.10 foreign tar-ustar])
9AM_CONFIG_HEADER([config.h])
109
11m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
1211
13AC_ISC_POSIX12# Workaround to make aclocal get the right flags
14AC_PROG_CC13AC_CONFIG_MACRO_DIR([m4])
15AC_PROG_LIBTOOL14AC_SUBST(ACLOCAL_AMFLAGS, "\${ACLOCAL_FLAGS} -I m4")
16PKG_PROG_PKG_CONFIG([0.19])15
17IT_PROG_INTLTOOL([0.40.0])16IT_PROG_INTLTOOL([0.40.0])
1817
19GETTEXT_PACKAGE="${PACKAGE}"18GETTEXT_PACKAGE="${PACKAGE}"
@@ -23,10 +22,6 @@
23localedir='$(prefix)/$(DATADIRNAME)/locale'22localedir='$(prefix)/$(DATADIRNAME)/locale'
24AC_SUBST(localedir)23AC_SUBST(localedir)
2524
26# Workaround to make aclocal get the right flags
27AC_CONFIG_MACRO_DIR([m4])
28AC_SUBST(ACLOCAL_AMFLAGS, "\${ACLOCAL_FLAGS} -I m4")
29
30# Need lndir for builddir != srcdir builds, because Python is not sane25# Need lndir for builddir != srcdir builds, because Python is not sane
31AC_PATH_PROG([LNDIR], [lndir], [])26AC_PATH_PROG([LNDIR], [lndir], [])
32if test "x$LNDIR" = "x"; then27if test "x$LNDIR" = "x"; then
@@ -102,45 +97,6 @@
102AC_SUBST(DBUS_CFLAGS)97AC_SUBST(DBUS_CFLAGS)
103AC_SUBST(DBUS_LIBS)98AC_SUBST(DBUS_LIBS)
10499
105##################################################
106# Check for gtk-doc.
107##################################################
108GTK_DOC_CHECK(1.0)
109DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc --enable-debug"
110AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
111
112##################################################
113# Check for introspection
114##################################################
115GOBJECT_INTROSPECTION_CHECK([0.6.4])
116AC_MSG_CHECKING([if gobject-introspection requires new options])
117$PKG_CONFIG --atleast-version=0.9.4 gobject-introspection-1.0
118new_introspection=$?
119if test "x$new_introspection" = "x0"; then
120 AC_MSG_RESULT([yes])
121else
122 AC_MSG_RESULT([no])
123fi
124AM_CONDITIONAL([HAVE_NEW_INTROSPECTION], [test "x$new_introspection" = "x0"])
125
126# Fix up some junk from GIR
127if test "x$found_introspection" = "xyes"; then
128 INTROSPECTION_GIRDIR_NAME="`basename ${INTROSPECTION_GIRDIR}`"
129 INTROSPECTION_TYPELIBDIR_NAME="`basename ${INTROSPECTION_TYPELIBDIR}`"
130 AC_SUBST(INTROSPECTION_GIRDIR_NAME)
131 AC_SUBST(INTROSPECTION_TYPELIBDIR_NAME)
132fi
133
134dnl glib-genmarshal
135AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
136
137LIBSYNCDAEMON_CURRENT=1
138LIBSYNCDAEMON_REVISION=0
139LIBSYNCDAEMON_AGE=0
140AC_SUBST(LIBSYNCDAEMON_CURRENT)
141AC_SUBST(LIBSYNCDAEMON_REVISION)
142AC_SUBST(LIBSYNCDAEMON_AGE)
143
144dnl ---------------------------------------------------------------------------100dnl ---------------------------------------------------------------------------
145dnl - Are we specifying a different dbus root ?101dnl - Are we specifying a different dbus root ?
146dnl ---------------------------------------------------------------------------102dnl ---------------------------------------------------------------------------
@@ -169,11 +125,8 @@
169AC_CONFIG_FILES([125AC_CONFIG_FILES([
170Makefile126Makefile
171data/Makefile127data/Makefile
172libsyncdaemon/Makefile
173libsyncdaemon/libsyncdaemon-1.0.pc
174po/Makefile.in128po/Makefile.in
175docs/Makefile129docs/Makefile
176docs/reference/Makefile
177])130])
178131
179if [[ -n "$(lsb_release -r | grep -v '1[2-9].[0-9][0-9]')" ]]; then 132if [[ -n "$(lsb_release -r | grep -v '1[2-9].[0-9][0-9]')" ]]; then
180133
=== modified file 'docs/Makefile.am'
--- docs/Makefile.am 2012-03-13 16:53:57 +0000
+++ docs/Makefile.am 2013-06-05 20:11:30 +0000
@@ -1,4 +1,3 @@
1SUBDIRS = reference
21
3manfilesdir = $(mandir)/man12manfilesdir = $(mandir)/man1
4manfiles_DATA = \3manfiles_DATA = \
54
=== removed directory 'docs/reference'
=== removed file 'docs/reference/Makefile.am'
--- docs/reference/Makefile.am 2010-10-19 15:38:45 +0000
+++ docs/reference/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
1## Process this file with automake to produce Makefile.in
2
3# Dummy targets we need to make distcheck and check pass
4test test-report perf-report full-report:
5 ## Ignore
6
7# automake requirements
8AUTOMAKE_OPTIONS = 1.7
9
10# The name of the module
11DOC_MODULE=libsyncdaemon
12
13# The top-level SGML file. You can change this if you want to.
14DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
15
16# The directory containing the source code. Relative to $(srcdir).
17DOC_SOURCE_DIR=../../libsyncdaemon
18
19# Extra options to pass to gtkdoc-scangobj. Not normally needed.
20SCANGOBJ_OPTIONS=
21
22# Extra options to supply to gtkdoc-scan.
23# Fx --rebuild-types --rebuild-sections
24SCAN_OPTIONS=
25
26# Extra options to supply to gtkdoc-mkdb.
27MKDB_OPTIONS=--sgml-mode --output-format=xml --ignore-files=trio
28
29# Extra options to supply to gtkdoc-fixref. Not normally needed.
30FIXXREF_OPTIONS=
31
32# Used for dependencies. The docs will be rebuilt if any of these change.
33HFILE_GLOB=$(top_srcdir)/libsyncdaemon/syncdaemon-*.h
34CFILE_GLOB=$(top_srcdir)/libsyncdaemon/syncdaemon-*.c
35
36# Header files to ignore when scanning.
37IGNORE_HFILES= \
38 utils.h
39
40# Images to copy into HTML directory.
41HTML_IMAGES=
42
43# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
44content_files =
45
46# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
47INCLUDES=-I$(top_srcdir)/libsyncdaemon \
48 $(DBUS_CFLAGS)
49
50GTKDOC_LIBS=$(DBUS_LIBS) \
51 $(top_builddir)/libsyncdaemon/libsyncdaemon-1.0.la
52
53# This includes the standard gtk-doc make rules, copied by gtkdocize.
54include $(top_srcdir)/gtk-doc.make
55
56# Other files to distribute
57# e.g. EXTRA_DIST += version.xml.in
58EXTRA_DIST += \
59 libsyncdaemon.types \
60 libsyncdaemon-docs.sgml
61# libsyncdaemon-sections.txt
62
630
=== removed file 'docs/reference/libsyncdaemon-docs.sgml'
--- docs/reference/libsyncdaemon-docs.sgml 2010-10-19 13:28:23 +0000
+++ docs/reference/libsyncdaemon-docs.sgml 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1<?xml version="1.0"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4[
5 <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
6]>
7<book id="index">
8 <bookinfo>
9 <title>libsyncdaemon Reference Manual</title>
10 <releaseinfo>
11 for libsyncdaemon [VERSION].
12 The latest version of this documentation can be found on-line at
13 <ulink role="online-location" url="http://[SERVER]/libsyncdaemon/index.html">http://[SERVER]/libsyncdaemon/</ulink>.
14 </releaseinfo>
15 </bookinfo>
16
17 <chapter>
18 <title>[Insert title here]</title>
19 <xi:include href="xml/syncdaemon-metadata.xml"/>
20 <xi:include href="xml/syncdaemon-events-interface.xml"/>
21 <xi:include href="xml/syncdaemon-file-info.xml"/>
22 <xi:include href="xml/syncdaemon-transfer-info.xml"/>
23 <xi:include href="xml/syncdaemon-share-info.xml"/>
24 <xi:include href="xml/syncdaemon-filesystem-interface.xml"/>
25 <xi:include href="xml/syncdaemon-status-interface.xml"/>
26 <xi:include href="xml/syncdaemon-config-interface.xml"/>
27 <xi:include href="xml/syncdaemon-publicfiles-interface.xml"/>
28 <xi:include href="xml/syncdaemon-authentication.xml"/>
29 <xi:include href="xml/syncdaemon-shares-interface.xml"/>
30 <xi:include href="xml/syncdaemon-credentials.xml"/>
31 <xi:include href="xml/syncdaemon-folders-interface.xml"/>
32 <xi:include href="xml/syncdaemon-daemon.xml"/>
33 <xi:include href="xml/syncdaemon-interface.xml"/>
34 <xi:include href="xml/syncdaemon-folder-info.xml"/>
35 <xi:include href="xml/syncdaemon-status-info.xml"/>
36
37 </chapter>
38 <chapter id="object-tree">
39 <title>Object Hierarchy</title>
40 <xi:include href="xml/tree_index.sgml"/>
41 </chapter>
42 <index id="api-index-full">
43 <title>API Index</title>
44 <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
45 </index>
46
47 <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
48</book>
490
=== removed directory 'libsyncdaemon'
=== removed file 'libsyncdaemon/Makefile.am'
--- libsyncdaemon/Makefile.am 2012-09-17 19:18:24 +0000
+++ libsyncdaemon/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
1CLEANFILES = $(NULL)
2
3lib_LTLIBRARIES = libsyncdaemon-1.0.la
4
5noinst_PROGRAMS = test-libsyncdaemon
6
7INCLUDES = \
8 -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
9 -I$(top_srcdir) \
10 $(DBUS_CFLAGS)
11
12# Marshallers
13MARSHAL_GENERATED = syncdaemon-marshal.c syncdaemon-marshal.h
14
15syncdaemon-marshal.h: syncdaemon-marshal.list $(GLIB_GENMARSHAL)
16 $(GLIB_GENMARSHAL) $< --header --prefix=_syncdaemon_marshal > $@
17
18syncdaemon-marshal.c: syncdaemon-marshal.list $(GLIB_GENMARSHAL) syncdaemon-marshal.h
19 $(GLIB_GENMARSHAL) $< --body --prefix=_syncdaemon_marshal > $@
20
21syncdaemonincludedir = $(includedir)/libsyncdaemon-1.0/libsyncdaemon
22syncdaemoninclude_HEADERS = \
23 libsyncdaemon.h \
24 syncdaemon-authentication.h \
25 syncdaemon-daemon.h \
26 syncdaemon-config-interface.h \
27 syncdaemon-credentials.h \
28 syncdaemon-events-interface.h \
29 syncdaemon-file-info.h \
30 syncdaemon-filesystem-interface.h \
31 syncdaemon-folder-info.h \
32 syncdaemon-folders-interface.h \
33 syncdaemon-metadata.h \
34 syncdaemon-publicfiles-interface.h \
35 syncdaemon-share-info.h \
36 syncdaemon-shares-interface.h \
37 syncdaemon-status-info.h \
38 syncdaemon-status-interface.h \
39 syncdaemon-transfer-info.h \
40 syncdaemon-interface.h
41
42libsyncdaemon_1_0_la_SOURCES = \
43 syncdaemon-marshal.c \
44 syncdaemon-authentication.c \
45 syncdaemon-daemon.c \
46 syncdaemon-config-interface.c \
47 syncdaemon-credentials.c \
48 syncdaemon-events-interface.c \
49 syncdaemon-file-info.c \
50 syncdaemon-filesystem-interface.c \
51 syncdaemon-folder-info.c \
52 syncdaemon-folders-interface.c \
53 syncdaemon-metadata.c \
54 syncdaemon-publicfiles-interface.c \
55 syncdaemon-share-info.c \
56 syncdaemon-shares-interface.c \
57 syncdaemon-status-info.c \
58 syncdaemon-status-interface.c \
59 syncdaemon-transfer-info.c \
60 syncdaemon-interface.c \
61 utils.c
62
63libsyncdaemon_1_0_la_LIBADD = \
64 $(DBUS_LIBS)
65libsyncdaemon_1_0_la_LDFLAGS = -version-info $(LIBSYNCDAEMON_CURRENT):$(LIBSYNCDAEMON_REVISION):$(LIBSYNCDAEMON_AGE)
66
67test_libsyncdaemon_SOURCES = test-libsyncdaemon.c
68test_libsyncdaemon_LDADD = libsyncdaemon-1.0.la $(DBUS_LIBS)
69
70pkgconfigdir = $(libdir)/pkgconfig
71pkgconfig_DATA = libsyncdaemon-1.0.pc
72
73MAINTAINERCLEANFILES = \
74 Makefile.in \
75 $(MARSHAL_GENERATED)
76
77EXTRA_DIST = \
78 syncdaemon-marshal.list \
79 utils.h \
80 $(MARSHAL_GENERATED)
81
82-include $(INTROSPECTION_MAKEFILE)
83INTROSPECTION_GIRS =
84INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
85INTROSPECTION_SCANNER_ARGS = \
86 --add-include-path=$(srcdir) \
87 --c-include="libsyncdaemon/libsyncdaemon.h"
88
89if HAVE_NEW_INTROSPECTION
90INTROSPECTION_SCANNER_ARGS += --identifier-prefix=Syncdaemon --warn-all
91endif
92
93if HAVE_INTROSPECTION
94introspection_files = \
95 $(syncdaemoninclude_HEADERS) \
96 $(shell ls syncdaemon*.[ch])
97Syncdaemon-1.0.gir: libsyncdaemon-1.0.la Makefile
98Syncdaemon_1_0_gir_NAMESPACE = Syncdaemon
99Syncdaemon_1_0_gir_INCLUDES = GObject-2.0
100Syncdaemon_1_0_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir)
101Syncdaemon_1_0_gir_LIBS = libsyncdaemon-1.0.la
102Syncdaemon_1_0_gir_FILES = $(addprefix $(srcdir)/, $(introspection_files))
103Syncdaemon_1_0_gir_EXPORT_PACKAGES = libsyncdaemon-1.0
104INTROSPECTION_GIRS += Syncdaemon-1.0.gir
105
106girdir = $(datadir)/$(INTROSPECTION_GIRDIR_NAME)
107gir_DATA = $(INTROSPECTION_GIRS)
108
109typelibsdir = $(libdir)/$(INTROSPECTION_TYPELIBDIR_NAME)
110typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
111
112CLEANFILES += $(gir_DATA) $(typelibs_DATA)
113
114endif # HAVE_INTROSPECTION
1150
=== removed file 'libsyncdaemon/libsyncdaemon-1.0.pc.in'
--- libsyncdaemon/libsyncdaemon-1.0.pc.in 2010-06-24 12:14:39 +0000
+++ libsyncdaemon/libsyncdaemon-1.0.pc.in 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1prefix=@prefix@
2exec_prefix=${prefix}
3libdir=${exec_prefix}/lib
4includedir=${exec_prefix}/include
5
6Name: libsyncdaemon
7Description: Ubuntu One SyncDaemon access library
8Version: @VERSION@
9Libs: -L${libdir} -lsyncdaemon-1.0
10Cflags: -I${includedir}/libsyncdaemon-1.0
11Requires: gobject-2.0
120
=== removed file 'libsyncdaemon/libsyncdaemon.h'
--- libsyncdaemon/libsyncdaemon.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/libsyncdaemon.h 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include <libsyncdaemon/syncdaemon-authentication.h>
36#include <libsyncdaemon/syncdaemon-config-interface.h>
37#include <libsyncdaemon/syncdaemon-credentials.h>
38#include <libsyncdaemon/syncdaemon-daemon.h>
39#include <libsyncdaemon/syncdaemon-events-interface.h>
40#include <libsyncdaemon/syncdaemon-file-info.h>
41#include <libsyncdaemon/syncdaemon-filesystem-interface.h>
42#include <libsyncdaemon/syncdaemon-folder-info.h>
43#include <libsyncdaemon/syncdaemon-folders-interface.h>
44#include <libsyncdaemon/syncdaemon-interface.h>
45#include <libsyncdaemon/syncdaemon-publicfiles-interface.h>
46#include <libsyncdaemon/syncdaemon-share-info.h>
47#include <libsyncdaemon/syncdaemon-shares-interface.h>
48#include <libsyncdaemon/syncdaemon-status-info.h>
49#include <libsyncdaemon/syncdaemon-status-interface.h>
50#include <libsyncdaemon/syncdaemon-transfer-info.h>
510
=== removed file 'libsyncdaemon/syncdaemon-authentication.c'
--- libsyncdaemon/syncdaemon-authentication.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-authentication.c 1970-01-01 00:00:00 +0000
@@ -1,298 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#include <string.h>
37#include <glib/gi18n-lib.h>
38#include <dbus/dbus-glib.h>
39#include "syncdaemon-authentication.h"
40#include "syncdaemon-marshal.h"
41
42G_DEFINE_TYPE(SyncdaemonAuthentication, syncdaemon_authentication, G_TYPE_OBJECT)
43
44struct _SyncdaemonAuthenticationPrivate {
45 DBusGConnection *bus;
46 DBusGProxy *proxy;
47 gboolean has_credentials;
48 SyncdaemonCredentials *credentials;
49};
50
51/* Signals */
52enum {
53 CREDENTIALS_FOUND_SIGNAL,
54 AUTHORIZATION_CANCELLED_SIGNAL,
55 ERROR_SIGNAL,
56 LAST_SIGNAL
57};
58
59static guint auth_signals[LAST_SIGNAL] = { 0, };
60
61static void
62syncdaemon_authentication_finalize (GObject *object)
63{
64 SyncdaemonAuthentication *auth = SYNCDAEMON_AUTHENTICATION (object);
65
66 if (auth->priv != NULL) {
67 if (auth->priv->credentials != NULL)
68 g_object_unref (G_OBJECT (auth->priv->credentials));
69 if (auth->priv->proxy != NULL)
70 g_object_unref (G_OBJECT (auth->priv->proxy));
71 if (auth->priv->bus != NULL)
72 dbus_g_connection_unref (auth->priv->bus);
73
74 g_free (auth->priv);
75 }
76
77 G_OBJECT_CLASS (syncdaemon_authentication_parent_class)->finalize (object);
78}
79
80static void
81syncdaemon_authentication_class_init (SyncdaemonAuthenticationClass *klass)
82{
83 GObjectClass *object_class = G_OBJECT_CLASS (klass);
84
85 object_class->finalize = syncdaemon_authentication_finalize;
86
87 /* Register signals */
88 auth_signals[CREDENTIALS_FOUND_SIGNAL] = g_signal_new ("credentials_found",
89 G_TYPE_FROM_CLASS (klass),
90 (GSignalFlags) G_SIGNAL_RUN_LAST,
91 G_STRUCT_OFFSET (SyncdaemonAuthenticationClass, credentials_found),
92 NULL, NULL,
93 g_cclosure_marshal_VOID__OBJECT,
94 G_TYPE_NONE, 1,
95 G_TYPE_OBJECT);
96 auth_signals[AUTHORIZATION_CANCELLED_SIGNAL] = g_signal_new ("authorization_cancelled",
97 G_TYPE_FROM_CLASS (klass),
98 (GSignalFlags) G_SIGNAL_RUN_LAST,
99 G_STRUCT_OFFSET (SyncdaemonAuthenticationClass, authorization_cancelled),
100 NULL, NULL,
101 g_cclosure_marshal_VOID__VOID,
102 G_TYPE_NONE, 0);
103 auth_signals[ERROR_SIGNAL] = g_signal_new ("error",
104 G_TYPE_FROM_CLASS (klass),
105 (GSignalFlags) G_SIGNAL_RUN_LAST,
106 G_STRUCT_OFFSET (SyncdaemonAuthenticationClass, error),
107 NULL, NULL,
108 g_cclosure_marshal_VOID__STRING,
109 G_TYPE_NONE, 1,
110 G_TYPE_STRING);
111}
112
113static void
114credentials_found_cb (DBusGProxy *proxy, GHashTable *result, gpointer user_data)
115{
116 SyncdaemonAuthentication *auth = SYNCDAEMON_AUTHENTICATION (user_data);
117
118 g_debug ("Authorization completed!");
119
120 if (auth->priv->credentials != NULL)
121 g_object_unref (G_OBJECT (auth->priv->credentials));
122
123 auth->priv->credentials = syncdaemon_credentials_new_from_hash_table (result);
124 auth->priv->has_credentials = TRUE;
125
126 g_signal_emit (auth, auth_signals[CREDENTIALS_FOUND_SIGNAL], 0, auth->priv->credentials);
127}
128
129static void
130authorization_denied_cb (DBusGProxy *proxy, gpointer user_data)
131{
132 g_debug ("Authorization denied");
133
134 g_signal_emit (user_data, auth_signals[AUTHORIZATION_CANCELLED_SIGNAL], 0);
135}
136
137static void
138credentials_error_cb (DBusGProxy *proxy, GHashTable *error_dict, gpointer user_data)
139{
140 g_debug ("Authorization error");
141
142 g_signal_emit (user_data, auth_signals[ERROR_SIGNAL], 0,
143 g_hash_table_lookup (error_dict, "message"));
144}
145
146static void
147credentials_not_found_cb (DBusGProxy *proxy, gpointer user_data)
148{
149 SyncdaemonAuthentication *auth = SYNCDAEMON_AUTHENTICATION (user_data);
150
151 g_debug ("Credentials for Ubuntu One not found!");
152
153 if (auth->priv->credentials != NULL)
154 g_object_unref (G_OBJECT (auth->priv->credentials));
155 auth->priv->has_credentials = FALSE;
156
157 g_signal_emit (auth, auth_signals[ERROR_SIGNAL], 0,
158 "Credentials not found.");
159}
160
161static void
162syncdaemon_authentication_init (SyncdaemonAuthentication *auth)
163{
164 GError *error = NULL;
165
166 auth->priv = g_new0 (SyncdaemonAuthenticationPrivate, 1);
167 auth->priv->has_credentials = FALSE;
168
169 /* Initialize DBus */
170 auth->priv->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
171 if (error != NULL) {
172 g_warning ("Couldn't get session bus: %s", error->message);
173 g_error_free (error);
174 } else {
175 auth->priv->proxy = dbus_g_proxy_new_for_name (auth->priv->bus, "com.ubuntuone.Credentials",
176 "/credentials", "com.ubuntuone.CredentialsManagement");
177 if (auth->priv->proxy != NULL) {
178 dbus_g_proxy_add_signal (auth->priv->proxy, "CredentialsFound",
179 dbus_g_type_get_map ("GHashTable",
180 G_TYPE_STRING,
181 G_TYPE_STRING),
182 G_TYPE_INVALID);
183 dbus_g_proxy_connect_signal (auth->priv->proxy, "CredentialsFound",
184 G_CALLBACK (credentials_found_cb), auth, NULL);
185
186 dbus_g_proxy_add_signal (auth->priv->proxy, "CredentialsNotFound",
187 G_TYPE_INVALID);
188 dbus_g_proxy_connect_signal (auth->priv->proxy, "CredentialsNotFound",
189 G_CALLBACK (credentials_not_found_cb), auth, NULL);
190
191 dbus_g_proxy_add_signal (auth->priv->proxy, "AuthorizationDenied",
192 G_TYPE_INVALID);
193 dbus_g_proxy_connect_signal (auth->priv->proxy, "AuthorizationDenied",
194 G_CALLBACK (authorization_denied_cb), auth, NULL);
195
196 dbus_g_proxy_add_signal (auth->priv->proxy, "CredentialsError",
197 dbus_g_type_get_map ("GHashTable",
198 G_TYPE_STRING,
199 G_TYPE_STRING),
200 G_TYPE_INVALID);
201 dbus_g_proxy_connect_signal (auth->priv->proxy, "CredentialsError",
202 G_CALLBACK (credentials_error_cb), auth, NULL);
203 } else
204 g_warning ("Couldn't get proxy for com.ubuntuone.CredentialsManagement");
205
206 }
207}
208
209/**
210 * syncdaemon_authentication_find_credentials:
211 */
212SyncdaemonCredentials *
213syncdaemon_authentication_find_credentials (SyncdaemonAuthentication *auth)
214{
215 SyncdaemonCredentials *result = NULL;
216 g_return_val_if_fail (SYNCDAEMON_IS_AUTHENTICATION (auth), NULL);
217
218 if (!auth->priv->has_credentials) {
219 GHashTable *credentials;
220 GError *error = NULL;
221
222 if (dbus_g_proxy_call (auth->priv->proxy, "find_credentials_sync", &error,
223 G_TYPE_INVALID,
224 dbus_g_type_get_map ("GHashTable",
225 G_TYPE_STRING,
226 G_TYPE_STRING), &credentials,
227 G_TYPE_INVALID)) {
228 if (g_hash_table_size (credentials) >= 4) {
229 auth->priv->credentials = syncdaemon_credentials_new_from_hash_table (credentials);
230 auth->priv->has_credentials = TRUE;
231 result = auth->priv->credentials;
232 } else {
233 g_debug ("Got less number of items (%i) in credentials hash table than expected (4)!",
234 g_hash_table_size (credentials));
235 }
236 g_hash_table_destroy (credentials);
237 } else {
238 g_warning ("Could not get credentials: %s", error->message);
239 g_error_free (error);
240 }
241 }
242
243 return result;
244}
245
246/**
247 * syncdaemon_authentication_has_credentials:
248 */
249gboolean
250syncdaemon_authentication_has_credentials (SyncdaemonAuthentication *auth)
251{
252 g_return_val_if_fail (SYNCDAEMON_IS_AUTHENTICATION (auth), FALSE);
253
254 if (auth->priv->has_credentials)
255 return TRUE;
256
257 return syncdaemon_authentication_find_credentials (auth) != NULL;
258}
259
260/**
261 * syncdaemon_authentication_login_or_register:
262 */
263void
264syncdaemon_authentication_login_or_register (SyncdaemonAuthentication *auth)
265{
266 GHashTable *params = g_hash_table_new (g_str_hash, g_str_equal);
267
268 g_return_if_fail (SYNCDAEMON_IS_AUTHENTICATION (auth));
269
270 g_hash_table_insert (params, "window_id", "0"); /* FIXME: get window ID */
271
272 dbus_g_proxy_call_no_reply (auth->priv->proxy, "register",
273 dbus_g_type_get_map ("GHashTable",
274 G_TYPE_STRING,
275 G_TYPE_STRING), params,
276 G_TYPE_INVALID,
277 G_TYPE_INVALID);
278
279 g_hash_table_destroy (params);
280}
281
282/**
283 * syncdaemon_authentication_clear_token:
284 */
285void
286syncdaemon_authentication_clear_token (SyncdaemonAuthentication *auth)
287{
288 GError *error = NULL;
289
290 g_return_if_fail (SYNCDAEMON_IS_AUTHENTICATION (auth));
291
292 if (!dbus_g_proxy_call (auth->priv->proxy, "clear_credentials", &error,
293 G_TYPE_INVALID,
294 G_TYPE_INVALID)) {
295 g_warning ("Error calling 'clear_credentials': %s", error->message);
296 g_error_free (error);
297 }
298}
2990
=== removed file 'libsyncdaemon/syncdaemon-authentication.h'
--- libsyncdaemon/syncdaemon-authentication.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-authentication.h 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_AUTHENTICATION_H__
36#define __SYNCDAEMON_AUTHENTICATION_H__
37
38#include <glib-object.h>
39#include "syncdaemon-credentials.h"
40
41G_BEGIN_DECLS
42
43#define SYNCDAEMON_TYPE_AUTHENTICATION (syncdaemon_authentication_get_type ())
44#define SYNCDAEMON_AUTHENTICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_AUTHENTICATION, SyncdaemonAuthentication))
45#define SYNCDAEMON_IS_AUTHENTICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_AUTHENTICATION))
46#define SYNCDAEMON_AUTHENTICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_AUTHENTICATION, SyncdaemonAuthenticationClass))
47#define SYNCDAEMON_IS_AUTHENTICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_AUTHENTICATION))
48#define SYNCDAEMON_AUTHENTICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_AUTHENTICATION, SyncdaemonAuthenticationClass))
49
50typedef struct _SyncdaemonAuthenticationPrivate SyncdaemonAuthenticationPrivate;
51
52typedef struct {
53 GObject parent;
54 SyncdaemonAuthenticationPrivate *priv;
55} SyncdaemonAuthentication;
56
57typedef struct {
58 GObjectClass parent_class;
59
60 void (* credentials_found) (SyncdaemonAuthentication *auth, SyncdaemonCredentials *credentials);
61 void (* authorization_cancelled) (SyncdaemonAuthentication *auth);
62 void (* error) (SyncdaemonAuthentication *auth, const gchar *error);
63} SyncdaemonAuthenticationClass;
64
65GType syncdaemon_authentication_get_type (void);
66SyncdaemonAuthentication *syncdaemon_authentication_new (void);
67
68SyncdaemonCredentials *syncdaemon_authentication_find_credentials (SyncdaemonAuthentication *auth);
69gboolean syncdaemon_authentication_has_credentials (SyncdaemonAuthentication *auth);
70void syncdaemon_authentication_login_or_register (SyncdaemonAuthentication *auth);
71void syncdaemon_authentication_clear_token (SyncdaemonAuthentication *auth);
72
73G_END_DECLS
74
75#endif
760
=== removed file 'libsyncdaemon/syncdaemon-config-interface.c'
--- libsyncdaemon/syncdaemon-config-interface.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-config-interface.c 1970-01-01 00:00:00 +0000
@@ -1,276 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#ifdef HAVE_GDBUS
37#else
38#include <dbus/dbus-glib.h>
39#endif
40#include "syncdaemon-config-interface.h"
41
42G_DEFINE_TYPE(SyncdaemonConfigInterface, syncdaemon_config_interface, SYNCDAEMON_TYPE_INTERFACE)
43
44struct _SyncdaemonConfigInterfacePrivate {
45 GObject *proxy;
46};
47
48static void
49syncdaemon_config_interface_finalize (GObject *object)
50{
51 SyncdaemonConfigInterface *interface = SYNCDAEMON_CONFIG_INTERFACE (object);
52
53 if (interface->priv != NULL) {
54 g_free (interface->priv);
55 }
56
57 G_OBJECT_CLASS (syncdaemon_config_interface_parent_class)->finalize (object);
58}
59
60static void
61syncdaemon_config_interface_class_init (SyncdaemonConfigInterfaceClass *klass)
62{
63 GObjectClass *object_class = G_OBJECT_CLASS (klass);
64
65 object_class->finalize = syncdaemon_config_interface_finalize;
66}
67
68static void
69syncdaemon_config_interface_init (SyncdaemonConfigInterface *interface)
70{
71 interface->priv = g_new0 (SyncdaemonConfigInterfacePrivate, 1);
72
73 /* Setup DBus proxy */
74 interface->priv->proxy = syncdaemon_interface_setup_proxy (SYNCDAEMON_INTERFACE (interface),
75 "com.ubuntuone.SyncDaemon",
76 "/config", "com.ubuntuone.SyncDaemon.Config");
77}
78
79/**
80 * syncdaemon_config_interface_new:
81 */
82SyncdaemonConfigInterface *
83syncdaemon_config_interface_new (SyncdaemonDaemon *daemon)
84{
85 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
86
87 return g_object_new (SYNCDAEMON_TYPE_CONFIG_INTERFACE, "daemon", daemon, NULL);
88}
89
90static gboolean
91get_boolean_method (SyncdaemonConfigInterface *interface, const gchar *method)
92{
93 gboolean enabled;
94 GError *error = NULL;
95
96 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), method, &error,
97 G_TYPE_INVALID,
98 G_TYPE_BOOLEAN, &enabled,
99 G_TYPE_INVALID)) {
100 g_warning ("Failed calling %s: %s", method, error->message);
101 g_error_free (error);
102
103 return FALSE;
104 }
105
106 return enabled;
107}
108
109static void
110enable_setting_method (SyncdaemonConfigInterface *interface,
111 const gchar *enable_method,
112 const gchar *disable_method,
113 gboolean enabled)
114{
115 GError *error = NULL;
116
117 if (enabled) {
118 dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), enable_method, &error,
119 G_TYPE_INVALID,
120 G_TYPE_INVALID);
121 } else {
122 dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), disable_method, &error,
123 G_TYPE_INVALID,
124 G_TYPE_INVALID);
125 }
126
127 if (error) {
128 g_warning ("Failed calling %s: %s", enabled ? enable_method : disable_method, error->message);
129 g_error_free (error);
130 }
131}
132
133/**
134 * syncdaemon_config_interface_get_bandwidth_throttling:
135 */
136gboolean
137syncdaemon_config_interface_get_bandwidth_throttling (SyncdaemonConfigInterface *interface)
138{
139 g_return_val_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface), FALSE);
140
141 return get_boolean_method (interface, "bandwidth_throttling_enabled");
142}
143
144/**
145 * syncdaemon_config_interface_set_bandwidth_throttling:
146 */
147void
148syncdaemon_config_interface_set_bandwidth_throttling (SyncdaemonConfigInterface *interface, gboolean enabled)
149{
150 g_return_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface));
151
152 enable_setting_method (interface, "enable_bandwidth_throttling", "disable_bandwidth_throttling", enabled);
153}
154
155/**
156 * syncdaemon_config_interface_get_files_sync:
157 */
158gboolean
159syncdaemon_config_interface_get_files_sync (SyncdaemonConfigInterface *interface)
160{
161 gboolean enabled;
162 GError *error = NULL;
163
164 g_return_val_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface), FALSE);
165
166 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "files_sync_enabled", &error,
167 G_TYPE_INVALID,
168 G_TYPE_BOOLEAN, &enabled,
169 G_TYPE_INVALID)) {
170 g_warning ("Failed calling files_sync_enabled: %s", error->message);
171 g_error_free (error);
172
173 return FALSE;
174 }
175
176 return enabled;
177}
178
179/**
180 * syncdaemon_config_interface_set_files_sync:
181 */
182void
183syncdaemon_config_interface_set_files_sync (SyncdaemonConfigInterface *interface, gboolean enabled)
184{
185 GError *error = NULL;
186
187 g_return_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface));
188
189 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "set_files_sync_enabled", &error,
190 G_TYPE_BOOLEAN, enabled,
191 G_TYPE_INVALID,
192 G_TYPE_INVALID)) {
193 g_warning ("Failed calling set_files_sync_enabled: %s", error->message);
194 g_error_free (error);
195 }
196}
197
198/**
199 * syncdaemon_config_interface_get_throttling_limits:
200 */
201void
202syncdaemon_config_interface_get_throttling_limits (SyncdaemonConfigInterface *interface,
203 gint *download,
204 gint *upload)
205{
206 GHashTable *result;
207 GError *error = NULL;
208
209 g_return_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface));
210
211 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "get_throttling_limits", &error,
212 G_TYPE_INVALID,
213 dbus_g_type_get_map ("GHashTable",
214 G_TYPE_STRING,
215 G_TYPE_INT), &result,
216 G_TYPE_INVALID)) {
217 g_warning ("Failed calling get_throttling_limits: %s", error->message);
218 g_error_free (error);
219 } else {
220 gint *download_got, *upload_got;
221
222 download_got = g_hash_table_lookup (result, "download");
223 upload_got = g_hash_table_lookup (result, "upload");
224
225 if (download != NULL)
226 *download = *download_got;
227 if (upload != NULL)
228 *upload = *upload_got;
229
230 g_hash_table_destroy (result);
231 }
232}
233
234/**
235 * syncdaemon_config_interface_set_throttling_limits:
236 */
237void
238syncdaemon_config_interface_set_throttling_limits (SyncdaemonConfigInterface *interface,
239 gint download,
240 gint upload)
241{
242 GError *error = NULL;
243
244 g_return_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface));
245
246 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "set_throttling_limits", &error,
247 G_TYPE_INT, download,
248 G_TYPE_INT, upload,
249 G_TYPE_INVALID,
250 G_TYPE_INVALID)) {
251 g_warning ("Failed calling set_throttling_limits: %s", error->message);
252 g_error_free (error);
253 }
254}
255
256/**
257 * syncdaemon_config_interface_get_udf_autosubscribe:
258 */
259gboolean
260syncdaemon_config_interface_get_udf_autosubscribe (SyncdaemonConfigInterface *interface)
261{
262 g_return_val_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface), FALSE);
263
264 return get_boolean_method (interface, "udf_autosubscribe_enabled");
265}
266
267/**
268 * syncdaemon_config_interface_set_bandwidth_throttling_enabled:
269 */
270void
271syncdaemon_config_interface_set_udf_autosubscribe (SyncdaemonConfigInterface *interface, gboolean enabled)
272{
273 g_return_if_fail (SYNCDAEMON_IS_CONFIG_INTERFACE (interface));
274
275 enable_setting_method (interface, "enable_udf_autosubscribe", "disable_udf_autosubscribe", enabled);
276}
2770
=== removed file 'libsyncdaemon/syncdaemon-config-interface.h'
--- libsyncdaemon/syncdaemon-config-interface.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-config-interface.h 1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_CONFIG_INTERFACE_H__
36#define __SYNCDAEMON_CONFIG_INTERFACE_H__
37
38#include "syncdaemon-daemon.h"
39#include "syncdaemon-interface.h"
40
41G_BEGIN_DECLS
42
43#define SYNCDAEMON_TYPE_CONFIG_INTERFACE (syncdaemon_config_interface_get_type ())
44#define SYNCDAEMON_CONFIG_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_CONFIG_INTERFACE, SyncdaemonConfigInterface))
45#define SYNCDAEMON_IS_CONFIG_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_CONFIG_INTERFACE))
46#define SYNCDAEMON_CONFIG_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_CONFIG_INTERFACE, SyncdaemonConfigInterfaceClass))
47#define SYNCDAEMON_IS_CONFIG_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_CONFIG_INTERFACE))
48#define SYNCDAEMON_CONFIG_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_CONFIG_INTERFACE, SyncdaemonConfigInterfaceClass))
49
50typedef struct _SyncdaemonConfigInterfacePrivate SyncdaemonConfigInterfacePrivate;
51
52typedef struct {
53 SyncdaemonInterface parent;
54 SyncdaemonConfigInterfacePrivate *priv;
55} SyncdaemonConfigInterface;
56
57typedef struct {
58 SyncdaemonInterfaceClass parent_class;
59} SyncdaemonConfigInterfaceClass;
60
61GType syncdaemon_config_interface_get_type (void);
62
63SyncdaemonConfigInterface *syncdaemon_config_interface_new (SyncdaemonDaemon *daemon);
64
65gboolean syncdaemon_config_interface_get_bandwidth_throttling (SyncdaemonConfigInterface *interface);
66void syncdaemon_config_interface_set_bandwidth_throttling (SyncdaemonConfigInterface *interface,
67 gboolean enabled);
68gboolean syncdaemon_config_interface_get_files_sync (SyncdaemonConfigInterface *interface);
69void syncdaemon_config_interface_set_files_sync (SyncdaemonConfigInterface *interface,
70 gboolean enabled);
71void syncdaemon_config_interface_get_throttling_limits (SyncdaemonConfigInterface *interface,
72 gint *download,
73 gint *upload);
74void syncdaemon_config_interface_set_throttling_limits (SyncdaemonConfigInterface *interface,
75 gint download,
76 gint upload);
77gboolean syncdaemon_config_interface_get_udf_autosubscribe (SyncdaemonConfigInterface *interface);
78void syncdaemon_config_interface_set_udf_autosubscribe (SyncdaemonConfigInterface *interface,
79 gboolean enabled);
80
81G_END_DECLS
82
83#endif
840
=== removed file 'libsyncdaemon/syncdaemon-credentials.c'
--- libsyncdaemon/syncdaemon-credentials.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-credentials.c 1970-01-01 00:00:00 +0000
@@ -1,215 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "syncdaemon-credentials.h"
36
37G_DEFINE_TYPE(SyncdaemonCredentials, syncdaemon_credentials, G_TYPE_OBJECT)
38
39struct _SyncdaemonCredentialsPrivate {
40 gchar *consumer_key;
41 gchar *consumer_secret;
42 gchar *token;
43 gchar *token_secret;
44};
45
46static void
47syncdaemon_credentials_finalize (GObject *object)
48{
49 SyncdaemonCredentials *credentials = SYNCDAEMON_CREDENTIALS (object);
50
51 if (credentials->priv != NULL) {
52 if (credentials->priv->consumer_key != NULL)
53 g_free (credentials->priv->consumer_key);
54 if (credentials->priv->consumer_secret != NULL)
55 g_free (credentials->priv->consumer_secret);
56 if (credentials->priv->token != NULL)
57 g_free (credentials->priv->token);
58 if (credentials->priv->token_secret != NULL)
59 g_free (credentials->priv->token_secret);
60
61 g_free (credentials->priv);
62 }
63
64 G_OBJECT_CLASS (syncdaemon_credentials_parent_class)->finalize (object);
65}
66
67static void
68syncdaemon_credentials_class_init (SyncdaemonCredentialsClass *klass)
69{
70 GObjectClass *object_class = G_OBJECT_CLASS (klass);
71
72 object_class->finalize = syncdaemon_credentials_finalize;
73}
74
75static void
76syncdaemon_credentials_init (SyncdaemonCredentials *credentials)
77{
78 credentials->priv = g_new0 (SyncdaemonCredentialsPrivate, 1);
79}
80
81/**
82 * syncdaemon_credentials_new:
83 */
84SyncdaemonCredentials *
85syncdaemon_credentials_new (void)
86{
87 return g_object_new (SYNCDAEMON_TYPE_CREDENTIALS, NULL);
88}
89
90/**
91 * syncdaemon_credentials_new_from_hash_table:
92 */
93SyncdaemonCredentials *
94syncdaemon_credentials_new_from_hash_table (GHashTable *hash)
95{
96 SyncdaemonCredentials *credentials;
97
98 credentials = g_object_new (SYNCDAEMON_TYPE_CREDENTIALS, NULL);
99 if (hash != NULL) {
100 syncdaemon_credentials_set_consumer_key (
101 credentials,
102 g_hash_table_lookup (hash, "consumer_key"));
103 syncdaemon_credentials_set_consumer_secret (
104 credentials,
105 g_hash_table_lookup (hash, "consumer_secret"));
106 syncdaemon_credentials_set_token (
107 credentials,
108 g_hash_table_lookup (hash, "token"));
109 syncdaemon_credentials_set_token_secret (
110 credentials,
111 g_hash_table_lookup (hash, "token_secret"));
112 }
113
114 return credentials;
115}
116
117/**
118 * syncdaemon_credentials_get_oauth_consumer_token:
119 */
120const gchar *
121syncdaemon_credentials_get_consumer_key (SyncdaemonCredentials *credentials)
122{
123 g_return_val_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials), NULL);
124
125 return (const gchar *) credentials->priv->consumer_key;
126}
127
128/**
129 * syncdaemon_credentials_set_consumer_key:
130 */
131void
132syncdaemon_credentials_set_consumer_key (SyncdaemonCredentials *credentials, const gchar *consumer_key)
133{
134 g_return_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials));
135
136 if (credentials->priv->consumer_key != NULL)
137 g_free (credentials->priv->consumer_key);
138
139 credentials->priv->consumer_key = g_strdup (consumer_key);
140}
141
142/**
143 * syncdaemon_credentials_get_consumer_secret:
144 */
145const gchar *
146syncdaemon_credentials_get_consumer_secret (SyncdaemonCredentials *credentials)
147{
148 g_return_val_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials), NULL);
149
150 return (const gchar *) credentials->priv->consumer_secret;
151}
152
153/**
154 * syncdaemon_credentials_set_consumer_secret:
155 */
156void
157syncdaemon_credentials_set_consumer_secret (SyncdaemonCredentials *credentials, const gchar *consumer_secret)
158{
159 g_return_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials));
160
161 if (credentials->priv->consumer_secret != NULL)
162 g_free (credentials->priv->consumer_secret);
163
164 credentials->priv->consumer_secret = g_strdup (consumer_secret);
165}
166
167/**
168 * syncdaemon_credentials_get_token:
169 */
170const gchar *
171syncdaemon_credentials_get_token (SyncdaemonCredentials *credentials)
172{
173 g_return_val_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials), NULL);
174
175 return (const gchar *) credentials->priv->token;
176}
177
178/**
179 * syncdaemon_credentials_set_token:
180 */
181void
182syncdaemon_credentials_set_token (SyncdaemonCredentials *credentials, const gchar *token)
183{
184 g_return_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials));
185
186 if (credentials->priv->token != NULL)
187 g_free (credentials->priv->token);
188
189 credentials->priv->token = g_strdup (token);
190}
191
192/**
193 * syncdaemon_credentials_get_token_secret:
194 */
195const gchar *
196syncdaemon_credentials_get_token_secret (SyncdaemonCredentials *credentials)
197{
198 g_return_val_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials), NULL);
199
200 return (const gchar *) credentials->priv->token_secret;
201}
202
203/**
204 * syncdaemon_credentials_set_token_secret:
205 */
206void
207syncdaemon_credentials_set_token_secret (SyncdaemonCredentials *credentials, const gchar *token_secret)
208{
209 g_return_if_fail (SYNCDAEMON_IS_CREDENTIALS (credentials));
210
211 if (credentials->priv->token_secret != NULL)
212 g_free (credentials->priv->token_secret);
213
214 credentials->priv->token_secret = g_strdup (token_secret);
215}
2160
=== removed file 'libsyncdaemon/syncdaemon-credentials.h'
--- libsyncdaemon/syncdaemon-credentials.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-credentials.h 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_CREDENTIALS_H__
36#define __SYNCDAEMON_CREDENTIALS_H__
37
38#include <glib-object.h>
39
40G_BEGIN_DECLS
41
42#define SYNCDAEMON_TYPE_CREDENTIALS (syncdaemon_credentials_get_type ())
43#define SYNCDAEMON_CREDENTIALS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_CREDENTIALS, SyncdaemonCredentials))
44#define SYNCDAEMON_IS_CREDENTIALS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_CREDENTIALS))
45#define SYNCDAEMON_CREDENTIALS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_CREDENTIALS, SyncdaemonCredentialsClass))
46#define SYNCDAEMON_IS_CREDENTIALS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_CREDENTIALS))
47#define SYNCDAEMON_CREDENTIALS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_CREDENTIALS, SyncdaemonCredentialsClass))
48
49typedef struct _SyncdaemonCredentialsPrivate SyncdaemonCredentialsPrivate;
50
51typedef struct {
52 GObject parent;
53 SyncdaemonCredentialsPrivate *priv;
54} SyncdaemonCredentials;
55
56typedef struct {
57 GObjectClass parent_class;
58} SyncdaemonCredentialsClass;
59
60GType syncdaemon_credentials_get_type (void);
61SyncdaemonCredentials *syncdaemon_credentials_new (void);
62SyncdaemonCredentials *syncdaemon_credentials_new_from_hash_table (GHashTable *hash);
63
64const gchar *syncdaemon_credentials_get_consumer_key (SyncdaemonCredentials *credentials);
65void syncdaemon_credentials_set_consumer_key (SyncdaemonCredentials *credentials, const gchar *consumer_key);
66const gchar *syncdaemon_credentials_get_consumer_secret (SyncdaemonCredentials *credentials);
67void syncdaemon_credentials_set_consumer_secret (SyncdaemonCredentials *credentials, const gchar *consumer_secret);
68const gchar *syncdaemon_credentials_get_token (SyncdaemonCredentials *credentials);
69void syncdaemon_credentials_set_token (SyncdaemonCredentials *credentials, const gchar *token);
70const gchar *syncdaemon_credentials_get_token_secret (SyncdaemonCredentials *credentials);
71void syncdaemon_credentials_set_token_secret (SyncdaemonCredentials *credentials, const gchar *token_secret);
72
73G_END_DECLS
74
75#endif
760
=== removed file 'libsyncdaemon/syncdaemon-daemon.c'
--- libsyncdaemon/syncdaemon-daemon.c 2012-04-13 23:36:32 +0000
+++ libsyncdaemon/syncdaemon-daemon.c 1970-01-01 00:00:00 +0000
@@ -1,1477 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#include <string.h>
37#ifdef HAVE_GDBUS
38#include <gio/gio.h>
39#else
40#include <dbus/dbus-glib.h>
41#include <dbus/dbus-glib-bindings.h>
42#endif
43#include "syncdaemon-daemon.h"
44#include "syncdaemon-config-interface.h"
45#include "syncdaemon-events-interface.h"
46#include "syncdaemon-filesystem-interface.h"
47#include "syncdaemon-folders-interface.h"
48#include "syncdaemon-publicfiles-interface.h"
49#include "syncdaemon-shares-interface.h"
50#include "syncdaemon-status-interface.h"
51#include "syncdaemon-marshal.h"
52
53#define SYNCDAEMON_DBUS_NAME "com.ubuntuone.SyncDaemon"
54
55G_DEFINE_TYPE(SyncdaemonDaemon, syncdaemon_daemon, G_TYPE_OBJECT)
56
57struct _SyncdaemonDaemonPrivate {
58#ifdef HAVE_GDBUS
59 GDBusConnection *bus;
60 GDbusProxy *dbus_proxy;
61#else
62 DBusGConnection *bus;
63 DBusGProxy *dbus_proxy;
64#endif
65
66 /* Interfaces */
67 GObject *daemon_interface;
68 GHashTable *subinterfaces;
69
70 /* Status */
71 gboolean ready;
72 gboolean connected;
73 gchar *root_dir;
74 SyncdaemonAuthentication *auth;
75};
76
77/* Signals */
78enum {
79 READY_SIGNAL,
80 CONNECTED_SIGNAL,
81 DISCONNECTED_SIGNAL,
82 STATUS_CHANGED_SIGNAL,
83 ERROR_SIGNAL,
84 EVENT_SIGNAL,
85 FOLDER_CREATED_SIGNAL,
86 FOLDER_DELETED_SIGNAL,
87 FOLDER_SUBSCRIBED_SIGNAL,
88 FOLDER_UNSUBSCRIBED_SIGNAL,
89 FILE_PUBLISHED_SIGNAL,
90 FILE_UNPUBLISHED_SIGNAL,
91 SHARE_CREATED_SIGNAL,
92 SHARE_DELETED_SIGNAL,
93 DOWNLOAD_STARTED_SIGNAL,
94 DOWNLOAD_FILE_PROGRESS_SIGNAL,
95 DOWNLOAD_FINISHED_SIGNAL,
96 UPLOAD_STARTED_SIGNAL,
97 UPLOAD_FILE_PROGRESS_SIGNAL,
98 UPLOAD_FINISHED_SIGNAL,
99 QUOTA_EXCEEDED_SIGNAL,
100 LAST_SIGNAL
101};
102
103static guint daemon_signals[LAST_SIGNAL] = { 0, };
104
105static void
106syncdaemon_daemon_finalize (GObject *object)
107{
108 SyncdaemonDaemon *daemon = SYNCDAEMON_DAEMON (object);
109
110 if (daemon->priv != NULL) {
111 g_hash_table_destroy (daemon->priv->subinterfaces);
112
113 if (daemon->priv->dbus_proxy != NULL)
114 g_object_unref (daemon->priv->dbus_proxy);
115
116 if (daemon->priv->bus != NULL) {
117#ifdef HAVE_GDBUS
118 g_object_unref (G_OBJECT (daemon->priv->bus));
119#else
120 dbus_g_connection_unref (daemon->priv->bus);
121#endif
122 }
123
124 if (daemon->priv->root_dir != NULL)
125 g_free (daemon->priv->root_dir);
126
127 if (daemon->priv->auth != NULL)
128 g_object_unref (G_OBJECT (daemon->priv->auth));
129
130 g_free (daemon->priv);
131 }
132
133 G_OBJECT_CLASS (syncdaemon_daemon_parent_class)->finalize (object);
134}
135
136static void
137syncdaemon_daemon_class_init (SyncdaemonDaemonClass *klass)
138{
139 GObjectClass *object_class = G_OBJECT_CLASS (klass);
140
141 object_class->finalize = syncdaemon_daemon_finalize;
142
143 /* Register signals */
144 daemon_signals[READY_SIGNAL] = g_signal_new ("ready",
145 G_TYPE_FROM_CLASS (klass),
146 (GSignalFlags) G_SIGNAL_RUN_LAST,
147 G_STRUCT_OFFSET (SyncdaemonDaemonClass, ready),
148 NULL, NULL,
149 g_cclosure_marshal_VOID__VOID,
150 G_TYPE_NONE, 0);
151 daemon_signals[CONNECTED_SIGNAL] = g_signal_new ("connected",
152 G_TYPE_FROM_CLASS (klass),
153 (GSignalFlags) G_SIGNAL_RUN_LAST,
154 G_STRUCT_OFFSET (SyncdaemonDaemonClass, connected),
155 NULL, NULL,
156 g_cclosure_marshal_VOID__VOID,
157 G_TYPE_NONE, 0);
158 daemon_signals[DISCONNECTED_SIGNAL] = g_signal_new ("disconnected",
159 G_TYPE_FROM_CLASS (klass),
160 (GSignalFlags) G_SIGNAL_RUN_LAST,
161 G_STRUCT_OFFSET (SyncdaemonDaemonClass, disconnected),
162 NULL, NULL,
163 g_cclosure_marshal_VOID__VOID,
164 G_TYPE_NONE, 0);
165 daemon_signals[STATUS_CHANGED_SIGNAL] = g_signal_new ("status_changed",
166 G_TYPE_FROM_CLASS (klass),
167 (GSignalFlags) G_SIGNAL_RUN_LAST,
168 G_STRUCT_OFFSET (SyncdaemonDaemonClass, status_changed),
169 NULL, NULL,
170 g_cclosure_marshal_VOID__OBJECT,
171 G_TYPE_NONE, 1,
172 G_TYPE_OBJECT);
173 daemon_signals[EVENT_SIGNAL] = g_signal_new ("event",
174 G_TYPE_FROM_CLASS (klass),
175 (GSignalFlags) G_SIGNAL_RUN_LAST,
176 G_STRUCT_OFFSET (SyncdaemonDaemonClass, event),
177 NULL, NULL,
178 g_cclosure_marshal_VOID__POINTER,
179 G_TYPE_NONE, 1,
180 G_TYPE_POINTER);
181 daemon_signals[ERROR_SIGNAL] = g_signal_new ("error",
182 G_TYPE_FROM_CLASS (klass),
183 (GSignalFlags) G_SIGNAL_RUN_LAST,
184 G_STRUCT_OFFSET (SyncdaemonDaemonClass, error),
185 NULL, NULL,
186 _syncdaemon_marshal_VOID__STRING_POINTER,
187 G_TYPE_NONE, 2,
188 G_TYPE_STRING, G_TYPE_POINTER);
189 daemon_signals[FOLDER_CREATED_SIGNAL] = g_signal_new ("folder_created",
190 G_TYPE_FROM_CLASS (klass),
191 (GSignalFlags) G_SIGNAL_RUN_LAST,
192 G_STRUCT_OFFSET (SyncdaemonDaemonClass, folder_created),
193 NULL, NULL,
194 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
195 G_TYPE_NONE, 2,
196 G_TYPE_BOOLEAN,
197 G_TYPE_OBJECT);
198 daemon_signals[FOLDER_DELETED_SIGNAL] = g_signal_new ("folder_deleted",
199 G_TYPE_FROM_CLASS (klass),
200 (GSignalFlags) G_SIGNAL_RUN_LAST,
201 G_STRUCT_OFFSET (SyncdaemonDaemonClass, folder_deleted),
202 NULL, NULL,
203 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
204 G_TYPE_NONE, 2,
205 G_TYPE_BOOLEAN,
206 G_TYPE_OBJECT);
207 daemon_signals[FOLDER_SUBSCRIBED_SIGNAL] = g_signal_new ("folder_subscribed",
208 G_TYPE_FROM_CLASS (klass),
209 (GSignalFlags) G_SIGNAL_RUN_LAST,
210 G_STRUCT_OFFSET (SyncdaemonDaemonClass, folder_subscribed),
211 NULL, NULL,
212 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
213 G_TYPE_NONE, 2,
214 G_TYPE_BOOLEAN,
215 G_TYPE_OBJECT);
216 daemon_signals[FOLDER_UNSUBSCRIBED_SIGNAL] = g_signal_new ("folder_unsubscribed",
217 G_TYPE_FROM_CLASS (klass),
218 (GSignalFlags) G_SIGNAL_RUN_LAST,
219 G_STRUCT_OFFSET (SyncdaemonDaemonClass, folder_unsubscribed),
220 NULL, NULL,
221 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
222 G_TYPE_NONE, 2,
223 G_TYPE_BOOLEAN,
224 G_TYPE_OBJECT);
225 daemon_signals[FILE_PUBLISHED_SIGNAL] = g_signal_new ("file_published",
226 G_TYPE_FROM_CLASS (klass),
227 (GSignalFlags) G_SIGNAL_RUN_LAST,
228 G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_published),
229 NULL, NULL,
230 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
231 G_TYPE_NONE, 2,
232 G_TYPE_BOOLEAN,
233 G_TYPE_OBJECT);
234 daemon_signals[FILE_UNPUBLISHED_SIGNAL] = g_signal_new ("file_unpublished",
235 G_TYPE_FROM_CLASS (klass),
236 (GSignalFlags) G_SIGNAL_RUN_LAST,
237 G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_unpublished),
238 NULL, NULL,
239 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
240 G_TYPE_NONE, 2,
241 G_TYPE_BOOLEAN,
242 G_TYPE_OBJECT);
243 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",
244 G_TYPE_FROM_CLASS (klass),
245 (GSignalFlags) G_SIGNAL_RUN_LAST,
246 G_STRUCT_OFFSET (SyncdaemonDaemonClass, share_created),
247 NULL, NULL,
248 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
249 G_TYPE_NONE, 2,
250 G_TYPE_BOOLEAN,
251 G_TYPE_OBJECT);
252 daemon_signals[SHARE_DELETED_SIGNAL] = g_signal_new ("share_deleted",
253 G_TYPE_FROM_CLASS (klass),
254 (GSignalFlags) G_SIGNAL_RUN_LAST,
255 G_STRUCT_OFFSET (SyncdaemonDaemonClass, share_deleted),
256 NULL, NULL,
257 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
258 G_TYPE_NONE, 2,
259 G_TYPE_BOOLEAN,
260 G_TYPE_OBJECT);
261 daemon_signals[DOWNLOAD_STARTED_SIGNAL] = g_signal_new ("download_started",
262 G_TYPE_FROM_CLASS (klass),
263 (GSignalFlags) G_SIGNAL_RUN_LAST,
264 G_STRUCT_OFFSET (SyncdaemonDaemonClass, download_started),
265 NULL, NULL,
266 g_cclosure_marshal_VOID__STRING,
267 G_TYPE_NONE, 1,
268 G_TYPE_STRING);
269 daemon_signals[DOWNLOAD_FILE_PROGRESS_SIGNAL] = g_signal_new ("download_file_progress",
270 G_TYPE_FROM_CLASS (klass),
271 (GSignalFlags) G_SIGNAL_RUN_LAST,
272 G_STRUCT_OFFSET (SyncdaemonDaemonClass, download_file_progress),
273 NULL, NULL,
274 _syncdaemon_marshal_VOID__STRING_OBJECT,
275 G_TYPE_NONE, 2,
276 G_TYPE_STRING, G_TYPE_OBJECT);
277 daemon_signals[DOWNLOAD_FINISHED_SIGNAL] = g_signal_new ("download_finished",
278 G_TYPE_FROM_CLASS (klass),
279 (GSignalFlags) G_SIGNAL_RUN_LAST,
280 G_STRUCT_OFFSET (SyncdaemonDaemonClass, download_finished),
281 NULL, NULL,
282 _syncdaemon_marshal_VOID__STRING_OBJECT,
283 G_TYPE_NONE, 2,
284 G_TYPE_STRING, G_TYPE_OBJECT);
285 daemon_signals[UPLOAD_STARTED_SIGNAL] = g_signal_new ("upload_started",
286 G_TYPE_FROM_CLASS (klass),
287 (GSignalFlags) G_SIGNAL_RUN_LAST,
288 G_STRUCT_OFFSET (SyncdaemonDaemonClass, upload_started),
289 NULL, NULL,
290 g_cclosure_marshal_VOID__STRING,
291 G_TYPE_NONE, 1,
292 G_TYPE_STRING);
293 daemon_signals[UPLOAD_FILE_PROGRESS_SIGNAL] = g_signal_new ("upload_file_progress",
294 G_TYPE_FROM_CLASS (klass),
295 (GSignalFlags) G_SIGNAL_RUN_LAST,
296 G_STRUCT_OFFSET (SyncdaemonDaemonClass, upload_file_progress),
297 NULL, NULL,
298 _syncdaemon_marshal_VOID__STRING_OBJECT,
299 G_TYPE_NONE, 2,
300 G_TYPE_STRING, G_TYPE_OBJECT);
301 daemon_signals[UPLOAD_FINISHED_SIGNAL] = g_signal_new ("upload_finished",
302 G_TYPE_FROM_CLASS (klass),
303 (GSignalFlags) G_SIGNAL_RUN_LAST,
304 G_STRUCT_OFFSET (SyncdaemonDaemonClass, upload_finished),
305 NULL, NULL,
306 _syncdaemon_marshal_VOID__STRING_OBJECT,
307 G_TYPE_NONE, 2,
308 G_TYPE_STRING, G_TYPE_OBJECT);
309 daemon_signals[QUOTA_EXCEEDED_SIGNAL] = g_signal_new ("quota_exceeded",
310 G_TYPE_FROM_CLASS (klass),
311 (GSignalFlags) G_SIGNAL_RUN_LAST,
312 G_STRUCT_OFFSET (SyncdaemonDaemonClass, quota_exceeded),
313 NULL, NULL,
314 g_cclosure_marshal_VOID__POINTER,
315 G_TYPE_NONE, 1,
316 G_TYPE_POINTER);
317}
318
319static void
320quota_exceeded_cb (DBusGProxy *proxy, GHashTable *volume_info, gpointer user_data)
321{
322 SyncdaemonDaemon *daemon = SYNCDAEMON_DAEMON (user_data);
323
324 if (daemon != NULL)
325 g_signal_emit_by_name (daemon, "quota_exceeded", volume_info);
326}
327
328static gboolean
329ready_signal_idle_cb (gpointer user_data)
330{
331 SyncdaemonDaemon *daemon = SYNCDAEMON_DAEMON (user_data);
332
333 g_signal_emit (daemon, daemon_signals[READY_SIGNAL], 0);
334
335 return FALSE;
336}
337
338static void
339setup_daemon_interface (SyncdaemonDaemon *daemon)
340{
341 GObject *proxy = NULL;
342
343 if (daemon->priv->daemon_interface != NULL)
344 g_object_unref (daemon->priv->daemon_interface);
345 daemon->priv->daemon_interface = g_object_new (SYNCDAEMON_TYPE_INTERFACE,
346 "daemon", daemon,
347 NULL);
348 proxy = syncdaemon_interface_setup_proxy (SYNCDAEMON_INTERFACE (daemon->priv->daemon_interface),
349 SYNCDAEMON_DBUS_NAME, "/",
350 "com.ubuntuone.SyncDaemon.SyncDaemon");
351 if (proxy != NULL) {
352 daemon->priv->ready = TRUE;
353
354 dbus_g_proxy_add_signal (DBUS_G_PROXY (proxy), "QuotaExceeded",
355 dbus_g_type_get_map ("GHashTable",
356 G_TYPE_STRING,
357 G_TYPE_STRING),
358 G_TYPE_INVALID);
359 dbus_g_proxy_connect_signal (DBUS_G_PROXY (proxy), "QuotaExceeded",
360 G_CALLBACK (quota_exceeded_cb),
361 daemon, NULL);
362
363 /* Now get all the interfaces so that we get the signals from them */
364 syncdaemon_daemon_get_config_interface (daemon);
365 syncdaemon_daemon_get_events_interface (daemon);
366 syncdaemon_daemon_get_filesystem_interface (daemon);
367 syncdaemon_daemon_get_folders_interface (daemon);
368 syncdaemon_daemon_get_publicfiles_interface (daemon);
369 syncdaemon_daemon_get_shares_interface (daemon);
370 syncdaemon_daemon_get_status_interface (daemon);
371
372 /* Emit the signal in an idle callback so that callers get it when syncdaemon is running
373 and hence signal is emitted in the _init method */
374 g_idle_add ((GSourceFunc) ready_signal_idle_cb, daemon);
375 }
376
377}
378
379static void
380name_owner_changed_cb (DBusGProxy *proxy,
381 const char *name,
382 const char *old_owner,
383 const char *new_owner,
384 gpointer user_data)
385{
386 SyncdaemonDaemon *daemon = SYNCDAEMON_DAEMON (user_data);
387
388 if (g_strcmp0 (name, SYNCDAEMON_DBUS_NAME) == 0) {
389 if (new_owner != NULL && strlen (new_owner) > 0) {
390 g_debug ("Got notification of SyncDaemon startup in NameOwnerChanged");
391 setup_daemon_interface (daemon);
392 } else {
393 daemon->priv->ready = FALSE;
394
395 g_debug ("Syncdaemon service died");
396 if (daemon->priv->daemon_interface != NULL) {
397 g_object_unref (daemon->priv->daemon_interface);
398 daemon->priv->daemon_interface = NULL;
399 }
400
401 g_hash_table_remove_all (daemon->priv->subinterfaces);
402 daemon->priv->connected = FALSE;
403 }
404 }
405}
406
407static void
408syncdaemon_daemon_init (SyncdaemonDaemon *daemon)
409{
410 gboolean has_owner;
411 GError *error = NULL;
412
413 daemon->priv = g_new0 (SyncdaemonDaemonPrivate, 1);
414
415 daemon->priv->ready = FALSE;
416 daemon->priv->connected = FALSE;
417 daemon->priv->subinterfaces = g_hash_table_new_full (g_str_hash, g_str_equal,
418 g_free, g_object_unref);
419 daemon->priv->auth = g_object_new (SYNCDAEMON_TYPE_AUTHENTICATION, NULL);
420
421 /* Initialize DBus */
422#ifdef HAVE_GDBUS
423 daemon->priv->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
424#else
425 daemon->priv->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
426#endif
427 if (error != NULL) {
428 g_warning ("Couldn't get session bus: %s", error->message);
429 g_error_free (error);
430 return;
431 }
432
433 daemon->priv->dbus_proxy = dbus_g_proxy_new_for_name (daemon->priv->bus,
434 "org.freedesktop.DBus",
435 "/org/freedesktop/DBus",
436 "org.freedesktop.DBus");
437
438 /* Check if syncdaemon is running */
439 error = NULL;
440 if (org_freedesktop_DBus_name_has_owner (daemon->priv->dbus_proxy, SYNCDAEMON_DBUS_NAME, &has_owner, &error)) {
441 if (has_owner) {
442 /* Already running, so initialize ourselves */
443 g_debug ("SyncDaemon already running, initializing SyncdaemonDaemon object");
444 setup_daemon_interface (daemon);
445 } else
446 g_debug ("Syncdaemon not running, waiting for it to start in NameOwnerChanged");
447 } else {
448 /* The DBus call failed, so just wait for SyncDaemon to start in name_owner_changed_cb */
449 g_warning ("Error calling NameHasOwner: %s", error->message);
450 g_error_free (error);
451 }
452
453 /* Listen to DBus for syncdaemon restarts */
454 dbus_g_proxy_add_signal (DBUS_G_PROXY (daemon->priv->dbus_proxy), "NameOwnerChanged",
455 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
456 G_TYPE_INVALID);
457 dbus_g_proxy_connect_signal (DBUS_G_PROXY (daemon->priv->dbus_proxy),
458 "NameOwnerChanged",
459 G_CALLBACK (name_owner_changed_cb),
460 daemon, NULL);
461}
462
463/**
464 * syncdaemon_daemon_new:
465 *
466 * Create a new #SyncdaemonDaemon object, which provides access to the
467 * Syncdaemon daemon.
468 *
469 * Return value: A new #SyncdaemonDaemon object.
470 */
471SyncdaemonDaemon *
472syncdaemon_daemon_new (void)
473{
474 return g_object_new (SYNCDAEMON_TYPE_DAEMON, NULL);
475}
476
477/**
478 * syncdaemon_daemon_is_ready:
479 */
480gboolean
481syncdaemon_daemon_is_ready (SyncdaemonDaemon *daemon)
482{
483 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
484
485 return daemon->priv->ready;
486}
487
488static void
489connect_response_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
490{
491 GError *error = NULL;
492 SyncdaemonDaemon *daemon = (SyncdaemonDaemon *) user_data;
493
494 if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
495 daemon->priv->connected = TRUE;
496 g_signal_emit (daemon, daemon_signals[CONNECTED_SIGNAL], 0);
497 } else {
498 g_warning ("Syncdaemon cannot connect: %s", error->message);
499 g_error_free (error);
500 }
501}
502
503/**
504 * syncdaemon_daemon_connect:
505 */
506gboolean
507syncdaemon_daemon_connect (SyncdaemonDaemon *daemon)
508{
509 GObject *proxy;
510
511 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
512
513 proxy = syncdaemon_interface_get_proxy_object (SYNCDAEMON_INTERFACE (daemon->priv->daemon_interface));
514 if (proxy != NULL) {
515#ifdef HAVE_GDBUS
516#else
517 if (!dbus_g_proxy_begin_call (DBUS_G_PROXY (proxy), "connect",
518 connect_response_cb, daemon, NULL,
519 G_TYPE_INVALID)) {
520 g_warning ("Call to 'connect' method failed");
521
522 return FALSE;
523 }
524#endif
525 }
526
527 return TRUE;
528}
529
530static void
531disconnect_response_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
532{
533 GError *error = NULL;
534 SyncdaemonDaemon *daemon = (SyncdaemonDaemon *) user_data;
535
536 if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
537 daemon->priv->connected = FALSE;
538 g_signal_emit (daemon, daemon_signals[DISCONNECTED_SIGNAL], 0);
539 } else {
540 g_warning ("Syncdaemon cannot disconnect: %s", error->message);
541 g_error_free (error);
542 }
543}
544
545/**
546 * syncdaemon_daemon_interface_disconnect:
547 */
548gboolean
549syncdaemon_daemon_disconnect (SyncdaemonDaemon *daemon)
550{
551 GObject *proxy;
552
553 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
554
555 proxy = syncdaemon_interface_get_proxy_object (SYNCDAEMON_INTERFACE (daemon->priv->daemon_interface));
556 if (proxy != NULL) {
557#ifdef HAVE_GDBUS
558#else
559 if (!dbus_g_proxy_begin_call (DBUS_G_PROXY (proxy), "disconnect",
560 disconnect_response_cb, daemon, NULL,
561 G_TYPE_INVALID)) {
562 g_warning ("Call to 'disconnect' method failed");
563
564 return FALSE;
565 }
566#endif
567 }
568
569 return TRUE;
570}
571
572/**
573 * syncdaemon_daemon_interface_quit:
574 */
575gboolean
576syncdaemon_daemon_quit (SyncdaemonDaemon *daemon)
577{
578 GObject *proxy;
579
580 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
581
582 proxy = syncdaemon_interface_get_proxy_object (SYNCDAEMON_INTERFACE (daemon->priv->daemon_interface));
583 if (proxy != NULL) {
584 GError *error = NULL;
585
586#ifdef HAVE_GDBUS
587#else
588 if (!dbus_g_proxy_call (DBUS_G_PROXY (proxy), "quit", &error,
589 G_TYPE_INVALID,
590 G_TYPE_INVALID)) {
591 g_warning ("Could not quit syncdaemon: %s", error->message);
592 g_error_free (error);
593
594 return FALSE;
595 }
596#endif
597 }
598
599 return TRUE;
600}
601
602/**
603 * syncdaemon_daemon_get_root_dir:
604 */
605const gchar *
606syncdaemon_daemon_get_root_dir (SyncdaemonDaemon *daemon)
607{
608 GObject *proxy;
609
610 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
611
612 if (daemon->priv->root_dir != NULL)
613 return (const gchar *) daemon->priv->root_dir;
614
615 proxy = syncdaemon_interface_get_proxy_object (SYNCDAEMON_INTERFACE (daemon->priv->daemon_interface));
616 if (proxy != NULL) {
617 gchar *new_root_dir;
618 GError *error = NULL;
619
620#ifdef HAVE_GDBUS
621#else
622 if (!dbus_g_proxy_call (DBUS_G_PROXY (proxy), "get_rootdir", &error,
623 G_TYPE_INVALID,
624 G_TYPE_STRING, &new_root_dir,
625 G_TYPE_INVALID)) {
626 g_warning ("Could not get syncdaemon's root dir: %s", error->message);
627 g_error_free (error);
628
629 return NULL;
630 }
631#endif
632
633 daemon->priv->root_dir = new_root_dir;
634
635 return (const gchar *) daemon->priv->root_dir;
636 }
637
638 return NULL;
639}
640
641/**
642 * syncdaemon_daemon_has_network:
643 */
644gboolean
645syncdaemon_daemon_has_network (SyncdaemonDaemon *daemon)
646{
647 SyncdaemonInterface *interface;
648 gboolean result = FALSE;
649
650 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
651
652 interface = syncdaemon_daemon_get_status_interface (daemon);
653 if (SYNCDAEMON_IS_STATUS_INTERFACE (interface)) {
654 SyncdaemonStatusInfo *status_info;
655
656 status_info = syncdaemon_status_interface_get_current_status (SYNCDAEMON_STATUS_INTERFACE (interface));
657 if (g_strrstr (syncdaemon_status_info_get_connection (status_info), "With Network") != NULL)
658 result = TRUE;
659
660 g_object_unref (G_OBJECT (status_info));
661 }
662
663 return result;
664}
665
666/**
667 * syncdaemon_daemon_get_authentication:
668 */
669SyncdaemonAuthentication *
670syncdaemon_daemon_get_authentication (SyncdaemonDaemon *daemon)
671{
672 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
673
674 return daemon->priv->auth;
675}
676
677/**
678 * syncdaemon_daemon_get_bandwidth_throttling:
679 * @daemon: A #SyncdaemonDaemon object
680 *
681 * Get whether bandwidth throttling is enabled or not.
682 *
683 * Return value: TRUE if enabled, FALSE if disabled.
684 */
685gboolean
686syncdaemon_daemon_get_bandwidth_throttling (SyncdaemonDaemon *daemon)
687{
688 SyncdaemonInterface *interface;
689
690 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
691
692 interface = syncdaemon_daemon_get_config_interface (daemon);
693 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
694 return syncdaemon_config_interface_get_bandwidth_throttling (SYNCDAEMON_CONFIG_INTERFACE (interface));
695
696 return FALSE;
697}
698
699/**
700 * syncdaemon_daemon_set_bandwidth_throttling:
701 * @daemon: A #SyncdaemonDaemon object
702 * @enabled: Whether to enable bandwidth throttling or not.
703 *
704 * Enable or disable bandwidth throttling.
705 */
706void
707syncdaemon_daemon_set_bandwidth_throttling (SyncdaemonDaemon *daemon, gboolean enabled)
708{
709 SyncdaemonInterface *interface;
710
711 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
712
713 interface = syncdaemon_daemon_get_config_interface (daemon);
714 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
715 syncdaemon_config_interface_set_bandwidth_throttling (SYNCDAEMON_CONFIG_INTERFACE (interface), enabled);
716}
717
718/**
719 * syncdaemon_daemon_get_files_sync:
720 * @daemon: A #SyncdaemonDaemon object
721 *
722 * Get whether file syncing is enabled or not.
723 *
724 * Return value: TRUE if enabled, FALSE if disabled.
725 */
726gboolean
727syncdaemon_daemon_get_files_sync (SyncdaemonDaemon *daemon)
728{
729 SyncdaemonInterface *interface;
730
731 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
732
733 interface = syncdaemon_daemon_get_config_interface (daemon);
734 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
735 return syncdaemon_config_interface_get_files_sync (SYNCDAEMON_CONFIG_INTERFACE (interface));
736
737 return FALSE;
738}
739
740/**
741 * syncdaemon_daemon_set_files_sync:
742 * @daemon: A #SyncdaemonDaemon object
743 * @enabled: Whether to enable file syncing or not.
744 *
745 * Enable or disable file syncing.
746 */
747void
748syncdaemon_daemon_set_files_sync (SyncdaemonDaemon *daemon, gboolean enabled)
749{
750 SyncdaemonInterface *interface;
751
752 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
753
754 interface = syncdaemon_daemon_get_config_interface (daemon);
755 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
756 syncdaemon_config_interface_set_files_sync (SYNCDAEMON_CONFIG_INTERFACE (interface), enabled);
757}
758
759/**
760 * syncdaemon_daemon_get_throttling_limits:
761 * @daemon: A #SyncdaemonDaemon object
762 * @download: Placeholder for download limits
763 * @upload: Placeholder for upload limits
764 *
765 * Retrieve download and upload throttling limits.
766 */
767void
768syncdaemon_daemon_get_throttling_limits (SyncdaemonDaemon *daemon, gint *download, gint *upload)
769{
770 SyncdaemonInterface *interface;
771
772 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
773
774 interface = syncdaemon_daemon_get_config_interface (daemon);
775 if (interface != NULL) {
776 syncdaemon_config_interface_get_throttling_limits (SYNCDAEMON_CONFIG_INTERFACE (interface),
777 download,
778 upload);
779 }
780}
781
782/**
783 * syncdaemon_daemon_set_throttling_limits:
784 * @daemon: A #SyncdaemonDaemon object
785 * @download: Download limit
786 * @upload: Upload limit
787 *
788 * Set download and upload throttling limits.
789 */
790void
791syncdaemon_daemon_set_throttling_limits (SyncdaemonDaemon *daemon, gint download, gint upload)
792{
793 SyncdaemonInterface *interface;
794
795 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
796
797 interface = syncdaemon_daemon_get_config_interface (daemon);
798 if (interface != NULL) {
799 syncdaemon_config_interface_set_throttling_limits (SYNCDAEMON_CONFIG_INTERFACE (interface),
800 download,
801 upload);
802 }
803}
804
805/**
806 * syncdaemon_daemon_get_udf_autosubscribe:
807 * @daemon: A #SyncdaemonDaemon object
808 *
809 * Get whether autosubscription for UDFs is enabled or not.
810 *
811 * Return value: TRUE if enabled, FALSE if disabled.
812 */
813gboolean
814syncdaemon_daemon_get_udf_autosubscribe (SyncdaemonDaemon *daemon)
815{
816 SyncdaemonInterface *interface;
817
818 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
819
820 interface = syncdaemon_daemon_get_config_interface (daemon);
821 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
822 return syncdaemon_config_interface_get_udf_autosubscribe (SYNCDAEMON_CONFIG_INTERFACE (interface));
823
824 return FALSE;
825}
826
827/**
828 * syncdaemon_daemon_set_udf_autosubscribe:
829 * @daemon: A #SyncdaemonDaemon object
830 * @enabled: Whether to enable UDF autosubscription or not.
831 *
832 * Enable or disable UDF autosubscription.
833 */
834void
835syncdaemon_daemon_set_udf_autosubscribe (SyncdaemonDaemon *daemon, gboolean enabled)
836{
837 SyncdaemonInterface *interface;
838
839 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
840
841 interface = syncdaemon_daemon_get_config_interface (daemon);
842 if (SYNCDAEMON_IS_CONFIG_INTERFACE (interface))
843 syncdaemon_config_interface_set_udf_autosubscribe (SYNCDAEMON_CONFIG_INTERFACE (interface), enabled);
844}
845
846/**
847 * syncdaemon_daemon_get_metadata:
848 * @daemon: A #SyncdaemonDaemon object
849 * @path: Path to check metadata for
850 * @with_subtree_sync_check: For folders, whether to check the status of all its children
851 *
852 * Retrieve metadata for a file or folder inside a Ubuntu One directory.
853 *
854 * Return value: Metadata for the specified path.
855 */
856SyncdaemonMetadata *
857syncdaemon_daemon_get_metadata (SyncdaemonDaemon *daemon, const gchar *path, gboolean with_subtree_sync_check)
858{
859 SyncdaemonInterface *interface;
860
861 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
862
863 interface = syncdaemon_daemon_get_filesystem_interface (daemon);
864 if (interface != NULL) {
865 return syncdaemon_filesystem_interface_get_metadata (SYNCDAEMON_FILESYSTEM_INTERFACE (interface),
866 path,
867 with_subtree_sync_check);
868 }
869
870 return NULL;
871}
872
873/**
874 * syncdaemon_daemon_get_folders:
875 * @daemon: A #SyncdaemonDaemon object
876 *
877 * Retrieve the list of folders setup for synchronization with Ubuntu One.
878 *
879 * Return value: A list of #SyncdaemonFolderInfo containing all the folders being
880 * synchronized by the user. When no longer needed, the list should be freed
881 * by calling g_slist_free.
882 */
883GSList *
884syncdaemon_daemon_get_folders (SyncdaemonDaemon *daemon)
885{
886 SyncdaemonInterface *interface;
887
888 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
889
890 interface = syncdaemon_daemon_get_folders_interface (daemon);
891 if (interface != NULL)
892 return syncdaemon_folders_interface_get_folders (SYNCDAEMON_FOLDERS_INTERFACE (interface));
893
894 return NULL;
895}
896
897/**
898 * syncdaemon_daemon_get_folder_info:
899 * @daemon: A #SyncdaemonDaemon object
900 * @path: Full path of the folder for which to retrieve information.
901 *
902 * Get information about a folder under Ubuntu One.
903 *
904 * Return value: A #SyncdaemonFolderInfo object containing all the information
905 * for the node. When no longer needed, it should be freed by calling
906 * g_object_unref.
907 */
908SyncdaemonFolderInfo *
909syncdaemon_daemon_get_folder_info (SyncdaemonDaemon *daemon, const gchar *path)
910{
911 SyncdaemonInterface *interface;
912
913 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
914
915 interface = syncdaemon_daemon_get_folders_interface (daemon);
916 if (interface != NULL)
917 return syncdaemon_folders_interface_get_info (SYNCDAEMON_FOLDERS_INTERFACE (interface), path);
918
919 return NULL;
920}
921
922/**
923 * syncdaemon_daemon_is_folder_enabled:
924 * @daemon: A #SyncdaemonDaemon object
925 * @path: The folder path to check
926 * @is_root: Placeholder for returning whether the given path is a U1 root folder
927 *
928 * Check whether a given path is a folder enabled for synchronization to U1.
929 *
930 * Return value: TRUE if the folder is enabled, FALSE otherwise.
931 */
932gboolean
933syncdaemon_daemon_is_folder_enabled (SyncdaemonDaemon *daemon, const gchar *path, gboolean *is_root)
934{
935 const gchar *root;
936 gchar *root_with_slash;
937 gboolean managed = FALSE, is_subscribed = FALSE;
938 gchar *dirpath;
939 SyncdaemonInterface *interface;
940
941 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
942 g_return_val_if_fail (path != NULL, FALSE);
943
944 *is_root = FALSE;
945
946 /* First check the root folder */
947 root = syncdaemon_daemon_get_root_dir (daemon);
948 if (g_strcmp0 (path, root) == 0) {
949 *is_root = TRUE;
950 return TRUE;
951 } else {
952 root_with_slash = g_build_filename (root, G_DIR_SEPARATOR_S, NULL);
953
954 if (g_str_has_prefix (path, root_with_slash)) {
955 g_free(root_with_slash);
956 return TRUE;
957 }
958 g_free(root_with_slash);
959 }
960 /* Now check the 'Shared With Me' directory */
961 dirpath = g_build_filename (root, "Shared With Me", NULL);
962 if (g_strcmp0 (path, dirpath) == 0) {
963 g_free (dirpath);
964 return FALSE;
965 }
966 g_free (dirpath);
967
968 /* And finally check UDFs */
969 interface = syncdaemon_daemon_get_folders_interface (daemon);
970 if (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface)) {
971 GSList *udfs, *l;
972
973 udfs = syncdaemon_folders_interface_get_folders (SYNCDAEMON_FOLDERS_INTERFACE (interface));
974 for (l = udfs; l != NULL; l = l->next) {
975 const gchar *tmp_path;
976 gchar *tmp_path_with_slash;
977 SyncdaemonFolderInfo *finfo = SYNCDAEMON_FOLDER_INFO (l->data);
978
979 tmp_path = syncdaemon_folder_info_get_path (finfo);
980 is_subscribed = syncdaemon_folder_info_get_subscribed (finfo);
981
982 tmp_path_with_slash = g_strconcat (tmp_path, G_DIR_SEPARATOR_S, NULL);
983 if (g_strcmp0 (path, tmp_path) == 0) {
984 managed = is_subscribed;
985 *is_root = TRUE;
986 break;
987 } else if (g_str_has_prefix (path, tmp_path_with_slash)) {
988 managed = is_subscribed;
989 break;
990 }
991 g_free (tmp_path_with_slash);
992 }
993
994 g_slist_free (udfs);
995 }
996
997 return managed;
998}
999
1000/**
1001 * syncdaemon_daemon_create_folder:
1002 * @daemon: A #SyncdaemonDaemon object
1003 * @path: The full path of the folder to create
1004 *
1005 * Enable a folder for Ubuntu One synchronization.
1006 *
1007 * The result of the operation can be retrieved by connecting to the "folder_created"
1008 * signal of the #SyncdaemonDaemon object.
1009 */
1010void
1011syncdaemon_daemon_create_folder (SyncdaemonDaemon *daemon, const gchar *path)
1012{
1013 SyncdaemonInterface *interface;
1014
1015 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1016
1017 interface = syncdaemon_daemon_get_folders_interface (daemon);
1018 if (interface != NULL)
1019 syncdaemon_folders_interface_create (SYNCDAEMON_FOLDERS_INTERFACE (interface), path);
1020 else
1021 g_signal_emit (daemon, daemon_signals[FOLDER_CREATED_SIGNAL], 0, FALSE, NULL);
1022}
1023
1024/**
1025 * syncdaemon_daemon_delete_folder:
1026 * @daemon: A #SyncdaemonDaemon object
1027 * @path: The full path of the folder to delete
1028 *
1029 * Disable a folder for Ubuntu One synchronization.
1030 *
1031 * The result of the operation can be retrieved by connecting to the "folder_deleted"
1032 * signal of the #SyncdaemonDaemon object.
1033 */
1034void
1035syncdaemon_daemon_delete_folder (SyncdaemonDaemon *daemon, const gchar *path)
1036{
1037 SyncdaemonInterface *interface;
1038
1039 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1040
1041 interface = syncdaemon_daemon_get_folders_interface (daemon);
1042 if (interface != NULL)
1043 syncdaemon_folders_interface_delete (SYNCDAEMON_FOLDERS_INTERFACE (interface), path);
1044 else
1045 g_signal_emit (daemon, daemon_signals[FOLDER_DELETED_SIGNAL], 0, FALSE, NULL);
1046}
1047
1048/**
1049 * syncdaemon_daemon_subscribe_folder:
1050 * @daemon: A #SyncdaemonDaemon object
1051 * @path: The full path of the folder to subscribe
1052 *
1053 * Subscribe a folder for Ubuntu One synchronization.
1054 *
1055 * The result of the operation can be retrieved by connecting to the "folder_subscribed"
1056 * signal of the #SyncdaemonDaemon object.
1057 */
1058void
1059syncdaemon_daemon_subscribe_folder (SyncdaemonDaemon *daemon, const gchar *path)
1060{
1061 SyncdaemonInterface *interface;
1062
1063 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1064
1065 interface = syncdaemon_daemon_get_folders_interface (daemon);
1066 if (interface != NULL)
1067 syncdaemon_folders_interface_subscribe (SYNCDAEMON_FOLDERS_INTERFACE (interface), path);
1068 else
1069 g_signal_emit (daemon, daemon_signals[FOLDER_SUBSCRIBED_SIGNAL], 0, FALSE, NULL);
1070}
1071
1072/**
1073 * syncdaemon_daemon_unsubscribe_folder:
1074 * @daemon: A #SyncdaemonDaemon object
1075 * @path: The full path of the folder to unsubscribe
1076 *
1077 * Unsubscribe a folder from Ubuntu One synchronization.
1078 *
1079 * The result of the operation can be retrieved by connecting to the "folder_unsubscribed"
1080 * signal of the #SyncdaemonDaemon object.
1081 */
1082void
1083syncdaemon_daemon_unsubscribe_folder (SyncdaemonDaemon *daemon, const gchar *path)
1084{
1085 SyncdaemonInterface *interface;
1086
1087 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1088
1089 interface = syncdaemon_daemon_get_folders_interface (daemon);
1090 if (interface != NULL)
1091 syncdaemon_folders_interface_unsubscribe (SYNCDAEMON_FOLDERS_INTERFACE (interface), path);
1092 else
1093 g_signal_emit (daemon, daemon_signals[FOLDER_UNSUBSCRIBED_SIGNAL], 0, FALSE, NULL);
1094}
1095
1096/**
1097 * syncdaemon_daemon_publish_file:
1098 * @daemon: A #SyncdaemonDaemon object
1099 * @path: Full path of the file to be published
1100 *
1101 * Publish a file on Ubuntu One. When the file is successfully published, the "file_published"
1102 * signal will be emitted.
1103 *
1104 * Return value: TRUE if successful, FALSE otherwise.
1105 */
1106gboolean
1107syncdaemon_daemon_publish_file (SyncdaemonDaemon *daemon, const gchar *path)
1108{
1109 SyncdaemonMetadata *metadata;
1110 gboolean result = FALSE;
1111
1112 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
1113
1114 /* First, retrieve the metadata */
1115 metadata = syncdaemon_daemon_get_metadata (daemon, path, FALSE);
1116 if (metadata != NULL) {
1117 SyncdaemonInterface *interface;
1118
1119 interface = syncdaemon_daemon_get_publicfiles_interface (daemon);
1120 syncdaemon_publicfiles_interface_change_public_access (
1121 SYNCDAEMON_PUBLICFILES_INTERFACE (interface),
1122 syncdaemon_metadata_get_share_id (metadata),
1123 syncdaemon_metadata_get_node_id (metadata),
1124 TRUE);
1125
1126 result = TRUE;
1127
1128 g_object_unref (metadata);
1129 }
1130
1131 return result;
1132}
1133
1134/**
1135 * syncdaemon_daemon_unpublish_file:
1136 * @daemon: A #SyncdaemonDaemon object
1137 * @path: Full path of the file to be unpublished
1138 *
1139 * Unpublish a file from Ubuntu One. When the file is successfully unpublished, the "file_unpublished"
1140 * signal will be emitted.
1141 *
1142 * Return value: TRUE if successful, FALSE otherwise.
1143 */
1144gboolean
1145syncdaemon_daemon_unpublish_file (SyncdaemonDaemon *daemon, const gchar *path)
1146{
1147 SyncdaemonMetadata *metadata;
1148 gboolean result = FALSE;
1149
1150 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), FALSE);
1151
1152 /* First, retrieve the metadata */
1153 metadata = syncdaemon_daemon_get_metadata (daemon, path, FALSE);
1154 if (metadata != NULL) {
1155 SyncdaemonInterface *interface;
1156
1157 interface = syncdaemon_daemon_get_publicfiles_interface (daemon);
1158 syncdaemon_publicfiles_interface_change_public_access (
1159 SYNCDAEMON_PUBLICFILES_INTERFACE (interface),
1160 syncdaemon_metadata_get_share_id (metadata),
1161 syncdaemon_metadata_get_node_id (metadata),
1162 FALSE);
1163
1164 result = TRUE;
1165
1166 g_object_unref (metadata);
1167 }
1168
1169 return result;
1170}
1171
1172/**
1173 * syncdaemon_daemon_get_public_files:
1174 * @daemon: A #SyncdaemonDaemon object
1175 *
1176 * Retrieve the list of public files.
1177 *
1178 * Return value: A #GSList of #SyncdaemonFileInfo objects, each of which describes
1179 * a published file for the user. When no longer needed, this list should be
1180 * freed by calling g_slist_free, but the data within the list should never
1181 * be freed, as it belongs to the library.
1182 */
1183GSList *
1184syncdaemon_daemon_get_public_files (SyncdaemonDaemon *daemon)
1185{
1186 SyncdaemonInterface *interface;
1187
1188 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1189
1190 interface = syncdaemon_daemon_get_publicfiles_interface (daemon);
1191 if (interface != NULL) {
1192 return syncdaemon_publicfiles_interface_get_public_files (
1193 SYNCDAEMON_PUBLICFILES_INTERFACE (interface));
1194 }
1195
1196 return NULL;
1197}
1198
1199/**
1200 * syncdaemon_daemon_create_share:
1201 * @daemon: A #SyncdaemonDaemon object
1202 * @path: Full path of the folder to be shared
1203 * @usernames: List of users with whom to share the folder
1204 * @name: Name to be used for the share
1205 * @allow_modifications: Whether to allow modifications to the list of users
1206 *
1207 * Share a Ubuntu One folder with a list of users.
1208 *
1209 * The result of the operation can be retrieved by connecting to the "share_created"
1210 * signal of the #SyncdaemonDaemon object.
1211 */
1212void
1213syncdaemon_daemon_create_share (SyncdaemonDaemon *daemon,
1214 const gchar *path,
1215 GSList *usernames,
1216 const gchar *name,
1217 gboolean allow_modifications)
1218{
1219 SyncdaemonInterface *interface;
1220
1221 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1222
1223 interface = syncdaemon_daemon_get_shares_interface (daemon);
1224 if (interface != NULL) {
1225 syncdaemon_shares_interface_create (SYNCDAEMON_SHARES_INTERFACE (interface),
1226 path,
1227 usernames,
1228 name,
1229 allow_modifications);
1230 } else
1231 g_signal_emit (daemon, daemon_signals[SHARE_CREATED_SIGNAL], 0, FALSE, NULL);
1232}
1233
1234/**
1235 * syncdaemon_daemon_delete_share:
1236 * @daemon: A #SyncdaemonDaemon object
1237 * @path: Full path of the folder to be shared
1238 *
1239 * Stop sharing a Ubuntu One folder.
1240 *
1241 * The result of the operation can be retrieved by connecting to the "share_deleted"
1242 * signal of the #SyncdaemonDaemon object.
1243 */
1244void
1245syncdaemon_daemon_delete_share (SyncdaemonDaemon *daemon, const gchar *path)
1246{
1247 SyncdaemonInterface *interface;
1248
1249 g_return_if_fail (SYNCDAEMON_IS_DAEMON (daemon));
1250
1251 interface = syncdaemon_daemon_get_shares_interface (daemon);
1252 if (interface != NULL)
1253 syncdaemon_shares_interface_delete (SYNCDAEMON_SHARES_INTERFACE (interface), path);
1254 else
1255 g_signal_emit (daemon, daemon_signals[SHARE_DELETED_SIGNAL], 0, FALSE, NULL);
1256}
1257
1258/**
1259 * syncdaemon_daemon_get_shared_folders:
1260 * @daemon: A #SyncdaemonDaemon object
1261 *
1262 * Get the list of folders shared by the user with other users.
1263 *
1264 * Return value: A GSList of #SyncdaemonShareInfo objects. When no longer needed,
1265 * the list should be freed by calling #g_slist_free.
1266 */
1267GSList *
1268syncdaemon_daemon_get_shared_folders (SyncdaemonDaemon *daemon)
1269{
1270 SyncdaemonInterface *interface;
1271
1272 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1273
1274 interface = syncdaemon_daemon_get_shares_interface (daemon);
1275 if (interface != NULL)
1276 return syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
1277
1278 return NULL;
1279}
1280
1281/**
1282 * syncdaemon_daemon_get_shares:
1283 * @daemon: A #SyncdaemonDaemon object
1284 *
1285 * Get the list of folders shared by other users with the current user.
1286 *
1287 * Return value: A GSList of #SyncdaemonShareInfo objects. When no longer needed,
1288 * the list should be freed by calling #g_slist_free.
1289 */
1290GSList *
1291syncdaemon_daemon_get_shares (SyncdaemonDaemon *daemon)
1292{
1293 SyncdaemonInterface *interface;
1294
1295 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1296
1297 interface = syncdaemon_daemon_get_shares_interface (daemon);
1298 if (interface != NULL)
1299 return syncdaemon_shares_interface_get_shares (SYNCDAEMON_SHARES_INTERFACE (interface));
1300
1301 return NULL;
1302}
1303
1304/**
1305 * syncdaemon_daemon_get_current_status:
1306 * @daemon: A #SyncdaemonDaemon object
1307 *
1308 * Retrieve the current status of SyncDaemon.
1309 *
1310 * Return value: A #SyncdaemonStatusInfo object containing information about
1311 * Syncdaemon's current status. When no longer needed, it should be freed by
1312 * calling g_object_unref.
1313 */
1314SyncdaemonStatusInfo *
1315syncdaemon_daemon_get_current_status (SyncdaemonDaemon *daemon)
1316{
1317 SyncdaemonInterface *interface;
1318
1319 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1320
1321 interface = syncdaemon_daemon_get_status_interface (daemon);
1322 if (interface != NULL)
1323 return syncdaemon_status_interface_get_current_status (SYNCDAEMON_STATUS_INTERFACE (interface));
1324
1325 return NULL;
1326}
1327
1328/**
1329 * syncdaemon_daemon_get_current_downloads:
1330 * @daemon: A #SyncdaemonDaemon object
1331 *
1332 * Retrieve the list of downloads in progress.
1333 *
1334 * Return value: A GSList of #SyncdaemonTransferInfo objects, each of which contains
1335 * information about a file download in progress. The data in the list belongs to
1336 * the library, so when no longer needed, the list should be freed by just calling
1337 * g_slist_free.
1338 */
1339GSList *
1340syncdaemon_daemon_get_current_downloads (SyncdaemonDaemon *daemon)
1341{
1342 SyncdaemonInterface *interface;
1343
1344 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1345
1346 interface = syncdaemon_daemon_get_status_interface (daemon);
1347 if (interface != NULL)
1348 return syncdaemon_status_interface_get_current_downloads (SYNCDAEMON_STATUS_INTERFACE (interface));
1349
1350 return NULL;
1351}
1352
1353/**
1354 * syncdaemon_daemon_get_current_uploads:
1355 * @daemon: A #SyncdaemonDaemon object
1356 *
1357 * Retrieve the list of uploads in progress.
1358 *
1359 * Return value: A GSList of #SyncdaemonTransferInfo objects, each of which contains
1360 * information about a file upload in progress. The data in the list belongs to
1361 * the library, so when no longer needed, the list should be freed by just calling
1362 * g_slist_free.
1363 */
1364GSList *
1365syncdaemon_daemon_get_current_uploads (SyncdaemonDaemon *daemon)
1366{
1367 SyncdaemonInterface *interface;
1368
1369 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1370
1371 interface = syncdaemon_daemon_get_status_interface (daemon);
1372 if (interface != NULL)
1373 return syncdaemon_status_interface_get_current_uploads (SYNCDAEMON_STATUS_INTERFACE (interface));
1374
1375 return NULL;
1376}
1377
1378typedef SyncdaemonInterface * (* SDINewFunc) (SyncdaemonDaemon * daemon);
1379
1380static SyncdaemonInterface *
1381get_interface (SyncdaemonDaemon *daemon, const gchar *path, SDINewFunc new_func)
1382{
1383 SyncdaemonInterface *interface;
1384
1385 interface = g_hash_table_lookup (daemon->priv->subinterfaces, path);
1386 if (interface == NULL) {
1387 interface = new_func (daemon);
1388 if (SYNCDAEMON_IS_INTERFACE (interface))
1389 g_hash_table_insert (daemon->priv->subinterfaces, g_strdup (path), interface);
1390 }
1391
1392 return interface;
1393}
1394
1395/**
1396 * syncdaemon_daemon_get_config_interface:
1397 */
1398SyncdaemonInterface *
1399syncdaemon_daemon_get_config_interface (SyncdaemonDaemon *daemon)
1400{
1401 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1402
1403 return get_interface (daemon, "/config",
1404 (SDINewFunc) syncdaemon_config_interface_new);
1405}
1406
1407/**
1408 * syncdaemon_daemon_get_events_interface:
1409 */
1410SyncdaemonInterface *
1411syncdaemon_daemon_get_events_interface (SyncdaemonDaemon *daemon)
1412{
1413 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1414
1415 return get_interface (daemon, "/events",
1416 (SDINewFunc) syncdaemon_events_interface_new);
1417}
1418
1419/**
1420 * syncdaemon_daemon_get_filesystem_interface:
1421 */
1422SyncdaemonInterface *
1423syncdaemon_daemon_get_filesystem_interface (SyncdaemonDaemon *daemon)
1424{
1425 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1426
1427 return get_interface (daemon, "/filesystem",
1428 (SDINewFunc) syncdaemon_filesystem_interface_new);
1429}
1430
1431/**
1432 * syncdaemon_daemon_get_folders_interface:
1433 */
1434SyncdaemonInterface *
1435syncdaemon_daemon_get_folders_interface (SyncdaemonDaemon *daemon)
1436{
1437 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1438
1439 return get_interface (daemon, "/folders",
1440 (SDINewFunc) syncdaemon_folders_interface_new);
1441}
1442
1443/**
1444 * syncdaemon_daemon_get_publicfiles_interface:
1445 */
1446SyncdaemonInterface *
1447syncdaemon_daemon_get_publicfiles_interface (SyncdaemonDaemon *daemon)
1448{
1449 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1450
1451 return get_interface (daemon, "/publicfiles",
1452 (SDINewFunc) syncdaemon_publicfiles_interface_new);
1453}
1454
1455/**
1456 * syncdaemon_daemon_get_shares_interface:
1457 */
1458SyncdaemonInterface *
1459syncdaemon_daemon_get_shares_interface (SyncdaemonDaemon *daemon)
1460{
1461 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1462
1463 return get_interface (daemon, "/shares",
1464 (SDINewFunc) syncdaemon_shares_interface_new);
1465}
1466
1467/**
1468 * syncdaemon_daemon_get_status_interface:
1469 */
1470SyncdaemonInterface *
1471syncdaemon_daemon_get_status_interface (SyncdaemonDaemon *daemon)
1472{
1473 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
1474
1475 return get_interface (daemon, "/status",
1476 (SDINewFunc) syncdaemon_status_interface_new);
1477}
14780
=== removed file 'libsyncdaemon/syncdaemon-daemon.h'
--- libsyncdaemon/syncdaemon-daemon.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-daemon.h 1970-01-01 00:00:00 +0000
@@ -1,172 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_DAEMON_H__
36#define __SYNCDAEMON_DAEMON_H__
37
38#include <glib-object.h>
39#include "syncdaemon-authentication.h"
40#include "syncdaemon-file-info.h"
41#include "syncdaemon-folder-info.h"
42#include "syncdaemon-interface.h"
43#include "syncdaemon-metadata.h"
44#include "syncdaemon-share-info.h"
45#include "syncdaemon-status-info.h"
46#include "syncdaemon-transfer-info.h"
47
48G_BEGIN_DECLS
49
50#define SYNCDAEMON_TYPE_DAEMON (syncdaemon_daemon_get_type ())
51#define SYNCDAEMON_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_DAEMON, SyncdaemonDaemon))
52#define SYNCDAEMON_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_DAEMON))
53#define SYNCDAEMON_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_DAEMON, SyncdaemonDaemonClass))
54#define SYNCDAEMON_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_DAEMON))
55#define SYNCDAEMON_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_DAEMON, SyncdaemonDaemonClass))
56
57typedef struct _SyncdaemonDaemonPrivate SyncdaemonDaemonPrivate;
58
59typedef struct {
60 GObject parent;
61 SyncdaemonDaemonPrivate *priv;
62} SyncdaemonDaemon;
63
64typedef struct {
65 GObjectClass parent_class;
66
67 /* Signals */
68 void (* ready) (SyncdaemonDaemon *daemon);
69
70 void (* connected) (SyncdaemonDaemon *daemon);
71 void (* disconnected) (SyncdaemonDaemon *daemon);
72 void (* status_changed) (SyncdaemonDaemon *daemon, SyncdaemonStatusInfo *status_info);
73
74 void (* event) (SyncdaemonDaemon *daemon, GHashTable *event_dict);
75 void (* error) (SyncdaemonDaemon *daemon, const gchar *signal, GHashTable *extra_args);
76
77 void (* folder_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
78 void (* folder_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
79 void (* folder_subscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
80 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
81
82 void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
83 void (* file_unpublished) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
84
85 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
86 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
87
88 void (* download_started) (SyncdaemonDaemon *daemon, const gchar *path);
89 void (* download_file_progress) (SyncdaemonDaemon *daemon, const gchar *path, SyncdaemonTransferInfo *tinfo);
90 void (* download_finished) (SyncdaemonDaemon *daemon, const gchar *path, SyncdaemonTransferInfo *tinfo);
91 void (* upload_started) (SyncdaemonDaemon *daemon, const gchar *path);
92 void (* upload_file_progress) (SyncdaemonDaemon *daemon, const gchar *path, SyncdaemonTransferInfo *tinfo);
93 void (* upload_finished) (SyncdaemonDaemon *daemon, const gchar *path, SyncdaemonTransferInfo *tinfo);
94
95 void (* quota_exceeded) (SyncdaemonDaemon *daemon, GHashTable *volume_info);
96} SyncdaemonDaemonClass;
97
98GType syncdaemon_daemon_get_type (void);
99
100SyncdaemonDaemon *syncdaemon_daemon_new (void);
101
102gboolean syncdaemon_daemon_is_ready (SyncdaemonDaemon *daemon);
103
104gboolean syncdaemon_daemon_connect (SyncdaemonDaemon *daemon);
105gboolean syncdaemon_daemon_disconnect (SyncdaemonDaemon *daemon);
106gboolean syncdaemon_daemon_quit (SyncdaemonDaemon *daemon);
107const gchar *syncdaemon_daemon_get_root_dir (SyncdaemonDaemon *daemon);
108
109gboolean syncdaemon_daemon_has_network (SyncdaemonDaemon *daemon);
110SyncdaemonAuthentication *syncdaemon_daemon_get_authentication (SyncdaemonDaemon *daemon);
111
112/* Configuration */
113gboolean syncdaemon_daemon_get_bandwidth_throttling (SyncdaemonDaemon *daemon);
114void syncdaemon_daemon_set_bandwidth_throttling (SyncdaemonDaemon *daemon, gboolean enabled);
115gboolean syncdaemon_daemon_get_files_sync (SyncdaemonDaemon *daemon);
116void syncdaemon_daemon_set_files_sync (SyncdaemonDaemon *daemon, gboolean enabled);
117void syncdaemon_daemon_get_throttling_limits (SyncdaemonDaemon *daemon, gint *download, gint *upload);
118void syncdaemon_daemon_set_throttling_limits (SyncdaemonDaemon *daemon, gint download, gint upload);
119gboolean syncdaemon_daemon_get_udf_autosubscribe (SyncdaemonDaemon *daemon);
120void syncdaemon_daemon_set_udf_autosubscribe (SyncdaemonDaemon *daemon, gboolean enabled);
121
122/* File system operations */
123SyncdaemonMetadata *syncdaemon_daemon_get_metadata (SyncdaemonDaemon *daemon,
124 const gchar *path,
125 gboolean with_subtree_sync_check);
126
127
128/* Folders operations */
129GSList *syncdaemon_daemon_get_folders (SyncdaemonDaemon *daemon);
130SyncdaemonFolderInfo*syncdaemon_daemon_get_folder_info (SyncdaemonDaemon *daemon, const gchar *path);
131gboolean syncdaemon_daemon_is_folder_enabled (SyncdaemonDaemon *daemon,
132 const gchar *path,
133 gboolean *is_root);
134void syncdaemon_daemon_create_folder (SyncdaemonDaemon *daemon, const gchar *path);
135void syncdaemon_daemon_delete_folder (SyncdaemonDaemon *daemon, const gchar *path);
136void syncdaemon_daemon_subscribe_folder (SyncdaemonDaemon *daemon, const gchar *path);
137void syncdaemon_daemon_unsubscribe_folder (SyncdaemonDaemon *daemon, const gchar *path);
138
139/* Public files operations */
140gboolean syncdaemon_daemon_publish_file (SyncdaemonDaemon *daemon, const gchar *path);
141gboolean syncdaemon_daemon_unpublish_file (SyncdaemonDaemon *daemon, const gchar *path);
142GSList *syncdaemon_daemon_get_public_files (SyncdaemonDaemon *daemon);
143
144/* Shares operations */
145void syncdaemon_daemon_create_share (SyncdaemonDaemon *daemon,
146 const gchar *path,
147 GSList *usernames,
148 const gchar *name,
149 gboolean allow_modifications);
150void syncdaemon_daemon_delete_share (SyncdaemonDaemon *daemon, const gchar *path);
151GSList *syncdaemon_daemon_get_shared_folders (SyncdaemonDaemon *daemon);
152GSList *syncdaemon_daemon_get_shares (SyncdaemonDaemon *daemon);
153
154/* Status operations */
155SyncdaemonStatusInfo*syncdaemon_daemon_get_current_status (SyncdaemonDaemon *daemon);
156GSList *syncdaemon_daemon_get_current_downloads (SyncdaemonDaemon *daemon);
157GSList *syncdaemon_daemon_get_current_uploads (SyncdaemonDaemon *daemon);
158
159/*
160 * Low level DBus interface access
161 */
162SyncdaemonInterface *syncdaemon_daemon_get_config_interface (SyncdaemonDaemon *daemon);
163SyncdaemonInterface *syncdaemon_daemon_get_events_interface (SyncdaemonDaemon *daemon);
164SyncdaemonInterface *syncdaemon_daemon_get_filesystem_interface (SyncdaemonDaemon *daemon);
165SyncdaemonInterface *syncdaemon_daemon_get_folders_interface (SyncdaemonDaemon *daemon);
166SyncdaemonInterface *syncdaemon_daemon_get_publicfiles_interface (SyncdaemonDaemon *daemon);
167SyncdaemonInterface *syncdaemon_daemon_get_shares_interface (SyncdaemonDaemon *daemon);
168SyncdaemonInterface *syncdaemon_daemon_get_status_interface (SyncdaemonDaemon *daemon);
169
170G_END_DECLS
171
172#endif
1730
=== removed file 'libsyncdaemon/syncdaemon-events-interface.c'
--- libsyncdaemon/syncdaemon-events-interface.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-events-interface.c 1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#ifdef HAVE_GDBUS
37#else
38#include <dbus/dbus-glib.h>
39#endif
40#include "syncdaemon-events-interface.h"
41
42G_DEFINE_TYPE(SyncdaemonEventsInterface, syncdaemon_events_interface, SYNCDAEMON_TYPE_INTERFACE)
43
44struct _SyncdaemonEventsInterfacePrivate {
45 GObject *proxy;
46};
47
48static void
49syncdaemon_events_interface_finalize (GObject *object)
50{
51 SyncdaemonEventsInterface *interface = SYNCDAEMON_EVENTS_INTERFACE (object);
52
53 if (interface->priv != NULL) {
54 g_free (interface->priv);
55 }
56
57 G_OBJECT_CLASS (syncdaemon_events_interface_parent_class)->finalize (object);
58}
59
60static void
61syncdaemon_events_interface_class_init (SyncdaemonEventsInterfaceClass *klass)
62{
63 GObjectClass *object_class = G_OBJECT_CLASS (klass);
64
65 object_class->finalize = syncdaemon_events_interface_finalize;
66}
67
68static void
69event_cb (DBusGProxy *proxy, GHashTable *event_dict, gpointer user_data)
70{
71 SyncdaemonDaemon *daemon = NULL;
72 SyncdaemonEventsInterface *interface = SYNCDAEMON_EVENTS_INTERFACE (user_data);
73
74 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
75 if (daemon != NULL)
76 g_signal_emit_by_name (daemon, "event", event_dict);
77}
78
79static void
80syncdaemon_events_interface_init (SyncdaemonEventsInterface *interface)
81{
82 interface->priv = g_new0 (SyncdaemonEventsInterfacePrivate, 1);
83
84 /* Setup DBus proxy */
85 interface->priv->proxy = syncdaemon_interface_setup_proxy (SYNCDAEMON_INTERFACE (interface),
86 "com.ubuntuone.SyncDaemon",
87 "/events", "com.ubuntuone.SyncDaemon.Events");
88 if (interface->priv->proxy != NULL) {
89 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "Event",
90 dbus_g_type_get_map ("GHashTable",
91 G_TYPE_STRING,
92 G_TYPE_STRING),
93 G_TYPE_INVALID);
94 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "Event",
95 G_CALLBACK (event_cb), interface, NULL);
96 }
97}
98
99/**
100 * syncdaemon_events_interface_new:
101 */
102SyncdaemonEventsInterface *
103syncdaemon_events_interface_new (SyncdaemonDaemon *daemon)
104{
105 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
106
107 return g_object_new (SYNCDAEMON_TYPE_EVENTS_INTERFACE, "daemon", daemon, NULL);
108}
109
110/**
111 * syncdaemon_events_interface_push_event:
112 */
113void
114syncdaemon_events_interface_push_event (SyncdaemonEventsInterface *interface,
115 const gchar *event_name,
116 const gchar **args)
117{
118 GError *error = NULL;
119
120 g_return_if_fail (SYNCDAEMON_IS_EVENTS_INTERFACE (interface));
121
122 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "push_event", &error,
123 G_TYPE_STRING, event_name,
124 G_TYPE_STRV, args,
125 G_TYPE_INVALID,
126 G_TYPE_INVALID)) {
127 g_warning ("Failed calling push_event: %s", error->message);
128 g_error_free (error);
129 }
130}
1310
=== removed file 'libsyncdaemon/syncdaemon-events-interface.h'
--- libsyncdaemon/syncdaemon-events-interface.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-events-interface.h 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_EVENTS_INTERFACE_H__
36#define __SYNCDAEMON_EVENTS_INTERFACE_H__
37
38#include "syncdaemon-daemon.h"
39#include "syncdaemon-interface.h"
40
41G_BEGIN_DECLS
42
43#define SYNCDAEMON_TYPE_EVENTS_INTERFACE (syncdaemon_events_interface_get_type ())
44#define SYNCDAEMON_EVENTS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_EVENTS_INTERFACE, SyncdaemonEventsInterface))
45#define SYNCDAEMON_IS_EVENTS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_EVENTS_INTERFACE))
46#define SYNCDAEMON_EVENTS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_EVENTS_INTERFACE, SyncdaemonEventsInterfaceClass))
47#define SYNCDAEMON_IS_EVENTS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_EVENTS_INTERFACE))
48#define SYNCDAEMON_EVENTS_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_EVENTS_INTERFACE, SyncdaemonEventsInterfaceClass))
49
50typedef struct _SyncdaemonEventsInterfacePrivate SyncdaemonEventsInterfacePrivate;
51
52typedef struct {
53 SyncdaemonInterface parent;
54 SyncdaemonEventsInterfacePrivate *priv;
55} SyncdaemonEventsInterface;
56
57typedef struct {
58 SyncdaemonInterfaceClass parent_class;
59} SyncdaemonEventsInterfaceClass;
60
61GType syncdaemon_events_interface_get_type (void);
62
63SyncdaemonEventsInterface *syncdaemon_events_interface_new (SyncdaemonDaemon *daemon);
64
65void syncdaemon_events_interface_push_event (SyncdaemonEventsInterface *interface,
66 const gchar *event_name,
67 const gchar **args);
68
69G_END_DECLS
70
71#endif
720
=== removed file 'libsyncdaemon/syncdaemon-file-info.c'
--- libsyncdaemon/syncdaemon-file-info.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-file-info.c 1970-01-01 00:00:00 +0000
@@ -1,236 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "syncdaemon-file-info.h"
36
37G_DEFINE_TYPE(SyncdaemonFileInfo, syncdaemon_file_info, G_TYPE_OBJECT)
38
39struct _SyncdaemonFileInfoPrivate {
40 gchar *volume_id;
41 gchar *node_id;
42 gchar *public_url;
43 gchar *path;
44 gboolean is_public;
45};
46
47static void
48syncdaemon_file_info_finalize (GObject *object)
49{
50 SyncdaemonFileInfo *finfo = SYNCDAEMON_FILE_INFO (object);
51
52 if (finfo->priv != NULL) {
53 if (finfo->priv->volume_id != NULL)
54 g_free (finfo->priv->volume_id);
55
56 if (finfo->priv->node_id != NULL)
57 g_free (finfo->priv->node_id);
58
59 if (finfo->priv->public_url != NULL)
60 g_free (finfo->priv->public_url);
61
62 if (finfo->priv->path != NULL)
63 g_free (finfo->priv->path);
64
65 g_free (finfo->priv);
66 }
67
68 G_OBJECT_CLASS (syncdaemon_file_info_parent_class)->finalize (object);
69}
70
71static void
72syncdaemon_file_info_class_init (SyncdaemonFileInfoClass *klass)
73{
74 GObjectClass *object_class = G_OBJECT_CLASS (klass);
75
76 object_class->finalize = syncdaemon_file_info_finalize;
77}
78
79static void
80syncdaemon_file_info_init (SyncdaemonFileInfo *finfo)
81{
82 finfo->priv = g_new0 (SyncdaemonFileInfoPrivate, 1);
83}
84
85/**
86 * syncdaemon_file_info_new:
87 */
88SyncdaemonFileInfo *
89syncdaemon_file_info_new (void)
90{
91 return g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL);
92}
93
94/**
95 * syncdaemon_file_info_new_from_hash_table:
96 */
97SyncdaemonFileInfo *
98syncdaemon_file_info_new_from_hash_table (GHashTable *hash)
99{
100 SyncdaemonFileInfo *finfo;
101
102 finfo = g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL);
103 if (hash != NULL) {
104 syncdaemon_file_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id"));
105 syncdaemon_file_info_set_node_id (finfo, g_hash_table_lookup (hash, "node_id"));
106 syncdaemon_file_info_set_public_url (finfo, g_hash_table_lookup (hash, "public_url"));
107 syncdaemon_file_info_set_path (finfo, g_hash_table_lookup (hash, "path"));
108 syncdaemon_file_info_set_is_public (
109 finfo,
110 g_strcmp0 (g_hash_table_lookup (hash, "is_public"), "True") == 0);
111 }
112
113 return finfo;
114}
115
116/**
117 * syncdaemon_file_info_get_volume_id:
118 */
119const gchar *
120syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo)
121{
122 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
123
124 return (const gchar *) finfo->priv->volume_id;
125}
126
127/**
128 * syncdaemon_file_info_set_volume_id:
129 */
130void
131syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id)
132{
133 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
134
135 if (finfo->priv->volume_id != NULL)
136 g_free (finfo->priv->volume_id);
137
138 finfo->priv->volume_id = g_strdup (volume_id);
139}
140
141/**
142 * syncdaemon_file_info_get_node_id:
143 */
144const gchar *
145syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo)
146{
147 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
148
149 return (const gchar *) finfo->priv->node_id;
150}
151
152/**
153 * syncdaemon_file_info_set_node_id:
154 */
155void
156syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id)
157{
158 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
159
160 if (finfo->priv->node_id != NULL)
161 g_free (finfo->priv->node_id);
162
163 finfo->priv->node_id = g_strdup (node_id);
164}
165
166/**
167 * syncdaemon_file_info_get_public_url:
168 */
169const gchar *
170syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo)
171{
172 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
173
174 return (const gchar *) finfo->priv->public_url;
175}
176
177/**
178 * syncdaemon_file_info_set_public_url:
179 */
180void
181syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url)
182{
183 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
184
185 if (finfo->priv->public_url != NULL)
186 g_free (finfo->priv->public_url);
187
188 finfo->priv->public_url = g_strdup (public_url);
189}
190
191/**
192 * syncdaemon_file_info_get_path:
193 */
194const gchar *
195syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo)
196{
197 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
198
199 return (const gchar *) finfo->priv->path;
200}
201
202/**
203 * syncdaemon_file_info_set_path:
204 */
205void
206syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path)
207{
208 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
209
210 if (finfo->priv->path != NULL)
211 g_free (finfo->priv->path);
212
213 finfo->priv->path = g_strdup (path);
214}
215
216/**
217 * syncdaemon_file_info_get_is_public:
218 */
219gboolean
220syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo)
221{
222 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), FALSE);
223
224 return finfo->priv->is_public;
225}
226
227/**
228 * syncdaemon_file_info_set_is_public:
229 */
230void
231syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public)
232{
233 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
234
235 finfo->priv->is_public = is_public;
236}
2370
=== removed file 'libsyncdaemon/syncdaemon-file-info.h'
--- libsyncdaemon/syncdaemon-file-info.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-file-info.h 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_FILE_INFO_H__
36#define __SYNCDAEMON_FILE_INFO_H__
37
38#include <glib-object.h>
39
40G_BEGIN_DECLS
41
42#define SYNCDAEMON_TYPE_FILE_INFO (syncdaemon_file_info_get_type ())
43#define SYNCDAEMON_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfo))
44#define SYNCDAEMON_IS_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FILE_INFO))
45#define SYNCDAEMON_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass))
46#define SYNCDAEMON_IS_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FILE_INFO))
47#define SYNCDAEMON_FILE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass))
48
49typedef struct _SyncdaemonFileInfoPrivate SyncdaemonFileInfoPrivate;
50
51typedef struct {
52 GObject parent;
53 SyncdaemonFileInfoPrivate *priv;
54} SyncdaemonFileInfo;
55
56typedef struct {
57 GObjectClass parent_class;
58} SyncdaemonFileInfoClass;
59
60GType syncdaemon_file_info_get_type (void);
61SyncdaemonFileInfo *syncdaemon_file_info_new (void);
62SyncdaemonFileInfo *syncdaemon_file_info_new_from_hash_table (GHashTable *hash);
63
64const gchar *syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo);
65void syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id);
66const gchar *syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo);
67void syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id);
68const gchar *syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo);
69void syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path);
70
71gboolean syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo);
72void syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public);
73const gchar *syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo);
74void syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url);
75
76G_END_DECLS
77
78#endif
790
=== removed file 'libsyncdaemon/syncdaemon-filesystem-interface.c'
--- libsyncdaemon/syncdaemon-filesystem-interface.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-filesystem-interface.c 1970-01-01 00:00:00 +0000
@@ -1,190 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#ifdef HAVE_GDBUS
37#else
38#include <dbus/dbus-glib.h>
39#endif
40#include "syncdaemon-filesystem-interface.h"
41
42G_DEFINE_TYPE(SyncdaemonFilesystemInterface, syncdaemon_filesystem_interface, SYNCDAEMON_TYPE_INTERFACE)
43
44struct _SyncdaemonFilesystemInterfacePrivate {
45 GObject *proxy;
46};
47
48static void
49syncdaemon_filesystem_interface_finalize (GObject *object)
50{
51 SyncdaemonFilesystemInterface *interface = SYNCDAEMON_FILESYSTEM_INTERFACE (object);
52
53 if (interface->priv != NULL) {
54 g_free (interface->priv);
55 }
56
57 G_OBJECT_CLASS (syncdaemon_filesystem_interface_parent_class)->finalize (object);
58}
59
60static void
61syncdaemon_filesystem_interface_class_init (SyncdaemonFilesystemInterfaceClass *klass)
62{
63 GObjectClass *object_class = G_OBJECT_CLASS (klass);
64
65 object_class->finalize = syncdaemon_filesystem_interface_finalize;
66}
67
68static void
69syncdaemon_filesystem_interface_init (SyncdaemonFilesystemInterface *interface)
70{
71 interface->priv = g_new0 (SyncdaemonFilesystemInterfacePrivate, 1);
72
73 /* Setup DBus proxy */
74 interface->priv->proxy = syncdaemon_interface_setup_proxy (SYNCDAEMON_INTERFACE (interface),
75 "com.ubuntuone.SyncDaemon",
76 "/filesystem", "com.ubuntuone.SyncDaemon.FileSystem");
77}
78
79/**
80 * syncdaemon_filesystem_interface_new:
81 */
82SyncdaemonFilesystemInterface *
83syncdaemon_filesystem_interface_new (SyncdaemonDaemon *daemon)
84{
85 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
86
87 return g_object_new (SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE, "daemon", daemon, NULL);
88}
89
90/**
91 * syncdaemon_filesystem_interface_get_metadata:
92 */
93SyncdaemonMetadata *
94syncdaemon_filesystem_interface_get_metadata (SyncdaemonFilesystemInterface *interface,
95 const gchar *path,
96 gboolean with_subtree_sync_check)
97{
98 GError *error = NULL;
99 GHashTable *hash;
100 const char *method;
101
102 g_return_val_if_fail (SYNCDAEMON_IS_FILESYSTEM_INTERFACE (interface), NULL);
103
104 if (with_subtree_sync_check)
105 method = "get_metadata_and_quick_tree_synced";
106 else
107 method = "get_metadata";
108
109 if (!dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), method, &error,
110 G_TYPE_STRING, path,
111 G_TYPE_INVALID,
112 dbus_g_type_get_map ("GHashTable",
113 G_TYPE_STRING,
114 G_TYPE_STRING), &hash,
115 G_TYPE_INVALID)) {
116 g_warning ("Failed calling %s: %s", method, error->message);
117 g_error_free (error);
118
119 return NULL;
120 }
121
122 return syncdaemon_metadata_new_from_hash_table (hash);
123}
124
125typedef struct {
126 SyncdaemonFilesystemInterface *interface;
127 SyncdaemonGotMetadataFunc callback;
128 gpointer user_data;
129} GotMetadataData;
130
131static void
132got_metadata_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
133{
134 GHashTable *hash;
135 GError *error = NULL;
136 GotMetadataData *gmd = (GotMetadataData *) user_data;
137
138 if (dbus_g_proxy_end_call (proxy, call_id, &error,
139 dbus_g_type_get_map ("GHashTable",
140 G_TYPE_STRING,
141 G_TYPE_STRING), &hash,
142 G_TYPE_INVALID)) {
143 SyncdaemonMetadata *metadata;
144
145 metadata = syncdaemon_metadata_new_from_hash_table (hash);
146 gmd->callback (gmd->interface, TRUE, metadata, gmd->user_data);
147
148 /* Free memory */
149 g_object_unref (G_OBJECT (metadata));
150 g_hash_table_destroy (hash);
151 } else {
152 g_warning ("Error getting metadata: %s", error->message);
153 g_error_free (error);
154 gmd->callback (gmd->interface, FALSE, NULL, gmd->user_data);
155 }
156
157 g_free (gmd);
158}
159
160/**
161 * syncdaemon_filesystem_interface_get_metadata_async:
162 */
163void
164syncdaemon_filesystem_interface_get_metadata_async (SyncdaemonFilesystemInterface *interface,
165 const gchar *path,
166 gboolean with_subtree_sync_check,
167 SyncdaemonGotMetadataFunc callback,
168 gpointer user_data)
169{
170 GotMetadataData *gmd;
171 const gchar *method;
172
173 g_return_if_fail (SYNCDAEMON_IS_FILESYSTEM_INTERFACE (interface));
174
175 if (with_subtree_sync_check)
176 method = "get_metadata_and_quick_tree_synced";
177 else
178 method = "get_metadata";
179
180 gmd = g_new0 (GotMetadataData, 1);
181 gmd->interface = interface;
182 gmd->callback = callback;
183 gmd->user_data = user_data;
184
185 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy),
186 method,
187 got_metadata_cb, gmd, NULL,
188 G_TYPE_STRING, path,
189 G_TYPE_INVALID);
190}
1910
=== removed file 'libsyncdaemon/syncdaemon-filesystem-interface.h'
--- libsyncdaemon/syncdaemon-filesystem-interface.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-filesystem-interface.h 1970-01-01 00:00:00 +0000
@@ -1,84 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_FILESYSTEM_INTERFACE_H__
36#define __SYNCDAEMON_FILESYSTEM_INTERFACE_H__
37
38#include "syncdaemon-daemon.h"
39#include "syncdaemon-interface.h"
40#include "syncdaemon-metadata.h"
41
42G_BEGIN_DECLS
43
44#define SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE (syncdaemon_filesystem_interface_get_type ())
45#define SYNCDAEMON_FILESYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE, SyncdaemonFilesystemInterface))
46#define SYNCDAEMON_IS_FILESYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE))
47#define SYNCDAEMON_FILESYSTEM_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE, SyncdaemonFilesystemInterfaceClass))
48#define SYNCDAEMON_IS_FILESYSTEM_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE))
49#define SYNCDAEMON_FILESYSTEM_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FILESYSTEM_INTERFACE, SyncdaemonFilesystemInterfaceClass))
50
51typedef struct _SyncdaemonFilesystemInterfacePrivate SyncdaemonFilesystemInterfacePrivate;
52
53typedef struct {
54 SyncdaemonInterface parent;
55 SyncdaemonFilesystemInterfacePrivate *priv;
56} SyncdaemonFilesystemInterface;
57
58typedef struct {
59 SyncdaemonInterfaceClass parent_class;
60} SyncdaemonFilesystemInterfaceClass;
61
62GType syncdaemon_filesystem_interface_get_type (void);
63
64SyncdaemonFilesystemInterface *syncdaemon_filesystem_interface_new (SyncdaemonDaemon *daemon);
65
66SyncdaemonMetadata *syncdaemon_filesystem_interface_get_metadata (SyncdaemonFilesystemInterface *interface,
67 const gchar *path,
68 gboolean with_subtree_sync_check);
69
70typedef void (* SyncdaemonGotMetadataFunc) (SyncdaemonFilesystemInterface *interface,
71 gboolean success,
72 SyncdaemonMetadata *metadata,
73 gpointer user_data);
74
75void syncdaemon_filesystem_interface_get_metadata_async (SyncdaemonFilesystemInterface *interface,
76 const gchar *path,
77 gboolean with_subtree_sync_check,
78 SyncdaemonGotMetadataFunc callback,
79 gpointer user_data);
80
81
82G_END_DECLS
83
84#endif
850
=== removed file 'libsyncdaemon/syncdaemon-folder-info.c'
--- libsyncdaemon/syncdaemon-folder-info.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-folder-info.c 1970-01-01 00:00:00 +0000
@@ -1,176 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "syncdaemon-folder-info.h"
36
37G_DEFINE_TYPE(SyncdaemonFolderInfo, syncdaemon_folder_info, G_TYPE_OBJECT)
38
39struct _SyncdaemonFolderInfoPrivate {
40 gchar *path;
41 gboolean subscribed;
42 gchar *volume_id;
43};
44
45static void
46syncdaemon_folder_info_finalize (GObject *object)
47{
48 SyncdaemonFolderInfo *finfo = SYNCDAEMON_FOLDER_INFO (object);
49
50 if (finfo->priv != NULL) {
51 if (finfo->priv->path != NULL)
52 g_free (finfo->priv->path);
53
54 if (finfo->priv->volume_id != NULL)
55 g_free (finfo->priv->volume_id);
56
57 g_free (finfo->priv);
58 }
59
60 G_OBJECT_CLASS (syncdaemon_folder_info_parent_class)->finalize (object);
61}
62
63static void
64syncdaemon_folder_info_class_init (SyncdaemonFolderInfoClass *klass)
65{
66 GObjectClass *object_class = G_OBJECT_CLASS (klass);
67
68 object_class->finalize = syncdaemon_folder_info_finalize;
69}
70
71static void
72syncdaemon_folder_info_init (SyncdaemonFolderInfo *finfo)
73{
74 finfo->priv = g_new0 (SyncdaemonFolderInfoPrivate, 1);
75}
76
77/**
78 * syncdaemon_folder_info_new:
79 */
80SyncdaemonFolderInfo *
81syncdaemon_folder_info_new (void)
82{
83 return g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
84}
85
86/**
87 * syncdaemon_folder_info_new_from_hash_table:
88 */
89SyncdaemonFolderInfo *
90syncdaemon_folder_info_new_from_hash_table (GHashTable *hash)
91{
92 SyncdaemonFolderInfo *finfo;
93
94 finfo = g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
95 if (hash != NULL) {
96 syncdaemon_folder_info_set_path (finfo, g_hash_table_lookup (hash, "path"));
97 syncdaemon_folder_info_set_subscribed (
98 finfo,
99 g_strcmp0 (g_hash_table_lookup (hash, "subscribed"), "True") == 0);
100 syncdaemon_folder_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id"));
101 }
102
103 return finfo;
104}
105
106/**
107 * syncdaemon_folder_info_get_path:
108 */
109const gchar *
110syncdaemon_folder_info_get_path (SyncdaemonFolderInfo *finfo)
111{
112 g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
113
114 return (const gchar *) finfo->priv->path;
115}
116
117/**
118 * syncdaemon_folder_info_set_path:
119 */
120void
121syncdaemon_folder_info_set_path (SyncdaemonFolderInfo *finfo, const gchar *path)
122{
123 g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
124
125 if (finfo->priv->path != NULL)
126 g_free (finfo->priv->path);
127
128 finfo->priv->path = g_strdup (path);
129}
130
131/**
132 * syncdaemon_folder_info_get_subscribed:
133 */
134gboolean
135syncdaemon_folder_info_get_subscribed (SyncdaemonFolderInfo *finfo)
136{
137 g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), FALSE);
138
139 return finfo->priv->subscribed;
140}
141
142/**
143 * syncdaemon_folder_info_set_subscribed:
144 */
145void
146syncdaemon_folder_info_set_subscribed (SyncdaemonFolderInfo *finfo, gboolean subscribed)
147{
148 g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
149
150 finfo->priv->subscribed = subscribed;
151}
152
153/**
154 * syncdaemon_folder_info_get_volume_id:
155 */
156const gchar *
157syncdaemon_folder_info_get_volume_id (SyncdaemonFolderInfo *finfo)
158{
159 g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
160
161 return (const gchar *) finfo->priv->volume_id;
162}
163
164/**
165 * syncdaemon_folder_info_set_volume_id:
166 */
167void
168syncdaemon_folder_info_set_volume_id (SyncdaemonFolderInfo *finfo, const gchar *volume_id)
169{
170 g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
171
172 if (finfo->priv->volume_id != NULL)
173 g_free (finfo->priv->volume_id);
174
175 finfo->priv->volume_id = g_strdup (volume_id);
176}
1770
=== removed file 'libsyncdaemon/syncdaemon-folder-info.h'
--- libsyncdaemon/syncdaemon-folder-info.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-folder-info.h 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_FOLDER_INFO_H__
36#define __SYNCDAEMON_FOLDER_INFO_H__
37
38#include <glib-object.h>
39
40G_BEGIN_DECLS
41
42#define SYNCDAEMON_TYPE_FOLDER_INFO (syncdaemon_folder_info_get_type ())
43#define SYNCDAEMON_FOLDER_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FOLDER_INFO, SyncdaemonFolderInfo))
44#define SYNCDAEMON_IS_FOLDER_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FOLDER_INFO))
45#define SYNCDAEMON_FOLDER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FOLDER_INFO, SyncdaemonFolderInfoClass))
46#define SYNCDAEMON_IS_FOLDER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FOLDER_INFO))
47#define SYNCDAEMON_FOLDER_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FOLDER_INFO, SyncdaemonFolderInfoClass))
48
49typedef struct _SyncdaemonFolderInfoPrivate SyncdaemonFolderInfoPrivate;
50
51typedef struct {
52 GObject parent;
53 SyncdaemonFolderInfoPrivate *priv;
54} SyncdaemonFolderInfo;
55
56typedef struct {
57 GObjectClass parent_class;
58} SyncdaemonFolderInfoClass;
59
60GType syncdaemon_folder_info_get_type (void);
61SyncdaemonFolderInfo *syncdaemon_folder_info_new (void);
62SyncdaemonFolderInfo *syncdaemon_folder_info_new_from_hash_table (GHashTable *hash);
63
64const gchar *syncdaemon_folder_info_get_path (SyncdaemonFolderInfo *finfo);
65void syncdaemon_folder_info_set_path (SyncdaemonFolderInfo *finfo, const gchar *path);
66gboolean syncdaemon_folder_info_get_subscribed (SyncdaemonFolderInfo *finfo);
67void syncdaemon_folder_info_set_subscribed (SyncdaemonFolderInfo *finfo, gboolean subscribed);
68const gchar *syncdaemon_folder_info_get_volume_id (SyncdaemonFolderInfo *finfo);
69void syncdaemon_folder_info_set_volume_id (SyncdaemonFolderInfo *finfo, const gchar *volume_id);
70
71G_END_DECLS
72
73#endif
740
=== removed file 'libsyncdaemon/syncdaemon-folders-interface.c'
--- libsyncdaemon/syncdaemon-folders-interface.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-folders-interface.c 1970-01-01 00:00:00 +0000
@@ -1,494 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#include "syncdaemon-folders-interface.h"
37#include "utils.h"
38
39G_DEFINE_TYPE(SyncdaemonFoldersInterface, syncdaemon_folders_interface, SYNCDAEMON_TYPE_INTERFACE)
40
41struct _SyncdaemonFoldersInterfacePrivate {
42 GObject *proxy;
43 GHashTable *folders;
44};
45
46static void
47syncdaemon_folders_interface_finalize (GObject *object)
48{
49 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (object);
50
51 if (interface->priv != NULL) {
52 if (interface->priv->folders != NULL)
53 g_hash_table_destroy (interface->priv->folders);
54
55 g_free (interface->priv);
56 }
57
58 G_OBJECT_CLASS (syncdaemon_folders_interface_parent_class)->finalize (object);
59}
60
61static void
62syncdaemon_folders_interface_class_init (SyncdaemonFoldersInterfaceClass *klass)
63{
64 GObjectClass *object_class = G_OBJECT_CLASS (klass);
65
66 object_class->finalize = syncdaemon_folders_interface_finalize;
67}
68
69static void
70folder_created_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data)
71{
72 SyncdaemonFolderInfo *folder_info;
73 SyncdaemonDaemon *daemon = NULL;
74 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
75
76 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
77
78 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
79
80 /* Update our cache of folders */
81 if (interface->priv->folders != NULL) {
82 g_hash_table_insert (interface->priv->folders,
83 g_strdup (syncdaemon_folder_info_get_path (folder_info)),
84 folder_info);
85
86 if (daemon != NULL)
87 g_signal_emit_by_name (daemon, "folder_created", TRUE, folder_info);
88 } else {
89 if (daemon != NULL)
90 g_signal_emit_by_name (daemon, "folder_created", TRUE, folder_info);
91 g_object_unref (G_OBJECT (folder_info));
92 }
93}
94
95static void
96folder_create_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data)
97{
98 SyncdaemonDaemon *daemon = NULL;
99 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
100
101 /* Notify listeners */
102 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
103 if (daemon != NULL) {
104 SyncdaemonFolderInfo *folder_info;
105
106 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
107 g_signal_emit_by_name (daemon, "folder_created", FALSE, folder_info);
108 g_object_unref (G_OBJECT (folder_info));
109 }
110}
111
112static void
113folder_deleted_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data)
114{
115 SyncdaemonFolderInfo *folder_info;
116 SyncdaemonDaemon *daemon = NULL;
117 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
118
119 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
120
121 /* Notify listeners */
122 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
123 if (daemon != NULL)
124 g_signal_emit_by_name (daemon, "folder_deleted", TRUE, folder_info);
125
126 /* Update our cache of folders */
127 if (interface->priv->folders != NULL)
128 g_hash_table_remove (interface->priv->folders,
129 syncdaemon_folder_info_get_path (folder_info));
130
131 g_object_unref (G_OBJECT (folder_info));
132}
133
134static void
135folder_delete_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data)
136{
137 SyncdaemonFolderInfo *folder_info;
138 SyncdaemonDaemon *daemon = NULL;
139 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
140
141 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
142
143 /* Notify listeners */
144 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
145 if (daemon != NULL)
146 g_signal_emit_by_name (daemon, "folder_deleted", FALSE, folder_info);
147
148 g_object_unref (G_OBJECT (folder_info));
149}
150
151static void
152folder_subscribed_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data)
153{
154 SyncdaemonFolderInfo *folder_info;
155 SyncdaemonDaemon *daemon = NULL;
156 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
157
158 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
159
160 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
161 if (daemon != NULL)
162 g_signal_emit_by_name (daemon, "folder_subscribed", TRUE, folder_info);
163
164 if (interface->priv->folders != NULL) {
165 g_hash_table_insert (interface->priv->folders,
166 g_strdup (syncdaemon_folder_info_get_path (folder_info)),
167 folder_info);
168 } else
169 g_object_unref (G_OBJECT (folder_info));
170}
171
172static void
173folder_subscribe_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data)
174{
175 SyncdaemonFolderInfo *folder_info;
176 SyncdaemonDaemon *daemon = NULL;
177 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
178
179 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
180
181 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
182 if (daemon != NULL)
183 g_signal_emit_by_name (daemon, "folder_subscribed", FALSE, folder_info);
184
185 g_object_unref (G_OBJECT (folder_info));
186}
187
188static void
189folder_unsubscribed_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data)
190{
191 SyncdaemonFolderInfo *folder_info;
192 SyncdaemonDaemon *daemon = NULL;
193 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
194
195 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
196
197 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
198 if (daemon != NULL)
199 g_signal_emit_by_name (daemon, "folder_unsubscribed", TRUE, folder_info);
200
201 if (interface->priv->folders != NULL) {
202 g_hash_table_insert (interface->priv->folders,
203 g_strdup (syncdaemon_folder_info_get_path (folder_info)),
204 folder_info);
205 } else
206 g_object_unref (G_OBJECT (folder_info));
207}
208
209static void
210folder_unsubscribe_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data)
211{
212 SyncdaemonFolderInfo *folder_info;
213 SyncdaemonDaemon *daemon = NULL;
214 SyncdaemonFoldersInterface *interface = SYNCDAEMON_FOLDERS_INTERFACE (user_data);
215
216 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
217
218 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
219 if (daemon != NULL)
220 g_signal_emit_by_name (daemon, "folder_unsubscribed", FALSE, folder_info);
221
222 g_object_unref (G_OBJECT (folder_info));
223}
224
225static void
226syncdaemon_folders_interface_init (SyncdaemonFoldersInterface *interface)
227{
228 interface->priv = g_new0 (SyncdaemonFoldersInterfacePrivate, 1);
229
230 /* Setup DBus proxy */
231 interface->priv->proxy = syncdaemon_interface_setup_proxy (SYNCDAEMON_INTERFACE (interface),
232 "com.ubuntuone.SyncDaemon",
233 "/folders", "com.ubuntuone.SyncDaemon.Folders");
234 if (interface->priv->proxy != NULL) {
235 /* Connect to DBus proxy signals */
236 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderCreated",
237 dbus_g_type_get_map ("GHashTable",
238 G_TYPE_STRING,
239 G_TYPE_STRING),
240 G_TYPE_INVALID);
241 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderCreated",
242 G_CALLBACK (folder_created_cb), interface, NULL);
243
244 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderDeleted",
245 dbus_g_type_get_map ("GHashTable",
246 G_TYPE_STRING,
247 G_TYPE_STRING),
248 G_TYPE_INVALID);
249 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderDeleted",
250 G_CALLBACK (folder_deleted_cb), interface, NULL);
251
252 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderSubscribed",
253 dbus_g_type_get_map ("GHashTable",
254 G_TYPE_STRING,
255 G_TYPE_STRING),
256 G_TYPE_INVALID);
257 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderSubscribed",
258 G_CALLBACK (folder_subscribed_cb), interface, NULL);
259
260 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderUnSubscribed",
261 dbus_g_type_get_map ("GHashTable",
262 G_TYPE_STRING,
263 G_TYPE_STRING),
264 G_TYPE_INVALID);
265 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderUnSubscribed",
266 G_CALLBACK (folder_unsubscribed_cb), interface, NULL);
267
268 /* Error signals */
269 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderCreateError",
270 dbus_g_type_get_map ("GHashTable",
271 G_TYPE_STRING,
272 G_TYPE_STRING),
273 G_TYPE_STRING,
274 G_TYPE_INVALID);
275 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderCreateError",
276 G_CALLBACK (folder_create_error_cb), interface, NULL);
277
278 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderDeleteError",
279 dbus_g_type_get_map ("GHashTable",
280 G_TYPE_STRING,
281 G_TYPE_STRING),
282 G_TYPE_STRING,
283 G_TYPE_INVALID);
284 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderDeleteError",
285 G_CALLBACK (folder_delete_error_cb), interface, NULL);
286
287 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderSubscribeError",
288 dbus_g_type_get_map ("GHashTable",
289 G_TYPE_STRING,
290 G_TYPE_STRING),
291 G_TYPE_STRING,
292 G_TYPE_INVALID);
293 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderSubscribeError",
294 G_CALLBACK (folder_subscribe_error_cb), interface, NULL);
295
296 dbus_g_proxy_add_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderUnSubscribeError",
297 dbus_g_type_get_map ("GHashTable",
298 G_TYPE_STRING,
299 G_TYPE_STRING),
300 G_TYPE_STRING,
301 G_TYPE_INVALID);
302 dbus_g_proxy_connect_signal (DBUS_G_PROXY (interface->priv->proxy), "FolderUnSubscribeError",
303 G_CALLBACK (folder_unsubscribe_error_cb), interface, NULL);
304 }
305}
306
307/**
308 * syncdaemon_folders_interface_new:
309 */
310SyncdaemonFoldersInterface *
311syncdaemon_folders_interface_new (SyncdaemonDaemon *daemon)
312{
313 g_return_val_if_fail (SYNCDAEMON_IS_DAEMON (daemon), NULL);
314
315 return g_object_new (SYNCDAEMON_TYPE_FOLDERS_INTERFACE, "daemon", daemon, NULL);
316}
317
318/**
319 * syncdaemon_folders_interface_create:
320 */
321void
322syncdaemon_folders_interface_create (SyncdaemonFoldersInterface *interface, const gchar *path)
323{
324 g_return_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface));
325 g_return_if_fail (path != NULL);
326
327 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create",
328 no_output_dbus_call_ended_cb, interface, NULL,
329 G_TYPE_STRING, path,
330 G_TYPE_INVALID);
331}
332
333/**
334 * syncdaemon_folders_interface_delete:
335 */
336void
337syncdaemon_folders_interface_delete (SyncdaemonFoldersInterface *interface, const gchar *folder_id)
338{
339 g_return_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface));
340 g_return_if_fail (folder_id != NULL);
341
342 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "delete",
343 no_output_dbus_call_ended_cb, interface, NULL,
344 G_TYPE_STRING, folder_id,
345 G_TYPE_INVALID);
346}
347
348/**
349 * syncdaemon_folders_interface_get_folders:
350 *
351 * Return value: A GSList of #SyncdaemonFolderInfo containing all the folders being
352 * synchronized by the user. When no longer needed, the list should be freed
353 * by calling g_slist_free.
354 */
355GSList *
356syncdaemon_folders_interface_get_folders (SyncdaemonFoldersInterface *interface)
357{
358 GSList *returned_folders = NULL;
359 GError *error = NULL;
360
361 g_return_val_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface), NULL);
362
363 if (interface->priv->folders != NULL) {
364 GHashTableIter iter;
365 gchar *path;
366 SyncdaemonFolderInfo *folder_info;
367
368 /* If we already got the folders list, no need for an extra DBus call */
369 g_hash_table_iter_init (&iter, interface->priv->folders);
370 while (g_hash_table_iter_next (&iter, (gpointer *) &path, (gpointer *) &folder_info))
371 returned_folders = g_slist_append (returned_folders, folder_info);
372 } else {
373 GSList *list;
374
375 if (dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "get_folders", &error,
376 G_TYPE_INVALID,
377 dbus_g_type_get_collection ("GSList",
378 dbus_g_type_get_map
379 ("GHashTable",
380 G_TYPE_STRING,
381 G_TYPE_STRING)), &list,
382 G_TYPE_INVALID)) {
383 GSList *l;
384
385 /* Add the folders to our live-updating list */
386 interface->priv->folders = g_hash_table_new_full (g_str_hash, g_str_equal,
387 g_free, g_object_unref);
388 for (l = list; l != NULL; l = l->next) {
389 SyncdaemonFolderInfo *folder_info;
390
391 folder_info = syncdaemon_folder_info_new_from_hash_table (l->data);
392 g_hash_table_insert (interface->priv->folders,
393 g_strdup (g_hash_table_lookup (l->data, "path")),
394 folder_info);
395
396 returned_folders = g_slist_append (returned_folders, folder_info);
397 }
398
399 /* Free memory */
400 g_slist_foreach (list, (GFunc) g_hash_table_destroy, NULL);
401 g_slist_free (list);
402 } else {
403 g_warning ("Error calling get_folders: %s", error->message);
404 g_error_free (error);
405 }
406 }
407
408 return returned_folders;
409}
410
411/**
412 * syncdaemon_folders_interface_get_info:
413 *
414 * Return value: A #SyncdaemonFolderInfo object containing all the information
415 * for the node. When no longer needed, it should be freed by calling
416 * g_object_unref.
417 */
418SyncdaemonFolderInfo *
419syncdaemon_folders_interface_get_info (SyncdaemonFoldersInterface *interface, const gchar *path)
420{
421 SyncdaemonFolderInfo *folder_info = NULL;
422 GError *error = NULL;
423
424 g_return_val_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface), NULL);
425 g_return_val_if_fail (path != NULL, NULL);
426
427 if (interface->priv->folders != NULL) {
428 folder_info = g_hash_table_lookup (interface->priv->folders, path);
429 if (folder_info != NULL)
430 folder_info = g_object_ref (G_OBJECT (folder_info));
431 }
432
433 if (!folder_info) {
434 GHashTable *hash;
435
436 if (dbus_g_proxy_call (DBUS_G_PROXY (interface->priv->proxy), "get_info", &error,
437 G_TYPE_STRING, path,
438 G_TYPE_INVALID,
439 dbus_g_type_get_map ("GHashTable",
440 G_TYPE_STRING,
441 G_TYPE_STRING), &hash,
442 G_TYPE_INVALID)) {
443 folder_info = syncdaemon_folder_info_new_from_hash_table (hash);
444 } else {
445 g_warning ("Error calling get_info: %s", error->message);
446 g_error_free (error);
447 }
448 }
449
450 return folder_info;
451}
452
453/**
454 * syncdaemon_folders_interface_refresh_volumes:
455 */
456void
457syncdaemon_folders_interface_refresh_volumes (SyncdaemonFoldersInterface *interface)
458{
459 g_return_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface));
460
461 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "refresh_volumes",
462 no_output_dbus_call_ended_cb, interface, NULL,
463 G_TYPE_INVALID);
464}
465
466/**
467 * syncdaemon_folders_interface_subscribe:
468 */
469void
470syncdaemon_folders_interface_subscribe (SyncdaemonFoldersInterface *interface, const gchar *folder_id)
471{
472 g_return_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface));
473 g_return_if_fail (folder_id != NULL);
474
475 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "subscribe",
476 no_output_dbus_call_ended_cb, interface, NULL,
477 G_TYPE_STRING, folder_id,
478 G_TYPE_INVALID);
479}
480
481/**
482 * syncdaemon_folders_interface_unsubscribe:
483 */
484void
485syncdaemon_folders_interface_unsubscribe (SyncdaemonFoldersInterface *interface, const gchar *folder_id)
486{
487 g_return_if_fail (SYNCDAEMON_IS_FOLDERS_INTERFACE (interface));
488 g_return_if_fail (folder_id != NULL);
489
490 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "unsubscribe",
491 no_output_dbus_call_ended_cb, interface, NULL,
492 G_TYPE_STRING, folder_id,
493 G_TYPE_INVALID);
494}
4950
=== removed file 'libsyncdaemon/syncdaemon-folders-interface.h'
--- libsyncdaemon/syncdaemon-folders-interface.h 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-folders-interface.h 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#ifndef __SYNCDAEMON_FOLDERS_INTERFACE_H__
36#define __SYNCDAEMON_FOLDERS_INTERFACE_H__
37
38#include "syncdaemon-daemon.h"
39#include "syncdaemon-folder-info.h"
40#include "syncdaemon-interface.h"
41
42G_BEGIN_DECLS
43
44#define SYNCDAEMON_TYPE_FOLDERS_INTERFACE (syncdaemon_folders_interface_get_type ())
45#define SYNCDAEMON_FOLDERS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FOLDERS_INTERFACE, SyncdaemonFoldersInterface))
46#define SYNCDAEMON_IS_FOLDERS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FOLDERS_INTERFACE))
47#define SYNCDAEMON_FOLDERS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FOLDERS_INTERFACE, SyncdaemonFoldersInterfaceClass))
48#define SYNCDAEMON_IS_FOLDERS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FOLDERS_INTERFACE))
49#define SYNCDAEMON_FOLDERS_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FOLDERS_INTERFACE, SyncdaemonFoldersInterfaceClass))
50
51typedef struct _SyncdaemonFoldersInterfacePrivate SyncdaemonFoldersInterfacePrivate;
52
53typedef struct {
54 SyncdaemonInterface parent;
55 SyncdaemonFoldersInterfacePrivate *priv;
56} SyncdaemonFoldersInterface;
57
58typedef struct {
59 SyncdaemonInterfaceClass parent_class;
60} SyncdaemonFoldersInterfaceClass;
61
62GType syncdaemon_folders_interface_get_type (void);
63
64SyncdaemonFoldersInterface *syncdaemon_folders_interface_new (SyncdaemonDaemon *daemon);
65
66void syncdaemon_folders_interface_create (SyncdaemonFoldersInterface *interface, const gchar *path);
67void syncdaemon_folders_interface_delete (SyncdaemonFoldersInterface *interface, const gchar *folder_id);
68GSList *syncdaemon_folders_interface_get_folders (SyncdaemonFoldersInterface *interface);
69SyncdaemonFolderInfo *syncdaemon_folders_interface_get_info (SyncdaemonFoldersInterface *interface, const gchar *path);
70void syncdaemon_folders_interface_refresh_volumes (SyncdaemonFoldersInterface *interface);
71void syncdaemon_folders_interface_subscribe (SyncdaemonFoldersInterface *interface, const gchar *folder_id);
72void syncdaemon_folders_interface_unsubscribe (SyncdaemonFoldersInterface *interface, const gchar *folder_id);
73
74G_END_DECLS
75
76#endif
770
=== removed file 'libsyncdaemon/syncdaemon-interface.c'
--- libsyncdaemon/syncdaemon-interface.c 2012-04-09 20:07:05 +0000
+++ libsyncdaemon/syncdaemon-interface.c 1970-01-01 00:00:00 +0000
@@ -1,274 +0,0 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010-2012 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * In addition, as a special exception, the copyright holders give
21 * permission to link the code of portions of this program with the
22 * OpenSSL library under certain conditions as described in each
23 * individual source file, and distribute linked combinations
24 * including the two.
25 * You must obey the GNU General Public License in all respects
26 * for all of the code used other than OpenSSL. If you modify
27 * file(s) with this exception, you may extend this exception to your
28 * version of the file(s), but you are not obligated to do so. If you
29 * do not wish to do so, delete this exception statement from your
30 * version. If you delete this exception statement from all source
31 * files in the program, then also delete it here.
32 *
33 */
34
35#include "config.h"
36#ifdef HAVE_GDBUS
37#include <gio/gio.h>
38#else
39#include <dbus/dbus-glib.h>
40#endif
41#include "syncdaemon-daemon.h"
42#include "syncdaemon-interface.h"
43#include "syncdaemon-marshal.h"
44
45G_DEFINE_TYPE(SyncdaemonInterface, syncdaemon_interface, G_TYPE_OBJECT)
46
47struct _SyncdaemonInterfacePrivate {
48 SyncdaemonDaemon *daemon;
49#ifdef HAVE_GDBUS
50 GDBusConnection *bus;
51 GDBusProxy *proxy;
52#else
53 DBusGConnection *bus;
54 DBusGProxy *proxy;
55#endif
56};
57
58enum {
59 PROP_0,
60 PROP_DAEMON
61};
62
63static void
64syncdaemon_interface_finalize (GObject *object)
65{
66 SyncdaemonInterface *interface = SYNCDAEMON_INTERFACE (object);
67
68 if (interface->priv != NULL) {
69 if (interface->priv->proxy != NULL)
70 g_object_unref (G_OBJECT (interface->priv->proxy));
71
72 if (interface->priv->bus != NULL) {
73#ifdef HAVE_GDBUS
74 g_object_unref (G_OBJECT (interface->priv->bus));
75#else
76 dbus_g_connection_unref (interface->priv->bus);
77#endif
78 }
79
80 if (interface->priv->daemon != NULL)
81 g_object_unref (G_OBJECT (interface->priv->daemon));
82
83 g_free (interface->priv);
84 interface->priv = NULL;
85 }
86
87 G_OBJECT_CLASS (syncdaemon_interface_parent_class)->finalize (object);
88}
89
90static void
91syncdaemon_interface_set_property (GObject *object,
92 guint prop_id,
93 const GValue *value,
94 GParamSpec *pspec)
95{
96 SyncdaemonInterface *interface = SYNCDAEMON_INTERFACE (object);
97
98 switch (prop_id) {
99 case PROP_DAEMON:
100 if (interface->priv->daemon != NULL)
101 g_object_unref (G_OBJECT (interface->priv->daemon));
102 interface->priv->daemon = g_object_ref (G_OBJECT (g_value_get_object (value)));
103 break;
104 default:
105 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
106 break;
107 }
108}
109
110static void
111syncdaemon_interface_get_property (GObject *object,
112 guint prop_id,
113 GValue *value,
114 GParamSpec *pspec)
115{
116 SyncdaemonInterface *interface = SYNCDAEMON_INTERFACE (object);
117
118 switch (prop_id) {
119 case PROP_DAEMON:
120 g_value_set_object (value, interface->priv->daemon);
121 break;
122 default:
123 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
124 break;
125 }
126}
127
128static void
129syncdaemon_interface_class_init (SyncdaemonInterfaceClass *klass)
130{
131 GObjectClass *object_class = G_OBJECT_CLASS (klass);
132
133 object_class->finalize = syncdaemon_interface_finalize;
134 object_class->set_property = syncdaemon_interface_set_property;
135 object_class->get_property = syncdaemon_interface_get_property;
136
137 /* Install properties */
138 g_object_class_install_property (object_class,
139 PROP_DAEMON,
140 g_param_spec_object ("daemon",
141 "SyncdaemonDaemon object",
142 "Daemon object from which this interface was created",
143 SYNCDAEMON_TYPE_DAEMON,
144 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
145
146 /* Register DBus marshallers */
147 dbus_g_object_register_marshaller (_syncdaemon_marshal_VOID__STRING_POINTER,
148 G_TYPE_NONE,
149 G_TYPE_STRING,
150 dbus_g_type_get_map ("GHashTable",
151 G_TYPE_STRING,
152 G_TYPE_STRING),
153 G_TYPE_INVALID);
154 dbus_g_object_register_marshaller (_syncdaemon_marshal_VOID__POINTER_STRING,
155 G_TYPE_NONE,
156 dbus_g_type_get_map ("GHashTable",
157 G_TYPE_STRING,
158 G_TYPE_STRING),
159 G_TYPE_STRING,
160 G_TYPE_INVALID);
161}
162
163static void
164syncdaemon_interface_init (SyncdaemonInterface *interface)
165{
166 GError *error = NULL;
167
168 interface->priv = g_new0 (SyncdaemonInterfacePrivate, 1);
169
170 /* Initialize DBus */
171#ifdef HAVE_GDBUS
172 interface->priv->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
173#else
174 interface->priv->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
175#endif
176 if (error != NULL) {
177 g_warning ("Couldn't get session bus: %s", error->message);
178 g_error_free (error);
179 }
180}
181
182static void
183#ifdef HAVE_GDBUS
184#else
185signal_error_cb (DBusGProxy *proxy, const gchar *signal, GHashTable *extra_args, gpointer user_data)
186#endif
187{
188 SyncdaemonInterface *interface = SYNCDAEMON_INTERFACE (user_data);
189
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches