diff options
Diffstat (limited to 'sfshare-daemon')
-rwxr-xr-x | sfshare-daemon/Makefile.am | 5 | ||||
-rwxr-xr-x | sfshare-daemon/data/Makefile.am | 7 | ||||
-rw-r--r-- | sfshare-daemon/src/Makefile | 50 | ||||
-rwxr-xr-x | sfshare-daemon/src/Makefile.am | 6 | ||||
-rw-r--r-- | sfshare-daemon/src/dbus_service.c | 35 | ||||
-rw-r--r-- | sfshare-daemon/src/dbus_service.h | 2 | ||||
-rw-r--r-- | sfshare-daemon/src/samba_share.c | 38 | ||||
-rw-r--r-- | sfshare-daemon/src/samba_share.h | 28 | ||||
-rw-r--r-- | sfshare-daemon/src/sfshare_errors.h | 4 | ||||
-rw-r--r-- | sfshare-daemon/src/sfshared.c | 2 |
10 files changed, 79 insertions, 98 deletions
diff --git a/sfshare-daemon/Makefile.am b/sfshare-daemon/Makefile.am new file mode 100755 index 0000000..834fbb9 --- /dev/null +++ b/sfshare-daemon/Makefile.am @@ -0,0 +1,5 @@ +AUTOMAKE_OPTIONS = foreign + +SUBDIRS = \ + src \ + data diff --git a/sfshare-daemon/data/Makefile.am b/sfshare-daemon/data/Makefile.am new file mode 100755 index 0000000..0e32e00 --- /dev/null +++ b/sfshare-daemon/data/Makefile.am @@ -0,0 +1,7 @@ +#/etc/dbus-1/system.d +dbusconfdir = $(sysconfdir)/dbus-1/system.d/ +dbusconf_DATA = org.fedoraproject.SimpleFileShare.conf + + + +EXTRA_DIST = $(dbusconf_DATA) diff --git a/sfshare-daemon/src/Makefile b/sfshare-daemon/src/Makefile deleted file mode 100644 index b703f87..0000000 --- a/sfshare-daemon/src/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# TEMPORARY MAKEFILE -CXX=gcc - -CXXFLAGS=-Wall `pkg-config --cflags --libs gtk+-2.0 dbus-glib-1 polkit-gtk-1` - - -# objektove soubory -OBJS= dbus_service.o samba_share.o - -all: sfshared - -############################################################################### - -samba_share.o: samba_share.c samba_share.h sfshare_errors.h - $(CXX) $(CXXFLAGS) -c samba_share.c - -dbus_service.o: dbus_service.c dbus_service.h samba_share.h sfshare_errors.h - $(CXX) $(CXXFLAGS) -c dbus_service.c - -sfshared: $(OBJS) - $(CXX) $(OBJS) $(CXXFLAGS) sfshared.c -o sfshared - - -################################################################################ -.PHONY: clean edit install uninstall - -clean: - rm -f *.o - rm -f sfshared - -install: all - cp sfshared /usr/sbin -#### only root can run it - cp ../data/org.fedoraproject.SimpleFileShare.conf /etc/dbus-1/system.d/ -#### only root can run it - cp ../data/org.fedoraproject.SimpleFileShare.policy /usr/share/polkit-1/actions/ -#### only root can run it - cp ../data/org.fedoraproject.SimpleFileShare.service /usr/share/dbus-1/system-services/ - -uninstall: - rm -f /usr/sbin/sfshared - rm -f /etc/dbus-1/system.d/org.fedoraproject.SimpleFileShare.conf - rm -f /usr/share/polkit-1/actions/org.fedoraproject.SimpleFileShare.policy - rm -f /usr/share/dbus-1/system-services/org.fedoraproject.SimpleFileShare.service - - -################################################################################ - -edit: - gvim -p *.h *.cpp diff --git a/sfshare-daemon/src/Makefile.am b/sfshare-daemon/src/Makefile.am new file mode 100755 index 0000000..f4c11a2 --- /dev/null +++ b/sfshare-daemon/src/Makefile.am @@ -0,0 +1,6 @@ +AM_CFLAGS=-Wall @POLKIT_CFLAGS@ @GTK_CFLAGS@ @DBUS_GLIB_CFLAGS@ +AM_LDFLAGS= @POLKIT_LIBS@ @GTK_LIBS@ @DBUS_GLIB_LIBS@ + + +bin_PROGRAMS = sfshared +sfshared_SOURCES = dbus_service.c dbus_service.h samba_share.c sfshared.c dbus_service_glue.h samba_share.h sfshare_errors.h diff --git a/sfshare-daemon/src/dbus_service.c b/sfshare-daemon/src/dbus_service.c index ef986bd..c2f0258 100644 --- a/sfshare-daemon/src/dbus_service.c +++ b/sfshare-daemon/src/dbus_service.c @@ -53,7 +53,6 @@ GType daemon_object_get_type (void); struct DaemonObject { GObject parent; - }; struct DaemonObjectClass @@ -79,6 +78,9 @@ gboolean daemon_delete_share (DaemonObject *obj,const gchar *path, DBusGMethodIn #include "dbus_service_glue.h" +/** +* Return text of Error +*/ gchar * get_error_msg (Error_sfshare err) { @@ -144,7 +146,7 @@ get_error_quark (void) } -/* Return error to context */ +/** Return error to context */ static void send_error (DBusGMethodInvocation *context, gint error_code, @@ -167,7 +169,9 @@ send_error (DBusGMethodInvocation *context, } - +/** +* Create pointer to DaemonData filled with values from parameters +*/ DaemonData * daemon_data_new ( DBusGMethodInvocation *context, AuthorizedCallback auth_cb, const gchar **in) { @@ -191,7 +195,9 @@ daemon_data_new ( DBusGMethodInvocation *context, AuthorizedCallback auth_cb, co return ret; } - +/** +* Free DaemonData pointer +*/ void daemon_data_free (DaemonData * data) { @@ -208,9 +214,9 @@ daemon_data_free (DaemonData * data) } - - - +/** +* PolicyKit callback function +*/ static void check_authorization_cb (PolkitAuthority *authority, GAsyncResult *res, @@ -269,10 +275,13 @@ daemon_object_class_init (DaemonObjectClass *klass) { } +/** +* Handle incomming request - D-Bus get_share_status +*/ gboolean daemon_get_share_status (DaemonObject *obj, const gchar *path, gchar ***result, GError **error) { - puts("daemon_get_share_status"); + /* puts("daemon_get_share_status"); */ Error_sfshare err; @@ -287,7 +296,7 @@ daemon_get_share_status (DaemonObject *obj, const gchar *path, gchar ***result, return TRUE; } -/* +/** * Authorized call of smb_set_share - write or change share section */ void @@ -311,7 +320,7 @@ setup_share_authorized (gpointer data) -/* +/** * Dbus setup share - polkit authorization check */ gboolean @@ -337,7 +346,7 @@ daemon_setup_share (DaemonObject *obj,const gchar **parameters, DBusGMethodInvoc -/* +/** * Authorized call of smb_delete_share - delete share section */ void @@ -360,7 +369,7 @@ delete_share_authorized (gpointer data) } -/* +/** * Dbus delete share - polkit authorization check */ gboolean @@ -389,7 +398,7 @@ daemon_delete_share (DaemonObject *obj, const gchar *path, DBusGMethodInvocation } -/* +/** * Start of sfshare deamon */ int diff --git a/sfshare-daemon/src/dbus_service.h b/sfshare-daemon/src/dbus_service.h index 58fe627..79897a1 100644 --- a/sfshare-daemon/src/dbus_service.h +++ b/sfshare-daemon/src/dbus_service.h @@ -33,7 +33,7 @@ typedef struct } DaemonData; -/* Daemon start */ +/** Daemon start */ int dbus_sfshare_start (); GQuark get_error_quark (void); diff --git a/sfshare-daemon/src/samba_share.c b/sfshare-daemon/src/samba_share.c index 01c91b8..32987bf 100644 --- a/sfshare-daemon/src/samba_share.c +++ b/sfshare-daemon/src/samba_share.c @@ -47,14 +47,14 @@ gchar *smb_conf_path = "/etc/samba/smb.conf"; const gchar *smb_special_section [SECTIONS_COUNT] = {"global", "homes", "printers"}; -/* Send SIGHUP to smb and nmb */ +/** Send SIGHUP to smb and nmb */ void smb_reload_service () { system("killall -HUP smb nmb"); } -/* +/** * Function changes path to smb.conf to path */ void @@ -64,7 +64,7 @@ set_smbconf_path (const gchar *path) } -/* +/** * Save string str as new smb.conf */ gint @@ -100,7 +100,7 @@ write_smbconf (const gchar *content) } -/* +/** * Function free TSmbConfItem from memmory */ void @@ -117,7 +117,7 @@ smbconf_item_free(TSmbConfItem *item) } -/* +/** * Function allocs memory for TSmbConfItem */ TSmbConfItem* @@ -137,7 +137,7 @@ smbconf_item_new0 () } -/* +/** * Function allocs memory for TSmbConfItem */ TSmbConfItem* @@ -162,7 +162,7 @@ smbconf_item_new (const gchar *name, const gchar *path, const gchar *comment, co return ret; } -/* +/** * Function returns new array */ GPtrArray* @@ -173,7 +173,7 @@ shared_items_array_new () } -/* +/** * Destroy array */ void @@ -191,7 +191,7 @@ shared_items_array_free (GPtrArray *array) } -/* +/** * If ok return 0 else return number of error */ gint check_item(TSmbConfItem *item) @@ -210,7 +210,7 @@ gint check_item(TSmbConfItem *item) } -/* +/** * Parse line of smb.conf and fill competent field of item structure */ void @@ -325,7 +325,7 @@ parse_to_share_item (gchar *txt, TSmbConfItem *item) -/* +/** * Funciton loads all share section to array */ gint @@ -417,7 +417,7 @@ load_smb_conf (GPtrArray *shared_items) } -/* +/** * Returns share imte if directory [path] is shared, * if not return NULL; */ @@ -442,7 +442,7 @@ TSmbConfItem } -/* +/** * True if share name exist */ gboolean @@ -463,7 +463,7 @@ share_name_exist (GPtrArray *shared_items, const gchar *sharename) } -/* +/** * Write new share section or change chare section defined by share parameter */ gint @@ -746,7 +746,7 @@ write_share (GPtrArray *shared_items, TSmbConfItem *share) -/* +/** * Function erase shared section containing path from smb.conf * shared_items must by actual! */ @@ -853,7 +853,7 @@ void char_to_strv(const gchar *str, gchar ***ret) } -/* +/** * If path is shared then returns share parameters in result. */ gint @@ -898,7 +898,7 @@ smb_get_share_status (const gchar *path, gchar ***result) } -/* +/** * Write share to smb.conf */ gint @@ -927,8 +927,8 @@ smb_set_share (gchar **parameters) } -/* -* Delete share to smb.conf +/** +* Delete share section from smb.conf */ gint smb_delete_share (gchar **path) diff --git a/sfshare-daemon/src/samba_share.h b/sfshare-daemon/src/samba_share.h index f967126..ae9e34b 100644 --- a/sfshare-daemon/src/samba_share.h +++ b/sfshare-daemon/src/samba_share.h @@ -32,46 +32,50 @@ typedef struct smb_conf_item } TSmbConfItem; -/* Funciton loads all share section to array */ +/** Funciton loads all share section to array */ gint load_smb_conf (GPtrArray *shared_items); -/*Function erase shared section containing path from smb.conf */ +/** Function erase shared section containing path from smb.conf */ gint delete_share (GPtrArray *shared_items, const gchar *path); - +/** Write new share section or change chare section defined by share parameter */ gint write_share (GPtrArray *shared_items, TSmbConfItem *share); - +/** If path is shared then returns share parameters in result. */ gboolean smb_get_share_status (const gchar *path, gchar ***result); + +/** Write or channge section in smb.conf */ gint smb_set_share (gchar **parameters); + +/** Delete share section from smb.conf */ gint smb_delete_share (gchar **path); void item_to_strv (TSmbConfItem *item, gchar ***ret); -/*Function changes path to smb.conf to path */ +/** Function changes path to smb.conf to path */ void set_smbconf_path (const gchar *path); -/*Function returns new array */ +/** Function returns new array */ GPtrArray* shared_items_array_new(); -/*Function destroy Share Items Array */ +/** Function destroy Share Items Array */ void shared_items_array_free (GPtrArray *array); -/*Function allocs memory for TSmbConfItem and sets parameters */ +/** Function allocs memory for TSmbConfItem and sets parameters */ TSmbConfItem* smbconf_item_new (const gchar *name, const gchar *path, const gchar *comment, const gchar *read_only, const gchar *guest_ok); -/*Function allocs memory for TSmbConfItem */ +/** Function allocs memory for TSmbConfItem */ TSmbConfItem* smbconf_item_new0 (); -/*If ok return 0 else return number of error */ +/** If ok return 0 else return number of error */ gint check_item (TSmbConfItem *item); -/*Function free memory */ +/** Function free memory */ void smbconf_item_free (TSmbConfItem *item); -/* Send SIGHUP to smb and nmb */ +/** Send SIGHUP to smb and nmb */ void smb_reload_service (); #endif diff --git a/sfshare-daemon/src/sfshare_errors.h b/sfshare-daemon/src/sfshare_errors.h index 4fe9fc7..6c7bc4b 100644 --- a/sfshare-daemon/src/sfshare_errors.h +++ b/sfshare-daemon/src/sfshare_errors.h @@ -19,7 +19,7 @@ #define SFSHARE_ERRORS_H -/* Types of errors */ +/** Types of errors */ typedef enum { OK, @@ -40,7 +40,7 @@ typedef enum } Error_sfshare; -/* Definition in file: dbus_service.c */ +/** Definition in file: dbus_service.c */ gchar *get_error_msg (Error_sfshare err); #endif diff --git a/sfshare-daemon/src/sfshared.c b/sfshare-daemon/src/sfshared.c index 1c81701..0a2ee3b 100644 --- a/sfshare-daemon/src/sfshared.c +++ b/sfshare-daemon/src/sfshared.c @@ -23,7 +23,7 @@ #include "samba_share.h" #include "dbus_service.h" - +/** Run daemon */ int main() { return dbus_sfshare_start(); |