コード例 #1
0
ファイル: actions.c プロジェクト: dot-Sean/telephony
int
sflphone_place_call(callable_obj_t * c, SFLPhoneClient *client)
{
    account_t * account = NULL;

    if (c == NULL) {
        g_warning("Callable object is NULL while making new call");
        return -1;
    }

    g_debug("Placing call from %s to %s using account %s", c->_display_name, c->_peer_number, c->_accountID);

    if (c->_state != CALL_STATE_DIALING) {
        g_warning("Call not in state dialing, cannot place call");
        return -1;
    }

    if (!c->_peer_number || strlen(c->_peer_number) == 0) {
        g_warning("No peer number set for this call");
        return -1;
    }

    // Get the account for this call
    if (strlen(c->_accountID) != 0) {
        g_debug("Account %s already set for this call", c->_accountID);
        account = account_list_get_by_id(c->_accountID);
    } else {
        g_debug("No account set for this call, use first of the list");
        account = account_list_get_current();
    }

    // Make sure the previously found account is registered, take first one registered elsewhere
    if (account) {
        const gchar *status = account_lookup(account, CONFIG_ACCOUNT_REGISTRATION_STATUS);
        if (!utf8_case_equal(status, "REGISTERED")) {
            // Place the call with the first registered account
            account = account_list_get_by_state(ACCOUNT_STATE_REGISTERED);
        }
    }

    // If there is no account specified or found, fallback on IP2IP call
    if(account == NULL) {
        g_debug("Could not find an account for this call, making ip to ip call");
        account = account_list_get_by_id("IP2IP");
        if (account == NULL) {
            g_warning("Actions: Could not determine any account for this call");
            return -1;
        }
    }

    // free memory for previous account id and use the new one in case it changed
    g_free(c->_accountID);
    c->_accountID = g_strdup(account->accountID);
    dbus_place_call(c);
    notify_current_account(account, client);

    c->_history_state = g_strdup(OUTGOING_STRING);

    return 0;
}
コード例 #2
0
/**
 * Fills the treelist with accounts, should be called whenever the account
 * list is modified.
 */
static void account_store_fill()
{
    g_return_if_fail(account_list_dialog != NULL);
    gtk_list_store_clear(account_store);

    // IP2IP account must be first
    account_t *ip2ip = account_list_get_by_id(IP2IP_PROFILE);
    g_return_if_fail(ip2ip != NULL);
    ip2ip->state = ACCOUNT_STATE_IP2IP_READY;

    GtkTreeIter iter;
    gtk_list_store_append(account_store, &iter);

    account_store_add(&iter, ip2ip);

    for (size_t i = 0; i < account_list_get_size(); ++i) {
        account_t *a = account_list_get_nth(i);
        g_return_if_fail(a != NULL);

        // we don't want to process the IP2IP twice
        if (a != ip2ip) {
            gtk_list_store_append(account_store, &iter);
            account_store_add(&iter, a);
        }
    }
}
コード例 #3
0
ファイル: actions.c プロジェクト: dot-Sean/telephony
void
sflphone_incoming_call(callable_obj_t * c, SFLPhoneClient *client)
{
    c->_history_state = g_strdup(MISSED_STRING);
    calllist_add_call(current_calls_tab, c);
    calltree_add_call(current_calls_tab, c, NULL);

    update_actions(client);
    calltree_display(current_calls_tab, client);

    // Change the status bar if we are dealing with a direct SIP call
    if (is_direct_call(c)) {
        gchar *msg = g_markup_printf_escaped(_("Direct SIP call"));
        statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
        statusbar_push_message(msg , NULL, __MSG_ACCOUNT_DEFAULT);
        g_free(msg);
    }
    account_t *account = account_list_get_by_id(c->_accountID);
    if (!account) {
        g_warning("Account is NULL");
    } else if (account_has_autoanswer_on(account)) {
        calltab_select_call(active_calltree_tab, c);
        sflphone_pick_up(client);
    }
}
コード例 #4
0
ファイル: sflnotify.c プロジェクト: dyfet/sflphone
void
notify_incoming_call(callable_obj_t* c)
{
#if USE_NOTIFY
    gchar* title;

    if (strlen(c->_accountID) == 0)
        title = g_markup_printf_escaped("IP-to-IP call");
    else {
        title = g_markup_printf_escaped(_("%s account : %s") ,
                                        (gchar*) g_hash_table_lookup(account_list_get_by_id(c->_accountID)->properties , ACCOUNT_TYPE) ,
                                        (gchar*) g_hash_table_lookup(account_list_get_by_id(c->_accountID)->properties , ACCOUNT_ALIAS)) ;
    }

    gchar *callerid = g_markup_printf_escaped(_("<i>From</i> %s"), c->_peer_number);

    create_new_gnome_notification(title,
                                  callerid,
                                  NOTIFY_URGENCY_CRITICAL,
                                  utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER);
#endif
}
コード例 #5
0
ファイル: accountlist.c プロジェクト: dyfet/sflphone
void account_list_remove(const gchar *accountID)
{
    account_t *target = account_list_get_by_id(accountID);
    if (target) {
#if GLIB_CHECK_VERSION(2, 30, 0)
        if (!g_queue_remove(accountQueue, target))
            ERROR("Could not remove account with ID %s", accountID);
#else
        g_queue_remove(accountQueue, target);
#endif
    }

}
コード例 #6
0
static void
highlight_registration(G_GNUC_UNUSED GtkTreeViewColumn *col, GtkCellRenderer *rend,
                       GtkTreeModel *tree_model, GtkTreeIter *iter,
                       G_GNUC_UNUSED gpointer data)
{
    GValue val;
    memset(&val, 0, sizeof(val));
    gtk_tree_model_get_value(tree_model, iter, COLUMN_ACCOUNT_ID, &val);
    account_t *current = account_list_get_by_id(g_value_get_string(&val));
    g_value_unset(&val);

    if (current)
        g_object_set(G_OBJECT(rend), "foreground", state_color(current), NULL);
}
コード例 #7
0
/**
 * Call back when the user click on an account in the list
 */
static void
select_account_cb(GtkTreeSelection *selection, GtkTreeModel *model)
{
    GtkTreeIter iter;
    if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
        gtk_widget_set_sensitive(move_up_button, FALSE);
        gtk_widget_set_sensitive(move_down_button, FALSE);
        gtk_widget_set_sensitive(edit_button, FALSE);
        gtk_widget_set_sensitive(delete_button, FALSE);
        return;
    }

    // The Gvalue will be initialized in the following function
    GValue val;
    memset(&val, 0, sizeof(val));
    gtk_tree_model_get_value(model, &iter, COLUMN_ACCOUNT_ID, &val);

    gchar *selected_accountID = g_value_dup_string(&val);
    g_value_unset(&val);

    g_debug("Selected account has accountID %s", selected_accountID);
    account_t *selected_account = account_list_get_by_id(selected_accountID);
    g_return_if_fail(selected_account != NULL);

    gtk_widget_set_sensitive(edit_button, TRUE);

    if (!account_is_IP2IP(selected_account)) {
        gtk_widget_set_sensitive(move_up_button, TRUE);
        gtk_widget_set_sensitive(move_down_button, TRUE);
        gtk_widget_set_sensitive(delete_button, TRUE);

        /* Update status bar about current registration state */
        update_account_list_status_bar(selected_account);
    } else {
        gtk_widget_set_sensitive(move_up_button, FALSE);
        gtk_widget_set_sensitive(move_down_button, FALSE);
        gtk_widget_set_sensitive(delete_button, FALSE);
    }
    g_free(selected_accountID);
}
コード例 #8
0
static void
enable_account_cb(G_GNUC_UNUSED GtkCellRendererToggle *rend, gchar* path,
                  gpointer data)
{
    // The IP2IP profile can't be disabled
    if (g_strcmp0(path, "0") == 0)
        return;

    // Get pointer on object
    GtkTreePath *tree_path = gtk_tree_path_new_from_string(path);
    GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(data));
    GtkTreeIter iter;
    gtk_tree_model_get_iter(model, &iter, tree_path);
    gboolean enable;
    gchar *id;
    gtk_tree_model_get(model, &iter, COLUMN_ACCOUNT_ACTIVE, &enable,
                       COLUMN_ACCOUNT_ID, &id, -1);

    account_t *account = account_list_get_by_id(id);
    if (!account) {
        g_warning("Invalid account %s", id);
        return;
    }

    enable = !enable;

    // Store value
    gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_ACCOUNT_ACTIVE,
                       enable, -1);

    // Modify account state
    const gchar * enabled_str = enable ? "true" : "false";
    g_debug("Account is enabled: %s", enabled_str);

    account_replace(account, CONFIG_ACCOUNT_ENABLE, enabled_str);
    dbus_send_register(account->accountID, enable);
}
コード例 #9
0
static void
highlight_ip_profile(G_GNUC_UNUSED GtkTreeViewColumn *col, GtkCellRenderer *rend,
                     GtkTreeModel *tree_model, GtkTreeIter *iter,
                     G_GNUC_UNUSED gpointer data)
{
    GValue val;
    memset(&val, 0, sizeof(val));
    gtk_tree_model_get_value(tree_model, iter, COLUMN_ACCOUNT_ID, &val);
    account_t *current = account_list_get_by_id(g_value_get_string(&val));
    g_value_unset(&val);

    // Make the IP2IP account  appear differently
    if (current) {
        if (account_is_IP2IP(current)) {
            g_object_set(G_OBJECT(rend), "weight", PANGO_WEIGHT_THIN, "style",
                         PANGO_STYLE_ITALIC, "stretch",
                         PANGO_STRETCH_ULTRA_EXPANDED, "scale", 0.95, NULL);
        } else {
            g_object_set(G_OBJECT(rend), "weight", PANGO_WEIGHT_MEDIUM,
                         "style", PANGO_STYLE_NORMAL, "stretch",
                         PANGO_STRETCH_NORMAL, "scale", 1.0, NULL);
        }
    }
}