2
/* Ekiga -- A VoIP and Video-Conferencing application
3
* Copyright (C) 2000-2007 Damien Sandras
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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
13
* GNU General Public License for more details.
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 Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20
* Ekiga is licensed under the GPL license and as a special exception,
21
* you have permission to link or otherwise combine this program with the
22
* programs OPAL, OpenH323 and PWLIB, and distribute the combination,
23
* without applying the requirements of the GNU GPL to the OPAL, OpenH323
24
* and PWLIB programs, as long as you do follow the requirements of the
25
* GNU GPL for all the rest of the software thus combined.
30
* evolution-source.cpp - description
31
* ------------------------------------------
32
* begin : written in 2007 by Julien Puydt
33
* copyright : (c) 2007 by Julien Puydt
34
* description : implementation of an evolution source
40
#include "evolution-source.h"
42
#define GCONF_PATH "/apps/evolution/addressbook/sources"
45
on_source_list_group_added_c (ESourceList */*source_list*/,
49
Evolution::Source *self = NULL;
51
self = (Evolution::Source *)data;
53
self->add_group (group);
57
Evolution::Source::add_group (ESourceGroup *group)
59
GSList *sources = NULL;
60
ESource *source = NULL;
64
Evolution::Book *book = NULL;
66
sources = e_source_group_peek_sources (group);
68
for ( ; sources != NULL; sources = g_slist_next (sources)) {
70
source = E_SOURCE (sources->data);
72
s = e_source_copy (source);
74
uri = g_strdup_printf("%s/%s",
75
e_source_group_peek_base_uri (group),
76
e_source_peek_relative_uri (source));
77
e_source_set_absolute_uri (s, uri);
80
ebook = e_book_new (s, NULL);
83
book = new Evolution::Book (services, ebook);
85
g_object_unref (ebook);
93
on_source_list_group_removed_c (ESourceList */*source_list*/,
97
Evolution::Source *self = NULL;
99
self = (Evolution::Source *)data;
101
self->remove_group (group);
105
Evolution::Source::remove_group (ESourceGroup *group)
107
gboolean found = FALSE;
108
ESource *book_source = NULL;
109
ESourceGroup *book_group = NULL;
110
EBook *book_ebook = NULL;
116
for (iterator iter = begin ();
120
book_ebook = iter->get_ebook ();
122
book_source = e_book_get_source (book_ebook);
124
book_group = e_source_peek_group (book_source);
126
if (book_group == group) {
129
iter->removed.emit ();
136
Evolution::Source::Source (Ekiga::ServiceCore &_services)
137
: services(_services)
139
GSList *groups = NULL;
140
ESourceGroup *group = NULL;
142
source_list = e_source_list_new_for_gconf_default (GCONF_PATH);
144
groups = e_source_list_peek_groups (source_list);
146
for ( ; groups != NULL; groups = g_slist_next (groups)) {
148
group = E_SOURCE_GROUP (groups->data);
152
g_signal_connect (source_list, "group-added",
153
G_CALLBACK (on_source_list_group_added_c), this);
154
g_signal_connect (source_list, "group-removed",
155
G_CALLBACK (on_source_list_group_removed_c), this);
158
Evolution::Source::~Source ()
160
g_object_unref (source_list);
164
Evolution::Source::populate_menu (Ekiga::MenuBuilder &/*builder*/)
166
/* FIXME: add back creating a new addressbook later */