File: soap-test.c

package info (click to toggle)
evolution-data-server 1.0.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 39,504 kB
  • ctags: 26,423
  • sloc: ansic: 175,347; tcl: 30,499; sh: 20,699; perl: 11,320; xml: 9,039; java: 7,653; cpp: 6,029; makefile: 4,866; awk: 1,338; yacc: 1,103; sed: 772; cs: 505; lex: 134; asm: 14
file content (77 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <config.h>
#include <glib/gmain.h>
#include <libgnome/gnome-init.h>
#include "e-gw-connection.h"

static GMainLoop *main_loop;
static char *arg_hostname, *arg_username, *arg_password;

static void
display_container (EGwContainer *container)
{
	g_print (" Container: %s\n", e_gw_container_get_name (container));
	g_print ("\tID: %s\n", e_gw_container_get_id (container));

	g_print ("\n");
}

static gboolean
idle_cb (gpointer data)
{
	EGwConnection *cnc;

	cnc = e_gw_connection_new (arg_hostname, arg_username, arg_password);
	if (E_IS_GW_CONNECTION (cnc)) {
		GList *container_list = NULL;

		g_print ("Connected to %s!\n", arg_hostname);

		/* get list of containers */
		g_print ("Getting list of containers...\n");
		if (e_gw_connection_get_container_list (cnc, &container_list) == E_GW_CONNECTION_STATUS_OK) {
			GList *container;

			for (container = container_list; container != NULL; container = container->next)
				display_container (E_GW_CONTAINER (container->data));

			e_gw_connection_free_container_list (container_list);
		}

		g_object_unref (cnc);
	} else
		g_print ("ERROR: Could not connect to %s\n", arg_hostname);

	g_main_loop_quit (main_loop);

	return FALSE;
}

int
main (int argc, char *argv[])
{
	gnome_program_init (PACKAGE, VERSION,
			    LIBGNOME_MODULE,
			    argc, argv,
			    NULL);

	if (argc != 3 && argc != 4) {
		g_print ("Usage: %s hostname username [password]\n", argv[0]);
		return -1;
	}

	arg_hostname = argv[1];
	arg_username = argv[2];
	if (argc == 4)
		arg_password = argv[3];
	else
		arg_password = NULL;

	main_loop = g_main_loop_new (NULL, TRUE);
	g_idle_add ((GSourceFunc) idle_cb, NULL);
	g_main_loop_run (main_loop);

	/* terminate */
	g_main_loop_unref (main_loop);

	return 0;
}