Merge branch 'm_savard'

This commit is contained in:
Alexandre Savard
2010-02-18 09:49:57 -05:00
18 changed files with 291 additions and 162 deletions

View File

@ -25,11 +25,10 @@
#include <statusicon.h>
#if GTK_CHECK_VERSION(2,10,0)
GtkStatusIcon* status;
GtkWidget * show_menu_item;
GtkStatusIcon *status;
GtkWidget *show_menu_item, *hangup_menu_item;
gboolean __minimized = MINIMIZED;
void popup_main_window (void)
{
if (__POPUP_WINDOW)
@ -40,18 +39,39 @@ void popup_main_window (void)
}
}
void show_status_hangup_icon() {
DEBUG("Show Hangup in Systray");
gtk_widget_show(GTK_WIDGET(hangup_menu_item));
}
void hide_status_hangup_icon() {
DEBUG("Hide Hangup in Systray");
gtk_widget_hide(GTK_WIDGET(hangup_menu_item));
}
void
status_quit ( void * foo UNUSED)
{
sflphone_quit();
}
void
status_hangup ()
{
sflphone_hang_up();
}
void
status_icon_unminimize()
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), TRUE);
}
gboolean main_widget_minimized()
{
return __minimized;
@ -92,6 +112,7 @@ GtkWidget* create_menu()
{
GtkWidget * menu;
GtkWidget * menu_items;
GtkWidget * image;
menu = gtk_menu_new ();
@ -101,10 +122,18 @@ GtkWidget* create_menu()
g_signal_connect(G_OBJECT (show_menu_item), "toggled",
G_CALLBACK (show_hide),
NULL);
hangup_menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(hangup_menu_item), image);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), hangup_menu_item);
g_signal_connect(G_OBJECT (hangup_menu_item), "activate",
G_CALLBACK (status_hangup),
NULL);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_QUIT, get_accel_group());
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (status_quit),

View File

@ -45,6 +45,19 @@ void show_status_icon();
*/
void status_icon_unminimize();
/**
* Show hangup icon
*/
void show_status_hangup_icon();
/**
* Show hangup icon
*/
void hide_status_hangup_icon();
/**
* Tells if the main window if minimized or not
* @return gboolean TRUE if the main window is minimized

View File

@ -25,15 +25,15 @@
<menuitem action="Preferences"/>
</menu>
<menu name="ViewMenu" action="View">
<menu name="ViewMenu" action="View">
<menuitem action="Toolbar"/>
<separator/>
<menuitem action="Dialpad"/>
<!--menuitem name="VolumeControlsToggle" action="VolumeControls"/-->
<menuitem action="VolumeControls"/>
<separator/>
<menuitem action="History"/>
<menuitem action="Addressbook"/>
<menuitem action="History"/>
<menuitem action="Addressbook"/>
</menu>
<menu name="HelpMenu" action="Help">
@ -41,25 +41,25 @@
<menuitem action="About"/>
</menu>
</menubar>
</menubar>
<toolbar name="ToolbarActions">
<toolitem name="NewCallToolbar" action="NewCall"/>
<toolitem name="PickUpToolbar" action="PickUp"/>
<toolitem name="HangUpToolbar" action="HangUp"/>
<toolitem name="OnHoldToolbar" action="OnHold"/>
<toolitem name="OffHoldToolbar" action="OffHold"/>
<toolitem name="TransferToolbar" action="Transfer"/>
<toolitem name="RecordToolbar" action="Record"/>
<separator/>
<toolitem name="VoicemailToolbar" action="Voicemail"/>
<toolitem name="HistoryToolbar" action="History"/>
<toolitem name="AddressbookToolbar" action="Addressbook"/>
</toolbar>
<toolbar name="ToolbarActions">
<toolitem name="NewCallToolbar" action="NewCall"/>
<toolitem name="PickUpToolbar" action="PickUp"/>
<toolitem name="HangUpToolbar" action="HangUp"/>
<toolitem name="OnHoldToolbar" action="OnHold"/>
<toolitem name="OffHoldToolbar" action="OffHold"/>
<toolitem name="TransferToolbar" action="Transfer"/>
<toolitem name="RecordToolbar" action="Record"/>
<separator/>
<toolitem name="VoicemailToolbar" action="Voicemail"/>
<toolitem name="HistoryToolbar" action="History"/>
<toolitem name="AddressbookToolbar" action="Addressbook"/>
</toolbar>
<popup name="PopupMenu">
<menuitem action="Copy"/>
<menuitem action="Paste"/>
<separator/>
</popup>
<popup name="PopupMenu">
<menuitem action="Copy"/>
<menuitem action="Paste"/>
<separator/>
</popup>
</ui>

View File

@ -27,6 +27,7 @@
#include <glib/gprintf.h>
#include <libgnome/gnome-help.h>
#include <uimanager.h>
#include <statusicon.h>
static GtkWidget *toolbar;
static GtkWidget *toolbarWindows;
@ -147,7 +148,9 @@ void update_actions()
if (selectedCall)
{
// DEBUG("------------------------- selected call ---------------------------\n");
// update icon in systray
show_status_hangup_icon();
gtk_action_set_sensitive (GTK_ACTION (copyAction), TRUE);
switch(selectedCall->_state)
@ -225,7 +228,8 @@ void update_actions()
}
else if (selectedConf){
// DEBUG("------------------------- selected conf ---------------------------\n");
// update icon in systray
show_status_hangup_icon();
switch(selectedConf->_state) {
@ -265,6 +269,10 @@ void update_actions()
}
else {
// update icon in systray
hide_status_hangup_icon();
if( account_list_get_size() > 0 && current_account_has_mailbox ())
{
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (voicemailToolbar), -2);

View File

@ -58,7 +58,7 @@ class AudioLayer {
*/
AudioLayer( ManagerImpl* manager , int type )
: _defaultVolume(100)
, _layerType( type )
, _layerType( type )
, _manager(manager)
, _urgentRingBuffer( SIZEBUF, default_id )
, _indexIn ( 0 )

View File

@ -24,20 +24,19 @@ static pa_channel_map channel_map;
AudioStream::AudioStream (PulseLayerType * driver)
AudioStream::AudioStream (PulseLayerType * driver, int smplrate)
: _audiostream (NULL),
_context (driver->context),
_streamType (driver->type),
_streamDescription (driver->description),
_volume(),
flag (PA_STREAM_AUTO_TIMING_UPDATE),
sample_spec(),
_flag (PA_STREAM_AUTO_TIMING_UPDATE),
_sample_spec(),
_mainloop (driver->mainloop)
{
sample_spec.format = PA_SAMPLE_S16LE;
// sample_spec.format = PA_SAMPLE_FLOAT32LE;
sample_spec.rate = 44100;
sample_spec.channels = 1;
_sample_spec.format = PA_SAMPLE_S16LE; // PA_SAMPLE_FLOAT32LE;
_sample_spec.rate = smplrate;
_sample_spec.channels = 1;
channel_map.channels = 1;
pa_cvolume_set (&_volume , 1 , PA_VOLUME_NORM) ; // * vol / 100 ;
}
@ -178,20 +177,13 @@ AudioStream::createStream (pa_context* c)
ost::MutexLock guard (_mutex);
pa_stream* s;
//pa_cvolume cv;
// pa_sample_spec ss;
// ss.format = PA_SAMPLE_S16LE;
// ss.rate = 44100;
// ss.channels = 1;
assert (pa_sample_spec_valid (&sample_spec));
assert (pa_sample_spec_valid (&_sample_spec));
assert (pa_channel_map_valid (&channel_map));
pa_buffer_attr* attributes = (pa_buffer_attr*) malloc (sizeof (pa_buffer_attr));
if (! (s = pa_stream_new (c, _streamDescription.c_str() , &sample_spec, &channel_map)))
if (! (s = pa_stream_new (c, _streamDescription.c_str() , &_sample_spec, &channel_map)))
_debug ("%s: pa_stream_new() failed : %s" , _streamDescription.c_str(), pa_strerror (pa_context_errno (c)));
assert (s);
@ -202,7 +194,7 @@ AudioStream::createStream (pa_context* c)
// 20 ms framesize TODO: take framesize value from config
attributes->maxlength = (uint32_t) -1;
attributes->tlength = pa_usec_to_bytes (100 * PA_USEC_PER_MSEC, &sample_spec);
attributes->tlength = pa_usec_to_bytes (100 * PA_USEC_PER_MSEC, &_sample_spec);
attributes->prebuf = 0;
attributes->minreq = (uint32_t) -1;
attributes->fragsize = (uint32_t) -1;
@ -215,7 +207,7 @@ AudioStream::createStream (pa_context* c)
attributes->tlength = (uint32_t) -1;
attributes->prebuf = (uint32_t) -1;
attributes->minreq = (uint32_t) -1;
attributes->fragsize = pa_usec_to_bytes (50 * PA_USEC_PER_MSEC, &sample_spec);
attributes->fragsize = pa_usec_to_bytes (50 * PA_USEC_PER_MSEC, &_sample_spec);

View File

@ -54,7 +54,7 @@ class AudioStream {
* Constructor
* @param context The PulseLayerType structure containing various information.
*/
AudioStream(PulseLayerType * driver);
AudioStream(PulseLayerType * driver, int smplrate);
/**
* Destructor
@ -175,8 +175,8 @@ class AudioStream {
* Streams parameters
*/
pa_cvolume _volume;
pa_stream_flags_t flag;
pa_sample_spec sample_spec ;
pa_stream_flags_t _flag;
pa_sample_spec _sample_spec ;
pa_threaded_mainloop * _mainloop;

View File

@ -243,7 +243,7 @@ bool PulseLayer::createStreams (pa_context* c)
playbackParam->volume = _manager->getSpkrVolume();
playbackParam->mainloop = m;
playback = new AudioStream (playbackParam);
playback = new AudioStream (playbackParam, _audioSampleRate);
playback->connectStream();
pa_stream_set_write_callback (playback->pulseStream(), playback_callback, this);
pa_stream_set_overflow_callback (playback->pulseStream(), playback_overflow_callback, this);
@ -259,7 +259,7 @@ bool PulseLayer::createStreams (pa_context* c)
recordParam->volume = _manager->getMicVolume();
recordParam->mainloop = m;
record = new AudioStream (recordParam);
record = new AudioStream (recordParam, _audioSampleRate);
record->connectStream();
pa_stream_set_read_callback (record->pulseStream() , capture_callback, this);
// pa_stream_set_suspended_callback(record->pulseStream(), stream_suspended_callback, this);

View File

@ -20,7 +20,7 @@
#include "manager.h"
SamplerateConverter::SamplerateConverter (void)
: _frequence (Manager::instance().getConfigInt (AUDIO , ALSA_SAMPLE_RATE)) //44100
: _frequence (Manager::instance().getConfigInt (AUDIO , AUDIO_SAMPLE_RATE)) //44100
, _framesize (Manager::instance().getConfigInt (AUDIO , ALSA_FRAME_SIZE))
, _floatBufferDownMic (NULL)
, _floatBufferUpMic (NULL)

View File

@ -40,8 +40,7 @@ void
CallManager::placeCall (const std::string& accountID,
const std::string& callID,
const std::string& to)
{
// Check if a destination number is available
{ // Check if a destination number is available
if (to == "") _debug ("No number entered - Call stopped");
else Manager::instance().outgoingCall (accountID, callID, to);

View File

@ -162,6 +162,8 @@
<method name="addAccount">
<!--* Add a new account to the SFLphone-daemon list. If no
details are specified, default parameters are used.
A REGISTER is automatically sent and configuration is
saved if account created successfully.
@param[in] input details
@param[out] output accountID

View File

@ -2293,7 +2293,7 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate)
// Audio settings
_config.addDefaultValue (std::pair<std::string, std::string> (ALSA_CARD_ID_IN, ALSA_DFT_CARD), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (ALSA_CARD_ID_OUT, ALSA_DFT_CARD), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (ALSA_SAMPLE_RATE, DFT_SAMPLE_RATE), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (AUDIO_SAMPLE_RATE, DFT_SAMPLE_RATE), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (ALSA_FRAME_SIZE, DFT_FRAME_SIZE), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (ALSA_PLUGIN, PCM_DEFAULT), AUDIO);
_config.addDefaultValue (std::pair<std::string, std::string> (RING_CHOICE, DFT_RINGTONE), AUDIO);
@ -2958,7 +2958,7 @@ ManagerImpl::selectAudioDriver (void)
alsaPlugin = getConfigString (AUDIO , ALSA_PLUGIN);
numCardIn = getConfigInt (AUDIO , ALSA_CARD_ID_IN);
numCardOut = getConfigInt (AUDIO , ALSA_CARD_ID_OUT);
sampleRate = getConfigInt (AUDIO , ALSA_SAMPLE_RATE);
sampleRate = getConfigInt (AUDIO , AUDIO_SAMPLE_RATE);
if (sampleRate <=0 || sampleRate > 48000) {
sampleRate = 44100;
@ -3007,7 +3007,7 @@ void ManagerImpl::switchAudioManager (void)
type = _audiodriver->getLayerType();
samplerate = getConfigInt (AUDIO , ALSA_SAMPLE_RATE);
samplerate = getConfigInt (AUDIO , AUDIO_SAMPLE_RATE);
framesize = getConfigInt (AUDIO , ALSA_FRAME_SIZE);

View File

@ -31,31 +31,31 @@
#define ACCOUNT_IAX0 "IAX0" /** Account type IAX */
/** User configuration file fields */
#define AUDIO "Audio" /** Section Audio */
#define CODECS "ActiveCodecs" /** List of active codecs */
#define AUDIO "Audio" /** Section Audio */
#define CODECS "ActiveCodecs" /** List of active codecs */
#define ALSA_CARD_ID_IN "Alsa.cardID_In" /** Soundcard index to use for capture */
#define ALSA_CARD_ID_OUT "Alsa.cardID_Out" /** Soundcard index to use for playback */
#define ALSA_FRAME_SIZE "Alsa.framesize" /** Audio layer frame size */
#define ALSA_PLUGIN "Alsa.plugin" /** Alsa plugin */
#define ALSA_SAMPLE_RATE "Alsa.sampleRate" /** Audio layer sample rate */
#define RING_CHOICE "Rings.ringChoice" /** Ringtone */
#define VOLUME_SPKR "Volume.speakers" /** Speaker volume */
#define ALSA_PLUGIN "Alsa.plugin" /** Alsa plugin */
#define AUDIO_SAMPLE_RATE "Alsa.sampleRate" /** Audio layer sample rate */
#define RING_CHOICE "Rings.ringChoice" /** Ringtone */
#define VOLUME_SPKR "Volume.speakers" /** Speaker volume */
#define VOLUME_MICRO "Volume.micro" /** Mic volume */
#define RECORD_PATH "Record.path" /** Recording path */
#define PREFERENCES "Preferences" /** Section Preferences */
#define PREFERENCES "Preferences" /** Section Preferences */
#define CONFIG_MD5HASH "md5Hash" /** Option to store credential as md5 hash*/
#define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */
#define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */
#define CONFIG_SEARCHBAR "Searchbar.display" /** Whether or nor display the search bar */
#define CONFIG_HISTORY_LIMIT "History.limit" /** Set the maximum number of days kept */
#define CONFIG_HISTORY_ENABLED "History.enabled" /** Is the history enabled or not */
#define CONFIG_NOTIFY "Notify.all" /** Desktop notification level */
#define CONFIG_MAIL_NOTIFY "Notify.mails" /** Desktop mail notification level */
#define ZONE_TONE "Options.zoneToneChoice" /** Country tone */
#define CONFIG_RINGTONE "Ringtones.enable" /** Ringtones preferences */
#define CONFIG_START "Start.hidden" /** SFLphone starts in the systm tray or not */
#define CONFIG_POPUP "Window.popup" /** SFLphone pops up on incoming calls or not */
#define CONFIG_VOLUME "Volume.display" /** Display the mic and speaker volume controls */
#define ZONE_TONE "Options.zoneToneChoice" /** Country tone */
#define CONFIG_RINGTONE "Ringtones.enable" /** Ringtones preferences */
#define CONFIG_START "Start.hidden" /** SFLphone starts in the systm tray or not */
#define CONFIG_POPUP "Window.popup" /** SFLphone pops up on incoming calls or not */
#define CONFIG_VOLUME "Volume.display" /** Display the mic and speaker volume controls */
#define CONFIG_AUDIO "Audio.api" /** Audio manager (ALSA or pulseaudio) */
#define CONFIG_PA_VOLUME_CTRL "Pulseaudio.volumeCtrl" /** Whether or not PA should modify volume of other applications on the same sink */
#define CONFIG_SIP_PORT "SIP.portNum"
@ -68,11 +68,11 @@
#define IP2IP_PROFILE "IP2IP"
#define SIGNALISATION "VoIPLink" /** Section Signalisation */
#define ZRTP_ZIDFILE "ZRTP.zidFile" /** The filename used for storing ZIDs */
#define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */
#define PLAY_TONES "DTMF.playTones" /** Whether or not should play tones */
#define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */
#define PLAY_TONES "DTMF.playTones" /** Whether or not should play tones */
#define PULSE_LENGTH "DTMF.pulseLength" /** Length of the DTMF in millisecond */
#define SEND_DTMF_AS "DTMF.sendDTMFas" /** DTMF send mode */
#define SYMMETRIC "VoIPLink.symmetric" /** VoIP link type */
#define SYMMETRIC "VoIPLink.symmetric" /** VoIP link type */
#define ADDRESSBOOK "Addressbook" /** Address book section */
#define ADDRESSBOOK_ENABLE "Addressbook.enable" /** Enable address book */
@ -91,26 +91,26 @@
#define PHONE_NUMBER_HOOK_ENABLED "Hooks.phone_number_enabled"
#define PHONE_NUMBER_HOOK_ADD_PREFIX "Hooks.phone_number_add_prefix"
#define EMPTY_FIELD "" /** Default value for empty field */
#define EMPTY_FIELD "" /** Default value for empty field */
#define DEFAULT_ACCOUNT_TYPE "SIP"
#define DFT_STUN_SERVER "stun.sflphone.org" /** Default STUN server address */
#define TRUE_STR "true" /** Default YES value */
#define FALSE_STR "false" /** Default NO value */
#define DFT_STUN_SERVER "stun.sflphone.org" /** Default STUN server address */
#define TRUE_STR "true" /** Default YES value */
#define FALSE_STR "false" /** Default NO value */
#define DFT_PULSE_LENGTH_STR "250" /** Default DTMF lenght */
#define SIP_INFO_STR "0" /** Default DTMF transport mode */
#define ALSA_DFT_CARD "0" /** Default sound card index */
#define DFT_VOL_SPKR_STR "100" /** Default speaker volume */
#define DFT_VOL_MICRO_STR "100" /** Default mic volume */
#define DFT_RINGTONE "konga.ul" /** Default ringtone */
#define DFT_ZONE "North America" /** Default geographical zone */
#define DFT_VOICEMAIL "888" /** Default voicemail number */
#define DFT_FRAME_SIZE "20" /** Default frame size in millisecond */
#define DFT_SAMPLE_RATE "44100" /** Default sample rate in HZ */
#define DFT_NOTIF_LEVEL "2" /** Default desktop notification level : maximum */
#define DFT_HISTORY_LIMIT "30" /** Default maximum days in history */
#define DFT_EXPIRE_VALUE "600" /** Default expire value for registration */
#define DFT_RESOLVE_ONCE FALSE_STR
#define DFT_AUDIO_MANAGER "1" /** Default audio manager */
#define SIP_INFO_STR "0" /** Default DTMF transport mode */
#define ALSA_DFT_CARD "0" /** Default sound card index */
#define DFT_VOL_SPKR_STR "100" /** Default speaker volume */
#define DFT_VOL_MICRO_STR "100" /** Default mic volume */
#define DFT_RINGTONE "konga.ul" /** Default ringtone */
#define DFT_ZONE "North America" /** Default geographical zone */
#define DFT_VOICEMAIL "888" /** Default voicemail number */
#define DFT_FRAME_SIZE "20" /** Default frame size in millisecond */
#define DFT_SAMPLE_RATE "44100" /** Default sample rate in HZ */
#define DFT_NOTIF_LEVEL "2" /** Default desktop notification level : maximum */
#define DFT_HISTORY_LIMIT "30" /** Default maximum days in history */
#define DFT_EXPIRE_VALUE "600" /** Default expire value for registration */
#define DFT_RESOLVE_ONCE FALSE_STR
#define DFT_AUDIO_MANAGER "1" /** Default audio manager */
#define DFT_SIP_PORT "5060"
#define DFT_STUN_ENABLE FALSE_STR
#define DFT_RECORD_PATH HOMEDIR

View File

@ -63,7 +63,7 @@ void AudioLayerTest::setUp()
void AudioLayerTest::testAudioLayerConfig()
{
int sampling_rate = Manager::instance().getConfigInt (AUDIO, ALSA_SAMPLE_RATE);
int sampling_rate = Manager::instance().getConfigInt (AUDIO, AUDIO_SAMPLE_RATE);
int frame_size = Manager::instance().getConfigInt (AUDIO, ALSA_FRAME_SIZE);
frame_size = 0; // frame size in config not used anymore
@ -122,7 +122,7 @@ void AudioLayerTest::testPulseConnect()
alsaPlugin = manager->getConfigString (AUDIO , ALSA_PLUGIN);
numCardIn = manager->getConfigInt (AUDIO , ALSA_CARD_ID_IN);
numCardOut = manager->getConfigInt (AUDIO , ALSA_CARD_ID_OUT);
sampleRate = manager->getConfigInt (AUDIO , ALSA_SAMPLE_RATE);
sampleRate = manager->getConfigInt (AUDIO , AUDIO_SAMPLE_RATE);
frameSize = manager->getConfigInt (AUDIO, ALSA_FRAME_SIZE);
CPPUNIT_ASSERT (_pulselayer->getPlaybackStream() == NULL);

View File

@ -5,25 +5,12 @@
# In Firefox use Preferences > Applications and set the callto handler
# to this script.
# The sflphone daemon config file
RESFILE=~/.config/sflphone/sflphonedrc
# Parse sflphonedrc and get default account id string
if [ -f "$RESFILE" ]; then
# Use first ID
ACCOUNTID=`grep Accounts.order $RESFILE | sed -e 's/Accounts.order=//' -e 's/\/.*//'`
# Accounts.order is not set
if [ -z $ACCOUNTID ]; then
# Use first account declared in sflphone config
ACCOUNTID="`grep -m 1 Account: $RESFILE | sed -e 's/\[//' -e 's/\]//'`"
fi
else
echo Fatal: Cant find sflphonedrc config file.
exit 1
# Test if a SFLphone client is already open, if not open a new one
# Opening a new client will start sflphoned if not already running
SFLPHONEC=`ps -A | grep sflphone-client`
if [ "$SFLPHONEC" = "" ]; then
/usr/bin/sflphone-client-gnome&
fi
# Check 1st argument (phone number)
@ -38,13 +25,16 @@ TO="`echo $1 | sed -e 's/[^0123456789]//g'`"
# Generate call id.
CALLID=${RANDOM}$$
dbus-send \
--type="method_call" \
--dest="org.sflphone.SFLphone" \
"/org/sflphone/SFLphone/CallManager" \
"org.sflphone.SFLphone.CallManager.placeCall" \
string:"$ACCOUNTID" \
string:"$CALLID" \
# Dbus placeCallFirstAccount method does not reach sflphoned if starting
# Should find another way to do this
sleep 1
dbus-send \
--type="method_call" \
--dest="org.sflphone.SFLphone" \
"/org/sflphone/SFLphone/CallManager" \
"org.sflphone.SFLphone.CallManager.placeCallFirstAccount" \
string:"$CALLID" \
string:"$TO"
exit 0

View File

@ -61,7 +61,8 @@ def printHelp():
--gaia Get all IAX accounts. \n\
--gcc Get current callid. \n\
--gacl Get active codec list. \n\
\n\
--sac Set accout for next call \n\
\n\
--gad <account> Get account details . \n\
--enable <account> Enable the account. \n\
--disable <account> Disable the account. \n\
@ -83,9 +84,12 @@ def printHelp():
# Option definition
try:
opts, args = getopt.getopt(sys.argv[1:],"", [ "help", "gaa", "gal", "gara", "gaea", "gasa", "gaia", "gacl", "gac", "gcc",
"hangup=", "refuse=", "hold", "unhold=", "transfer=","dtmf=", "accept=",
"gcd=", "gad=", "register=", "unregister=", "enable=", "disable=", "call=" ])
opts, args = getopt.getopt(sys.argv[1:],"",
[ "help", "gaa", "gal", "gara", "gaea", "gasa", "gaia",
"gacl", "gac", "gcc", "hangup=", "refuse=", "hold",
"unhold=", "transfer=","dtmf=", "accept=", "gcd=",
"gad=", "register=", "unregister=", "enable=", "disable=",
"call=", "sac=" ])
except getopt.GetoptError,err:
print str(err)
sys.exit(2)
@ -166,6 +170,12 @@ else:
print "Account: " + details['ACCOUNTID']
print "Peer: " + details['PEER_NAME'] + "<" + details['PEER_NUMBER'] + ">"
elif opt == "--sac":
if arg is "":
print "Must specifies the accout to be set"
else:
sflphone.setAccount(arg)
#
# call options

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
import time
from sflphonectrlsimple import SflPhoneCtrlSimple
@ -7,40 +8,76 @@ class SflPhoneTests(SflPhoneCtrlSimple):
def test_get_allaccounts_methods(self):
print "--- getAllAccounts() ---"
for account in self.getAllAccounts():
print " " + account
print "\n"
print "--- getAllRegisteredAccounts() ---"
for account in self.getAllRegisteredAccounts():
print " " + account
print "\n"
print "--- getAllSipAccounts() ---"
for account in self.getAllSipAccounts():
print " " + account
print "\n"
print "--- getAllIaxAccounts() ---"
for account in self.getAllIaxAccounts():
print " " + account
print "\n"
# def test_codecs_methods(self):
def test_make_iptoip_call(self):
"""Make a call to a server (sipp) on port 5062"""
i = 0
while(i < 50):
# print "--- getCodecList() ---"
# for codec int self.getCodecList():
# print " " + codec
# print "\n"
callid = self.Call("sip:test@127.0.0.1:5062")
time.sleep(0.4)
self.HangUp(callid)
time.sleep(0.4)
i = i+1
def test_make_account_call(self):
"""Register an account on a remote server and make several calls"""
self.setAccount("Account:1258495784");
time.sleep(3)
i = 0
while(i < 50):
callid = self.Call("5000")
time.sleep(0.4)
self.HangUp(callid)
time.sleep(0.4)
i = i+1
sfl = SflPhoneTests()
def test_create_account(self):
"""Create a new sip fake account and remove it"""
sfl.test_get_allaccounts_methods()
CONFIG_ACCOUNT_TYPE = "Account.type"
CONFIG_ACCOUNT_ALIAS = "Account.alias"
HOSTNAME = "hostname"
USERNAME = "username"
PASSWORD = "password"
accDetails = {CONFIG_ACCOUNT_TYPE:"SIP", CONFIG_ACCOUNT_ALIAS:"myNewAccount",
HOSTNAME:"192.168.50.3", USERNAME:"431",
PASSWORD:"alexandre"}
accountID = self.addAccount(accDetails)
print "New Account ID " + accountID
time.sleep(3)
self.removeAccount(accountID)
print "Account with ID " + accountID + " removed"
sflphone = SflPhoneTests()
sflphone.test_get_allaccounts_methods()
sflphone.test_make_iptoip_call()
sflphone.test_make_account_call()
sflphone.test_create_account()

View File

@ -29,7 +29,7 @@ from gobject import GObject
import getopt
import time
import md5
import hashlib
from threading import Thread
@ -170,13 +170,40 @@ class SflPhoneCtrlSimple(object):
#
# Account management
#
def addAccount(self, details=None):
"""Add a new account account
Add a new account to the SFLphone-daemon. Default parameters are \
used for missing account configuration field.
Required parameters are type, alias, hostname, username and password
input details
"""
if details is None:
raise SPaccountError("Must specifies type, alias, hostname, \
username and password in \
order to create a new account")
return self.configurationmanager.addAccount(details)
def removeAccount(self, accountID=None):
"""Remove an account from internal list"""
if accountID is None:
raise SPaccountError("Account ID must be specified")
self.configurationmanager.removeAccount(accountID)
def getAllAccounts(self):
""" Return a list with all accounts"""
"""Return a list with all accounts"""
return self.configurationmanager.getAccountList()
def getAllEnabledAccounts(self):
""" Return a list with all enabled accounts"""
"""Return a list with all enabled accounts"""
accounts = self.getAllAccounts()
activeaccounts = []
for testedaccount in accounts:
@ -222,11 +249,15 @@ class SflPhoneCtrlSimple(object):
raise SPaccountError("No account matched with alias")
def setAccount(self, account):
"""Define the active account"""
"""Define the active account
The active account will be used when sending a new call
"""
if account in self.getAllAccounts():
self.account = account
else:
print account
raise SflPhoneError("Not a valid account")
def setFirstRegisteredAccount(self):
@ -315,7 +346,6 @@ class SflPhoneCtrlSimple(object):
def getAllSipAccounts(self):
"""Return a list of SIP accounts"""
sipAccountsList = []
for accountName in self.getAllAccounts():
if self.getAccountDetails(accountName)['Account.type'] == "SIP":
@ -395,24 +425,36 @@ class SflPhoneCtrlSimple(object):
# Action
#
def Call(self, dest):
"""Start a call and return a CallID"""
if not self.account:
"""Start a call and return a CallID
Use the current account previously set using setAccount().
If no account specified, first registered one in account list is used.
For phone number prefixed using SIP scheme (i.e. sip: or sips:),
IP2IP profile is automatically selected and set as the default account
return callID Newly generated callidentifier for this call
"""
if dest is None or dest == "":
raise SflPhoneError("Invalid call destination")
# Set the account to be used for this call
if dest.find('sip:') is 0 or dest.find('sips:') is 0:
print "Ip 2 IP call"
self.setAccount("IP2IP")
elif not self.account:
self.setFirstRegisteredAccount()
if not self.isAccountRegistered():
if self.account is "IP2IP" and self.isAccountRegistered():
raise SflPhoneError("Can't place a call without a registered account")
if dest is None or dest == "":
raise SflPhoneError("Invalid call destination")
# callid = str(random.randrange(2**32-1))
t = long( time.time() * 1000 )
r = long( random.random()*100000000000000000L )
data = str(t) + str(r)
callid = md5.md5(data).hexdigest()
# Generate a call ID for this call
callid = self.GenerateCallID()
# Add the call to the list of active calls and set status to SENT
self.activeCalls[callid] = {'Account': self.account, 'To': dest, 'State': 'SENT' }
# Send the request to the CallManager
self.callmanager.placeCall(self.account, callid, dest)
@ -424,14 +466,14 @@ class SflPhoneCtrlSimple(object):
if not self.account:
self.setFirstRegisteredAccount()
if not self.isAccountRegistered():
raise SflPhoneError("Can't hangup a call without a registered account")
# if not self.isAccountRegistered() and self.accout is not "IP2IP":
# raise SflPhoneError("Can't hangup a call without a registered account")
if callid is None or callid == "":
pass # just to see
#raise SflPhoneError("Invalid callID")
self.callmanager.hangUp(callid)
self.callmanager.hangUp(callid)
def Transfert(self, callid, to):
@ -509,4 +551,11 @@ class SflPhoneCtrlSimple(object):
self.callmanager.playDTMF(key)
def GenerateCallID(self):
"""Generate Call ID"""
m = hashlib.md5()
t = long( time.time() * 1000 )
r = long( random.random()*100000000000000000L )
m.update(str(t) + str(r))
callid = m.hexdigest()
return callid