Hello community,
here is the log from the commit of package libopensync-plugin-gpe
checked in at Fri Jul 7 04:27:36 CEST 2006.
--------
--- libopensync-plugin-gpe/libopensync-plugin-gpe.changes 2006-01-25 21:37:38.000000000 +0100
+++ libopensync-plugin-gpe/libopensync-plugin-gpe.changes 2006-07-06 14:48:56.000000000 +0200
@@ -1,0 +2,7 @@
+Thu Jul 6 13:47:27 CEST 2006 - dgollub@suse.de
+
+- update to version 0.18_SVN1095:
+ o added syncing via tcp/ip
+ o fixed some gcc warnings
+
+-------------------------------------------------------------------
Old:
----
libopensync-plugin-gpe-0.18_SVN770.tar.bz2
libopensync-plugin-gpe_gcc-warnings.patch
New:
----
libopensync-plugin-gpe-0.18_SVN1095.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libopensync-plugin-gpe.spec ++++++
--- /var/tmp/diff_new_pack.4JGuaE/_old 2006-07-07 04:27:14.000000000 +0200
+++ /var/tmp/diff_new_pack.4JGuaE/_new 2006-07-07 04:27:14.000000000 +0200
@@ -1,11 +1,11 @@
#
-# spec file for package libopensync-plugin-gpe (Version 0.18_SVN770)
+# spec file for package libopensync-plugin-gpe (Version 0.18_SVN1095)
#
-# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
-# Please submit bugfixes or comments via http://bugs.opensuse.org
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
@@ -13,7 +13,7 @@
Name: libopensync-plugin-gpe
BuildRequires: libopensync-devel
URL: http://www.openync.org
-Version: 0.18_SVN770
+Version: 0.18_SVN1095
Release: 1
Summary: GPE syncronisation plugin for OpenSync
License: GPL
@@ -21,8 +21,6 @@
Autoreqprov: on
Source: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-Patch0: %{name}_gcc-warnings.patch
-#Patch1: %{name}_pkgconfig-sqlite3.patch
Requires: libopensync = %{version}
%define prefix /usr
@@ -37,11 +35,9 @@
%prep
%setup -q
-%patch
-%{?suse_update_config:%{suse_update_config -f . }}
-autoreconf -sfi
%build
+autoreconf -sfi
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%_prefix --libdir=%_libdir --localstatedir=%_localstatedir
make
@@ -54,11 +50,9 @@
%clean
rm -rf $RPM_BUILD_ROOT
-%post
-%run_ldconfig
+%post -p /sbin/ldconfig
-%postun
-%run_ldconfig
+%postun -p /sbin/ldconfig
%files
%defattr(-, root, root)
@@ -67,6 +61,10 @@
%doc AUTHORS COPYING INSTALL ChangeLog README BUGS
%changelog -n libopensync-plugin-gpe
+* Thu Jul 06 2006 - dgollub@suse.de
+- update to version 0.18_SVN1095:
+ o added syncing via tcp/ip
+ o fixed some gcc warnings
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Dec 12 2005 - dgollub@suse.de
++++++ libopensync-plugin-gpe-0.18_SVN770.tar.bz2 -> libopensync-plugin-gpe-0.18_SVN1095.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/ChangeLog new/libopensync-plugin-gpe-0.18_SVN1095/ChangeLog
--- old/libopensync-plugin-gpe-0.18_SVN770/ChangeLog 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/ChangeLog 2006-05-19 04:30:00.000000000 +0200
@@ -1,31 +1,52 @@
-2005-11-29 Martin Felis
+2006-05-19 Martin Felis
+
+ * ChangeLog: Changed the emailadress, hoping receiving less span
+ in the future.
+ * testclient/test_client.c, testclient/Makefile, testclient/README:
+ Added a small client to test the connections to the gpesyncd.
+ * contacts.c, calendar.c, todo.c: - Remeoved a bug that prevents from
+ errors being displayed. Instead of (null) will now the actual message
+ displayed.
+ - Made the traces look a bit more consistent. All data will be now
+ reported on level 3, means debug.
+ * gpe_sync.c: Set is_threadsafe to FALSE
+ * gpesync_client.c: Fixed some memory leaks.
+ * gpesync_client.h: Using now the variable types of glib.
+
+2006-01-07 Martin Felis
+
+ * gpesync_client.c, gpesync_client.h, gpe_sync.c, gpe_sync.h,
+ gpe_xml.c: Added syncing over tcp/ip.
+ * README: Improved the documentation.
+
+2005-11-29 Martin Felis
Moved the repository from gpe cvs to opensync svn.
-2005-09-22 Martin Felis
+2005-09-22 Martin Felis
* gpesync_client.c: Removed some errors when compiling with "-Werror"
- (thanks koen).
-2005-09-18 Martin Felis
+2005-09-18 Martin Felis
* gpesync_client.c, gpesync_client.h: Using now a GString instead
of a buffer with fixed length for receiving answers from gpesyncd.
* contacts.c, todo.c, calendar.c: Small change in reading answers
from gpesyncd.
-2005-09-16 Martin Felis
+2005-09-16 Martin Felis
* contacts.c, todo.c, calendar.c, utils.c, utils.h: Changed the
reporting of the uids. They will be now reported as
gpe-<type>-<uid>, so that file-sync can sort them out.
-2005-09-16 Martin Felis
+2005-09-16 Martin Felis
* contacts.c, todo.c, calendar.c: Fixed a bug that wouldn't let us
duplicate an item.
-2005-08-31 Martin Felis
+2005-08-31 Martin Felis
* contacts.c, contacts.h: Changed the way items are committed.
* utils.c, utils.h: Removed functions, that are no more needed.
@@ -34,7 +55,7 @@
* calendar.c, calendar.h, todo.c, todo.h: New way items are committed.
* Makefile.am: Added calendar.* and todo.* to be compiled too.
-2005-08-31 Martin Felis
+2005-08-31 Martin Felis
* gpesync_client.c, gpesync_client.h: Added. It's the communication
backend for this plugin. It is the client for the gpesyncd.
@@ -46,7 +67,7 @@
* gpe_db.h gpe_db.c: No more needed. All conversion is made by the
gpesyncd on the pda.
-2005-08-13 Martin Felis
+2005-08-13 Martin Felis
* gpe_db.h gpe_db.c: Implemented the tags_replace_category function,
which replaces the numbers of the cateogories to their names.
@@ -54,7 +75,7 @@
tags_replace_category.
* contacts.c: Reading and writing now implemented.
-2005-08-02 Martin Felis
+2005-08-02 Martin Felis
* gpe_db.h gpe_db.c: Files added for easier querying/handling of the
results from nsqlc_exec().
@@ -67,6 +88,6 @@
* configure.in : Added support for libgpevtype.
* README : Put in a few words.
-2005-07-27 Martin Felis
+2005-07-27 Martin Felis
* Changelog: started to use it!
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/README new/libopensync-plugin-gpe-0.18_SVN1095/README
--- old/libopensync-plugin-gpe-0.18_SVN770/README 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/README 2006-01-07 18:28:07.000000000 +0100
@@ -5,41 +5,27 @@
written. Although there should be no damage to your files, it is not
guaranteed that it works, so make backups!
-This plugin needs the gpesyncd installed on the gpe side. Syncing is done
-by using ssh, so this too has to be installed. The easiest way is to use
-key authentication. At the end of this document is a small howto to use
-it.
-
-Some notes on how all works:
-All the conversion of the vcards, vevents and vtodo's is done on the gpe
-device by using the gpesyncd. This plugin makes a normal ssh-connection
-to the pda, runs there the gpesyncd and makes all queries to it. gpesyncd
-converts all the data in the sqlite databases to vcards, vevents and vtodos,
-that are sent back to opensync.
+General information
+-------------------
+You need to install the gpesyncd on the gpe side. This will read out the
+sqlite databases and convert the data into vcards, vevents and vtodos.
+
+Syncing can be done by using tcp/ip or over ssh. Both have their advantages
+and disadvantages. But anyway I would recommend anyone to do syncing over
+ssh.
+
+Syncing over ssh
+----------------
+By using ssh, you need to additionally install the sshd on the gpe side. If
+you want to use it, just set in the configuration xml file "use_ssh" to 1
+(which is default).
-Should there be any problems with the conversion, the problems are probably
-adressed to gpesyncd. Please look at its BUGS file before reporting a
-conversion problem.
-
-Otherwise, see BUGS for known problems.
-
-Have fun.
-Martin (martin@silef.de)
-
-Some personal notes:
-
-A BIG THANKS to google, for making the "Summer of Code"
-(http://code.google.com/summerofcode.html).
-and a BIG THANK AS LEAST AS BIG AS TO GOOGLE, to handhelds.org for doing all
-this great stuff and letting me code this while the summer of code for you.
-I REALLY enjoyed it (and hopefully still enjoy it).
-
-Using key authentication:
-At first, you need to generate a new ssh-key pair with
+To have it as comfortable as with the syncing over tcp/ip, you should use
+key authentication. To do so, you need to generate a new ssh-key pair with
$ ssh-keygen -t dsa
-I recommend you to choose a passphrase althought you don't need one. After it
+I recommend you to choose a passphrase although you don't need one. After it
you have two keys: id_dsa and id_dsa.pub. The id_dsa is you private
key, never loose it, never give it away.
Now you need to append the contents of id_dsa.pub to ~/.ssh/authorized_keys
@@ -54,6 +40,39 @@
is running and you can connect to the gpe device without typing in any
passwords.
-Otherwise see:
+If this didn't work or you want more information, go to
http://sial.org/howto/openssh/publickey-auth/
+Syncing over tcp/ip
+-------------------
+For this you need to run the gpesyncd on the gpe device as the user with
+whom you want to sync. You also need to run it with the -D parameter so
+that it will be in the "daemon mode". Optionaly you can specify a port after
+the -D parameter. If you provide none, the default port 6446 will be used.
+
+Additionally you need to list the ip(s) from the computer(s) you want to
+allow to sync the file $HOME/.gpe/gpesyncd.allow . If you don't have
+this file, or it is empty, the gpesyncd will block all incoming connections.
+Whenever a connection is blocked and you try to sync, you should get an
+error like "Your're not allowed to connect!" from opensync.
+
+In the configuration xml file you need to set "use_ssh" to 0.
+
+Troubleshooting
+---------------
+Should there be any problems with the conversion, the problems are probably
+adressed to gpesyncd. Please look at its BUGS file before reporting a
+conversion problem.
+
+Otherwise, see BUGS for known problems.
+
+Have fun.
+Martin (martin@silef.de)
+
+Some personal notes:
+
+A BIG THANKS to google, for making the "Summer of Code"
+(http://code.google.com/summerofcode.html).
+and a BIG THANK AS LEAST AS BIG AS TO GOOGLE, to handhelds.org for doing all
+this great stuff and letting me code this while the summer of code for you.
+I REALLY enjoyed it (and hopefully still enjoy it).
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/calendar.c new/libopensync-plugin-gpe-0.18_SVN1095/src/calendar.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/calendar.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/calendar.c 2006-05-19 04:30:00.000000000 +0200
@@ -80,8 +80,11 @@
osync_context_report_success(ctx);
}
else {
- osync_debug ("GPE_SYNC", 0, "Couldn't commit event: %s", error);
- osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Couldn't commit event: %s", error);
+ /* result was split up into result (the part before the
+ * ':') and modified (the part after ':'); */
+ error = modified;
+ osync_debug ("GPE_SYNC", 0, "Couldn't commit event: %s ", error);
+ osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Couldn't commit event %s", error);
g_free (error);
}
} else {
@@ -116,6 +119,7 @@
gchar *errmsg = NULL;
GSList *uid_list = NULL, *iter;
+ osync_debug ("GPE_SYNC", 3, "Getting uidlists for vevens:");
gpesync_client_exec (env->client, "uidlist vevent", client_callback_list, &uid_list, &errmsg);
@@ -126,7 +130,7 @@
if (errmsg)
{
- if (strcasecmp (errmsg, "Error: No item found\n"))
+ if (strncasecmp (errmsg, "Error: No item found", 20))
{
osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Error getting event uidlist: %s\n", errmsg);
} else {
@@ -150,6 +154,8 @@
{
/* The list we got has the format:
* uid:modified */
+ osync_debug ("GPE_SYNC", 3, "Read: \"%s\"", (gchar *) iter->data);
+
gchar *modified = NULL;
gchar *uid = NULL;
@@ -162,8 +168,9 @@
}
g_string_assign (vevent_data, "");
+ osync_debug ("GPE_SYNC", 3, "Getting vcard %s\n", uid);
gpesync_client_exec_printf (env->client, "get vevent %s", client_callback_gstring, &vevent_data, &errmsg, uid);
- osync_debug("GPE_SYNC", 2, "vevent output:\n%s", vevent_data->str);
+ osync_debug("GPE_SYNC", 3, "vevent output:\n%s", vevent_data->str);
report_change (ctx, "event", uid, modified, vevent_data->str);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/contacts.c new/libopensync-plugin-gpe-0.18_SVN1095/src/contacts.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/contacts.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/contacts.c 2006-05-19 04:30:00.000000000 +0200
@@ -80,6 +80,9 @@
osync_context_report_success(ctx);
}
else {
+ /* result was split up into result and modified, whereas
+ * modified is the string after ":" */
+ error = modified;
osync_debug ("GPE_SYNC", 0, "Couldn't commit contact: %s", error);
osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Couldn't commit contact: %s", error);
g_free (error);
@@ -116,16 +119,17 @@
gchar *errmsg = NULL;
GSList *uid_list = NULL, *iter;
- gpesync_client_exec (env->client, "uidlist vcard", client_callback_list, &uid_list, &errmsg);
+ osync_debug("GPE_SYNC", 3, "Getting uidlists for vcards:");
+ gpesync_client_exec (env->client, "uidlist vcard\n", client_callback_list, &uid_list, &errmsg);
if ((uid_list) && (!strncasecmp ((gchar *)uid_list->data, "ERROR", 5)))
{
errmsg = (gchar *) uid_list->data;
}
-
+
if (errmsg)
{
- if (strcasecmp (errmsg, "Error: No item found\n"))
+ if (strncasecmp (errmsg, "Error: No item found",20))
{
osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Error getting contact uidlist: %s\n", errmsg);
} else {
@@ -149,20 +153,23 @@
{
/* The list we got has the format:
* uid:modified */
- gchar *modified = NULL;
+ osync_debug ("GPE_SYNC", 3, "Read: \"%s\"", (gchar *) iter->data);
+
+ gchar *modified = NULL;
gchar *uid = NULL;
if (parse_value_modified ((gchar *)iter->data, &uid, &modified) == FALSE)
{
- osync_context_report_error (ctx, OSYNC_ERROR_CONVERT, "Wrong uidlist item: %s\n");
+ osync_context_report_error (ctx, OSYNC_ERROR_CONVERT, "Wrong uidlist item: %s\n", uid);
g_slist_free (uid_list);
return FALSE;
}
g_string_assign (vcard_data, "");
+ osync_debug("GPE_SYNC", 3, "Getting vcard %s", uid);
gpesync_client_exec_printf (env->client, "get vcard %s", client_callback_gstring, &vcard_data, &errmsg, uid);
- osync_debug("GPE_SYNC", 2, "vcard output:\n%s", vcard_data->str);
+ osync_debug("GPE_SYNC", 3, "vcard output:\n%s", vcard_data->str);
report_change (ctx, "contact", uid, modified, vcard_data->str);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpe-sync new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe-sync
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpe-sync 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe-sync 2006-01-07 18:25:09.000000000 +0100
@@ -1,4 +1,6 @@
<config>
127.0.0.1
+ 6446
gpeuser
+ 1
</config>
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_sync.c new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_sync.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_sync.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_sync.c 2006-05-19 04:30:00.000000000 +0200
@@ -67,7 +67,7 @@
*
* \param ctx The context of the plugin
*/
-static void connect(OSyncContext *ctx)
+static void gpe_connect(OSyncContext *ctx)
{
osync_debug("GPE_SYNC", 4, "start: %s", __func__);
@@ -76,10 +76,15 @@
OSyncError *error = NULL;
- gchar *path = g_strdup_printf ("%s@%s", env->username, env->device_addr);
-
char *client_err;
- env->client = gpesync_client_open (path, &client_err);
+ if (env->use_ssh)
+ {
+ gchar *path = g_strdup_printf ("%s@%s", env->username, env->device_addr);
+ env->client = gpesync_client_open_ssh (path, &client_err);
+ }
+ else
+ env->client = gpesync_client_open (env->device_addr, env->device_port, &client_err);
+
if (env->client == NULL) {
osync_context_report_error(ctx, OSYNC_ERROR_NO_CONNECTION, client_err);
env->client = NULL;
@@ -105,9 +110,9 @@
{
osync_debug("GPE_SYNC", 4, "start: %s", __func__);
- osync_bool get_contacts = FALSE,
- get_calendar = FALSE,
- get_todo = FALSE;
+ osync_bool get_contacts = FALSE;
+ osync_bool get_calendar = FALSE;
+ osync_bool get_todo = FALSE;
get_contacts = gpe_contacts_get_changes(ctx);
get_calendar = gpe_calendar_get_changes(ctx);
@@ -144,7 +149,7 @@
*
* \brief ctx The context of the plugin
*/
-static void disconnect(OSyncContext *ctx)
+static void gpe_disconnect(OSyncContext *ctx)
{
osync_debug("GPE_SYNC", 4, "start: %s", __func__);
gpe_environment *env = (gpe_environment *)osync_context_get_plugin_data(ctx);
@@ -198,13 +203,13 @@
info->longname = "Provides synchronisation with handhelds using GPE.";
info->description = "See http://gpe.handhelds.org for more information";
info->version = 1;
- info->is_threadsafe = TRUE;
+ info->is_threadsafe = FALSE;
//Now set the function we made earlier
info->functions.initialize = initialize;
- info->functions.connect = connect;
+ info->functions.connect = gpe_connect;
info->functions.sync_done = sync_done;
- info->functions.disconnect = disconnect;
+ info->functions.disconnect = gpe_disconnect;
info->functions.finalize = finalize;
info->functions.get_changeinfo = get_changeinfo;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_sync.h new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_sync.h
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_sync.h 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_sync.h 2006-01-07 18:25:09.000000000 +0100
@@ -43,6 +43,8 @@
// configuration
char *device_addr; // the ip of the handheld;
char *username; // The user on the handheld
+ int device_port;
+ int use_ssh;
int debuglevel;
} gpe_environment;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_xml.c new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_xml.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpe_xml.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpe_xml.c 2006-01-07 18:25:09.000000000 +0100
@@ -31,9 +31,11 @@
// Set the defaults
env->device_addr = (char*)malloc(sizeof(char)*10);
strcpy(env->device_addr, "127.0.0.1");
+ env->device_port = 6446;
env->username = (char*)malloc(sizeof(char)*9);
strcpy(env->username, "gpeuser");
-
+ env->use_ssh = 1;
+
doc = xmlParseMemory(data, size);
if(!doc) {
@@ -63,6 +65,12 @@
// convert the string to an ip
env->device_addr = g_strdup(str);
}
+ if (!xmlStrcmp(cur->name, (const xmlChar *)"handheld_port")) {
+ env->device_port = atoi(str);
+ }
+ if (!xmlStrcmp(cur->name, (const xmlChar *)"use_ssh")) {
+ env->use_ssh = atoi(str);
+ }
if (!xmlStrcmp(cur->name, (const xmlChar *)"handheld_user")) {
env->username = g_strdup(str);
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpesync_client.c new/libopensync-plugin-gpe-0.18_SVN1095/src/gpesync_client.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpesync_client.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpesync_client.c 2006-05-28 03:59:12.000000000 +0200
@@ -41,7 +41,7 @@
struct gpesync_client_query_context
{
- struct gpesync_client *ctx;
+ gpesync_client *ctx;
int type;
@@ -65,9 +65,10 @@
va_end (va);
if (verbose)
- fprintf (stderr, "[gpsyncclient write_command]: %s\n", buf);
+ fprintf (stderr, "[gpsyncclient %s]: %s\n", __func__, buf);
- write (ctx->outfd, buf, strlen (buf));
+ if (write (ctx->outfd, buf, strlen (buf)) == -1 && verbose)
+ fprintf (stderr, "[gpsyncclient %s]: failed\n", __func__);
free (buf);
}
@@ -91,13 +92,13 @@
while ((data[*len] != '\n') && (data[*len] != '\0'))
{
- g_string_append_c (string, data[*len]);
+ string = g_string_append_c (string, data[*len]);
*len += 1;
}
if (data[*len] == '\n')
{
- g_string_append_c (string, data[*len]);
+ string = g_string_append_c (string, data[*len]);
*len += 1;
}
@@ -153,7 +154,15 @@
query_ctx->aborting = TRUE;
}
+ memset (argv, 0, sizeof (char *) *argc);
g_free (argv);
+
+ iter = lines;
+ while (iter)
+ {
+ g_free (iter->data);
+ iter = iter->next;
+ }
g_slist_free (lines);
}
}
@@ -168,57 +177,75 @@
ctx = query_ctx->ctx;
buf = g_string_new ("");
+ if (!ctx->socket)
+ {
+ /* Reading from the ssh session. */
+ for (;;)
+ {
+ int rc;
+ char c;
+
+ rc = read (ctx->infd, &c, 1);
+ if (rc < 0)
+ {
+ perror ("read");
+ ctx->busy = 0;
+ break;
+ }
- for (;;)
+ if (have_len == FALSE)
+ {
+ if (c == ':')
+ {
+ len = atoi (buf->str);
+ have_len = TRUE;
+ g_string_assign (buf, "");
+ continue;
+ }
+ }
+ else
+ {
+ if (buf->len == len - 1)
+ {
+ g_string_append_c (buf, c);
+ break;
+ }
+ }
+ g_string_append_c (buf, c);
+ }
+ } else {
+ /* Reading from the tcp/ip socket. */
+ int bytesread=BUFFER_LEN-1;
+ char buffer [BUFFER_LEN];
+
+ while (bytesread == BUFFER_LEN -1)
{
- int rc;
- char c;
-
- rc = read (ctx->infd, &c, 1);
- if (rc < 0)
- {
- perror ("read");
- ctx->busy = 0;
- break;
- }
-
- if (have_len == FALSE)
- {
- if (c == ':')
- {
- len = atoi (buf->str);
- have_len = TRUE;
- g_string_assign (buf, "");
- continue;
- }
- }
- else
- {
- if (buf->len == len - 1)
- {
- g_string_append_c (buf, c);
- break;
- }
- }
-
- g_string_append_c (buf, c);
-
+ bzero (buffer, BUFFER_LEN);
+ bytesread = recv (ctx->socket, buffer, BUFFER_LEN-1, 0);
+ if (bytesread < 0)
+ {
+ perror ("Reading");
+ exit (1);
+ }
+ g_string_append_len (buf, buffer, bytesread);
}
+ }
if (ctx->busy)
{
read_lines (query_ctx, buf->str);
g_string_free (buf, TRUE);
+ buf = NULL;
ctx->busy = 0;
}
}
gpesync_client *
-gpesync_client_open (const char *addr, char **errmsg)
+gpesync_client_open_ssh (const char *addr, char **errmsg)
{
gpesync_client *ctx;
gchar *hostname = NULL;
- const gchar *username = NULL;
+ gchar *username = NULL;
gchar *str;
gchar *p;
@@ -241,12 +268,15 @@
hostname = "localhost";
if (username == NULL)
- username = g_get_user_name ();
+ username = (gchar *) g_get_user_name ();
- ctx = g_malloc0 (sizeof (struct gpesync_client));
+ ctx = g_malloc0 (sizeof (gpesync_client));
- pipe (in_fds);
- pipe (out_fds);
+ if (pipe (in_fds) && verbose)
+ fprintf(stderr, "[gpsyncclient %s]: pipe failed.\n", __func__);
+
+ if (pipe (out_fds) && verbose)
+ fprintf(stderr, "[gpsyncclinet %s]: pipe fialed.\n", __func__);
pid = fork ();
if (pid == 0)
@@ -268,21 +298,82 @@
ctx->outfd = out_fds[1];
ctx->infd = in_fds[0];
- ctx->hostname = (hostname);
- ctx->username = (username);
+ ctx->hostname = g_strdup(hostname);
+ ctx->username = g_strdup(username);
g_free (str);
return ctx;
}
+gpesync_client *
+gpesync_client_open (const char *addr, int port, char **errmsg)
+{
+ gpesync_client *ctx;
+ ctx = g_malloc0 (sizeof (gpesync_client));
+
+ struct hostent *he;
+ struct sockaddr_in server_addr;
+
+ if ((he = gethostbyname (addr)) == NULL)
+ {
+ herror ("gethostbyname");
+ exit (1);
+ }
+
+ if ((ctx->socket = socket (PF_INET, SOCK_STREAM, 0)) == -1)
+ {
+ perror ("socket");
+ exit (1);
+ }
+
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons (port);
+ server_addr.sin_addr = *((struct in_addr *)he->h_addr);
+ memset (&(server_addr.sin_zero), '\0', 8);
+
+ if (connect (ctx->socket, (struct sockaddr *) &server_addr,
+ sizeof (struct sockaddr)) == -1)
+ {
+ perror ("connect");
+ exit (1);
+ }
+
+ char buffer[BUFFER_LEN];
+ bzero (buffer, BUFFER_LEN);
+
+ if (read (ctx->socket, buffer, 255) < 0) {
+ perror ("read");
+ exit (1);
+ }
+
+ if (strcasecmp (buffer, "OK\n"))
+ {
+ if (errmsg)
+ {
+ *errmsg = strdup (buffer);
+ }
+ gpesync_client_close (ctx);
+ return NULL;
+ }
+
+ return ctx;
+}
+
void
gpesync_client_close (gpesync_client * ctx)
{
+ g_free (ctx->hostname);
+ g_free (ctx->username);
+
close (ctx->infd);
if (ctx->infd != ctx->outfd)
close (ctx->outfd);
+ if (ctx->socket)
+ shutdown (ctx->socket, SHUT_RDWR);
+ ctx->socket = 0;
+
g_free (ctx);
// ctx = NULL;
}
@@ -293,7 +384,6 @@
{
struct gpesync_client_query_context query;
GString *cmd = g_string_new ("");
- g_string_append_printf (cmd, "%d:%s", strlen (command), command);
memset (&query, 0, sizeof (query));
query.ctx = ctx;
@@ -303,9 +393,28 @@
query.result = 0;
query.error = NULL;
- ctx->busy = 1;
+ if (!ctx->socket)
+ {
+ g_string_append_printf (cmd, "%d:%s", (unsigned int) strlen (command), command);
+
+ write_command (ctx, cmd->str);
- write_command (ctx, cmd->str);
+ } else {
+ int bytes_sent=0, n=0;
+
+ while (bytes_sent < strlen (command))
+ {
+ n = send (ctx->socket, command + bytes_sent, strlen (command) - bytes_sent, 0);
+ if (n < 0)
+ {
+ perror ("sending");
+ exit (1);
+ }
+ bytes_sent += n;
+ }
+ }
+
+ ctx->busy = 1;
while (ctx->busy)
read_response (&query);
@@ -337,7 +446,6 @@
for (i = 0; i < argc; i++)
{
*data_list = g_slist_append (*data_list, g_strdup (argv[i]));
- g_free (argv[i]);
}
return 0;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/gpesync_client.h new/libopensync-plugin-gpe-0.18_SVN1095/src/gpesync_client.h
--- old/libopensync-plugin-gpe-0.18_SVN770/src/gpesync_client.h 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/gpesync_client.h 2006-05-19 04:30:00.000000000 +0200
@@ -14,8 +14,31 @@
#ifndef _GPE__CLIENT_H_
#define _GPE__CLIENT_H_
#include /* Needed for the definition of va_list */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define BUFFER_LEN 1024
+
+typedef struct
+{
+ gint infd;
+ gint outfd;
+ gint seq;
+
+ gint busy;
+ gint socket;
+
+ gchar *hostname;
+ gchar *username;
+} gpesync_client;
-typedef struct gpesync_client gpesync_client;
/*! \brief This opens a connection to the gpesyncd
*
@@ -23,7 +46,9 @@
* \param errmsg If an error occurs, the message will be written there.
*
*/
-gpesync_client *gpesync_client_open(const char *addr, char **errmsg);
+gpesync_client *gpesync_client_open_ssh(const char *addr, char **errmsg);
+
+gpesync_client *gpesync_client_open(const char *addr, int port, char **errmsg);
/*! \brief Closes an exisiting connection and frees the memory.
*
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/Makefile new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/Makefile
--- old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/Makefile 2006-05-19 04:30:00.000000000 +0200
@@ -0,0 +1,19 @@
+GLIB_CFLAGS := $(shell pkg-config --cflags glib-2.0)
+GLIB_LDFLAGS := $(shell pkg-config --libs glib-2.0)
+OUT=client
+INCLUDE=$(GLIB_CFLAGS)
+
+XXFLAGS=-Wall -g $(INCLUDE) -L/usr/lib
+LDFLAGS=$(GLIB_LDFLAGS)
+CXX=gcc
+OBJ=gpesync_client.o
+
+all: test_client.c $(OBJ)
+ $(CXX) $(OBJ) test_client.c -o $(OUT) $(XXFLAGS) $(LDFLAGS)
+
+gpesync_client.o: ../gpesync_client.c ../gpesync_client.h
+ $(CXX) ../gpesync_client.c -c $(XXFLAGS)
+
+clean:
+ rm *.o
+ rm $(OUT)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/README new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/README
--- old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/README 1970-01-01 01:00:00.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/README 2006-05-19 04:30:00.000000000 +0200
@@ -0,0 +1,2 @@
+This is a small client, that is able to connect and send commands to the
+gpesyncd over ssh or tcp/ip.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/test_client.c new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/test_client.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/testclient/test_client.c 1970-01-01 01:00:00.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/testclient/test_client.c 2006-05-19 04:30:00.000000000 +0200
@@ -0,0 +1,67 @@
+#include
+#include
+#include
+#include "../gpesync_client.h"
+
+int portno = 6446;
+
+int main (int argc, char *argv[])
+{
+ if (argc < 3)
+ {
+ fprintf (stderr, "usage: %s TCP|SSH host [port]\n", argv[0]);
+ exit (0);
+ }
+ gpesync_client *ctx = NULL;
+ char buffer[BUFFER_LEN];
+ char *mode = argv[1];
+ char *server = argv[2];
+ char *error;
+ GString *result=NULL;
+
+ if (argc == 4)
+ portno = atoi (argv[3]);
+
+ bzero (buffer, BUFFER_LEN);
+ if (!strcasecmp(mode, "ssh"))
+ {
+ ctx = gpesync_client_open_ssh (server, &error);
+ }
+ else if (!strcasecmp (mode, "tcp"))
+ {
+ ctx = gpesync_client_open (server, portno, &error);
+ }
+ else
+ {
+ fprintf (stderr, "Invalid mode: %s. Please use TCP or SSH\n", mode);
+ return -1;
+ }
+
+ if (!ctx)
+ {
+ fprintf (stderr, "Error connecting to %s:%d\n", server, portno);
+ fprintf (stderr, "Message: %s\n", error);
+ return -1;
+ }
+
+ printf ("Login successful!\n");
+ printf ("Please specify command: ");
+ fgets (buffer, BUFFER_LEN, stdin);
+ result = g_string_new ("");
+
+ while (strncasecmp (buffer, "quit", 4))
+ {
+ gpesync_client_exec_printf (ctx, buffer, client_callback_gstring, &result, NULL);
+ printf ("> %s", result->str);
+
+ memset (buffer, 0, BUFFER_LEN);
+ printf ("Please specify command: ");
+ fgets (buffer, BUFFER_LEN, stdin);
+ g_string_assign (result, "");
+ }
+
+ g_string_free (result, TRUE);
+ gpesync_client_close (ctx);
+
+ return 0;
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/todo.c new/libopensync-plugin-gpe-0.18_SVN1095/src/todo.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/todo.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/todo.c 2006-05-19 04:30:00.000000000 +0200
@@ -80,6 +80,9 @@
osync_context_report_success(ctx);
}
else {
+ /* result was split up into result (the part before the
+ * ':') and modified (the part after ':'); */
+ error = modified;
osync_debug ("GPE_SYNC", 0, "Couldn't commit todo: %s", error);
osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Couldn't commit todo: %s", error);
g_free (error);
@@ -117,6 +120,7 @@
gchar *errmsg = NULL;
GSList *uid_list = NULL, *iter;
+ osync_debug ("GPE_SYNC", 3, "Getting uidlists for vevents:");
gpesync_client_exec (env->client, "uidlist vtodo", client_callback_list, &uid_list, &errmsg);
if (uid_list)
@@ -125,7 +129,7 @@
if (errmsg)
{
- if (strcasecmp (errmsg, "Error: No item found\n"))
+ if (strncasecmp (errmsg, "Error: No item found", 20))
{ osync_context_report_error (ctx, OSYNC_ERROR_GENERIC, "Error getting todo uidlist: %s\n", errmsg);
} else {
/* We haven't found any items, so go on. */
@@ -148,6 +152,8 @@
{
/* The list we got has the format:
* uid:modified */
+ osync_debug ("GPE_SYNC", 3, "Read: \"%s\"", (gchar *) iter->data);
+
gchar *modified = NULL;
gchar *uid = NULL;
@@ -160,8 +166,9 @@
}
g_string_assign (vtodo_data, "");
+ osync_debug ("GPE_SYNC", 3, "Getting vcard %s", uid);
gpesync_client_exec_printf (env->client, "get vtodo %s", client_callback_gstring, &vtodo_data, &errmsg, uid);
- osync_debug("GPE_SYNC", 2, "vtodo output:\n%s", vtodo_data->str);
+ osync_debug("GPE_SYNC", 3, "vtodo output:\n%s", vtodo_data->str);
report_change (ctx, "todo", uid, modified, vtodo_data->str);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-gpe-0.18_SVN770/src/utils.c new/libopensync-plugin-gpe-0.18_SVN1095/src/utils.c
--- old/libopensync-plugin-gpe-0.18_SVN770/src/utils.c 2005-11-29 13:09:13.000000000 +0100
+++ new/libopensync-plugin-gpe-0.18_SVN1095/src/utils.c 2006-01-06 20:03:46.000000000 +0100
@@ -33,7 +33,7 @@
gchar *p;
p = strrchr (string, '-');
- *p++;
+ p++;
return atoi(p);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit-unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit-help@opensuse.org