~ubuntu-branches/ubuntu/saucy/ekiga/saucy

« back to all changes in this revision

Viewing changes to lib/engine/addressbook/call-history/history-contact.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Eugen Dedu, Eugen Dedu, Loic Minier
  • Date: 2008-09-27 10:00:00 UTC
  • mfrom: (5.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080927100000-l5k5werb6czr5b3h
Tags: 3.0.1-1
[ Eugen Dedu ]
* New version.  (Closes: #500089).
* Add our own changelog file in /usr/share/doc.
* Remove gnomemeeting transitional package.
* Discover new interfaces.  (Closes: #488199).
* Compile with dbus support.  (Closes: #467212).
* Numeric keypad inserts digits at correct position.  (Closes: #440159).
* Use libnotify upon call.  (Closes: #412604).
* Symlink identical GNOME help files, to reduce size.  (Closes: #505536).
* Explicitely build-depends on a few dev packages, even if they were
  pulled out anyway by the other dependencies.

[ Loic Minier ]
* Use clean:: instead of clean: in rules.
* Don't disable Uploaders: generation for control.in -> control generation
  in rules.
* Fix some tabs which were size 4 anyway.
* Generate a PO template during build by calling intltool-update -p in
  install; thanks Ubuntu and Martin Pitt; closes: #505535.
* Also let the -dbg depend on ${misc:Depends}.
* Cleanup rules; in particular, use dpkg-parsechangelog and honor
  distclean/clean failures, remove old clean rules, commented out stuff,
  gtk-only stuff.
* Pass -s to dh_* in binary-arch.
* Use debian/*.links and debian/*.manpages instead of symlink manually or
  passing files to dh_installman.
* Use ftp.gnome.org in copyright.
* Switch to quilt and fix target deps in the process; build-dep on quilt
  instead of dpatch; rename news.dpatch to 00_news.patch and refresh;
  replace 00list with series.
* Install autotools-dev config.guess and .sub after patching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Ekiga -- A VoIP and Video-Conferencing application
 
4
 * Copyright (C) 2000-2007 Damien Sandras
 
5
 
 
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.
 
13
 *
 
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.
 
17
 *
 
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.
 
24
 */
 
25
 
 
26
 
 
27
/*
 
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
 
33
 *
 
34
 */
 
35
 
 
36
#include "config.h"
 
37
 
 
38
#include <iostream>
 
39
#include <glib.h>
 
40
 
 
41
#include "robust-xml.h"
 
42
 
 
43
#include "history-contact.h"
 
44
 
 
45
 
 
46
History::Contact::Contact (Ekiga::ServiceCore &_core,
 
47
                           xmlNodePtr _node):
 
48
  core(_core), node(_node)
 
49
{
 
50
  xmlChar *xml_str;
 
51
 
 
52
  contact_core
 
53
    = dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));
 
54
 
 
55
  xml_str = xmlGetProp (node, (const xmlChar *)"type");
 
56
  if (xml_str != NULL)
 
57
    m_type = (call_type)(xml_str[0] - '0'); // FIXME: I don't like it!
 
58
  xmlFree (xml_str);
 
59
 
 
60
  xml_str = xmlGetProp (node, (const xmlChar *)"uri");
 
61
  if (xml_str != NULL)
 
62
    uri = (const char *)xml_str;
 
63
  xmlFree (xml_str);
 
64
 
 
65
  for (xmlNodePtr child = node->children ;
 
66
       child != NULL ;
 
67
       child = child->next) {
 
68
 
 
69
    if (child->type == XML_ELEMENT_NODE
 
70
        && child->name != NULL) {
 
71
 
 
72
      if (xmlStrEqual (BAD_CAST ("name"), child->name)) {
 
73
 
 
74
        xml_str = xmlNodeGetContent (child);
 
75
        if (xml_str != NULL)
 
76
          name = (const char *)xml_str;
 
77
        xmlFree (xml_str);
 
78
      }
 
79
 
 
80
      if (xmlStrEqual (BAD_CAST ("call_start"), child->name)) {
 
81
 
 
82
        xml_str = xmlNodeGetContent (child);
 
83
        if (xml_str != NULL)
 
84
          call_start = (time_t) atoi ((const char *) xml_str);
 
85
        xmlFree (xml_str);
 
86
      }
 
87
 
 
88
      if (xmlStrEqual (BAD_CAST ("call_duration"), child->name)) {
 
89
 
 
90
        xml_str = xmlNodeGetContent (child);
 
91
        if (xml_str != NULL)
 
92
          call_duration = (const char *) xml_str;
 
93
        xmlFree (xml_str);
 
94
      }
 
95
    }
 
96
  }
 
97
}
 
98
 
 
99
 
 
100
History::Contact::Contact (Ekiga::ServiceCore &_core,
 
101
                           const std::string _name,
 
102
                           const std::string _uri,
 
103
                           time_t _call_start,
 
104
                           const std::string _call_duration,
 
105
                           call_type c_t):
 
106
  core(_core), name(_name), uri(_uri), call_start(_call_start), call_duration(_call_duration), m_type(c_t)
 
107
{
 
108
  gchar *tmp = NULL;
 
109
  std::string callp;
 
110
  contact_core
 
111
    = dynamic_cast<Ekiga::ContactCore*>(core.get ("contact-core"));
 
112
 
 
113
  node = xmlNewNode (NULL, BAD_CAST "entry");
 
114
 
 
115
  xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
 
116
  xmlNewChild (node, NULL,
 
117
               BAD_CAST "name",
 
118
               BAD_CAST robust_xmlEscape (node->doc, name).c_str ());
 
119
 
 
120
  tmp = g_strdup_printf ("%lu", call_start);
 
121
  xmlNewChild (node, NULL,
 
122
               BAD_CAST "call_start", BAD_CAST tmp);
 
123
  g_free (tmp);
 
124
 
 
125
  xmlNewChild (node, NULL,
 
126
               BAD_CAST "call_duration", BAD_CAST call_duration.c_str ());
 
127
 
 
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);
 
131
  g_free (tmp);
 
132
}
 
133
 
 
134
History::Contact::~Contact ()
 
135
{
 
136
}
 
137
 
 
138
const std::string
 
139
History::Contact::get_name () const
 
140
{
 
141
  return name;
 
142
}
 
143
 
 
144
const std::set<std::string>
 
145
History::Contact::get_groups () const
 
146
{
 
147
  std::set<std::string> groups;
 
148
 
 
149
  switch (m_type) {
 
150
  case RECEIVED:
 
151
    groups.insert (_("Received"));
 
152
    break;
 
153
  case PLACED:
 
154
    groups.insert (_("Placed"));
 
155
    break;
 
156
  case MISSED:
 
157
    groups.insert (_("Missed"));
 
158
    break;
 
159
 
 
160
  default:
 
161
    groups.insert ("AIE!!");
 
162
  }
 
163
 
 
164
  return groups;
 
165
}
 
166
 
 
167
bool
 
168
History::Contact::populate_menu (Ekiga::MenuBuilder &builder)
 
169
{
 
170
  return contact_core->populate_contact_menu (*this, uri, builder);
 
171
}
 
172
 
 
173
xmlNodePtr
 
174
History::Contact::get_node ()
 
175
{
 
176
  return node;
 
177
}
 
178
 
 
179
History::call_type
 
180
History::Contact::get_type () const
 
181
{
 
182
  return m_type;
 
183
}
 
184
 
 
185
time_t
 
186
History::Contact::get_call_start () const
 
187
{
 
188
  return call_start;
 
189
}
 
190
 
 
191
const std::string 
 
192
History::Contact::get_call_duration () const
 
193
{
 
194
  return call_duration;
 
195
}
 
196
 
 
197
bool
 
198
History::Contact::is_found (std::string /*test*/) const
 
199
{
 
200
  /* FIXME */
 
201
  return true;
 
202
}