summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/jingle/libjingle/talk/examples/call/callclient.h
blob: d35a61144475da33f0d82051b56e1df640bfee57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Jingle call example
 * Copyright 2004--2005, Google Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef CRICKET_EXAMPLES_CALL_CALLCLIENT_H__
#define CRICKET_EXAMPLES_CALL_CALLCLIENT_H__

#include <map>
#include <string>
#include "talk/p2p/base/session.h"
#include "talk/p2p/client/sessionclient.h"
#include "talk/xmpp/xmppclient.h"
#include "talk/examples/call/status.h"

namespace buzz {
class PresencePushTask;
class Status;
}

namespace cricket {
class Thread;
class NetworkManager;
class PortAllocator;
class PhoneSessionClient;
class Receiver;
class Call;
}

struct RosterItem {
  buzz::Jid jid;
  buzz::Status::Show show;
  std::string status;
};

class CallClient: public sigslot::has_slots<> {
public:
  CallClient(buzz::XmppClient* xmpp_client);
  ~CallClient();

  cricket::PhoneSessionClient* phone_client() const { return phone_client_; }

  void PrintRoster();
  void MakeCallTo(const std::string& name);

private:
  typedef std::map<std::string,RosterItem> RosterMap;

  buzz::XmppClient* xmpp_client_;
  cricket::Thread* worker_thread_;
  cricket::NetworkManager* network_manager_;
  cricket::PortAllocator* port_allocator_;
  cricket::SessionManager* session_manager_;
  cricket::PhoneSessionClient* phone_client_;
  cricket::Receiver* receiver_;
  buzz::PresencePushTask* presence_push_;
  RosterMap* roster_;

  void OnStateChange(buzz::XmppEngine::State state);

  void InitPhone();
  void OnRequestSignaling();
  void OnCallCreate(cricket::Call* call);
  const std::string strerror(buzz::XmppEngine::Error err);
  void OnSessionState(cricket::Call* call,
                      cricket::Session* session,
                      cricket::Session::State state);
  void OnSendStanza(cricket::SessionClient *client, const buzz::XmlElement* stanza);

  void InitPresence();
  void OnStatusUpdate(const buzz::Status& status);
};

#endif // CRICKET_EXAMPLES_CALL_CALLCLIENT_H__