Commit c82e2eee authored by Emmanuel Milou's avatar Emmanuel Milou

[#3619] Send message through the IM GUI + indentation

parent ed1f88b2
This diff is collapsed.
......@@ -584,4 +584,7 @@ void dbus_set_window_position_y (const guint posy);
GHashTable* dbus_get_shortcuts(void);
void dbus_set_shortcuts(GHashTable * shortcuts);
/* Instant messaging */
void dbus_send_text_message (const gchar* callID, const gchar *message);
#endif
This diff is collapsed.
......@@ -72,7 +72,7 @@ web_view_nav_requested_cb(
static void
on_SendMessage_click (void) {
/* Get the text in the buffer */
/* Get all the text in the buffer */
GtkTextIter start, end;
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (_this->textarea));
gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
......@@ -80,8 +80,12 @@ on_SendMessage_click (void) {
if (g_strcasecmp (message, "") != 0 )
{
/* Display our own message in the chat window */
im_widget_add_message (GTK_WIDGET (_this), message);
/* Send the message to the peer */
dbus_send_text_message (_this->callID, message);
/* Empty the buffer */
gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &start, &end);
}
......@@ -94,12 +98,12 @@ im_widget_class_init(IMWidgetClass *klass)
}
static void
im_widget_init(IMWidget *im)
im_widget_init (IMWidget *im)
{
im->textarea = gtk_text_view_new ();
im->web_view = webkit_web_view_new();
GtkWidget *textscrollwin = gtk_scrolled_window_new(NULL, NULL);
GtkWidget *textscrollwin = gtk_scrolled_window_new (NULL, NULL);
GtkWidget *webscrollwin = gtk_scrolled_window_new (NULL, NULL);
/* A bar with the entry text and the button to send the message */
......
......@@ -52,6 +52,7 @@ struct _IMWidget {
/* Private */
GtkWidget *textarea;
GtkWidget *web_view;
gchar *callID; /* The callID attached to this conversation */
WebKitWebFrame *web_frame; // Our web frame
JSGlobalContextRef js_context; // The frame's global JS context
JSObjectRef js_global; // The frame's global context JS object
......
......@@ -4,17 +4,14 @@
utilspp::LifetimeLibraryImpl::LifetimeLibraryImpl()
:
mTrackerArray (NULL),
mNbElements (0)
{}
mNbElements (0) {}
utilspp::LifetimeLibraryImpl::~LifetimeLibraryImpl()
{
utilspp::LifetimeLibraryImpl::~LifetimeLibraryImpl() {
terminate();
}
void
utilspp::LifetimeLibraryImpl::add (utilspp::PrivateMembers::LifetimeTracker *tracker)
{
utilspp::LifetimeLibraryImpl::add (utilspp::PrivateMembers::LifetimeTracker *tracker) {
utilspp::PrivateMembers::TrackerArray newArray = static_cast<
utilspp::PrivateMembers::TrackerArray > (std::realloc (mTrackerArray,
mNbElements + 1));
......@@ -39,8 +36,7 @@ utilspp::LifetimeLibraryImpl::add (utilspp::PrivateMembers::LifetimeTracker *tra
};
void
utilspp::LifetimeLibraryImpl::terminate()
{
utilspp::LifetimeLibraryImpl::terminate() {
//The number of elements MUST always be equal or over zero.
assert (mNbElements >= 0);
......@@ -64,8 +60,7 @@ utilspp::LifetimeLibraryImpl::terminate()
}
unsigned int
utilspp::getLongevity (utilspp::LifetimeLibraryImpl *)
{
utilspp::getLongevity (utilspp::LifetimeLibraryImpl *) {
return 0;
}
......@@ -10,24 +10,20 @@ int utilspp::PrivateMembers::mNbElements = 0;
utilspp::PrivateMembers::LifetimeTracker::LifetimeTracker (unsigned int
longevity)
:
mLongevity (longevity)
{}
mLongevity (longevity) {}
utilspp::PrivateMembers::LifetimeTracker::~LifetimeTracker()
{}
utilspp::PrivateMembers::LifetimeTracker::~LifetimeTracker() {}
bool
utilspp::PrivateMembers::LifetimeTracker::compare (
const LifetimeTracker *l,
const LifetimeTracker *r
)
{
) {
return l->mLongevity < r->mLongevity;
}
void
utilspp::PrivateMembers::atExitFunc()
{
utilspp::PrivateMembers::atExitFunc() {
assert ( (mTrackerArray != NULL) &&
(mNbElements > 0));
......
......@@ -34,89 +34,87 @@
#include "manager.h"
Account::Account (const AccountID& accountID, std::string type) :
_accountID (accountID)
, _link (NULL)
, _enabled (false)
, _type (type)
, _codecOrder ()
{
setRegistrationState (Unregistered);
_accountID (accountID)
, _link (NULL)
, _enabled (false)
, _type (type)
, _codecOrder () {
setRegistrationState (Unregistered);
}
Account::~Account()
{
Account::~Account() {
}
void Account::loadConfig() {
std::string p;
std::string p;
p = Manager::instance().getConfigString (_accountID , CONFIG_ACCOUNT_TYPE);
p = Manager::instance().getConfigString (_accountID , CONFIG_ACCOUNT_TYPE);
#ifdef USE_IAX
_enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false;
_enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false;
#else
if (p == "IAX")
_enabled = false;
else
_enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false;
if (p == "IAX")
_enabled = false;
else
_enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false;
#endif
loadAudioCodecs ();
loadAudioCodecs ();
}
void Account::setRegistrationState (RegistrationState state) {
if (state != _registrationState) {
_debug ("Account: set registration state");
_registrationState = state;
if (state != _registrationState) {
_debug ("Account: set registration state");
_registrationState = state;
// Notify the client
Manager::instance().connectionStatusNotification();
}
// Notify the client
Manager::instance().connectionStatusNotification();
}
}
void Account::loadAudioCodecs (void) {
// if the user never set the codec list, use the default configuration for this account
if (Manager::instance ().getConfigString (_accountID, "ActiveCodecs") == "") {
_info ("Account: use the default order");
Manager::instance ().getCodecDescriptorMap ().setDefaultOrder();
}
// else retrieve the one set in the user config file
else {
std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs();
// This property is now set per account basis
std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs");
setActiveCodecs (Manager::instance ().unserialize (s));
}
// if the user never set the codec list, use the default configuration for this account
if (Manager::instance ().getConfigString (_accountID, "ActiveCodecs") == "") {
_info ("Account: use the default order");
Manager::instance ().getCodecDescriptorMap ().setDefaultOrder();
}
// else retrieve the one set in the user config file
else {
std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs();
// This property is now set per account basis
std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs");
setActiveCodecs (Manager::instance ().unserialize (s));
}
}
void Account::setActiveCodecs (const std::vector <std::string> &list) {
_codecOrder.clear();
// list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order.
int i=0;
int payload;
size_t size = list.size();
while ( (unsigned int) i < size) {
payload = std::atoi (list[i].data());
_info ("Account: Adding codec with RTP payload=%i", payload);
//if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) {
_codecOrder.push_back ( (AudioCodecType) payload);
//}
i++;
}
// setConfig
std::string s = Manager::instance ().serialize (list);
// Set the config per account
Manager::instance().setConfig (_accountID, "ActiveCodecs", s);
_codecOrder.clear();
// list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order.
int i=0;
int payload;
size_t size = list.size();
while ( (unsigned int) i < size) {
payload = std::atoi (list[i].data());
_info ("Account: Adding codec with RTP payload=%i", payload);
//if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) {
_codecOrder.push_back ( (AudioCodecType) payload);
//}
i++;
}
// setConfig
std::string s = Manager::instance ().serialize (list);
// Set the config per account
Manager::instance().setConfig (_accountID, "ActiveCodecs", s);
}
......@@ -36,18 +36,15 @@
#include "iax/iaxaccount.h"
#endif
AccountCreator::AccountCreator()
{
AccountCreator::AccountCreator() {
}
AccountCreator::~AccountCreator()
{
AccountCreator::~AccountCreator() {
}
Account*
AccountCreator::createAccount (AccountType type, AccountID accountID)
{
AccountCreator::createAccount (AccountType type, AccountID accountID) {
switch (type) {
case SIP_ACCOUNT:
......
......@@ -34,12 +34,10 @@
const double AudioDevice::DEFAULT_RATE = 8000.0;
AudioDevice::AudioDevice (int id, const std::string& name) :
_id (id), _name (name), _rate (DEFAULT_RATE)
{
_id (id), _name (name), _rate (DEFAULT_RATE) {
_rate = DEFAULT_RATE;
}
AudioDevice::~AudioDevice()
{
AudioDevice::~AudioDevice() {
}
......@@ -30,8 +30,7 @@
#include "audiolayer.h"
void AudioLayer::flushMain (void)
{
void AudioLayer::flushMain (void) {
ost::MutexLock guard (_mutex);
// should pass call id
......@@ -42,15 +41,13 @@ void AudioLayer::flushMain (void)
}
void AudioLayer::flushUrgent (void)
{
void AudioLayer::flushUrgent (void) {
ost::MutexLock guard (_mutex);
_urgentRingBuffer.flushAll();
}
int AudioLayer::putUrgent (void* buffer, int toCopy)
{
int AudioLayer::putUrgent (void* buffer, int toCopy) {
int a;
ost::MutexLock guard (_mutex);
......@@ -65,8 +62,7 @@ int AudioLayer::putUrgent (void* buffer, int toCopy)
return 0;
}
int AudioLayer::putMain (void *buffer, int toCopy, CallID call_id)
{
int AudioLayer::putMain (void *buffer, int toCopy, CallID call_id) {
int a;
ost::MutexLock guard (_mutex);
......
......@@ -36,19 +36,16 @@
#include <math.h>
#include <strings.h>
AudioLoop::AudioLoop() :_buffer (0), _size (0), _pos (0), _sampleRate (0)
{
AudioLoop::AudioLoop() :_buffer (0), _size (0), _pos (0), _sampleRate (0) {
}
AudioLoop::~AudioLoop()
{
AudioLoop::~AudioLoop() {
delete [] _buffer;
_buffer = 0;
}
int
AudioLoop::getNext (SFLDataFormat* output, int nb, short volume)
{
AudioLoop::getNext (SFLDataFormat* output, int nb, short volume) {
int copied = 0;
int block;
int pos = _pos;
......@@ -64,7 +61,7 @@ AudioLoop::getNext (SFLDataFormat* output, int nb, short volume)
bcopy (_buffer+pos, output, block*sizeof (SFLDataFormat)); // short>char conversion
if (volume!=100) {
for (int i=0;i<block;i++) {
for (int i=0; i<block; i++) {
*output = (*output * volume) /100;
output++;
}
......
......@@ -33,47 +33,42 @@
AudioProcessing::AudioProcessing(Algorithm *_algo) : _algorithm(_algo) {}
AudioProcessing::AudioProcessing (Algorithm *_algo) : _algorithm (_algo) {}
AudioProcessing::~AudioProcessing(void){}
AudioProcessing::~AudioProcessing (void) {}
void AudioProcessing::resetAlgorithm(void)
{
if(_algorithm)
_algorithm->reset();
void AudioProcessing::resetAlgorithm (void) {
if (_algorithm)
_algorithm->reset();
}
int AudioProcessing::getData(SFLDataFormat *outputData)
{
if(_algorithm)
return _algorithm->getData(outputData);
else
return 0;
int AudioProcessing::getData (SFLDataFormat *outputData) {
if (_algorithm)
return _algorithm->getData (outputData);
else
return 0;
}
void AudioProcessing::putData(SFLDataFormat *inputData, int nbBytes)
{
if(_algorithm)
_algorithm->putData(inputData, nbBytes);
void AudioProcessing::putData (SFLDataFormat *inputData, int nbBytes) {
if (_algorithm)
_algorithm->putData (inputData, nbBytes);
}
void AudioProcessing::processAudio(SFLDataFormat *inputData, int nbBytes)
{
if(_algorithm)
_algorithm->process(inputData, nbBytes);
void AudioProcessing::processAudio (SFLDataFormat *inputData, int nbBytes) {
if (_algorithm)
_algorithm->process (inputData, nbBytes);
}
int AudioProcessing::processAudio(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes)
{
if(_algorithm)
return _algorithm->process(inputData, outputData, nbBytes);
else
return 0;
int AudioProcessing::processAudio (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) {
if (_algorithm)
return _algorithm->process (inputData, outputData, nbBytes);
else
return 0;
}
void AudioProcessing::processAudio(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {
if(_algorithm)
_algorithm->process(micData, spkrData, outputData, nbBytes);
void AudioProcessing::processAudio (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {
if (_algorithm)
_algorithm->process (micData, spkrData, outputData, nbBytes);
}
This diff is collapsed.
......@@ -33,13 +33,12 @@
int AudioRecorder::count = 0;
AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread()
{
AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread() {
setCancel (cancelDeferred);
++count;
std::string id("processid_");
std::string id ("processid_");
// convert count into string
std::string s;
......@@ -47,37 +46,36 @@ AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread()
out << count;
s = out.str();
recorderId = id.append(s);
recorderId = id.append (s);
arecord = arec;
mbuffer = mb;
mbuffer = mb;
}
/**
* Reimplementation of run()
*/
void AudioRecorder::run (void)
{
void AudioRecorder::run (void) {
SFLDataFormat buffer[10000];
while(true) {
while (true) {
if(!mbuffer)
_warn("AudioRecorder: Error: No instance of ringbuffer");
if (!mbuffer)
_warn ("AudioRecorder: Error: No instance of ringbuffer");
int availBytes = mbuffer->availForGet(recorderId);
int availBytes = mbuffer->availForGet (recorderId);
if(availBytes > 0) {
if (availBytes > 0) {
int got = mbuffer->getData(buffer, availBytes, 100, recorderId);
int got = mbuffer->getData (buffer, availBytes, 100, recorderId);
int availBytesAfter = mbuffer->availForGet(recorderId);
int availBytesAfter = mbuffer->availForGet (recorderId);
arecord->recData(buffer, availBytes/sizeof(SFLDataFormat));
}
arecord->recData (buffer, availBytes/sizeof (SFLDataFormat));
}
sleep(20);
sleep (20);
}
......
......@@ -39,20 +39,17 @@
#include <cstring>
#include <cerrno>
namespace sfl
{
namespace sfl {
AudioZrtpSession::AudioZrtpSession (ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename) :
ost::SymmetricZRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()),
AudioRtpSession<AudioZrtpSession> (manager, sipcall),
_zidFilename (zidFilename)
{
_zidFilename (zidFilename) {
_debug ("AudioZrtpSession initialized");
initializeZid();
}
void AudioZrtpSession::initializeZid (void)
{
void AudioZrtpSession::initializeZid (void) {
if (_zidFilename.empty()) {
throw ZrtpZidException();
......
......@@ -44,18 +44,16 @@ using namespace ost;
using namespace std;
namespace sfl
{
namespace sfl {
ZrtpSessionCallback::ZrtpSessionCallback (SIPCall *sipcall) :
_sipcall (sipcall)
{
_sipcall (sipcall) {
if (_mapInitialized) {
return;
}
_info("Zrtp: Initialize callbacks");
_info ("Zrtp: Initialize callbacks");
/**
* Information Map
......@@ -123,38 +121,33 @@ ZrtpSessionCallback::ZrtpSessionCallback (SIPCall *sipcall) :
}
void
ZrtpSessionCallback::secureOn (std::string cipher)
{
ZrtpSessionCallback::secureOn (std::string cipher) {
_debug ("Zrtp: Secure mode is on with cipher %s", cipher.c_str());
DBusManager::instance().getCallManager()->secureZrtpOn (_sipcall->getCallId(), cipher);
}
void
ZrtpSessionCallback::secureOff (void)
{
ZrtpSessionCallback::secureOff (void) {
_debug ("Zrtp: Secure mode is off");
DBusManager::instance().getCallManager()->secureZrtpOff (_sipcall->getCallId());
}
void
ZrtpSessionCallback::showSAS (std::string sas, bool verified)
{
ZrtpSessionCallback::showSAS (std::string sas, bool verified) {
_debug ("Zrtp: SAS is: %s", sas.c_str());
DBusManager::instance().getCallManager()->showSAS (_sipcall->getCallId(), sas, verified);
}
void
ZrtpSessionCallback::zrtpNotSuppOther()
{
ZrtpSessionCallback::zrtpNotSuppOther() {
_debug ("Zrtp: Callee does not support ZRTP");
DBusManager::instance().getCallManager()->zrtpNotSuppOther (_sipcall->getCallId());
}
void
ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t subCode)
{
ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t subCode) {
string* msg;
if (sev == Info) {
......@@ -197,8 +190,7 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub
}
void
ZrtpSessionCallback::zrtpNegotiationFailed (MessageSeverity severity, int subCode)
{
ZrtpSessionCallback::zrtpNegotiationFailed (MessageSeverity severity, int subCode) {
string* msg;
if (severity == ZrtpError) {
......@@ -223,8 +215,7 @@ ZrtpSessionCallback::zrtpNegotiationFailed (MessageSeverity severity, int subCod
}
void
ZrtpSessionCallback::confirmGoClear()
{
ZrtpSessionCallback::confirmGoClear() {
_debug ("Zrtp: Received go clear message. Until confirmation, ZRTP won't send any data");
DBusManager::instance().getCallManager()->zrtpNotSuppOther (_sipcall->getCallId());
}
......
......@@ -32,8 +32,7 @@
#include "../common.h"
#include "audiocodec.h"
class Alaw : public AudioCodec
{
class Alaw : public AudioCodec {
public:
// 8 PCMA A 8000 1 [RFC3551]
......@@ -134,13 +133,11 @@ class Alaw : public AudioCodec
};
// the class factories
extern "C" AudioCodec* create()
{
extern "C" AudioCodec* create() {
return new Alaw (8);
}
extern "C" void destroy (AudioCodec* a)
{
extern "C" void destroy (AudioCodec* a) {
delete a;
}
......@@ -43,8 +43,7 @@
#define FALSE 0
class G722 : public AudioCodec
{