source: proiecte/PPPP/gdm/common/test-settings-client.c @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

File size: 2.7 KB
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 *
20 */
21
22#include "config.h"
23
24#include <stdlib.h>
25#include <stdio.h>
26#include <sys/types.h>
27#include <string.h>
28#include <errno.h>
29
30#include <locale.h>
31
32#include <glib.h>
33#include <glib-object.h>
34
35#include "gdm-settings-client.h"
36#include "gdm-settings-keys.h"
37
38static void
39notify_cb (guint             id,
40           GdmSettingsEntry *entry,
41           gpointer          user_data)
42{
43        g_debug ("Value changed: %s=%s",
44                 gdm_settings_entry_get_key (entry),
45                 gdm_settings_entry_get_value (entry));
46}
47
48static gboolean
49test_settings_client (gpointer data)
50{
51        char    *strval;
52        gboolean boolval;
53        gboolean res;
54
55        strval = NULL;
56        res = gdm_settings_client_get_string (GDM_KEY_WILLING, &strval);
57        g_debug ("Got res=%d %s=%s", res, GDM_KEY_WILLING, strval);
58        g_free (strval);
59
60        res = gdm_settings_client_get_boolean (GDM_KEY_XDMCP_ENABLE, &boolval);
61        g_debug ("Got res=%d %s=%s", res, GDM_KEY_XDMCP_ENABLE, boolval ? "true" : "false");
62
63        g_debug ("Adding notify for all keys");
64        gdm_settings_client_notify_add ("/", notify_cb, NULL, NULL);
65
66        g_debug ("Setting boolean key %s to %s", GDM_KEY_XDMCP_ENABLE, !boolval ? "true" : "false");
67        gdm_settings_client_set_boolean (GDM_KEY_XDMCP_ENABLE, !boolval);
68        g_debug ("Setting boolean key %s to %s", GDM_KEY_XDMCP_ENABLE, boolval ? "true" : "false");
69        gdm_settings_client_set_boolean (GDM_KEY_XDMCP_ENABLE, boolval);
70
71        return FALSE;
72}
73
74int
75main (int argc, char **argv)
76{
77        GMainLoop *loop;
78
79        g_type_init ();
80
81        if (! gdm_settings_client_init (GDMCONFDIR "/gdm.schemas", "/")) {
82                exit (1);
83        }
84
85        g_idle_add (test_settings_client, NULL);
86
87        loop = g_main_loop_new (NULL, FALSE);
88        g_main_loop_run (loop);
89
90        return 0;
91}
Note: See TracBrowser for help on using the repository browser.