--- configure.in 2005/05/21 16:29:33 1.1 +++ configure.in 2005/05/21 16:50:52 @@ -60,6 +60,10 @@ fi AC_SUBST(DBUS_SYS_DIR) AC_DEFINE_UNQUOTED(DBUS_SYSTEMD_DIR, "$DBUS_SYS_DIR", [Where system.d dir for DBUS is]) +if pkg-config dbus-1 --atleast-version=0.30 ; then + AC_DEFINE(DBUS_USE_NEW_API, 1, [Whether to use the new API for DBUS 0.30]) +fi + AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) --- src/nautilus-share.c 2005/05/21 16:25:32 1.1 +++ src/nautilus-share.c 2005/05/21 17:11:44 @@ -19,6 +19,10 @@ * (C) Copyright 2005 Ethium, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -727,7 +731,11 @@ nautilus_module_initialize (GTypeModule /* FIXME error */ /* dbus_bus_set_base_service(g_dbus, NAUTILUS_DBUS_SRV); */ +#ifndef DBUS_USE_NEW_API dbus_bus_acquire_service (g_dbus, NAUTILUS_DBUS_SRV, +#else /* DBUS_USE_NEW_API */ + dbus_bus_request_name (g_dbus, NAUTILUS_DBUS_SRV, +#endif /* DBUS_USE_NEW_API */ 0, NULL); dbus_connection_setup_with_g_main (g_dbus, NULL); --- src/smbparser-dbus-client.c 2005/05/21 16:25:12 1.1 +++ src/smbparser-dbus-client.c 2005/05/21 17:11:56 @@ -19,6 +19,10 @@ * (C) Copyright 2005 Ethium, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include @@ -59,8 +63,13 @@ smbparser_dbus_remove_key(DBusConnection return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "RemoveKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, DBUS_TYPE_STRING, key, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, + DBUS_TYPE_STRING, &key, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -77,9 +86,15 @@ smbparser_dbus_set_key(DBusConnection *b return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "SetKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, key, DBUS_TYPE_STRING, value, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &key, + DBUS_TYPE_STRING, &value, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -96,8 +111,13 @@ smbparser_dbus_share_remove_key(DBusConn return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareRemoveKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, key, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &key, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -114,9 +134,15 @@ smbparser_dbus_share_set_key(DBusConnect return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareSetKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, key, DBUS_TYPE_STRING, value, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &key, + DBUS_TYPE_STRING, &value, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -133,7 +159,11 @@ smbparser_dbus_remove_section(DBusConnec return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "RemoveSection"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -150,7 +180,11 @@ smbparser_dbus_share_remove(DBusConnecti return FALSE; message = dbus_message_new_signal (SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareRemove"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_connection_send (bus, message, NULL); dbus_message_unref (message); @@ -171,8 +205,13 @@ smbparser_dbus_rename_section(DBusConnec return FALSE; message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "RenameSection"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, DBUS_TYPE_STRING, newname, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, + DBUS_TYPE_STRING, &newname, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); @@ -206,8 +245,13 @@ smbparser_dbus_share_rename(DBusConnecti return FALSE; message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareRename"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, newname, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &newname, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); @@ -241,7 +285,11 @@ smbparser_dbus_add_section(DBusConnectio return FALSE; message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "AddSection"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -272,8 +320,13 @@ smbparser_dbus_share_add(DBusConnection return FALSE; message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareAdd"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, name, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &name, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -304,7 +357,11 @@ smbparser_dbus_section_used(DBusConnecti return FALSE; message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "SectionUsed"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -337,8 +394,13 @@ smbparser_dbus_get_key(DBusConnection *b message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "GetKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, section, DBUS_TYPE_STRING, key, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, §ion, + DBUS_TYPE_STRING, &key, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -347,7 +409,9 @@ smbparser_dbus_get_key(DBusConnection *b if (dbus_message_get_args (reply, &error_args, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID)) { value = ((dbus_string == NULL) || (strcmp(dbus_string,"")==0) ? NULL : g_strdup (dbus_string)); +#ifndef DBUS_USE_NEW_API dbus_free (dbus_string); +#endif /* ! DBUS_USE_NEW_API */ } else g_print("GetKey error in dbus_message_get_args: %s\n",error_args.message); @@ -377,8 +441,13 @@ smbparser_dbus_share_get_key(DBusConnect message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareGetKey"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, DBUS_TYPE_STRING, key, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, + DBUS_TYPE_STRING, &key, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -387,7 +456,9 @@ smbparser_dbus_share_get_key(DBusConnect if (dbus_message_get_args (reply, &error_args, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID)) { value = ((dbus_string == NULL) || (strcmp(dbus_string,"")==0) ? NULL : g_strdup (dbus_string)); +#ifndef DBUS_USE_NEW_API dbus_free (dbus_string); +#endif /* ! DBUS_USE_NEW_API */ } else g_print("GetKey error in dbus_message_get_args: %s\n",error_args.message); @@ -415,7 +486,11 @@ smbparser_dbus_share_get_name(DBusConnec message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareGetName"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); @@ -425,7 +500,9 @@ smbparser_dbus_share_get_name(DBusConnec if (dbus_message_get_args (reply, &error_args, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID)) { value = ((dbus_string == NULL) || (strcmp(dbus_string,"")==0) ? NULL : g_strdup (dbus_string)); +#ifndef DBUS_USE_NEW_API dbus_free (dbus_string); +#endif /* ! DBUS_USE_NEW_API */ } else g_print("ShareGetName error in dbus_message_get_args: %s\n",error_args.message); @@ -453,7 +530,11 @@ smbparser_dbus_share_is_writable(DBusCon message = dbus_message_new_method_call (SMBPARSER_DBUS_SRV, SMBPARSER_DBUS_PATH, SMBPARSER_DBUS_INTERFACE, "ShareIsWritable"); dbus_message_append_args (message, +#ifndef DBUS_USE_NEW_API DBUS_TYPE_STRING, path, +#else /* DBUS_USE_NEW_API */ + DBUS_TYPE_STRING, &path, +#endif /* DBUS_USE_NEW_API */ DBUS_TYPE_INVALID); dbus_error_init (&error); if((reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &error))) @@ -498,7 +579,11 @@ main (int argc, char **argv) } dbus_error_free (&error); +#ifndef DBUS_USE_NEW_API dbus_bus_acquire_service (bus, NAUTILUS_DBUS_SRV, +#else /* DBUS_USE_NEW_API */ + dbus_bus_request_name (bus, NAUTILUS_DBUS_SRV, +#endif /* DBUS_USE_NEW_API */ 0, NULL); /* Set up this connection to work in a GLib event loop */ dbus_connection_setup_with_g_main (bus, NULL); --- src/smbparser-dbus-server.c 2005/05/21 16:25:15 1.1 +++ src/smbparser-dbus-server.c 2005/05/21 17:12:08 @@ -19,6 +19,10 @@ * (C) Copyright 2005 Ethium, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -195,16 +199,30 @@ path_message_func (DBusConnection *conn if((sharename = smbparser_get_sharename(shares, path))) { value = smbparser_get_key(shares,sharename,key); +#ifdef DBUS_USE_NEW_API + if (!value) + value = ""; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_INFO,"Share Get key %s in section %s -> %s\n", key, sharename,value); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_STRING, value?value:"", DBUS_TYPE_INVALID); +#endif /* ! DBUS_USE_NEW_API */ } else { daemon_log(LOG_ERR,"Share Get key path: %s not found\n",path); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + value = ""; +#endif /* DBUS_USE_NEW_API */ } +#ifndef DBUS_USE_NEW_API dbus_free (path); dbus_free (key); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -235,14 +253,24 @@ path_message_func (DBusConnection *conn if (!(sharename = smbparser_get_sharename(shares, path))) { daemon_log(LOG_ERR,"SGN Sharename path:%s not found\n", path); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + sharename = ""; +#endif /* DBUS_USE_NEW_API */ } else { daemon_log(LOG_INFO,"Path %s is sharename %s\n", path, sharename); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_STRING, sharename, DBUS_TYPE_INVALID); +#endif /* ! DBUS_USE_NEW_API */ } +#ifndef DBUS_USE_NEW_API dbus_free (path); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_STRING, &sharename, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -264,6 +292,9 @@ path_message_func (DBusConnection *conn char *sharename; char *newname; DBusMessage *reply_message = NULL; +#ifdef DBUS_USE_NEW_API + dbus_uint32_t reply_val; +#endif /* DBUS_USE_NEW_API */ dbus_error_init (&error); if (dbus_message_get_args @@ -274,8 +305,15 @@ path_message_func (DBusConnection *conn reply_message = dbus_message_new_method_return (message); if (!(sharename = smbparser_get_sharename(shares, path))) { +#ifdef DBUS_USE_NEW_API + reply_val = 2; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareRename Sharename path:%s not found\n", path); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 2, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } else { @@ -285,25 +323,48 @@ path_message_func (DBusConnection *conn /* FIXME strlen(sharename) et meme modele que ShareAdd */ if(authorized_section(sharename) == FALSE) { +#ifdef DBUS_USE_NEW_API + reply_val = 1; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareRename received, but error: authorized_section\n"); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 1, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } else if(find_sharename(shares,newname)) { +#ifdef DBUS_USE_NEW_API + reply_val = 1; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareRename Sharename already in used: %s\n", newname); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 1, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } else { +#ifdef DBUS_USE_NEW_API + reply_val = 0; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareRename Sharename not in used: %s\n", newname); shares = smbparser_rename_section(shares,sharename,newname); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } } } +#ifndef DBUS_USE_NEW_API dbus_free (path); dbus_free (newname); +#endif /* ! DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -325,6 +386,9 @@ path_message_func (DBusConnection *conn char *name; char *username; DBusMessage *reply_message = NULL; +#ifdef DBUS_USE_NEW_API + dbus_uint32_t reply_val; +#endif /* DBUS_USE_NEW_API */ dbus_error_init (&error); if (!dbus_message_get_args @@ -341,45 +405,89 @@ path_message_func (DBusConnection *conn reply_message = dbus_message_new_method_return (message); if (name && (strlen(name) == 0)) { +#ifdef DBUS_USE_NEW_API + reply_val = 4; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareAdd received, but error: strlen(name) == 0\n"); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 4, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ goto exit; } if (!authorized_section(name)) { +#ifdef DBUS_USE_NEW_API + reply_val = 3; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareAdd received, but error: authorized_section\n"); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 3, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ goto exit; } if (!authorized_path(connection, path)) { +#ifdef DBUS_USE_NEW_API + reply_val = 2; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareAdd received, but error: authorized_path\n"); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 2, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ goto exit; } if(find_sharename(shares,name)) { +#ifdef DBUS_USE_NEW_API + reply_val = 1; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareAdd Name already in used: %s\n", name); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 1, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ goto exit; } if(smbparser_get_sharename(shares, path)) { +#ifdef DBUS_USE_NEW_API + reply_val = 3; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"ShareAdd Path already in used: %s\n", path); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 3, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ goto exit; } if((username = get_nautilus_user(connection))) { +#ifdef DBUS_USE_NEW_API + reply_val = 0; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_INFO,"ShareAdd Name not in used: %s\n", name); shares = smbparser_add_section(shares,name,username); shares = smbparser_set_key(shares,name,"force user", username); shares = smbparser_set_key(shares,name,"path",path); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } exit: +#ifndef DBUS_USE_NEW_API dbus_free (name); dbus_free (path); +#endif /* ! DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -396,6 +504,9 @@ path_message_func (DBusConnection *conn DBusError error; char *sharename; DBusMessage *reply_message = NULL; +#ifdef DBUS_USE_NEW_API + dbus_uint32_t reply_val; +#endif /* DBUS_USE_NEW_API */ dbus_error_init (&error); if (dbus_message_get_args @@ -407,21 +518,44 @@ path_message_func (DBusConnection *conn if(authorized_section(sharename) == FALSE) { +#ifdef DBUS_USE_NEW_API + reply_val = 1; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"SectionUsed received, but error: authorized_section\n"); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 1, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } else if(find_sharename(shares,sharename)) { +#ifdef DBUS_USE_NEW_API + reply_val = 1; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_ERR,"SU Sharename already in used: %s\n", sharename); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 1, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } else { +#ifdef DBUS_USE_NEW_API + reply_val = 0; +#endif /* DBUS_USE_NEW_API */ daemon_log(LOG_INFO,"SU Sharename not in used: %s\n", sharename); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_UINT32, &reply_val, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ } +#ifndef DBUS_USE_NEW_API dbus_free (sharename); +#endif /* ! DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -450,9 +584,15 @@ path_message_func (DBusConnection *conn DBUS_TYPE_INVALID)) { writable = smbparser_sharename_is_writable(shares,path); daemon_log(LOG_INFO,"Path %s -> %d\n", path, writable); +#ifndef DBUS_USE_NEW_API dbus_free (path); +#endif /* ! DBUS_USE_NEW_API */ reply_message = dbus_message_new_method_return (message); +#ifndef DBUS_USE_NEW_API dbus_message_append_args (reply_message, DBUS_TYPE_BOOLEAN, writable, DBUS_TYPE_INVALID); +#else /* DBUS_USE_NEW_API */ + dbus_message_append_args (reply_message, DBUS_TYPE_BOOLEAN, &writable, DBUS_TYPE_INVALID); +#endif /* DBUS_USE_NEW_API */ if (reply_message) { dbus_connection_send (connection, reply_message, NULL); @@ -475,7 +615,11 @@ signal_filter (DBusConnection *connectio { GMainLoop *loop = user_data; +#ifndef DBUS_USE_NEW_API if (dbus_message_is_signal(message, DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL, "Disconnected")) { +#else /* DBUS_USE_NEW_API */ + if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) { +#endif /* DBUS_USE_NEW_API */ g_main_loop_quit (loop); return DBUS_HANDLER_RESULT_HANDLED; } @@ -522,9 +666,11 @@ signal_filter (DBusConnection *connectio else daemon_log(LOG_ERR,"SSK Sharename path:%s not found\n", path); +#ifndef DBUS_USE_NEW_API dbus_free (path); dbus_free (key); dbus_free (value); +#endif /* ! DBUS_USE_NEW_API */ } else { daemon_log(LOG_ERR,"SetKey received, but error getting message: %s\n", error.message); dbus_error_free (&error); @@ -555,8 +701,10 @@ signal_filter (DBusConnection *connectio else daemon_log(LOG_ERR,"SRK Sharename path:%s not found\n", path); +#ifndef DBUS_USE_NEW_API dbus_free (path); dbus_free (key); +#endif /* ! DBUS_USE_NEW_API */ } else { daemon_log(LOG_ERR,"RemoveKey received, but error getting message: %s\n", error.message); dbus_error_free (&error); @@ -584,7 +732,9 @@ signal_filter (DBusConnection *connectio } else daemon_log(LOG_ERR,"SRS Sharename path:%s not found\n", path); +#ifndef DBUS_USE_NEW_API dbus_free (path); +#endif /* ! DBUS_USE_NEW_API */ } else { daemon_log(LOG_ERR,"RemoveSection received, but error getting message: %s\n", error.message); dbus_error_free (&error); --- src/smbshared.c 2005/05/21 16:25:24 1.1 +++ src/smbshared.c 2005/05/21 17:12:17 @@ -19,6 +19,10 @@ * (C) Copyright 2005 Ethium, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -81,7 +85,11 @@ smbshared () dbus_connection_register_object_path(bus,SMBPARSER_DBUS_PATH, &smbparser_vtable, NULL); +#ifndef DBUS_USE_NEW_API dbus_bus_acquire_service (bus, SMBPARSER_DBUS_SRV, +#else /* DBUS_USE_NEW_API */ + dbus_bus_request_name (bus, SMBPARSER_DBUS_SRV, +#endif /* DBUS_USE_NEW_API */ 0, &error); g_main_loop_run (loop);