Commit 5d1cd79b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#13722: Makes instant messaging optional a build time for sflphone daemon

parent b71dcd0b
......@@ -175,8 +175,18 @@ DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1
PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,,
AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)]))
#AX_LIB_EXPAT([1.95.0])
#AS_IF([test "$HAVE_EXPAT" != "yes"], [AC_MSG_ERROR([libexpat could not be found, which is required to build this package.])], [])
AC_ARG_WITH([instant_messaging],
[ AS_HELP_STRING([--without-instant_messaging], [disable support for instant-messaging]) ],
[],
[with_instant_messaging=yes])
AS_IF([test "x$with_instant_messaging" = "xyes"], [
AX_LIB_EXPAT([1.95.0])
AS_IF([test "$HAVE_EXPAT" != "yes"], [AC_MSG_ERROR([libexpat could not be found, which is required to build this package.])], [])
]);
AC_DEFINE_UNQUOTED([HAVE_INSTANT_MESSAGING], `if test "x$with_instant_messaging" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have instant messaging support])
AM_CONDITIONAL(BUILD_INSTANT_MESSAGING, test "x$with_instant_messaging" = "xyes" )
AX_PTHREAD
......
......@@ -7,7 +7,11 @@ if SFL_VIDEO
SFL_VIDEO_SUBDIR = video
endif
SUBDIRS = dbus audio config hooks history sip iax im $(SFL_VIDEO_SUBDIR)
if BUILD_INSTANT_MESSAGING
INSTANT_MESSAGING_SUBDIR = im
endif
SUBDIRS = dbus audio config hooks history sip iax $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR)
sflphoned_SOURCES = main.cpp
......@@ -62,16 +66,19 @@ if SFL_VIDEO
SFL_VIDEO_LIB=./video/libvideo.la
endif
if BUILD_INSTANT_MESSAGING
IM_LIB=./im/libim.la
endif
libsflphone_la_LIBADD = \
$(top_builddir)/libs/iax2/libiax2.la \
$(IAX_LIB) \
./im/libim.la \
./sip/libsiplink.la \
./audio/libaudio.la \
./dbus/libdbus.la \
./config/libconfig.la \
./hooks/libhooks.la \
./history/libhistory.la $(SFL_VIDEO_LIB)
./history/libhistory.la $(SFL_VIDEO_LIB) $(IM_LIB)
libsflphone_la_LDFLAGS = \
@CCGNU2_LIBS@ \
......
......@@ -389,6 +389,10 @@ CallManager::acceptEnrollment(const std::string& callID, const bool& accepted)
void
CallManager::sendTextMessage(const std::string& callID, const std::string& message)
{
#if HAVE_INSTANT_MESSAGING
if (!Manager::instance().sendTextMessage(callID, message, "Me"))
throw CallManagerException();
#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
}
......@@ -399,6 +399,7 @@ IAXVoIPLink::carryingDTMFdigits(const std::string& id, char code)
}
}
#if HAVE_INSTANT_MESSAGING
void
IAXVoIPLink::sendTextMessage(const std::string& callID,
const std::string& message,
......@@ -411,6 +412,7 @@ IAXVoIPLink::sendTextMessage(const std::string& callID,
sfl::InstantMessaging::send_iax_message(call->session, callID, message.c_str());
}
}
#endif
std::string
IAXVoIPLink::getCurrentVideoCodecName(Call * /*call*/) const
......@@ -521,7 +523,9 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
break;
case IAX_EVENT_TEXT:
#if HAVE_INSTANT_MESSAGING
Manager::instance().incomingMessage(call->getCallId(), call->getPeerNumber(), std::string((const char*) event->data));
#endif
break;
case IAX_EVENT_RINGA:
......
......@@ -167,7 +167,9 @@ class IAXVoIPLink : public VoIPLink {
virtual void carryingDTMFdigits(const std::string& id, char code);
#if HAVE_INSTANT_MESSAGING
virtual void sendTextMessage(const std::string& callID, const std::string& message, const std::string& from);
#endif
/**
* Return the codec protocol used for this call
......
......@@ -31,9 +31,8 @@
#include "instant_messaging.h"
#include "logger.h"
//#include "expat.h"
#include "expat.h"
#if 0
namespace {
void XMLCALL
startElementCallback(void *userData, const char *name, const char **atts)
......@@ -52,7 +51,6 @@ startElementCallback(void *userData, const char *name, const char **atts)
void XMLCALL endElementCallback(void * /*userData*/, const char * /*name*/)
{}
} // end anonymous namespace
#endif
namespace sfl {
bool InstantMessaging::saveMessage(const std::string &message, const std::string &author, const std::string &id, int mode)
......@@ -151,7 +149,6 @@ InstantMessaging::parseXmlUriList(const std::string &urilist)
{
InstantMessaging::UriList list;
/*
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, &list);
XML_SetElementHandler(parser, startElementCallback, endElementCallback);
......@@ -161,7 +158,6 @@ InstantMessaging::parseXmlUriList(const std::string &urilist)
XML_GetCurrentLineNumber(parser));
throw InstantMessageException("Error while parsing uri-list xml content");
}
*/
return list;
}
......
......@@ -1381,6 +1381,7 @@ void ManagerImpl::incomingCall(Call &call, const std::string& accountId)
//THREAD=VoIP
#if HAVE_INSTANT_MESSAGING
void ManagerImpl::incomingMessage(const std::string& callID,
const std::string& from,
const std::string& message)
......@@ -1417,7 +1418,6 @@ void ManagerImpl::incomingMessage(const std::string& callID,
dbus_.getCallManager()->incomingMessage(callID, from, message);
}
//THREAD=VoIP
bool ManagerImpl::sendTextMessage(const std::string& callID, const std::string& message, const std::string& from)
{
......@@ -1486,9 +1486,9 @@ bool ManagerImpl::sendTextMessage(const std::string& callID, const std::string&
account->getVoIPLink()->sendTextMessage(callID, message, from);
}
return true;
}
#endif // HAVE_INSTANT_MESSAGING
//THREAD=VoIP CALL=Outgoing
void ManagerImpl::peerAnsweredCall(const std::string& id)
......
......@@ -390,6 +390,7 @@ class ManagerImpl {
*/
void peerHungupCall(const std::string& id);
#if HAVE_INSTANT_MESSAGING
/**
* Notify the client with an incoming message
* @param accountId The account identifier
......@@ -405,6 +406,7 @@ class ManagerImpl {
* @param from The sender of this message (could be another participant of a conference)
*/
bool sendTextMessage(const std::string& callID, const std::string& message, const std::string& from);
#endif // HAVE_INSTANT_MESSAGING
/**
* Notify the client he has voice mails
......
......@@ -1015,6 +1015,7 @@ SIPVoIPLink::offhold(const std::string& id)
call->setState(Call::ACTIVE);
}
#if HAVE_INSTANT_MESSAGING
void SIPVoIPLink::sendTextMessage(const std::string &callID,
const std::string &message,
const std::string &from)
......@@ -1035,6 +1036,7 @@ void SIPVoIPLink::sendTextMessage(const std::string &callID,
list.push_front(entry);
send_sip_message(call->inv, callID, appendUriList(message, list));
}
#endif // HAVE_INSTANT_MESSAGING
bool
SIPVoIPLink::transferCommon(SIPCall *call, pj_str_t *dst)
......@@ -1679,10 +1681,22 @@ void transaction_state_changed_cb(pjsip_inv_session * inv,
if (!event->body.tsx_state.src.rdata)
return;
pjsip_rx_data *r_data = event->body.tsx_state.src.rdata;
// Respond with a 200/OK
pjsip_dlg_create_response(inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data);
pjsip_dlg_send_response(inv->dlg, tsx, t_data);
// Try to determine who is the recipient of the message
SIPCall *call = static_cast<SIPCall *>(inv->mod_data[mod_ua_.id]);
if (!call)
return;
#if HAVE_INSTANT_MESSAGING
// Incoming TEXT message
// Get the message inside the transaction
pjsip_rx_data *r_data = event->body.tsx_state.src.rdata;
if (!r_data->msg_info.msg->body)
return;
const char *formattedMsgPtr = static_cast<const char*>(r_data->msg_info.msg->body->data);
......@@ -1690,16 +1704,6 @@ void transaction_state_changed_cb(pjsip_inv_session * inv,
return;
std::string formattedMessage(formattedMsgPtr, strlen(formattedMsgPtr));
// Try to determine who is the recipient of the message
SIPCall *call = static_cast<SIPCall *>(inv->mod_data[mod_ua_.id]);
if (!call)
return;
// Respond with a 200/OK
pjsip_dlg_create_response(inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data);
pjsip_dlg_send_response(inv->dlg, tsx, t_data);
using namespace sfl::InstantMessaging;
try {
......@@ -1728,6 +1732,7 @@ void transaction_state_changed_cb(pjsip_inv_session * inv,
} catch (const sfl::InstantMessageException &except) {
ERROR("%s", except.what());
}
#endif
}
void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account)
......
......@@ -240,9 +240,11 @@ class SIPVoIPLink : public VoIPLink {
* @param The actual message to be transmitted
* @param The sender of this message (could be another participant of a conference)
*/
#if HAVE_INSTANT_MESSAGING
void sendTextMessage(const std::string& callID,
const std::string& message,
const std::string& from);
#endif
/**
* Create the default UDP transport according ot Ip2Ip profile settings
......
......@@ -160,9 +160,11 @@ class VoIPLink {
* @param The actual message to be transmitted
* @param The sender of this message (could be another participant of a conference)
*/
#if HAVE_INSTANT_MESSAGING
virtual void sendTextMessage(const std::string &callID,
const std::string &message,
const std::string &from) = 0;
#endif
/** Add a call to the call map (protected by mutex)
* @param call A call pointer with a unique pointer
......
......@@ -26,8 +26,6 @@ test_SOURCES = constants.h \
numbercleanertest.cpp \
sdesnegotiatortest.h \
sdesnegotiatortest.cpp \
instantmessagingtest.h \
instantmessagingtest.cpp \
siptest.h \
siptest.cpp \
sdptest.h \
......@@ -41,6 +39,11 @@ test_SOURCES = constants.h \
resamplertest.h \
resamplertest.cpp
if BUILD_INSTANT_MESSAGING
test_SOURCES+=instantmessagingtest.h \
instantmessagingtest.cpp
endif
clean-local:
rm -rf cppunitresults.xml im:testfile1.txt im:testfile2.txt \
sample_echocancel_500ms_8kHz_16bit.raw
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment