Commit e2d84da7 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #27364: client: merge APIs

parent b642a0b5
......@@ -43,12 +43,7 @@
#include "logger.h"
#include "manager.h"
#ifndef __ANDROID__
#include "client/configurationmanager.h"
#else
#include "client/android/configurationmanager.h"
#include "client/android/jni_callbacks.h"
#endif
const char * const Account::AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
const char * const Account::VIDEO_CODECS_KEY = "videoCodecs";
......
......@@ -39,11 +39,7 @@
#include "audioloop.h"
#include "manager.h"
#if HAVE_DBUS
#include "client/callmanager.h"
#else
#include "client/android/callmanager.h"
#endif
#include <cmath>
#include <numeric>
......
......@@ -32,7 +32,8 @@
#include <vector>
#include "global.h"
#include "callmanager.h"
#include "client/callmanager.h"
#include "jni_callbacks.h"
#include "sip/sipcall.h"
#include "sip/sipvoiplink.h"
......@@ -48,76 +49,53 @@
CallManager::CallManager()
{}
void CallManager::placeCall(const std::string& accountID,
bool CallManager::placeCall(const std::string& accountID,
const std::string& callID,
const std::string& to)
{
// Check if a destination number is available
if (to.empty())
DEBUG("No number entered - Call stopped");
else
Manager::instance().outgoingCall(accountID, callID, to);
}
void CallManager::placeCallFirstAccount(const std::string& callID,
const std::string& to)
{
using std::vector;
using std::string;
if (to.empty()) {
WARN("CallManager: Warning: No number entered, call stopped");
return;
}
vector<string> accountList(Manager::instance().loadAccountOrder());
if (accountList.empty())
accountList = Manager::instance().getAccountList();
for (vector<string>::const_iterator iter = accountList.begin(); iter != accountList.end(); ++iter) {
Account *account = Manager::instance().getAccount(*iter);
if (account && (*iter != SIPAccount::IP2IP_PROFILE) && account->isEnabled()) {
Manager::instance().outgoingCall(*iter, callID, to);
return;
}
DEBUG("No number entered - Call stopped");
return false;
} else {
return Manager::instance().outgoingCall(accountID, callID, to);
}
}
void
bool
CallManager::refuse(const std::string& callID)
{
Manager::instance().refuseCall(callID);
return Manager::instance().refuseCall(callID);
}
void
bool
CallManager::accept(const std::string& callID)
{
Manager::instance().answerCall(callID);
return Manager::instance().answerCall(callID);
}
void
bool
CallManager::hangUp(const std::string& callID)
{
Manager::instance().hangupCall(callID);
return Manager::instance().hangupCall(callID);
}
void
bool
CallManager::hangUpConference(const std::string& confID)
{
Manager::instance().hangupConference(confID);
return Manager::instance().hangupConference(confID);
}
void
bool
CallManager::hold(const std::string& callID)
{
Manager::instance().onHoldCall(callID);
return Manager::instance().onHoldCall(callID);
}
void
bool
CallManager::unhold(const std::string& callID)
{
Manager::instance().offHoldCall(callID);
return Manager::instance().offHoldCall(callID);
}
bool
......@@ -169,32 +147,45 @@ CallManager::getVolume(const std::string& device)
return 0;
}
bool CallManager::sendTextMessage(const std::string& callID, const std::string& message, const std::string& from)
void
CallManager::sendTextMessage(const std::string& callID, const std::string& message, const std::string& from)
{
return Manager::instance().sendTextMessage(callID,message,from);
#if HAVE_INSTANT_MESSAGING
Manager::instance().sendTextMessage(callID, message, from);
#endif
}
bool CallManager::toggleRecordingCall(const std::string& id)
void
CallManager::sendTextMessage(const std::string& callID, const std::string& message)
{
Manager::instance().toggleRecordingCall(id);
#if HAVE_INSTANT_MESSAGING
try{
Manager::instance().sendTextMessage(callID, message, "Me");
}catch(...){
ERROR("Could not send \"%s\" text message to %s", message.c_str(), callID.c_str());
}
#else
ERROR("Could not send \"%s\" text message to %s since SFLphone daemon does not support it, please recompile with instant messaging support", message.c_str(), callID.c_str());
#endif
}
void
CallManager::joinParticipant(const std::string& sel_callID, const std::string& drag_callID)
bool CallManager::toggleRecording(const std::string& id)
{
Manager::instance().joinParticipant(sel_callID, drag_callID);
return Manager::instance().toggleRecordingCall(id);
}
void
CallManager::createConfFromParticipantList(const std::vector<std::string>& participants)
bool
CallManager::joinParticipant(const std::string& sel_callID, const std::string& drag_callID)
{
Manager::instance().createConfFromParticipantList(participants);
return Manager::instance().joinParticipant(sel_callID, drag_callID);
}
void
CallManager::createConference(const std::string& id1, const std::string& id2)
CallManager::createConfFromParticipantList(const std::vector<std::string>& participants)
{
Manager::instance().createConference(id1,id2);
Manager::instance().createConfFromParticipantList(participants);
}
void
......@@ -203,43 +194,43 @@ CallManager::removeConference(const std::string& conference_id)
Manager::instance().removeConference(conference_id);
}
void
bool
CallManager::addParticipant(const std::string& callID, const std::string& confID)
{
Manager::instance().addParticipant(callID, confID);
return Manager::instance().addParticipant(callID, confID);
}
void
bool
CallManager::addMainParticipant(const std::string& confID)
{
Manager::instance().addMainParticipant(confID);
return Manager::instance().addMainParticipant(confID);
}
void
bool
CallManager::detachParticipant(const std::string& callID)
{
Manager::instance().detachParticipant(callID);
return Manager::instance().detachParticipant(callID);
}
void
bool
CallManager::joinConference(const std::string& sel_confID, const std::string& drag_confID)
{
Manager::instance().joinConference(sel_confID, drag_confID);
return Manager::instance().joinConference(sel_confID, drag_confID);
}
void
bool
CallManager::holdConference(const std::string& confID)
{
Manager::instance().holdConference(confID);
return Manager::instance().holdConference(confID);
}
void
bool
CallManager::unholdConference(const std::string& confID)
{
Manager::instance().unHoldConference(confID);
return Manager::instance().unHoldConference(confID);
}
bool
bool
CallManager::isConferenceParticipant(const std::string& call_id)
{
return Manager::instance().isConferenceParticipant(call_id);
......@@ -434,22 +425,6 @@ CallManager::acceptEnrollment(const std::string& callID, const bool& accepted)
#endif
}
void
CallManager::sendTextMessage(const std::string& callID, const std::string& message)
{
#if HAVE_INSTANT_MESSAGING
try{
Manager::instance().sendTextMessage(callID, message, "Me");
}catch(...){
ERROR("Could not send \"%s\" text message to %s", message.c_str(), callID.c_str());
}
#else
ERROR("Could not send \"%s\" text message to %s since SFLphone daemon does not support it, please recompile with instant messaging support", message.c_str(), callID.c_str());
#endif
}
void CallManager::callStateChanged(const std::string& callID, const std::string& state)
{
on_call_state_changed_wrapper(callID, state);
......@@ -517,7 +492,7 @@ void CallManager::registrationStateChanged(const std::string& accoundID, const s
void CallManager::sipCallStateChanged(const std::string& accoundID, const std::string& state, const int32_t& code)
{
}
void CallManager::updatePlaybackScale(const int32_t&, const int32_t&)
......
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
*
* 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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __SFL_CALLMANAGER_H__
#define __SFL_CALLMANAGER_H__
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
/* placeholder for the jni-glue */
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
#include <vector>
#include <map>
#include "client/android/jni_callbacks.h"
namespace sfl {
class AudioZrtpSession;
}
class CallManager {
public:
CallManager();
/* methods exported by this interface,
* you will have to implement them
*/
/* Call related methods */
void placeCall(const std::string& accountID, const std::string& callID, const std::string& to);
void placeCallFirstAccount(const std::string& callID, const std::string& to);
void refuse(const std::string& callID);
void accept(const std::string& callID);
void hangUp(const std::string& callID);
void hold(const std::string& callID);
void unhold(const std::string& callID);
bool transfer(const std::string& callID, const std::string& to);
bool attendedTransfer(const std::string& transferID, const std::string& targetID);
std::map< std::string, std::string > getCallDetails(const std::string& callID);
std::vector< std::string > getCallList();
/* Conference related methods */
void removeConference(const std::string& conference_id);
void joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
void createConfFromParticipantList(const std::vector< std::string >& participants);
void createConference(const std::string& id1, const std::string& id2);
void addParticipant(const std::string& callID, const std::string& confID);
void addMainParticipant(const std::string& confID);
void detachParticipant(const std::string& callID);
void joinConference(const std::string& sel_confID, const std::string& drag_confID);
void hangUpConference(const std::string& confID);
void holdConference(const std::string& confID);
void unholdConference(const std::string& confID);
bool isConferenceParticipant(const std::string& call_id);
std::vector<std::string> getConferenceList();
std::vector<std::string> getParticipantList(const std::string& confID);
std::string getConferenceId(const std::string& callID);
std::map<std::string, std::string> getConferenceDetails(const std::string& callID);
bool sendTextMessage(const std::string& callID, const std::string& message, const std::string& from);
/* File Playback methods */
bool toggleRecordingCall(const std::string& id);
bool startRecordedFilePlayback(const std::string& filepath);
void stopRecordedFilePlayback(const std::string& filepath);
/* General audio methods */
void setVolume(const std::string& device, const double& value);
double getVolume(const std::string& device);
void recordPlaybackSeek(const double& value);
bool getIsRecording(const std::string& callID);
std::string getCurrentAudioCodecName(const std::string& callID);
void playDTMF(const std::string& key);
void startTone(const int32_t& start, const int32_t& type);
/* Security related methods */
void setSASVerified(const std::string& callID);
void resetSASVerified(const std::string& callID);
void setConfirmGoClear(const std::string& callID);
void requestGoClear(const std::string& callID);
void acceptEnrollment(const std::string& callID, const bool& accepted);
/* Instant messaging */
void sendTextMessage(const std::string& callID, const std::string& message);
void callStateChanged(const std::string& callID, const std::string& state);
void transferFailed();
void transferSucceeded();
void recordPlaybackStopped(const std::string& path);
void recordPlaybackFilepath(const std::string& id, const std::string& filename);
void voiceMailNotify(const std::string& callID, const std::string& nd_msg);
void incomingMessage(const std::string& ID, const std::string& from, const std::string& msg);
void incomingCall(const std::string& accountID, const std::string& callID, const std::string& from);
void conferenceCreated(const std::string& confID);
void conferenceChanged(const std::string& confID,const std::string& state);
void conferenceRemoved(const std::string& confID);
void newCallCreated(const std::string& accountID, const std::string& callID, const std::string& to);
void registrationStateChanged(const std::string& accoundID, const std::string& state, const int32_t& code);
void sipCallStateChanged(const std::string& accoundID, const std::string& state, const int32_t& code);
void updatePlaybackScale(const int32_t&, const int32_t&);
private:
#if HAVE_ZRTP
sfl::AudioZrtpSession * getAudioZrtpSession(const std::string& callID);
#endif
};
#endif//CALLMANAGER_H__
......@@ -30,7 +30,7 @@
%header %{
#include "callmanager.h"
#include "client/callmanager.h"
typedef struct callmanager_callback
......@@ -163,48 +163,57 @@ void setCallbackObject(Callback* callback) {
class CallManager {
public:
/* Manager::instance().outgoingCall */
void placeCall(const std::string& accountID,
const std::string& callID,
const std::string& to);
/* Manager::instance().refuseCall */
void refuse(const std::string& callID);
/* Manager::instance().answerCall */
void accept(const std::string& callID);
/* Manager::instance().hangupCall */
void hangUp(const std::string& callID);
void hold(const std::string& callID);
void unhold(const std::string& callID);
bool placeCall(const std::string& accountID, const std::string& callID, const std::string& to);
bool refuse(const std::string& callID);
bool accept(const std::string& callID);
bool hangUp(const std::string& callID);
bool hold(const std::string& callID);
bool unhold(const std::string& callID);
bool transfer(const std::string& callID, const std::string& to);
bool attendedTransfer(const std::string& transferID, const std::string& targetID);
std::map< std::string, std::string > getCallDetails(const std::string& callID);
std::vector< std::string > getCallList();
/* Record methods */
bool toggleRecordingCall(const std::string& id);
bool startRecordedFilePlayback(const std::string& filepath);
void stopRecordedFilePlayback(const std::string& filepath);
bool getIsRecording(const std::string& callID);
bool sendTextMessage(const std::string& callID, const std::string& message, const std::string& from);
/* Conference related methods */
/* Conference related methods */
void removeConference(const std::string& conference_id);
void joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
void createConfFromParticipantList(const std::vector< std::string >& participants);
void createConference(const std::string& id1, const std::string& id2);
void addParticipant(const std::string& callID, const std::string& confID);
std::vector<std::string> getParticipantList(const std::string& confID);
void addMainParticipant(const std::string& confID);
void detachParticipant(const std::string& callID);
void joinConference(const std::string& sel_confID, const std::string& drag_confID);
void hangUpConference(const std::string& confID);
void holdConference(const std::string& confID);
void unholdConference(const std::string& confID);
bool isConferenceParticipant(const std::string& call_id);
bool addParticipant(const std::string& callID, const std::string& confID);
bool addMainParticipant(const std::string& confID);
bool detachParticipant(const std::string& callID);
bool joinConference(const std::string& sel_confID, const std::string& drag_confID);
bool hangUpConference(const std::string& confID);
bool holdConference(const std::string& confID);
bool unholdConference(const std::string& confID);
std::vector<std::string> getConferenceList();
std::vector<std::string> getCallList();
std::vector<std::string> getParticipantList(const std::string& confID);
std::string getConferenceId(const std::string& callID);
std::map<std::string, std::string> getConferenceDetails(const std::string& callID);
/* File Playback methods */
bool startRecordedFilePlayback(const std::string& filepath);
void stopRecordedFilePlayback(const std::string& filepath);
/* General audio methods */
void setVolume(const std::string& device, const double& value);
double getVolume(const std::string& device);
bool toggleRecording(const std::string& callID);
void recordPlaybackSeek(const double& value);
bool getIsRecording(const std::string& callID);
std::string getCurrentAudioCodecName(const std::string& callID);
void playDTMF(const std::string& key);
void startTone(const int32_t& start, const int32_t& type);
/* Security related methods */
void setSASVerified(const std::string& callID);
void resetSASVerified(const std::string& callID);
void setConfirmGoClear(const std::string& callID);
void requestGoClear(const std::string& callID);
void acceptEnrollment(const std::string& callID, const bool& accepted);
/* Instant messaging */
void sendTextMessage(const std::string& callID, const std::string& message);
};
class Callback {
......
......@@ -41,8 +41,8 @@
#include "callmanager.h"
#include "configurationmanager.h"
#include "client/callmanager.h"
#include "client/configurationmanager.h"
#if HAVE_DBUS
#include "client/networkmanager.h"
......
......@@ -38,7 +38,8 @@
#include <cerrno>
#include <sstream>
#include "configurationmanager.h"
#include "client/configurationmanager.h"
#include "jni_callbacks.h"
#include "account_schema.h"
#include "manager.h"
#include "sip/sipvoiplink.h"
......@@ -171,6 +172,20 @@ void ConfigurationManager::removeAccount(const std::string& accoundID)
return Manager::instance().removeAccount(accoundID);
}
/**
* Send the list of all codecs loaded to the client through DBus.
* Can stay global, as only the active codecs will be set per accounts
*/
std::vector<int32_t> ConfigurationManager::getAudioCodecList()
{
std::vector<int32_t> list(Manager::instance().audioCodecFactory.getCodecList());
// if (list.empty())
// errorAlert(CODECS_NOT_LOADED);
return list;
}
std::vector<std::string> ConfigurationManager::getAccountList()
{
return Manager::instance().getAccountList();
......@@ -329,7 +344,7 @@ int32_t ConfigurationManager::isIax2Enabled()
{
return HAVE_IAX;
}
/*
std::string ConfigurationManager::getRecordPath()
{
return Manager::instance().audioPreference.getRecordPath();
......@@ -350,6 +365,7 @@ void ConfigurationManager::setIsAlwaysRecording(const bool& rec)
Manager::instance().setIsAlwaysRecording(rec);
}
/*
void ConfigurationManager::setRecordingCall(const std::string& id)
{
Manager::instance().setRecordingCall(id);
......