void sflphone_fill_account_list(void) { account_list_init(); gchar **array = dbus_account_list(); for (gchar **accountID = array; accountID && *accountID; ++accountID) { account_t *acc = create_account_with_ID(*accountID); if (acc->properties == NULL) { g_warning("SFLphone: Error: Could not fetch details for account %s", *accountID); break; } account_list_add(acc); /* Fill the actual array of credentials */ dbus_get_credentials(acc); gchar * status = account_lookup(acc, CONFIG_ACCOUNT_REGISTRATION_STATUS); if (g_strcmp0(status, "REGISTERED") == 0) acc->state = ACCOUNT_STATE_REGISTERED; else if (g_strcmp0(status, "UNREGISTERED") == 0) acc->state = ACCOUNT_STATE_UNREGISTERED; else if (g_strcmp0(status, "TRYING") == 0) acc->state = ACCOUNT_STATE_TRYING; else if (g_strcmp0(status, "ERROR_GENERIC") == 0) acc->state = ACCOUNT_STATE_ERROR; else if (g_strcmp0(status, "ERROR_AUTH") == 0) acc->state = ACCOUNT_STATE_ERROR_AUTH; else if (g_strcmp0(status, "ERROR_NETWORK") == 0) acc->state = ACCOUNT_STATE_ERROR_NETWORK; else if (g_strcmp0(status, "ERROR_HOST") == 0) acc->state = ACCOUNT_STATE_ERROR_HOST; else if (g_strcmp0(status, "ERROR_NOT_ACCEPTABLE") == 0) acc->state = ACCOUNT_STATE_ERROR_NOT_ACCEPTABLE; else if (g_strcmp0(status, "ERROR_EXIST_STUN") == 0) acc->state = ACCOUNT_STATE_ERROR_EXIST_STUN; else if (g_strcmp0(status, "READY") == 0) acc->state = ACCOUNT_STATE_IP2IP_READY; else { g_warning("Unexpected status %s", status); acc->state = ACCOUNT_STATE_INVALID; } gchar * code = account_lookup(acc, CONFIG_ACCOUNT_REGISTRATION_STATE_CODE); if (code != NULL) acc->protocol_state_code = atoi(code); acc->protocol_state_description = account_lookup(acc, CONFIG_ACCOUNT_REGISTRATION_STATE_DESC); } g_strfreev(array); // Set the current account message number current_account_set_message_number(current_account_get_message_number()); }
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); }
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; }
void status_bar_display_account() { statusbar_pop_message(__MSG_ACCOUNT_DEFAULT); account_t *acc = account_list_get_current(); status_tray_icon_online(acc != NULL); static const char * const account_types[] = { N_("(SIP)"), N_("(IAX)") }; gchar* msg; if (acc) { const guint type_idx = account_is_IAX(acc); msg = g_markup_printf_escaped(_("%s %s"), (gchar*) account_lookup(acc, CONFIG_ACCOUNT_ALIAS), _(account_types[type_idx])); } else { msg = g_markup_printf_escaped(_("No registered accounts")); } statusbar_push_message(msg, NULL, __MSG_ACCOUNT_DEFAULT); g_free(msg); }
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; }
static gboolean is_type(const account_t *account, const gchar *type) { const gchar *account_type = account_lookup(account, ACCOUNT_TYPE); return g_strcmp0(account_type, type) == 0; }