~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libebackend/e-offline-listener.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/* server-interface-check.h
 
3
 *
 
4
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of version 2 of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but 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 Lesser General Public
 
16
 * License along with this program; if not, write to the
 
17
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
 *
 
20
 * Author: Sivaiah Nallagatla <snallagatla@novell.com>
 
21
 */
 
22
 
 
23
/*Note : Copied from src/offline_listener.c . This should be replaced */
 
24
/* with network manager code */
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
#include "config.h"
 
28
#endif
 
29
 
 
30
#include "e-offline-listener.h"
 
31
#include <gconf/gconf-client.h>
 
32
 
 
33
G_DEFINE_TYPE (EOfflineListener, e_offline_listener, G_TYPE_OBJECT)
 
34
 
 
35
enum {
 
36
        CHANGED,
 
37
        NUM_SIGNALS
 
38
};
 
39
 
 
40
static guint signals[NUM_SIGNALS] = { 0 };
 
41
 
 
42
static GObjectClass *parent_class = NULL;
 
43
 
 
44
struct _EOfflineListenerPrivate
 
45
{
 
46
        GConfClient *default_client;
 
47
        gboolean is_offline_now;
 
48
};
 
49
 
 
50
static void
 
51
set_online_status (EOfflineListener *eol, gboolean is_offline)
 
52
{
 
53
        EOfflineListenerPrivate *priv;
 
54
 
 
55
        priv = eol->priv;
 
56
 
 
57
        g_signal_emit (eol, signals[CHANGED], 0);
 
58
}
 
59
 
 
60
static void
 
61
online_status_changed (GConfClient *client, gint cnxn_id, GConfEntry *entry, gpointer data)
 
62
{
 
63
        GConfValue *value;
 
64
        gboolean offline;
 
65
        EOfflineListener *eol;
 
66
        EOfflineListenerPrivate *priv;
 
67
 
 
68
        eol = E_OFFLINE_LISTENER (data);
 
69
        g_return_if_fail (eol != NULL);
 
70
 
 
71
        priv = eol->priv;
 
72
        offline = FALSE;
 
73
        value = gconf_entry_get_value (entry);
 
74
        if (value)
 
75
                offline = gconf_value_get_bool (value);
 
76
 
 
77
        if (priv->is_offline_now != offline) {
 
78
                priv->is_offline_now = offline;
 
79
 
 
80
                set_online_status (eol, offline);
 
81
        }
 
82
}
 
83
 
 
84
static void
 
85
setup_offline_listener (EOfflineListener *eol)
 
86
{
 
87
        EOfflineListenerPrivate *priv = eol->priv;
 
88
 
 
89
        priv->default_client = gconf_client_get_default ();
 
90
        gconf_client_add_dir (priv->default_client, "/apps/evolution/shell", GCONF_CLIENT_PRELOAD_RECURSIVE,NULL);
 
91
        gconf_client_notify_add (priv->default_client, "/apps/evolution/shell/start_offline",
 
92
                                 (GConfClientNotifyFunc)online_status_changed,
 
93
                                 eol, NULL, NULL);
 
94
 
 
95
        priv->is_offline_now = gconf_client_get_bool (priv->default_client, "/apps/evolution/shell/start_offline", NULL);
 
96
        set_online_status (eol, priv->is_offline_now);
 
97
}
 
98
 
 
99
/**
 
100
 * e_offline_listener_new:
 
101
 *
 
102
 * Returns a new #EOfflineListener.
 
103
 *
 
104
 * Returns: a new #EOfflineListener
 
105
 *
 
106
 * Since: 2.30
 
107
 **/
 
108
EOfflineListener*
 
109
e_offline_listener_new (void)
 
110
{
 
111
        EOfflineListener *eol = g_object_new (E_TYPE_OFFLINE_LISTENER, NULL);
 
112
 
 
113
        setup_offline_listener (eol);
 
114
 
 
115
        return eol;
 
116
}
 
117
 
 
118
static void
 
119
e_offline_listener_dispose (GObject *object)
 
120
{
 
121
        EOfflineListener *eol = E_OFFLINE_LISTENER (object);
 
122
        if (eol->priv->default_client) {
 
123
                g_object_unref (eol->priv->default_client);
 
124
                eol->priv->default_client = NULL;
 
125
        }
 
126
 
 
127
        (* G_OBJECT_CLASS (parent_class)->dispose) (object);
 
128
}
 
129
 
 
130
static void
 
131
e_offline_listener_finalize (GObject *object)
 
132
{
 
133
        EOfflineListener *eol;
 
134
        EOfflineListenerPrivate *priv;
 
135
 
 
136
        eol = E_OFFLINE_LISTENER (object);
 
137
        priv = eol->priv;
 
138
 
 
139
        g_free (priv);
 
140
        eol->priv = NULL;
 
141
 
 
142
        parent_class->finalize (object);
 
143
}
 
144
 
 
145
static void
 
146
e_offline_listener_init (EOfflineListener *eol)
 
147
{
 
148
        EOfflineListenerPrivate *priv;
 
149
 
 
150
        priv = g_new0 (EOfflineListenerPrivate, 1);
 
151
        eol->priv = priv;
 
152
}
 
153
 
 
154
static void
 
155
e_offline_listener_class_init (EOfflineListenerClass *klass)
 
156
{
 
157
        GObjectClass *object_class;
 
158
 
 
159
        parent_class = g_type_class_peek_parent (klass);
 
160
 
 
161
        object_class = G_OBJECT_CLASS (klass);
 
162
        object_class->dispose = e_offline_listener_dispose;
 
163
        object_class->finalize = e_offline_listener_finalize;
 
164
 
 
165
        signals[CHANGED] =
 
166
                g_signal_new ("changed",
 
167
                              G_OBJECT_CLASS_TYPE (object_class),
 
168
                              G_SIGNAL_RUN_LAST,
 
169
                              G_STRUCT_OFFSET (EOfflineListenerClass, changed),
 
170
                              NULL, NULL,
 
171
                              g_cclosure_marshal_VOID__VOID,
 
172
                              G_TYPE_NONE, 0);
 
173
}
 
174
 
 
175
/**
 
176
 * e_offline_listener_get_state:
 
177
 * @eol: an #EOfflineListener
 
178
 *
 
179
 * FIXME Document me!
 
180
 *
 
181
 * Since: 2.30
 
182
 **/
 
183
EOfflineListenerState
 
184
e_offline_listener_get_state (EOfflineListener *eol)
 
185
{
 
186
        g_return_val_if_fail (E_IS_OFFLINE_LISTENER (eol), EOL_STATE_OFFLINE);
 
187
 
 
188
        return eol->priv->is_offline_now ? EOL_STATE_OFFLINE : EOL_STATE_ONLINE;
 
189
}