From ce83da8c418fb930c59a4176620c2ab40a9f873c Mon Sep 17 00:00:00 2001 From: llea <llea> Date: Wed, 10 Aug 2005 20:10:13 +0000 Subject: [PATCH] Add blink notification for voice-message --- CHANGES | 4 +++ ChangeLog | 4 +++ README | 3 ++ TODO | 2 +- src/audio/tonegenerator.cpp | 2 +- src/audio/tonegenerator.h | 30 +++++++++++++++-- src/gui/guiframework.h | 2 ++ src/gui/qt/qtGUImainwindow.cpp | 19 +++++------ src/gui/qt/qtGUImainwindow.h | 6 ++-- src/managerimpl.cpp | 28 ++++++++++------ src/managerimpl.h | 2 ++ src/sipcall.cpp | 3 -- src/sipvoiplink.cpp | 61 ++++++++++++++++++++++++++++++++-- src/sipvoiplink.h | 9 ++++- src/skin.cpp | 3 -- 15 files changed, 140 insertions(+), 38 deletions(-) diff --git a/CHANGES b/CHANGES index 26d6b6057d..0854f0eeba 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +SFLphone (0.4.1) / 2005-08-11 + * Use libeXosip2 + * Add blink notification for voice-message + SFLphone (0.4) / 2005-07-06 * Cleanup code * Add autotools support diff --git a/ChangeLog b/ChangeLog index 3cf42029ec..6c8da48393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Laurielle LEA (10 August 2005) version 0.4 +- Add blink notification for voice-message +- Cleanup code + Laurielle LEA (1st August 2005) version 0.4 - Add comments in header files diff --git a/README b/README index eb94683c84..62eb859d31 100644 --- a/README +++ b/README @@ -1,5 +1,6 @@ This is SFLPhone-0.4 release. + You need ccrtp-1.3.0 which needs commoncpp2>=1.3.0 libeXosip2-1.9.1-pre15 needs libosip2-2.2.0 You also need PortAudio_v19 @@ -148,6 +149,8 @@ Don't hesitate to post your comments/suggestions/questions on the forge.novell mailing-list. +Jean-Philippe Barette-LaPierre +(jean-philippe.barrette-lapierre@savoirfairelinux.com) Laurielle Lea (laurielle.lea@savoirfairelinux.com) Jerome Oufella (jerome.oufella@savoirfairelinux.com) diff --git a/TODO b/TODO index bbedbd4c02..58ead5e53a 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,7 @@ For project core: Management of message blinking-notification Management Config like about:config in Mozilla Improvement of STUN -Add ZeroConf +Add ZeroConf support with mDNSResponder-107.1 library from apple Add IAX support Management of account (add, remove, ...) Management of exceptions diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 6d0760f436..140ea786a2 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -17,9 +17,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <math.h> #include <iostream> #include <fstream> +#include <math.h> #include <stdlib.h> #include "audiolayer.h" diff --git a/src/audio/tonegenerator.h b/src/audio/tonegenerator.h index 26f67275ff..de0aa541f7 100644 --- a/src/audio/tonegenerator.h +++ b/src/audio/tonegenerator.h @@ -69,22 +69,42 @@ public: ToneGenerator (); ~ToneGenerator (void); - string toneZone[NB_ZONES_MAX][NB_TONES_MAX]; - + /** + * Returns id selected zone for tone choice + */ int idZoneName (const string &); + /** + * Calculate sinus with superposition of 2 frequencies + */ void generateSin (int, int, int16 *); + + /** + * Build tone according to the id-zone, with initialisation of ring tone. + * Generate sinus with frequencies alternatively by time + */ void buildTone (int, int, int16*); + + /** + * Handle the required tone + */ void toneHandle (int); + + /** + * Play the ringtone when incoming call occured + */ int playRingtone (const char*); + /////////////////////////// + // Public members variable + ////////////////////////// int16 *sample; int freq1, freq2; int time; int totalbytes; - int16 buf[SIZEBUF]; + private: /* * Initialisation of the supported tones according to the countries. @@ -100,6 +120,10 @@ private: */ int contains(const string& str, char c); + ////////////////////////// + // Private member variable + ////////////////////////// + string toneZone[NB_ZONES_MAX][NB_TONES_MAX]; ToneThread* tonethread; }; diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h index f91e47c6bd..edd4bcff7b 100644 --- a/src/gui/guiframework.h +++ b/src/gui/guiframework.h @@ -45,6 +45,8 @@ public: virtual void setup (void) = 0; virtual int selectedCall (void) = 0; virtual bool isCurrentId (short) = 0; + virtual void startVoiceMessageNotification (void) = 0; + virtual void stopVoiceMessageNotification (void) = 0; /* Child class to parent class */ int outgoingCall (const string& to); diff --git a/src/gui/qt/qtGUImainwindow.cpp b/src/gui/qt/qtGUImainwindow.cpp index 4c405f70bf..32696aa669 100644 --- a/src/gui/qt/qtGUImainwindow.cpp +++ b/src/gui/qt/qtGUImainwindow.cpp @@ -1295,11 +1295,16 @@ QtGUIMainWindow::hangupLine (void) * Stop the blinking message slot and load the message-off button pixmap. */ void -QtGUIMainWindow::stopTimerMessage (void) { +QtGUIMainWindow::stopVoiceMessageNotification (void) { _msgVar = false; phoneKey_msg->setPixmap(TabMsgPixmap[FREE]); } +void +QtGUIMainWindow::startVoiceMessageNotification (void) { + _msgVar = true; +} + /** * Stop the call timer. * @@ -1348,16 +1353,8 @@ QtGUIMainWindow::volumeMicChanged (int val) { void QtGUIMainWindow::registerSlot (void) { - static bool reg = false; - _panel->saveSlot(); - if (!reg) { - registerVoIPLink(); - reg = true; - } else { - unregisterVoIPLink(); - reg = false; - } + registerVoIPLink(); } /** @@ -1383,7 +1380,7 @@ QtGUIMainWindow::blinkLineSlot (void) { // Dial the voicemail Number automatically when button is clicked void QtGUIMainWindow::button_msg (void) { - stopTimerMessage(); + stopVoiceMessageNotification(); _lcd->clearBuffer(); _lcd->appendText(get_config_fields_str(PREFERENCES, VOICEMAIL_NUM)); if (qt_outgoingCall() == -1) { diff --git a/src/gui/qt/qtGUImainwindow.h b/src/gui/qt/qtGUImainwindow.h index 8b3accef5f..4b483ccad8 100644 --- a/src/gui/qt/qtGUImainwindow.h +++ b/src/gui/qt/qtGUImainwindow.h @@ -96,6 +96,7 @@ public: virtual void displayContext (short id); virtual string getRingtoneFile (void); virtual void setup (void); + /* * Return the id matching to the chosen line */ @@ -166,7 +167,8 @@ public: /* * Stop the blinking-signal when you check your voicemail (not used yet) */ - void stopTimerMessage (void); + void stopVoiceMessageNotification (void); + void startVoiceMessageNotification (void); /* * Manage if you selected a line before dialing @@ -184,7 +186,7 @@ public: * Manage if you are in transfer mode */ inline void setTransfer (bool b) { _transfer = b; } - inline bool getTransfer (void) {return _transfer; } + inline bool getTransfer (void) { return _transfer; } signals: void keyPressed (int); diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 7ef766632f..0278399cbf 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -23,9 +23,9 @@ # include <sys/types.h> // mkdir(2) # include <sys/stat.h> // mkdir(2) -#include <sys/socket.h> // inet_ntoa() -#include <netinet/in.h> -#include <arpa/inet.h> +//#include <sys/socket.h> // inet_ntoa() +//#include <netinet/in.h> +//#include <arpa/inet.h> #include <cc++/thread.h> #include <cstdlib> @@ -64,7 +64,6 @@ ManagerImpl::ManagerImpl (void) _error = new Error(); _tone = new ToneGenerator(); - _nCalls = 0; _nCodecs = 0; _currentCallId = 0; @@ -77,7 +76,6 @@ ManagerImpl::ManagerImpl (void) _ringback = false; _exist = 0; _loaded = false; - } ManagerImpl::~ManagerImpl (void) @@ -513,7 +511,6 @@ ManagerImpl::incomingCall (short id) return _gui->incomingCall(id); } -// L'autre personne a repondu void ManagerImpl::peerAnsweredCall (short id) { @@ -604,6 +601,18 @@ ManagerImpl::isCurrentId (short id) return _gui->isCurrentId(id); } +void +ManagerImpl::startVoiceMessageNotification (void) +{ + _gui->startVoiceMessageNotification(); +} + +void +ManagerImpl::stopVoiceMessageNotification (void) +{ + _gui->stopVoiceMessageNotification(); +} + void ManagerImpl::congestion (bool var) { if (isDriverLoaded()) { @@ -643,7 +652,7 @@ ManagerImpl::ringtone (bool var) if (_ringtone != var) { _ringtone = var; } - + _zonetone = var; if (getNumberOfCalls() == 1) { // If just one line is ringing @@ -663,7 +672,7 @@ ManagerImpl::notificationIncomingCall (void) { _tone->generateSin(440, 0, buffer); - // Control volume + // Volume Control buf_ctrl_vol = new int16[size*CHANNELS]; spkrVolume = getSpkrVolume(); for (int j = 0; j < size; j++) { @@ -751,7 +760,6 @@ ManagerImpl::useStun (void) { } } - /////////////////////////////////////////////////////////////////////////////// // Private functions /////////////////////////////////////////////////////////////////////////////// @@ -791,7 +799,7 @@ ManagerImpl::createSettingsPath (void) { } } - // Load user's config + // Load user's configuration _path = _path + "/" + PROGNAME + "rc"; exist = Config::tree()->populateFromFile(_path); diff --git a/src/managerimpl.h b/src/managerimpl.h index 17a372d8d8..958e3e1c75 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -179,6 +179,8 @@ public: void displayStatus (const string& status); int selectedCall (void); bool isCurrentId (short id); + void startVoiceMessageNotification (void); + void stopVoiceMessageNotification (void); /* * Handle audio sounds heard by a caller while they wait for their diff --git a/src/sipcall.cpp b/src/sipcall.cpp index 84fef206d8..a22ab74721 100644 --- a/src/sipcall.cpp +++ b/src/sipcall.cpp @@ -26,9 +26,6 @@ // For AF_INET #include <sys/socket.h> -#include <sys/types.h> -#include <netinet/in.h> -// #include "global.h" #include "audio/audiocodec.h" diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 3b11d5f446..a26cf65cf8 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -2,6 +2,8 @@ * Copyright (C) 2004-2005 Savoir-Faire Linux inc. * Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com> * + * Portions Copyright (C) 2002,2003 Aymeric Moizard <jack@atosc.org> + * * 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 @@ -50,6 +52,8 @@ using namespace std; #define DEFAULT_LOCAL_PORT 10500 #define RANDOM_LOCAL_PORT ((rand() % 27250) + 5250)*2 +#define VOICE_MSG "Voice-Message" +#define LENGTH_VOICE_MSG 15 SipVoIPLink::SipVoIPLink (short id) : VoIPLink (id) { @@ -57,6 +61,7 @@ SipVoIPLink::SipVoIPLink (short id) : VoIPLink (id) _localPort = 0; _cid = 0; _reg_id = -1; + _nMsgVoicemail = 0; _evThread = new EventThread (this); _sipcallVector = new SipCallVector(); _audiortp = new AudioRtp(); @@ -120,7 +125,9 @@ SipVoIPLink::init (void) } + // Set user agent eXosip_set_user_agent(tmp.data()); + _evThread->start(); return 1; } @@ -145,7 +152,6 @@ int SipVoIPLink::setRegister (void) { int i; -// int reg_id = -1; osip_message_t *reg = NULL; string proxy = "sip:" + get_config_fields_str(SIGNALISATION, PROXY); @@ -199,6 +205,7 @@ SipVoIPLink::setRegister (void) eXosip_unlock(); Manager::instance().error()->setError(0); + return i; } @@ -209,6 +216,8 @@ SipVoIPLink::setUnregister (void) // int reg_id = -1; osip_message_t *reg = NULL; + eXosip_lock(); + if (_reg_id > 0) { _debug("UNREGISTER\n"); i = eXosip_register_build_register (_reg_id, 0, ®); @@ -218,7 +227,7 @@ SipVoIPLink::setUnregister (void) eXosip_unlock(); return -1; } - + i = eXosip_register_send_register (_reg_id, reg); if (i == -2) { _debug("cannot build registration, check the setup\n"); @@ -552,6 +561,7 @@ SipVoIPLink::getEvent (void) if (event == NULL) { return -1; } + switch (event->type) { // IP-Phone user receives a new call case EXOSIP_CALL_INVITE: // @@ -698,8 +708,11 @@ SipVoIPLink::getEvent (void) eXosip_automatic_action(); eXosip_unlock(); break; - case BAD_REQ: case UNAUTHORIZED: + setAuthentication(); + break; + + case BAD_REQ: case FORBIDDEN: case NOT_FOUND: case NOT_ALLOWED: @@ -773,6 +786,48 @@ SipVoIPLink::getEvent (void) eXosip_options_send_answer (event->tid, BUSY_HERE, NULL); } eXosip_unlock(); + } + + // Voice message + else if (event->request != NULL && MSG_IS_NOTIFY(event->request)){ + int ii; + unsigned int pos; + unsigned int pos_slash; + string *str; + string nb_msg; + osip_body_t *body; + + // Get the message body + ii = osip_message_get_body(event->request, 0, &body); + if (ii != 0) { + _debug("Cannot get body\n"); + return -1; + } + + // Analyse message body + str = new string(body->body); + pos = str->find (VOICE_MSG); + + if (pos == string::npos) { + // If the string is not found + return -1; + } + + pos_slash = str->find ("/"); + nb_msg = str->substr(pos + LENGTH_VOICE_MSG, + pos_slash - (pos + LENGTH_VOICE_MSG)); + + // Set the number of voice-message + setMsgVoicemail(atoi(nb_msg.data())); + + if (getMsgVoicemail() != 0) { + // If there is at least one voice-message, start notification + Manager::instance().startVoiceMessageNotification(); + } else { + // Stop notification when there is 0 voice message + Manager::instance().stopVoiceMessageNotification(); + } + delete str; } break; diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index e8caf1ffad..f0ec02e484 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -1,7 +1,9 @@ /** * Copyright (C) 2004-2005 Savoir-Faire Linux inc. * Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * + * + * Portions Copyright (C) 2002,2003 Aymeric Moizard <jack@atosc.org> + * * 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 @@ -125,6 +127,10 @@ public: // Use to Cancel inline void setCid (int cid) { _cid = cid; } inline int getCid (void) { return _cid; } + + // Handle voice-message + inline void setMsgVoicemail (int nMsg) { _nMsgVoicemail = nMsg; } + inline int getMsgVoicemail (void) { return _nMsgVoicemail; } private: /* @@ -215,6 +221,7 @@ private: int _localPort; int _cid; int _reg_id; + int _nMsgVoicemail; }; #endif // __SIP_VOIP_LINK_H__ diff --git a/src/skin.cpp b/src/skin.cpp index 97d1261e55..b4d9809261 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -20,9 +20,6 @@ #include "skin.h" -#ifndef PROGSHAREDIR -#error "You must run configure to define PREFIX and PROGSHAREDIR." -#endif const char* PIXMAP_LINE_NAMES[] = { PIXMAP_LINE0_OFF, -- GitLab