~ubuntu-branches/ubuntu/vivid/ekiga/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/engine/protocol/call-core.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2011-07-17 00:24:50 UTC
  • mfrom: (5.1.5 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110717002450-ytg3wsrc1ptd3153
Tags: 3.3.1-1
* New upstream release.
 - Required libpt-dev 2.10 and libopal-dev 3.10
* Fix debian/watch to catch new version
* Remove libnotify0.7.patch - included upstream
* Add libboost-dev and libboost-signals-dev to Build-Depends
* debian/rules: Don't install *.la files for new internal shared libs
* Fix Vcs URIs to point to correct desktop/experimental/ekiga tree

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-2009 Damien Sandras <dsandras@seconix.com>
 
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
 *                         call-core.cpp  -  description
 
29
 *                         ------------------------------------------
 
30
 *   begin                : written in 2007 by Damien Sandras 
 
31
 *   copyright            : (c) 2007 by Damien Sandras
 
32
 *   description          : declaration of the interface of a call core.
 
33
 *                          A call core manages CallManagers.
 
34
 *
 
35
 */
 
36
 
 
37
#include <iostream>
 
38
#include <sstream>
 
39
 
 
40
#include "config.h"
 
41
 
 
42
#include "call-core.h"
 
43
#include "call-manager.h"
 
44
 
 
45
 
 
46
using namespace Ekiga;
 
47
 
 
48
 
 
49
CallCore::~CallCore ()
 
50
{
 
51
  manager_connections.clear ();
 
52
}
 
53
 
 
54
 
 
55
void CallCore::add_manager (boost::shared_ptr<CallManager> manager)
 
56
{
 
57
  managers.insert (manager);
 
58
  manager_added (manager);
 
59
 
 
60
  manager_connections.push_back (manager->ready.connect (boost::bind (&CallCore::on_manager_ready, this, manager)));
 
61
}
 
62
 
 
63
 
 
64
CallCore::iterator CallCore::begin ()
 
65
{
 
66
  return managers.begin ();
 
67
}
 
68
 
 
69
 
 
70
CallCore::const_iterator CallCore::begin () const
 
71
{
 
72
  return managers.begin ();
 
73
}
 
74
 
 
75
 
 
76
CallCore::iterator CallCore::end ()
 
77
{
 
78
  return managers.end (); 
 
79
}
 
80
 
 
81
 
 
82
CallCore::const_iterator CallCore::end () const
 
83
{
 
84
  return managers.end (); 
 
85
}
 
86
 
 
87
 
 
88
bool CallCore::dial (const std::string uri)
 
89
{
 
90
  for (std::set<boost::shared_ptr<CallManager> >::iterator iter = managers.begin ();
 
91
       iter != managers.end ();
 
92
       iter++) {
 
93
    if ((*iter)->dial (uri))
 
94
      return true;
 
95
  }
 
96
 
 
97
  return false;
 
98
}
 
99
 
 
100
 
 
101
void CallCore::add_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
102
{
 
103
  std::list<boost::signals::connection> conns;
 
104
 
 
105
  conns.push_back (call->ringing.connect (boost::bind (&CallCore::on_ringing_call, this, call, manager)));
 
106
  conns.push_back (call->setup.connect (boost::bind (&CallCore::on_setup_call, this, call, manager)));
 
107
  conns.push_back (call->missed.connect (boost::bind (&CallCore::on_missed_call, this, call, manager)));
 
108
  conns.push_back (call->cleared.connect (boost::bind (&CallCore::on_cleared_call, this, _1, call, manager)));
 
109
  conns.push_back (call->established.connect (boost::bind (&CallCore::on_established_call, this, call, manager)));
 
110
  conns.push_back (call->held.connect (boost::bind (&CallCore::on_held_call, this, call, manager)));
 
111
  conns.push_back (call->retrieved.connect (boost::bind (&CallCore::on_retrieved_call, this, call, manager)));
 
112
  conns.push_back (call->stream_opened.connect (boost::bind (&CallCore::on_stream_opened, this, _1, _2, _3, call, manager)));
 
113
  conns.push_back (call->stream_closed.connect (boost::bind (&CallCore::on_stream_closed, this, _1, _2, _3, call, manager)));
 
114
  conns.push_back (call->stream_paused.connect (boost::bind (&CallCore::on_stream_paused, this, _1, _2, call, manager)));
 
115
  conns.push_back (call->stream_resumed.connect (boost::bind (&CallCore::on_stream_resumed, this, _1, _2, call, manager)));
 
116
  conns.push_back (call->removed.connect (boost::bind (&CallCore::on_call_removed, this, call)));
 
117
 
 
118
  call_connections [call->get_id ()] = conns;
 
119
}
 
120
 
 
121
 
 
122
void CallCore::remove_call (boost::shared_ptr<Call> call)
 
123
{
 
124
  for (std::list<boost::signals::connection>::iterator iter2 = call_connections [call->get_id ()].begin ();
 
125
       iter2 != call_connections [call->get_id ()].end ();
 
126
       ++iter2)
 
127
    iter2->disconnect ();
 
128
 
 
129
  call_connections.erase (call->get_id ());
 
130
}
 
131
 
 
132
 
 
133
void CallCore::on_ringing_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
134
{
 
135
  ringing_call (manager, call);
 
136
}
 
137
 
 
138
 
 
139
void CallCore::on_setup_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
140
{
 
141
  setup_call (manager, call);
 
142
}
 
143
 
 
144
 
 
145
void CallCore::on_missed_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
146
{
 
147
  missed_call (manager, call);
 
148
}
 
149
 
 
150
 
 
151
void CallCore::on_cleared_call (std::string reason, boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
152
{
 
153
  cleared_call (manager, call, reason); 
 
154
}
 
155
 
 
156
 
 
157
void CallCore::on_established_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
158
{
 
159
  established_call (manager, call);
 
160
}
 
161
 
 
162
 
 
163
void CallCore::on_held_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
164
{
 
165
  held_call (manager, call);
 
166
}
 
167
 
 
168
 
 
169
void CallCore::on_retrieved_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
170
{
 
171
  retrieved_call (manager, call);
 
172
}
 
173
 
 
174
 
 
175
void CallCore::on_stream_opened (std::string name, Call::StreamType type, bool is_transmitting, boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
176
{
 
177
  stream_opened (manager, call, name, type, is_transmitting);
 
178
}
 
179
 
 
180
 
 
181
void CallCore::on_stream_closed (std::string name, Call::StreamType type, bool is_transmitting, boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
182
{
 
183
  stream_closed (manager, call, name, type, is_transmitting);
 
184
}
 
185
 
 
186
 
 
187
void CallCore::on_stream_paused (std::string name, Call::StreamType type, boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
188
{
 
189
  stream_paused (manager, call, name, type);
 
190
}
 
191
 
 
192
 
 
193
void CallCore::on_stream_resumed (std::string name, Call::StreamType type, boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 
194
{
 
195
  stream_resumed (manager, call, name, type);
 
196
}
 
197
 
 
198
 
 
199
void CallCore::on_manager_ready (boost::shared_ptr<CallManager> manager)
 
200
{
 
201
  manager_ready (manager);
 
202
  nr_ready++;
 
203
 
 
204
  if (nr_ready >= managers.size ())
 
205
    ready ();
 
206
}
 
207
 
 
208
 
 
209
void CallCore::on_call_removed (boost::shared_ptr<Call> call)
 
210
{
 
211
  remove_call (call);
 
212
}