示例#1
0
GtkWidget* create_hooks_settings()
{
    GtkWidget *ret, *frame, *table, *label, *widg;

    // Load the user value
    hooks_load_parameters(&_urlhook_config);

    ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
    gtk_container_set_border_width(GTK_CONTAINER(ret), 10);

    gnome_main_section_new_with_table(_("URL Argument"), &frame, &table, 5, 2);
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
    gtk_widget_show(frame);

    gchar *message = "<small>Custom commands on incoming calls with URL. %s will be replaced with the passed URL.</small>";
    GtkWidget *info_bar = gnome_info_bar(message, GTK_MESSAGE_INFO);
    gtk_table_attach(GTK_TABLE(table), info_bar, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 10, 10);

    widg = gtk_check_button_new_with_mnemonic(_("Trigger on specific _SIP header"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->sip_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(sip_enabled_cb), NULL);
    gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

    field = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(field), _urlhook_config->sip_field);
    gtk_table_attach(GTK_TABLE(table), field, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

    widg = gtk_check_button_new_with_mnemonic(_("Trigger on _IAX2 URL"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->iax2_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(iax2_enabled_cb), NULL);
    gtk_table_attach(GTK_TABLE(table), widg, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

    label = gtk_label_new_with_mnemonic(_("Command to _run"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.05, 0.5);
    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
    command = gtk_entry_new();
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), command);
    gtk_entry_set_text(GTK_ENTRY(command), _urlhook_config->command);
    gtk_table_attach(GTK_TABLE(table), command, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10);

    gnome_main_section_new_with_table(_("Phone number rewriting"), &frame, &table, 4, 2);
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
    gtk_widget_show(frame);

    widg = gtk_check_button_new_with_mnemonic(_("_Prefix dialed numbers with"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->phone_number_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(phone_number_enabled_cb), NULL);
    gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

    prefix = gtk_entry_new();
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), prefix);
    gtk_entry_set_text(GTK_ENTRY(prefix), _urlhook_config->phone_number_prefix);
    gtk_widget_set_sensitive(GTK_WIDGET(prefix), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widg)));
    gtk_table_attach(GTK_TABLE(table), prefix, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10);

    gtk_widget_show_all(ret);

    return ret;
}
示例#2
0
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;
}
示例#3
0
void
notify_incoming_message(const gchar *callID, const gchar *msg)
{
#if USE_NOTIFY
    gchar* title = g_markup_printf_escaped(_("%s says:"), callID);

    create_new_gnome_notification(title,
                                  (gchar *)msg,
                                  NOTIFY_URGENCY_CRITICAL,
                                  utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER);
#endif
}
示例#4
0
void
notify_secure_off(callable_obj_t* c)
{
#if USE_NOTIFY
    gchar *title = g_markup_printf_escaped("Secure mode is off.");
    gchar *callerid = g_markup_printf_escaped(_("<i>With:</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
void
notify_zrtp_negotiation_failed(callable_obj_t* c)
{
#if USE_NOTIFY
    gchar *title = g_markup_printf_escaped("ZRTP Error.");
    gchar *callerid = g_markup_printf_escaped(_("ZRTP negotiation failed with %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
}
static void account_store_add(GtkTreeIter *iter, account_t *account)
{
    const gchar *enabled = account_lookup(account, CONFIG_ACCOUNT_ENABLE);
    const gchar *type = account_lookup(account, CONFIG_ACCOUNT_TYPE);
    g_debug("Account is enabled :%s", enabled);
    const gchar *state_name = account_state_name(account->state);

    gtk_list_store_set(account_store, iter,
                       COLUMN_ACCOUNT_ALIAS, account_lookup(account, CONFIG_ACCOUNT_ALIAS),
                       COLUMN_ACCOUNT_TYPE, type,
                       COLUMN_ACCOUNT_STATUS, state_name,
                       COLUMN_ACCOUNT_ACTIVE, utf8_case_equal(enabled, "true"),
                       COLUMN_ACCOUNT_ID, account->accountID, -1);
}
示例#7
0
static guint account_list_get_position(account_t *account)
{
    guint size = account_list_get_size();

    for (guint i = 0; i < size; i++) {
        account_t *tmp = account_list_get_nth(i);

        if (utf8_case_equal(tmp->accountID, account->accountID))
            return i;
    }

    // Not found
    return -1;
}
示例#8
0
gboolean current_account_has_mailbox(void)
{
    // Check if the current account has a voicemail number configured
    account_t *current = account_list_get_current();

    if (current) {
        gchar * account_mailbox = account_lookup(current, ACCOUNT_MAILBOX);

        if (account_mailbox && !utf8_case_equal(account_mailbox, ""))
            return TRUE;
    }

    return FALSE;
}
示例#9
0
static gboolean is_direct_call(callable_obj_t * c)
{
    if (utf8_case_equal(c->_accountID, "empty")) {
        if (!g_str_has_prefix(c->_peer_number, "sip:")) {
            gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL);
            g_free(c->_peer_number);
            c->_peer_number = new_number;
        }

        return TRUE;
    }

    return g_str_has_prefix(c->_peer_number, "sip:") ||
           g_str_has_prefix(c->_peer_number, "sips:");
}
示例#10
0
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
}
示例#11
0
GtkWidget*
create_hooks_settings(SFLPhoneClient *client)
{
    GtkWidget *ret, *frame, *label, *widg;

    // Load the user value
    hooks_load_parameters(&_urlhook_config);

    ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
    gtk_container_set_border_width(GTK_CONTAINER(ret), 10);

    GtkWidget *grid;
    gnome_main_section_new_with_grid(_("URL Argument"), &frame, &grid);
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
    gtk_widget_show(frame);

    gchar *message = "<small>Custom commands on incoming calls with URL. %s will be replaced with the passed URL.</small>";
    GtkWidget *info_bar = gnome_info_bar(message, GTK_MESSAGE_INFO);
    /* 2x1 */
    gtk_grid_attach(GTK_GRID(grid), info_bar, 0, 0, 2, 1);

    widg = gtk_check_button_new_with_mnemonic(_("Trigger on specific _SIP header"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->sip_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(sip_enabled_cb), NULL);
    gtk_grid_attach(GTK_GRID(grid), widg, 0, 2, 1, 1);

    field = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(field), _urlhook_config->sip_field);
    gtk_grid_attach(GTK_GRID(grid), field, 1, 2, 1, 1);

    widg = gtk_check_button_new_with_mnemonic(_("Trigger on _IAX2 URL"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->iax2_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(iax2_enabled_cb), NULL);
    /* 2x1 */
    gtk_grid_attach(GTK_GRID(grid), widg, 0, 3, 2, 1);

    label = gtk_label_new_with_mnemonic(_("Command to _run"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.05, 0.5);
    gtk_grid_attach(GTK_GRID(grid), label, 0, 4, 1, 1);
    command = gtk_entry_new();
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), command);
    gtk_entry_set_text(GTK_ENTRY(command), _urlhook_config->command);
    gtk_grid_attach(GTK_GRID(grid), command, 1, 4, 1, 1);

    gnome_main_section_new_with_grid(_("Phone number rewriting"), &frame, &grid);
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
    gtk_widget_show(frame);

    widg = gtk_check_button_new_with_mnemonic(_("_Prefix dialed numbers with"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->phone_number_enabled, "true"));
    g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(phone_number_enabled_cb), NULL);
    gtk_grid_attach(GTK_GRID(grid), widg, 0, 0, 1, 1);

    prefix = gtk_entry_new();
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), prefix);
    gtk_entry_set_text(GTK_ENTRY(prefix), _urlhook_config->phone_number_prefix);
    gtk_widget_set_sensitive(GTK_WIDGET(prefix), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widg)));
    gtk_grid_attach(GTK_GRID(grid), prefix, 1, 0, 1, 1);

    gnome_main_section_new_with_grid(_("Messaging"), &frame, &grid);
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
    gtk_widget_show(frame);

    label = gtk_label_new_with_mnemonic(_("Open URL in"));
    url   = gtk_entry_new();

    gchar *url_command = g_settings_get_string(client->settings, "messaging-url-command");
    if (url_command && *url_command) {
        gtk_entry_set_text(GTK_ENTRY(url), url_command);
        g_free(url_command);
    } else
        gtk_entry_set_text(GTK_ENTRY(url), "xdg-open");
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), url);
    gtk_grid_attach(GTK_GRID(grid), label, 0, 4, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), url, 1, 4, 1, 1);

    gtk_widget_show_all(ret);

    return ret;
}