aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/pas/pas-backend-file.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@src.gnome.org>2000-05-17 01:50:28 +0800
committerChris Toshok <toshok@src.gnome.org>2000-05-17 01:50:28 +0800
commitd6db70c32dafe0acde40893893d37eb05564967c (patch)
treefa4f7e1bb16ff35f4a8ec231a6157aa30a763c09 /addressbook/backend/pas/pas-backend-file.c
parentf8cb586400f551b3ade8594890a6ffdd991ae673 (diff)
downloadgsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.gz
gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.zst
gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.zip
add typedefs for the can_write functions, and add parameters to
* backend/pas/pas-book.h: add typedefs for the can_write functions, and add parameters to pas_book_new. * backend/pas/pas-book.c (pas_book_construct): add can_write/can_write_card params. (pas_book_new): same. (impl_Evolution_Book_can_write): new function. (impl_Evolution_Book_can_write_card): same. (pas_book_get_epv): assign the can_write/can_write_card slots in the epv. * backend/pas/pas-backend-ldap.c (pas_backend_ldap_can_write): new function. (pas_backend_ldap_can_write_card): same. (pas_backend_ldap_add_client): add can_write/can_write_card to pas_book_new call. * backend/pas/pas-backend-file.c (pas_backend_file_can_write_card): new function, calls can_write. (pas_backend_file_can_write): same. (can_write): return TRUE if we can write to the addressbook file. (pas_backend_file_add_client): add can_write/can_write_card to pas_book_new call. * backend/idl/addressbook.idl (Evolution): add can_write and can_write_card permission requests. svn path=/trunk/; revision=3093
Diffstat (limited to 'addressbook/backend/pas/pas-backend-file.c')
-rw-r--r--addressbook/backend/pas/pas-backend-file.c52
1 files changed, 43 insertions, 9 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 9de1b1c421..56a0fd4652 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -8,6 +8,7 @@
#include "config.h"
#include <gtk/gtksignal.h>
+#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#ifdef HAVE_DB_185_H
@@ -816,6 +817,45 @@ pas_backend_file_process_check_connection (PASBackend *backend,
pas_book_report_connection (book, bf->priv->file_db != NULL);
}
+static char *
+pas_backend_file_extract_path_from_uri (const char *uri)
+{
+ g_assert (strncasecmp (uri, "file:", 5) == 0);
+
+ return g_strdup (uri + 5);
+}
+
+static gboolean
+can_write (PASBackend *backend)
+{
+ PASBackendFile *bf = PAS_BACKEND_FILE (backend);
+ char *path = pas_backend_file_extract_path_from_uri (bf->priv->uri);
+ gboolean retval;
+
+ retval = (access (path, W_OK) != -1);
+
+ g_free (path);
+
+ return retval;
+}
+
+static gboolean
+pas_backend_file_can_write (PASBook *book)
+{
+ PASBackend* backend = pas_book_get_backend (book);
+
+ return can_write(backend);
+}
+
+static gboolean
+pas_backend_file_can_write_card (PASBook *book,
+ const char *id)
+{
+ PASBackend* backend = pas_book_get_backend (book);
+
+ return can_write(backend);
+}
+
static void
pas_backend_file_process_client_requests (PASBook *book)
{
@@ -895,14 +935,6 @@ pas_backend_file_get_vcard (PASBook *book, const char *id)
}
}
-static char *
-pas_backend_file_extract_path_from_uri (const char *uri)
-{
- g_assert (strncasecmp (uri, "file:", 5) == 0);
-
- return g_strdup (uri + 5);
-}
-
static gboolean
pas_backend_file_upgrade_db (PASBackendFile *bf, char *old_version)
{
@@ -1033,7 +1065,9 @@ pas_backend_file_add_client (PASBackend *backend,
book = pas_book_new (
backend, listener,
- pas_backend_file_get_vcard);
+ pas_backend_file_get_vcard,
+ pas_backend_file_can_write,
+ pas_backend_file_can_write_card);
if (!book) {
if (!bf->priv->clients)