~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/src/audio/audiortp/zrtp_session_callback.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-19 21:46:37 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120519214637-la8rbrford5kj6m3
Tags: 1.1.0-1
* New upstream release 
  - Fixes "FTBFS with libccrtp-dev/2.0.2 from experimental" (Closes: #663282)
* NEW Maintainer: Debian VoIP Team - Thanks Francois for your work.
  - (Closes: #665789: O: sflphone -- SIP and IAX2 compatible VoIP phone)
* Added Build-Depends: libdbus-c++-bin
* Add gcc47-fixes.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *  as that of the covered work.
29
29
 */
30
30
#include "zrtp_session_callback.h"
31
 
#include "global.h"
 
31
#include "logger.h"
32
32
#include "sip/sipcall.h"
33
33
#include "dbus/dbusmanager.h"
34
34
#include "dbus/callmanager.h"
35
35
#include "manager.h"
36
36
 
37
37
#include <cstdlib>
38
 
#include <string>
39
38
#include <map>
40
 
#include <utility> // for std::pair
41
39
 
42
40
using namespace GnuZrtpCodes;
43
41
 
45
43
 
46
44
namespace sfl {
47
45
 
48
 
ZrtpSessionCallback::ZrtpSessionCallback(SIPCall *sipcall) :
49
 
    sipcall_(sipcall)
 
46
ZrtpSessionCallback::ZrtpSessionCallback(SIPCall &call) : call_(call)
50
47
{
51
 
    using std::pair;
52
 
    using std::string;
53
 
 
54
48
    // we've already initialized the maps, we only need to check one
55
49
    if (not infoMap_.empty())
56
50
        return;
57
51
 
58
 
    DEBUG("Zrtp: Initialize callbacks");
59
 
 
60
52
    // Information Map
61
53
    infoMap_[InfoHelloReceived] = "Hello received, preparing a Commit";
62
54
    infoMap_[InfoCommitDHGenerated] =  "Commit: Generated a public DH key";
111
103
void
112
104
ZrtpSessionCallback::secureOn(std::string cipher)
113
105
{
114
 
    DEBUG("Zrtp: Secure mode is on with cipher %s", cipher.c_str());
115
 
    Manager::instance().getDbusManager()->getCallManager()->secureZrtpOn(sipcall_->getCallId(), cipher);
 
106
    DEBUG("Secure mode is on with cipher %s", cipher.c_str());
 
107
    Manager::instance().getDbusManager()->getCallManager()->secureZrtpOn(call_.getCallId(), cipher);
116
108
}
117
109
 
118
110
void
119
111
ZrtpSessionCallback::secureOff()
120
112
{
121
 
    DEBUG("Zrtp: Secure mode is off");
122
 
    Manager::instance().getDbusManager()->getCallManager()->secureZrtpOff(sipcall_->getCallId());
 
113
    DEBUG("Secure mode is off");
 
114
    Manager::instance().getDbusManager()->getCallManager()->secureZrtpOff(call_.getCallId());
123
115
}
124
116
 
125
117
void
126
118
ZrtpSessionCallback::showSAS(std::string sas, bool verified)
127
119
{
128
 
    DEBUG("Zrtp: SAS is: %s", sas.c_str());
129
 
    Manager::instance().getDbusManager()->getCallManager()->showSAS(sipcall_->getCallId(), sas, verified);
 
120
    DEBUG("SAS is: %s", sas.c_str());
 
121
    Manager::instance().getDbusManager()->getCallManager()->showSAS(call_.getCallId(), sas, verified);
130
122
}
131
123
 
132
 
 
133
124
void
134
125
ZrtpSessionCallback::zrtpNotSuppOther()
135
126
{
136
 
    DEBUG("Zrtp: Callee does not support ZRTP");
137
 
    Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(sipcall_->getCallId());
 
127
    DEBUG("Callee does not support ZRTP");
 
128
    Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
138
129
}
139
130
 
140
 
 
141
131
void
142
132
ZrtpSessionCallback::showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subCode)
143
133
{
156
146
    if (severity == ZrtpError) {
157
147
        if (subCode < 0) {  // received an error packet from peer
158
148
            subCode *= -1;
159
 
            DEBUG("Zrtp: Received error packet: ");
 
149
            DEBUG("Received error packet: ");
160
150
        } else
161
 
            DEBUG("Zrtp: Sent error packet: ");
 
151
            DEBUG("Sent error packet: ");
162
152
 
163
153
        std::map<int32, std::string>::const_iterator iter = zrtpMap_.find(subCode);
164
154
        if (iter != zrtpMap_.end()) {
165
155
            DEBUG("%s", iter->second.c_str());
166
 
            Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(sipcall_->getCallId(), iter->second, "ZRTP");
 
156
            Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "ZRTP");
167
157
        }
168
158
    } else {
169
159
        std::map<int32, std::string>::const_iterator iter = severeMap_.find(subCode);
170
160
        if (iter != severeMap_.end()) {
171
161
            DEBUG("%s", iter->second.c_str());
172
 
            Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(sipcall_->getCallId(), iter->second, "severe");
 
162
            Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "severe");
173
163
        }
174
164
    }
175
165
}
177
167
void
178
168
ZrtpSessionCallback::confirmGoClear()
179
169
{
180
 
    DEBUG("Zrtp: Received go clear message. Until confirmation, ZRTP won't send any data");
181
 
    Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(sipcall_->getCallId());
 
170
    DEBUG("Received go clear message. Until confirmation, ZRTP won't send any data");
 
171
    Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
182
172
}
183
173
 
184
174
std::map<int32, std::string> ZrtpSessionCallback::infoMap_;