diff options
author | bertrand <bertrand@helixcode.com> | 2000-03-12 13:09:43 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 2000-03-12 13:09:43 +0800 |
commit | f669ff481f57cf5b609ea2e8fe30cfb8dece8587 (patch) | |
tree | e0b812f92689476aed9751bfda46b3071af159a5 /shell/e-service.c | |
parent | 679fa9316ef0cfb3fea44adeb4ab4a7795ae71ed (diff) | |
download | gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar.gz gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar.bz2 gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar.lz gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar.xz gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.tar.zst gsoc2013-evolution-f669ff481f57cf5b609ea2e8fe30cfb8dece8587.zip |
add a field refering to a service associated to the efolder. In the case
2000-03-12 bertrand <bertrand@helixcode.com>
* shell/e-folder.h: add a field refering to a
service associated to the efolder. In the case of
distant folders, it is generally a server.
* shell/e-service.c: New class. Models a service.
A service is an object with an URI and a root folder.
It genreally reporesents a distant folder.
A service is generally a ressource shared amongst
several folders.
* shell/e-service.h:
2000-03-10 bertrand <bertrand@helixcode.com>
* camel-service.h: cosmetic changes.
svn path=/trunk/; revision=2100
Diffstat (limited to 'shell/e-service.c')
-rw-r--r-- | shell/e-service.c | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/shell/e-service.c b/shell/e-service.c new file mode 100644 index 0000000000..f567487ef4 --- /dev/null +++ b/shell/e-service.c @@ -0,0 +1,242 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * e-service.c: Abstract class for Evolution services + * + * Author: + * Bertrand Guiheneuf (bg@aful.org) + * Miguel de Icaza (miguel@helixcode.com) + * + * (C) 2000 Helix Code, Inc. + */ + +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + + + + +#include <config.h> +#include <libgnome/libgnome.h> +#include "e-util/e-util.h" +#include "e-service.h" + +#define PARENT_TYPE gtk_object_get_type () + +static GtkObjectClass *parent_class; + +#define EFC(o) E_SERVICE_CLASS (GTK_OBJECT (o)->klass) + + + +static void +e_service_destroy (GtkObject *object) +{ + EService *eservice = E_SERVICE (object); + + if (eservice->uri) + g_free (eservice->uri); + + if (eservice->desc) + g_free (eservice->desc); + + if (eservice->home_page) + g_free (eservice->home_page); + + parent_class->destroy (object); +} + +static void +e_service_class_init (GtkObjectClass *object_class) +{ + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->destroy = e_service_destroy; + + +} + +static void +e_service_init (GtkObject *object) +{ +} + +E_MAKE_TYPE (e_service, "EService", EService, e_service_class_init, e_service_init, PARENT_TYPE) + + +EFolder * +e_service_get_root_efolder (EService *eservice) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + + +} + + + +void +e_service_set_uri (EService *eservice, const char *uri) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + g_return_if_fail (uri != NULL); + + if (eservice->uri) + g_free (eservice->uri); + + eservice->uri = g_strdup (uri); +} + +const char * +e_service_get_uri (EService *eservice) +{ + g_return_val_if_fail (eservice != NULL, NULL); + g_return_val_if_fail (E_IS_SERVICE (eservice), NULL); + + return eservice->uri; +} + +void +e_service_set_description (EService *eservice, const char *desc) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + g_return_if_fail (desc != NULL); + + if (eservice->desc) + g_free (eservice->desc); + + eservice->desc = g_strdup (desc); +} + +const char * +e_service_get_description (EService *eservice) +{ + g_return_val_if_fail (eservice != NULL, NULL); + g_return_val_if_fail (E_IS_SERVICE (eservice), NULL); + + return eservice->desc; +} + +void +e_service_set_home_page (EService *eservice, const char *home_page) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + g_return_if_fail (home_page != NULL); + + if (eservice->home_page) + g_free (eservice->home_page); + + eservice->home_page = g_strdup (home_page); +} + +const char * +e_service_get_home_page (EService *eservice) +{ + g_return_val_if_fail (eservice != NULL, NULL); + g_return_val_if_fail (E_IS_SERVICE (eservice), NULL); + + return eservice->home_page; +} + +const char * +e_service_get_type_name (EService *eservice) +{ + g_return_val_if_fail (eservice != NULL, NULL); + g_return_val_if_fail (E_IS_SERVICE (eservice), NULL); + + switch (eservice->type){ + case E_SERVICE_MAIL: + return _("A service containing mail items"); + + case E_SERVICE_CONTACTS: + return _("A service containing contacts"); + + case E_SERVICE_CALENDAR: + return _("A service containing calendar entries"); + + case E_SERVICE_TASKS: + return _("A service containing tasks"); + + default: + g_assert_not_reached (); + } + + return NULL; +} + +void +e_service_construct (EService *eservice, EServiceType type, + const char *uri, const char *name, + const char *desc, const char *home_page) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + + + /* EServices are self-owned */ + GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (eservice), GTK_FLOATING); + + if (uri) + eservice->uri = g_strdup (uri); + if (name) + eservice->name = g_strdup (name); + if (desc) + eservice->desc = g_strdup (desc); + if (home_page) + eservice->home_page = g_strdup (home_page); + + eservice->type = type; +} + +EService * +e_service_new (EServiceType type, + const char *uri, const char *name, + const char *desc, const char *home_page) +{ + EService *eservice; + + eservice = gtk_type_new (e_service_get_type ()); + + e_service_construct (eservice, type, uri, name, desc, home_page); + return eservice; +} + +const char * +e_service_get_name (EService *eservice) +{ + g_return_val_if_fail (eservice != NULL, NULL); + g_return_val_if_fail (E_IS_SERVICE (eservice), NULL); + + return eservice->name; +} + +void +e_service_set_name (EService *eservice, const char *name) +{ + g_return_if_fail (eservice != NULL); + g_return_if_fail (E_IS_SERVICE (eservice)); + + if (eservice->name) + g_free (eservice->name); + + eservice->name = g_strdup (name); +} + + |