114
121
status_bar_display_account ()
119
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
126
statusbar_pop_message (__MSG_ACCOUNT_DEFAULT);
128
DEBUG ("status_bar_display_account begin");
121
130
acc = account_list_get_current ();
123
status_tray_icon_online(TRUE);
124
msg = g_markup_printf_escaped("%s %s (%s)" ,
126
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS),
127
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE));
131
status_tray_icon_online(FALSE);
132
msg = g_markup_printf_escaped(_("No registered accounts"));
134
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
133
status_tray_icon_online (TRUE);
134
msg = g_markup_printf_escaped ("%s %s (%s)" ,
136
(gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_ALIAS),
137
(gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_TYPE));
139
status_tray_icon_online (FALSE);
140
msg = g_markup_printf_escaped (_ ("No registered accounts"));
143
statusbar_push_message (msg, NULL, __MSG_ACCOUNT_DEFAULT);
146
DEBUG ("status_bar_display_account_end");
142
153
gboolean quit = FALSE;
143
guint count = calllist_get_size(current_calls);
154
guint count = calllist_get_size (current_calls);
145
157
quit = main_window_ask_quit();
154
164
sflphone_save_history ();
156
dbus_unregister(getpid());
166
dbus_unregister (getpid());
158
168
//call_list_clean(); TODO
159
169
//account_list_clean()
160
170
gtk_main_quit ();
166
sflphone_hold (callable_obj_t * c )
177
sflphone_hold (callable_obj_t * c)
168
179
c->_state = CALL_STATE_HOLD;
169
calltree_update_call(current_calls, c, NULL);
180
calltree_update_call (current_calls, c, NULL);
170
181
update_actions();
174
sflphone_ringing(callable_obj_t * c )
185
sflphone_ringing (callable_obj_t * c)
176
187
c->_state = CALL_STATE_RINGING;
177
calltree_update_call(current_calls, c, NULL);
188
calltree_update_call (current_calls, c, NULL);
178
189
update_actions();
182
sflphone_hung_up( callable_obj_t * c)
193
sflphone_hung_up (callable_obj_t * c)
184
calllist_remove( current_calls, c->_callID);
185
calltree_remove_call(current_calls, c, NULL);
195
DEBUG ("SFLphone: Hung up");
197
calllist_remove (current_calls, c->_callID);
198
calltree_remove_call (current_calls, c, NULL);
186
199
c->_state = CALL_STATE_DIALING;
187
call_remove_all_errors(c);
200
call_remove_all_errors (c);
188
201
update_actions();
203
// test wether the widget contain text, if not remove it
204
if ( (im_window_get_nb_tabs() > 1) && c->_im_widget && ! (IM_WIDGET (c->_im_widget)->containText))
205
im_window_remove_tab (c->_im_widget);
207
im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE);
189
209
#if GTK_CHECK_VERSION(2,10,0)
190
status_tray_icon_blink( FALSE );
210
status_tray_icon_blink (FALSE);
194
static hashtable_free(gpointer key, gpointer value, gpointer user_data)
212
calltree_update_clock();
200
215
/** Internal to actions: Fill account list */
201
void sflphone_fill_account_list (void) {
216
void sflphone_fill_account_list (void)
204
220
gchar** accountID;
209
DEBUG("SFLphone: Fill account list");
211
count = current_account_get_message_number ();
224
DEBUG ("SFLphone: Fill account list");
226
count = current_account_get_message_number ();
213
228
account_list_clear ();
215
array = (gchar **)dbus_account_list();
218
for (accountID = array; *accountID; accountID++)
220
account_t * a = g_new0(account_t,1);
221
a->accountID = g_strdup(*accountID);
230
array = (gchar **) dbus_account_list();
234
for (accountID = array; *accountID; accountID++) {
235
account_t * a = g_new0 (account_t,1);
236
a->accountID = g_strdup (*accountID);
222
237
a->credential_information = NULL;
223
// TODO Clean codec list QUEUE
238
account_list_add (a);
226
241
g_strfreev (array);
229
for( i = 0; i < account_list_get_size(); i++)
244
for (i = 0; i < account_list_get_size(); i++) {
231
245
account_t * a = account_list_get_nth (i);
232
GHashTable * details = (GHashTable *) dbus_account_details(a->accountID);
233
if( details == NULL )
246
GHashTable * details = (GHashTable *) dbus_account_details (a->accountID);
235
251
a->properties = details;
237
/* As this function might be called numberous time, we should free the
253
/* As this function might be called numberous time, we should free the
238
254
* previously allocated space to avoid memory leaks.
241
257
/* Fill the actual array of credentials */
242
int number_of_credential = dbus_get_number_of_credential(a->accountID);
243
if(number_of_credential) {
258
int number_of_credential = dbus_get_number_of_credential (a->accountID);
260
if (number_of_credential) {
244
261
a->credential_information = g_ptr_array_new();
246
263
a->credential_information = NULL;
249
266
int credential_index;
250
for(credential_index = 0; credential_index < number_of_credential; credential_index++) {
268
for (credential_index = 0; credential_index < number_of_credential; credential_index++) {
251
269
GHashTable * credential_information = dbus_get_credential (a->accountID, credential_index);
252
g_ptr_array_add(a->credential_information, credential_information);
270
g_ptr_array_add (a->credential_information, credential_information);
255
gchar * status = g_hash_table_lookup(details, REGISTRATION_STATUS);
256
if(strcmp(status, "REGISTERED") == 0)
273
gchar * status = g_hash_table_lookup (details, REGISTRATION_STATUS);
275
if (strcmp (status, "REGISTERED") == 0) {
258
276
a->state = ACCOUNT_STATE_REGISTERED;
260
else if(strcmp(status, "UNREGISTERED") == 0)
277
} else if (strcmp (status, "UNREGISTERED") == 0) {
262
278
a->state = ACCOUNT_STATE_UNREGISTERED;
264
else if(strcmp(status, "TRYING") == 0)
279
} else if (strcmp (status, "TRYING") == 0) {
266
280
a->state = ACCOUNT_STATE_TRYING;
268
else if(strcmp(status, "ERROR") == 0)
281
} else if (strcmp (status, "ERROR") == 0) {
270
282
a->state = ACCOUNT_STATE_ERROR;
272
else if(strcmp( status , "ERROR_AUTH") == 0 )
283
} else if (strcmp (status , "ERROR_AUTH") == 0) {
274
284
a->state = ACCOUNT_STATE_ERROR_AUTH;
276
else if(strcmp( status , "ERROR_NETWORK") == 0 )
285
} else if (strcmp (status , "ERROR_NETWORK") == 0) {
278
286
a->state = ACCOUNT_STATE_ERROR_NETWORK;
280
else if(strcmp( status , "ERROR_HOST") == 0 )
287
} else if (strcmp (status , "ERROR_HOST") == 0) {
282
288
a->state = ACCOUNT_STATE_ERROR_HOST;
284
else if(strcmp( status , "ERROR_CONF_STUN") == 0 )
289
} else if (strcmp (status , "ERROR_CONF_STUN") == 0) {
286
290
a->state = ACCOUNT_STATE_ERROR_CONF_STUN;
288
else if(strcmp( status , "ERROR_EXIST_STUN") == 0 )
291
} else if (strcmp (status , "ERROR_EXIST_STUN") == 0) {
290
292
a->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
292
else if (strcmp (status, "READY") == 0) {
293
a->state = IP2IP_PROFILE_STATUS;
293
} else if (strcmp (status, "READY") == 0) {
294
a->state = IP2IP_PROFILE_STATUS;
297
296
a->state = ACCOUNT_STATE_INVALID;
300
299
gchar * code = NULL;
301
code = g_hash_table_lookup(details, REGISTRATION_STATE_CODE);
300
code = g_hash_table_lookup (details, REGISTRATION_STATE_CODE);
302
302
if (code != NULL) {
303
a->protocol_state_code = atoi(code);
303
a->protocol_state_code = atoi (code);
305
g_free(a->protocol_state_description);
306
a->protocol_state_description = g_hash_table_lookup(details, REGISTRATION_STATE_DESCRIPTION);
306
g_free (a->protocol_state_description);
307
a->protocol_state_description = g_hash_table_lookup (details, REGISTRATION_STATE_DESCRIPTION);
309
// Set the current account message number
310
current_account_set_message_number (count);
310
// Set the current account message number
311
current_account_set_message_number (count);
312
sflphone_fill_codec_list ();
313
sflphone_fill_codec_list ();
315
gboolean sflphone_init() {
317
if(!dbus_connect ()){
319
main_window_error_message(_("Unable to connect to the SFLphone server.\nMake sure the daemon is running."));
316
gboolean sflphone_init()
319
if (!dbus_connect ()) {
321
main_window_error_message (_ ("Unable to connect to the SFLphone server.\nMake sure the daemon is running."));
324
dbus_register(getpid(), "Gtk+ Client");
326
// Init icons factory
327
init_icon_factory ();
329
current_calls = calltab_init(FALSE, CURRENT_CALLS);
330
contacts = calltab_init(TRUE, CONTACTS);
331
history = calltab_init(TRUE, HISTORY);
324
dbus_register (getpid(), "Gtk+ Client");
326
// Init icons factory
327
init_icon_factory ();
329
current_calls = calltab_init (FALSE, CURRENT_CALLS);
330
contacts = calltab_init (TRUE, CONTACTS);
331
history = calltab_init (TRUE, HISTORY);
333
333
account_list_init ();
334
334
codec_capabilities_load ();
335
conferencelist_init ();
335
conferencelist_init ();
337
337
// Fetch the configured accounts
338
338
sflphone_fill_account_list ();
340
// Fetch the ip2ip profile
340
// Fetch the ip2ip profile
341
341
sflphone_fill_ip2ip_profile();
343
// Fetch the conference list
344
// sflphone_fill_conference_list();
343
// Fetch the conference list
344
// sflphone_fill_conference_list();
350
void sflphone_fill_ip2ip_profile(void)
350
void sflphone_fill_ip2ip_profile (void)
352
352
ip2ip_profile = (GHashTable *) dbus_get_ip2_ip_details();
355
355
void sflphone_get_ip2ip_properties (GHashTable **properties)
357
*properties = ip2ip_profile;
357
*properties = ip2ip_profile;
361
361
sflphone_hang_up()
363
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
364
conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree);
368
switch(selectedCall->_state)
363
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
364
conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree);
366
DEBUG ("SFLphone: Hang up");
369
switch (selectedCall->_state) {
370
370
case CALL_STATE_DIALING:
371
371
dbus_hang_up (selectedCall);
373
373
case CALL_STATE_RINGING:
374
374
dbus_hang_up (selectedCall);
375
call_remove_all_errors(selectedCall);
375
call_remove_all_errors (selectedCall);
376
376
selectedCall->_state = CALL_STATE_DIALING;
377
377
//selectedCall->_stop = 0;
491
WARN("Should not happen in sflphone_on_hold!");
510
WARN ("Should not happen in sflphone_on_hold!");
495
else if (selectedConf) {
496
dbus_hold_conference(selectedConf);
513
} else if (selectedConf) {
514
dbus_hold_conference (selectedConf);
501
519
sflphone_off_hold ()
503
DEBUG("sflphone_off_hold");
504
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
505
conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree);
521
DEBUG ("sflphone_off_hold");
522
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
523
conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree);
509
switch(selectedCall->_state)
526
switch (selectedCall->_state) {
511
527
case CALL_STATE_HOLD:
512
528
dbus_unhold (selectedCall);
515
WARN("Should not happen in sflphone_off_hold ()!");
531
WARN ("Should not happen in sflphone_off_hold ()!");
519
else if (selectedConf) {
522
dbus_unhold_conference(selectedConf);
525
if(dbus_get_is_recording(selectedCall))
527
DEBUG("Currently recording!");
531
DEBUG("Not recording currently");
534
} else if (selectedConf) {
537
dbus_unhold_conference (selectedConf);
538
sflphone_fail( callable_obj_t * c )
543
sflphone_fail (callable_obj_t * c)
540
545
c->_state = CALL_STATE_FAILURE;
541
calltree_update_call(current_calls, c, NULL);
546
calltree_update_call (current_calls, c, NULL);
542
547
update_actions();
546
sflphone_busy( callable_obj_t * c )
551
sflphone_busy (callable_obj_t * c)
548
553
c->_state = CALL_STATE_BUSY;
549
calltree_update_call(current_calls, c, NULL);
554
calltree_update_call (current_calls, c, NULL);
550
555
update_actions();
554
sflphone_current( callable_obj_t * c )
559
sflphone_current (callable_obj_t * c)
557
if( c->_state != CALL_STATE_HOLD )
562
if (c->_state != CALL_STATE_HOLD)
558
563
set_timestamp (&c->_time_start);
559
565
c->_state = CALL_STATE_CURRENT;
560
calltree_update_call(current_calls, c, NULL);
566
calltree_update_call (current_calls, c, NULL);
561
567
update_actions();
565
sflphone_record( callable_obj_t * c )
571
sflphone_record (callable_obj_t * c)
567
if( c->_state != CALL_STATE_HOLD )
573
if (c->_state != CALL_STATE_HOLD)
568
574
set_timestamp (&c->_time_start);
569
576
c->_state = CALL_STATE_RECORD;
570
calltree_update_call(current_calls, c, NULL);
577
calltree_update_call (current_calls, c, NULL);
571
578
update_actions();
575
582
sflphone_set_transfert()
577
callable_obj_t * c = calltab_get_selected_call(current_calls);
584
callable_obj_t * c = calltab_get_selected_call (current_calls);
580
587
c->_state = CALL_STATE_TRANSFERT;
581
c->_trsft_to = g_strdup("");
582
calltree_update_call(current_calls, c, NULL);
588
c->_trsft_to = g_strdup ("");
589
calltree_update_call (current_calls, c, NULL);
584
592
update_actions();
588
596
sflphone_unset_transfert()
590
callable_obj_t * c = calltab_get_selected_call(current_calls);
598
callable_obj_t * c = calltab_get_selected_call (current_calls);
593
601
c->_state = CALL_STATE_CURRENT;
594
c->_trsft_to = g_strdup("");
595
calltree_update_call(current_calls, c, NULL);
602
c->_trsft_to = g_strdup ("");
603
calltree_update_call (current_calls, c, NULL);
597
606
update_actions();
601
sflphone_display_transfer_status(const gchar* message)
610
sflphone_display_transfer_status (const gchar* message)
603
statusbar_push_message( message , __MSG_ACCOUNT_DEFAULT);
612
statusbar_push_message (message , NULL, __MSG_ACCOUNT_DEFAULT);
607
616
sflphone_incoming_call (callable_obj_t * c)
611
620
c->_history_state = MISSED;
612
calllist_add ( current_calls, c );
613
calllist_add( history, c );
614
calltree_add_call( current_calls, c, NULL);
621
calllist_add (current_calls, c);
622
calllist_add (history, c);
623
calltree_add_call (current_calls, c, NULL);
615
624
update_actions();
616
625
calltree_display (current_calls);
618
// Change the status bar if we are dealing with a direct SIP call
619
if(_is_direct_call(c)) {
620
msg = g_markup_printf_escaped (_("Direct SIP call"));
621
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
622
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
627
// Change the status bar if we are dealing with a direct SIP call
628
if (_is_direct_call (c)) {
629
msg = g_markup_printf_escaped (_ ("Direct SIP call"));
630
statusbar_pop_message (__MSG_ACCOUNT_DEFAULT);
631
statusbar_push_message (msg , NULL, __MSG_ACCOUNT_DEFAULT);
628
process_dialing(callable_obj_t * c, guint keyval, gchar * key)
637
process_dialing (callable_obj_t * c, guint keyval, gchar * key)
630
639
// We stop the tone
631
if(strlen(c->_peer_number) == 0 && c->_state != CALL_STATE_TRANSFERT){
632
dbus_start_tone( FALSE , 0 );
640
if (strlen (c->_peer_number) == 0 && c->_state != CALL_STATE_TRANSFERT) {
641
dbus_start_tone (FALSE , 0);
633
642
//dbus_play_dtmf( key );
636
DEBUG("process_dialing : keyval : %i",keyval);
637
DEBUG("process_dialing : key : %s",key);
645
DEBUG ("process_dialing : keyval : %i",keyval);
646
DEBUG ("process_dialing : key : %s",key);
641
649
case 65293: /* ENTER */
642
650
case 65421: /* ENTER numpad */
643
sflphone_place_call(c);
651
sflphone_place_call (c);
645
653
case 65307: /* ESCAPE */
654
sflphone_hang_up (c);
648
case 65288: /* BACKSPACE */
649
{ /* Brackets mandatory because of local vars */
650
gchar * before = c->_peer_number;
651
if(strlen(c->_peer_number) >= 1){
653
if (c->_state == CALL_STATE_TRANSFERT)
655
// Process backspace if and only if string not NULL
656
if(strlen(c->_trsft_to) > 0)
657
c->_trsft_to = g_strndup (c->_trsft_to, strlen(c->_trsft_to) - 1);
661
c->_peer_number = g_strndup(c->_peer_number, strlen(c->_peer_number) -1);
663
DEBUG("TO: backspace %s", c->_peer_number);
665
calltree_update_call(current_calls, c, NULL);
667
else if(strlen(c->_peer_number) == 0)
669
if(c->_state != CALL_STATE_TRANSFERT)
656
case 65288: { /* BACKSPACE */
657
/* Brackets mandatory because of local vars */
658
gchar * before = c->_peer_number;
660
if (strlen (c->_peer_number) >= 1) {
662
if (c->_state == CALL_STATE_TRANSFERT) {
663
// Process backspace if and only if string not NULL
664
if (strlen (c->_trsft_to) > 0)
665
c->_trsft_to = g_strndup (c->_trsft_to, strlen (c->_trsft_to) - 1);
667
c->_peer_number = g_strndup (c->_peer_number, strlen (c->_peer_number) -1);
669
DEBUG ("TO: backspace %s", c->_peer_number);
672
calltree_update_call (current_calls, c, NULL);
673
} else if (strlen (c->_peer_number) == 0) {
674
if (c->_state != CALL_STATE_TRANSFERT)
674
679
case 65289: /* TAB */
675
680
case 65513: /* ALT */
676
681
case 65507: /* CTRL */
789
789
//update_callable_obj_tree(current_calls,c);
794
796
case CALL_STATE_INCOMING:
797
799
case 65293: /* ENTER */
798
800
case 65421: /* ENTER numpad */
799
801
c->_history_state = INCOMING;
800
calltree_update_call(history, c, NULL);
802
DEBUG("from sflphone_keypad ( enter ) : "); stop_notification();
802
calltree_update_call (history, c, NULL);
804
DEBUG ("from sflphone_keypad ( enter ) : ");
804
807
case 65307: /* ESCAPE */
806
DEBUG("from sflphone_keypad ( escape ) : "); stop_notification();
809
DEBUG ("from sflphone_keypad ( escape ) : ");
810
815
case CALL_STATE_TRANSFERT:
813
818
case 65293: /* ENTER */
814
819
case 65421: /* ENTER numpad */
816
821
set_timestamp (&c->_time_stop);
818
823
case 65307: /* ESCAPE */
819
sflphone_unset_transfert(c);
824
sflphone_unset_transfert (c);
821
826
default: // When a call is on transfert, typing new numbers will add it to c->_peer_number
822
process_dialing(c, keyval, key);
827
process_dialing (c, keyval, key);
826
832
case CALL_STATE_HOLD:
829
835
case 65293: /* ENTER */
830
836
case 65421: /* ENTER numpad */
833
839
case 65307: /* ESCAPE */
836
842
default: // When a call is on hold, typing new numbers will create a new call
837
process_dialing(sflphone_new_call(), keyval, key);
843
process_dialing (sflphone_new_call(), keyval, key);
841
848
case CALL_STATE_RINGING:
842
849
case CALL_STATE_BUSY:
843
850
case CALL_STATE_FAILURE:
847
854
case 65307: /* ESCAPE */
850
calltree_update_call(history, c, NULL);
857
calltree_update_call (history, c, NULL);
860
867
sflphone_new_call();
864
static int _place_direct_call(const callable_obj_t * c) {
871
static int _place_direct_call (const callable_obj_t * c)
865
873
if (c->_state == CALL_STATE_DIALING) {
866
874
dbus_place_call (c);
873
static int _place_registered_call(callable_obj_t * c) {
882
static int _place_registered_call (callable_obj_t * c)
875
885
account_t * current = NULL;
878
DEBUG("callable_obj_t is NULL in _place_registered_call");
888
DEBUG ("Actions: Callable_obj_t is NULL in _place_registered_call");
882
892
if (c->_state != CALL_STATE_DIALING) {
886
if(g_strcasecmp(c->_peer_number, "") == 0) {
896
if (g_strcasecmp (c->_peer_number, "") == 0) {
890
if( account_list_get_size() == 0 ) {
900
if (account_list_get_size() == 0) {
891
901
notify_no_accounts();
896
if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) {
906
if (account_list_get_by_state (ACCOUNT_STATE_REGISTERED) == NULL) {
907
DEBUG ("Actions: No registered account, cannot make a call");
897
908
notify_no_registered_accounts();
902
if(g_strcasecmp(c->_accountID, "") != 0) {
903
current = account_list_get_by_id(c->_accountID);
913
DEBUG ("Actions: Get account for this call");
915
if (g_strcasecmp (c->_accountID, "") != 0) {
916
DEBUG ("Actions: Account %s already set for this call", c->_accountID);
917
current = account_list_get_by_id (c->_accountID);
919
DEBUG ("Actions: No account set for this call, use first of the list");
905
920
current = account_list_get_current();
908
if(current == NULL) {
909
DEBUG("Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID);
923
if (current == NULL) {
924
DEBUG ("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID);
913
if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) {
928
if (g_strcasecmp (g_hash_table_lookup (current->properties, "Status"),"REGISTERED") ==0) {
914
929
/* The call is made with the current account */
915
c->_accountID = current->accountID;
930
// free memory for previous account id and get a new one
931
g_free (c->_accountID);
932
c->_accountID = g_strdup (current->accountID);
918
/* Place the call with the first registered account
919
* and switch the current account.
920
* If we are here, we can be sure that there is at least one.
922
current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED );
923
c->_accountID = current->accountID;
925
notify_current_account( current );
935
/* Place the call with the first registered account
936
* and switch the current account.
937
* If we are here, we can be sure that there is at least one.
939
current = account_list_get_by_state (ACCOUNT_STATE_REGISTERED);
940
g_free (c->_accountID);
941
c->_accountID = g_strdup (current->accountID);
943
notify_current_account (current);
928
946
c->_history_state = OUTGOING;
929
calllist_add(history, c);
947
calllist_add (history, c);
934
sflphone_place_call ( callable_obj_t * c )
952
sflphone_place_call (callable_obj_t * c)
938
DEBUG("Placing call with %s @ %s and accountid %s", c->_peer_name, c->_peer_number, c->_accountID);
941
DEBUG("Unexpected condition: callable_obj_t is null in %s at %d", __FILE__, __LINE__);
956
DEBUG ("Actions: Placing call with %s @ %s and accountid %s", c->_peer_name, c->_peer_number, c->_accountID);
959
DEBUG ("Actions: Unexpected condition: callable_obj_t is null in %s at %d", __FILE__, __LINE__);
945
if(_is_direct_call(c)) {
946
msg = g_markup_printf_escaped (_("Direct SIP call"));
947
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
948
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
950
if(_place_direct_call(c) < 0) {
951
DEBUG("An error occured while placing direct call in %s at %d", __FILE__, __LINE__);
955
if(_place_registered_call(c) < 0) {
956
DEBUG("An error occured while placing registered call in %s at %d", __FILE__, __LINE__);
964
sflphone_detach_participant(const gchar* callID)
966
DEBUG("Action: Detach participant from conference");
969
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
970
DEBUG("Action: Detach participant %s", selectedCall->_callID);
972
if(selectedCall->_confID) {
973
g_free(selectedCall->_confID);
974
selectedCall->_confID = NULL;
977
calltree_remove_call(current_calls, selectedCall, NULL);
978
calltree_add_call(current_calls, selectedCall, NULL);
979
dbus_detach_participant(selectedCall->_callID);
982
callable_obj_t * selectedCall = calllist_get(current_calls, callID);
983
DEBUG("Action: Darticipant %s", callID);
985
if(selectedCall->_confID) {
986
g_free(selectedCall->_confID);
987
selectedCall->_confID = NULL;
990
calltree_remove_call(current_calls, selectedCall, NULL);
991
calltree_add_call(current_calls, selectedCall, NULL);
992
dbus_detach_participant(callID);
998
sflphone_join_participant(const gchar* sel_callID, const gchar* drag_callID)
1000
DEBUG("sflphone join participants %s and %s", sel_callID, drag_callID);
1003
dbus_join_participant(sel_callID, drag_callID);
1008
sflphone_add_participant(const gchar* callID, const gchar* confID)
1010
DEBUG("sflphone add participant %s to conference %s", callID, confID);
1012
dbus_add_participant(callID, confID);
963
if (_is_direct_call (c)) {
964
msg = g_markup_printf_escaped (_ ("Direct SIP call"));
965
statusbar_pop_message (__MSG_ACCOUNT_DEFAULT);
966
statusbar_push_message (msg , NULL, __MSG_ACCOUNT_DEFAULT);
969
if (_place_direct_call (c) < 0) {
970
DEBUG ("An error occured while placing direct call in %s at %d", __FILE__, __LINE__);
974
if (_place_registered_call (c) < 0) {
975
DEBUG ("An error occured while placing registered call in %s at %d", __FILE__, __LINE__);
983
sflphone_detach_participant (const gchar* callID)
985
DEBUG ("Action: Detach participant from conference");
987
if (callID == NULL) {
988
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
989
DEBUG ("Action: Detach participant %s", selectedCall->_callID);
991
if (selectedCall->_confID) {
992
g_free (selectedCall->_confID);
993
selectedCall->_confID = NULL;
996
// Instant messaging widget should have been deactivated during the conference
997
if (selectedCall->_im_widget)
998
im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE);
1000
calltree_remove_call (current_calls, selectedCall, NULL);
1001
calltree_add_call (current_calls, selectedCall, NULL);
1002
dbus_detach_participant (selectedCall->_callID);
1004
callable_obj_t * selectedCall = calllist_get (current_calls, callID);
1005
DEBUG ("Action: Darticipant %s", callID);
1007
if (selectedCall->_confID) {
1008
g_free (selectedCall->_confID);
1009
selectedCall->_confID = NULL;
1012
// Instant messagin widget should have been deactivated during the conference
1013
if (selectedCall->_im_widget)
1014
im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE);
1016
calltree_remove_call (current_calls, selectedCall, NULL);
1017
calltree_add_call (current_calls, selectedCall, NULL);
1018
dbus_detach_participant (callID);
1024
sflphone_join_participant (const gchar* sel_callID, const gchar* drag_callID)
1026
DEBUG ("sflphone join participants %s and %s", sel_callID, drag_callID);
1029
dbus_join_participant (sel_callID, drag_callID);
1034
sflphone_add_participant (const gchar* callID, const gchar* confID)
1036
DEBUG ("sflphone add participant %s to conference %s", callID, confID);
1038
dbus_add_participant (callID, confID);
1016
1042
sflphone_add_conference()
1018
DEBUG("sflphone add a conference to tree view");
1044
DEBUG ("sflphone add a conference to tree view");
1019
1045
// dbus_join_participant(selected_call, dragged_call);
1023
sflphone_join_conference(const gchar* sel_confID, const gchar* drag_confID)
1025
DEBUG("sflphone join two conference");
1026
dbus_join_conference(sel_confID, drag_confID);
1030
sflphone_add_main_participant(const conference_obj_t * c)
1032
DEBUG("sflphone add main participant");
1033
dbus_add_main_participant(c->_confID);
1037
sflphone_conference_on_hold(const conference_obj_t * c)
1039
DEBUG("sflphone_conference_on_hold");
1040
dbus_hold_conference(c);
1044
sflphone_conference_off_hold(const conference_obj_t * c)
1046
DEBUG("sflphone_conference_off_hold");
1047
dbus_unhold_conference(c);
1049
sflphone_join_conference (const gchar* sel_confID, const gchar* drag_confID)
1051
DEBUG ("sflphone join two conference");
1052
dbus_join_conference (sel_confID, drag_confID);
1056
sflphone_add_main_participant (const conference_obj_t * c)
1058
DEBUG ("sflphone add main participant");
1059
dbus_add_main_participant (c->_confID);
1063
sflphone_conference_on_hold (const conference_obj_t * c)
1065
DEBUG ("sflphone_conference_on_hold");
1066
dbus_hold_conference (c);
1070
sflphone_conference_off_hold (const conference_obj_t * c)
1072
DEBUG ("sflphone_conference_off_hold");
1073
dbus_unhold_conference (c);
1052
1078
sflphone_rec_call()
1054
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
1055
conference_obj_t * selectedConf = calltab_get_selected_conf(current_calls);
1059
dbus_set_record(selectedCall->_callID);
1060
switch(selectedCall->_state)
1080
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
1081
conference_obj_t * selectedConf = calltab_get_selected_conf (current_calls);
1084
DEBUG ("SFLphone: Set record for selected call");
1085
dbus_set_record (selectedCall->_callID);
1087
switch (selectedCall->_state) {
1062
1088
case CALL_STATE_CURRENT:
1063
selectedCall->_state = CALL_STATE_RECORD;
1089
selectedCall->_state = CALL_STATE_RECORD;
1065
1091
case CALL_STATE_RECORD:
1066
selectedCall->_state = CALL_STATE_CURRENT;
1092
selectedCall->_state = CALL_STATE_CURRENT;
1069
WARN("Should not happen in sflphone_off_hold ()!");
1073
else if(selectedConf)
1075
dbus_set_record(selectedConf->_confID);
1076
switch(selectedConf->_state)
1095
WARN ("Should not happen in sflphone_off_hold ()!");
1098
} else if (selectedConf) {
1099
DEBUG ("SFLphone: Set record for selected conf");
1100
dbus_set_record (selectedConf->_confID);
1102
switch (selectedConf->_state) {
1078
1103
case CONFERENCE_STATE_ACTIVE_ATACHED:
1079
selectedCall->_state = CONFERENCE_STATE_RECORD;
1104
selectedConf->_state = CONFERENCE_STATE_RECORD;
1081
1106
case CONFERENCE_STATE_RECORD:
1082
selectedCall->_state = CONFERENCE_STATE_ACTIVE_ATACHED;
1107
selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED;
1085
WARN("Should not happen in sflphone_off_hold ()!");
1110
WARN ("Should not happen in sflphone_off_hold ()!");
1089
calltree_update_call(current_calls, selectedCall, NULL);
1115
calltree_update_call (current_calls, selectedCall, NULL);
1090
1116
update_actions();
1092
// gchar* codname = sflphone_get_current_codec_name();
1093
// DEBUG("sflphone_get_current_codec_name: %s",codname);
1096
void sflphone_fill_codec_list () {
1098
guint account_list_size;
1100
account_t *current = NULL;
1101
gchar** codecs = NULL;
1103
DEBUG("SFLphone: Fill codec list");
1105
account_list_size = account_list_get_size ();
1107
for (i=0; i<account_list_size; i++)
1109
current = account_list_get_nth (i);
1111
sflphone_fill_codec_list_per_account (¤t);
1116
if (codec_list_get_size() == 0) {
1119
ERROR ("No audio codecs found");
1120
dbus_unregister(getpid());
1125
void sflphone_fill_codec_list_per_account (account_t **account) {
1119
void sflphone_fill_codec_list ()
1122
guint account_list_size;
1124
account_t *current = NULL;
1126
DEBUG ("SFLphone: Fill codec list");
1128
account_list_size = account_list_get_size ();
1130
for (i=0; i<account_list_size; i++) {
1131
current = account_list_get_nth (i);
1134
sflphone_fill_codec_list_per_account (¤t);
1140
void sflphone_fill_codec_list_per_account (account_t **account)
1131
1145
GQueue *codeclist;
1132
1146
gboolean active = FALSE;
1134
order = (gchar**) dbus_get_active_codec_list ((*account)->accountID);
1148
order = (gchar**) dbus_get_active_codec_list ( (*account)->accountID);
1136
1150
codeclist = (*account)->codecs;
1138
1152
// First clean the list
1139
1153
codec_list_clear (&codeclist);
1142
ERROR("SFLphone: No codec list provided");
1144
for (pl=order; *pl; pl++)
1146
codec_t * cpy = NULL;
1148
// Each account will have a copy of the system-wide capabilities
1149
codec_create_new_from_caps (codec_list_get_by_payload ((gconstpointer) (size_t)atoi (*pl), NULL), &cpy);
1151
cpy->is_active = TRUE;
1152
codec_list_add (cpy, &codeclist);
1155
ERROR ("SFLphone: Couldn't find codec");
1158
// Test here if we just added some active codec.
1159
active = (codeclist->length == 0) ? TRUE : FALSE;
1161
guint caps_size = codec_list_get_size (), i=0;
1163
for (i=0; i<caps_size; i++) {
1165
codec_t * current_cap = capabilities_get_nth (i);
1166
// Check if this codec has already been enabled for this account
1167
if (codec_list_get_by_payload ( (gconstpointer) (size_t)(current_cap->_payload), codeclist) == NULL) {
1169
// codec_create_new_from_caps (current_cap, &cpy);
1170
current_cap->is_active = active;
1171
codec_list_add (current_cap, &codeclist);
1178
(*account)->codecs = codeclist;
1180
// call dbus function with array of strings
1181
codec_list_update_to_daemon (*account);
1156
ERROR ("SFLphone: No codec list provided");
1158
for (pl=order; *pl; pl++) {
1159
codec_t * cpy = NULL;
1161
// Each account will have a copy of the system-wide capabilities
1162
codec_create_new_from_caps (codec_list_get_by_payload ( (gconstpointer) (size_t) atoi (*pl), NULL), &cpy);
1165
cpy->is_active = TRUE;
1166
codec_list_add (cpy, &codeclist);
1168
ERROR ("SFLphone: Couldn't find codec");
1171
// Test here if we just added some active codec.
1172
active = (codeclist->length == 0) ? TRUE : FALSE;
1174
guint caps_size = codec_list_get_size (), i=0;
1176
for (i=0; i<caps_size; i++) {
1178
codec_t * current_cap = capabilities_get_nth (i);
1180
// Check if this codec has already been enabled for this account
1181
if (codec_list_get_by_payload ( (gconstpointer) (size_t) (current_cap->_payload), codeclist) == NULL) {
1183
// codec_create_new_from_caps (current_cap, &cpy);
1184
current_cap->is_active = active;
1185
codec_list_add (current_cap, &codeclist);
1191
(*account)->codecs = codeclist;
1193
// call dbus function with array of strings
1194
codec_list_update_to_daemon (*account);
1185
1198
void sflphone_fill_call_list (void)
1188
gchar** calls = (gchar**)dbus_get_call_list();
1201
gchar** calls = (gchar**) dbus_get_call_list();
1190
1203
GHashTable *call_details;
1191
1204
callable_obj_t *c;
1194
DEBUG("sflphone_fill_call_list");
1207
DEBUG ("sflphone_fill_call_list");
1198
for(pl=calls; *calls; calls++)
1200
c = g_new0(callable_obj_t, 1);
1201
callID = (gchar*)(*calls);
1202
call_details = dbus_get_call_details(callID);
1210
for (pl=calls; *calls; calls++) {
1211
c = g_new0 (callable_obj_t, 1);
1212
callID = (gchar*) (*calls);
1213
call_details = dbus_get_call_details (callID);
1203
1214
create_new_call_from_details (callID, call_details, &c);
1204
c->_callID = g_strdup(callID);
1215
c->_callID = g_strdup (callID);
1205
1216
c->_zrtp_confirmed = FALSE;
1206
1217
// Add it to the list
1207
1218
DEBUG ("Add call retrieved from server side: %s\n", c->_callID);
1320
1331
DEBUG ("Saving history ...");
1322
result = g_hash_table_new(NULL, g_str_equal);
1333
result = g_hash_table_new (NULL, g_str_equal);
1323
1334
items = history->callQueue;
1324
1335
size = calllist_get_size (history);
1326
for (i=0; i<size; i++)
1337
for (i=0; i<size; i++) {
1328
1338
current = g_queue_peek_nth (items, i);
1331
1341
value = serialize_history_entry (current);
1332
1342
key = convert_timestamp_to_gchar (current->_time_start);
1333
g_hash_table_replace(result, (gpointer) key,
1343
g_hash_table_replace (result, (gpointer) key,
1338
1348
dbus_set_history (result);
1340
1350
// Decrement the reference count
1341
g_hash_table_unref(result);
1351
g_hash_table_unref (result);
1345
sflphone_srtp_sdes_on(callable_obj_t * c)
1355
sflphone_srtp_sdes_on (callable_obj_t * c)
1348
1358
c->_srtp_state = SRTP_STATE_SDES_SUCCESS;
1350
calltree_update_call(current_calls, c, NULL);
1360
calltree_update_call (current_calls, c, NULL);
1351
1361
update_actions();
1355
sflphone_srtp_sdes_off(callable_obj_t * c)
1365
sflphone_srtp_sdes_off (callable_obj_t * c)
1357
1367
c->_srtp_state = SRTP_STATE_UNLOCKED;
1359
calltree_update_call(current_calls, c, NULL);
1369
calltree_update_call (current_calls, c, NULL);
1360
1370
update_actions();
1365
sflphone_srtp_zrtp_on( callable_obj_t * c)
1375
sflphone_srtp_zrtp_on (callable_obj_t * c)
1367
1377
c->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED;
1369
calltree_update_call(current_calls, c, NULL);
1379
calltree_update_call (current_calls, c, NULL);
1370
1380
update_actions();
1374
sflphone_srtp_zrtp_off( callable_obj_t * c )
1384
sflphone_srtp_zrtp_off (callable_obj_t * c)
1376
1386
c->_srtp_state = SRTP_STATE_UNLOCKED;
1377
calltree_update_call(current_calls, c, NULL);
1387
calltree_update_call (current_calls, c, NULL);
1378
1388
update_actions();
1382
sflphone_srtp_zrtp_show_sas( callable_obj_t * c, const gchar* sas, const gboolean verified)
1392
sflphone_srtp_zrtp_show_sas (callable_obj_t * c, const gchar* sas, const gboolean verified)
1385
DEBUG("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__);
1395
DEBUG ("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__);
1387
c->_sas = g_strdup(sas);
1388
if(verified == TRUE) {
1398
c->_sas = g_strdup (sas);
1400
if (verified == TRUE) {
1389
1401
c->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED;
1391
1403
c->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED;
1393
calltree_update_call(current_calls, c, NULL);
1406
calltree_update_call (current_calls, c, NULL);
1394
1407
update_actions();
1398
sflphone_srtp_zrtp_not_supported( callable_obj_t * c )
1411
sflphone_srtp_zrtp_not_supported (callable_obj_t * c)
1400
DEBUG("ZRTP not supported");
1401
main_window_zrtp_not_supported(c);
1413
DEBUG ("ZRTP not supported");
1414
main_window_zrtp_not_supported (c);
1404
1417
/* Method on sflphoned */
1406
sflphone_set_confirm_go_clear( callable_obj_t * c )
1419
sflphone_set_confirm_go_clear (callable_obj_t * c)
1408
dbus_set_confirm_go_clear(c);
1421
dbus_set_confirm_go_clear (c);
1412
sflphone_request_go_clear(void)
1425
sflphone_request_go_clear (void)
1414
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
1416
dbus_request_go_clear(selectedCall);
1427
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
1430
dbus_request_go_clear (selectedCall);
1420
1434
/* Signal sent by sflphoned */
1422
sflphone_confirm_go_clear( callable_obj_t * c )
1436
sflphone_confirm_go_clear (callable_obj_t * c)
1424
main_window_confirm_go_clear(c);
1438
main_window_confirm_go_clear (c);
1429
sflphone_call_state_changed( callable_obj_t * c, const gchar * description, const guint code)
1443
sflphone_call_state_changed (callable_obj_t * c, const gchar * description, const guint code)
1431
DEBUG("sflphone_call_state_changed");
1433
DEBUG("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__);
1445
DEBUG ("SFLPhone: sflphone_call_state_changed");
1448
DEBUG ("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__);
1435
//g_free(c->_state_code_description);
1450
//g_free(c->_state_code_description);
1436
1451
//DEBUG("sflphone_call_state_changed");
1437
c->_state_code_description = g_strdup(description);
1438
c->_state_code = code;
1452
c->_state_code_description = g_strdup (description);
1453
c->_state_code = code;
1454
DEBUG ("SFLPhone: state code %d", c->_state_code);
1441
calltree_update_call(current_calls, c, NULL);
1457
calltree_update_call (current_calls, c, NULL);
1442
1458
update_actions();
1446
void sflphone_get_interface_addr_from_name(char *iface_name, char **iface_addr, int size) {
1462
void sflphone_get_interface_addr_from_name (char *iface_name, char **iface_addr, int size)
1448
1465
struct ifreq ifr;