3
* Ekiga -- A VoIP and Video-Conferencing application
4
* Copyright (C) 2000-2007 Damien Sandras
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version. This program is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Ekiga is licensed under the GPL license and as a special exception, you
19
* have permission to link or otherwise combine this program with the
20
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
21
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
22
* programs, as long as you do follow the requirements of the GNU GPL for all
23
* the rest of the software thus combined.
28
* history-contact.cpp - description
29
* ------------------------------------------
30
* begin : written in 2007 by Julien Puydt
31
* copyright : (c) 2007 by Julien Puydt
32
* description : implementation of a call history entry
41
#include "robust-xml.h"
43
#include "history-contact.h"
46
History::Contact::Contact (Ekiga::ServiceCore &_core,
48
core(_core), node(_node)
53
= dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));
55
xml_str = xmlGetProp (node, (const xmlChar *)"type");
57
m_type = (call_type)(xml_str[0] - '0'); // FIXME: I don't like it!
60
xml_str = xmlGetProp (node, (const xmlChar *)"uri");
62
uri = (const char *)xml_str;
65
for (xmlNodePtr child = node->children ;
67
child = child->next) {
69
if (child->type == XML_ELEMENT_NODE
70
&& child->name != NULL) {
72
if (xmlStrEqual (BAD_CAST ("name"), child->name)) {
74
xml_str = xmlNodeGetContent (child);
76
name = (const char *)xml_str;
80
if (xmlStrEqual (BAD_CAST ("call_start"), child->name)) {
82
xml_str = xmlNodeGetContent (child);
84
call_start = (time_t) atoi ((const char *) xml_str);
88
if (xmlStrEqual (BAD_CAST ("call_duration"), child->name)) {
90
xml_str = xmlNodeGetContent (child);
92
call_duration = (const char *) xml_str;
100
History::Contact::Contact (Ekiga::ServiceCore &_core,
101
const std::string _name,
102
const std::string _uri,
104
const std::string _call_duration,
106
core(_core), name(_name), uri(_uri), call_start(_call_start), call_duration(_call_duration), m_type(c_t)
111
= dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));
113
node = xmlNewNode (NULL, BAD_CAST "entry");
115
xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
116
xmlNewChild (node, NULL,
118
BAD_CAST robust_xmlEscape (node->doc, name).c_str ());
120
tmp = g_strdup_printf ("%lu", call_start);
121
xmlNewChild (node, NULL,
122
BAD_CAST "call_start", BAD_CAST tmp);
125
xmlNewChild (node, NULL,
126
BAD_CAST "call_duration", BAD_CAST call_duration.c_str ());
128
/* FIXME: I don't like the way it's done */
129
tmp = g_strdup_printf ("%d", m_type);
130
xmlSetProp (node, BAD_CAST "type", BAD_CAST tmp);
134
History::Contact::~Contact ()
139
History::Contact::get_name () const
144
const std::set<std::string>
145
History::Contact::get_groups () const
147
std::set<std::string> groups;
151
groups.insert (_("Received"));
154
groups.insert (_("Placed"));
157
groups.insert (_("Missed"));
161
groups.insert ("AIE!!");
168
History::Contact::populate_menu (Ekiga::MenuBuilder &builder)
170
return contact_core->populate_contact_menu (*this, uri, builder);
174
History::Contact::get_node ()
180
History::Contact::get_type () const
186
History::Contact::get_call_start () const
192
History::Contact::get_call_duration () const
194
return call_duration;
198
History::Contact::is_found (std::string /*test*/) const