From: Andrea Zagli Date: Wed, 26 Dec 2012 18:05:37 +0000 (+0100) Subject: Initial import. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=ad39c395e1a91675e7242202e43e9724997015a1;p=libgapp Initial import. --- ad39c395e1a91675e7242202e43e9724997015a1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4b3d41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +*~ +*.rpath +*.pot +*.mo +*.gmo +*.o +*.lo +*.la +*.bak +*.stamp +*.tar.gz +*.pc +*.sed +*.sin +*.header +.libs +.deps +ABOUT-NLS +INSTALL +Makefile +Makefile.in +Makefile.in.in +Makevars +aclocal.m4 +autom4te.cache/ +config.guess +config.log +config.sub +configure +depcomp +gtk-doc.make +install-sh +ltmain.sh +m4/ +missing +config.h +config.status +docs/reference/version.xml +docs/reference/html/ +docs/reference/xml/ +libtool +stamp-h1 +tests/test +POTFILES +mkinstalldirs +stamp-it +intltool-* +Rules-quot +*.exe +*.csv +COPYING +config.h.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ad1de0f --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Andrea Zagli diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..b658aa5 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +SUBDIRS = src tests + +ACLOCAL_AMFLAGS = -I m4 + +EXTRA_DIST = libgapp.pc.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libgapp.pc + +distclean-local: + if test "$(srcdir)" = "."; then :; else \ + rm -f ChangeLog; \ + fi + +ChangeLog: + @echo Creating $@ + @if test -d "$(srcdir)/.git"; then \ + (GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat -M -C --name-status --date=short --no-color) | fmt --split-only > $@.tmp \ + && mv -f $@.tmp $@ \ + || ($(RM) $@.tmp; \ + echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ + (test -f $@ || echo git-log is required to generate this file >> $@)); \ + else \ + test -f $@ || \ + (echo A git checkout and git-log is required to generate ChangeLog >&2 && \ + echo A git checkout and git-log is required to generate this file >> $@); \ + fi + +.PHONY: ChangeLog diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..8f351cd --- /dev/null +++ b/autogen.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="libgapp" + +(test -f $srcdir/configure.ac \ + && test -d $srcdir/src \ + && test -f $srcdir/src/gapp.h) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level libgapp directory" + exit 1 +} + +which gnome-autogen.sh || { + echo "You need to install gnome-common from GNOME and make" + echo "sure the gnome-autogen.sh script is in your \$PATH." + exit 1 +} + +USE_GNOME2_MACROS=1 . gnome-autogen.sh diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..d8ea377 --- /dev/null +++ b/configure.ac @@ -0,0 +1,68 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.65) +AC_INIT([libgapp], [0.0.1], [azagli@libero.it]) +AC_CONFIG_SRCDIR([src/service.c]) +AC_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE(-Wall) + +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + +AM_MAINTAINER_MODE + +AC_CONFIG_MACRO_DIR([m4]) + +AC_CANONICAL_SYSTEM + +LT_INIT + +AC_LIBTOOL_WIN32_DLL + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_LIBTOOL +AC_PROG_RANLIB + +# Checks for libraries. +PKG_CHECK_MODULES(GAPP, [libgfeed >= 0.2.0]) + +AC_SUBST(GAPP_CFLAGS) +AC_SUBST(GAPP_LIBS) + +# Checks for header files. +AC_HEADER_STDC + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +# Checks for library functions. + +# Checks for library functions. + +dnl ****************************** +dnl Check for Operating System +dnl ****************************** + +platform_win32=no + +case "$host" in +*-mingw*) + platform_win32=yes + ;; +esac + +AM_CONDITIONAL(PLATFORM_WIN32, [test $platform_win32 = yes]) + +# Output files +AC_CONFIG_FILES([ + libgapp.pc + Makefile + src/Makefile + tests/Makefile +]) +AC_OUTPUT diff --git a/libgapp.pc.in b/libgapp.pc.in new file mode 100644 index 0000000..5df0eaa --- /dev/null +++ b/libgapp.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: @PACKAGE_NAME@ +Description: Library to manage Atom Publishing Protocol resources. +Version: @PACKAGE_VERSION@ +Requires: libgfeed +Libs: -L${libdir} -lgfeed +Cflags: -I${includedir} diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..74742bd --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,22 @@ +if PLATFORM_WIN32 +WIN32_LIBS=-lwsock32 +else +WIN32_LIBS= +endif + +LIBS = $(GAPP_LIBS) \ + $(WIN32_LIBS) + +AM_CPPFLAGS = $(GAPP_CFLAGS) \ + -DG_LOG_DOMAIN=\"GApp\" + +lib_LTLIBRARIES = libgapp.la + +libgapp_la_SOURCES = service.c + +libgapp_la_LDFLAGS = -no-undefined + +libgapp_include_HEADERS = gapp.h \ + service.h + +libgapp_includedir = $(includedir)/libgapp diff --git a/src/gapp.h b/src/gapp.h new file mode 100644 index 0000000..6400319 --- /dev/null +++ b/src/gapp.h @@ -0,0 +1,41 @@ +/* libgfeed + * + * Copyright (C) 2005-2006 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Andrea Zagli + */ + +#ifndef __GFEED_H__ +#define __GFEED_H__ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#endif /* __GFEED_H__ */ diff --git a/src/service.c b/src/service.c new file mode 100644 index 0000000..104df92 --- /dev/null +++ b/src/service.c @@ -0,0 +1,177 @@ +/* libgapp + * + * Copyright (C) 2012 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Andrea Zagli + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include "gapp.h" +#include "service.h" + +enum +{ + PROP_0, + PROP_URL +}; + +static void service_class_init (ServiceClass *klass); +static void service_init (Service *service); + +static void service_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void service_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static Service *parse_xml (xmlDoc *xdoc); + + +#define SERVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_SERVICE, ServicePrivate)) + +typedef struct _ServicePrivate ServicePrivate; +struct _ServicePrivate + { + gchar *url; + }; + +G_DEFINE_TYPE (Service, service, G_TYPE_OBJECT) + +static void +service_class_init (ServiceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (ServicePrivate)); + + object_class->set_property = service_set_property; + object_class->get_property = service_get_property; + + g_object_class_install_property (object_class, PROP_URL, + g_param_spec_string ("url", + "Url", + "Url of the service xml file.", + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READABLE)); +} + +static void +service_init (Service *service) +{ +} + +/** + * service_new: + * @url: + * + * Returns: the newly created #Service object. + */ +Service +*service_new (const gchar *url) +{ + Service *service = SERVICE (g_object_new (service_get_type (), NULL)); + + return service; +} + +/** + * service_get_xml_doc: + * @service: an #Service object. + * + * Returns: the #xmlDoc correspondent to the entire #Service object. + */ +xmlDoc +*service_get_xml_doc (Service *service) +{ + xmlNode *xnode; + GList *lst; + + ServicePrivate *priv = SERVICE_GET_PRIVATE (service); + + xmlDoc *xdoc = xmlNewDoc ((const xmlChar *)"1.0"); + xmlNode *xroot = xmlNewNode (NULL, (const xmlChar *)"feed"); + + /* adding root element */ + if (xroot == NULL) return NULL; + + xmlNewNs (xroot, (const xmlChar *)"http://www.w3.org/2005/Atom", NULL); + xmlDocSetRootElement (xdoc, xroot); + + return xdoc; +} + +/** + * service_save_file: + * @service: an #Service object. + * @filename: + * + */ +gboolean +service_save_file (Service *service, const gchar *filename) +{ + return (xmlSaveFileEnc (filename, service_get_xml_doc (service), "utf-8") > -1); +} + +static void +service_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + GObject *obj; + + Service *service = SERVICE (object); + ServicePrivate *priv = SERVICE_GET_PRIVATE (service); + + switch (property_id) + { + case PROP_URL: + priv->url = g_strdup (g_value_get_string (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +service_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + Service *service = SERVICE (object); + ServicePrivate *priv = SERVICE_GET_PRIVATE (service); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static Service +*parse_xml (xmlDoc *xdoc) +{ + Service *service; + + return service; +} diff --git a/src/service.h b/src/service.h new file mode 100644 index 0000000..b5214a4 --- /dev/null +++ b/src/service.h @@ -0,0 +1,63 @@ +/* libgapp + * + * Copyright (C) 2012 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Andrea Zagli + */ + +#ifndef __SERVICE_H__ +#define __SERVICE_H__ + +#include +#include +#include + +G_BEGIN_DECLS + + +#define TYPE_SERVICE (service_get_type ()) +#define SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SERVICE, Service)) +#define SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SERVICE, ServiceClass)) +#define IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SERVICE)) +#define IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SERVICE)) +#define SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SERVICE, ServiceClass)) + + +typedef struct _Service Service; +typedef struct _ServiceClass ServiceClass; + +struct _Service + { + GObject parent; + }; + +struct _ServiceClass + { + GObjectClass parent_class; + }; + +GType service_get_type (void) G_GNUC_CONST; + +Service *service_new (const gchar *url); + +xmlDoc *service_get_xml_doc (Service *service); +gboolean service_save_file (Service *service, const gchar *filename); + + +G_END_DECLS + +#endif /* __SERVICE_H__ */ diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..20d4aed --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,12 @@ +AM_CPPFLAGS = $(WARN_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) \ + $(GAPP_CFLAGS) + -I$(top_srcdir)/src \ + -DGUIDIR="\"@abs_builddir@\"" + +LIBS = $(GAPP_LIBS) \ + -export-dynamic + +LDADD = $(top_builddir)/src/libgapp.la + +noinst_PROGRAMS =