From f8060100f02267ce5a7fca6840677b4adcd24602 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Fri, 18 Jul 2008 20:36:11 -0400 Subject: [PATCH] Removing calls for python helper (code compiles now). --- src/gcalendar.c | 107 +++++--------------------------------------------------- 1 file changed, 8 insertions(+), 99 deletions(-) diff --git a/src/gcalendar.c b/src/gcalendar.c index 139c448..d24180a 100644 --- a/src/gcalendar.c +++ b/src/gcalendar.c @@ -37,12 +37,16 @@ #include #include #include +#include +#include struct gc_plgdata { char *url; char *username; char *password; + gcal_t gcal; + struct gcal_event_array all_events; OSyncHashTable *hashtable; OSyncObjTypeSink *sink; OSyncObjFormat *objformat; @@ -72,106 +76,11 @@ osync_bool run_helper(struct gc_plgdata *plgdata, const char *operation, const char *arg, int *in, int *out, pid_t *ppid, OSyncError **error) { - int fdin[2]; - int fdout[2]; - /* pipe for sending the password */ - int fdpwd[2]; - pid_t pid; - - if (pipe(fdin) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "pipe() failed"); - goto error; - } - - if (pipe(fdout) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "pipe() failed"); - goto error_fdout; - } - - if (pipe(fdpwd) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "pipe() failed"); - goto error_fdpwd; - } - - pid = fork(); - if (pid < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "fork() failed"); - goto error_fork; - } - - if (!pid) { - /* child process */ - close(fdin[1]); - close(fdpwd[1]); - close(fdout[0]); - close(0); - close(1); - dup2(fdin[0], 0); - dup2(fdout[1], 1); - - char *pwdstr = g_strdup_printf("%d", fdpwd[0]); - char *const argv[] = { - GCAL_HELPER, - plgdata->url, - plgdata->username, - pwdstr, - strdup(operation), - arg ? strdup(arg) : NULL, - NULL - }; - - execvp(argv[0], argv); - - /* execvp() error */ - fprintf(stderr, "Cannot exec plugin helper (%s)\n", GCAL_HELPER); - exit(1); - } - - /* parent process */ - close(fdin[0]); - close(fdpwd[0]); - close(fdout[1]); - - /* send the password to gchelper */ - if (write(fdpwd[1], - plgdata->password, strlen(plgdata->password) - ) < strlen(plgdata->password)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't write password to gchelper"); - goto error_sendpass; - } - - close(fdpwd[1]); - - if (in) - *in = fdin[1]; - else - close(fdin[1]); - - if (out) - *out = fdout[0]; - else - close(fdout[0]); - - if (ppid) - *ppid = pid; - - return TRUE; - -error_sendpass: - kill(pid, SIGTERM); - waitpid(pid, NULL, 0); -error_fork: - close(fdpwd[0]); - close(fdpwd[1]); -error_fdpwd: - close(fdout[0]); - close(fdout[1]); -error_fdout: - close(fdin[0]); - close(fdin[1]); -error: - return FALSE; + osync_bool result = FALSE; + /* TODO: add calls to libgcal */ +exit: + return result; } char *gc_get_cfgvalue(xmlNode *cfg, const char *name) -- 2.11.4.GIT