~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to gnome/src/contacts/calltree.c

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "calltree.h"
39
39
#include "str_utils.h"
40
40
#include "account_schema.h"
 
41
#include <glib/gi18n.h>
41
42
#include <string.h>
42
43
#include <stdlib.h>
 
44
#include <stdint.h>
43
45
#include <gtk/gtk.h>
44
46
 
45
47
#include "dbus.h"
70
72
 
71
73
static PopupData *popup_data = NULL;
72
74
 
73
 
// Messages used in menu item
74
 
static const gchar * const SFL_CREATE_CONFERENCE = "Create conference";
75
 
static const gchar * const SFL_TRANSFER_CALL = "Transfer call to";
 
75
#define SFL_CREATE_CONFERENCE _("Create conference")
 
76
#define SFL_TRANSFER_CALL _("Transfer call to")
76
77
 
77
78
static GtkWidget *calltree_popupmenu = NULL;
78
79
static GtkWidget *calltree_menu_items = NULL;
272
273
                            selectedCall->_zrtp_confirmed = TRUE;
273
274
 
274
275
                        dbus_confirm_sas(selectedCall);
275
 
                        calltree_update_call(current_calls_tab, selectedCall, client, TRUE);
 
276
                        calltree_update_call(current_calls_tab, selectedCall, client);
276
277
                        break;
277
278
                    case SRTP_STATE_ZRTP_SAS_CONFIRMED:
278
279
                        selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED;
279
280
                        dbus_reset_sas(selectedCall);
280
 
                        calltree_update_call(current_calls_tab, selectedCall, client, TRUE);
 
281
                        calltree_update_call(current_calls_tab, selectedCall, client);
281
282
                        break;
282
283
                    default:
283
284
                        g_debug("Single click but no action");
324
325
}
325
326
 
326
327
static gchar *
327
 
calltree_display_call_info(callable_obj_t * call, CallDisplayType display_type,
328
 
                           const gchar *const audio_codec,
329
 
                           const gchar *const video_codec)
 
328
calltree_display_call_info(callable_obj_t * call, CallDisplayType display_type)
330
329
{
331
330
    gchar display_number[strlen(call->_peer_number) + 1];
332
331
    strcpy(display_number, call->_peer_number);
355
354
 
356
355
    gchar *desc = g_markup_printf_escaped("<b>%s</b>   <i>%s</i>   ", name, details);
357
356
    gchar *suffix = NULL;
358
 
    gchar *codec = NULL;
359
357
 
360
358
    switch (display_type) {
361
359
        case DISPLAY_TYPE_CALL:
362
360
            if (call->_state_code)
363
361
                suffix = g_markup_printf_escaped("\n<i>%s (%d)</i>", call->_state_code_description, call->_state_code);
364
362
            break;
365
 
        case DISPLAY_TYPE_STATE_CODE :
366
 
            if (video_codec && *video_codec)
367
 
                codec = g_strconcat(audio_codec, " ", video_codec, NULL);
368
 
            else
369
 
                codec = g_strdup(audio_codec);
370
363
 
371
364
            if (call->_state_code)
372
 
                suffix = g_markup_printf_escaped("\n<i>%s (%d)</i>  <i>%s</i>",
373
 
                                                 call->_state_code_description, call->_state_code,
374
 
                                                 codec);
375
 
            else
376
 
                suffix = g_markup_printf_escaped("\n<i>%s</i>", codec);
377
 
 
378
 
            g_free(codec);
 
365
                suffix = g_markup_printf_escaped("\n<i>%s (%d)</i>",
 
366
                                                 call->_state_code_description, call->_state_code);
379
367
            break;
380
368
        case DISPLAY_TYPE_CALL_TRANSFER:
381
 
            suffix = g_markup_printf_escaped("\n<i>Transfer to:%s</i> ", call->_trsft_to);
 
369
            suffix = g_markup_printf_escaped(_("\n<i>Transfer to:%s</i> "), call->_trsft_to);
382
370
            break;
383
371
        case DISPLAY_TYPE_SAS:
384
 
            suffix = g_markup_printf_escaped("\n<i>Confirm SAS <b>%s</b> ?</i>", call->_sas);
 
372
            suffix = g_markup_printf_escaped(_("\n<i>Confirm SAS <b>%s</b> ?</i>"), call->_sas);
385
373
            break;
386
374
        case DISPLAY_TYPE_HISTORY :
387
375
        default:
632
620
typedef struct {
633
621
    calltab_t *tab;
634
622
    callable_obj_t *call;
635
 
    gboolean update_codecs;
636
623
} CallUpdateCtx;
637
624
 
638
625
typedef struct {
679
666
    /* Update text */
680
667
    gchar *description = NULL;
681
668
 
682
 
    gchar *audio_codec;
683
 
    gchar *video_codec;
684
 
 
685
 
    /* Don't get codec names if call does not exist */
686
 
    if (ctx->update_codecs) {
687
 
        audio_codec = call_get_audio_codec(call);
688
 
#ifdef SFL_VIDEO
689
 
        video_codec = call_get_video_codec(call);
690
 
#else
691
 
        video_codec = g_strdup("");
692
 
#endif
693
 
    } else {
694
 
        audio_codec = g_strdup("");
695
 
        video_codec = g_strdup("");
696
 
    }
697
 
 
698
669
    if (call->_state == CALL_STATE_TRANSFER)
699
 
        description = calltree_display_call_info(call, DISPLAY_TYPE_CALL_TRANSFER, "", "");
 
670
        description = calltree_display_call_info(call, DISPLAY_TYPE_CALL_TRANSFER);
700
671
    else
701
672
        if (call->_sas && display_sas && call->_srtp_state == SRTP_STATE_ZRTP_SAS_UNCONFIRMED && !call->_zrtp_confirmed)
702
 
            description = calltree_display_call_info(call, DISPLAY_TYPE_SAS, "", "");
 
673
            description = calltree_display_call_info(call, DISPLAY_TYPE_SAS);
703
674
        else
704
 
            description = calltree_display_call_info(call, DISPLAY_TYPE_STATE_CODE, audio_codec, video_codec);
705
 
 
706
 
    g_free(video_codec);
707
 
    g_free(audio_codec);
 
675
            description = calltree_display_call_info(call, DISPLAY_TYPE_STATE_CODE);
708
676
 
709
677
    /* Update icons */
710
678
    if (calltab_has_name(tab, CURRENT_CALLS)) {
769
737
        pixbuf = history_state_to_pixbuf(call);
770
738
 
771
739
        g_free(description);
772
 
        description = calltree_display_call_info(call, DISPLAY_TYPE_HISTORY, "", "");
 
740
        description = calltree_display_call_info(call, DISPLAY_TYPE_HISTORY);
773
741
        gchar *date = get_formatted_start_timestamp(call->_time_start);
774
742
        gchar *duration = get_call_duration(call);
775
743
        gchar *full_duration = g_strconcat(date , duration , NULL);
800
768
}
801
769
 
802
770
void
803
 
calltree_update_call(calltab_t* tab, callable_obj_t * call, SFLPhoneClient *client, gboolean update_codecs)
 
771
calltree_update_call(calltab_t* tab, callable_obj_t * call, SFLPhoneClient *client)
804
772
{
805
773
    if (!call) {
806
774
        g_warning("Call is NULL, ignoring");
807
775
        return;
808
776
    }
809
 
    CallUpdateCtx ctx = {tab, call, update_codecs};
 
777
    CallUpdateCtx ctx = {tab, call};
810
778
    GtkTreeStore *store = tab->store;
811
779
    GtkTreeModel *model = GTK_TREE_MODEL(store);
812
780
    gtk_tree_model_foreach(model, update_call, (gpointer) &ctx);
828
796
 
829
797
    // New call in the list
830
798
 
831
 
    gchar *description = calltree_display_call_info(call, DISPLAY_TYPE_CALL, "", "");
 
799
    gchar *description = calltree_display_call_info(call, DISPLAY_TYPE_CALL);
832
800
 
833
801
    gtk_tree_store_prepend(tab->store, &iter, parent);
834
802
 
915
883
void calltree_add_history_entry(callable_obj_t *call)
916
884
{
917
885
    // New call in the list
918
 
    gchar * description = calltree_display_call_info(call, DISPLAY_TYPE_HISTORY, "", "");
 
886
    gchar * description = calltree_display_call_info(call, DISPLAY_TYPE_HISTORY);
919
887
 
920
888
    GtkTreeIter iter;
921
889
    gtk_tree_store_prepend(history_tab->store, &iter, NULL);
1202
1170
    update_actions(client);
1203
1171
}
1204
1172
 
1205
 
 
1206
1173
gboolean calltree_update_clock(G_GNUC_UNUSED gpointer data)
1207
1174
{
1208
1175
    if (calllist_empty(current_calls_tab))
1209
1176
        return TRUE;
1210
1177
 
1211
 
    char timestr[20];
 
1178
    char timestr[32];
1212
1179
    const gchar *msg = "";
1213
 
    long duration;
1214
1180
    callable_obj_t *call = calltab_get_selected_call(current_calls_tab);
1215
1181
 
1216
 
    if (call)
 
1182
    if (call) {
1217
1183
        switch (call->_state) {
1218
1184
            case CALL_STATE_INVALID:
1219
1185
            case CALL_STATE_INCOMING:
1223
1189
            case CALL_STATE_BUSY:
1224
1190
                break;
1225
1191
            default:
1226
 
                duration = difftime(time(NULL), call->_time_start);
1227
 
 
1228
 
                if (duration < 0)
1229
 
                    duration = 0;
1230
 
 
1231
 
                g_snprintf(timestr, sizeof(timestr), "%.2ld:%.2ld", duration / 60, duration % 60);
 
1192
                format_duration(call, time(NULL), timestr, sizeof(timestr));
1232
1193
                msg = timestr;
1233
1194
                break;
1234
1195
        }
 
1196
    }
1235
1197
 
1236
1198
    statusbar_update_clock(msg);
1237
1199
    return TRUE;
1321
1283
                sflphone_add_participant(source_ID, conf_ID);
1322
1284
                result = TRUE;
1323
1285
            }
 
1286
            g_free(conf_ID);
1324
1287
        }
1325
1288
    }
1326
1289
    g_value_unset(&source_val);