diff --git a/astylerc b/astylerc index 0170fbdc9431c1f5875bf75231dd88f8c692b06c..460124f66d7a1f71a6c4d0a168f9502e4755a059 100644 --- a/astylerc +++ b/astylerc @@ -12,4 +12,5 @@ indent-switches # Indent 'switch' blocks so that the 'case X:' statement break-blocks # Pad empty lines around header blocks (e.g. 'if', 'while'...). brackets=linux unpad=paren +formatted -d diff --git a/sflphone-client-gnome/INSTALL b/sflphone-client-gnome/INSTALL index 2550dab75261145b56f3d223673e00bef2aa78df..7d1c323beae76333f523f6df31c47a87f5597edb 100644 --- a/sflphone-client-gnome/INSTALL +++ b/sflphone-client-gnome/INSTALL @@ -4,8 +4,10 @@ Installation Instructions Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. Basic Installation ================== @@ -13,7 +15,11 @@ Basic Installation Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for -instructions specific to this package. +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses @@ -42,7 +48,7 @@ may remove or edit it. you want to change it or regenerate `configure' using a newer version of `autoconf'. -The simplest way to compile this package is: + The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. @@ -53,12 +59,22 @@ The simplest way to compile this package is: 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with - the package. + the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is @@ -67,8 +83,15 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. - 6. Often, you can also type `make uninstall' to remove the installed - files again. + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. Compilers and Options ===================== @@ -93,7 +116,8 @@ same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have @@ -120,7 +144,8 @@ Installation Names By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you @@ -131,15 +156,46 @@ Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. -Optional Features -================= - Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE @@ -152,6 +208,13 @@ find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + Particular systems ================== @@ -288,7 +351,7 @@ operates. `configure' can determine that directory automatically. `--prefix=DIR' - Use DIR as the installation prefix. *Note Installation Names:: + Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. diff --git a/sflphone-client-gnome/Makefile.am b/sflphone-client-gnome/Makefile.am index e6696e170ddc9143a6f134554035c0a866534c59..386a60f1a868106be330ff86b121e5983609642d 100644 --- a/sflphone-client-gnome/Makefile.am +++ b/sflphone-client-gnome/Makefile.am @@ -1,5 +1,7 @@ SUBDIRS = src pixmaps tests man po doc +CFLAGS=-Wall -Werror -Wextra + ACLOCAL_AMFLAGS = -I m4 GCONFTOOL=gconftool-2 diff --git a/sflphone-client-gnome/configure.ac b/sflphone-client-gnome/configure.ac index be6faac5149766bc9e3ddc0d19cbac75ef6fdd97..8511fbbf6d392d576b740eb719fa05db0540a988 100644 --- a/sflphone-client-gnome/configure.ac +++ b/sflphone-client-gnome/configure.ac @@ -24,7 +24,7 @@ AC_ARG_WITH(debug, if test "x$with_debug" = "xfull" -o "x$with_debug" = "xyes"; then CFLAGS="-g -O0 -DDEBUG -Wall -Wextra" else - CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wall -Wextra" fi AC_PROG_CC diff --git a/sflphone-client-gnome/globals.mak b/sflphone-client-gnome/globals.mak index 8fe5ee180b5b23c08aaff4dda0927d41bdbdeb32..359696c7dd4c7ba93f1258c56be480121c312a29 100644 --- a/sflphone-client-gnome/globals.mak +++ b/sflphone-client-gnome/globals.mak @@ -1,6 +1,9 @@ # Global variables src = $(top_srcdir) +ASTYLERC="$(top_srcdir)/../astylerc" +indent="/usr/bin/astyle" + # Preprocessor flags AM_CPPFLAGS = $(DEPS_CFLAGS) \ $(LIBSEXY_CFLAGS) \ @@ -21,3 +24,8 @@ AM_CPPFLAGS = $(DEPS_CFLAGS) \ -DLOCALEDIR=\""$(localedir)"\" \ -DSFLPHONE_UIDIR=\""$(datadir)/sflphone/ui"\" +indent: + @echo "Indenting code:" + if [ -f $(ASTYLERC) ] ; then \ + find $(top_srcdir)/src/ -regex ".*\.\(h\|c\)" -exec $(indent) --options=$(ASTYLERC) {} \; ; \ + fi diff --git a/sflphone-client-gnome/src/Makefile.am b/sflphone-client-gnome/src/Makefile.am index 57fb2e4689c4b90983255c477e6aa014e40f4ea7..f279e1d8d3d77898e8cb27fef430e8b462acfa7d 100644 --- a/sflphone-client-gnome/src/Makefile.am +++ b/sflphone-client-gnome/src/Makefile.am @@ -42,3 +42,5 @@ install-exec-local: uninstall-local: -test -h $(DESTDIR)$(bindir)/sflphone && rm $(DESTDIR)$(bindir)/sflphone + +all: indent diff --git a/sflphone-client-gnome/src/accountlist.c b/sflphone-client-gnome/src/accountlist.c index 6d6e55ad472b5f693f9d22c70af4f0a44860bf75..d73f3450c9f9d4cc926128daaf7133fc5fe07214 100644 --- a/sflphone-client-gnome/src/accountlist.c +++ b/sflphone-client-gnome/src/accountlist.c @@ -36,362 +36,372 @@ GQueue * accountQueue; /* GCompareFunc to compare a accountID (gchar* and a account_t) */ -gint is_accountID_struct ( gconstpointer a, gconstpointer b) { - - if(!a || !b) - return 1; - - account_t * c = (account_t*)a; - if(strcmp(c->accountID, (gchar*) b) == 0) - { - return 0; - } - else - { - return 1; - } +gint is_accountID_struct (gconstpointer a, gconstpointer b) +{ + + if (!a || !b) + return 1; + + account_t * c = (account_t*) a; + + if (strcmp (c->accountID, (gchar*) b) == 0) { + return 0; + } else { + return 1; + } } /* GCompareFunc to get current call (gchar* and a account_t) */ -gint get_state_struct ( gconstpointer a, gconstpointer b) { - - account_t * c = (account_t*)a; - if( c->state == *((account_state_t*)b)) - { - return 0; - } - else - { - return 1; - } +gint get_state_struct (gconstpointer a, gconstpointer b) +{ + + account_t * c = (account_t*) a; + + if (c->state == * ( (account_state_t*) b)) { + return 0; + } else { + return 1; + } } -void account_list_init () { +void account_list_init () +{ - accountQueue = g_queue_new (); + accountQueue = g_queue_new (); } - void +void account_list_clean () { - g_queue_free (accountQueue); + g_queue_free (accountQueue); } - void +void account_list_add (account_t * c) { - g_queue_push_tail (accountQueue, (gpointer *) c); + g_queue_push_tail (accountQueue, (gpointer *) c); } - void +void account_list_add_at_nth (account_t * c, guint pos) { - g_queue_push_nth (accountQueue, (gpointer *) c, pos); + g_queue_push_nth (accountQueue, (gpointer *) c, pos); } - void +void account_list_remove (const gchar * accountID) { - GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); - if (c) - { - g_queue_remove(accountQueue, c->data); - } + GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); + + if (c) { + g_queue_remove (accountQueue, c->data); + } } - account_t * -account_list_get_by_state (account_state_t state ) +account_t * +account_list_get_by_state (account_state_t state) { - GList * c = g_queue_find_custom (accountQueue, &state, get_state_struct); - if (c) - { - return (account_t *)c->data; - } - else - { - return NULL; - } + GList * c = g_queue_find_custom (accountQueue, &state, get_state_struct); + + if (c) { + return (account_t *) c->data; + } else { + return NULL; + } } - account_t * -account_list_get_by_id(gchar * accountID) +account_t * +account_list_get_by_id (gchar * accountID) { - GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); - if(c) - { - return (account_t *)c->data; - } - else - { - return NULL; - } + GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); + + if (c) { + return (account_t *) c->data; + } else { + return NULL; + } } -guint account_list_get_size (void) { - - return g_queue_get_length (accountQueue); +guint account_list_get_size (void) +{ + + return g_queue_get_length (accountQueue); } -account_t * account_list_get_nth (guint n) { +account_t * account_list_get_nth (guint n) +{ - return g_queue_peek_nth (accountQueue, n); + return g_queue_peek_nth (accountQueue, n); } - account_t* -account_list_get_current( ) +account_t* +account_list_get_current() { - account_t *current; + account_t *current; - // No account registered - if (account_list_get_registered_accounts () == 0) - return NULL; + // No account registered + if (account_list_get_registered_accounts () == 0) + return NULL; - // if we are here, it means that we have at least one registered account in the list - // So we get the first one - current = account_list_get_by_state (ACCOUNT_STATE_REGISTERED); - if (!current) - return NULL; + // if we are here, it means that we have at least one registered account in the list + // So we get the first one + current = account_list_get_by_state (ACCOUNT_STATE_REGISTERED); - return current; + if (!current) + return NULL; + + return current; } void account_list_set_current (account_t *current) { - gpointer acc; - guint pos; - - // 2 steps: - // 1 - retrieve the index of the current account in the Queue - // 2 - then set it as first - pos = account_list_get_position (current); - if (pos > 0) - { - acc = g_queue_pop_nth(accountQueue, pos); - g_queue_push_nth(accountQueue, acc, 0); - } + gpointer acc; + guint pos; + + // 2 steps: + // 1 - retrieve the index of the current account in the Queue + // 2 - then set it as first + pos = account_list_get_position (current); + + if (pos > 0) { + acc = g_queue_pop_nth (accountQueue, pos); + g_queue_push_nth (accountQueue, acc, 0); + } } const gchar * account_state_name (account_state_t s) { - gchar * state; - switch(s) - { - case ACCOUNT_STATE_REGISTERED: - state = _("Registered"); - break; - case ACCOUNT_STATE_UNREGISTERED: - state = _("Not Registered"); - break; - case ACCOUNT_STATE_TRYING: - state = _("Trying..."); - break; - case ACCOUNT_STATE_ERROR: - state = _("Error"); - break; - case ACCOUNT_STATE_ERROR_AUTH: - state = _("Authentication Failed"); - break; - case ACCOUNT_STATE_ERROR_NETWORK: - state = _("Network unreachable"); - break; - case ACCOUNT_STATE_ERROR_HOST: - state = _("Host unreachable"); - break; - case ACCOUNT_STATE_ERROR_CONF_STUN: - state = _("Stun configuration error"); - break; - case ACCOUNT_STATE_ERROR_EXIST_STUN: - state = _("Stun server invalid"); - break; - case IP2IP_PROFILE_STATUS: - state = _("Ready"); - break; - default: - state = _("Invalid"); - break; - } - return state; + gchar * state; + + switch (s) { + case ACCOUNT_STATE_REGISTERED: + state = _ ("Registered"); + break; + case ACCOUNT_STATE_UNREGISTERED: + state = _ ("Not Registered"); + break; + case ACCOUNT_STATE_TRYING: + state = _ ("Trying..."); + break; + case ACCOUNT_STATE_ERROR: + state = _ ("Error"); + break; + case ACCOUNT_STATE_ERROR_AUTH: + state = _ ("Authentication Failed"); + break; + case ACCOUNT_STATE_ERROR_NETWORK: + state = _ ("Network unreachable"); + break; + case ACCOUNT_STATE_ERROR_HOST: + state = _ ("Host unreachable"); + break; + case ACCOUNT_STATE_ERROR_CONF_STUN: + state = _ ("Stun configuration error"); + break; + case ACCOUNT_STATE_ERROR_EXIST_STUN: + state = _ ("Stun server invalid"); + break; + case IP2IP_PROFILE_STATUS: + state = _ ("Ready"); + break; + default: + state = _ ("Invalid"); + break; + } + + return state; } - void -account_list_clear ( ) +void +account_list_clear () { - g_queue_free (accountQueue); - accountQueue = g_queue_new (); + g_queue_free (accountQueue); + accountQueue = g_queue_new (); } - void -account_list_move_up(guint index) +void +account_list_move_up (guint index) { - DEBUG ("index = %i\n", index); + DEBUG ("index = %i\n", index); - if(index != 0) - { - gpointer acc = g_queue_pop_nth(accountQueue, index); - g_queue_push_nth(accountQueue, acc, index-1); - } + if (index != 0) { + gpointer acc = g_queue_pop_nth (accountQueue, index); + g_queue_push_nth (accountQueue, acc, index-1); + } } - void -account_list_move_down(guint index) +void +account_list_move_down (guint index) { - if(index != accountQueue->length) - { - gpointer acc = g_queue_pop_nth(accountQueue, index); - g_queue_push_nth(accountQueue, acc, index+1); - } + if (index != accountQueue->length) { + gpointer acc = g_queue_pop_nth (accountQueue, index); + g_queue_push_nth (accountQueue, acc, index+1); + } } - guint -account_list_get_registered_accounts( void ) +guint +account_list_get_registered_accounts (void) { - guint res = 0; - unsigned int i; - - for(i=0;i<account_list_get_size();i++) - { - - if( account_list_get_nth( i ) -> state == ( ACCOUNT_STATE_REGISTERED )) - res ++; - } - DEBUG("Account: %d registered accounts" , res ); - return res; + guint res = 0; + unsigned int i; + + for (i=0; i<account_list_get_size(); i++) { + + if (account_list_get_nth (i) -> state == (ACCOUNT_STATE_REGISTERED)) + res ++; + } + + DEBUG ("Account: %d registered accounts" , res); + return res; } -gchar* account_list_get_current_id( void ){ +gchar* account_list_get_current_id (void) +{ - account_t *current; + account_t *current; - current = account_list_get_current (); - if (current) - return current->accountID; - else - return ""; + current = account_list_get_current (); + + if (current) + return current->accountID; + else + return ""; } -int account_list_get_sip_account_number( void ){ +int account_list_get_sip_account_number (void) +{ - int n; - guint size, i; - account_t *current; + int n; + guint size, i; + account_t *current; - size = account_list_get_size(); - n = 0; - for( i=0; i<size ;i++ ){ - current = account_list_get_nth( i ); - if( strcmp(g_hash_table_lookup(current->properties, ACCOUNT_TYPE), "SIP" ) == 0 ) - n++; - } + size = account_list_get_size(); + n = 0; - return n; + for (i=0; i<size ; i++) { + current = account_list_get_nth (i); + + if (strcmp (g_hash_table_lookup (current->properties, ACCOUNT_TYPE), "SIP") == 0) + n++; + } + + return n; } -int account_list_get_iax_account_number( void ){ +int account_list_get_iax_account_number (void) +{ + + int n; + guint size, i; + account_t *current; + + size = account_list_get_size(); + n = 0; - int n; - guint size, i; - account_t *current; + for (i=0; i<size ; i++) { + current = account_list_get_nth (i); - size = account_list_get_size(); - n = 0; - for( i=0; i<size ;i++ ){ - current = account_list_get_nth( i ); - if( strcmp(g_hash_table_lookup(current->properties, ACCOUNT_TYPE), "IAX" ) == 0 ) - n++; - } + if (strcmp (g_hash_table_lookup (current->properties, ACCOUNT_TYPE), "IAX") == 0) + n++; + } - return n; + return n; } -gchar * account_list_get_ordered_list (void) { +gchar * account_list_get_ordered_list (void) +{ + + gchar *order=""; + guint i; + + for (i=0; i < account_list_get_size(); i++) { + account_t * account = NULL; + account = account_list_get_nth (i); - gchar *order=""; - guint i; + if (account != NULL) { + order = g_strconcat (order, account->accountID, "/", NULL); + } + } - for( i=0; i < account_list_get_size(); i++ ) - { - account_t * account = NULL; - account = account_list_get_nth(i); - if (account != NULL) { - order = g_strconcat (order, account->accountID, "/", NULL); - } - } - return order; + return order; } -guint account_list_get_position (account_t *account) +guint account_list_get_position (account_t *account) { - guint size, i; - account_t *tmp; - - size = account_list_get_size (); - for (i=0; i<size; i++) - { - tmp = account_list_get_nth (i); - if (g_strcasecmp (tmp->accountID, account->accountID) == 0) - { - return i; - } - } - // Not found - return -1; + guint size, i; + account_t *tmp; + + size = account_list_get_size (); + + for (i=0; i<size; i++) { + tmp = account_list_get_nth (i); + + if (g_strcasecmp (tmp->accountID, account->accountID) == 0) { + return i; + } + } + + // Not found + return -1; } gboolean current_account_has_mailbox (void) { - account_t *current; + account_t *current; + + // Check if the current account has a voicemail number configured - // Check if the current account has a voicemail number configured + current = account_list_get_current (); - current = account_list_get_current (); - if (current) - { - if (g_strcasecmp (g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX), "") != 0) - return TRUE; - } + if (current) { + gchar * account_mailbox = g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX); - return FALSE; + if (account_mailbox != NULL && g_strcasecmp (account_mailbox, "") != 0) + return TRUE; + } + + return FALSE; } void current_account_set_message_number (guint nb) { - account_t *current; + account_t *current; + + current = account_list_get_current (); - current = account_list_get_current (); - if (current) - { - current->_messages_number = nb; - } + if (current) { + current->_messages_number = nb; + } } guint current_account_get_message_number (void) { - account_t *current; - - current = account_list_get_current (); - if (current) - { - return current->_messages_number; - } - else - return 0; + account_t *current; + + current = account_list_get_current (); + + if (current) { + return current->_messages_number; + } else + return 0; } gboolean current_account_has_new_message (void) { - account_t *current; - - current = account_list_get_current (); - if (current) - { - return (current->_messages_number > 0); - } - return FALSE; + account_t *current; + + current = account_list_get_current (); + + if (current) { + return (current->_messages_number > 0); + } + + return FALSE; } diff --git a/sflphone-client-gnome/src/accountlist.h b/sflphone-client-gnome/src/accountlist.h index 1ba201ffa8a4aca27da2210801465211bf24c71a..9aa8bb361a0b8b2383e9f9a3b2b34c4483d4e3db 100644 --- a/sflphone-client-gnome/src/accountlist.h +++ b/sflphone-client-gnome/src/accountlist.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,7 +28,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __ACCOUNTLIST_H__ #define __ACCOUNTLIST_H__ @@ -37,176 +37,175 @@ * @brief A list to hold accounts. */ -/** @enum account_state_t +/** @enum account_state_t * This enum have all the states an account can take. */ -typedef enum -{ - /** Invalid state */ - ACCOUNT_STATE_INVALID = 0, - /** The account is registered */ - ACCOUNT_STATE_REGISTERED, - /** The account is not registered */ - ACCOUNT_STATE_UNREGISTERED, - /** The account is trying to register */ - ACCOUNT_STATE_TRYING, - /** Error state. The account is not registered */ - ACCOUNT_STATE_ERROR, - /** An authentification error occured. Wrong password or wrong username. The account is not registered */ - ACCOUNT_STATE_ERROR_AUTH, - /** The network is unreachable. The account is not registered */ - ACCOUNT_STATE_ERROR_NETWORK, - /** Host is unreachable. The account is not registered */ - ACCOUNT_STATE_ERROR_HOST, - /** Stun server configuration error. The account is not registered */ - ACCOUNT_STATE_ERROR_CONF_STUN, - /** Stun server is not existing. The account is not registered */ - ACCOUNT_STATE_ERROR_EXIST_STUN, - /** IP profile status **/ - IP2IP_PROFILE_STATUS +typedef enum { + /** Invalid state */ + ACCOUNT_STATE_INVALID = 0, + /** The account is registered */ + ACCOUNT_STATE_REGISTERED, + /** The account is not registered */ + ACCOUNT_STATE_UNREGISTERED, + /** The account is trying to register */ + ACCOUNT_STATE_TRYING, + /** Error state. The account is not registered */ + ACCOUNT_STATE_ERROR, + /** An authentification error occured. Wrong password or wrong username. The account is not registered */ + ACCOUNT_STATE_ERROR_AUTH, + /** The network is unreachable. The account is not registered */ + ACCOUNT_STATE_ERROR_NETWORK, + /** Host is unreachable. The account is not registered */ + ACCOUNT_STATE_ERROR_HOST, + /** Stun server configuration error. The account is not registered */ + ACCOUNT_STATE_ERROR_CONF_STUN, + /** Stun server is not existing. The account is not registered */ + ACCOUNT_STATE_ERROR_EXIST_STUN, + /** IP profile status **/ + IP2IP_PROFILE_STATUS } account_state_t; /** @struct account_t * @brief Account information. - * This struct holds information about an account. All values are stored in the - * properties GHashTable except the accountID and state. This match how the + * This struct holds information about an account. All values are stored in the + * properties GHashTable except the accountID and state. This match how the * server internally works and the dbus API to save and retrieve the accounts details. - * - * To retrieve the Alias for example, use g_hash_table_lookup(a->properties, ACCOUNT_ALIAS). + * + * To retrieve the Alias for example, use g_hash_table_lookup(a->properties, ACCOUNT_ALIAS). */ typedef struct { - gchar * accountID; - account_state_t state; - gchar * protocol_state_description; - guint protocol_state_code; - GHashTable * properties; - GPtrArray * credential_information; - - /* The codec list */ - GQueue *codecs; - guint _messages_number; + gchar * accountID; + account_state_t state; + gchar * protocol_state_description; + guint protocol_state_code; + GHashTable * properties; + GPtrArray * credential_information; + + /* The codec list */ + GQueue *codecs; + guint _messages_number; } account_t; -/** - * This function initialize the account list. +/** + * This function initialize the account list. */ void account_list_init (); -/** - * This function empty and free the account list. +/** + * This function empty and free the account list. */ void account_list_clean (); -/** - * This function append an account to list. - * @param a The account you want to add +/** + * This function append an account to list. + * @param a The account you want to add */ void account_list_add (account_t * a); -/** - * This function append an account to list at a given position. +/** + * This function append an account to list at a given position. * @param a The account you want to add * @param pos THe position in the list to insert the account */ void account_list_add_at_nth (account_t * a, guint pos); -/** - * This function remove an account from list. +/** + * This function remove an account from list. * @param accountID The accountID of the account you want to remove */ void account_list_remove (const gchar * accountID); -/** - * Return the first account that corresponds to the state +/** + * Return the first account that corresponds to the state * @param state The state - * @return account_t* An account or NULL + * @return account_t* An account or NULL */ -account_t * account_list_get_by_state ( account_state_t state); +account_t * account_list_get_by_state (account_state_t state); /** * @return guint The number of registered accounts in the list */ -guint account_list_get_registered_accounts( ); +guint account_list_get_registered_accounts(); -/** +/** * Return the number of accounts in the list - * @return guint The number of accounts in the list + * @return guint The number of accounts in the list */ -guint account_list_get_size ( ); +guint account_list_get_size (); -/** +/** * Return the account at the nth position in the list * @param n The position of the account you want - * @return An account or NULL + * @return An account or NULL */ -account_t * account_list_get_nth ( guint n ); +account_t * account_list_get_nth (guint n); -/** +/** * Return the current account struct * @return The current account struct */ -account_t * account_list_get_current( ); +account_t * account_list_get_current(); -/** +/** * This function sets an account as the current one * @param current the account you want to set as current */ void account_list_set_current (account_t *current); -/** +/** * This function maps account_state_t enums to a description. * @param s The state - * @return The full text description of the state + * @return The full text description of the state */ -const gchar * account_state_name(account_state_t s); +const gchar * account_state_name (account_state_t s); -/** +/** * This function clear the list */ -void account_list_clear ( ); +void account_list_clear (); -/** +/** * Return the account associated with an ID * @param accountID The ID of the account - * @return An account or NULL + * @return An account or NULL */ -account_t * account_list_get_by_id(gchar * accountID); +account_t * account_list_get_by_id (gchar * accountID); -/** +/** * Move the account from an unit up in the account_list * @param index The current index in the list */ -void account_list_move_up( guint index ); +void account_list_move_up (guint index); -/** +/** * Move the account from an unit down in the account_list * @param index The current index in the list */ -void account_list_move_down( guint index ); +void account_list_move_down (guint index); /** * Return the ID of the current default account * @return gchar* The id */ -gchar* account_list_get_current_id( void ); +gchar* account_list_get_current_id (void); /** * Returns the number of SIP accounts that have been configured */ -int account_list_get_sip_account_number( void ); +int account_list_get_sip_account_number (void); /** * Returns the number of IAX accounts that have been configured */ -int account_list_get_iax_account_number( void ); +int account_list_get_iax_account_number (void); gchar * account_list_get_ordered_list (void); guint account_list_get_position (account_t *account); -gboolean account_list_current_account_has_mailbox (void); +gboolean current_account_has_mailbox (void); guint current_account_get_message_number (void); @@ -214,4 +213,4 @@ void current_account_set_message_number (guint nb); gboolean current_account_has_new_message (void); -#endif +#endif diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index c81611a7d1df1273fad243a748a5c971460ad72b..265b4e25b46ef9ed20381b86a87a6ef85d51056d 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -55,7 +55,7 @@ GHashTable * ip2ip_profile=NULL; - void +void sflphone_notify_voice_mail (const gchar* accountID , guint count) { gchar *id; @@ -66,7 +66,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count) id = g_strdup (accountID); current_id = account_list_get_current_id (); - DEBUG("sflphone_notify_voice_mail begin"); + DEBUG ("sflphone_notify_voice_mail begin"); if (g_strcasecmp (id, current_id) != 0 || account_list_get_size() == 0) return; @@ -79,9 +79,9 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count) update_voicemail_status (); if (current) - notify_voice_mails (count, current); + notify_voice_mails (count, current); - DEBUG("sflphone_notify_voice_mail end"); + DEBUG ("sflphone_notify_voice_mail end"); } /* @@ -90,23 +90,25 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count) * registered account of the account list * Else, check if it an IP call. if not, popup an error message */ - -static gboolean _is_direct_call(callable_obj_t * c) { - if(g_strcasecmp(c->_accountID, EMPTY_ENTRY) == 0) { - if(!g_str_has_prefix (c->_peer_number, "sip:")) { - gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL); - g_free(c->_peer_number); +static gboolean _is_direct_call (callable_obj_t * c) +{ + + if (g_strcasecmp (c->_accountID, EMPTY_ENTRY) == 0) { + 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 1; } - if(g_str_has_prefix (c->_peer_number, "sip:")) { + if (g_str_has_prefix (c->_peer_number, "sip:")) { return 1; } - if(g_str_has_prefix (c->_peer_number, "sips:")) { + if (g_str_has_prefix (c->_peer_number, "sips:")) { return 1; } @@ -114,286 +116,261 @@ static gboolean _is_direct_call(callable_obj_t * c) { } - void +void status_bar_display_account () { gchar* msg; account_t* acc; - statusbar_pop_message(__MSG_ACCOUNT_DEFAULT); + statusbar_pop_message (__MSG_ACCOUNT_DEFAULT); - DEBUG("status_bar_display_account begin"); + DEBUG ("status_bar_display_account begin"); acc = account_list_get_current (); - if(acc){ - status_tray_icon_online(TRUE); - msg = g_markup_printf_escaped("%s %s (%s)" , - _("Using account"), - (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS), - (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE)); - } - else - { - status_tray_icon_online(FALSE); - msg = g_markup_printf_escaped(_("No registered accounts")); + + if (acc) { + status_tray_icon_online (TRUE); + msg = g_markup_printf_escaped ("%s %s (%s)" , + _ ("Using account"), + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_ALIAS), + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_TYPE)); + } else { + status_tray_icon_online (FALSE); + msg = g_markup_printf_escaped (_ ("No registered accounts")); } - statusbar_push_message( msg, NULL, __MSG_ACCOUNT_DEFAULT); - g_free(msg); - DEBUG("status_bar_display_account_end"); + statusbar_push_message (msg, NULL, __MSG_ACCOUNT_DEFAULT); + g_free (msg); + + DEBUG ("status_bar_display_account_end"); } - gboolean +gboolean sflphone_quit () { gboolean quit = FALSE; - guint count = calllist_get_size(current_calls); - if(count > 0){ + guint count = calllist_get_size (current_calls); + + if (count > 0) { quit = main_window_ask_quit(); - } - else{ + } else { quit = TRUE; } - if (quit) - { - // Save the history + if (quit) { + // Save the history sflphone_save_history (); - dbus_unregister(getpid()); + dbus_unregister (getpid()); dbus_clean (); //call_list_clean(); TODO //account_list_clean() gtk_main_quit (); } + return quit; } - void -sflphone_hold (callable_obj_t * c ) +void +sflphone_hold (callable_obj_t * c) { c->_state = CALL_STATE_HOLD; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_ringing(callable_obj_t * c ) +void +sflphone_ringing (callable_obj_t * c) { c->_state = CALL_STATE_RINGING; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_hung_up( callable_obj_t * c) +void +sflphone_hung_up (callable_obj_t * c) { - DEBUG("SFLphone: Hung up"); + DEBUG ("SFLphone: Hung up"); - calllist_remove( current_calls, c->_callID); - calltree_remove_call(current_calls, c, NULL); + calllist_remove (current_calls, c->_callID); + calltree_remove_call (current_calls, c, NULL); c->_state = CALL_STATE_DIALING; - call_remove_all_errors(c); + call_remove_all_errors (c); update_actions(); #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink( FALSE ); + status_tray_icon_blink (FALSE); #endif - free_callable_obj_t(c); - calltree_update_clock(); } -static hashtable_free(gpointer key, gpointer value, gpointer user_data) -{ - g_free(key); - g_free(value); -} - /** Internal to actions: Fill account list */ -void sflphone_fill_account_list (void) { +void sflphone_fill_account_list (void) +{ gchar** array; gchar** accountID; unsigned int i; int count; - GQueue *codeclist; - DEBUG("SFLphone: Fill account list"); - + DEBUG ("SFLphone: Fill account list"); + count = current_account_get_message_number (); account_list_clear (); - array = (gchar **)dbus_account_list(); - if(array) - { - /* - if(!(*accountID)) - DEBUG("hhhhhhhhhmmmmmmmmmmmm"); - */ - - for (accountID = array; *accountID; accountID++) - { - account_t * a = g_new0(account_t,1); - a->accountID = g_strdup(*accountID); - DEBUG("------------------- Account ID %s", a->accountID); + array = (gchar **) dbus_account_list(); + + if (array) { + /* + if(!(*accountID)) + DEBUG("hhhhhhhhhmmmmmmmmmmmm"); + */ + + for (accountID = array; *accountID; accountID++) { + account_t * a = g_new0 (account_t,1); + a->accountID = g_strdup (*accountID); + DEBUG ("------------------- Account ID %s", a->accountID); a->credential_information = NULL; - // TODO Clean codec list QUEUE - account_list_add(a); + // TODO Clean codec list QUEUE + account_list_add (a); } + g_strfreev (array); } - for( i = 0; i < account_list_get_size(); i++) - { + for (i = 0; i < account_list_get_size(); i++) { account_t * a = account_list_get_nth (i); - GHashTable * details = (GHashTable *) dbus_account_details(a->accountID); - if( details == NULL ) + GHashTable * details = (GHashTable *) dbus_account_details (a->accountID); + + if (details == NULL) break; + a->properties = details; - - /* As this function might be called numberous time, we should free the + + /* As this function might be called numberous time, we should free the * previously allocated space to avoid memory leaks. */ /* Fill the actual array of credentials */ - int number_of_credential = dbus_get_number_of_credential(a->accountID); - if(number_of_credential) { + int number_of_credential = dbus_get_number_of_credential (a->accountID); + + if (number_of_credential) { a->credential_information = g_ptr_array_new(); } else { a->credential_information = NULL; } - + int credential_index; - for(credential_index = 0; credential_index < number_of_credential; credential_index++) { + + for (credential_index = 0; credential_index < number_of_credential; credential_index++) { GHashTable * credential_information = dbus_get_credential (a->accountID, credential_index); - g_ptr_array_add(a->credential_information, credential_information); + g_ptr_array_add (a->credential_information, credential_information); } - gchar * status = g_hash_table_lookup(details, REGISTRATION_STATUS); - if(strcmp(status, "REGISTERED") == 0) - { + gchar * status = g_hash_table_lookup (details, REGISTRATION_STATUS); + + if (strcmp (status, "REGISTERED") == 0) { a->state = ACCOUNT_STATE_REGISTERED; - } - else if(strcmp(status, "UNREGISTERED") == 0) - { + } else if (strcmp (status, "UNREGISTERED") == 0) { a->state = ACCOUNT_STATE_UNREGISTERED; - } - else if(strcmp(status, "TRYING") == 0) - { + } else if (strcmp (status, "TRYING") == 0) { a->state = ACCOUNT_STATE_TRYING; - } - else if(strcmp(status, "ERROR") == 0) - { + } else if (strcmp (status, "ERROR") == 0) { a->state = ACCOUNT_STATE_ERROR; - } - else if(strcmp( status , "ERROR_AUTH") == 0 ) - { + } else if (strcmp (status , "ERROR_AUTH") == 0) { a->state = ACCOUNT_STATE_ERROR_AUTH; - } - else if(strcmp( status , "ERROR_NETWORK") == 0 ) - { + } else if (strcmp (status , "ERROR_NETWORK") == 0) { a->state = ACCOUNT_STATE_ERROR_NETWORK; - } - else if(strcmp( status , "ERROR_HOST") == 0 ) - { + } else if (strcmp (status , "ERROR_HOST") == 0) { a->state = ACCOUNT_STATE_ERROR_HOST; - } - else if(strcmp( status , "ERROR_CONF_STUN") == 0 ) - { + } else if (strcmp (status , "ERROR_CONF_STUN") == 0) { a->state = ACCOUNT_STATE_ERROR_CONF_STUN; - } - else if(strcmp( status , "ERROR_EXIST_STUN") == 0 ) - { + } else if (strcmp (status , "ERROR_EXIST_STUN") == 0) { a->state = ACCOUNT_STATE_ERROR_EXIST_STUN; - } - else if (strcmp (status, "READY") == 0) { - a->state = IP2IP_PROFILE_STATUS; - } - else - { + } else if (strcmp (status, "READY") == 0) { + a->state = IP2IP_PROFILE_STATUS; + } else { a->state = ACCOUNT_STATE_INVALID; } gchar * code = NULL; - code = g_hash_table_lookup(details, REGISTRATION_STATE_CODE); + code = g_hash_table_lookup (details, REGISTRATION_STATE_CODE); + if (code != NULL) { - a->protocol_state_code = atoi(code); + a->protocol_state_code = atoi (code); } - g_free(a->protocol_state_description); - a->protocol_state_description = g_hash_table_lookup(details, REGISTRATION_STATE_DESCRIPTION); + + g_free (a->protocol_state_description); + a->protocol_state_description = g_hash_table_lookup (details, REGISTRATION_STATE_DESCRIPTION); } // Set the current account message number current_account_set_message_number (count); - + sflphone_fill_codec_list (); } -gboolean sflphone_init() { +gboolean sflphone_init() +{ - if(!dbus_connect ()){ + if (!dbus_connect ()) { - main_window_error_message(_("Unable to connect to the SFLphone server.\nMake sure the daemon is running.")); + main_window_error_message (_ ("Unable to connect to the SFLphone server.\nMake sure the daemon is running.")); return FALSE; - } - else - { - dbus_register(getpid(), "Gtk+ Client"); + } else { + dbus_register (getpid(), "Gtk+ Client"); - // Init icons factory - init_icon_factory (); + // Init icons factory + init_icon_factory (); - current_calls = calltab_init(FALSE, CURRENT_CALLS); - contacts = calltab_init(TRUE, CONTACTS); - history = calltab_init(TRUE, HISTORY); + current_calls = calltab_init (FALSE, CURRENT_CALLS); + contacts = calltab_init (TRUE, CONTACTS); + history = calltab_init (TRUE, HISTORY); account_list_init (); codec_capabilities_load (); - conferencelist_init (); + conferencelist_init (); // Fetch the configured accounts sflphone_fill_account_list (); - // Fetch the ip2ip profile + // Fetch the ip2ip profile sflphone_fill_ip2ip_profile(); - - // Fetch the conference list - // sflphone_fill_conference_list(); + + // Fetch the conference list + // sflphone_fill_conference_list(); return TRUE; } } -void sflphone_fill_ip2ip_profile(void) +void sflphone_fill_ip2ip_profile (void) { ip2ip_profile = (GHashTable *) dbus_get_ip2_ip_details(); } void sflphone_get_ip2ip_properties (GHashTable **properties) { - *properties = ip2ip_profile; + *properties = ip2ip_profile; } - void +void sflphone_hang_up() { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); - DEBUG("SFLphone: Hang up"); + DEBUG ("SFLphone: Hang up"); - if(selectedCall) - { - switch(selectedCall->_state) - { + if (selectedCall) { + switch (selectedCall->_state) { case CALL_STATE_DIALING: dbus_hang_up (selectedCall); break; case CALL_STATE_RINGING: dbus_hang_up (selectedCall); - call_remove_all_errors(selectedCall); + call_remove_all_errors (selectedCall); selectedCall->_state = CALL_STATE_DIALING; //selectedCall->_stop = 0; break; @@ -402,36 +379,36 @@ sflphone_hang_up() case CALL_STATE_BUSY: case CALL_STATE_RECORD: dbus_hang_up (selectedCall); - call_remove_all_errors(selectedCall); + call_remove_all_errors (selectedCall); selectedCall->_state = CALL_STATE_DIALING; set_timestamp (&selectedCall->_time_stop); break; case CALL_STATE_FAILURE: dbus_hang_up (selectedCall); - call_remove_all_errors(selectedCall); + call_remove_all_errors (selectedCall); selectedCall->_state = CALL_STATE_DIALING; break; case CALL_STATE_INCOMING: dbus_refuse (selectedCall); - call_remove_all_errors(selectedCall); + call_remove_all_errors (selectedCall); selectedCall->_state = CALL_STATE_DIALING; - DEBUG("from sflphone_hang_up : "); stop_notification(); + DEBUG ("from sflphone_hang_up : "); + stop_notification(); break; case CALL_STATE_TRANSFERT: dbus_hang_up (selectedCall); - call_remove_all_errors(selectedCall); + call_remove_all_errors (selectedCall); set_timestamp (&selectedCall->_time_stop); break; default: - WARN("Should not happen in sflphone_hang_up()!"); + WARN ("Should not happen in sflphone_hang_up()!"); break; } - } - else if(selectedConf) { - dbus_hang_up_conference(selectedConf); + } else if (selectedConf) { + dbus_hang_up_conference (selectedConf); } - calltree_update_call(history, selectedCall, NULL); + calltree_update_call (history, selectedCall, NULL); calltree_update_clock(); } @@ -442,30 +419,29 @@ sflphone_conference_hang_up() { conference_obj_t * selectedConf = calltab_get_selected_conf(); - if(selectedConf) - dbus_hang_up_conference(selectedConf); + if (selectedConf) + dbus_hang_up_conference (selectedConf); } - void +void sflphone_pick_up() { - DEBUG("sflphone_pick_up\n"); + DEBUG ("sflphone_pick_up\n"); callable_obj_t * selectedCall = NULL; - selectedCall = calltab_get_selected_call(active_calltree); - - if(selectedCall) - { - switch(selectedCall->_state) - { + selectedCall = calltab_get_selected_call (active_calltree); + + if (selectedCall) { + switch (selectedCall->_state) { case CALL_STATE_DIALING: sflphone_place_call (selectedCall); break; case CALL_STATE_INCOMING: selectedCall->_history_state = INCOMING; - calltree_update_call( history, selectedCall, NULL); + calltree_update_call (history, selectedCall, NULL); dbus_accept (selectedCall); - DEBUG("from sflphone_pick_up : "); stop_notification(); + DEBUG ("from sflphone_pick_up : "); + stop_notification(); break; case CALL_STATE_HOLD: sflphone_new_call(); @@ -482,27 +458,25 @@ sflphone_pick_up() sflphone_new_call(); break; default: - WARN("Should not happen in sflphone_pick_up()!"); + WARN ("Should not happen in sflphone_pick_up()!"); break; } - } - else { + } else { sflphone_new_call(); } } - void +void sflphone_on_hold () { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree); - - DEBUG("sflphone_on_hold"); - if(selectedCall) - { - switch(selectedCall->_state) - { + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + + DEBUG ("sflphone_on_hold"); + + if (selectedCall) { + switch (selectedCall->_state) { case CALL_STATE_CURRENT: dbus_hold (selectedCall); break; @@ -511,179 +485,175 @@ sflphone_on_hold () break; default: - WARN("Should not happen in sflphone_on_hold!"); + WARN ("Should not happen in sflphone_on_hold!"); break; } - } - else if (selectedConf) { - dbus_hold_conference(selectedConf); + } else if (selectedConf) { + dbus_hold_conference (selectedConf); } } - void +void sflphone_off_hold () { - DEBUG("sflphone_off_hold"); - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree); - - if(selectedCall) - { - switch(selectedCall->_state) - { + DEBUG ("sflphone_off_hold"); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + + if (selectedCall) { + switch (selectedCall->_state) { case CALL_STATE_HOLD: dbus_unhold (selectedCall); break; default: - WARN("Should not happen in sflphone_off_hold ()!"); + WARN ("Should not happen in sflphone_off_hold ()!"); break; } - } - else if (selectedConf) { + } else if (selectedConf) { + - - dbus_unhold_conference(selectedConf); + dbus_unhold_conference (selectedConf); } } - void -sflphone_fail( callable_obj_t * c ) +void +sflphone_fail (callable_obj_t * c) { c->_state = CALL_STATE_FAILURE; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_busy( callable_obj_t * c ) +void +sflphone_busy (callable_obj_t * c) { c->_state = CALL_STATE_BUSY; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_current( callable_obj_t * c ) +void +sflphone_current (callable_obj_t * c) { - if( c->_state != CALL_STATE_HOLD ) + if (c->_state != CALL_STATE_HOLD) set_timestamp (&c->_time_start); + c->_state = CALL_STATE_CURRENT; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_record( callable_obj_t * c ) +void +sflphone_record (callable_obj_t * c) { - if( c->_state != CALL_STATE_HOLD ) - set_timestamp (&c->_time_start); + if (c->_state != CALL_STATE_HOLD) + set_timestamp (&c->_time_start); + c->_state = CALL_STATE_RECORD; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void +void sflphone_set_transfert() { - callable_obj_t * c = calltab_get_selected_call(current_calls); - if(c) - { + callable_obj_t * c = calltab_get_selected_call (current_calls); + + if (c) { c->_state = CALL_STATE_TRANSFERT; - c->_trsft_to = g_strdup(""); - calltree_update_call(current_calls, c, NULL); + c->_trsft_to = g_strdup (""); + calltree_update_call (current_calls, c, NULL); } + update_actions(); } - void +void sflphone_unset_transfert() { - callable_obj_t * c = calltab_get_selected_call(current_calls); - if(c) - { + callable_obj_t * c = calltab_get_selected_call (current_calls); + + if (c) { c->_state = CALL_STATE_CURRENT; - c->_trsft_to = g_strdup(""); - calltree_update_call(current_calls, c, NULL); + c->_trsft_to = g_strdup (""); + calltree_update_call (current_calls, c, NULL); } + update_actions(); } - void -sflphone_display_transfer_status(const gchar* message) +void +sflphone_display_transfer_status (const gchar* message) { - statusbar_push_message( message , NULL, __MSG_ACCOUNT_DEFAULT); + statusbar_push_message (message , NULL, __MSG_ACCOUNT_DEFAULT); } - void +void sflphone_incoming_call (callable_obj_t * c) { - gchar *msg = ""; + gchar *msg = ""; c->_history_state = MISSED; - calllist_add ( current_calls, c ); - calllist_add( history, c ); - calltree_add_call( current_calls, c, NULL); + calllist_add (current_calls, c); + calllist_add (history, c); + calltree_add_call (current_calls, c, NULL); update_actions(); calltree_display (current_calls); - - // Change the status bar if we are dealing with a direct SIP call - if(_is_direct_call(c)) { - 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); - } + + // Change the status bar if we are dealing with a direct SIP call + if (_is_direct_call (c)) { + 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); + } } - void -process_dialing(callable_obj_t * c, guint keyval, gchar * key) +void +process_dialing (callable_obj_t * c, guint keyval, gchar * key) { // We stop the tone - if(strlen(c->_peer_number) == 0 && c->_state != CALL_STATE_TRANSFERT){ - dbus_start_tone( FALSE , 0 ); + if (strlen (c->_peer_number) == 0 && c->_state != CALL_STATE_TRANSFERT) { + dbus_start_tone (FALSE , 0); //dbus_play_dtmf( key ); } - DEBUG("process_dialing : keyval : %i",keyval); - DEBUG("process_dialing : key : %s",key); + DEBUG ("process_dialing : keyval : %i",keyval); + DEBUG ("process_dialing : key : %s",key); - switch (keyval) - { + switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ - sflphone_place_call(c); + sflphone_place_call (c); break; case 65307: /* ESCAPE */ - sflphone_hang_up(c); + sflphone_hang_up (c); break; case 65288: /* BACKSPACE */ - { /* Brackets mandatory because of local vars */ - gchar * before = c->_peer_number; - if(strlen(c->_peer_number) >= 1){ - - if (c->_state == CALL_STATE_TRANSFERT) - { - // Process backspace if and only if string not NULL - if(strlen(c->_trsft_to) > 0) - c->_trsft_to = g_strndup (c->_trsft_to, strlen(c->_trsft_to) - 1); - } - else - { - c->_peer_number = g_strndup(c->_peer_number, strlen(c->_peer_number) -1); - g_free(before); - DEBUG("TO: backspace %s", c->_peer_number); - } - calltree_update_call(current_calls, c, NULL); - } - else if(strlen(c->_peer_number) == 0) - { - if(c->_state != CALL_STATE_TRANSFERT) - dbus_hang_up(c); + { /* Brackets mandatory because of local vars */ + gchar * before = c->_peer_number; + + if (strlen (c->_peer_number) >= 1) { + + if (c->_state == CALL_STATE_TRANSFERT) { + // Process backspace if and only if string not NULL + if (strlen (c->_trsft_to) > 0) + c->_trsft_to = g_strndup (c->_trsft_to, strlen (c->_trsft_to) - 1); + } else { + c->_peer_number = g_strndup (c->_peer_number, strlen (c->_peer_number) -1); + g_free (before); + DEBUG ("TO: backspace %s", c->_peer_number); } + + calltree_update_call (current_calls, c, NULL); + } else if (strlen (c->_peer_number) == 0) { + if (c->_state != CALL_STATE_TRANSFERT) + dbus_hang_up (c); } - break; + } + break; case 65289: /* TAB */ case 65513: /* ALT */ case 65507: /* CTRL */ @@ -691,33 +661,31 @@ process_dialing(callable_obj_t * c, guint keyval, gchar * key) case 65509: /* CAPS */ break; default: + // if (keyval < 255 || (keyval >65453 && keyval < 65466)) - if (keyval < 127 || (keyval > 65400 && keyval < 65466)) - { + if (keyval < 127 || (keyval > 65400 && keyval < 65466)) { - if (c->_state == CALL_STATE_TRANSFERT) - { - c->_trsft_to = g_strconcat(c->_trsft_to, key, NULL); - } - else - { - dbus_play_dtmf( key ); - c->_peer_number = g_strconcat(c->_peer_number, key, NULL); + if (c->_state == CALL_STATE_TRANSFERT) { + c->_trsft_to = g_strconcat (c->_trsft_to, key, NULL); + } else { + dbus_play_dtmf (key); + c->_peer_number = g_strconcat (c->_peer_number, key, NULL); } - if(c->_state == CALL_STATE_DIALING) - { + if (c->_state == CALL_STATE_DIALING) { //g_free(c->_peer_name); //c->_peer_name = g_strconcat("\"\" <", c->_peer_number, ">", NULL); } - calltree_update_call(current_calls, c, NULL); + + calltree_update_call (current_calls, c, NULL); } + break; } } - callable_obj_t * +callable_obj_t * sflphone_new_call() { @@ -725,18 +693,18 @@ sflphone_new_call() callable_obj_t * current_selected_call; gchar *peer_name, *peer_number; - DEBUG("Actions: Sflphone new call"); + DEBUG ("Actions: Sflphone new call"); - current_selected_call = calltab_get_selected_call(current_calls); + current_selected_call = calltab_get_selected_call (current_calls); - if ((current_selected_call != NULL) && (current_selected_call->_confID == NULL)) - sflphone_on_hold(); + if ( (current_selected_call != NULL) && (current_selected_call->_confID == NULL)) + sflphone_on_hold(); // Play a tone when creating a new call - if( calllist_get_size(current_calls) == 0 ) - dbus_start_tone( TRUE , (current_account_has_new_message () > 0)? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ; + if (calllist_get_size (current_calls) == 0) + dbus_start_tone (TRUE , (current_account_has_new_message () > 0) ? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ; - peer_number = g_strdup(""); + peer_number = g_strdup (""); peer_name = g_strdup (""); create_new_call (CALL, CALL_STATE_DIALING, "", "", peer_name, peer_number, &c); @@ -750,50 +718,47 @@ sflphone_new_call() } - void -sflphone_keypad( guint keyval, gchar * key) +void +sflphone_keypad (guint keyval, gchar * key) { - callable_obj_t * c = calltab_get_selected_call(current_calls); + callable_obj_t * c = calltab_get_selected_call (current_calls); + + if ( (active_calltree != current_calls) || (active_calltree == current_calls && !c)) { + DEBUG ("Not in a call, not dialing, create a new call"); - if((active_calltree != current_calls) || (active_calltree == current_calls && !c)) - { - DEBUG("Not in a call, not dialing, create a new call"); //dbus_play_dtmf(key); - switch (keyval) - { + switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ case 65307: /* ESCAPE */ break; default: calltree_display (current_calls); - process_dialing(sflphone_new_call(), keyval, key); + process_dialing (sflphone_new_call(), keyval, key); break; } - } - else if(c) - { - DEBUG("Call is non-zero"); - switch(c->_state) - { + } else if (c) { + DEBUG ("Call is non-zero"); + + switch (c->_state) { case CALL_STATE_DIALING: // Currently dialing => edit number - DEBUG("Writing a number"); - process_dialing(c, keyval, key); + DEBUG ("Writing a number"); + process_dialing (c, keyval, key); break; case CALL_STATE_RECORD: case CALL_STATE_CURRENT: - switch (keyval) - { + + switch (keyval) { case 65307: /* ESCAPE */ - dbus_hang_up(c); + dbus_hang_up (c); set_timestamp (&c->_time_stop); - calltree_update_call(history, c, NULL); + calltree_update_call (history, c, NULL); break; default: // To play the dtmf when calling mail box for instance - dbus_play_dtmf(key); - if (keyval < 255 || (keyval >65453 && keyval < 65466)) - { + dbus_play_dtmf (key); + + if (keyval < 255 || (keyval >65453 && keyval < 65466)) { //gchar * temp = g_strconcat(call_get_number(c), key, NULL); //gchar * before = c->from; //c->from = g_strconcat("\"",call_get_name(c) ,"\" <", temp, ">", NULL); @@ -801,416 +766,421 @@ sflphone_keypad( guint keyval, gchar * key) //g_free(temp); //update_callable_obj_tree(current_calls,c); } + break; } + break; case CALL_STATE_INCOMING: - switch (keyval) - { + + switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ c->_history_state = INCOMING; - calltree_update_call(history, c, NULL); - dbus_accept(c); - DEBUG("from sflphone_keypad ( enter ) : "); stop_notification(); + calltree_update_call (history, c, NULL); + dbus_accept (c); + DEBUG ("from sflphone_keypad ( enter ) : "); + stop_notification(); break; case 65307: /* ESCAPE */ - dbus_refuse(c); - DEBUG("from sflphone_keypad ( escape ) : "); stop_notification(); + dbus_refuse (c); + DEBUG ("from sflphone_keypad ( escape ) : "); + stop_notification(); break; } + break; case CALL_STATE_TRANSFERT: - switch (keyval) - { + + switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ - dbus_transfert(c); + dbus_transfert (c); set_timestamp (&c->_time_stop); break; case 65307: /* ESCAPE */ - sflphone_unset_transfert(c); + sflphone_unset_transfert (c); break; default: // When a call is on transfert, typing new numbers will add it to c->_peer_number - process_dialing(c, keyval, key); + process_dialing (c, keyval, key); break; } + break; case CALL_STATE_HOLD: - switch (keyval) - { + + switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ - dbus_unhold(c); + dbus_unhold (c); break; case 65307: /* ESCAPE */ - dbus_hang_up(c); + dbus_hang_up (c); break; default: // When a call is on hold, typing new numbers will create a new call - process_dialing(sflphone_new_call(), keyval, key); + process_dialing (sflphone_new_call(), keyval, key); break; } + break; case CALL_STATE_RINGING: case CALL_STATE_BUSY: case CALL_STATE_FAILURE: + //c->_stop = 0; - switch (keyval) - { + switch (keyval) { case 65307: /* ESCAPE */ - dbus_hang_up(c); + dbus_hang_up (c); //c->_stop = 0; - calltree_update_call(history, c, NULL); + calltree_update_call (history, c, NULL); break; } + break; default: break; } - } - else { + } else { sflphone_new_call(); } } -static int _place_direct_call(const callable_obj_t * c) { +static int _place_direct_call (const callable_obj_t * c) +{ if (c->_state == CALL_STATE_DIALING) { dbus_place_call (c); } else { return -1; } + return 0; } -static int _place_registered_call(callable_obj_t * c) { +static int _place_registered_call (callable_obj_t * c) +{ account_t * current = NULL; - - if(c == NULL) { - DEBUG("Actions: Callable_obj_t is NULL in _place_registered_call"); + + if (c == NULL) { + DEBUG ("Actions: Callable_obj_t is NULL in _place_registered_call"); return -1; } - + if (c->_state != CALL_STATE_DIALING) { return -1; } - - if(g_strcasecmp(c->_peer_number, "") == 0) { + + if (g_strcasecmp (c->_peer_number, "") == 0) { return -1; } - - if( account_list_get_size() == 0 ) { + + if (account_list_get_size() == 0) { notify_no_accounts(); - sflphone_fail(c); + sflphone_fail (c); return -1; - } - - if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) { - DEBUG("Actions: No registered account, cannot make a call"); + } + + if (account_list_get_by_state (ACCOUNT_STATE_REGISTERED) == NULL) { + DEBUG ("Actions: No registered account, cannot make a call"); notify_no_registered_accounts(); - sflphone_fail(c); + sflphone_fail (c); return -1; } - - DEBUG("Actions: Get account for this call"); - if(g_strcasecmp(c->_accountID, "") != 0) { - DEBUG("Actions: Account %s already set for this call", c->_accountID); - current = account_list_get_by_id(c->_accountID); + + DEBUG ("Actions: Get account for this call"); + + if (g_strcasecmp (c->_accountID, "") != 0) { + DEBUG ("Actions: Account %s already set for this call", c->_accountID); + current = account_list_get_by_id (c->_accountID); } else { - DEBUG("Actions: No account set for this call, use first of the list"); + DEBUG ("Actions: No account set for this call, use first of the list"); current = account_list_get_current(); } - if(current == NULL) { - DEBUG("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID); + if (current == NULL) { + DEBUG ("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID); return -1; - } - - if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) { + } + + if (g_strcasecmp (g_hash_table_lookup (current->properties, "Status"),"REGISTERED") ==0) { /* The call is made with the current account */ // free memory for previous account id and get a new one - g_free(c->_accountID); - c->_accountID = g_strdup(current->accountID); - dbus_place_call(c); + g_free (c->_accountID); + c->_accountID = g_strdup (current->accountID); + dbus_place_call (c); } else { - /* Place the call with the first registered account - * and switch the current account. - * If we are here, we can be sure that there is at least one. - */ - current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); - g_free(c->_accountID); - c->_accountID = g_strdup(current->accountID); - dbus_place_call(c); - notify_current_account( current ); - } + /* Place the call with the first registered account + * and switch the current account. + * If we are here, we can be sure that there is at least one. + */ + current = account_list_get_by_state (ACCOUNT_STATE_REGISTERED); + g_free (c->_accountID); + c->_accountID = g_strdup (current->accountID); + dbus_place_call (c); + notify_current_account (current); + } c->_history_state = OUTGOING; - calllist_add(history, c); + calllist_add (history, c); return 0; } - void -sflphone_place_call ( callable_obj_t * c ) +void +sflphone_place_call (callable_obj_t * c) { - gchar *msg = ""; + gchar *msg = ""; + + DEBUG ("Actions: Placing call with %s @ %s and accountid %s", c->_peer_name, c->_peer_number, c->_accountID); - DEBUG("Actions: Placing call with %s @ %s and accountid %s", c->_peer_name, c->_peer_number, c->_accountID); - - if(c == NULL) { - DEBUG("Actions: Unexpected condition: callable_obj_t is null in %s at %d", __FILE__, __LINE__); + if (c == NULL) { + DEBUG ("Actions: Unexpected condition: callable_obj_t is null in %s at %d", __FILE__, __LINE__); return; } - if(_is_direct_call(c)) { - 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); - if(_place_direct_call(c) < 0) { - DEBUG("An error occured while placing direct call in %s at %d", __FILE__, __LINE__); + if (_is_direct_call (c)) { + 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); + + if (_place_direct_call (c) < 0) { + DEBUG ("An error occured while placing direct call in %s at %d", __FILE__, __LINE__); return; } } else { - if(_place_registered_call(c) < 0) { - DEBUG("An error occured while placing registered call in %s at %d", __FILE__, __LINE__); + if (_place_registered_call (c) < 0) { + DEBUG ("An error occured while placing registered call in %s at %d", __FILE__, __LINE__); return; } } } - void -sflphone_detach_participant(const gchar* callID) +void +sflphone_detach_participant (const gchar* callID) { - DEBUG("Action: Detach participant from conference"); + DEBUG ("Action: Detach participant from conference"); - if(callID == NULL) { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - DEBUG("Action: Detach participant %s", selectedCall->_callID); + if (callID == NULL) { + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + DEBUG ("Action: Detach participant %s", selectedCall->_callID); - if(selectedCall->_confID) { - g_free(selectedCall->_confID); - selectedCall->_confID = NULL; - } + if (selectedCall->_confID) { + g_free (selectedCall->_confID); + selectedCall->_confID = NULL; + } - calltree_remove_call(current_calls, selectedCall, NULL); - calltree_add_call(current_calls, selectedCall, NULL); - dbus_detach_participant(selectedCall->_callID); - } - else { - callable_obj_t * selectedCall = calllist_get(current_calls, callID); - DEBUG("Action: Darticipant %s", callID); - - if(selectedCall->_confID) { - g_free(selectedCall->_confID); - selectedCall->_confID = NULL; - } - - calltree_remove_call(current_calls, selectedCall, NULL); - calltree_add_call(current_calls, selectedCall, NULL); - dbus_detach_participant(callID); + calltree_remove_call (current_calls, selectedCall, NULL); + calltree_add_call (current_calls, selectedCall, NULL); + dbus_detach_participant (selectedCall->_callID); + } else { + callable_obj_t * selectedCall = calllist_get (current_calls, callID); + DEBUG ("Action: Darticipant %s", callID); + + if (selectedCall->_confID) { + g_free (selectedCall->_confID); + selectedCall->_confID = NULL; + } + + calltree_remove_call (current_calls, selectedCall, NULL); + calltree_add_call (current_calls, selectedCall, NULL); + dbus_detach_participant (callID); } - + } - void -sflphone_join_participant(const gchar* sel_callID, const gchar* drag_callID) +void +sflphone_join_participant (const gchar* sel_callID, const gchar* drag_callID) { - DEBUG("sflphone join participants %s and %s", sel_callID, drag_callID); + DEBUG ("sflphone join participants %s and %s", sel_callID, drag_callID); - - dbus_join_participant(sel_callID, drag_callID); + + dbus_join_participant (sel_callID, drag_callID); } - void -sflphone_add_participant(const gchar* callID, const gchar* confID) +void +sflphone_add_participant (const gchar* callID, const gchar* confID) { - DEBUG("sflphone add participant %s to conference %s", callID, confID); + DEBUG ("sflphone add participant %s to conference %s", callID, confID); - dbus_add_participant(callID, confID); + dbus_add_participant (callID, confID); } - void +void sflphone_add_conference() { - DEBUG("sflphone add a conference to tree view"); + DEBUG ("sflphone add a conference to tree view"); // dbus_join_participant(selected_call, dragged_call); } - void -sflphone_join_conference(const gchar* sel_confID, const gchar* drag_confID) +void +sflphone_join_conference (const gchar* sel_confID, const gchar* drag_confID) { - DEBUG("sflphone join two conference"); - dbus_join_conference(sel_confID, drag_confID); + DEBUG ("sflphone join two conference"); + dbus_join_conference (sel_confID, drag_confID); } void -sflphone_add_main_participant(const conference_obj_t * c) +sflphone_add_main_participant (const conference_obj_t * c) { - DEBUG("sflphone add main participant"); - dbus_add_main_participant(c->_confID); + DEBUG ("sflphone add main participant"); + dbus_add_main_participant (c->_confID); } void -sflphone_conference_on_hold(const conference_obj_t * c) +sflphone_conference_on_hold (const conference_obj_t * c) { - DEBUG("sflphone_conference_on_hold"); - dbus_hold_conference(c); + DEBUG ("sflphone_conference_on_hold"); + dbus_hold_conference (c); } void -sflphone_conference_off_hold(const conference_obj_t * c) +sflphone_conference_off_hold (const conference_obj_t * c) { - DEBUG("sflphone_conference_off_hold"); - dbus_unhold_conference(c); + DEBUG ("sflphone_conference_off_hold"); + dbus_unhold_conference (c); } - void +void sflphone_rec_call() { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf(current_calls); - - if(selectedCall) - { - dbus_set_record(selectedCall->_callID); - switch(selectedCall->_state) - { + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf (current_calls); + + if (selectedCall) { + dbus_set_record (selectedCall->_callID); + + switch (selectedCall->_state) { case CALL_STATE_CURRENT: - selectedCall->_state = CALL_STATE_RECORD; - break; + selectedCall->_state = CALL_STATE_RECORD; + break; case CALL_STATE_RECORD: - selectedCall->_state = CALL_STATE_CURRENT; - break; + selectedCall->_state = CALL_STATE_CURRENT; + break; default: - WARN("Should not happen in sflphone_off_hold ()!"); - break; - } - } - else if(selectedConf) - { - dbus_set_record(selectedConf->_confID); - switch(selectedConf->_state) - { + WARN ("Should not happen in sflphone_off_hold ()!"); + break; + } + } else if (selectedConf) { + dbus_set_record (selectedConf->_confID); + + switch (selectedConf->_state) { case CONFERENCE_STATE_ACTIVE_ATACHED: - selectedConf->_state = CONFERENCE_STATE_RECORD; - break; + selectedConf->_state = CONFERENCE_STATE_RECORD; + break; case CONFERENCE_STATE_RECORD: - selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; - break; + selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; + break; default: - WARN("Should not happen in sflphone_off_hold ()!"); - break; - } + WARN ("Should not happen in sflphone_off_hold ()!"); + break; + } } - calltree_update_call(current_calls, selectedCall, NULL); + + calltree_update_call (current_calls, selectedCall, NULL); update_actions(); } -void sflphone_fill_codec_list () { +void sflphone_fill_codec_list () +{ - guint account_list_size; - guint i; - account_t *current = NULL; - gchar** codecs = NULL; + guint account_list_size; + guint i; + account_t *current = NULL; - DEBUG("SFLphone: Fill codec list"); + DEBUG ("SFLphone: Fill codec list"); - account_list_size = account_list_get_size (); + account_list_size = account_list_get_size (); - for (i=0; i<account_list_size; i++) - { - current = account_list_get_nth (i); - if (current) { - sflphone_fill_codec_list_per_account (¤t); - } - } + for (i=0; i<account_list_size; i++) { + current = account_list_get_nth (i); + + if (current) { + sflphone_fill_codec_list_per_account (¤t); + } + } } -void sflphone_fill_codec_list_per_account (account_t **account) { +void sflphone_fill_codec_list_per_account (account_t **account) +{ gchar **order; - gchar** details; gchar** pl; - gchar *accountID; GQueue *codeclist; gboolean active = FALSE; - order = (gchar**) dbus_get_active_codec_list ((*account)->accountID); + order = (gchar**) dbus_get_active_codec_list ( (*account)->accountID); codeclist = (*account)->codecs; // First clean the list codec_list_clear (&codeclist); - if(!(*order)) - ERROR("SFLphone: No codec list provided"); - - for (pl=order; *pl; pl++) - { - codec_t * cpy = NULL; - - // Each account will have a copy of the system-wide capabilities - codec_create_new_from_caps (codec_list_get_by_payload ((gconstpointer) (size_t)atoi (*pl), NULL), &cpy); - if (cpy) { - cpy->is_active = TRUE; - codec_list_add (cpy, &codeclist); - } - else - ERROR ("SFLphone: Couldn't find codec"); + if (! (*order)) + ERROR ("SFLphone: No codec list provided"); + + for (pl=order; *pl; pl++) { + codec_t * cpy = NULL; + + // Each account will have a copy of the system-wide capabilities + codec_create_new_from_caps (codec_list_get_by_payload ( (gconstpointer) (size_t) atoi (*pl), NULL), &cpy); + + if (cpy) { + cpy->is_active = TRUE; + codec_list_add (cpy, &codeclist); + } else + ERROR ("SFLphone: Couldn't find codec"); + } + + // Test here if we just added some active codec. + active = (codeclist->length == 0) ? TRUE : FALSE; + + guint caps_size = codec_list_get_size (), i=0; + + for (i=0; i<caps_size; i++) { + + codec_t * current_cap = capabilities_get_nth (i); + + // Check if this codec has already been enabled for this account + if (codec_list_get_by_payload ( (gconstpointer) (size_t) (current_cap->_payload), codeclist) == NULL) { + // codec_t *cpy; + // codec_create_new_from_caps (current_cap, &cpy); + current_cap->is_active = active; + codec_list_add (current_cap, &codeclist); + } else { + } + } - // Test here if we just added some active codec. - active = (codeclist->length == 0) ? TRUE : FALSE; - - guint caps_size = codec_list_get_size (), i=0; - - for (i=0; i<caps_size; i++) { - - codec_t * current_cap = capabilities_get_nth (i); - // Check if this codec has already been enabled for this account - if (codec_list_get_by_payload ( (gconstpointer) (size_t)(current_cap->_payload), codeclist) == NULL) { - // codec_t *cpy; - // codec_create_new_from_caps (current_cap, &cpy); - current_cap->is_active = active; - codec_list_add (current_cap, &codeclist); - } - else { - } - - } - - (*account)->codecs = codeclist; - - // call dbus function with array of strings - codec_list_update_to_daemon (*account); - + (*account)->codecs = codeclist; + + // call dbus function with array of strings + codec_list_update_to_daemon (*account); + } void sflphone_fill_call_list (void) { - gchar** calls = (gchar**)dbus_get_call_list(); + gchar** calls = (gchar**) dbus_get_call_list(); gchar** pl; GHashTable *call_details; callable_obj_t *c; gchar *callID; - DEBUG("sflphone_fill_call_list"); + DEBUG ("sflphone_fill_call_list"); - if(calls) - { - for(pl=calls; *calls; calls++) - { - c = g_new0(callable_obj_t, 1); - callID = (gchar*)(*calls); - call_details = dbus_get_call_details(callID); + if (calls) { + for (pl=calls; *calls; calls++) { + c = g_new0 (callable_obj_t, 1); + callID = (gchar*) (*calls); + call_details = dbus_get_call_details (callID); create_new_call_from_details (callID, call_details, &c); - c->_callID = g_strdup(callID); + c->_callID = g_strdup (callID); c->_zrtp_confirmed = FALSE; // Add it to the list DEBUG ("Add call retrieved from server side: %s\n", c->_callID); @@ -1222,7 +1192,7 @@ void sflphone_fill_call_list (void) } -void sflphone_fill_conference_list(void) +void sflphone_fill_conference_list (void) { // TODO Fetch the active conferences at client startup @@ -1232,28 +1202,26 @@ void sflphone_fill_conference_list(void) gchar* conf_id; conference_obj_t* conf; - DEBUG("sflphone_fill_conference_list"); + DEBUG ("sflphone_fill_conference_list"); conferences = dbus_get_conference_list(); - if(conferences) - { - for (pl = conferences; *conferences; conferences++) - { - conf = g_new0(conference_obj_t, 1); - conf_id = (gchar*)(*conferences); + if (conferences) { + for (pl = conferences; *conferences; conferences++) { + conf = g_new0 (conference_obj_t, 1); + conf_id = (gchar*) (*conferences); + + DEBUG (" fetching conference: %s", conf_id); + + conference_details = (GHashTable*) dbus_get_conference_details (conf_id); - DEBUG(" fetching conference: %s", conf_id); + create_new_conference_from_details (conf_id, conference_details, &conf); - conference_details = (GHashTable*) dbus_get_conference_details(conf_id); - - create_new_conference_from_details (conf_id, conference_details, &conf); - - conf->_confID = g_strdup(conf_id); + conf->_confID = g_strdup (conf_id); - conferencelist_add(conf); - calltree_add_conference (current_calls, conf); - } + conferencelist_add (conf); + calltree_add_conference (current_calls, conf); + } } } @@ -1261,59 +1229,61 @@ void sflphone_fill_history (void) { GHashTable *entries; GHashTableIter iter; - gpointer key, key_to_min, value; + gpointer key, value; + gpointer key_to_min = NULL; callable_obj_t *history_entry; - - int timestamp, min_timestamp; + int timestamp = 0; + int min_timestamp = 0; gboolean is_first; DEBUG ("Loading history ..."); entries = dbus_get_history (); + if (entries) { - while(g_hash_table_size (entries)) { + while (g_hash_table_size (entries)) { - is_first = TRUE; + is_first = TRUE; - // find lowest timestamp in map - g_hash_table_iter_init (&iter, entries); - while (g_hash_table_iter_next (&iter, &key, &value)) { + // find lowest timestamp in map + g_hash_table_iter_init (&iter, entries); - timestamp = atoi((gchar*)key); + while (g_hash_table_iter_next (&iter, &key, &value)) { - if(is_first) { + timestamp = atoi ( (gchar*) key); - // first iteration of the loop, init search - min_timestamp = timestamp; - key_to_min = key; + if (is_first) { - is_first = FALSE; - } - else { + // first iteration of the loop, init search + min_timestamp = timestamp; + key_to_min = key; - // if lower, replace - if(timestamp < min_timestamp) { + is_first = FALSE; + } else { - min_timestamp = timestamp; - key_to_min = key; - } - } - } + // if lower, replace + if (timestamp < min_timestamp) { - if(g_hash_table_lookup_extended(entries, key_to_min, &key, &value)) { + min_timestamp = timestamp; + key_to_min = key; + } + } + } + + if (g_hash_table_lookup_extended (entries, key_to_min, &key, &value)) { - // do something with key and value - create_history_entry_from_serialized_form ((gchar*)key, (gchar*)value, &history_entry); - DEBUG("HISTORY ENTRY: %i\n", history_entry->_time_start); - // Add it and update the GUI - calllist_add (history, history_entry); - - // remove entry from map - g_hash_table_remove(entries, key_to_min); - } - } + // do something with key and value + create_history_entry_from_serialized_form ( (gchar*) key, (gchar*) value, &history_entry); + DEBUG ("HISTORY ENTRY: %i\n", history_entry->_time_start); + // Add it and update the GUI + calllist_add (history, history_entry); + + // remove entry from map + g_hash_table_remove (entries, key_to_min); + } + } } } @@ -1328,131 +1298,136 @@ void sflphone_save_history (void) DEBUG ("Saving history ..."); - result = g_hash_table_new(NULL, g_str_equal); + result = g_hash_table_new (NULL, g_str_equal); items = history->callQueue; size = calllist_get_size (history); - for (i=0; i<size; i++) - { + for (i=0; i<size; i++) { current = g_queue_peek_nth (items, i); - if (current) - { + + if (current) { value = serialize_history_entry (current); key = convert_timestamp_to_gchar (current->_time_start); - g_hash_table_replace(result, (gpointer) key, - (gpointer) value); + g_hash_table_replace (result, (gpointer) key, + (gpointer) value); } } dbus_set_history (result); // Decrement the reference count - g_hash_table_unref(result); + g_hash_table_unref (result); } - void -sflphone_srtp_sdes_on(callable_obj_t * c) +void +sflphone_srtp_sdes_on (callable_obj_t * c) { c->_srtp_state = SRTP_STATE_SDES_SUCCESS; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_srtp_sdes_off(callable_obj_t * c) +void +sflphone_srtp_sdes_off (callable_obj_t * c) { c->_srtp_state = SRTP_STATE_UNLOCKED; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_srtp_zrtp_on( callable_obj_t * c) +void +sflphone_srtp_zrtp_on (callable_obj_t * c) { c->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_srtp_zrtp_off( callable_obj_t * c ) +void +sflphone_srtp_zrtp_off (callable_obj_t * c) { c->_srtp_state = SRTP_STATE_UNLOCKED; - calltree_update_call(current_calls, c, NULL); + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_srtp_zrtp_show_sas( callable_obj_t * c, const gchar* sas, const gboolean verified) +void +sflphone_srtp_zrtp_show_sas (callable_obj_t * c, const gchar* sas, const gboolean verified) { - if(c == NULL) { - DEBUG("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__); + if (c == NULL) { + DEBUG ("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__); } - c->_sas = g_strdup(sas); - if(verified == TRUE) { + + c->_sas = g_strdup (sas); + + if (verified == TRUE) { c->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED; } else { c->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED; } - calltree_update_call(current_calls, c, NULL); + + calltree_update_call (current_calls, c, NULL); update_actions(); } - void -sflphone_srtp_zrtp_not_supported( callable_obj_t * c ) +void +sflphone_srtp_zrtp_not_supported (callable_obj_t * c) { - DEBUG("ZRTP not supported"); - main_window_zrtp_not_supported(c); + DEBUG ("ZRTP not supported"); + main_window_zrtp_not_supported (c); } /* Method on sflphoned */ - void -sflphone_set_confirm_go_clear( callable_obj_t * c ) +void +sflphone_set_confirm_go_clear (callable_obj_t * c) { - dbus_set_confirm_go_clear(c); + dbus_set_confirm_go_clear (c); } - void -sflphone_request_go_clear(void) +void +sflphone_request_go_clear (void) { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - if(selectedCall) { - dbus_request_go_clear(selectedCall); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + + if (selectedCall) { + dbus_request_go_clear (selectedCall); } } /* Signal sent by sflphoned */ - void -sflphone_confirm_go_clear( callable_obj_t * c ) +void +sflphone_confirm_go_clear (callable_obj_t * c) { - main_window_confirm_go_clear(c); + main_window_confirm_go_clear (c); } - void -sflphone_call_state_changed( callable_obj_t * c, const gchar * description, const guint code) +void +sflphone_call_state_changed (callable_obj_t * c, const gchar * description, const guint code) { - DEBUG("sflphone_call_state_changed"); - if(c == NULL) { - DEBUG("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__); + DEBUG ("sflphone_call_state_changed"); + + if (c == NULL) { + DEBUG ("Panic callable obj is NULL in %s at %d", __FILE__, __LINE__); } else { - //g_free(c->_state_code_description); + //g_free(c->_state_code_description); //DEBUG("sflphone_call_state_changed"); - c->_state_code_description = g_strdup(description); - c->_state_code = code; + c->_state_code_description = g_strdup (description); + c->_state_code = code; } - - calltree_update_call(current_calls, c, NULL); + + calltree_update_call (current_calls, c, NULL); update_actions(); } -void sflphone_get_interface_addr_from_name(char *iface_name, char **iface_addr, int size) { +void sflphone_get_interface_addr_from_name (char *iface_name, char **iface_addr, int size) +{ struct ifreq ifr; int fd; @@ -1463,26 +1438,26 @@ void sflphone_get_interface_addr_from_name(char *iface_name, char **iface_addr, struct sockaddr_in *saddr_in; struct in_addr *addr_in; - if((fd = socket (AF_INET, SOCK_DGRAM,0)) < 0) - DEBUG("getInterfaceAddrFromName error could not open socket\n"); + if ( (fd = socket (AF_INET, SOCK_DGRAM,0)) < 0) + DEBUG ("getInterfaceAddrFromName error could not open socket\n"); memset (&ifr, 0, sizeof (struct ifreq)); strcpy (ifr.ifr_name, iface_name); ifr.ifr_addr.sa_family = AF_INET; - if((err = ioctl(fd, SIOCGIFADDR, &ifr)) < 0) - DEBUG("getInterfaceAddrFromName use default interface (0.0.0.0)\n"); + if ( (err = ioctl (fd, SIOCGIFADDR, &ifr)) < 0) + DEBUG ("getInterfaceAddrFromName use default interface (0.0.0.0)\n"); + - - saddr_in = (struct sockaddr_in *)&ifr.ifr_addr; - addr_in = &(saddr_in->sin_addr); + saddr_in = (struct sockaddr_in *) &ifr.ifr_addr; + addr_in = & (saddr_in->sin_addr); - tmp_addr = (char *)addr_in; + tmp_addr = (char *) addr_in; - snprintf(*iface_addr, size, "%d.%d.%d.%d", - UC(tmp_addr[0]), UC(tmp_addr[1]), UC(tmp_addr[2]), UC(tmp_addr[3])); + snprintf (*iface_addr, size, "%d.%d.%d.%d", + UC (tmp_addr[0]), UC (tmp_addr[1]), UC (tmp_addr[2]), UC (tmp_addr[3])); - close(fd); + close (fd); } diff --git a/sflphone-client-gnome/src/actions.h b/sflphone-client-gnome/src/actions.h index 8be845e176769555f61d50653b4dc2d0f07b445e..5cd2a7245d69369f0a8ab811e3e70415dbc22c10 100644 --- a/sflphone-client-gnome/src/actions.h +++ b/sflphone-client-gnome/src/actions.h @@ -54,13 +54,13 @@ * Initialize lists and configurations * @return TRUE if succeeded, FALSE otherwise */ -gboolean sflphone_init ( ) ; +gboolean sflphone_init () ; /** * Steps when closing the application. Will ask for confirmation if a call is in progress. * @return TRUE if the user wants to quit, FALSE otherwise. */ -gboolean sflphone_quit ( ) ; +gboolean sflphone_quit () ; /** * Hang up / refuse the current call @@ -88,7 +88,7 @@ callable_obj_t * sflphone_new_call(); * @param accountID The account the voice mails are for * @param count The number of voice mails */ -void sflphone_notify_voice_mail ( const gchar* accountID , guint count ); +void sflphone_notify_voice_mail (const gchar* accountID , guint count); /** * Prepare SFLphone to transfer a call and wait for the user to dial the number to transfer to @@ -110,43 +110,43 @@ void sflphone_pick_up (); * Put the call on hold state * @param c The current call */ -void sflphone_hold ( callable_obj_t * c); +void sflphone_hold (callable_obj_t * c); /** * Put the call in Ringing state * @param c* The current call */ -void sflphone_ringing(callable_obj_t * c ); +void sflphone_ringing (callable_obj_t * c); /** * Put the call in Busy state * @param c* The current call */ -void sflphone_busy( callable_obj_t * c ); +void sflphone_busy (callable_obj_t * c); /** * Put the call in Failure state * @param c* The current call */ -void sflphone_fail( callable_obj_t * c ); +void sflphone_fail (callable_obj_t * c); /** * Put the call in Current state * @param c The current call */ -void sflphone_current ( callable_obj_t * c); +void sflphone_current (callable_obj_t * c); /** * The callee has hung up * @param c The current call */ -void sflphone_hung_up( callable_obj_t * c); +void sflphone_hung_up (callable_obj_t * c); /** * Incoming call * @param c The incoming call */ -void sflphone_incoming_call ( callable_obj_t * c); +void sflphone_incoming_call (callable_obj_t * c); /** * Dial the number @@ -154,26 +154,26 @@ void sflphone_incoming_call ( callable_obj_t * c); * @param keyval The unique int representing the key * @param key The char value of the key */ -void sflphone_keypad ( guint keyval, gchar * key); +void sflphone_keypad (guint keyval, gchar * key); /** * Place a call with a filled callable_obj_t.to * @param c A call in CALL_STATE_DIALING state */ -void sflphone_place_call ( callable_obj_t * c ); +void sflphone_place_call (callable_obj_t * c); /** * Fetch the ip2ip profile through dbus and fill - * the internal hash table. + * the internal hash table. */ -void sflphone_fill_ip2ip_profile(void); +void sflphone_fill_ip2ip_profile (void); /** * @return The internal hash table representing - * the settings for the ip2ip profile. + * the settings for the ip2ip profile. */ void sflphone_get_ip2ip_properties (GHashTable **properties); - + /** * Initialize the accounts data structure */ @@ -210,95 +210,110 @@ void sflphone_save_history (void); /** * Action called when two single call are dragged on together to create a new conference */ -void sflphone_join_participant(const gchar* sel_callID, const gchar* drag_callID); +void sflphone_join_participant (const gchar* sel_callID, const gchar* drag_callID); /** * Action called when a new participant is dragged in */ -void sflphone_add_participant(const gchar* callID, const gchar* confID); +void sflphone_add_participant (const gchar* callID, const gchar* confID); /** * Action called when a conference participant is draged out */ -void sflphone_detach_participant(const gchar* callID); +void sflphone_detach_participant (const gchar* callID); /** * Action called when two conference are merged together */ -void sflphone_join_conference(const gchar* sel_confID, const gchar* drag_confID); +void sflphone_join_conference (const gchar* sel_confID, const gchar* drag_confID); -/** - * Nofity that the communication is +/** + * Nofity that the communication is * now secured using SRTP/SDES. * @param c* The current call */ -void sflphone_srtp_sdes_on(callable_obj_t * c); +void sflphone_srtp_sdes_on (callable_obj_t * c); -/** +/** * Notify that the SRTP/SDES session * is not secured */ -/** - * Nofity that the communication is +/** + * Nofity that the communication is * now secured using ZRTP. * @param c* The current call */ -void sflphone_srtp_zrtp_on( callable_obj_t * c); +void sflphone_srtp_zrtp_on (callable_obj_t * c); -/** +/** * Called when the ZRTP session goes * unsecured. * @param c* The current call */ -void sflphone_srtp_zrtp_off( callable_obj_t * c ); +void sflphone_srtp_zrtp_off (callable_obj_t * c); -/** +/** * Called when the sas has been computed * and is ready to be displayed. * @param c* The current call * @param sas* The Short Authentication String * @param verified* Weather the SAS was confirmed or not. */ -void sflphone_srtp_zrtp_show_sas( callable_obj_t * c, const gchar* sas, const gboolean verified); +void sflphone_srtp_zrtp_show_sas (callable_obj_t * c, const gchar* sas, const gboolean verified); -/** +/** * Called when the remote peer does not support ZRTP * @param c* The current call */ -void sflphone_srtp_zrtp_not_supported( callable_obj_t * c ); +void sflphone_srtp_zrtp_not_supported (callable_obj_t * c); -/** +/** * Called when user wants to confirm go clear request. * @param c* The call to confirm the go clear request. */ -void sflphone_set_confirm_go_clear( callable_obj_t * c ); +void sflphone_set_confirm_go_clear (callable_obj_t * c); -/** +/** * Called when user wants to confirm go clear request. * @param c* The call to confirm the go clear request. */ -void sflphone_confirm_go_clear( callable_obj_t * c ); +void sflphone_confirm_go_clear (callable_obj_t * c); /** * Called when user wants to clear. * @param c* The call on which to go clear */ -void sflphone_request_go_clear(void); +void sflphone_request_go_clear (void); -/** - * Called when the UI needs to be refreshed to +/** + * Called when the UI needs to be refreshed to * better inform the user about the current - * state of the call. + * state of the call. * @param c A pointer to the call that needs to be updated * @param description A textual description of the code * @param code The status code as in SIP or IAX */ -void sflphone_call_state_changed(callable_obj_t * c, const gchar * description, const guint code); +void sflphone_call_state_changed (callable_obj_t * c, const gchar * description, const guint code); /** * Resolve an interface address given its name */ -void sflphone_get_interface_addr_from_name(char *iface_name, char **iface_addr, int size); +void sflphone_get_interface_addr_from_name (char *iface_name, char **iface_addr, int size); + +void sflphone_add_main_participant (const conference_obj_t * c); + +void +sflphone_conference_off_hold (const conference_obj_t * c); + +void +sflphone_srtp_sdes_off (callable_obj_t * c); + +void sflphone_fill_conference_list (void); + +void sflphone_conference_on_hold (const conference_obj_t * c); + +void sflphone_conference_hang_up(); + #endif diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 3311fc0e9fb7fe243cee06353f0375da1b82d628..54e0f1226c662f1199743f9902f1093e51dc392b 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -32,34 +32,32 @@ #include <codeclist.h> #include <sflphone_const.h> #include <time.h> +#include "contacts/calltree.h" +#include <unistd.h> #define UNIX_DAY 86400 #define UNIX_WEEK 86400 * 6 #define UNIX_TWO_DAYS 86400 * 2 -gint is_callID_callstruct ( gconstpointer a, gconstpointer b) +gint is_callID_callstruct (gconstpointer a, gconstpointer b) { - callable_obj_t * c = (callable_obj_t*)a; - if(g_strcasecmp(c->_callID, (const gchar*) b) == 0) - { + callable_obj_t * c = (callable_obj_t*) a; + + if (g_strcasecmp (c->_callID, (const gchar*) b) == 0) { return 0; - } - else - { + } else { return 1; } } -gint get_state_callstruct ( gconstpointer a, gconstpointer b) +gint get_state_callstruct (gconstpointer a, gconstpointer b) { - callable_obj_t * c = (callable_obj_t*)a; - if( c->_state == *((call_state_t*)b)) - { + callable_obj_t * c = (callable_obj_t*) a; + + if (c->_state == * ( (call_state_t*) b)) { return 0; - } - else - { + } else { return 1; } } @@ -68,7 +66,7 @@ gchar* call_get_peer_name (const gchar *format) { const gchar *end, *name; - DEBUG(" callable_obj: %s", format); + DEBUG (" callable_obj: %s", format); end = g_strrstr (format, "<"); @@ -76,118 +74,115 @@ gchar* call_get_peer_name (const gchar *format) return g_strndup (format, 0); } else { name = format; - return g_strndup(name, end - name); + return g_strndup (name, end - name); } } gchar* call_get_peer_number (const gchar *format) { - DEBUG(" callable_obj: %s", format); + DEBUG (" callable_obj: %s", format); - gchar * number = g_strrstr(format, "<") + 1; - gchar * end = g_strrstr(format, ">"); + gchar * number = g_strrstr (format, "<") + 1; + gchar * end = g_strrstr (format, ">"); - if(end && number) - number = g_strndup(number, end - number ); + if (end && number) + number = g_strndup (number, end - number); else - number = g_strdup(format); - + number = g_strdup (format); + return number; } gchar* call_get_audio_codec (callable_obj_t *obj) { - gchar *audio_codec = ""; - codec_t *codec; - gchar *format =""; - int samplerate; - - if (obj) - { - audio_codec = dbus_get_current_codec_name (obj); - codec = codec_list_get_by_name (audio_codec, NULL); - if (codec){ - samplerate = codec->sample_rate; - format = g_markup_printf_escaped ("%s/%i", audio_codec, samplerate); - } - } - return format; + gchar *audio_codec = ""; + codec_t *codec; + gchar *format =""; + int samplerate; + + if (obj) { + audio_codec = dbus_get_current_codec_name (obj); + codec = codec_list_get_by_name (audio_codec, NULL); + + if (codec) { + samplerate = codec->sample_rate; + format = g_markup_printf_escaped ("%s/%i", audio_codec, samplerate); + } + } + + return format; } -void call_add_error(callable_obj_t * call, gpointer dialog) +void call_add_error (callable_obj_t * call, gpointer dialog) { g_ptr_array_add (call->_error_dialogs, dialog); } -void call_remove_error(callable_obj_t * call, gpointer dialog) +void call_remove_error (callable_obj_t * call, gpointer dialog) { g_ptr_array_remove (call->_error_dialogs, dialog); } -void call_remove_all_errors(callable_obj_t * call) +void call_remove_all_errors (callable_obj_t * call) { g_ptr_array_foreach (call->_error_dialogs, (GFunc) gtk_widget_destroy, NULL); } -void *threaded_clock_incrementer(void *pc) { +void threaded_clock_incrementer (void *pc) +{ - callable_obj_t *call = (callable_obj_t *)pc; + callable_obj_t *call = (callable_obj_t *) pc; - - while(call->clockStarted) { + while (call->clockStarted) { - gchar *res; - int duration; - time_t start, current; + int duration; + time_t start, current; - gdk_threads_enter (); - - set_timestamp(&(call->_time_current)); + gdk_threads_enter (); - start = call->_time_start; - current = call->_time_current; + set_timestamp (& (call->_time_current)); - if (current == start) { - g_snprintf(call->_timestr, 20, "00:00"); - - } + start = call->_time_start; + current = call->_time_current; - duration = (int) difftime(current, start); + if (current == start) { + g_snprintf (call->_timestr, 20, "00:00"); - if( duration / 60 == 0 ) { - if( duration < 10 ) { - g_snprintf(call->_timestr, 20, "00:0%d", duration); - } - else { - g_snprintf(call->_timestr, 20, "00:%d", duration); - } - } - else { - if( duration%60 < 10 ) { - g_snprintf(call->_timestr, 20, "0%d:0%d", duration/60, duration%60); - } - else { - g_snprintf(call->_timestr, 20, "%d:%d", duration/60, duration%60); - } - } + } - // Update clock only if call is active (current, hold, recording transfer) - if( (call->_state != CALL_STATE_INVALID) && - (call->_state != CALL_STATE_INCOMING) && - (call->_state != CALL_STATE_RINGING) && - (call->_state != CALL_STATE_DIALING) && - (call->_state != CALL_STATE_FAILURE) && - (call->_state != CALL_STATE_BUSY) ) { - calltree_update_clock(); - } + duration = (int) difftime (current, start); + + if (duration / 60 == 0) { + if (duration < 10) { + g_snprintf (call->_timestr, 20, "00:0%d", duration); + } else { + g_snprintf (call->_timestr, 20, "00:%d", duration); + } + } else { + if (duration%60 < 10) { + g_snprintf (call->_timestr, 20, "0%d:0%d", duration/60, duration%60); + } else { + g_snprintf (call->_timestr, 20, "%d:%d", duration/60, duration%60); + } + } + + // Update clock only if call is active (current, hold, recording transfer) + if ( (call->_state != CALL_STATE_INVALID) && + (call->_state != CALL_STATE_INCOMING) && + (call->_state != CALL_STATE_RINGING) && + (call->_state != CALL_STATE_DIALING) && + (call->_state != CALL_STATE_FAILURE) && + (call->_state != CALL_STATE_BUSY)) { + calltree_update_clock(); + } - gdk_threads_leave (); - + gdk_threads_leave (); - usleep(10000); - - } + + usleep (10000); + + } } @@ -198,9 +193,9 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , callable_obj_t *obj; gchar *call_id; - DEBUG("CallableObj: Create new call"); + DEBUG ("CallableObj: Create new call"); - DEBUG("Account: %s", accountID); + DEBUG ("Account: %s", accountID); // Allocate memory obj = g_new0 (callable_obj_t, 1); @@ -218,27 +213,28 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , obj->_peer_info = g_strdup (get_peer_info (peer_name, peer_number)); obj->_trsft_to = ""; - set_timestamp (&(obj->_time_start)); - set_timestamp (&(obj->_time_current)); - set_timestamp (&(obj->_time_stop)); + set_timestamp (& (obj->_time_start)); + set_timestamp (& (obj->_time_current)); + set_timestamp (& (obj->_time_stop)); // g_snprintf(obj->_timestr, 20, "00:00"); if (g_strcasecmp (callID, "") == 0) call_id = generate_call_id (); else call_id = callID; + // Set the IDs obj->_callID = g_strdup (call_id); obj->_confID = NULL; obj->clockStarted = 1; - if(obj->_type == CALL) { - // pthread_create(&(obj->tid), NULL, threaded_clock_incrementer, obj); - if( (obj->tid = g_thread_create((GThreadFunc)threaded_clock_incrementer, (void *)obj, TRUE, &err1)) == NULL) { - DEBUG("Thread creation failed!"); - g_error_free ( err1 ) ; - } + if (obj->_type == CALL) { + // pthread_create(&(obj->tid), NULL, threaded_clock_incrementer, obj); + if ( (obj->tid = g_thread_create ( (GThreadFunc) threaded_clock_incrementer, (void *) obj, TRUE, &err1)) == NULL) { + DEBUG ("Thread creation failed!"); + g_error_free (err1) ; + } } *new_call = obj; @@ -259,11 +255,11 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca if (g_strcasecmp (state_str, "CURRENT") == 0) state = CALL_STATE_CURRENT; - else if (g_strcasecmp (state_str, "RINGING") == 0) - state = CALL_STATE_RINGING; + else if (g_strcasecmp (state_str, "RINGING") == 0) + state = CALL_STATE_RINGING; - else if (g_strcasecmp (state_str, "INCOMING") == 0) - state = CALL_STATE_INCOMING; + else if (g_strcasecmp (state_str, "INCOMING") == 0) + state = CALL_STATE_INCOMING; else if (g_strcasecmp (state_str, "HOLD") == 0) state = CALL_STATE_HOLD; @@ -274,7 +270,7 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca else state = CALL_STATE_FAILURE; - create_new_call (CALL, state, (gchar*)call_id, accountID, peer_name, call_get_peer_number(peer_number), &new_call); + create_new_call (CALL, state, (gchar*) call_id, accountID, peer_name, call_get_peer_number (peer_number), &new_call); *call = new_call; } @@ -290,16 +286,15 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details // details is in serialized form, i e: calltype%to%from%callid - if ((ptr = g_strsplit(details, delim,5)) != NULL) { + if ( (ptr = g_strsplit (details, delim,5)) != NULL) { + + while (ptr != NULL && token < 5) { - while (ptr != NULL && token < 5) { - - switch (token) - { + switch (token) { case 0: history_state = get_history_state_from_id (*ptr); break; - case 1: + case 1: peer_number = *ptr; break; case 2: @@ -316,11 +311,12 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details } token++; - ptr++; + ptr++; - } + } } + if (g_strcasecmp (peer_name, "empty") == 0) peer_name=""; @@ -334,17 +330,17 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details void free_callable_obj_t (callable_obj_t *c) { - DEBUG("CallableObj: Free callable object"); + DEBUG ("CallableObj: Free callable object"); - if(!c) - ERROR("CallableObj: Callable object is NULL"); + if (!c) + ERROR ("CallableObj: Callable object is NULL"); - if(c->_type == CALL) { - c->clockStarted = 0; + if (c->_type == CALL) { + c->clockStarted = 0; - g_thread_join(c->tid); + g_thread_join (c->tid); } - + g_free (c->_callID); g_free (c->_accountID); g_free (c->_peer_name); @@ -352,12 +348,13 @@ void free_callable_obj_t (callable_obj_t *c) g_free (c->_peer_info); g_free (c); - DEBUG("If you don't see it that is because there is a problem"); + DEBUG ("If you don't see it that is because there is a problem"); calltree_update_clock(); } -void attach_thumbnail (callable_obj_t *call, GdkPixbuf *pixbuf) { +void attach_thumbnail (callable_obj_t *call, GdkPixbuf *pixbuf) +{ call->_contact_thumbnail = pixbuf; } @@ -365,8 +362,8 @@ gchar* generate_call_id (void) { gchar *call_id; - call_id = g_new0(gchar, 30); - g_sprintf(call_id, "%d", rand()); + call_id = g_new0 (gchar, 30); + g_sprintf (call_id, "%d", rand()); return call_id; } @@ -374,11 +371,12 @@ gchar* get_peer_info (gchar* number, gchar* name) { gchar *info; - info = g_strconcat("\"", name, "\" <", number, ">", NULL); + info = g_strconcat ("\"", name, "\" <", number, ">", NULL); return info; } -history_state_t get_history_state_from_id (gchar *indice){ +history_state_t get_history_state_from_id (gchar *indice) +{ history_state_t state; @@ -403,34 +401,32 @@ gchar* get_call_duration (callable_obj_t *obj) start = obj->_time_start; end = obj->_time_stop; - + if (start == end) - return g_markup_printf_escaped("<small>Duration:</small> 0:00"); + return g_markup_printf_escaped ("<small>Duration:</small> 0:00"); - duration = (int) difftime(end, start); + duration = (int) difftime (end, start); - if( duration / 60 == 0 ) - { - if( duration < 10 ) - res = g_markup_printf_escaped("00:0%i", duration); + if (duration / 60 == 0) { + if (duration < 10) + res = g_markup_printf_escaped ("00:0%i", duration); else - res = g_markup_printf_escaped("00:%i", duration); - } - else - { - if( duration%60 < 10 ) - res = g_markup_printf_escaped("%i:0%i" , duration/60 , duration%60); + res = g_markup_printf_escaped ("00:%i", duration); + } else { + if (duration%60 < 10) + res = g_markup_printf_escaped ("%i:0%i" , duration/60 , duration%60); else - res = g_markup_printf_escaped("%i:%i" , duration/60 , duration%60); + res = g_markup_printf_escaped ("%i:%i" , duration/60 , duration%60); } - return g_markup_printf_escaped("<small>Duration:</small> %s", res); + + return g_markup_printf_escaped ("<small>Duration:</small> %s", res); } gchar* serialize_history_entry (callable_obj_t *entry) { // "0|514-276-5468|Savoir-faire Linux|144562458" for instance - + gchar* result; gchar* separator = "|"; gchar* history_state, *timestamp; @@ -440,21 +436,23 @@ gchar* serialize_history_entry (callable_obj_t *entry) // and the timestamps timestamp = convert_timestamp_to_gchar (entry->_time_stop); - result = g_strconcat (history_state, separator, - entry->_peer_number, separator, - g_strcasecmp (entry->_peer_name,"") ==0 ? "empty": entry->_peer_name, separator, - timestamp, separator, - g_strcasecmp (entry->_accountID,"") ==0 ? "empty": entry->_accountID, + gchar* peer_name = (entry->_peer_name == NULL || g_strcasecmp (entry->_peer_name,"") == 0) ? "empty": entry->_peer_name; + gchar* account_id = (entry->_accountID == NULL || g_strcasecmp (entry->_accountID,"") == 0) ? "empty": entry->_accountID; + + result = g_strconcat (history_state, separator, + entry->_peer_number, separator, + peer_name, separator, + timestamp, separator, + account_id, NULL); - + return result; } gchar* get_history_id_from_state (history_state_t state) { // Refer to history_state_t enum in callable_obj.h - switch (state) - { + switch (state) { case MISSED: return "0"; case INCOMING: @@ -466,37 +464,38 @@ gchar* get_history_id_from_state (history_state_t state) } } -gchar* get_formatted_start_timestamp (callable_obj_t *obj) { - +gchar* get_formatted_start_timestamp (callable_obj_t *obj) +{ + struct tm* ptr; time_t lt, now; unsigned char str[100]; - if (obj) - { - // Fetch the current timestamp - (void) time (&now); + if (obj) { + // Fetch the current timestamp + (void) time (&now); lt = obj->_time_start; ptr = localtime (<); - if (now - lt < UNIX_WEEK) { - if (now-lt < UNIX_DAY) { - strftime((char *)str, 100, N_("today at %R"), (const struct tm *)ptr); - } else { - if (now - lt < UNIX_TWO_DAYS) { - strftime((char *)str, 100, N_("yesterday at %R"), (const struct tm *)ptr); - } else { - strftime((char *)str, 100, N_("%A at %R"), (const struct tm *)ptr); - } - } - } else { - strftime((char *)str, 100, N_("%x at %R"), (const struct tm *)ptr); - } + if (now - lt < UNIX_WEEK) { + if (now-lt < UNIX_DAY) { + strftime ( (char *) str, 100, N_ ("today at %R"), (const struct tm *) ptr); + } else { + if (now - lt < UNIX_TWO_DAYS) { + strftime ( (char *) str, 100, N_ ("yesterday at %R"), (const struct tm *) ptr); + } else { + strftime ( (char *) str, 100, N_ ("%A at %R"), (const struct tm *) ptr); + } + } + } else { + strftime ( (char *) str, 100, N_ ("%x at %R"), (const struct tm *) ptr); + } // result function of the current locale - return g_markup_printf_escaped("\n%s\n" , str); + return g_markup_printf_escaped ("\n%s\n" , str); } + return ""; } @@ -505,13 +504,13 @@ void set_timestamp (time_t *timestamp) time_t tmp; // Set to the current value - (void) time(&tmp); + (void) time (&tmp); *timestamp=tmp; } gchar* convert_timestamp_to_gchar (time_t timestamp) { - return g_markup_printf_escaped ("%i", (int)timestamp); + return g_markup_printf_escaped ("%i", (int) timestamp); } time_t convert_gchar_to_timestamp (gchar *timestamp) diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index fc3e7e1538c8ee7f4604bca3c59fc23bbe415815..4518dcd6ea1d0e8818fe59824b34bf822b8dbbbf 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -41,33 +41,30 @@ * @enum history_state * This enum have all the state a call can take in the history */ -typedef enum -{ - MISSED, - INCOMING, - OUTGOING +typedef enum { + MISSED, + INCOMING, + OUTGOING } history_state_t; /** * @enum contact_type * This enum have all types of contacts: HOME phone, cell phone, etc... */ -typedef enum -{ - CONTACT_PHONE_HOME, - CONTACT_PHONE_BUSINESS, - CONTACT_PHONE_MOBILE +typedef enum { + CONTACT_PHONE_HOME, + CONTACT_PHONE_BUSINESS, + CONTACT_PHONE_MOBILE } contact_type_t; /** * @enum callable_obj_type * This enum have all types of items */ -typedef enum -{ - CALL, - HISTORY_ENTRY, - CONTACT +typedef enum { + CALL, + HISTORY_ENTRY, + CONTACT } callable_type_t; @@ -75,16 +72,16 @@ typedef enum * This enum have all the states a call can take. */ typedef enum { - CALL_STATE_INVALID = 0, - CALL_STATE_INCOMING, - CALL_STATE_RINGING, - CALL_STATE_CURRENT, - CALL_STATE_DIALING, - CALL_STATE_HOLD, - CALL_STATE_FAILURE, - CALL_STATE_BUSY, - CALL_STATE_TRANSFERT, - CALL_STATE_RECORD, + CALL_STATE_INVALID = 0, + CALL_STATE_INCOMING, + CALL_STATE_RINGING, + CALL_STATE_CURRENT, + CALL_STATE_DIALING, + CALL_STATE_HOLD, + CALL_STATE_FAILURE, + CALL_STATE_BUSY, + CALL_STATE_TRANSFERT, + CALL_STATE_RECORD, } call_state_t; typedef enum { @@ -105,21 +102,21 @@ typedef struct { callable_type_t _type; // CALL - HISTORY ENTRY - CONTACT call_state_t _state; // The state of the call int _state_code; // The numeric state code as defined in SIP or IAX - gchar* _state_code_description; // A textual description of _state_code + gchar* _state_code_description; // A textual description of _state_code gchar* _callID; // The call ID gchar* _confID; // The conference ID (NULL if don't participate to a conference) gchar* _accountID; // The account the call is made with time_t _time_start; // The timestamp the call was initiating time_t _time_current; // Clock increment to display call's elapsed time time_t _time_stop; // The timestamp the call was over - gchar _timestr[20]; // The timestamp as a string format for disply in statusbar + gchar _timestr[20]; // The timestamp as a string format for disply in statusbar history_state_t _history_state; // The history state if necessary - srtp_state_t _srtp_state; // The state of security on the call + srtp_state_t _srtp_state; // The state of security on the call gchar* _srtp_cipher; // Cipher used for the srtp session gchar* _sas; // The Short Authentication String that should be displayed - gboolean _zrtp_confirmed; // Override real state. Used for hold/unhold - // since rtp session is killed each time and - // libzrtpcpp does not remember state (yet?) + gboolean _zrtp_confirmed; // Override real state. Used for hold/unhold + // since rtp session is killed each time and + // libzrtpcpp does not remember state (yet?) /** * The information about the person we are talking @@ -141,8 +138,8 @@ typedef struct { * The thumbnail, if callable_obj_type=CONTACT */ GdkPixbuf *_contact_thumbnail; - - /** + + /** * Maintains a list of error dialogs * associated with that call so that * they could be destroyed at the right @@ -167,26 +164,26 @@ void create_new_call_from_details (const gchar *, GHashTable *, callable_obj_t * void create_history_entry_from_serialized_form (gchar *, gchar *, callable_obj_t **); -void call_add_error(callable_obj_t * call, gpointer dialog); +void call_add_error (callable_obj_t * call, gpointer dialog); -void call_remove_error(callable_obj_t * call, gpointer dialog); +void call_remove_error (callable_obj_t * call, gpointer dialog); -void call_remove_all_errors(callable_obj_t * call); +void call_remove_all_errors (callable_obj_t * call); -/* - * GCompareFunc to compare a callID (gchar* and a callable_obj_t) +/* + * GCompareFunc to compare a callID (gchar* and a callable_obj_t) */ -gint is_callID_callstruct ( gconstpointer, gconstpointer); +gint is_callID_callstruct (gconstpointer, gconstpointer); -/* - * GCompareFunc to get current call (gchar* and a callable_obj_t) +/* + * GCompareFunc to get current call (gchar* and a callable_obj_t) */ -gint get_state_callstruct ( gconstpointer, gconstpointer); +gint get_state_callstruct (gconstpointer, gconstpointer); -/** +/** * This function parse the callable_obj_t.from field to return the name * @param c The call - * @return The full name of the caller or an empty string + * @return The full name of the caller or an empty string */ gchar* call_get_peer_name (const gchar*); diff --git a/sflphone-client-gnome/src/codeclist.c b/sflphone-client-gnome/src/codeclist.c index 21037b01fb90572cc16ddf4c72234b11df2e7f7d..d6fcadb3c910296f2e32b715a04c9c6598afa6ee 100644 --- a/sflphone-client-gnome/src/codeclist.c +++ b/sflphone-client-gnome/src/codeclist.c @@ -32,153 +32,154 @@ #include <string.h> #include <stdlib.h> +#include <unistd.h> #include "dbus.h" GQueue * codecsCapabilities = NULL; - gint +gint is_name_codecstruct (gconstpointer a, gconstpointer b) { - codec_t * c = (codec_t *)a; - if(strcmp(c->name, (const gchar *)b)==0) - return 0; - else - return 1; + codec_t * c = (codec_t *) a; + + if (strcmp (c->name, (const gchar *) b) ==0) + return 0; + else + return 1; } - gint +gint is_payload_codecstruct (gconstpointer a, gconstpointer b) { - codec_t * c = (codec_t *)a; - if(c->_payload == GPOINTER_TO_INT(b)) - return 0; - else - return 1; + codec_t * c = (codec_t *) a; + + if (c->_payload == GPOINTER_TO_INT (b)) + return 0; + else + return 1; } -void codec_list_init (GQueue **queue) { +void codec_list_init (GQueue **queue) +{ - // Create the queue object that will contain the audio codecs - *queue = g_queue_new(); + // Create the queue object that will contain the audio codecs + *queue = g_queue_new(); } -void codec_capabilities_load (void) { +void codec_capabilities_load (void) +{ - gchar **codecs = NULL, **pl = NULL, **specs = NULL; - guint payload; + gchar **codecs = NULL, **pl = NULL, **specs = NULL; + guint payload; - // Create the queue object that will contain the global list of audio codecs - if (codecsCapabilities != NULL) - g_queue_free (codecsCapabilities); + // Create the queue object that will contain the global list of audio codecs + if (codecsCapabilities != NULL) + g_queue_free (codecsCapabilities); - codecsCapabilities = g_queue_new(); + codecsCapabilities = g_queue_new(); - // This is a global list inherited by all accounts + // This is a global list inherited by all accounts codecs = (gchar**) dbus_codec_list (); - - // Add the codecs in the list - for (pl=codecs; *codecs; codecs++) { - - codec_t *c; - payload = atoi (*codecs); - specs = (gchar **) dbus_codec_details (payload); - codec_create_new_with_specs (payload, specs, TRUE, &c); - g_queue_push_tail (codecsCapabilities, (gpointer*) c); - } - // If we didn't load any codecs, problem ... - if (g_queue_get_length (codecsCapabilities) == 0) { + // Add the codecs in the list + for (pl=codecs; *codecs; codecs++) { - // Error message - ERROR ("No audio codecs found"); - dbus_unregister(getpid()); - exit(0); + codec_t *c; + payload = atoi (*codecs); + specs = (gchar **) dbus_codec_details (payload); + codec_create_new_with_specs (payload, specs, TRUE, &c); + g_queue_push_tail (codecsCapabilities, (gpointer*) c); } -} -void account_create_codec_list (account_t **acc) { + // If we didn't load any codecs, problem ... + if (g_queue_get_length (codecsCapabilities) == 0) { - gchar **order = NULL; - GQueue *_codecs; + // Error message + ERROR ("No audio codecs found"); + dbus_unregister (getpid()); + exit (0); + } +} - _codecs = (*acc)->codecs; - if (_codecs != NULL) - g_queue_free (_codecs); +void account_create_codec_list (account_t **acc) +{ - _codecs = g_queue_new (); - // _codecs = g_queue_copy (codecsCapabilities); + GQueue *_codecs; - (*acc)->codecs = _codecs; - // order = (gchar**) dbus_get_active_codec_list (acc->accountID); -} + _codecs = (*acc)->codecs; -void account_set_codec_list (account_t **acc) { + if (_codecs != NULL) + g_queue_free (_codecs); - // Reset the codec list - // account_create_codec_list (a); + _codecs = g_queue_new (); + (*acc)->codecs = _codecs; } -void codec_create_new (gint payload, gboolean active, codec_t **c) { +void codec_create_new (gint payload, gboolean active, codec_t **c) +{ - codec_t *codec; - gchar **specs; + codec_t *codec; + gchar **specs; - codec = g_new0 (codec_t, 1); - codec->_payload = payload; + codec = g_new0 (codec_t, 1); + codec->_payload = payload; specs = (gchar **) dbus_codec_details (payload); - codec->name = specs[0]; - codec->sample_rate = atoi (specs[1]); - codec->_bitrate = atoi (specs[2]); - codec->_bandwidth = atoi (specs[3]); - codec->is_active = active; + codec->name = specs[0]; + codec->sample_rate = atoi (specs[1]); + codec->_bitrate = atoi (specs[2]); + codec->_bandwidth = atoi (specs[3]); + codec->is_active = active; - *c = codec; + *c = codec; } -void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, codec_t **c) { +void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, codec_t **c) +{ - codec_t *codec; + codec_t *codec; - codec = g_new0 (codec_t, 1); - codec->_payload = payload; - codec->name = specs[0]; - codec->sample_rate = atoi (specs[1]); - codec->_bitrate = atoi (specs[2]); - codec->_bandwidth = atoi (specs[3]); - codec->is_active = active; + codec = g_new0 (codec_t, 1); + codec->_payload = payload; + codec->name = specs[0]; + codec->sample_rate = atoi (specs[1]); + codec->_bitrate = atoi (specs[2]); + codec->_bandwidth = atoi (specs[3]); + codec->is_active = active; - *c = codec; + *c = codec; } -void codec_create_new_from_caps (codec_t *original, codec_t **copy) { +void codec_create_new_from_caps (codec_t *original, codec_t **copy) +{ - codec_t *codec; + codec_t *codec; - if(!original) { - *copy = NULL; - return; - } + if (!original) { + *copy = NULL; + return; + } - codec = g_new0 (codec_t, 1); - codec->_payload = original->_payload; - codec->name = original->name; - codec->sample_rate = original->sample_rate; - codec->_bitrate = original->_bitrate; - codec->_bandwidth = original->_bandwidth; - codec->is_active = original->is_active; + codec = g_new0 (codec_t, 1); + codec->_payload = original->_payload; + codec->name = original->name; + codec->sample_rate = original->sample_rate; + codec->_bitrate = original->_bitrate; + codec->_bandwidth = original->_bandwidth; + codec->is_active = original->is_active; - *copy = codec; + *copy = codec; } -void codec_list_clear (GQueue **queue) { +void codec_list_clear (GQueue **queue) +{ - if (*queue != NULL) - g_queue_free (*queue); + if (*queue != NULL) + g_queue_free (*queue); - *queue = g_queue_new(); + *queue = g_queue_new(); } /*void codec_list_clear (void) { @@ -187,162 +188,174 @@ void codec_list_clear (GQueue **queue) { codecsCapabilities = g_queue_new(); }*/ -void codec_list_add(codec_t * c, GQueue **queue) { +void codec_list_add (codec_t * c, GQueue **queue) +{ - // Add a codec to a specific list - g_queue_push_tail (*queue, (gpointer *) c); + // Add a codec to a specific list + g_queue_push_tail (*queue, (gpointer *) c); } -void codec_set_active (codec_t **c) { +void codec_set_active (codec_t **c) +{ - if(c) - { - DEBUG("%s set active", (*c)->name); - (*c)->is_active = TRUE; - } + if (c) { + DEBUG ("%s set active", (*c)->name); + (*c)->is_active = TRUE; + } } -void codec_set_inactive (codec_t **c) { +void codec_set_inactive (codec_t **c) +{ - if(c){ - DEBUG("%s set active", (*c)->name); - (*c)->is_active = FALSE; - } + if (c) { + DEBUG ("%s set active", (*c)->name); + (*c)->is_active = FALSE; + } } -guint codec_list_get_size () { +guint codec_list_get_size () +{ - // The system wide codec list and the one per account have exactly the same size - // The only difference may be the order and the enabled codecs - return g_queue_get_length (codecsCapabilities); + // The system wide codec list and the one per account have exactly the same size + // The only difference may be the order and the enabled codecs + return g_queue_get_length (codecsCapabilities); } -codec_t* codec_list_get_by_name (gconstpointer name, GQueue *q) { +codec_t* codec_list_get_by_name (gconstpointer name, GQueue *q) +{ + + // If NULL is passed as argument, we look into the global capabilities + if (q == NULL) + q = codecsCapabilities; - // If NULL is passed as argument, we look into the global capabilities - if (q == NULL) - q = codecsCapabilities; + GList * c = g_queue_find_custom (q, name, is_name_codecstruct); - GList * c = g_queue_find_custom (q, name, is_name_codecstruct); - if(c) - return (codec_t *)c->data; - else - return NULL; + if (c) + return (codec_t *) c->data; + else + return NULL; } -codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q) { +codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q) +{ + + // If NULL is passed as argument, we look into the global capabilities + if (q == NULL) + q = codecsCapabilities; - // If NULL is passed as argument, we look into the global capabilities - if (q == NULL) - q = codecsCapabilities; + GList * c = g_queue_find_custom (q, payload, is_payload_codecstruct); - GList * c = g_queue_find_custom (q, payload, is_payload_codecstruct); - if(c) - return (codec_t *)c->data; - else - return NULL; + if (c) + return (codec_t *) c->data; + else + return NULL; } -codec_t* codec_list_get_nth (guint index, GQueue *q) { - return g_queue_peek_nth (q, index); +codec_t* codec_list_get_nth (guint index, GQueue *q) +{ + return g_queue_peek_nth (q, index); } -codec_t* capabilities_get_nth (guint index) { +codec_t* capabilities_get_nth (guint index) +{ - return g_queue_peek_nth (codecsCapabilities, index); + return g_queue_peek_nth (codecsCapabilities, index); } -void codec_set_prefered_order (guint index, GQueue *q) { +void codec_set_prefered_order (guint index, GQueue *q) +{ - codec_t * prefered = codec_list_get_nth (index, q); - g_queue_pop_nth (q, index); - g_queue_push_head (q, prefered); + codec_t * prefered = codec_list_get_nth (index, q); + g_queue_pop_nth (q, index); + g_queue_push_head (q, prefered); } -void codec_list_move_codec_up (guint index, GQueue **q) { +void codec_list_move_codec_up (guint index, GQueue **q) +{ - DEBUG("Codec list Size: %i \n", codec_list_get_size ()); + DEBUG ("Codec list Size: %i \n", codec_list_get_size ()); - GQueue *tmp = *q; + GQueue *tmp = *q; - if (index != 0) - { - gpointer codec = g_queue_pop_nth (tmp, index); - g_queue_push_nth (tmp, codec, index-1); - } + if (index != 0) { + gpointer codec = g_queue_pop_nth (tmp, index); + g_queue_push_nth (tmp, codec, index-1); + } - *q = tmp; + *q = tmp; } -void codec_list_move_codec_down (guint index, GQueue **q) { +void codec_list_move_codec_down (guint index, GQueue **q) +{ - DEBUG("Codec list Size: %i \n",codec_list_get_size()); + DEBUG ("Codec list Size: %i \n",codec_list_get_size()); - GQueue *tmp = *q; + GQueue *tmp = *q; - if (index != tmp->length) - { - gpointer codec = g_queue_pop_nth (tmp, index); - g_queue_push_nth (tmp, codec, index+1); - } - - *q = tmp; + if (index != tmp->length) { + gpointer codec = g_queue_pop_nth (tmp, index); + g_queue_push_nth (tmp, codec, index+1); + } + + *q = tmp; } -void codec_list_update_to_daemon (account_t *acc) { - - // String listing codecs payloads - const gchar** codecList; - - // Length of the codec list - int length = acc->codecs->length; - - // Initiate double array char list for one string - codecList = (void*)malloc(sizeof(void*)); - - // Get all codecs in queue - int c = 0; - unsigned int i = 0; - - for(i = 0; i < length; i++) - { - codec_t* currentCodec = codec_list_get_nth (i, acc->codecs); - // Assert not null - if(currentCodec) - { - // Save only if active - if(currentCodec->is_active) - { - // Reallocate memory each time more than one active codec is found - if(c!=0) - codecList = (void*)realloc(codecList, (c+1)*sizeof(void*)); - // Allocate memory for the payload - *(codecList+c) = (gchar*)malloc(sizeof(gchar*)); - char payload[10]; - // Put payload string in char array - sprintf(payload, "%d", currentCodec->_payload); - strcpy((char*)*(codecList+c), payload); - c++; - } - } - } - - // Allocate NULL array at the end for Dbus - codecList = (void*)realloc(codecList, (c+1)*sizeof(void*)); - *(codecList+c) = NULL; - - // call dbus function with array of strings - dbus_set_active_codec_list (codecList, acc->accountID); - - // Delete memory - for(i = 0; i < c; i++) { - free((gchar*)*(codecList+i)); - } - free(codecList); +void codec_list_update_to_daemon (account_t *acc) +{ + + // String listing codecs payloads + const gchar** codecList; + + // Length of the codec list + int length = acc->codecs->length; + + // Initiate double array char list for one string + codecList = (void*) malloc (sizeof (void*)); + + // Get all codecs in queue + int c = 0; + int i = 0; + + for (i = 0; i < length; i++) { + codec_t* currentCodec = codec_list_get_nth (i, acc->codecs); + + // Assert not null + if (currentCodec) { + // Save only if active + if (currentCodec->is_active) { + // Reallocate memory each time more than one active codec is found + if (c!=0) + codecList = (void*) realloc (codecList, (c+1) *sizeof (void*)); + + // Allocate memory for the payload + * (codecList+c) = (gchar*) malloc (sizeof (gchar*)); + char payload[10]; + // Put payload string in char array + sprintf (payload, "%d", currentCodec->_payload); + strcpy ( (char*) * (codecList+c), payload); + c++; + } + } + } + + // Allocate NULL array at the end for Dbus + codecList = (void*) realloc (codecList, (c+1) *sizeof (void*)); + * (codecList+c) = NULL; + + // call dbus function with array of strings + dbus_set_active_codec_list (codecList, acc->accountID); + + // Delete memory + for (i = 0; i < c; i++) { + free ( (gchar*) * (codecList+i)); + } + + free (codecList); } -GQueue* get_system_codec_list (void) { - return codecsCapabilities; +GQueue* get_system_codec_list (void) +{ + return codecsCapabilities; } diff --git a/sflphone-client-gnome/src/codeclist.h b/sflphone-client-gnome/src/codeclist.h index 0737f3853d10c77bb22bdca2efdb5cac89113bf6..253067a8df71f8fb3ad5cda7e697b8019ff15ec0 100644 --- a/sflphone-client-gnome/src/codeclist.h +++ b/sflphone-client-gnome/src/codeclist.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.net> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -38,19 +38,19 @@ */ typedef struct { - /** Payload of the codec */ - gint _payload; - /** Tells if the codec has been activated */ - gboolean is_active; - /** String description */ - gchar * name; - /** Sample rate */ - int sample_rate; - /** Bitrate */ - gdouble _bitrate; - /** Bandwidth */ - gdouble _bandwidth; -}codec_t; + /** Payload of the codec */ + gint _payload; + /** Tells if the codec has been activated */ + gboolean is_active; + /** String description */ + gchar * name; + /** Sample rate */ + int sample_rate; + /** Bitrate */ + gdouble _bitrate; + /** Bandwidth */ + gdouble _bandwidth; +} codec_t; /** @struct codec_t * @brief Codec information. @@ -58,29 +58,29 @@ typedef struct { * This match how the server internally works and the dbus API to save and retrieve the codecs details. */ -/** - * This function initialize a specific codec list. +/** + * This function initialize a specific codec list. */ void codec_list_init (GQueue **q); -/** - * This function initialize the system wide codec list. +/** + * This function initialize the system wide codec list. */ void codec_capabilities_load (void); -/** - * This function empty and free a specific codec list. +/** + * This function empty and free a specific codec list. */ void codec_list_clear (GQueue **q); -/** - * This function empty and free the system wide codec list. +/** + * This function empty and free the system wide codec list. */ void system_codec_list_clear (void); -/** - * This function append an codec to list. - * @param c The codec you want to add +/** + * This function append an codec to list. + * @param c The codec you want to add */ void codec_list_add (codec_t * c, GQueue **q); @@ -94,25 +94,25 @@ void codec_set_active (codec_t **c); * Set a codec inactive. An active codec won't be used for codec negociation * @param name The string description of the codec */ -void codec_set_inactive(codec_t **c); +void codec_set_inactive (codec_t **c); -/** +/** * Return the number of codecs in the list - * @return guint The number of codecs in the list + * @return guint The number of codecs in the list */ guint codec_list_get_size(); -/** - * Return the codec structure that corresponds to the string description +/** + * Return the codec structure that corresponds to the string description * @param name The string description of the codec - * @return codec_t* A codec or NULL + * @return codec_t* A codec or NULL */ -codec_t * codec_list_get_by_name(gconstpointer name, GQueue *q); +codec_t * codec_list_get_by_name (gconstpointer name, GQueue *q); -/** +/** * Return the codec at the nth position in the list * @param index The position of the codec you want - * @return codec_t* A codec or NULL + * @return codec_t* A codec or NULL */ codec_t* codec_list_get_nth (guint index, GQueue *q); codec_t* capabilities_get_nth (guint index); @@ -120,16 +120,16 @@ codec_t* capabilities_get_nth (guint index); /** * Set the prefered codec first in the codec list * @param index The position in the list of the prefered codec - */ + */ void codec_set_prefered_order (guint index, GQueue *q); -/** +/** * Move the codec from an unit up in the codec_list * @param index The current index in the list */ void codec_list_move_codec_up (guint index, GQueue **q); -/** +/** * Move the codec from an unit down in the codec_list * @param index The current index in the list */ @@ -145,7 +145,7 @@ codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q); GQueue* get_system_codec_list (void); /** - * Instanciate a new codecs with the given payload. + * Instanciate a new codecs with the given payload. * Fetches codec specification through D-Bus * * @param payload The unique RTP payload diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c index 3b534e079ab6d5c9e53e8615b254ebdb444b1fa5..680a784b0f9e979f9ed07aa6ba532461b8bec5d6 100644 --- a/sflphone-client-gnome/src/conference_obj.c +++ b/sflphone-client-gnome/src/conference_obj.c @@ -32,22 +32,20 @@ #include <sflphone_const.h> #include <time.h> -gint is_confID_confstruct ( gconstpointer a, gconstpointer b) +gint is_confID_confstruct (gconstpointer a, gconstpointer b) { - conference_obj_t * c = (conference_obj_t*)a; - if(g_strcasecmp(c->_confID, (const gchar*) b) == 0) - { + conference_obj_t * c = (conference_obj_t*) a; + + if (g_strcasecmp (c->_confID, (const gchar*) b) == 0) { return 0; - } - else - { + } else { return 1; } } -conference_obj_t* create_new_conference (conference_state_t state, const gchar* confID, conference_obj_t ** conf) +void create_new_conference (conference_state_t state, const gchar* confID, conference_obj_t ** conf) { - DEBUG("create_new_conference"); + DEBUG ("create_new_conference"); // conference_obj_t *obj; conference_obj_t *new_conf; @@ -56,7 +54,7 @@ conference_obj_t* create_new_conference (conference_state_t state, const gchar* // Allocate memory new_conf = g_new0 (conference_obj_t, 1); - // Set state field + // Set state field new_conf->_state = state; // Set the ID field @@ -66,17 +64,14 @@ conference_obj_t* create_new_conference (conference_state_t state, const gchar* new_conf->participant_list = NULL; *conf = new_conf; - } -conference_obj_t* create_new_conference_from_details (const gchar *conf_id, GHashTable *details, conference_obj_t ** conf) -{ - DEBUG("create_new_conference_from_details"); +void create_new_conference_from_details (const gchar *conf_id, GHashTable *details, conference_obj_t ** conf) +{ + DEBUG ("create_new_conference_from_details"); conference_obj_t *new_conf; - gchar* call_id; gchar** participants; - gchar** part; gchar* state_str; // GSList* participant_list; @@ -91,11 +86,11 @@ conference_obj_t* create_new_conference_from_details (const gchar *conf_id, GHas new_conf->participant_list = NULL; // get participant list - participants = dbus_get_participant_list(conf_id); + participants = dbus_get_participant_list (conf_id); // generate conference participant list - conference_participant_list_update(participants, new_conf); - + conference_participant_list_update (participants, new_conf); + state_str = g_hash_table_lookup (details, "CONF_STATE"); if (g_strcasecmp (state_str, "ACTIVE_ATACHED") == 0) @@ -114,49 +109,49 @@ void free_conference_obj_t (conference_obj_t *c) { g_free (c->_confID); - if(c->participant_list) + if (c->participant_list) g_slist_free (c->participant_list); g_free (c); } -void conference_add_participant(const gchar* call_id, conference_obj_t* conf) +void conference_add_participant (const gchar* call_id, conference_obj_t* conf) { // store the new participant list after appending participant id - conf->participant_list = g_slist_append(conf->participant_list, (gpointer)call_id); + conf->participant_list = g_slist_append (conf->participant_list, (gpointer) call_id); } -void conference_remove_participant(const gchar* call_id, conference_obj_t* conf) +void conference_remove_participant (const gchar* call_id, conference_obj_t* conf) { // store the new participant list after removing participant id - conf->participant_list = g_slist_remove(conf->participant_list, (gconstpointer)call_id); + conf->participant_list = g_slist_remove (conf->participant_list, (gconstpointer) call_id); } -GSList* conference_next_participant(GSList* participant) +GSList* conference_next_participant (GSList* participant) { - return g_slist_next(participant); + return g_slist_next (participant); } -GSList* conference_participant_list_update(gchar** participants, conference_obj_t* conf) +void conference_participant_list_update (gchar** participants, conference_obj_t* conf) { gchar* call_id; gchar** part; - if(conf->participant_list) { - g_slist_free(conf->participant_list); - conf->participant_list = NULL; + if (conf->participant_list) { + g_slist_free (conf->participant_list); + conf->participant_list = NULL; } - DEBUG("Conference: Participant list update"); + DEBUG ("Conference: Participant list update"); for (part = participants; *part; part++) { - call_id = (gchar*)(*part); - DEBUG("Adding %s", call_id); - conference_add_participant(call_id, conf); + call_id = (gchar*) (*part); + DEBUG ("Adding %s", call_id); + conference_add_participant (call_id, conf); } } diff --git a/sflphone-client-gnome/src/conference_obj.h b/sflphone-client-gnome/src/conference_obj.h index 5215ee7bd5aebbc9bea181e6fb622a34b42c6a55..edec21a7880ae38ad207da00753756949ff0c654 100644 --- a/sflphone-client-gnome/src/conference_obj.h +++ b/sflphone-client-gnome/src/conference_obj.h @@ -41,12 +41,11 @@ /** @enum conference_state_t * This enum have all the states a conference can take. */ -typedef enum -{ - CONFERENCE_STATE_ACTIVE_ATACHED = 0, - CONFERENCE_STATE_ACTIVE_DETACHED, - CONFERENCE_STATE_RECORD, - CONFERENCE_STATE_HOLD +typedef enum { + CONFERENCE_STATE_ACTIVE_ATACHED = 0, + CONFERENCE_STATE_ACTIVE_DETACHED, + CONFERENCE_STATE_RECORD, + CONFERENCE_STATE_HOLD } conference_state_t; @@ -60,27 +59,27 @@ typedef struct { gchar* _confID; // The call ID gboolean _conference_secured; // the security state of the conference gboolean _conf_srtp_enabled; // security required for this conference - GSList* participant_list; // participant list for this + GSList* participant_list; // participant list for this } conference_obj_t; -conference_obj_t* create_new_conference (conference_state_t, const gchar*, conference_obj_t **); +void create_new_conference (conference_state_t, const gchar*, conference_obj_t **); -conference_obj_t* create_new_conference_from_details (const gchar *, GHashTable *, conference_obj_t **); +void create_new_conference_from_details (const gchar *, GHashTable *, conference_obj_t **); void free_conference_obj_t (conference_obj_t *c); -/* - * GCompareFunc to compare a confID (gchar* and a callable_obj_t) +/* + * GCompareFunc to compare a confID (gchar* and a callable_obj_t) */ -gint is_confID_confstruct ( gconstpointer, gconstpointer); +gint is_confID_confstruct (gconstpointer, gconstpointer); -void conference_add_participatn(const gchar*, conference_obj_t *); +void conference_add_participatn (const gchar*, conference_obj_t *); -void conference_remove_participant(const gchar*, conference_obj_t *); +void conference_remove_participant (const gchar*, conference_obj_t *); -GSList* conference_next_participant(GSList* participant); +GSList* conference_next_participant (GSList* participant); -GSList* conference_participant_list_update(gchar**, conference_obj_t*); +void conference_participant_list_update (gchar**, conference_obj_t*); #endif diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 106671dcce4ad04d7e61773d48d607e0b45fde10..9deb3ebea4940eb087eb46bc826ef9fa42e77cc0 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -58,7 +58,7 @@ * TODO: tidy this up * by storing these variables * in a private structure. - * Local variables + * Local variables */ GtkDialog * dialog; GtkWidget * hbox; @@ -115,1278 +115,1258 @@ gchar *current_username; // Credentials enum { - COLUMN_CREDENTIAL_REALM, - COLUMN_CREDENTIAL_USERNAME, - COLUMN_CREDENTIAL_PASSWORD, - COLUMN_CREDENTIAL_DATA, - COLUMN_CREDENTIAL_COUNT + COLUMN_CREDENTIAL_REALM, + COLUMN_CREDENTIAL_USERNAME, + COLUMN_CREDENTIAL_PASSWORD, + COLUMN_CREDENTIAL_DATA, + COLUMN_CREDENTIAL_COUNT }; +/* + * The same window is used with different configurations + * so we need to reset some data to prevent side-effects + */ +static void reset() +{ + entryAlias = NULL; + protocolComboBox = NULL; + entryHostname = NULL; + entryUsername = NULL; + entryPassword = NULL; + entryUseragent = NULL; + entryMailbox = NULL; +} + /* * Display / Hide the password */ -static void show_password_cb (GtkWidget *widget, gpointer data) +static void show_password_cb (GtkWidget *widget UNUSED, gpointer data) { - gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data))); + gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data))); } /* Signal to protocolComboBox 'changed' */ -void change_protocol_cb (account_t *currentAccount UNUSED) { - - gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox)); - - // Only if tabs are not NULL - if(security_tab && advanced_tab) { - if (g_strcasecmp (protocol, "IAX") == 0) { - gtk_widget_hide (GTK_WIDGET(security_tab)); - gtk_widget_hide (GTK_WIDGET(advanced_tab)); - } - else { - gtk_widget_show (GTK_WIDGET(security_tab)); - gtk_widget_show (GTK_WIDGET(advanced_tab)); - } - } +void change_protocol_cb (account_t *currentAccount UNUSED) +{ + + gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox)); + + // Only if tabs are not NULL + if (security_tab && advanced_tab) { + if (g_strcasecmp (protocol, "IAX") == 0) { + gtk_widget_hide (GTK_WIDGET (security_tab)); + gtk_widget_hide (GTK_WIDGET (advanced_tab)); + } else { + gtk_widget_show (GTK_WIDGET (security_tab)); + gtk_widget_show (GTK_WIDGET (advanced_tab)); + } + } } - int -is_iax_enabled(void) +int +is_iax_enabled (void) { - int res = dbus_is_iax2_enabled(); - if(res == 1) - return TRUE; - else - return FALSE; + int res = dbus_is_iax2_enabled(); + + if (res == 1) + return TRUE; + else + return FALSE; } - void -select_dtmf_type( void ) +void +select_dtmf_type (void) { - DEBUG("DTMF selection changed\n"); + DEBUG ("DTMF selection changed\n"); - if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(overrtp) ) ) - { - // dbus_set_audio_manager( ALSA ); - DEBUG("Selected DTMF over RTP"); - } - else { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (overrtp))) { + // dbus_set_audio_manager( ALSA ); + DEBUG ("Selected DTMF over RTP"); + } else { - // dbus_set_audio_manager( PULSEAUDIO ); - DEBUG("Selected DTMF over SIP"); - } + // dbus_set_audio_manager( PULSEAUDIO ); + DEBUG ("Selected DTMF over SIP"); + } } -static GPtrArray* getNewCredential (GHashTable * properties) { +static GPtrArray* getNewCredential (GHashTable * properties) +{ + + GtkTreeIter iter; + gboolean valid; + gint row_count = 0; + + valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (credentialStore), &iter); - GtkTreeIter iter; - gboolean valid; - gint row_count = 0; + GPtrArray *credential_array = g_ptr_array_new (); - valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(credentialStore), &iter); + gchar *username; + gchar *realm; + gchar *password; + GHashTable * new_table; - GPtrArray *credential_array = g_ptr_array_new (); + if (valid == FALSE) { + DEBUG ("Gtk tree model iter is not valid"); + return NULL; + } + + gtk_tree_model_get (GTK_TREE_MODEL (credentialStore), &iter, + COLUMN_CREDENTIAL_REALM, &realm, + COLUMN_CREDENTIAL_USERNAME, &username, + COLUMN_CREDENTIAL_PASSWORD, &password, + -1); - gchar *username; - gchar *realm; - gchar *password; - GHashTable * new_table; + g_hash_table_insert (properties, g_strdup (ACCOUNT_REALM), realm); - if(valid == FALSE) { - DEBUG("Gtk tree model iter is not valid"); - return NULL; - } + // better use the current_username as it is the account username in the + // g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username); + g_hash_table_insert (properties, g_strdup (ACCOUNT_AUTHENTICATION_USERNAME), current_username); - gtk_tree_model_get (GTK_TREE_MODEL(credentialStore), &iter, - COLUMN_CREDENTIAL_REALM, &realm, - COLUMN_CREDENTIAL_USERNAME, &username, - COLUMN_CREDENTIAL_PASSWORD, &password, - -1); + // Do not change the password if nothing has been changed by the user + if (g_strcasecmp (password, PW_HIDDEN) != 0) + g_hash_table_insert (properties, g_strdup (ACCOUNT_PASSWORD), password); - g_hash_table_insert(properties, g_strdup(ACCOUNT_REALM), realm); + valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (credentialStore), &iter); - // better use the current_username as it is the account username in the - // g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username); - g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), current_username); - - // Do not change the password if nothing has been changed by the user - if (g_strcasecmp (password, PW_HIDDEN) != 0) - g_hash_table_insert(properties, g_strdup(ACCOUNT_PASSWORD), password); + while (valid) { + gtk_tree_model_get (GTK_TREE_MODEL (credentialStore), &iter, + COLUMN_CREDENTIAL_REALM, &realm, + COLUMN_CREDENTIAL_USERNAME, &username, + COLUMN_CREDENTIAL_PASSWORD, &password, + -1); - valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter); - - while (valid) { - gtk_tree_model_get (GTK_TREE_MODEL(credentialStore), &iter, - COLUMN_CREDENTIAL_REALM, &realm, - COLUMN_CREDENTIAL_USERNAME, &username, - COLUMN_CREDENTIAL_PASSWORD, &password, - -1); + DEBUG ("Row %d: %s %s %s", row_count, username, password, realm); - DEBUG ("Row %d: %s %s %s", row_count, username, password, realm); + new_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + g_hash_table_insert (new_table, g_strdup (ACCOUNT_REALM), realm); + g_hash_table_insert (new_table, g_strdup (ACCOUNT_USERNAME), username); + g_hash_table_insert (new_table, g_strdup (ACCOUNT_PASSWORD), password); - new_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - g_hash_table_insert(new_table, g_strdup(ACCOUNT_REALM), realm); - g_hash_table_insert(new_table, g_strdup(ACCOUNT_USERNAME), username); - g_hash_table_insert(new_table, g_strdup(ACCOUNT_PASSWORD), password); + g_ptr_array_add (credential_array, new_table); - g_ptr_array_add (credential_array, new_table); - - row_count ++; + row_count ++; - valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter); - } + valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (credentialStore), &iter); + } - return credential_array; + return credential_array; } -static void update_credential_cb(GtkWidget *widget, gpointer data UNUSED) +static void update_credential_cb (GtkWidget *widget, gpointer data UNUSED) { - GtkTreeIter iter; - gtk_tree_model_get_iter_from_string ((GtkTreeModel *) credentialStore, &iter, "0"); - gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "column")); - // g_print ("set password to %s\n", (gchar *) gtk_entry_get_text(GTK_ENTRY(widget))); - gtk_list_store_set (GTK_LIST_STORE (credentialStore), &iter, column, (gchar *) gtk_entry_get_text(GTK_ENTRY(widget)), -1); + GtkTreeIter iter; + gtk_tree_model_get_iter_from_string ( (GtkTreeModel *) credentialStore, &iter, "0"); + gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "column")); + // g_print ("set password to %s\n", (gchar *) gtk_entry_get_text(GTK_ENTRY(widget))); + gtk_list_store_set (GTK_LIST_STORE (credentialStore), &iter, column, (gchar *) gtk_entry_get_text (GTK_ENTRY (widget)), -1); } -static GtkWidget* create_basic_tab (account_t **a) { +static GtkWidget* create_basic_tab (account_t **a) +{ - GtkWidget * frame; - GtkWidget * table; - account_t *currentAccount; - GtkWidget * clearTextCheckbox; + GtkWidget * frame; + GtkWidget * table; + account_t *currentAccount; + GtkWidget * clearTextCheckbox; #if GTK_CHECK_VERSION(2,16,0) #else - GtkWidget *image; + GtkWidget *image; #endif - // Default settings - gchar *curAccountID = ""; - gchar *curAccountEnabled = "true"; - gchar *curAccountType = "SIP"; - gchar *curAlias = ""; - gchar *curUsername = ""; - gchar *curRouteSet = ""; - gchar *curHostname = ""; - gchar *curPassword = ""; - /* TODO: add curProxy, and add boxes for Proxy support */ - gchar *curMailbox = ""; - gchar *curUseragent = ""; - - currentAccount = *a; - - int row = 0; - - DEBUG("Config: Create basic account tab"); - - // Load from SIP/IAX/Unknown ? - if(currentAccount) - { - curAccountID = currentAccount->accountID; - curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE); - curAccountEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED); - curAlias = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ALIAS); - curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME); - curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD); - curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME); - // curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE); - curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX); - curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT); - } - - gnome_main_section_new (_("Account Parameters"), &frame); - gtk_widget_show(frame); - - if(strcmp(curAccountType, "SIP") == 0) { - table = gtk_table_new (9, 2, FALSE/* homogeneous */); - } - else if(strcmp(curAccountType, "IAX") == 0) { - table = gtk_table_new (8, 2, FALSE); - } - - gtk_table_set_row_spacings( GTK_TABLE(table), 10); - gtk_table_set_col_spacings( GTK_TABLE(table), 10); - gtk_widget_show (table); - gtk_container_add( GTK_CONTAINER( frame) , table ); - - label = gtk_label_new_with_mnemonic (_("_Alias")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - entryAlias = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryAlias); - gtk_entry_set_text(GTK_ENTRY(entryAlias), curAlias); - gtk_table_attach ( GTK_TABLE( table ), entryAlias, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - - row++; - label = gtk_label_new_with_mnemonic (_("_Protocol")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - protocolComboBox = gtk_combo_box_new_text(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), protocolComboBox); - gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), "SIP"); - if( is_iax_enabled() ) gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), "IAX"); - if(strcmp(curAccountType, "SIP") == 0) - { - gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),0); - } - else if(strcmp(curAccountType, "IAX") == 0) - { - gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),1); - } - else - { - DEBUG("Config: Error: Account protocol not valid"); - /* Should never come here, add debug message. */ - gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), _("Unknown")); - gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),2); - } - gtk_table_attach ( GTK_TABLE( table ), protocolComboBox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - /* Link signal 'changed' */ - g_signal_connect (G_OBJECT (GTK_COMBO_BOX(protocolComboBox)), "changed", - G_CALLBACK (change_protocol_cb), - currentAccount); - - row++; - label = gtk_label_new_with_mnemonic (_("_Host name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - entryHostname = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryHostname); - gtk_entry_set_text(GTK_ENTRY(entryHostname), curHostname); - gtk_table_attach ( GTK_TABLE( table ), entryHostname, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - row++; - label = gtk_label_new_with_mnemonic (_("_User name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); + // Default settings + gchar *curAccountID = ""; + gchar *curAccountEnabled = "true"; + gchar *curAccountType = "SIP"; + gchar *curAlias = ""; + gchar *curUsername = ""; + gchar *curHostname = ""; + gchar *curPassword = ""; + /* TODO: add curProxy, and add boxes for Proxy support */ + gchar *curMailbox = ""; + gchar *curUseragent = ""; + + currentAccount = *a; + + int row = 0; + + DEBUG ("Config: Create basic account tab"); + + // Load from SIP/IAX/Unknown ? + if (currentAccount) { + curAccountID = currentAccount->accountID; + curAccountType = g_hash_table_lookup (currentAccount->properties, ACCOUNT_TYPE); + curAccountEnabled = g_hash_table_lookup (currentAccount->properties, ACCOUNT_ENABLED); + curAlias = g_hash_table_lookup (currentAccount->properties, ACCOUNT_ALIAS); + curHostname = g_hash_table_lookup (currentAccount->properties, ACCOUNT_HOSTNAME); + curPassword = g_hash_table_lookup (currentAccount->properties, ACCOUNT_PASSWORD); + curUsername = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERNAME); + // curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE); + curMailbox = g_hash_table_lookup (currentAccount->properties, ACCOUNT_MAILBOX); + curMailbox = curMailbox != NULL ? curMailbox : ""; + curUseragent = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERAGENT); + } + + gnome_main_section_new (_ ("Account Parameters"), &frame); + gtk_widget_show (frame); + + if (strcmp (curAccountType, "SIP") == 0) { + table = gtk_table_new (9, 2, FALSE/* homogeneous */); + } else if (strcmp (curAccountType, "IAX") == 0) { + table = gtk_table_new (8, 2, FALSE); + } + + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_widget_show (table); + gtk_container_add (GTK_CONTAINER (frame) , table); + + label = gtk_label_new_with_mnemonic (_ ("_Alias")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + entryAlias = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryAlias); + gtk_entry_set_text (GTK_ENTRY (entryAlias), curAlias); + gtk_table_attach (GTK_TABLE (table), entryAlias, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + + row++; + label = gtk_label_new_with_mnemonic (_ ("_Protocol")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + protocolComboBox = gtk_combo_box_new_text(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), protocolComboBox); + gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), "SIP"); + + if (is_iax_enabled()) gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), "IAX"); + + if (strcmp (curAccountType, "SIP") == 0) { + gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),0); + } else if (strcmp (curAccountType, "IAX") == 0) { + gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),1); + } else { + DEBUG ("Config: Error: Account protocol not valid"); + /* Should never come here, add debug message. */ + gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), _ ("Unknown")); + gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),2); + } + + gtk_table_attach (GTK_TABLE (table), protocolComboBox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + /* Link signal 'changed' */ + g_signal_connect (G_OBJECT (GTK_COMBO_BOX (protocolComboBox)), "changed", + G_CALLBACK (change_protocol_cb), + currentAccount); + + row++; + label = gtk_label_new_with_mnemonic (_ ("_Host name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + entryHostname = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryHostname); + gtk_entry_set_text (GTK_ENTRY (entryHostname), curHostname); + gtk_table_attach (GTK_TABLE (table), entryHostname, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + row++; + label = gtk_label_new_with_mnemonic (_ ("_User name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - entryUsername = gtk_entry_new(); - gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entryUsername), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL)); + entryUsername = gtk_entry_new(); + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entryUsername), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL)); #else - entryUsername = sexy_icon_entry_new(); - image = gtk_image_new_from_file( ICONS_DIR "/stock_person.svg" ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(entryUsername), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + entryUsername = sexy_icon_entry_new(); + image = gtk_image_new_from_file (ICONS_DIR "/stock_person.svg"); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (entryUsername), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername); - gtk_entry_set_text(GTK_ENTRY(entryUsername), curUsername); - gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - if(strcmp(curAccountType, "SIP") == 0) { - g_signal_connect(G_OBJECT (entryUsername), "changed", G_CALLBACK (update_credential_cb), NULL); - g_object_set_data (G_OBJECT (entryUsername), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME)); - } - - // Route set can be update only for SIP account - // TODO: uncomment this code and implement route - /* - if(strcmp(curAccountType, "SIP") == 0) { - row++; - label = gtk_label_new_with_mnemonic(_("_Route (optional)")); - gtk_table_attach(GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - entryRouteSet = gtk_entry_new(); - gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryRouteSet); - gtk_entry_set_text(GTK_ENTRY(entryRouteSet), curRouteSet); - gtk_table_attach (GTK_TABLE(table), entryRouteSet, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - } - */ - - row++; - label = gtk_label_new_with_mnemonic (_("_Password")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername); + gtk_entry_set_text (GTK_ENTRY (entryUsername), curUsername); + gtk_table_attach (GTK_TABLE (table), entryUsername, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + if (strcmp (curAccountType, "SIP") == 0) { + g_signal_connect (G_OBJECT (entryUsername), "changed", G_CALLBACK (update_credential_cb), NULL); + g_object_set_data (G_OBJECT (entryUsername), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME)); + } + + row++; + label = gtk_label_new_with_mnemonic (_ ("_Password")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - entryPassword = gtk_entry_new(); - GtkSettings *settings = gtk_settings_get_default (); - //g_object_set (G_OBJECT (settings), "gtk-entry-password-hint-timeout", 600, NULL); - gtk_entry_set_icon_from_stock (GTK_ENTRY (entryPassword), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); + entryPassword = gtk_entry_new(); + gtk_entry_set_icon_from_stock (GTK_ENTRY (entryPassword), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); #else - entryPassword = sexy_icon_entry_new(); - image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(entryPassword), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + entryPassword = sexy_icon_entry_new(); + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (entryPassword), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_entry_set_visibility(GTK_ENTRY(entryPassword), FALSE); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword); - gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword); - gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - if(strcmp(curAccountType, "SIP") == 0) { - g_signal_connect (G_OBJECT (entryPassword), "changed", G_CALLBACK (update_credential_cb), NULL); - g_object_set_data (G_OBJECT (entryPassword), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD)); - } - - row++; - clearTextCheckbox = gtk_check_button_new_with_mnemonic (_("Show password")); - g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), entryPassword); - gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - row++; - label = gtk_label_new_with_mnemonic (_("_Voicemail number")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - entryMailbox = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox); - gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox); - gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - row++; - label = gtk_label_new_with_mnemonic (_("_User-agent")); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - entryUseragent = gtk_entry_new (); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUseragent); - gtk_entry_set_text (GTK_ENTRY (entryUseragent), curUseragent); - gtk_table_attach ( GTK_TABLE( table ), entryUseragent, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - gtk_widget_show_all( table ); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - - *a = currentAccount; - return frame; + gtk_entry_set_visibility (GTK_ENTRY (entryPassword), FALSE); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword); + gtk_entry_set_text (GTK_ENTRY (entryPassword), curPassword); + gtk_table_attach (GTK_TABLE (table), entryPassword, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + if (strcmp (curAccountType, "SIP") == 0) { + g_signal_connect (G_OBJECT (entryPassword), "changed", G_CALLBACK (update_credential_cb), NULL); + g_object_set_data (G_OBJECT (entryPassword), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD)); + } + + row++; + clearTextCheckbox = gtk_check_button_new_with_mnemonic (_ ("Show password")); + g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), entryPassword); + gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + row++; + label = gtk_label_new_with_mnemonic (_ ("_Voicemail number")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + entryMailbox = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox); + gtk_entry_set_text (GTK_ENTRY (entryMailbox), curMailbox); + gtk_table_attach (GTK_TABLE (table), entryMailbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + row++; + label = gtk_label_new_with_mnemonic (_ ("_User-agent")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + entryUseragent = gtk_entry_new (); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUseragent); + gtk_entry_set_text (GTK_ENTRY (entryUseragent), curUseragent); + gtk_table_attach (GTK_TABLE (table), entryUseragent, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + gtk_widget_show_all (table); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + + *a = currentAccount; + return frame; } -static void fill_treeview_with_credential (GtkListStore * credentialStore, account_t * account) +static void fill_treeview_with_credential (GtkListStore * credentialStore, account_t * account) { - GtkTreeIter iter; - gtk_list_store_clear(credentialStore); - - /* This is the default, undeletable credential */ - /* - // gtk_list_store_append (credentialStore, &iter); - gchar * authentication_name = g_hash_table_lookup(account->properties, ACCOUNT_AUTHENTICATION_USERNAME); - gchar * realm = g_hash_table_lookup(account->properties, ACCOUNT_REALM); - if (realm == NULL || (g_strcmp0(realm, "") == 0)) { - realm = g_strdup("*"); - } - - if((authentication_name == NULL) || (g_strcmp0(authentication_name, "") == 0)) { - gtk_list_store_set(credentialStore, &iter, - COLUMN_CREDENTIAL_REALM, realm, - COLUMN_CREDENTIAL_USERNAME, gtk_entry_get_text(GTK_ENTRY(entryUsername)), - COLUMN_CREDENTIAL_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entryPassword)), - COLUMN_CREDENTIAL_DATA, account, - -1); - } else { - gtk_list_store_set(credentialStore, &iter, - COLUMN_CREDENTIAL_REALM, g_hash_table_lookup(account->properties, ACCOUNT_REALM), - COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup(account->properties, ACCOUNT_AUTHENTICATION_USERNAME), - // COLUMN_CREDENTIAL_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entryPassword)), - COLUMN_CREDENTIAL_PASSWORD, PW_HIDDEN, - COLUMN_CREDENTIAL_DATA, account, - -1); - g_signal_handlers_disconnect_by_func (G_OBJECT(entryUsername), G_CALLBACK(update_credential_cb), NULL); - } - - */ - if(account->credential_information == NULL) { - DEBUG("No credential defined"); - return; - } - - unsigned int i; - for(i = 0; i < account->credential_information->len; i++) - { - GHashTable * element = g_ptr_array_index(account->credential_information, i); - gtk_list_store_append (credentialStore, &iter); - gtk_list_store_set(credentialStore, &iter, - COLUMN_CREDENTIAL_REALM, g_hash_table_lookup(element, ACCOUNT_REALM), - COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup(element, ACCOUNT_USERNAME), - COLUMN_CREDENTIAL_PASSWORD, g_hash_table_lookup(element, ACCOUNT_PASSWORD), - COLUMN_CREDENTIAL_DATA, element, -1); - } + GtkTreeIter iter; + gtk_list_store_clear (credentialStore); + + if (account->credential_information == NULL) { + DEBUG ("No credential defined"); + return; + } + + unsigned int i; + + for (i = 0; i < account->credential_information->len; i++) { + GHashTable * element = g_ptr_array_index (account->credential_information, i); + gtk_list_store_append (credentialStore, &iter); + gtk_list_store_set (credentialStore, &iter, + COLUMN_CREDENTIAL_REALM, g_hash_table_lookup (element, ACCOUNT_REALM), + COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup (element, ACCOUNT_USERNAME), + COLUMN_CREDENTIAL_PASSWORD, g_hash_table_lookup (element, ACCOUNT_PASSWORD), + COLUMN_CREDENTIAL_DATA, element, -1); + } } -static select_credential_cb(GtkTreeSelection *selection, GtkTreeModel *model) +static void select_credential_cb (GtkTreeSelection *selection, GtkTreeModel *model) { - GtkTreeIter iter; - GtkTreePath *path; - if(gtk_tree_selection_get_selected (selection, NULL, &iter)) { - path = gtk_tree_model_get_path (model, &iter); - if(gtk_tree_path_get_indices (path)[0] == 0) { - gtk_widget_set_sensitive(GTK_WIDGET(deleteCredButton), FALSE); - } else { - gtk_widget_set_sensitive(GTK_WIDGET(deleteCredButton), TRUE); - } - } + GtkTreeIter iter; + GtkTreePath *path; + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { + path = gtk_tree_model_get_path (model, &iter); + + if (gtk_tree_path_get_indices (path) [0] == 0) { + gtk_widget_set_sensitive (GTK_WIDGET (deleteCredButton), FALSE); + } else { + gtk_widget_set_sensitive (GTK_WIDGET (deleteCredButton), TRUE); + } + } } -static void add_credential_cb (GtkWidget *button, gpointer data) +static void add_credential_cb (GtkWidget *button UNUSED, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model = (GtkTreeModel *)data; - - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COLUMN_CREDENTIAL_REALM, "*", - COLUMN_CREDENTIAL_USERNAME, _("Authentication"), - COLUMN_CREDENTIAL_PASSWORD, _("Secret"), - -1); + GtkTreeIter iter; + GtkTreeModel *model = (GtkTreeModel *) data; + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COLUMN_CREDENTIAL_REALM, "*", + COLUMN_CREDENTIAL_USERNAME, _ ("Authentication"), + COLUMN_CREDENTIAL_PASSWORD, _ ("Secret"), + -1); } -static void delete_credential_cb(GtkWidget *button, gpointer data) +static void delete_credential_cb (GtkWidget *button UNUSED, gpointer data) { - GtkTreeIter iter; - GtkTreeView *treeview = (GtkTreeView *)data; - GtkTreeModel *model = gtk_tree_view_get_model (treeview); - GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); + GtkTreeIter iter; + GtkTreeView *treeview = (GtkTreeView *) data; + GtkTreeModel *model = gtk_tree_view_get_model (treeview); + GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - GtkTreePath *path; - path = gtk_tree_model_get_path (model, &iter); - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { + GtkTreePath *path; + path = gtk_tree_model_get_path (model, &iter); + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - gtk_tree_path_free (path); - } + gtk_tree_path_free (path); + } } -static void cell_edited_cb(GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gpointer data) +static void cell_edited_cb (GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gpointer data) { - GtkTreeModel *model = (GtkTreeModel *)data; - GtkTreePath *path = gtk_tree_path_new_from_string (path_desc); - GtkTreeIter iter; + GtkTreeModel *model = (GtkTreeModel *) data; + GtkTreePath *path = gtk_tree_path_new_from_string (path_desc); + GtkTreeIter iter; - gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "column")); - DEBUG("path desc in cell_edited_cb: %s\n", text); + gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "column")); + DEBUG ("path desc in cell_edited_cb: %s\n", text); - if(g_strcasecmp(path_desc, "0") == 0) { - if(g_strcasecmp(text, gtk_entry_get_text (GTK_ENTRY(entryUsername))) != 0) { - g_signal_handlers_disconnect_by_func (G_OBJECT(entryUsername), G_CALLBACK(update_credential_cb), NULL); - } + if (g_strcasecmp (path_desc, "0") == 0) { + if (g_strcasecmp (text, gtk_entry_get_text (GTK_ENTRY (entryUsername))) != 0) { + g_signal_handlers_disconnect_by_func (G_OBJECT (entryUsername), G_CALLBACK (update_credential_cb), NULL); + } - if (column == COLUMN_CREDENTIAL_PASSWORD) { - gtk_entry_set_text (GTK_ENTRY (entryPassword), text); - text = PW_HIDDEN; - } - } + if (column == COLUMN_CREDENTIAL_PASSWORD) { + gtk_entry_set_text (GTK_ENTRY (entryPassword), text); + text = PW_HIDDEN; + } + } - gtk_tree_model_get_iter (model, &iter, path); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, text, -1); - gtk_tree_path_free (path); + gtk_tree_model_get_iter (model, &iter, path); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, text, -1); + gtk_tree_path_free (path); } -static void editing_started_cb (GtkCellRenderer *cell, GtkCellEditable * editable, const gchar * path, gpointer data) { +static void editing_started_cb (GtkCellRenderer *cell UNUSED, GtkCellEditable * editable, const gchar * path, gpointer data UNUSED) +{ - DEBUG("Editing started"); - DEBUG("path desc in editing_started_cb: %s\n", path); + DEBUG ("Editing started"); + DEBUG ("path desc in editing_started_cb: %s\n", path); - // If we are dealing the first row - if (g_strcasecmp (path, "0") == 0) - { - gtk_entry_set_text (GTK_ENTRY (editable), gtk_entry_get_text (GTK_ENTRY (entryPassword))); - } + // If we are dealing the first row + if (g_strcasecmp (path, "0") == 0) { + gtk_entry_set_text (GTK_ENTRY (editable), gtk_entry_get_text (GTK_ENTRY (entryPassword))); + } } -static void show_advanced_zrtp_options_cb(GtkWidget *widget UNUSED, gpointer data) +static void show_advanced_zrtp_options_cb (GtkWidget *widget UNUSED, gpointer data) { - DEBUG("Advanced options for SRTP"); - if (g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "ZRTP") == 0) { - show_advanced_zrtp_options((GHashTable *) data); - } - else { - show_advanced_sdes_options((GHashTable *) data); + DEBUG ("Advanced options for SRTP"); + + if (g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "ZRTP") == 0) { + show_advanced_zrtp_options ( (GHashTable *) data); + } else { + show_advanced_sdes_options ( (GHashTable *) data); } } -static void show_advanced_tls_options_cb(GtkWidget *widget UNUSED, gpointer data) +static void show_advanced_tls_options_cb (GtkWidget *widget UNUSED, gpointer data) { - DEBUG("Advanced options for TLS"); - show_advanced_tls_options((GHashTable *) data); + DEBUG ("Advanced options for TLS"); + show_advanced_tls_options ( (GHashTable *) data); } -static void key_exchange_changed_cb(GtkWidget *widget, gpointer data) +static void key_exchange_changed_cb (GtkWidget *widget UNUSED, gpointer data UNUSED) { - DEBUG("Key exchange changed %s", gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo))); + DEBUG ("Key exchange changed %s", gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo))); - int isSdes = g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "SDES"); - int isZrtp = g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "ZRTP"); + int isSdes = g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "SDES"); + int isZrtp = g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "ZRTP"); - if ((isSdes == 0) || (isZrtp == 0)) { - gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), TRUE); + if ( (isSdes == 0) || (isZrtp == 0)) { + gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), TRUE); } else { - gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE); - + gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE); + } } -static void use_sip_tls_cb(GtkWidget *widget, gpointer data) +static void use_sip_tls_cb (GtkWidget *widget, gpointer data) { - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { - DEBUG("Using sips"); - gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE); - // Uncheck stun - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunCheckBox), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE); - gtk_widget_hide (stunServerLabel); - gtk_widget_hide (stunServerEntry); - - - - if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) { - gtk_widget_show(publishedAddressEntry); - gtk_widget_show(publishedPortSpinBox); - gtk_widget_show(publishedAddressLabel); - gtk_widget_show(publishedPortLabel); - } - - } else { - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), TRUE); - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox))) { - gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), FALSE); - gtk_widget_show(stunServerLabel); - gtk_widget_show(stunServerEntry); - gtk_widget_hide(publishedAddressEntry); - gtk_widget_hide(publishedPortSpinBox); - gtk_widget_hide(publishedAddressLabel); - gtk_widget_hide(publishedPortLabel); - } - else { - gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE); - gtk_widget_hide(stunServerLabel); - gtk_widget_hide(stunServerEntry); - } - - } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + DEBUG ("Using sips"); + gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); + // Uncheck stun + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), TRUE); + gtk_widget_hide (stunServerLabel); + gtk_widget_hide (stunServerEntry); + + + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) { + gtk_widget_show (publishedAddressEntry); + gtk_widget_show (publishedPortSpinBox); + gtk_widget_show (publishedAddressLabel); + gtk_widget_show (publishedPortLabel); + } + + } else { + gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), TRUE); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (useStunCheckBox))) { + gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), FALSE); + gtk_widget_show (stunServerLabel); + gtk_widget_show (stunServerEntry); + gtk_widget_hide (publishedAddressEntry); + gtk_widget_hide (publishedPortSpinBox); + gtk_widget_hide (publishedAddressLabel); + gtk_widget_hide (publishedPortLabel); + } else { + gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), TRUE); + gtk_widget_hide (stunServerLabel); + gtk_widget_hide (stunServerEntry); + } + + } } -static local_interface_changed_cb(GtkWidget * widget, gpointer data UNUSED) { +static void local_interface_changed_cb (GtkWidget * widget UNUSED, gpointer data UNUSED) +{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) { - gchar *local_iface_name; - gchar *local_iface_addr; - local_iface_addr = g_malloc(36); + gchar *local_iface_name; + gchar *local_iface_addr; + local_iface_addr = g_malloc (36); - local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo)); - // sflphone_get_interface_addr_from_name((char *)local_interface); - sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr, 36); + local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo)); + sflphone_get_interface_addr_from_name (local_iface_name, &local_iface_addr, 36); - gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr); - gtk_entry_set_text (GTK_ENTRY(publishedAddressEntry), local_iface_addr); + gtk_entry_set_text (GTK_ENTRY (localAddressEntry), local_iface_addr); + gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), local_iface_addr); - // gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)); - // gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL)); - g_free(local_iface_addr); - } + g_free (local_iface_addr); + } } -static set_published_addr_manually_cb(GtkWidget * widget, gpointer data UNUSED) +static void set_published_addr_manually_cb (GtkWidget * widget, gpointer data UNUSED) { - - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { - DEBUG("Config: Showing manual publishing options"); - gtk_widget_show(publishedPortLabel); - gtk_widget_show(publishedPortSpinBox); - gtk_widget_show(publishedAddressLabel); - gtk_widget_show(publishedAddressEntry); - } else { - DEBUG("Config: Hiding manual publishing options"); - gtk_widget_hide(publishedPortLabel); - gtk_widget_hide(publishedPortSpinBox); - gtk_widget_hide(publishedAddressLabel); - gtk_widget_hide(publishedAddressEntry); - } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + DEBUG ("Config: Showing manual publishing options"); + gtk_widget_show (publishedPortLabel); + gtk_widget_show (publishedPortSpinBox); + gtk_widget_show (publishedAddressLabel); + gtk_widget_show (publishedAddressEntry); + } else { + DEBUG ("Config: Hiding manual publishing options"); + gtk_widget_hide (publishedPortLabel); + gtk_widget_hide (publishedPortSpinBox); + gtk_widget_hide (publishedAddressLabel); + gtk_widget_hide (publishedAddressEntry); + } } -static use_stun_cb(GtkWidget *widget, gpointer data UNUSED) +static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED) { - gchar *local_interface; - gchar *local_address; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { - - DEBUG("Config: Showing stun options, hiding Local/Published info"); - gtk_widget_show (stunServerLabel); - gtk_widget_show (stunServerEntry); - gtk_widget_set_sensitive (sameAsLocalRadioButton, FALSE); - gtk_widget_set_sensitive (publishedAddrRadioButton, FALSE); - - gtk_widget_hide (publishedAddressLabel); - gtk_widget_hide (publishedPortLabel); - gtk_widget_hide (publishedAddressEntry); - gtk_widget_hide (publishedPortSpinBox); - - } else { - - DEBUG("Config: hiding stun options, showing Local/Published info"); - - gtk_widget_hide (stunServerLabel); - gtk_widget_hide (stunServerEntry); - gtk_widget_set_sensitive (sameAsLocalRadioButton, TRUE); - gtk_widget_set_sensitive (publishedAddrRadioButton, TRUE); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton))) { - gtk_widget_show (publishedAddressLabel); - gtk_widget_show (publishedPortLabel); - gtk_widget_show (publishedAddressEntry); - gtk_widget_show (publishedPortSpinBox); - } - } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + + DEBUG ("Config: Showing stun options, hiding Local/Published info"); + gtk_widget_show (stunServerLabel); + gtk_widget_show (stunServerEntry); + gtk_widget_set_sensitive (sameAsLocalRadioButton, FALSE); + gtk_widget_set_sensitive (publishedAddrRadioButton, FALSE); + + gtk_widget_hide (publishedAddressLabel); + gtk_widget_hide (publishedPortLabel); + gtk_widget_hide (publishedAddressEntry); + gtk_widget_hide (publishedPortSpinBox); + + } else { + + DEBUG ("Config: hiding stun options, showing Local/Published info"); + + gtk_widget_hide (stunServerLabel); + gtk_widget_hide (stunServerEntry); + gtk_widget_set_sensitive (sameAsLocalRadioButton, TRUE); + gtk_widget_set_sensitive (publishedAddrRadioButton, TRUE); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton))) { + gtk_widget_show (publishedAddressLabel); + gtk_widget_show (publishedPortLabel); + gtk_widget_show (publishedAddressEntry); + gtk_widget_show (publishedPortSpinBox); + } + } } -static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED) +static void same_as_local_cb (GtkWidget * widget, gpointer data UNUSED) { - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { - DEBUG("Same as local"); - gchar * local_interface; - gchar * local_address; + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + DEBUG ("Same as local"); + gchar * local_interface; + gchar * local_address; - local_interface = (gchar *) gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo)); - // sflphone_get_interface_addr_from_name((char *)local_interface); - local_address = dbus_get_address_from_interface_name(local_interface); + local_interface = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo)); + // sflphone_get_interface_addr_from_name((char *)local_interface); + local_address = dbus_get_address_from_interface_name (local_interface); - gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), local_address); + gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), local_address); - gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL)); - } + gchar * local_port = (gchar *) gtk_entry_get_text (GTK_ENTRY (localPortSpinBox)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (publishedPortSpinBox), g_ascii_strtod (local_port, NULL)); + } } -GtkWidget* create_credential_widget (account_t **a) { - - GtkWidget *frame, *table, *scrolledWindowCredential, *addButton; - GtkCellRenderer * renderer; - GtkTreeViewColumn * treeViewColumn; - GtkTreeSelection * treeSelection; - - /* Credentials tree view */ - gnome_main_section_new_with_table (_("Credential"), &frame, &table, 1, 1); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings(GTK_TABLE(table), 10); - - scrolledWindowCredential = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_SHADOW_IN); - gtk_table_attach_defaults (GTK_TABLE (table), scrolledWindowCredential, 0, 1, 0, 1); - - credentialStore = gtk_list_store_new(COLUMN_CREDENTIAL_COUNT, - G_TYPE_STRING, // Realm - G_TYPE_STRING, // Username - G_TYPE_STRING, // Password - G_TYPE_POINTER // Pointer to the Objectc - ); - - treeViewCredential = gtk_tree_view_new_with_model(GTK_TREE_MODEL(credentialStore)); - treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW (treeViewCredential)); - g_signal_connect(G_OBJECT (treeSelection), "changed", G_CALLBACK (select_credential_cb), credentialStore); - - renderer = gtk_cell_renderer_text_new(); - g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); - g_signal_connect(G_OBJECT (renderer), "edited", G_CALLBACK(cell_edited_cb), credentialStore); - g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_REALM)); - treeViewColumn = gtk_tree_view_column_new_with_attributes ("Realm", - renderer, - "markup", COLUMN_CREDENTIAL_REALM, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn); - - renderer = gtk_cell_renderer_text_new(); - g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); - g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore); - g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME)); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Authentication name"), - renderer, - "markup", COLUMN_CREDENTIAL_USERNAME, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn); - - renderer = gtk_cell_renderer_text_new(); - g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); - g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore); - g_signal_connect (renderer, "editing-started", G_CALLBACK (editing_started_cb), NULL); - g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD)); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Password"), - renderer, - "markup", COLUMN_CREDENTIAL_PASSWORD, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn); - - gtk_container_add(GTK_CONTAINER(scrolledWindowCredential), treeViewCredential); - - DEBUG("Credential pas ok"); - fill_treeview_with_credential(credentialStore, *a); - DEBUG("Credential ok"); - - /* Credential Buttons */ - hbox = gtk_hbox_new(FALSE, 10); - gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 3, 1, 2); - - addButton = gtk_button_new_from_stock (GTK_STOCK_ADD); - g_signal_connect (addButton, "clicked", G_CALLBACK (add_credential_cb), credentialStore); - gtk_box_pack_start(GTK_BOX(hbox), addButton, FALSE, FALSE, 0); - - deleteCredButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential); - gtk_box_pack_start(GTK_BOX(hbox), deleteCredButton, FALSE, FALSE, 0); - - /* Dynamically resize the window to fit the scrolled window */ - GtkRequisition requisitionTable; - GtkRequisition requisitionTreeView; - gtk_widget_size_request (GTK_WIDGET(treeViewCredential), &requisitionTreeView); - gtk_widget_size_request (GTK_WIDGET(table), &requisitionTable); - gtk_widget_set_size_request (GTK_WIDGET(scrolledWindowCredential), 400, 120); - // same_as_local_cb (sameAsLocalRadioButton, NULL); - // set_published_addr_manually_cb (publishedAddrRadioButton, NULL); - - return frame; +GtkWidget* create_credential_widget (account_t **a) +{ + + GtkWidget *frame, *table, *scrolledWindowCredential, *addButton; + GtkCellRenderer * renderer; + GtkTreeViewColumn * treeViewColumn; + GtkTreeSelection * treeSelection; + + /* Credentials tree view */ + gnome_main_section_new_with_table (_ ("Credential"), &frame, &table, 1, 1); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + + scrolledWindowCredential = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_SHADOW_IN); + gtk_table_attach_defaults (GTK_TABLE (table), scrolledWindowCredential, 0, 1, 0, 1); + + credentialStore = gtk_list_store_new (COLUMN_CREDENTIAL_COUNT, + G_TYPE_STRING, // Realm + G_TYPE_STRING, // Username + G_TYPE_STRING, // Password + G_TYPE_POINTER // Pointer to the Objectc + ); + + treeViewCredential = gtk_tree_view_new_with_model (GTK_TREE_MODEL (credentialStore)); + treeSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeViewCredential)); + g_signal_connect (G_OBJECT (treeSelection), "changed", G_CALLBACK (select_credential_cb), credentialStore); + + renderer = gtk_cell_renderer_text_new(); + g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); + g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore); + g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_REALM)); + treeViewColumn = gtk_tree_view_column_new_with_attributes ("Realm", + renderer, + "markup", COLUMN_CREDENTIAL_REALM, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn); + + renderer = gtk_cell_renderer_text_new(); + g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); + g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore); + g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME)); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Authentication name"), + renderer, + "markup", COLUMN_CREDENTIAL_USERNAME, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn); + + renderer = gtk_cell_renderer_text_new(); + g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL); + g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore); + g_signal_connect (renderer, "editing-started", G_CALLBACK (editing_started_cb), NULL); + g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD)); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Password"), + renderer, + "markup", COLUMN_CREDENTIAL_PASSWORD, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn); + + gtk_container_add (GTK_CONTAINER (scrolledWindowCredential), treeViewCredential); + + DEBUG ("Credential pas ok"); + fill_treeview_with_credential (credentialStore, *a); + DEBUG ("Credential ok"); + + /* Credential Buttons */ + hbox = gtk_hbox_new (FALSE, 10); + gtk_table_attach_defaults (GTK_TABLE (table), hbox, 0, 3, 1, 2); + + addButton = gtk_button_new_from_stock (GTK_STOCK_ADD); + g_signal_connect (addButton, "clicked", G_CALLBACK (add_credential_cb), credentialStore); + gtk_box_pack_start (GTK_BOX (hbox), addButton, FALSE, FALSE, 0); + + deleteCredButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE); + g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential); + gtk_box_pack_start (GTK_BOX (hbox), deleteCredButton, FALSE, FALSE, 0); + + /* Dynamically resize the window to fit the scrolled window */ + GtkRequisition requisitionTable; + GtkRequisition requisitionTreeView; + gtk_widget_size_request (GTK_WIDGET (treeViewCredential), &requisitionTreeView); + gtk_widget_size_request (GTK_WIDGET (table), &requisitionTable); + gtk_widget_set_size_request (GTK_WIDGET (scrolledWindowCredential), 400, 120); + // same_as_local_cb (sameAsLocalRadioButton, NULL); + // set_published_addr_manually_cb (publishedAddrRadioButton, NULL); + + return frame; } -GtkWidget* create_security_widget (account_t **a) { - - GtkWidget *frame, *table, *sipTlsAdvancedButton, *label; - gchar *curSRTPEnabled = NULL, *curKeyExchange = NULL, *curTLSEnabled = NULL; - - // Load from SIP/IAX/Unknown ? - if((*a)) { - curKeyExchange = g_hash_table_lookup ((*a)->properties, ACCOUNT_KEY_EXCHANGE); - if (curKeyExchange == NULL) { - curKeyExchange = "none"; - } - - curSRTPEnabled = g_hash_table_lookup ((*a)->properties, ACCOUNT_SRTP_ENABLED); - if (curSRTPEnabled == NULL) { - curSRTPEnabled = "false"; - } - - curTLSEnabled = g_hash_table_lookup ((*a)->properties, TLS_ENABLE); - if (curTLSEnabled == NULL) { - curTLSEnabled = "false"; - } - } - - gnome_main_section_new_with_table (_("Security"), &frame, &table, 2, 3); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings (GTK_TABLE(table), 10); - gtk_table_set_col_spacings (GTK_TABLE(table), 10); - - /* TLS subsection */ - sipTlsAdvancedButton = gtk_button_new_from_stock (GTK_STOCK_EDIT); - gtk_table_attach_defaults (GTK_TABLE (table), sipTlsAdvancedButton, 2, 3, 0, 1); - gtk_widget_set_sensitive (GTK_WIDGET (sipTlsAdvancedButton), FALSE); - g_signal_connect (G_OBJECT (sipTlsAdvancedButton), "clicked", G_CALLBACK (show_advanced_tls_options_cb), (*a)->properties); - - useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)")); - g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE); - gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1); - - /* ZRTP subsection */ - label = gtk_label_new_with_mnemonic (_("SRTP key exchange")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - keyExchangeCombo = gtk_combo_box_new_text(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), keyExchangeCombo); - gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), "ZRTP"); - gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), "SDES"); - gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), _("Disabled")); - - advancedZrtpButton = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES); - g_signal_connect(G_OBJECT(advancedZrtpButton), "clicked", G_CALLBACK(show_advanced_zrtp_options_cb), (*a)->properties); - - if (g_strcmp0(curSRTPEnabled, "false") == 0) - { - gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo), 2); - gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE); - } else { - if (strcmp(curKeyExchange, ZRTP) == 0) { - gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo),0); - } - else if (strcmp(curKeyExchange, SDES) == 0) { - gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo),1); - } - else { - gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo), 2); - gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE); - } - } - - g_signal_connect (G_OBJECT (GTK_COMBO_BOX(keyExchangeCombo)), "changed", G_CALLBACK (key_exchange_changed_cb), *a); - - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); - gtk_table_attach_defaults(GTK_TABLE(table), keyExchangeCombo, 1, 2, 1, 2); - gtk_table_attach_defaults(GTK_TABLE(table), advancedZrtpButton, 2, 3, 1, 2); - - gtk_widget_show_all(table); - - return frame; +GtkWidget* create_security_widget (account_t **a) +{ + + GtkWidget *frame, *table, *sipTlsAdvancedButton, *label; + gchar *curSRTPEnabled = NULL, *curKeyExchange = NULL, *curTLSEnabled = NULL; + + // Load from SIP/IAX/Unknown ? + if ( (*a)) { + curKeyExchange = g_hash_table_lookup ( (*a)->properties, ACCOUNT_KEY_EXCHANGE); + + if (curKeyExchange == NULL) { + curKeyExchange = "none"; + } + + curSRTPEnabled = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SRTP_ENABLED); + + if (curSRTPEnabled == NULL) { + curSRTPEnabled = "false"; + } + + curTLSEnabled = g_hash_table_lookup ( (*a)->properties, TLS_ENABLE); + + if (curTLSEnabled == NULL) { + curTLSEnabled = "false"; + } + } + + gnome_main_section_new_with_table (_ ("Security"), &frame, &table, 2, 3); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + + /* TLS subsection */ + sipTlsAdvancedButton = gtk_button_new_from_stock (GTK_STOCK_EDIT); + gtk_table_attach_defaults (GTK_TABLE (table), sipTlsAdvancedButton, 2, 3, 0, 1); + gtk_widget_set_sensitive (GTK_WIDGET (sipTlsAdvancedButton), FALSE); + g_signal_connect (G_OBJECT (sipTlsAdvancedButton), "clicked", G_CALLBACK (show_advanced_tls_options_cb), (*a)->properties); + + useSipTlsCheckBox = gtk_check_button_new_with_mnemonic (_ ("Use TLS transport (sips)")); + g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK (use_sip_tls_cb), sipTlsAdvancedButton); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useSipTlsCheckBox), (g_strcmp0 (curTLSEnabled, "true") == 0) ? TRUE:FALSE); + gtk_table_attach_defaults (GTK_TABLE (table), useSipTlsCheckBox, 0, 2, 0, 1); + + /* ZRTP subsection */ + label = gtk_label_new_with_mnemonic (_ ("SRTP key exchange")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + keyExchangeCombo = gtk_combo_box_new_text(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), keyExchangeCombo); + gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), "ZRTP"); + gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), "SDES"); + gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), _ ("Disabled")); + + advancedZrtpButton = gtk_button_new_from_stock (GTK_STOCK_PREFERENCES); + g_signal_connect (G_OBJECT (advancedZrtpButton), "clicked", G_CALLBACK (show_advanced_zrtp_options_cb), (*a)->properties); + + if (g_strcmp0 (curSRTPEnabled, "false") == 0) { + gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo), 2); + gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE); + } else { + if (strcmp (curKeyExchange, ZRTP) == 0) { + gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo),0); + } else if (strcmp (curKeyExchange, SDES) == 0) { + gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo),1); + } else { + gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo), 2); + gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE); + } + } + + g_signal_connect (G_OBJECT (GTK_COMBO_BOX (keyExchangeCombo)), "changed", G_CALLBACK (key_exchange_changed_cb), *a); + + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); + gtk_table_attach_defaults (GTK_TABLE (table), keyExchangeCombo, 1, 2, 1, 2); + gtk_table_attach_defaults (GTK_TABLE (table), advancedZrtpButton, 2, 3, 1, 2); + + gtk_widget_show_all (table); + + return frame; } GtkWidget * create_security_tab (account_t **a) { - GtkWidget * frame; - GtkWidget * ret; - GtkWidget * hbox; + GtkWidget * frame; + GtkWidget * ret; + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + // Credentials frame + frame = create_credential_widget (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - // Credentials frame - frame = create_credential_widget (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + // Security frame + frame = create_security_widget (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - // Security frame - frame = create_security_widget (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + gtk_widget_show_all (ret); - gtk_widget_show_all(ret); - - return ret; - } + return ret; +} -GtkWidget* create_registration_expire (account_t **a) { +GtkWidget* create_registration_expire (account_t **a) +{ GtkWidget *table, *frame, *label; gchar *resolve_once=NULL, *account_expire=NULL; if (*a) { - resolve_once = g_hash_table_lookup ((*a)->properties, ACCOUNT_RESOLVE_ONCE); - account_expire = g_hash_table_lookup ((*a)->properties, ACCOUNT_REGISTRATION_EXPIRE); + resolve_once = g_hash_table_lookup ( (*a)->properties, ACCOUNT_RESOLVE_ONCE); + account_expire = g_hash_table_lookup ( (*a)->properties, ACCOUNT_REGISTRATION_EXPIRE); } - gnome_main_section_new_with_table (_("Registration"), &frame, &table, 2, 3); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings (GTK_TABLE (table), 5); - - label = gtk_label_new_with_mnemonic (_("Registration expire")); + gnome_main_section_new_with_table (_ ("Registration"), &frame, &table, 2, 3); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); + + label = gtk_label_new_with_mnemonic (_ ("Registration expire")); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); expireSpinBox = gtk_spin_button_new_with_range (1, 65535, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), expireSpinBox); gtk_spin_button_set_value (GTK_SPIN_BUTTON (expireSpinBox), g_ascii_strtod (account_expire, NULL)); gtk_table_attach_defaults (GTK_TABLE (table), expireSpinBox, 1, 2, 0, 1); - - entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic (_("_Comply with RFC 3263")); + + entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic (_ ("_Comply with RFC 3263")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entryResolveNameOnlyOnce), - g_strcasecmp (resolve_once,"false") == 0 ? TRUE: FALSE); + g_strcasecmp (resolve_once,"false") == 0 ? TRUE: FALSE); gtk_table_attach_defaults (GTK_TABLE (table), entryResolveNameOnlyOnce, 0, 2, 1, 2); - gtk_widget_set_sensitive (GTK_WIDGET (entryResolveNameOnlyOnce ) , TRUE ); + gtk_widget_set_sensitive (GTK_WIDGET (entryResolveNameOnlyOnce) , TRUE); return frame; } -GtkWidget* create_network (account_t **a) { - +GtkWidget* create_network (account_t **a) +{ + GtkWidget *table, *frame, *label; - gchar *local_interface, *local_port; + gchar *local_interface = NULL; + gchar *local_port = NULL; if (*a) { - local_interface = g_hash_table_lookup ((*a)->properties, LOCAL_INTERFACE); - local_port = g_hash_table_lookup ((*a)->properties, LOCAL_PORT); + local_interface = g_hash_table_lookup ( (*a)->properties, LOCAL_INTERFACE); + local_port = g_hash_table_lookup ( (*a)->properties, LOCAL_PORT); } - gnome_main_section_new_with_table (_("Network Interface"), &frame, &table, 2, 3); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings( GTK_TABLE(table), 5); + gnome_main_section_new_with_table (_ ("Network Interface"), &frame, &table, 2, 3); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); /** - * Retreive the list of IP interface from the + * Retreive the list of IP interface from the * the daemon and build the combo box. */ - GtkListStore * ipInterfaceListStore; + GtkListStore * ipInterfaceListStore; GtkTreeIter iter; - ipInterfaceListStore = gtk_list_store_new( 1, G_TYPE_STRING ); - label = gtk_label_new_with_mnemonic (_("Local address")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); + ipInterfaceListStore = gtk_list_store_new (1, G_TYPE_STRING); + label = gtk_label_new_with_mnemonic (_ ("Local address")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - GtkTreeIter current_local_iface_iter = iter; + GtkTreeIter current_local_iface_iter = iter; gchar ** iface_list = NULL; // iface_list = (gchar**) dbus_get_all_ip_interface(); iface_list = (gchar**) dbus_get_all_ip_interface_by_name(); gchar ** iface = NULL; - // flag to determine if local_address is found + // flag to determine if local_address is found gboolean iface_found = FALSE; gchar *local_iface_addr; - gchar *local_iface_name; + gchar *local_iface_name; + + local_iface_addr= g_malloc (36); - local_iface_addr= g_malloc(36); - if (iface_list != NULL) { // fill the iterface combo box - for (iface = iface_list; *iface; iface++) { - DEBUG("Interface %s", *iface); - gtk_list_store_append(ipInterfaceListStore, &iter ); - gtk_list_store_set(ipInterfaceListStore, &iter, 0, *iface, -1 ); - - // set the current local address - if (!iface_found && (g_strcmp0(*iface, local_interface) == 0)) { - DEBUG("Setting active local address combo box"); - current_local_iface_iter = iter; - iface_found = TRUE; - } - } - - if(!iface_found) { - DEBUG("Did not find local ip address, take fisrt in the list"); - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ipInterfaceListStore), ¤t_local_iface_iter); - } - + for (iface = iface_list; *iface; iface++) { + DEBUG ("Interface %s", *iface); + gtk_list_store_append (ipInterfaceListStore, &iter); + gtk_list_store_set (ipInterfaceListStore, &iter, 0, *iface, -1); + + // set the current local address + if (!iface_found && (g_strcmp0 (*iface, local_interface) == 0)) { + DEBUG ("Setting active local address combo box"); + current_local_iface_iter = iter; + iface_found = TRUE; + } + } + + if (!iface_found) { + DEBUG ("Did not find local ip address, take fisrt in the list"); + gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ipInterfaceListStore), ¤t_local_iface_iter); + } + } - - - localAddressCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ipInterfaceListStore)); + + + localAddressCombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (ipInterfaceListStore)); gtk_label_set_mnemonic_widget (GTK_LABEL (label), localAddressCombo); - gtk_table_attach ( GTK_TABLE( table ), localAddressCombo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - g_object_unref(G_OBJECT(ipInterfaceListStore)); + gtk_table_attach (GTK_TABLE (table), localAddressCombo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + g_object_unref (G_OBJECT (ipInterfaceListStore)); + - GtkCellRenderer * ipInterfaceCellRenderer; ipInterfaceCellRenderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL); - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(localAddressCombo), ¤t_local_iface_iter); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (localAddressCombo), ipInterfaceCellRenderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL); + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (localAddressCombo), ¤t_local_iface_iter); // Fill the text entry with the ip address of local interface selected localAddressEntry = gtk_entry_new(); local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo)); - sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr, 36); - gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr); - gtk_widget_set_sensitive(localAddressEntry, FALSE); - gtk_table_attach ( GTK_TABLE( table ), localAddressEntry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + sflphone_get_interface_addr_from_name (local_iface_name, &local_iface_addr, 36); + gtk_entry_set_text (GTK_ENTRY (localAddressEntry), local_iface_addr); + gtk_widget_set_sensitive (localAddressEntry, FALSE); + gtk_table_attach (GTK_TABLE (table), localAddressEntry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + g_free (local_iface_addr); - g_free(local_iface_addr); - // Local port widget - label = gtk_label_new_with_mnemonic (_("Local port")); - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - localPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1); + label = gtk_label_new_with_mnemonic (_ ("Local port")); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + localPortSpinBox = gtk_spin_button_new_with_range (1, 65535, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), localPortSpinBox); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(localPortSpinBox), g_ascii_strtod(local_port, NULL)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (localPortSpinBox), g_ascii_strtod (local_port, NULL)); - gtk_table_attach_defaults(GTK_TABLE(table), localPortSpinBox, 1, 2, 1, 2); + gtk_table_attach_defaults (GTK_TABLE (table), localPortSpinBox, 1, 2, 1, 2); return frame; } -GtkWidget* create_published_address (account_t **a) { - - GtkWidget *table, *frame, *label; - gchar *use_tls, *published_address, *published_port, *local_address, *stun_enable, *stun_server, *published_sameas_local; - - // Get the user configuration - if (*a) { - - use_tls = g_hash_table_lookup ((*a)->properties, TLS_ENABLE); - published_sameas_local = g_hash_table_lookup ((*a)->properties, PUBLISHED_SAMEAS_LOCAL); - - if (g_strcasecmp (published_sameas_local, "true") == 0) { - published_address = dbus_get_address_from_interface_name (g_hash_table_lookup ((*a)->properties, LOCAL_INTERFACE)); - published_port = g_hash_table_lookup ((*a)->properties, LOCAL_PORT); - } - else { - published_address = g_hash_table_lookup ((*a)->properties, PUBLISHED_ADDRESS); - published_port = g_hash_table_lookup ((*a)->properties, PUBLISHED_PORT); - } - - stun_enable = g_hash_table_lookup ((*a)->properties, ACCOUNT_SIP_STUN_ENABLED); - stun_server = g_hash_table_lookup ((*a)->properties, ACCOUNT_SIP_STUN_SERVER); - published_sameas_local = g_hash_table_lookup ((*a)->properties, PUBLISHED_SAMEAS_LOCAL); - } - - gnome_main_section_new_with_table (_("Published address"), &frame, &table, 2, 3); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings (GTK_TABLE (table), 5); - - useStunCheckBox = gtk_check_button_new_with_mnemonic(_("Using STUN")); - gtk_table_attach_defaults(GTK_TABLE(table), useStunCheckBox, 0, 1, 0, 1); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(useStunCheckBox), - g_strcasecmp(stun_enable, "true") == 0 ? TRUE: FALSE); - gtk_widget_set_sensitive (GTK_WIDGET(useStunCheckBox), - g_strcasecmp(use_tls,"true") == 0 ? FALSE: TRUE); - - stunServerLabel = gtk_label_new_with_mnemonic (_("STUN server URL")); - gtk_table_attach_defaults(GTK_TABLE(table), stunServerLabel, 0, 1, 1, 2); - gtk_misc_set_alignment(GTK_MISC (stunServerLabel), 0, 0.5); - stunServerEntry = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (stunServerLabel), stunServerEntry); - gtk_entry_set_text(GTK_ENTRY(stunServerEntry), stun_server); - gtk_table_attach_defaults(GTK_TABLE(table), stunServerEntry, 1, 2, 1, 2); - - sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(NULL, _("Same as local parameters")); - gtk_table_attach_defaults(GTK_TABLE(table), sameAsLocalRadioButton, 0, 2, 3, 4); - - publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(sameAsLocalRadioButton), _("Set published address and port:")); - gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 4, 5); - - if (g_strcasecmp (published_sameas_local, "true") == 0) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), FALSE); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), TRUE); - } - - publishedAddressLabel = gtk_label_new_with_mnemonic (_("Published address")); - gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressLabel, 0, 1, 5, 6); - gtk_misc_set_alignment(GTK_MISC (publishedAddressLabel), 0, 0.5); - publishedAddressEntry = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (publishedAddressLabel), publishedAddressEntry); - - gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), published_address); - gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressEntry, 1, 2, 5, 6); - - publishedPortLabel = gtk_label_new_with_mnemonic(_("Published port")); - gtk_table_attach_defaults(GTK_TABLE(table), publishedPortLabel, 0, 1, 6, 7); - gtk_misc_set_alignment(GTK_MISC (publishedPortLabel), 0, 0.5); - publishedPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1); - gtk_label_set_mnemonic_widget(GTK_LABEL (publishedPortLabel), publishedPortSpinBox); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(published_port, NULL)); - - gtk_table_attach_defaults(GTK_TABLE(table), publishedPortSpinBox, 1, 2, 6, 7); - - // This will trigger a signal, and the above two - // widgets need to be instanciated before that. - g_signal_connect(localAddressCombo, "changed", G_CALLBACK(local_interface_changed_cb), localAddressCombo); - - g_signal_connect(useStunCheckBox, "toggled", G_CALLBACK(use_stun_cb), useStunCheckBox); - - g_signal_connect(sameAsLocalRadioButton, "toggled", G_CALLBACK(same_as_local_cb), sameAsLocalRadioButton); - g_signal_connect(publishedAddrRadioButton, "toggled", G_CALLBACK(set_published_addr_manually_cb), publishedAddrRadioButton); - - set_published_addr_manually_cb(publishedAddrRadioButton, NULL); - - return frame; +GtkWidget* create_published_address (account_t **a) +{ + + GtkWidget *table, *frame; + gchar *use_tls =NULL; + gchar *published_address = NULL; + gchar *published_port = NULL; + gchar *stun_enable = NULL; + gchar *stun_server = NULL; + gchar *published_sameas_local = NULL; + + // Get the user configuration + if (*a) { + + use_tls = g_hash_table_lookup ( (*a)->properties, TLS_ENABLE); + published_sameas_local = g_hash_table_lookup ( (*a)->properties, PUBLISHED_SAMEAS_LOCAL); + + if (g_strcasecmp (published_sameas_local, "true") == 0) { + published_address = dbus_get_address_from_interface_name (g_hash_table_lookup ( (*a)->properties, LOCAL_INTERFACE)); + published_port = g_hash_table_lookup ( (*a)->properties, LOCAL_PORT); + } else { + published_address = g_hash_table_lookup ( (*a)->properties, PUBLISHED_ADDRESS); + published_port = g_hash_table_lookup ( (*a)->properties, PUBLISHED_PORT); + } + + stun_enable = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SIP_STUN_ENABLED); + stun_server = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SIP_STUN_SERVER); + published_sameas_local = g_hash_table_lookup ( (*a)->properties, PUBLISHED_SAMEAS_LOCAL); + } + + gnome_main_section_new_with_table (_ ("Published address"), &frame, &table, 2, 3); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); + + useStunCheckBox = gtk_check_button_new_with_mnemonic (_ ("Using STUN")); + gtk_table_attach_defaults (GTK_TABLE (table), useStunCheckBox, 0, 1, 0, 1); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox), + g_strcasecmp (stun_enable, "true") == 0 ? TRUE: FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), + g_strcasecmp (use_tls,"true") == 0 ? FALSE: TRUE); + + stunServerLabel = gtk_label_new_with_mnemonic (_ ("STUN server URL")); + gtk_table_attach_defaults (GTK_TABLE (table), stunServerLabel, 0, 1, 1, 2); + gtk_misc_set_alignment (GTK_MISC (stunServerLabel), 0, 0.5); + stunServerEntry = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (stunServerLabel), stunServerEntry); + gtk_entry_set_text (GTK_ENTRY (stunServerEntry), stun_server); + gtk_table_attach_defaults (GTK_TABLE (table), stunServerEntry, 1, 2, 1, 2); + + sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget (NULL, _ ("Same as local parameters")); + gtk_table_attach_defaults (GTK_TABLE (table), sameAsLocalRadioButton, 0, 2, 3, 4); + + publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (sameAsLocalRadioButton), _ ("Set published address and port:")); + gtk_table_attach_defaults (GTK_TABLE (table), publishedAddrRadioButton, 0, 2, 4, 5); + + if (g_strcasecmp (published_sameas_local, "true") == 0) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), FALSE); + } else { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), TRUE); + } + + publishedAddressLabel = gtk_label_new_with_mnemonic (_ ("Published address")); + gtk_table_attach_defaults (GTK_TABLE (table), publishedAddressLabel, 0, 1, 5, 6); + gtk_misc_set_alignment (GTK_MISC (publishedAddressLabel), 0, 0.5); + publishedAddressEntry = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (publishedAddressLabel), publishedAddressEntry); + + gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), published_address); + gtk_table_attach_defaults (GTK_TABLE (table), publishedAddressEntry, 1, 2, 5, 6); + + publishedPortLabel = gtk_label_new_with_mnemonic (_ ("Published port")); + gtk_table_attach_defaults (GTK_TABLE (table), publishedPortLabel, 0, 1, 6, 7); + gtk_misc_set_alignment (GTK_MISC (publishedPortLabel), 0, 0.5); + publishedPortSpinBox = gtk_spin_button_new_with_range (1, 65535, 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (publishedPortLabel), publishedPortSpinBox); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (publishedPortSpinBox), g_ascii_strtod (published_port, NULL)); + + gtk_table_attach_defaults (GTK_TABLE (table), publishedPortSpinBox, 1, 2, 6, 7); + + // This will trigger a signal, and the above two + // widgets need to be instanciated before that. + g_signal_connect (localAddressCombo, "changed", G_CALLBACK (local_interface_changed_cb), localAddressCombo); + + g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), useStunCheckBox); + + g_signal_connect (sameAsLocalRadioButton, "toggled", G_CALLBACK (same_as_local_cb), sameAsLocalRadioButton); + g_signal_connect (publishedAddrRadioButton, "toggled", G_CALLBACK (set_published_addr_manually_cb), publishedAddrRadioButton); + + set_published_addr_manually_cb (publishedAddrRadioButton, NULL); + + return frame; } -GtkWidget* create_advanced_tab (account_t **a) { +GtkWidget* create_advanced_tab (account_t **a) +{ - // Build the advanced tab, to appear on the account configuration panel - DEBUG("Config: Build advanced tab"); + // Build the advanced tab, to appear on the account configuration panel + DEBUG ("Config: Build advanced tab"); - GtkWidget *ret, *frame; + GtkWidget *ret, *frame; - ret = gtk_vbox_new (FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - frame = create_registration_expire (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + frame = create_registration_expire (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - frame = create_network (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + frame = create_network (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - frame = create_published_address (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + frame = create_published_address (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - gtk_widget_show_all (ret); + gtk_widget_show_all (ret); - use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL); + use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL); - set_published_addr_manually_cb(GTK_WIDGET (publishedAddrRadioButton), NULL); + set_published_addr_manually_cb (GTK_WIDGET (publishedAddrRadioButton), NULL); - return ret; + return ret; } -void ringtone_enabled(GtkWidget *widget UNUSED, gpointer fileChooser, const gchar *accountID) +void ringtone_enabled (GtkWidget *widget UNUSED, gpointer fileChooser, const gchar *accountID UNUSED) { - gboolean isEnabled = gtk_widget_get_sensitive(GTK_WIDGET(fileChooser)); - - if(isEnabled) { - gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), FALSE); - } - else { - gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), TRUE); - } + gboolean isEnabled = gtk_widget_get_sensitive (GTK_WIDGET (fileChooser)); + + if (isEnabled) { + gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), FALSE); + } else { + gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), TRUE); + } } -GtkWidget* create_codecs_configuration (account_t **a) { +GtkWidget* create_codecs_configuration (account_t **a) +{ + + // Main widget + GtkWidget *ret, *codecs, *dtmf, *box, *frame, *sipinfo, *table; + account_t *currentAccount = *a; + gchar *currentDtmfType = ""; + gboolean dtmf_are_rtp = TRUE; + gpointer p; - // Main widget - GtkWidget *ret, *codecs, *dtmf, *box, *frame, *sipinfo, *table; - account_t *currentAccount = *a; - gchar *currentDtmfType = ""; - gboolean dtmf_are_rtp = TRUE; - gpointer p; + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + box = codecs_box (a); - box = codecs_box (a); + // Box for the codecs + gnome_main_section_new (_ ("Codecs"), &codecs); + gtk_box_pack_start (GTK_BOX (ret), codecs, FALSE, FALSE, 0); + gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200); + gtk_widget_show (codecs); + gtk_container_add (GTK_CONTAINER (codecs) , box); - // Box for the codecs - gnome_main_section_new (_("Codecs"), &codecs); - gtk_box_pack_start (GTK_BOX(ret), codecs, FALSE, FALSE, 0); - gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200); - gtk_widget_show (codecs); - gtk_container_add (GTK_CONTAINER (codecs) , box); + // Add DTMF type selection for SIP account only + p = g_hash_table_lookup (currentAccount->properties, g_strdup (ACCOUNT_TYPE)); - // Add DTMF type selection for SIP account only - p = g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_TYPE)); - if(g_strcmp0(p, "SIP") == 0) { - - // Box for dtmf - gnome_main_section_new_with_table (_("DTMF"), &dtmf, &table, 1, 2); - gtk_box_pack_start (GTK_BOX(ret), dtmf, FALSE, FALSE, 0); - gtk_widget_show (dtmf); + if (g_strcmp0 (p, "SIP") == 0) { + // Box for dtmf + gnome_main_section_new_with_table (_ ("DTMF"), &dtmf, &table, 1, 2); + gtk_box_pack_start (GTK_BOX (ret), dtmf, FALSE, FALSE, 0); + gtk_widget_show (dtmf); - currentDtmfType = g_hash_table_lookup (currentAccount->properties, g_strdup(ACCOUNT_DTMF_TYPE)); - if (g_strcasecmp(currentDtmfType, OVERRTP) != 0) { + + currentDtmfType = g_hash_table_lookup (currentAccount->properties, g_strdup (ACCOUNT_DTMF_TYPE)); + + if (g_strcasecmp (currentDtmfType, OVERRTP) != 0) { dtmf_are_rtp = FALSE; - } + } - overrtp = gtk_radio_button_new_with_label( NULL, _("RTP") ); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(overrtp), dtmf_are_rtp); - gtk_table_attach ( GTK_TABLE( table ), overrtp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + overrtp = gtk_radio_button_new_with_label (NULL, _ ("RTP")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (overrtp), dtmf_are_rtp); + gtk_table_attach (GTK_TABLE (table), overrtp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - sipinfo = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(overrtp), _("SIP")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(sipinfo), !dtmf_are_rtp); - g_signal_connect(G_OBJECT(sipinfo), "clicked", G_CALLBACK(select_dtmf_type), NULL); - gtk_table_attach ( GTK_TABLE( table ), sipinfo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - } + sipinfo = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (overrtp), _ ("SIP")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sipinfo), !dtmf_are_rtp); + g_signal_connect (G_OBJECT (sipinfo), "clicked", G_CALLBACK (select_dtmf_type), NULL); + gtk_table_attach (GTK_TABLE (table), sipinfo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + } + + // Box for the ringtones + gnome_main_section_new_with_table (_ ("Ringtones"), &frame, &table, 1, 2); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - // Box for the ringtones - gnome_main_section_new_with_table (_("Ringtones"), &frame, &table, 1, 2); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); + fileChooser = gtk_file_chooser_button_new (_ ("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN); - fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN); + p = g_hash_table_lookup (currentAccount->properties, g_strdup (CONFIG_RINGTONE_ENABLED)); + gboolean ringtoneEnabled = (g_strcmp0 (p, "true") == 0) ? TRUE : FALSE; - p = g_hash_table_lookup(currentAccount->properties, g_strdup(CONFIG_RINGTONE_ENABLED)); - gboolean ringtoneEnabled = (g_strcmp0(p, "true") == 0) ? TRUE : FALSE; + enableTone = gtk_check_button_new_with_mnemonic (_ ("_Enable ringtones")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableTone), ringtoneEnabled); + g_signal_connect (G_OBJECT (enableTone) , "clicked" , G_CALLBACK (ringtone_enabled), fileChooser); + gtk_table_attach (GTK_TABLE (table), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - enableTone = gtk_check_button_new_with_mnemonic( _("_Enable ringtones")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableTone), ringtoneEnabled); - g_signal_connect(G_OBJECT( enableTone) , "clicked" , G_CALLBACK( ringtone_enabled ), fileChooser); - gtk_table_attach ( GTK_TABLE( table ), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + // file chooser button + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fileChooser) , g_get_home_dir()); + p = g_hash_table_lookup (currentAccount->properties, g_strdup (CONFIG_RINGTONE_PATH)); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fileChooser) , p); + gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), ringtoneEnabled); - // file chooser button - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( fileChooser) , g_get_home_dir()); - p = g_hash_table_lookup(currentAccount->properties, g_strdup(CONFIG_RINGTONE_PATH)); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER( fileChooser) , p); - gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), ringtoneEnabled); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_set_name (filter , _ ("Audio Files")); + gtk_file_filter_add_pattern (filter , "*.wav"); + gtk_file_filter_add_pattern (filter , "*.ul"); + gtk_file_filter_add_pattern (filter , "*.au"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fileChooser) , filter); + gtk_table_attach (GTK_TABLE (table), fileChooser, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - GtkFileFilter *filter = gtk_file_filter_new(); - gtk_file_filter_set_name( filter , _("Audio Files") ); - gtk_file_filter_add_pattern(filter , "*.wav" ); - gtk_file_filter_add_pattern(filter , "*.ul" ); - gtk_file_filter_add_pattern(filter , "*.au" ); - gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( fileChooser ) , filter); - gtk_table_attach ( GTK_TABLE( table ), fileChooser, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - gtk_widget_show_all(ret); + gtk_widget_show_all (ret); - return ret; + return ret; } -void show_account_window (account_t * a) { +void show_account_window (account_t * a) +{ GtkWidget * notebook; - GtkWidget *tab, *codecs_tab, *ip_tab; + GtkWidget *tab, *codecs_tab, *ip_tab; gint response; account_t *currentAccount; - - // In case the published address is same than local, - // we must resolve published address from interface name + + + // Firstly we reset + reset(); + + // In case the published address is same than local, + // we must resolve published address from interface name gchar * local_interface; gchar * published_address; - - currentAccount = a; + + currentAccount = a; if (currentAccount == NULL) { - currentAccount = g_new0(account_t, 1); - currentAccount->properties = dbus_account_details(NULL); - currentAccount->accountID = "new"; - sflphone_fill_codec_list_per_account (¤tAccount); - DEBUG("Config: Account is NULL. Will fetch default values"); + currentAccount = g_new0 (account_t, 1); + currentAccount->properties = dbus_account_details (NULL); + currentAccount->accountID = "new"; + sflphone_fill_codec_list_per_account (¤tAccount); + DEBUG ("Config: Account is NULL. Will fetch default values"); } - dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"), - GTK_WINDOW(get_main_window()), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_APPLY, - GTK_RESPONSE_ACCEPT, - NULL)); - - gtk_dialog_set_has_separator(dialog, FALSE); - gtk_container_set_border_width (GTK_CONTAINER(dialog), 0); - + dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Account settings"), + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_APPLY, + GTK_RESPONSE_ACCEPT, + NULL)); + + gtk_dialog_set_has_separator (dialog, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 0); + notebook = gtk_notebook_new(); - gtk_box_pack_start(GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(notebook), 10); - gtk_widget_show(notebook); + gtk_box_pack_start (GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (notebook), 10); + gtk_widget_show (notebook); // We do not need the global settings for the IP2IP account if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - - /* General Settings */ - tab = create_basic_tab(¤tAccount); - - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Basic"))); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); + + /* General Settings */ + tab = create_basic_tab (¤tAccount); + + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Basic"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); } + /* Codecs */ codecs_tab = create_codecs_configuration (¤tAccount); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), codecs_tab, gtk_label_new(_("Codecs"))); - gtk_notebook_page_num (GTK_NOTEBOOK (notebook), codecs_tab); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), codecs_tab, gtk_label_new (_ ("Codecs"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), codecs_tab); // Get current protocol for this account protocol gchar *currentProtocol = "SIP"; - if(protocolComboBox) - currentProtocol = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(protocolComboBox)); + + if (protocolComboBox) + currentProtocol = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox)); // Do not need advanced or security one for the IP2IP account if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - /* Advanced */ - advanced_tab = create_advanced_tab(¤tAccount); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced"))); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook), advanced_tab); - - /* Security */ - security_tab = create_security_tab (¤tAccount); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security"))); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook),security_tab); + /* Advanced */ + advanced_tab = create_advanced_tab (¤tAccount); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), advanced_tab, gtk_label_new (_ ("Advanced"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), advanced_tab); - } - else { + /* Security */ + security_tab = create_security_tab (¤tAccount); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), security_tab, gtk_label_new (_ ("Security"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook),security_tab); + + } else { - /* Custom tab for the IP to IP profile */ - ip_tab = create_direct_ip_calls_tab (¤tAccount); - gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), ip_tab, gtk_label_new(_("Network"))); - gtk_notebook_page_num (GTK_NOTEBOOK (notebook), ip_tab); + /* Custom tab for the IP to IP profile */ + ip_tab = create_direct_ip_calls_tab (¤tAccount); + gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), ip_tab, gtk_label_new (_ ("Network"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), ip_tab); } // Emit signal to hide advanced and security tabs in case of IAX - if(protocolComboBox) - g_signal_emit_by_name (GTK_WIDGET(protocolComboBox), "changed", NULL); + if (protocolComboBox) + g_signal_emit_by_name (GTK_WIDGET (protocolComboBox), "changed", NULL); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook) , 0); @@ -1394,219 +1374,218 @@ void show_account_window (account_t * a) { /* Run dialog */ /**************/ response = gtk_dialog_run (GTK_DIALOG (dialog)); - + // Update protocol in case it changed gchar *proto = NULL; - if(protocolComboBox) - proto = (gchar *) gtk_combo_box_get_active_text(GTK_COMBO_BOX(protocolComboBox)); + + if (protocolComboBox) + proto = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox)); else - proto = "SIP"; + proto = "SIP"; // If cancel button is pressed - if(response == GTK_RESPONSE_CANCEL) { - gtk_widget_destroy (GTK_WIDGET(dialog)); - return; + if (response == GTK_RESPONSE_CANCEL) { + gtk_widget_destroy (GTK_WIDGET (dialog)); + return; } - gchar *key = g_strdup(ACCOUNT_USERNAME); - - // If accept button is + // If accept button is if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_ALIAS), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryAlias)))); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_TYPE), - g_strdup(proto)); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_HOSTNAME), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryHostname)))); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_USERNAME), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername)))); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_PASSWORD), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryPassword)))); - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_MAILBOX), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox)))); - - // Variable used to update credentials - current_username = (gchar *)g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_USERNAME)); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_ALIAS), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (entryAlias)))); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_TYPE), + g_strdup (proto)); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_HOSTNAME), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (entryHostname)))); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_USERNAME), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (entryUsername)))); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_PASSWORD), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (entryPassword)))); + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_MAILBOX), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (entryMailbox)))); + + // Variable used to update credentials + current_username = (gchar *) g_hash_table_lookup (currentAccount->properties, g_strdup (ACCOUNT_USERNAME)); } if (proto && strcmp (proto, "SIP") == 0) { - - if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_RESOLVE_ONCE), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce)) ? "false": "true")); - - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_REGISTRATION_EXPIRE), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(expireSpinBox)))); - - /* - // TODO: uncomment this code and implement route - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_ROUTE), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryRouteSet)))); - */ - - g_hash_table_replace(currentAccount->properties, - g_strdup(ACCOUNT_USERAGENT), - g_strdup(gtk_entry_get_text (GTK_ENTRY(entryUseragent)))); - - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox)) ? "true":"false")); - - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), - g_strdup(gtk_entry_get_text(GTK_ENTRY(stunServerEntry)))); - - g_hash_table_replace(currentAccount->properties, g_strdup(PUBLISHED_SAMEAS_LOCAL), g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton)) ? "true":"false")); - - if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) { - - g_hash_table_replace(currentAccount->properties, - g_strdup(PUBLISHED_PORT), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedPortSpinBox)))); - - g_hash_table_replace(currentAccount->properties, - g_strdup(PUBLISHED_ADDRESS), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedAddressEntry)))); - } - else { - - g_hash_table_replace(currentAccount->properties, - g_strdup(PUBLISHED_PORT), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)))); - local_interface = g_strdup((gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo))); - - published_address = dbus_get_address_from_interface_name(local_interface); - - g_hash_table_replace(currentAccount->properties, - g_strdup(PUBLISHED_ADDRESS), - published_address); - } - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(overrtp))) { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_DTMF_TYPE), g_strdup(OVERRTP)); - } - else { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_DTMF_TYPE), g_strdup(SIPINFO)); - } - - gchar* keyExchange = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)); - - if (g_strcasecmp(keyExchange, "ZRTP") == 0) { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true")); - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP)); - } - - else if(g_strcasecmp(keyExchange, "SDES") == 0) { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true")); - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(SDES)); - } - - else { - g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("false")); - } - - g_hash_table_replace(currentAccount->properties, g_strdup(TLS_ENABLE), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox)) ? "true":"false")); - } - - gboolean toneEnabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableTone)); - g_hash_table_replace(currentAccount->properties, - g_strdup(CONFIG_RINGTONE_ENABLED), - g_strdup(toneEnabled ? "true" : "false")); - - - g_hash_table_replace(currentAccount->properties, - g_strdup(CONFIG_RINGTONE_PATH), - g_strdup((gchar *)gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( fileChooser )))); - - g_hash_table_replace(currentAccount->properties, - g_strdup(LOCAL_INTERFACE), - g_strdup((gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo)))); - - g_hash_table_replace(currentAccount->properties, - g_strdup(LOCAL_PORT), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)))); + + if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { + + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_RESOLVE_ONCE), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entryResolveNameOnlyOnce)) ? "false": "true")); + + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_REGISTRATION_EXPIRE), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (expireSpinBox)))); + + /* + // TODO: uncomment this code and implement route + g_hash_table_replace(currentAccount->properties, + g_strdup(ACCOUNT_ROUTE), + g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryRouteSet)))); + */ + + g_hash_table_replace (currentAccount->properties, + g_strdup (ACCOUNT_USERAGENT), + g_strdup (gtk_entry_get_text (GTK_ENTRY (entryUseragent)))); + + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_SIP_STUN_ENABLED), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (useStunCheckBox)) ? "true":"false")); + + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_SIP_STUN_SERVER), + g_strdup (gtk_entry_get_text (GTK_ENTRY (stunServerEntry)))); + + g_hash_table_replace (currentAccount->properties, g_strdup (PUBLISHED_SAMEAS_LOCAL), g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton)) ? "true":"false")); + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) { + + g_hash_table_replace (currentAccount->properties, + g_strdup (PUBLISHED_PORT), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (publishedPortSpinBox)))); + + g_hash_table_replace (currentAccount->properties, + g_strdup (PUBLISHED_ADDRESS), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (publishedAddressEntry)))); + } else { + + g_hash_table_replace (currentAccount->properties, + g_strdup (PUBLISHED_PORT), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (localPortSpinBox)))); + local_interface = g_strdup ( (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo))); + + published_address = dbus_get_address_from_interface_name (local_interface); + + g_hash_table_replace (currentAccount->properties, + g_strdup (PUBLISHED_ADDRESS), + published_address); + } + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (overrtp))) { + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_DTMF_TYPE), g_strdup (OVERRTP)); + } else { + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_DTMF_TYPE), g_strdup (SIPINFO)); + } + + gchar* keyExchange = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)); + + if (g_strcasecmp (keyExchange, "ZRTP") == 0) { + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_SRTP_ENABLED), g_strdup ("true")); + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_KEY_EXCHANGE), g_strdup (ZRTP)); + } + + else if (g_strcasecmp (keyExchange, "SDES") == 0) { + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_SRTP_ENABLED), g_strdup ("true")); + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_KEY_EXCHANGE), g_strdup (SDES)); + } + + else { + g_hash_table_replace (currentAccount->properties, g_strdup (ACCOUNT_SRTP_ENABLED), g_strdup ("false")); + } + + g_hash_table_replace (currentAccount->properties, g_strdup (TLS_ENABLE), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (useSipTlsCheckBox)) ? "true":"false")); + } + + gboolean toneEnabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enableTone)); + g_hash_table_replace (currentAccount->properties, + g_strdup (CONFIG_RINGTONE_ENABLED), + g_strdup (toneEnabled ? "true" : "false")); + + + g_hash_table_replace (currentAccount->properties, + g_strdup (CONFIG_RINGTONE_PATH), + g_strdup ( (gchar *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser)))); + + g_hash_table_replace (currentAccount->properties, + g_strdup (LOCAL_INTERFACE), + g_strdup ( (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo)))); + + g_hash_table_replace (currentAccount->properties, + g_strdup (LOCAL_PORT), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (localPortSpinBox)))); } - - if (currentProtocol && strcmp(currentProtocol, "SIP") == 0) { - - /* Set new credentials if any */ - DEBUG("Config: Setting credentials"); - if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { - - /* This hack is necessary because of the way the - * configuration file is made (.ini at that time). - * and deleting account per account is too much - * of a trouble. - */ - dbus_delete_all_credential(currentAccount); - - DEBUG("Config: Get new credentials"); - GPtrArray * credential = getNewCredential(currentAccount->properties); - currentAccount->credential_information = credential; - if(currentAccount->credential_information != NULL) { - int i; - for(i = 0; i < currentAccount->credential_information->len; i++) { - DEBUG("Create new credential"); - dbus_set_credential(currentAccount, i); - } - // dbus_set_number_of_credential(currentAccount, currentAccount->credential_information->len); - } - } + + if (currentProtocol && strcmp (currentProtocol, "SIP") == 0) { + + /* Set new credentials if any */ + DEBUG ("Config: Setting credentials"); + + if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { + + /* This hack is necessary because of the way the + * configuration file is made (.ini at that time). + * and deleting account per account is too much + * of a trouble. + */ + dbus_delete_all_credential (currentAccount); + + DEBUG ("Config: Get new credentials"); + GPtrArray * credential = getNewCredential (currentAccount->properties); + currentAccount->credential_information = credential; + + if (currentAccount->credential_information != NULL) { + guint i; + + for (i = 0; i < currentAccount->credential_information->len; i++) { + DEBUG ("Create new credential"); + dbus_set_credential (currentAccount, i); + } + } + } } /** @todo Verify if it's the best condition to check */ - if (g_strcasecmp(currentAccount->accountID, "new") == 0) { - dbus_add_account(currentAccount); - } - else { - dbus_set_account_details(currentAccount); + if (g_strcasecmp (currentAccount->accountID, "new") == 0) { + dbus_add_account (currentAccount); + } else { + dbus_set_account_details (currentAccount); } - + // Perpetuate changes to the deamon codec_list_update_to_daemon (currentAccount); - - gtk_widget_destroy (GTK_WIDGET(dialog)); -} -GtkWidget* create_direct_ip_calls_tab (account_t **a) { + gtk_widget_destroy (GTK_WIDGET (dialog)); +} - GtkWidget *ret, *frame, *label; - gchar *description; +GtkWidget* create_direct_ip_calls_tab (account_t **a) +{ + + GtkWidget *ret, *frame, *label; + gchar *description; - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - description = g_markup_printf_escaped(_("This profile is used when you want to reach a remote peer simply by typing a sip URI such as <b>sip:remotepeer</b>. The settings you define here will also be used if no account can be matched to an incoming or outgoing call.")); - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), description); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (ret), label, FALSE, FALSE, 0); + description = g_markup_printf_escaped (_ ("This profile is used when you want to reach a remote peer simply by typing a sip URI such as <b>sip:remotepeer</b>. The settings you define here will also be used if no account can be matched to an incoming or outgoing call.")); + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), description); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (ret), label, FALSE, FALSE, 0); - GtkRequisition requisition; - gtk_widget_size_request (GTK_WIDGET (ret), &requisition); - gtk_widget_set_size_request (GTK_WIDGET (label), 350, -1); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + GtkRequisition requisition; + gtk_widget_size_request (GTK_WIDGET (ret), &requisition); + gtk_widget_set_size_request (GTK_WIDGET (label), 350, -1); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - frame = create_network (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + frame = create_network (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - frame = create_security_widget (a); - gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + frame = create_security_widget (a); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); - gtk_widget_show_all (ret); - return ret; + gtk_widget_show_all (ret); + return ret; } diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.h b/sflphone-client-gnome/src/config/accountconfigdialog.h index dee7c8d33e3742dbc8600985d8d480f7a2653531..ecfd97cf1b9c9d1c1751f98935b47539f2b5ed0d 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.h +++ b/sflphone-client-gnome/src/config/accountconfigdialog.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,7 +28,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __ACCOUNTWINDOW_H__ #define __ACCOUNTWINDOW_H__ /** @file accountconfigdialog.h @@ -39,10 +39,10 @@ #include "preferencesdialog.h" #include "accountlist.h" -/** - * Display the main account widget +/** + * Display the main account widget * @param a The account you want to edit or null for a new account - */ + */ void show_account_window (account_t *a); GtkWidget* create_registration_expire (account_t **a); @@ -50,4 +50,4 @@ GtkWidget* create_registration_expire (account_t **a); GtkWidget* create_direct_ip_calls_tab (account_t **a); -#endif +#endif diff --git a/sflphone-client-gnome/src/config/accountlistconfigdialog.c b/sflphone-client-gnome/src/config/accountlistconfigdialog.c index 0c6a975e8e342d29ee5d039adf1729361034ed48..eddf58f7dc177ce82b1f8d51f6d8200f5e59bfd0 100644 --- a/sflphone-client-gnome/src/config/accountlistconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountlistconfigdialog.c @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -36,6 +36,7 @@ #include <actions.h> #include <utils.h> #include <string.h> +#include <libgnome/gnome-help.h> #define CONTEXT_ID_REGISTRATION 0 @@ -50,49 +51,83 @@ GtkListStore * accountStore; GtkDialog * accountListDialog = NULL; -account_t * selectedAccount = NULL; +account_t * selectedAccount = NULL; // Account properties enum { - COLUMN_ACCOUNT_ALIAS, - COLUMN_ACCOUNT_TYPE, - COLUMN_ACCOUNT_STATUS, - COLUMN_ACCOUNT_ACTIVE, - COLUMN_ACCOUNT_DATA, - COLUMN_ACCOUNT_COUNT + COLUMN_ACCOUNT_ALIAS, + COLUMN_ACCOUNT_TYPE, + COLUMN_ACCOUNT_STATUS, + COLUMN_ACCOUNT_ACTIVE, + COLUMN_ACCOUNT_DATA, + COLUMN_ACCOUNT_COUNT }; +/** + * Delete an account + */ +static void delete_account_cb (void) +{ + + if (selectedAccount != NULL) { + dbus_remove_account (selectedAccount->accountID); + } +} + + +/** + * Edit an account + */ +static void edit_account_cb (void) +{ + + if (selectedAccount != NULL) { + show_account_window (selectedAccount); + } +} + +/** + * Add an account + */ +static void add_account_cb (void) +{ + + show_account_window (NULL); +} + /** * Fills the treelist with accounts */ -void account_list_config_dialog_fill() { +void account_list_config_dialog_fill() +{ + + if (accountListDialog == NULL) { + DEBUG ("Dialog is not opened"); + return; + } - if (accountListDialog == NULL) { - DEBUG("Dialog is not opened"); - return; - } + GtkTreeIter iter; - GtkTreeIter iter; + gtk_list_store_clear (accountStore); - gtk_list_store_clear(accountStore); + unsigned int i; - unsigned int i; - for(i = 0; i < account_list_get_size(); i++) { - account_t * a = account_list_get_nth (i); + for (i = 0; i < account_list_get_size(); i++) { + account_t * a = account_list_get_nth (i); - if (a) { - gtk_list_store_append (accountStore, &iter); + if (a) { + gtk_list_store_append (accountStore, &iter); - DEBUG("Filling accounts: Account is enabled :%s", g_hash_table_lookup(a->properties, ACCOUNT_ENABLED)); + DEBUG ("Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED)); - gtk_list_store_set(accountStore, &iter, - COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup(a->properties, ACCOUNT_ALIAS), // Name - COLUMN_ACCOUNT_TYPE, g_hash_table_lookup(a->properties, ACCOUNT_TYPE), // Protocol - COLUMN_ACCOUNT_STATUS, account_state_name(a->state), // Status - COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"true") == 0)? TRUE:FALSE, // Enable/Disable - COLUMN_ACCOUNT_DATA, a, // Pointer - -1); - } - } + gtk_list_store_set (accountStore, &iter, + COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup (a->properties, ACCOUNT_ALIAS), // Name + COLUMN_ACCOUNT_TYPE, g_hash_table_lookup (a->properties, ACCOUNT_TYPE), // Protocol + COLUMN_ACCOUNT_STATUS, account_state_name (a->state), // Status + COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp (g_hash_table_lookup (a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable + COLUMN_ACCOUNT_DATA, a, // Pointer + -1); + } + } } @@ -101,497 +136,473 @@ void account_list_config_dialog_fill() { /** * Call back when the user click on an account in the list */ - static void -select_account_cb(GtkTreeSelection *selection, GtkTreeModel *model) +static void +select_account_cb (GtkTreeSelection *selection, GtkTreeModel *model) { - GtkTreeIter iter; - GValue val; - gchar *state; - - memset (&val, 0, sizeof(val)); - if (!gtk_tree_selection_get_selected(selection, &model, &iter)) - { - selectedAccount = NULL; - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(editButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), FALSE); - return; - } - - // The Gvalue will be initialized in the following function - gtk_tree_model_get_value(model, &iter, COLUMN_ACCOUNT_DATA, &val); - - selectedAccount = (account_t*)g_value_get_pointer(&val); - g_value_unset(&val); - - if(selectedAccount != NULL) { - gtk_widget_set_sensitive(GTK_WIDGET(editButton), TRUE); - if (g_strcasecmp (selectedAccount->accountID, IP2IP) != 0) { - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), TRUE); - - /* Update status bar about current registration state */ - gtk_statusbar_pop (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION); - - if (selectedAccount->protocol_state_description != NULL - && selectedAccount->protocol_state_code != 0) { - - gchar * response = g_strdup_printf( - _("Server returned \"%s\" (%d)"), - selectedAccount->protocol_state_description, - selectedAccount->protocol_state_code); - gchar * message = g_strconcat( - account_state_name(selectedAccount->state), - ". ", - response, - NULL); - - gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, message); - - g_free(response); - g_free(message); - - } else { - state = (gchar*) account_state_name (selectedAccount->state); - gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, state); - } - } - else { - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), FALSE); - } - } - - DEBUG("Selecting account in account window"); + GtkTreeIter iter; + GValue val; + gchar *state; + + memset (&val, 0, sizeof (val)); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { + selectedAccount = NULL; + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveUpButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveDownButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (editButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (deleteButton), FALSE); + return; + } + + // The Gvalue will be initialized in the following function + gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_DATA, &val); + + selectedAccount = (account_t*) g_value_get_pointer (&val); + g_value_unset (&val); + + if (selectedAccount != NULL) { + gtk_widget_set_sensitive (GTK_WIDGET (editButton), TRUE); + + if (g_strcasecmp (selectedAccount->accountID, IP2IP) != 0) { + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveUpButton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveDownButton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (deleteButton), TRUE); + + /* Update status bar about current registration state */ + gtk_statusbar_pop (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION); + + if (selectedAccount->protocol_state_description != NULL + && selectedAccount->protocol_state_code != 0) { + + gchar * response = g_strdup_printf ( + _ ("Server returned \"%s\" (%d)"), + selectedAccount->protocol_state_description, + selectedAccount->protocol_state_code); + gchar * message = g_strconcat ( + account_state_name (selectedAccount->state), + ". ", + response, + NULL); + + gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, message); + + g_free (response); + g_free (message); + + } else { + state = (gchar*) account_state_name (selectedAccount->state); + gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, state); + } + } else { + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveUpButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveDownButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (deleteButton), FALSE); + } + } + + DEBUG ("Selecting account in account window"); } -static void enable_account_cb (GtkCellRendererToggle *rend UNUSED, gchar* path, gpointer data ) { - - GtkTreeIter iter; - GtkTreePath *treePath; - GtkTreeModel *model; - gboolean enable; - account_t* acc ; - - // The IP2IP profile can't be disabled - if (g_strcasecmp (path, "0") == 0) - return; - - // Get pointer on object - treePath = gtk_tree_path_new_from_string(path); - model = gtk_tree_view_get_model(GTK_TREE_VIEW(data)); - gtk_tree_model_get_iter(model, &iter, treePath); - gtk_tree_model_get(model, &iter, - COLUMN_ACCOUNT_ACTIVE, &enable, - COLUMN_ACCOUNT_DATA, &acc, - -1); - - enable = !enable; - - DEBUG("Account is %d enabled", enable); - // Store value - gtk_list_store_set(GTK_LIST_STORE(model), &iter, - COLUMN_ACCOUNT_ACTIVE, enable, - -1); - - // Modify account state - gchar * registrationState; - if (enable == TRUE) { - registrationState = g_strdup("true"); - } else { - registrationState = g_strdup("false"); - } - DEBUG("Replacing with %s", registrationState); - g_hash_table_replace( acc->properties , g_strdup(ACCOUNT_ENABLED), registrationState); - - dbus_send_register(acc->accountID, enable); +static void enable_account_cb (GtkCellRendererToggle *rend UNUSED, gchar* path, gpointer data) +{ + + GtkTreeIter iter; + GtkTreePath *treePath; + GtkTreeModel *model; + gboolean enable; + account_t* acc ; + + // The IP2IP profile can't be disabled + if (g_strcasecmp (path, "0") == 0) + return; + + // Get pointer on object + treePath = gtk_tree_path_new_from_string (path); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (data)); + gtk_tree_model_get_iter (model, &iter, treePath); + gtk_tree_model_get (model, &iter, + COLUMN_ACCOUNT_ACTIVE, &enable, + COLUMN_ACCOUNT_DATA, &acc, + -1); + + enable = !enable; + + DEBUG ("Account is %d enabled", enable); + // Store value + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COLUMN_ACCOUNT_ACTIVE, enable, + -1); + + // Modify account state + gchar * registrationState; + + if (enable == TRUE) { + registrationState = g_strdup ("true"); + } else { + registrationState = g_strdup ("false"); + } + + DEBUG ("Replacing with %s", registrationState); + g_hash_table_replace (acc->properties , g_strdup (ACCOUNT_ENABLED), registrationState); + + dbus_send_register (acc->accountID, enable); } /** * Move account in list depending on direction and selected account */ -static void account_move (gboolean moveUp, gpointer data) { - - GtkTreeIter iter; - GtkTreeIter *iter2; - GtkTreeView *treeView; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreePath *treePath; - gchar *path; - - // Get view, model and selection of codec store - treeView = GTK_TREE_VIEW (data); - model = gtk_tree_view_get_model (GTK_TREE_VIEW(treeView)); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(treeView)); - - // Find selected iteration and create a copy - gtk_tree_selection_get_selected (GTK_TREE_SELECTION(selection), &model, &iter); - iter2 = gtk_tree_iter_copy (&iter); - - // Find path of iteration - path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(model), &iter); - - // The first real account in the list can't move up because of the IP2IP account - // It can still move down though - if (g_strcasecmp (path, "1") == 0 && moveUp) - return; - - treePath = gtk_tree_path_new_from_string(path); - gint *indices = gtk_tree_path_get_indices(treePath); - gint indice = indices[0]; - - // Depending on button direction get new path - if(moveUp) - gtk_tree_path_prev(treePath); - else - gtk_tree_path_next(treePath); - gtk_tree_model_get_iter(model, &iter, treePath); - - // Swap iterations if valid - if(gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter)) - gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter2); - - // Scroll to new position - gtk_tree_view_scroll_to_cell (treeView, treePath, NULL, FALSE, 0, 0); - - // Free resources - gtk_tree_path_free(treePath); - gtk_tree_iter_free(iter2); - g_free(path); - - // Perpetuate changes in account queue - if(moveUp) - account_list_move_up(indice); - else - account_list_move_down(indice); - - - // Set the order in the configuration file - dbus_set_accounts_order (account_list_get_ordered_list ()); +static void account_move (gboolean moveUp, gpointer data) +{ + + GtkTreeIter iter; + GtkTreeIter *iter2; + GtkTreeView *treeView; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreePath *treePath; + gchar *path; + + // Get view, model and selection of codec store + treeView = GTK_TREE_VIEW (data); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeView)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeView)); + + // Find selected iteration and create a copy + gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter); + iter2 = gtk_tree_iter_copy (&iter); + + // Find path of iteration + path = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), &iter); + + // The first real account in the list can't move up because of the IP2IP account + // It can still move down though + if (g_strcasecmp (path, "1") == 0 && moveUp) + return; + + treePath = gtk_tree_path_new_from_string (path); + gint *indices = gtk_tree_path_get_indices (treePath); + gint indice = indices[0]; + + // Depending on button direction get new path + if (moveUp) + gtk_tree_path_prev (treePath); + else + gtk_tree_path_next (treePath); + + gtk_tree_model_get_iter (model, &iter, treePath); + + // Swap iterations if valid + if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (model), &iter)) + gtk_list_store_swap (GTK_LIST_STORE (model), &iter, iter2); + + // Scroll to new position + gtk_tree_view_scroll_to_cell (treeView, treePath, NULL, FALSE, 0, 0); + + // Free resources + gtk_tree_path_free (treePath); + gtk_tree_iter_free (iter2); + g_free (path); + + // Perpetuate changes in account queue + if (moveUp) + account_list_move_up (indice); + else + account_list_move_down (indice); + + + // Set the order in the configuration file + dbus_set_accounts_order (account_list_get_ordered_list ()); } /** * Called from move up account button signal */ - static void -account_move_up_cb(GtkButton *button UNUSED, gpointer data) +static void +account_move_up_cb (GtkButton *button UNUSED, gpointer data) { - // Change tree view ordering and get indice changed - account_move(TRUE, data); + // Change tree view ordering and get indice changed + account_move (TRUE, data); } /** * Called from move down account button signal */ - static void -account_move_down_cb(GtkButton *button UNUSED, gpointer data) +static void +account_move_down_cb (GtkButton *button UNUSED, gpointer data) { - // Change tree view ordering and get indice changed - account_move(FALSE, data); + // Change tree view ordering and get indice changed + account_move (FALSE, data); } - static void -help_contents_cb (GtkWidget * widget, - gpointer data UNUSED) +static void +help_contents_cb (GtkWidget * widget UNUSED, + gpointer data UNUSED) { - GError *error = NULL; + GError *error = NULL; - //gboolean success = gtk_show_uri (NULL, "ghelp: sflphone.xml", GDK_CURRENT_TIME, &error); - gnome_help_display ("sflphone.xml", "accounts", &error); + gnome_help_display ("sflphone.xml", "accounts", &error); - if (error != NULL) - { - g_warning ("%s", error->message); + if (error != NULL) { + g_warning ("%s", error->message); - g_error_free (error); - } + g_error_free (error); + } } - static void -close_dialog_cb (GtkWidget * widget, - gpointer data UNUSED) +static void +close_dialog_cb (GtkWidget * widget UNUSED, + gpointer data UNUSED) { - gtk_dialog_response(GTK_DIALOG(accountListDialog), GTK_RESPONSE_ACCEPT); + gtk_dialog_response (GTK_DIALOG (accountListDialog), GTK_RESPONSE_ACCEPT); } -void highlight_ip_profile (GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { - - GValue val; - account_t *current; - - memset (&val, 0, sizeof(val)); - gtk_tree_model_get_value(tree_model, iter, COLUMN_ACCOUNT_DATA, &val); - current = (account_t*) g_value_get_pointer(&val); - - g_value_unset (&val); - - if (current != NULL) { +void highlight_ip_profile (GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data UNUSED) +{ - // Make the first line appear differently - (g_strcasecmp (current->accountID, IP2IP) == 0) ? g_object_set (G_OBJECT (rend), "weight", PANGO_WEIGHT_THIN, - "style", PANGO_STYLE_ITALIC, - "stretch", PANGO_STRETCH_ULTRA_EXPANDED, - "scale", 0.95, - NULL) : - g_object_set (G_OBJECT (rend), "weight", PANGO_WEIGHT_MEDIUM, - "style", PANGO_STYLE_NORMAL, - "stretch", PANGO_STRETCH_NORMAL, - "scale", 1.0, - NULL) ; - } + GValue val; + account_t *current; + + memset (&val, 0, sizeof (val)); + gtk_tree_model_get_value (tree_model, iter, COLUMN_ACCOUNT_DATA, &val); + current = (account_t*) g_value_get_pointer (&val); + + g_value_unset (&val); + + if (current != NULL) { + + // Make the first line appear differently + (g_strcasecmp (current->accountID, IP2IP) == 0) ? g_object_set (G_OBJECT (rend), "weight", PANGO_WEIGHT_THIN, + "style", PANGO_STYLE_ITALIC, + "stretch", PANGO_STRETCH_ULTRA_EXPANDED, + "scale", 0.95, + NULL) : + g_object_set (G_OBJECT (rend), "weight", PANGO_WEIGHT_MEDIUM, + "style", PANGO_STYLE_NORMAL, + "stretch", PANGO_STRETCH_NORMAL, + "scale", 1.0, + NULL) ; + } } -void highlight_registration (GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { +void highlight_registration (GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data UNUSED) +{ - GValue val; - account_t *current; - GdkColor green = {0, 255, 0, 0}; + GValue val; + account_t *current; - memset (&val, 0, sizeof(val)); - gtk_tree_model_get_value(tree_model, iter, COLUMN_ACCOUNT_DATA, &val); - current = (account_t*) g_value_get_pointer(&val); + memset (&val, 0, sizeof (val)); + gtk_tree_model_get_value (tree_model, iter, COLUMN_ACCOUNT_DATA, &val); + current = (account_t*) g_value_get_pointer (&val); - g_value_unset (&val); + g_value_unset (&val); - if (current != NULL) { - if (g_strcasecmp (current->accountID, IP2IP) != 0) { - // Color the account state: green -> registered, otherwise red - (current->state == ACCOUNT_STATE_REGISTERED) ? g_object_set (G_OBJECT (rend), "foreground", "Dark Green", NULL) : - g_object_set (G_OBJECT (rend), "foreground", "Dark Red", NULL); - } - else - g_object_set (G_OBJECT (rend), "foreground", "Black", NULL); - } + if (current != NULL) { + if (g_strcasecmp (current->accountID, IP2IP) != 0) { + // Color the account state: green -> registered, otherwise red + (current->state == ACCOUNT_STATE_REGISTERED) ? g_object_set (G_OBJECT (rend), "foreground", "Dark Green", NULL) : + g_object_set (G_OBJECT (rend), "foreground", "Dark Red", NULL); + } else + g_object_set (G_OBJECT (rend), "foreground", "Black", NULL); + } } /** * Account settings tab */ -GtkWidget* create_account_list(GtkDialog * dialog) { - - GtkWidget *table, *scrolledWindow, *buttonBox; - GtkCellRenderer *renderer; - GtkTreeView * treeView; - GtkTreeViewColumn *treeViewColumn; - GtkTreeSelection *treeSelection; - GtkRequisition requisition; - - selectedAccount = NULL; - - table = gtk_table_new (1, 2, FALSE/* homogeneous */); - gtk_table_set_col_spacings(GTK_TABLE(table), 10); - gtk_container_set_border_width (GTK_CONTAINER (table), 10); - - scrolledWindow = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_SHADOW_IN); - gtk_table_attach (GTK_TABLE(table), scrolledWindow, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - accountStore = gtk_list_store_new(COLUMN_ACCOUNT_COUNT, - G_TYPE_STRING, // Name - G_TYPE_STRING, // Protocol - G_TYPE_STRING, // Status - G_TYPE_BOOLEAN, // Enabled / Disabled - G_TYPE_POINTER // Pointer to the Object - ); - - account_list_config_dialog_fill(); - - treeView = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL(accountStore))); - treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW (treeView)); - g_signal_connect(G_OBJECT (treeSelection), "changed", - G_CALLBACK (select_account_cb), - accountStore); - - renderer = gtk_cell_renderer_toggle_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("Enabled", renderer, "active", COLUMN_ACCOUNT_ACTIVE , NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); - g_signal_connect (G_OBJECT(renderer) , "toggled" , G_CALLBACK (enable_account_cb), (gpointer)treeView ); - - // gtk_cell_renderer_toggle_set_activatable (renderer, FALSE); - - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes ("Alias", - renderer, - "markup", COLUMN_ACCOUNT_ALIAS, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeView), treeViewColumn); - - // A double click on the account line opens the window to edit the account - g_signal_connect( G_OBJECT( treeView ) , "row-activated" , G_CALLBACK( edit_account_cb ) , NULL ); - gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); - - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Protocol"), - renderer, - "markup", COLUMN_ACCOUNT_TYPE, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeView), treeViewColumn); - gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); - - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Status"), - renderer, - "markup", COLUMN_ACCOUNT_STATUS, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(treeView), treeViewColumn); - // Highlight IP profile - gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); - // Highlight account registration state - gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_registration, NULL, NULL); - - g_object_unref(G_OBJECT(accountStore)); - - gtk_container_add (GTK_CONTAINER(scrolledWindow), GTK_WIDGET (treeView)); - - /* The buttons to press! */ - buttonBox = gtk_vbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(buttonBox), 10); - gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_START); - gtk_table_attach (GTK_TABLE(table), buttonBox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - accountMoveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP); - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), accountMoveUpButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(accountMoveUpButton), "clicked", G_CALLBACK(account_move_up_cb), treeView); - - accountMoveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); - gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), accountMoveDownButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(accountMoveDownButton), "clicked", G_CALLBACK(account_move_down_cb), treeView); - - addButton = gtk_button_new_from_stock (GTK_STOCK_ADD); - g_signal_connect_swapped(G_OBJECT(addButton), "clicked", - G_CALLBACK(add_account_cb), NULL); - gtk_box_pack_start(GTK_BOX(buttonBox), addButton, FALSE, FALSE, 0); - - editButton = gtk_button_new_from_stock (GTK_STOCK_EDIT); - gtk_widget_set_sensitive(GTK_WIDGET(editButton), FALSE); - g_signal_connect_swapped(G_OBJECT(editButton), "clicked", - G_CALLBACK(edit_account_cb), NULL); - gtk_box_pack_start(GTK_BOX(buttonBox), editButton, FALSE, FALSE, 0); - - deleteButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), FALSE); - g_signal_connect_swapped(G_OBJECT(deleteButton), "clicked", - G_CALLBACK(delete_account_cb), NULL); - gtk_box_pack_start(GTK_BOX(buttonBox), deleteButton, FALSE, FALSE, 0); - - /* help and close buttons */ - GtkWidget * buttonHbox = gtk_hbutton_box_new(); - gtk_table_attach(GTK_TABLE(table), buttonHbox, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10); - - GtkWidget * helpButton = gtk_button_new_from_stock (GTK_STOCK_HELP); - g_signal_connect_swapped(G_OBJECT(helpButton), "clicked", - G_CALLBACK(help_contents_cb), NULL); - gtk_box_pack_start(GTK_BOX(buttonHbox), helpButton, FALSE, FALSE, 0); - - GtkWidget * closeButton = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - g_signal_connect_swapped(G_OBJECT(closeButton), "clicked", G_CALLBACK(close_dialog_cb), NULL); - gtk_box_pack_start(GTK_BOX(buttonHbox), closeButton, FALSE, FALSE, 0); - - gtk_widget_show_all(table); - // account_list_config_dialog_fill(); - - /* Resize the scrolledWindow for a better view */ - gtk_widget_size_request(GTK_WIDGET(treeView), &requisition); - gtk_widget_set_size_request(GTK_WIDGET(scrolledWindow), requisition.width + 20, requisition.height); - GtkRequisition requisitionButton; - gtk_widget_size_request(GTK_WIDGET(deleteButton), &requisitionButton); - gtk_widget_set_size_request(GTK_WIDGET(closeButton), requisitionButton.width, -1); - gtk_widget_set_size_request(GTK_WIDGET(helpButton), requisitionButton.width, -1); - - gtk_widget_show_all(table); - - return table; +GtkWidget* create_account_list (GtkDialog * dialog UNUSED) +{ + + GtkWidget *table, *scrolledWindow, *buttonBox; + GtkCellRenderer *renderer; + GtkTreeView * treeView; + GtkTreeViewColumn *treeViewColumn; + GtkTreeSelection *treeSelection; + GtkRequisition requisition; + + selectedAccount = NULL; + + table = gtk_table_new (1, 2, FALSE/* homogeneous */); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + + scrolledWindow = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindow), GTK_SHADOW_IN); + gtk_table_attach (GTK_TABLE (table), scrolledWindow, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + accountStore = gtk_list_store_new (COLUMN_ACCOUNT_COUNT, + G_TYPE_STRING, // Name + G_TYPE_STRING, // Protocol + G_TYPE_STRING, // Status + G_TYPE_BOOLEAN, // Enabled / Disabled + G_TYPE_POINTER // Pointer to the Object + ); + + account_list_config_dialog_fill(); + + treeView = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (accountStore))); + treeSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeView)); + g_signal_connect (G_OBJECT (treeSelection), "changed", + G_CALLBACK (select_account_cb), + accountStore); + + renderer = gtk_cell_renderer_toggle_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes ("Enabled", renderer, "active", COLUMN_ACCOUNT_ACTIVE , NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), treeViewColumn); + g_signal_connect (G_OBJECT (renderer) , "toggled" , G_CALLBACK (enable_account_cb), (gpointer) treeView); + + // gtk_cell_renderer_toggle_set_activatable (renderer, FALSE); + + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes ("Alias", + renderer, + "markup", COLUMN_ACCOUNT_ALIAS, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), treeViewColumn); + + // A double click on the account line opens the window to edit the account + g_signal_connect (G_OBJECT (treeView) , "row-activated" , G_CALLBACK (edit_account_cb) , NULL); + gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); + + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Protocol"), + renderer, + "markup", COLUMN_ACCOUNT_TYPE, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), treeViewColumn); + gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); + + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Status"), + renderer, + "markup", COLUMN_ACCOUNT_STATUS, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), treeViewColumn); + // Highlight IP profile + gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_ip_profile, NULL, NULL); + // Highlight account registration state + gtk_tree_view_column_set_cell_data_func (treeViewColumn, renderer, highlight_registration, NULL, NULL); + + g_object_unref (G_OBJECT (accountStore)); + + gtk_container_add (GTK_CONTAINER (scrolledWindow), GTK_WIDGET (treeView)); + + /* The buttons to press! */ + buttonBox = gtk_vbutton_box_new(); + gtk_box_set_spacing (GTK_BOX (buttonBox), 10); + gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonBox), GTK_BUTTONBOX_START); + gtk_table_attach (GTK_TABLE (table), buttonBox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + accountMoveUpButton = gtk_button_new_from_stock (GTK_STOCK_GO_UP); + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveUpButton), FALSE); + gtk_box_pack_start (GTK_BOX (buttonBox), accountMoveUpButton, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (accountMoveUpButton), "clicked", G_CALLBACK (account_move_up_cb), treeView); + + accountMoveDownButton = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN); + gtk_widget_set_sensitive (GTK_WIDGET (accountMoveDownButton), FALSE); + gtk_box_pack_start (GTK_BOX (buttonBox), accountMoveDownButton, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (accountMoveDownButton), "clicked", G_CALLBACK (account_move_down_cb), treeView); + + addButton = gtk_button_new_from_stock (GTK_STOCK_ADD); + g_signal_connect_swapped (G_OBJECT (addButton), "clicked", + G_CALLBACK (add_account_cb), NULL); + gtk_box_pack_start (GTK_BOX (buttonBox), addButton, FALSE, FALSE, 0); + + editButton = gtk_button_new_from_stock (GTK_STOCK_EDIT); + gtk_widget_set_sensitive (GTK_WIDGET (editButton), FALSE); + g_signal_connect_swapped (G_OBJECT (editButton), "clicked", + G_CALLBACK (edit_account_cb), NULL); + gtk_box_pack_start (GTK_BOX (buttonBox), editButton, FALSE, FALSE, 0); + + deleteButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE); + gtk_widget_set_sensitive (GTK_WIDGET (deleteButton), FALSE); + g_signal_connect_swapped (G_OBJECT (deleteButton), "clicked", + G_CALLBACK (delete_account_cb), NULL); + gtk_box_pack_start (GTK_BOX (buttonBox), deleteButton, FALSE, FALSE, 0); + + /* help and close buttons */ + GtkWidget * buttonHbox = gtk_hbutton_box_new(); + gtk_table_attach (GTK_TABLE (table), buttonHbox, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10); + + GtkWidget * helpButton = gtk_button_new_from_stock (GTK_STOCK_HELP); + g_signal_connect_swapped (G_OBJECT (helpButton), "clicked", + G_CALLBACK (help_contents_cb), NULL); + gtk_box_pack_start (GTK_BOX (buttonHbox), helpButton, FALSE, FALSE, 0); + + GtkWidget * closeButton = gtk_button_new_from_stock (GTK_STOCK_CLOSE); + g_signal_connect_swapped (G_OBJECT (closeButton), "clicked", G_CALLBACK (close_dialog_cb), NULL); + gtk_box_pack_start (GTK_BOX (buttonHbox), closeButton, FALSE, FALSE, 0); + + gtk_widget_show_all (table); + // account_list_config_dialog_fill(); + + /* Resize the scrolledWindow for a better view */ + gtk_widget_size_request (GTK_WIDGET (treeView), &requisition); + gtk_widget_set_size_request (GTK_WIDGET (scrolledWindow), requisition.width + 20, requisition.height); + GtkRequisition requisitionButton; + gtk_widget_size_request (GTK_WIDGET (deleteButton), &requisitionButton); + gtk_widget_set_size_request (GTK_WIDGET (closeButton), requisitionButton.width, -1); + gtk_widget_set_size_request (GTK_WIDGET (helpButton), requisitionButton.width, -1); + + gtk_widget_show_all (table); + + return table; } - void -show_account_list_config_dialog(void) +void +show_account_list_config_dialog (void) { - GtkWidget * accountFrame; - GtkWidget * tab; - - accountListDialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Accounts"), - GTK_WINDOW(get_main_window()), - GTK_DIALOG_DESTROY_WITH_PARENT, - NULL)); - - /* Set window properties */ - gtk_dialog_set_has_separator(accountListDialog, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(accountListDialog), 0); - gtk_window_set_resizable(GTK_WINDOW(accountListDialog), FALSE); - - gnome_main_section_new (_("Configured Accounts"), &accountFrame); - gtk_box_pack_start( GTK_BOX(accountListDialog->vbox ), accountFrame , TRUE, TRUE, 0); - gtk_widget_show(accountFrame); - - /* Accounts tab */ - tab = create_account_list(accountListDialog); - gtk_widget_show(tab); - gtk_container_add(GTK_CONTAINER(accountFrame), tab); - - /* Status bar for the account list */ - status_bar = gtk_statusbar_new(); - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (status_bar), FALSE); - gtk_widget_show(status_bar); - gtk_box_pack_start(GTK_BOX(accountListDialog->vbox ), status_bar, TRUE, TRUE, 0); - - int number_accounts = account_list_get_registered_accounts (); - if (number_accounts) { - gchar * message = g_strdup_printf(n_("There is %d active account", - "There are %d active accounts", number_accounts), - number_accounts); - gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, message); - g_free(message); - } else { - gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, _("You have no active account")); - } - - gtk_dialog_run(accountListDialog); - - status_bar_display_account (); - - gtk_widget_destroy(GTK_WIDGET(accountListDialog)); - - accountListDialog = NULL; - - update_actions (); -} + GtkWidget * accountFrame; + GtkWidget * tab; + accountListDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Accounts"), + GTK_WINDOW (get_main_window()), + GTK_DIALOG_DESTROY_WITH_PARENT, + NULL)); -/** - * Delete an account - */ -static void delete_account_cb (void) { - - if(selectedAccount != NULL) { - dbus_remove_account(selectedAccount->accountID); - } -} + /* Set window properties */ + gtk_dialog_set_has_separator (accountListDialog, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (accountListDialog), 0); + gtk_window_set_resizable (GTK_WINDOW (accountListDialog), FALSE); + gnome_main_section_new (_ ("Configured Accounts"), &accountFrame); + gtk_box_pack_start (GTK_BOX (accountListDialog->vbox), accountFrame , TRUE, TRUE, 0); + gtk_widget_show (accountFrame); -/** - * Edit an account - */ -static void edit_account_cb (void) { + /* Accounts tab */ + tab = create_account_list (accountListDialog); + gtk_widget_show (tab); + gtk_container_add (GTK_CONTAINER (accountFrame), tab); - if(selectedAccount != NULL) { - show_account_window (selectedAccount); - } -} + /* Status bar for the account list */ + status_bar = gtk_statusbar_new(); + gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (status_bar), FALSE); + gtk_widget_show (status_bar); + gtk_box_pack_start (GTK_BOX (accountListDialog->vbox), status_bar, TRUE, TRUE, 0); -/** - * Add an account - */ -static void add_account_cb (void) { + int number_accounts = account_list_get_registered_accounts (); + + if (number_accounts) { + gchar * message = g_strdup_printf (n_ ("There is %d active account", + "There are %d active accounts", number_accounts), + number_accounts); + gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, message); + g_free (message); + } else { + gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, _ ("You have no active account")); + } + + gtk_dialog_run (accountListDialog); - show_account_window (NULL); + status_bar_display_account (); + + gtk_widget_destroy (GTK_WIDGET (accountListDialog)); + + accountListDialog = NULL; + + update_actions (); } + diff --git a/sflphone-client-gnome/src/config/accountlistconfigdialog.h b/sflphone-client-gnome/src/config/accountlistconfigdialog.h index a1ec479f2b6d274d4b2d81b0cb5fba673e56c605..090d124962724c1104353bd724a1436f5daa0519 100644 --- a/sflphone-client-gnome/src/config/accountlistconfigdialog.h +++ b/sflphone-client-gnome/src/config/accountlistconfigdialog.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,13 +34,7 @@ #include <sflphone_const.h> -void show_account_list_config_dialog(void); -void account_list_config_dialog_fill(void); - -static void delete_account_cb (void); - -static void add_account_cb (void); - -static void edit_account_cb (void); +void show_account_list_config_dialog (void); +void account_list_config_dialog_fill (void); #endif diff --git a/sflphone-client-gnome/src/config/addressbook-config.c b/sflphone-client-gnome/src/config/addressbook-config.c index 6d3bc09c4ba566835b5ce841167641d66cf69199..fd6b13d257cbc68e095d46b3fb4488eebd8d286a 100644 --- a/sflphone-client-gnome/src/config/addressbook-config.c +++ b/sflphone-client-gnome/src/config/addressbook-config.c @@ -38,13 +38,12 @@ GtkWidget *book_tree_view; GtkWidget *photo, *cards_label, *scale_label, *scrolled_label, *scrolled_window, *scale_button, *business, *mobile, *home; -enum -{ +enum { COLUMN_BOOK_ACTIVE, COLUMN_BOOK_NAME, COLUMN_BOOK_UID }; - void -addressbook_config_load_parameters(AddressBook_Config **settings) +void +addressbook_config_load_parameters (AddressBook_Config **settings) { GHashTable *_params = NULL; @@ -57,142 +56,139 @@ addressbook_config_load_parameters(AddressBook_Config **settings) _params = (GHashTable*) dbus_get_addressbook_settings(); if (_params == NULL) { - - DEBUG("Addressbook: No parameters received, use default"); - - _settings->enable = 1; - _settings->max_results = 30; - _settings->display_contact_photo = 0; - _settings->search_phone_business = 1; - _settings->search_phone_home = 1; - _settings->search_phone_mobile = 1; - - } - else { - _settings->enable = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_ENABLE)); - _settings->max_results = (size_t) (g_hash_table_lookup(_params, ADDRESSBOOK_MAX_RESULTS)); - _settings->display_contact_photo = (size_t) (g_hash_table_lookup(_params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)); - _settings->search_phone_business = (size_t) (g_hash_table_lookup(_params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)); - _settings->search_phone_home = (size_t) (g_hash_table_lookup(_params, ADDRESSBOOK_DISPLAY_PHONE_HOME)); - _settings->search_phone_mobile = (size_t) (g_hash_table_lookup(_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)); + + DEBUG ("Addressbook: No parameters received, use default"); + + _settings->enable = 1; + _settings->max_results = 30; + _settings->display_contact_photo = 0; + _settings->search_phone_business = 1; + _settings->search_phone_home = 1; + _settings->search_phone_mobile = 1; + + } else { + _settings->enable = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_ENABLE)); + _settings->max_results = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_MAX_RESULTS)); + _settings->display_contact_photo = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)); + _settings->search_phone_business = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)); + _settings->search_phone_home = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_HOME)); + _settings->search_phone_mobile = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)); } - DEBUG("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d", - _settings->enable, _settings->max_results, _settings->display_contact_photo, - _settings->search_phone_business, _settings->search_phone_home, _settings->search_phone_mobile); + DEBUG ("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d", + _settings->enable, _settings->max_results, _settings->display_contact_photo, + _settings->search_phone_business, _settings->search_phone_home, _settings->search_phone_mobile); *settings = _settings; } - void -addressbook_config_save_parameters(void) +void +addressbook_config_save_parameters (void) { GHashTable *params = NULL; - params = g_hash_table_new(NULL, g_str_equal); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_ENABLE, - (gpointer)(size_t) addressbook_config->enable); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_MAX_RESULTS, - (gpointer)(size_t) addressbook_config->max_results); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, - (gpointer)(size_t) addressbook_config->display_contact_photo); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_BUSINESS, - (gpointer)(size_t) addressbook_config->search_phone_business); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_HOME, - (gpointer)(size_t) addressbook_config->search_phone_home); - g_hash_table_replace(params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_MOBILE, - (gpointer)(size_t) addressbook_config->search_phone_mobile); - - dbus_set_addressbook_settings(params); + params = g_hash_table_new (NULL, g_str_equal); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_ENABLE, + (gpointer) (size_t) addressbook_config->enable); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_MAX_RESULTS, + (gpointer) (size_t) addressbook_config->max_results); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, + (gpointer) (size_t) addressbook_config->display_contact_photo); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_BUSINESS, + (gpointer) (size_t) addressbook_config->search_phone_business); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_HOME, + (gpointer) (size_t) addressbook_config->search_phone_home); + g_hash_table_replace (params, (gpointer) ADDRESSBOOK_DISPLAY_PHONE_MOBILE, + (gpointer) (size_t) addressbook_config->search_phone_mobile); + + dbus_set_addressbook_settings (params); // Decrement the reference count - g_hash_table_unref(params); + g_hash_table_unref (params); } void -enable_options(){ - - if (!addressbook_config->enable) - { - DEBUG("Disable addressbook options\n"); - gtk_widget_set_sensitive(photo, FALSE); - gtk_widget_set_sensitive(scrolled_label, FALSE); - gtk_widget_set_sensitive(cards_label, FALSE); - gtk_widget_set_sensitive(scrolled_window, FALSE); - gtk_widget_set_sensitive(scale_button, FALSE); - gtk_widget_set_sensitive(scale_label, FALSE); - gtk_widget_set_sensitive(business, FALSE); - gtk_widget_set_sensitive(mobile, FALSE); - gtk_widget_set_sensitive(home, FALSE); - gtk_widget_set_sensitive(book_tree_view, FALSE); - - - } - else - { - DEBUG("Enable addressbook options\n"); - gtk_widget_set_sensitive(photo, TRUE); - gtk_widget_set_sensitive(scrolled_label, TRUE); - gtk_widget_set_sensitive(cards_label, TRUE); - gtk_widget_set_sensitive(scrolled_window, TRUE); - gtk_widget_set_sensitive(scale_button, TRUE); - gtk_widget_set_sensitive(scale_label, TRUE); - gtk_widget_set_sensitive(business, TRUE); - gtk_widget_set_sensitive(mobile, TRUE); - gtk_widget_set_sensitive(home, TRUE); - gtk_widget_set_sensitive(book_tree_view, TRUE); +enable_options() +{ + + if (!addressbook_config->enable) { + DEBUG ("Disable addressbook options\n"); + gtk_widget_set_sensitive (photo, FALSE); + gtk_widget_set_sensitive (scrolled_label, FALSE); + gtk_widget_set_sensitive (cards_label, FALSE); + gtk_widget_set_sensitive (scrolled_window, FALSE); + gtk_widget_set_sensitive (scale_button, FALSE); + gtk_widget_set_sensitive (scale_label, FALSE); + gtk_widget_set_sensitive (business, FALSE); + gtk_widget_set_sensitive (mobile, FALSE); + gtk_widget_set_sensitive (home, FALSE); + gtk_widget_set_sensitive (book_tree_view, FALSE); + + + } else { + DEBUG ("Enable addressbook options\n"); + gtk_widget_set_sensitive (photo, TRUE); + gtk_widget_set_sensitive (scrolled_label, TRUE); + gtk_widget_set_sensitive (cards_label, TRUE); + gtk_widget_set_sensitive (scrolled_window, TRUE); + gtk_widget_set_sensitive (scale_button, TRUE); + gtk_widget_set_sensitive (scale_label, TRUE); + gtk_widget_set_sensitive (business, TRUE); + gtk_widget_set_sensitive (mobile, TRUE); + gtk_widget_set_sensitive (home, TRUE); + gtk_widget_set_sensitive (book_tree_view, TRUE); } } - static void +static void enable_cb (GtkWidget *widget) { addressbook_config->enable - = (guint) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); enable_options(); - + } - static void +static void max_results_cb (GtkSpinButton *button) { - addressbook_config->max_results = gtk_spin_button_get_value_as_int(button); + addressbook_config->max_results = gtk_spin_button_get_value_as_int (button); } - static void -display_contact_photo_cb(GtkWidget *widget) +static void +display_contact_photo_cb (GtkWidget *widget) { addressbook_config->display_contact_photo - = (guint) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); } - static void -search_phone_business_cb(GtkWidget *widget) +static void +search_phone_business_cb (GtkWidget *widget) { addressbook_config->search_phone_business - = (guint) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); } - static void -search_phone_home_cb(GtkWidget *widget) +static void +search_phone_home_cb (GtkWidget *widget) { - addressbook_config->search_phone_home = (guint) gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(widget)); + addressbook_config->search_phone_home = (guint) gtk_toggle_button_get_active ( + GTK_TOGGLE_BUTTON (widget)); } - static void -search_phone_mobile_cb(GtkWidget *widget) +static void +search_phone_mobile_cb (GtkWidget *widget) { addressbook_config->search_phone_mobile - = (guint) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); } /** @@ -200,8 +196,8 @@ search_phone_mobile_cb(GtkWidget *widget) * and in configuration files */ static void -addressbook_config_book_active_toggled( - GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data) +addressbook_config_book_active_toggled ( + GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data) { GtkTreeIter iter; GtkTreePath *treePath; @@ -211,66 +207,64 @@ addressbook_config_book_active_toggled( gchar* uid; // Get path of clicked book active toggle box - treePath = gtk_tree_path_new_from_string(path); - model = gtk_tree_view_get_model(GTK_TREE_VIEW(data)); - gtk_tree_model_get_iter(model, &iter, treePath); + treePath = gtk_tree_path_new_from_string (path); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (data)); + gtk_tree_model_get_iter (model, &iter, treePath); // Get active value at iteration - gtk_tree_model_get(model, &iter, COLUMN_BOOK_ACTIVE, &active, - COLUMN_BOOK_UID, &uid, COLUMN_BOOK_NAME, &name, -1); + gtk_tree_model_get (model, &iter, COLUMN_BOOK_ACTIVE, &active, + COLUMN_BOOK_UID, &uid, COLUMN_BOOK_NAME, &name, -1); // Toggle active value active = !active; // Store value - gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_BOOK_ACTIVE, active, -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_BOOK_ACTIVE, active, -1); - gtk_tree_path_free(treePath); + gtk_tree_path_free (treePath); // Update current memory stored books data - books_get_book_data_by_uid(uid)->active = active; + books_get_book_data_by_uid (uid)->active = active; // Save data gboolean valid; // Initiate double array char list for one string - const gchar** list = (void*) malloc(sizeof(void*)); + const gchar** list = (void*) malloc (sizeof (void*)); int c = 0; /* Get the first iter in the list */ - valid = gtk_tree_model_get_iter_first(model, &iter); + valid = gtk_tree_model_get_iter_first (model, &iter); - while (valid) - { + while (valid) { // Get active value at iteration - gtk_tree_model_get(model, &iter, COLUMN_BOOK_ACTIVE, &active, - COLUMN_BOOK_UID, &uid, COLUMN_BOOK_NAME, &name, -1); + gtk_tree_model_get (model, &iter, COLUMN_BOOK_ACTIVE, &active, + COLUMN_BOOK_UID, &uid, COLUMN_BOOK_NAME, &name, -1); - if (active) - { + if (active) { // Reallocate memory each time if (c != 0) - list = (void*) realloc(list, (c + 1) * sizeof(void*)); + list = (void*) realloc (list, (c + 1) * sizeof (void*)); - *(list + c) = uid; + * (list + c) = uid; c++; } - valid = gtk_tree_model_iter_next(model, &iter); + valid = gtk_tree_model_iter_next (model, &iter); } // Allocate NULL array at the end for Dbus - list = (void*) realloc(list, (c + 1) * sizeof(void*)); - *(list + c) = NULL; + list = (void*) realloc (list, (c + 1) * sizeof (void*)); + * (list + c) = NULL; // Call daemon to store in config file - dbus_set_addressbook_list(list); + dbus_set_addressbook_list (list); - free(list); + free (list); } - static void +static void addressbook_config_fill_book_list() { GtkTreeIter list_store_iterator; @@ -280,28 +274,27 @@ addressbook_config_fill_book_list() GSList *books_data = addressbook_get_books_data(); // Get model of view and clear it - store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(book_tree_view))); - gtk_list_store_clear(store); + store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (book_tree_view))); + gtk_list_store_clear (store); // Populate window for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) - { + = book_list_iterator->next) { book_data = (book_data_t *) book_list_iterator->data; - gtk_list_store_append(store, &list_store_iterator); - gtk_list_store_set(store, &list_store_iterator, COLUMN_BOOK_ACTIVE, - book_data->active, COLUMN_BOOK_UID, book_data->uid, COLUMN_BOOK_NAME, - book_data->name, -1); + gtk_list_store_append (store, &list_store_iterator); + gtk_list_store_set (store, &list_store_iterator, COLUMN_BOOK_ACTIVE, + book_data->active, COLUMN_BOOK_UID, book_data->uid, COLUMN_BOOK_NAME, + book_data->name, -1); } - store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(book_tree_view))); + store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (book_tree_view))); } - GtkWidget* +GtkWidget* create_addressbook_settings() { - GtkWidget *ret, *result_frame, *table, *value, *label, *item; + GtkWidget *ret, *result_frame, *table, *value, *item; GtkListStore *store; GtkCellRenderer *renderer; @@ -309,140 +302,140 @@ create_addressbook_settings() GtkTreeViewColumn *tree_view_column; // Load the user value - addressbook_config_load_parameters(&addressbook_config); + addressbook_config_load_parameters (&addressbook_config); - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - gnome_main_section_new_with_table (_("General"), &result_frame, &table, 3, 3); - gtk_box_pack_start(GTK_BOX(ret), result_frame, FALSE, FALSE, 0); + gnome_main_section_new_with_table (_ ("General"), &result_frame, &table, 3, 3); + gtk_box_pack_start (GTK_BOX (ret), result_frame, FALSE, FALSE, 0); // gtk_widget_show (result_frame); // PHOTO DISPLAY - item = gtk_check_button_new_with_mnemonic( _("_Use Evolution address books")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->enable); - g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (enable_cb), NULL); - gtk_table_attach ( GTK_TABLE( table ), item, 1, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + item = gtk_check_button_new_with_mnemonic (_ ("_Use Evolution address books")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), addressbook_config->enable); + g_signal_connect (G_OBJECT (item) , "clicked" , G_CALLBACK (enable_cb), NULL); + gtk_table_attach (GTK_TABLE (table), item, 1, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // SCALE BUTTON - NUMBER OF RESULTS - scale_button = gtk_hbox_new(FALSE, 0); - scale_label = gtk_label_new (_("Download limit :")); - gtk_box_pack_start(GTK_BOX(scale_button),scale_label,FALSE,FALSE,0); - value = gtk_spin_button_new_with_range(1, 500, 1); + scale_button = gtk_hbox_new (FALSE, 0); + scale_label = gtk_label_new (_ ("Download limit :")); + gtk_box_pack_start (GTK_BOX (scale_button),scale_label,FALSE,FALSE,0); + value = gtk_spin_button_new_with_range (1, 500, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (scale_label), value); - gtk_spin_button_set_value (GTK_SPIN_BUTTON( value ) , addressbook_config->max_results); - g_signal_connect (G_OBJECT (value) , "value-changed" , G_CALLBACK(max_results_cb), NULL ); - gtk_box_pack_start(GTK_BOX(scale_button),value,TRUE,TRUE,10); - gtk_table_attach ( GTK_TABLE( table ), scale_button, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND |GTK_FILL, 0, 0); - cards_label = gtk_label_new(_("cards")); - gtk_table_attach( GTK_TABLE(table), cards_label, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show_all(scale_button); - + gtk_spin_button_set_value (GTK_SPIN_BUTTON (value) , addressbook_config->max_results); + g_signal_connect (G_OBJECT (value) , "value-changed" , G_CALLBACK (max_results_cb), NULL); + gtk_box_pack_start (GTK_BOX (scale_button),value,TRUE,TRUE,10); + gtk_table_attach (GTK_TABLE (table), scale_button, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND |GTK_FILL, 0, 0); + cards_label = gtk_label_new (_ ("cards")); + gtk_table_attach (GTK_TABLE (table), cards_label, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show_all (scale_button); + // PHOTO DISPLAY - photo = gtk_check_button_new_with_mnemonic( _("_Display contact photo if available")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(photo), addressbook_config->display_contact_photo); - g_signal_connect (G_OBJECT(photo) , "clicked" , G_CALLBACK (display_contact_photo_cb), NULL); - gtk_table_attach ( GTK_TABLE( table ), photo, 1, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - + photo = gtk_check_button_new_with_mnemonic (_ ("_Display contact photo if available")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (photo), addressbook_config->display_contact_photo); + g_signal_connect (G_OBJECT (photo) , "clicked" , G_CALLBACK (display_contact_photo_cb), NULL); + gtk_table_attach (GTK_TABLE (table), photo, 1, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + // Fields - gnome_main_section_new_with_table (_("Fields from Evolution's address books"), &result_frame, &table, 1, 3); - gtk_box_pack_start(GTK_BOX(ret), result_frame, FALSE, FALSE, 0); + gnome_main_section_new_with_table (_ ("Fields from Evolution's address books"), &result_frame, &table, 1, 3); + gtk_box_pack_start (GTK_BOX (ret), result_frame, FALSE, FALSE, 0); // gtk_widget_show (result_frame); - business = gtk_check_button_new_with_mnemonic( _("_Work")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(business), addressbook_config->search_phone_business); - g_signal_connect (G_OBJECT(business) , "clicked" , G_CALLBACK (search_phone_business_cb) , NULL); - gtk_table_attach ( GTK_TABLE( table ), business, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(business, FALSE); + business = gtk_check_button_new_with_mnemonic (_ ("_Work")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (business), addressbook_config->search_phone_business); + g_signal_connect (G_OBJECT (business) , "clicked" , G_CALLBACK (search_phone_business_cb) , NULL); + gtk_table_attach (GTK_TABLE (table), business, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (business, FALSE); - home = gtk_check_button_new_with_mnemonic( _("_Home")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(home), addressbook_config->search_phone_home); - g_signal_connect (G_OBJECT(home) , "clicked" , G_CALLBACK (search_phone_home_cb) , NULL); - gtk_table_attach ( GTK_TABLE( table ), home, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(home, FALSE); + home = gtk_check_button_new_with_mnemonic (_ ("_Home")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (home), addressbook_config->search_phone_home); + g_signal_connect (G_OBJECT (home) , "clicked" , G_CALLBACK (search_phone_home_cb) , NULL); + gtk_table_attach (GTK_TABLE (table), home, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (home, FALSE); + + mobile = gtk_check_button_new_with_mnemonic (_ ("_Mobile")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mobile), addressbook_config->search_phone_mobile); + g_signal_connect (G_OBJECT (mobile) , "clicked" , G_CALLBACK (search_phone_mobile_cb) , NULL); + gtk_table_attach (GTK_TABLE (table), mobile, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - mobile = gtk_check_button_new_with_mnemonic( _("_Mobile")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(mobile), addressbook_config->search_phone_mobile); - g_signal_connect (G_OBJECT(mobile) , "clicked" , G_CALLBACK (search_phone_mobile_cb) , NULL); - gtk_table_attach ( GTK_TABLE( table ), mobile, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - // Address Book - gnome_main_section_new_with_table (_("Address Books"), &result_frame, &table, 2, 3); - gtk_box_pack_start(GTK_BOX(ret), result_frame, TRUE, TRUE, 0); + gnome_main_section_new_with_table (_ ("Address Books"), &result_frame, &table, 2, 3); + gtk_box_pack_start (GTK_BOX (ret), result_frame, TRUE, TRUE, 0); gtk_widget_show (result_frame); - scrolled_label = gtk_label_new (_("Select which Evolution address books to use")); - gtk_misc_set_alignment(GTK_MISC(scrolled_label), 0.00, 0.2); - - gtk_table_attach ( GTK_TABLE( table ), scrolled_label, 1, 4, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(scrolled_label, FALSE); + scrolled_label = gtk_label_new (_ ("Select which Evolution address books to use")); + gtk_misc_set_alignment (GTK_MISC (scrolled_label), 0.00, 0.2); + + gtk_table_attach (GTK_TABLE (table), scrolled_label, 1, 4, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (scrolled_label, FALSE); - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_table_attach ( GTK_TABLE( table ), scrolled_window, 1, 4, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scrolled_window, 1, 4, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - store = gtk_list_store_new(3, - G_TYPE_BOOLEAN, // Active - G_TYPE_STRING, // uid - G_TYPE_STRING // Name - ); + store = gtk_list_store_new (3, + G_TYPE_BOOLEAN, // Active + G_TYPE_STRING, // uid + G_TYPE_STRING // Name + ); // Create tree view with list store - book_tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); + book_tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); // Get tree selection manager - tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(book_tree_view)); + tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (book_tree_view)); // Active column renderer = gtk_cell_renderer_toggle_new(); - tree_view_column = gtk_tree_view_column_new_with_attributes("", renderer, "active", COLUMN_BOOK_ACTIVE, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(book_tree_view), tree_view_column); + tree_view_column = gtk_tree_view_column_new_with_attributes ("", renderer, "active", COLUMN_BOOK_ACTIVE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (book_tree_view), tree_view_column); // Toggle active property on clicked - g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(addressbook_config_book_active_toggled), (gpointer)book_tree_view); + g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (addressbook_config_book_active_toggled), (gpointer) book_tree_view); // Name column renderer = gtk_cell_renderer_text_new(); - tree_view_column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "markup", COLUMN_BOOK_NAME, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(book_tree_view), tree_view_column); + tree_view_column = gtk_tree_view_column_new_with_attributes (_ ("Name"), renderer, "markup", COLUMN_BOOK_NAME, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (book_tree_view), tree_view_column); - g_object_unref(G_OBJECT(store)); - gtk_container_add(GTK_CONTAINER(scrolled_window), book_tree_view); + g_object_unref (G_OBJECT (store)); + gtk_container_add (GTK_CONTAINER (scrolled_window), book_tree_view); addressbook_config_fill_book_list(); - gtk_widget_show_all(ret); + gtk_widget_show_all (ret); enable_options(); return ret; } - gboolean -addressbook_display(AddressBook_Config *settings, const gchar *field) +gboolean +addressbook_display (AddressBook_Config *settings, const gchar *field) { gboolean display = FALSE; - if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) + if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) display = (settings->display_contact_photo == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) display = (settings->search_phone_business == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) display = (settings->search_phone_home == 1) ? TRUE : FALSE; - else if (g_strcasecmp(field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) display = (settings->search_phone_mobile == 1) ? TRUE : FALSE; else diff --git a/sflphone-client-gnome/src/config/addressbook-config.h b/sflphone-client-gnome/src/config/addressbook-config.h index 234a8973559009e62c8a00602a3222f973004ec6..cd03bba833a9da0249424b49d91800b00bfd6eac 100644 --- a/sflphone-client-gnome/src/config/addressbook-config.h +++ b/sflphone-client-gnome/src/config/addressbook-config.h @@ -46,10 +46,9 @@ G_BEGIN_DECLS #define ADDRESSBOOK_DISPLAY_PHONE_HOME "ADDRESSBOOK_DISPLAY_PHONE_HOME" #define ADDRESSBOOK_DISPLAY_PHONE_MOBILE "ADDRESSBOOK_DISPLAY_PHONE_MOBILE" -typedef struct _AddressBook_Config -{ - // gint64: a signed integer guaranteed to be 64 bits on all platforms - // To print or scan values of this type, use G_GINT64_MODIFIER and/or G_GINT64_FORMAT +typedef struct _AddressBook_Config { + // gint64: a signed integer guaranteed to be 64 bits on all platforms + // To print or scan values of this type, use G_GINT64_MODIFIER and/or G_GINT64_FORMAT gint enable; gint max_results; gint display_contact_photo; @@ -62,7 +61,7 @@ typedef struct _AddressBook_Config * Save the parameters through D-BUS */ void -addressbook_config_save_parameters(void); +addressbook_config_save_parameters (void); /** * Initialize the address book structure, and retrieve the saved parameters through D-Bus @@ -70,10 +69,10 @@ addressbook_config_save_parameters(void); * @param settings The addressbook structure */ void -addressbook_config_load_parameters(AddressBook_Config **settings); +addressbook_config_load_parameters (AddressBook_Config **settings); gboolean -addressbook_display(AddressBook_Config *settings, const gchar *field); +addressbook_display (AddressBook_Config *settings, const gchar *field); GtkWidget* create_addressbook_settings(); diff --git a/sflphone-client-gnome/src/config/assistant.c b/sflphone-client-gnome/src/config/assistant.c index 7b5c342a81312a6c0b292aa3bdcd9511a980de53..71d3d654407f346ab3b413d15416179b99faefa0 100644 --- a/sflphone-client-gnome/src/config/assistant.c +++ b/sflphone-client-gnome/src/config/assistant.c @@ -54,25 +54,26 @@ char message[1024]; /** * Forward function */ -static gint forward_page_func( gint current_page , gpointer data ); +static gint forward_page_func (gint current_page , gpointer data); /** * Page template */ -static GtkWidget* create_vbox(GtkAssistantPageType type, const gchar *title, const gchar *section); -void prefill_sip(void) ; - -void set_account_type( GtkWidget* widget , gpointer data UNUSED ) { - if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget )) ){ - account_type = _SIP; - }else{ - account_type = _IAX ; - } +static GtkWidget* create_vbox (GtkAssistantPageType type, const gchar *title, const gchar *section); +void prefill_sip (void) ; + +void set_account_type (GtkWidget* widget , gpointer data UNUSED) +{ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + account_type = _SIP; + } else { + account_type = _IAX ; + } } -static void show_password_cb (GtkWidget *widget, gpointer data) +static void show_password_cb (GtkWidget *widget UNUSED, gpointer data) { - gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data))); + gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data))); } @@ -80,36 +81,38 @@ static void show_password_cb (GtkWidget *widget, gpointer data) * Fills string message with the final message of account registration * with alias, server and username specified. */ -void getMessageSummary( char * message , const gchar * alias, const gchar * server, const gchar * username, const gboolean zrtp) +void getMessageSummary (char * message , const gchar * alias, const gchar * server, const gchar * username, const gboolean zrtp) { - char var[64]; - sprintf( message, _("This assistant is now finished.")); - strcat( message, "\n" ); - strcat( message, _("You can at any time check your registration state or modify your accounts parameters in the Options/Accounts window.")); - strcat( message, "\n\n"); - - strcat( message, _("Alias")); - sprintf( var, " : %s\n", alias); - strcat( message, var); - - strcat( message, _("Server")); - sprintf( var, " : %s\n", server); - strcat( message, var); - - strcat( message, _("Username")); - sprintf( var, " : %s\n", username); - strcat( message, var); - - strcat( message, _("Security: ")); - if (zrtp) { - strcat( message, _("SRTP/ZRTP draft-zimmermann")); - } else { - strcat( message, _("None")); - } + char var[64]; + sprintf (message, _ ("This assistant is now finished.")); + strcat (message, "\n"); + strcat (message, _ ("You can at any time check your registration state or modify your accounts parameters in the Options/Accounts window.")); + strcat (message, "\n\n"); + + strcat (message, _ ("Alias")); + sprintf (var, " : %s\n", alias); + strcat (message, var); + + strcat (message, _ ("Server")); + sprintf (var, " : %s\n", server); + strcat (message, var); + + strcat (message, _ ("Username")); + sprintf (var, " : %s\n", username); + strcat (message, var); + + strcat (message, _ ("Security: ")); + + if (zrtp) { + strcat (message, _ ("SRTP/ZRTP draft-zimmermann")); + } else { + strcat (message, _ ("None")); + } } -void set_sflphone_org( GtkWidget* widget , gpointer data UNUSED ) { - use_sflphone_org = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))?1:0) ; +void set_sflphone_org (GtkWidget* widget , gpointer data UNUSED) +{ + use_sflphone_org = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ?1:0) ; } @@ -118,9 +121,11 @@ void set_sflphone_org( GtkWidget* widget , gpointer data UNUSED ) { * Callback when the close button of the dialog is clicked * Action : close the assistant widget and get back to sflphone main window */ -static void close_callback( void ) { - gtk_widget_destroy(wiz->assistant); - g_free(wiz); wiz = NULL; +static void close_callback (void) +{ + gtk_widget_destroy (wiz->assistant); + g_free (wiz); + wiz = NULL; status_bar_display_account (); } @@ -129,10 +134,12 @@ static void close_callback( void ) { * Callback when the cancel button of the dialog is clicked * Action : close the assistant widget and get back to sflphone main window */ -static void cancel_callback( void ) { - gtk_widget_destroy(wiz->assistant); - g_free(wiz); wiz = NULL; - +static void cancel_callback (void) +{ + gtk_widget_destroy (wiz->assistant); + g_free (wiz); + wiz = NULL; + status_bar_display_account (); } @@ -140,536 +147,562 @@ static void cancel_callback( void ) { * Callback when the button apply is clicked * Action : Set the account parameters with the entries values and called dbus_add_account */ -static void sip_apply_callback( void ) { - if(use_sflphone_org){ - prefill_sip(); - account_type = _SIP; - } - if( account_type == _SIP ) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_voicemail)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("SIP")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_server)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_password)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->sip_username)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup((gchar *)(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable))? "true":"false"))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->addr)))); - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable)) == TRUE) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup((gchar *)"true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup((gchar *)ZRTP)); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_DISPLAY_SAS), g_strdup((gchar *)"true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_NOT_SUPP_WARNING), g_strdup((gchar *)"true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_HELLO_HASH), g_strdup((gchar *)"true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_DISPLAY_SAS_ONCE), g_strdup((gchar *)"false")); +static void sip_apply_callback (void) +{ + if (use_sflphone_org) { + prefill_sip(); + account_type = _SIP; + } + + if (account_type == _SIP) { + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ALIAS), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->sip_alias)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ENABLED), g_strdup ("true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_MAILBOX), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->sip_voicemail)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_TYPE), g_strdup ("SIP")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_HOSTNAME), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->sip_server)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_PASSWORD), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->sip_password)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_USERNAME), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->sip_username)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_SIP_STUN_ENABLED), g_strdup ( (gchar *) (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wiz->enable)) ? "true":"false"))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_SIP_STUN_SERVER), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->addr)))); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wiz->zrtp_enable)) == TRUE) { + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_SRTP_ENABLED), g_strdup ( (gchar *) "true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_KEY_EXCHANGE), g_strdup ( (gchar *) ZRTP)); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ZRTP_DISPLAY_SAS), g_strdup ( (gchar *) "true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ZRTP_NOT_SUPP_WARNING), g_strdup ( (gchar *) "true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ZRTP_HELLO_HASH), g_strdup ( (gchar *) "true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_DISPLAY_SAS_ONCE), g_strdup ( (gchar *) "false")); } - // Add default interface info - gchar ** iface_list = NULL; - iface_list = (gchar**) dbus_get_all_ip_interface_by_name(); + // Add default interface info + gchar ** iface_list = NULL; + iface_list = (gchar**) dbus_get_all_ip_interface_by_name(); gchar ** iface = NULL; - // select the first interface available - iface = iface_list; - DEBUG("Selected interface %s", *iface); + // select the first interface available + iface = iface_list; + DEBUG ("Selected interface %s", *iface); - g_hash_table_insert(current->properties, g_strdup(LOCAL_INTERFACE), g_strdup((gchar *)*iface)); + g_hash_table_insert (current->properties, g_strdup (LOCAL_INTERFACE), g_strdup ( (gchar *) *iface)); - g_hash_table_insert(current->properties, g_strdup(PUBLISHED_ADDRESS), g_strdup((gchar *)*iface)); + g_hash_table_insert (current->properties, g_strdup (PUBLISHED_ADDRESS), g_strdup ( (gchar *) *iface)); - dbus_add_account( current ); - getMessageSummary(message, - gtk_entry_get_text (GTK_ENTRY(wiz->sip_alias)), - gtk_entry_get_text (GTK_ENTRY(wiz->sip_server)), - gtk_entry_get_text (GTK_ENTRY(wiz->sip_username)), - (gboolean)(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable))) - ); + dbus_add_account (current); + getMessageSummary (message, + gtk_entry_get_text (GTK_ENTRY (wiz->sip_alias)), + gtk_entry_get_text (GTK_ENTRY (wiz->sip_server)), + gtk_entry_get_text (GTK_ENTRY (wiz->sip_username)), + (gboolean) (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wiz->zrtp_enable))) + ); - gtk_label_set_text (GTK_LABEL(wiz->label_summary), message); - } + gtk_label_set_text (GTK_LABEL (wiz->label_summary), message); + } } /** * Callback when the button apply is clicked * Action : Set the account parameters with the entries values and called dbus_add_account */ -static void iax_apply_callback( void ) { - if( account_type == _IAX) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->iax_voicemail)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("IAX")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->iax_username)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->iax_server)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(wiz->iax_password)))); - - dbus_add_account( current ); - getMessageSummary(message, - gtk_entry_get_text (GTK_ENTRY(wiz->iax_alias)), - gtk_entry_get_text (GTK_ENTRY(wiz->iax_server)), - gtk_entry_get_text (GTK_ENTRY(wiz->iax_username)), - FALSE - ) ; - - gtk_label_set_text (GTK_LABEL(wiz->label_summary), message); - } +static void iax_apply_callback (void) +{ + if (account_type == _IAX) { + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ALIAS), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->iax_alias)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_ENABLED), g_strdup ("true")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_MAILBOX), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->iax_voicemail)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_TYPE), g_strdup ("IAX")); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_USERNAME), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->iax_username)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_HOSTNAME), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->iax_server)))); + g_hash_table_insert (current->properties, g_strdup (ACCOUNT_PASSWORD), g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (wiz->iax_password)))); + + dbus_add_account (current); + getMessageSummary (message, + gtk_entry_get_text (GTK_ENTRY (wiz->iax_alias)), + gtk_entry_get_text (GTK_ENTRY (wiz->iax_server)), + gtk_entry_get_text (GTK_ENTRY (wiz->iax_username)), + FALSE + ) ; + + gtk_label_set_text (GTK_LABEL (wiz->label_summary), message); + } } -void enable_stun( GtkWidget* widget ) { - gtk_widget_set_sensitive( GTK_WIDGET( wiz->addr ), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); +void enable_stun (GtkWidget* widget) +{ + gtk_widget_set_sensitive (GTK_WIDGET (wiz->addr), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); } -void build_wizard( void ) { - use_sflphone_org = 1; - if (wiz) - return ; - - wiz = ( struct _wizard* )g_malloc( sizeof( struct _wizard)); - current = g_new0(account_t, 1); - current->properties = NULL; - current->properties = dbus_account_details(NULL); - if (current->properties == NULL) { - DEBUG("Failed to get default values. Creating from scratch"); - current->properties = g_hash_table_new(NULL, g_str_equal); - } +void build_wizard (void) +{ + use_sflphone_org = 1; + + if (wiz) + return ; + + wiz = (struct _wizard*) g_malloc (sizeof (struct _wizard)); + current = g_new0 (account_t, 1); + current->properties = NULL; + current->properties = dbus_account_details (NULL); + + if (current->properties == NULL) { + DEBUG ("Failed to get default values. Creating from scratch"); + current->properties = g_hash_table_new (NULL, g_str_equal); + } + current->accountID = "new"; - wiz->assistant = gtk_assistant_new(); + wiz->assistant = gtk_assistant_new(); - gtk_window_set_title( GTK_WINDOW(wiz->assistant), _("SFLphone account creation wizard") ); - gtk_window_set_position(GTK_WINDOW(wiz->assistant), GTK_WIN_POS_CENTER); - gtk_window_set_default_size(GTK_WINDOW(wiz->assistant), 200 , 200); + gtk_window_set_title (GTK_WINDOW (wiz->assistant), _ ("SFLphone account creation wizard")); + gtk_window_set_position (GTK_WINDOW (wiz->assistant), GTK_WIN_POS_CENTER); + gtk_window_set_default_size (GTK_WINDOW (wiz->assistant), 200 , 200); - build_intro(); - build_sfl_or_account(); - build_select_account(); - build_sip_account_configuration(); - build_nat_settings(); - build_iax_account_configuration(); - build_email_configuration(); - build_summary(); + build_intro(); + build_sfl_or_account(); + build_select_account(); + build_sip_account_configuration(); + build_nat_settings(); + build_iax_account_configuration(); + build_email_configuration(); + build_summary(); - g_signal_connect(G_OBJECT(wiz->assistant), "close" , G_CALLBACK(close_callback), NULL); + g_signal_connect (G_OBJECT (wiz->assistant), "close" , G_CALLBACK (close_callback), NULL); - g_signal_connect(G_OBJECT(wiz->assistant), "cancel" , G_CALLBACK(cancel_callback), NULL); + g_signal_connect (G_OBJECT (wiz->assistant), "cancel" , G_CALLBACK (cancel_callback), NULL); - gtk_widget_show_all(wiz->assistant); + gtk_widget_show_all (wiz->assistant); - gtk_assistant_set_forward_page_func( GTK_ASSISTANT( wiz->assistant ), (GtkAssistantPageFunc) forward_page_func , NULL , NULL ); - gtk_assistant_update_buttons_state(GTK_ASSISTANT(wiz->assistant)); + gtk_assistant_set_forward_page_func (GTK_ASSISTANT (wiz->assistant), (GtkAssistantPageFunc) forward_page_func , NULL , NULL); + gtk_assistant_update_buttons_state (GTK_ASSISTANT (wiz->assistant)); } -GtkWidget* build_intro() { - GtkWidget *label; +GtkWidget* build_intro() +{ + GtkWidget *label; - wiz->intro = create_vbox( GTK_ASSISTANT_PAGE_INTRO , "SFLphone GNOME client" , _("Welcome to the Account creation wizard of SFLphone!")); - label = gtk_label_new(_("This installation wizard will help you configure an account.")) ; - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1); - gtk_box_pack_start(GTK_BOX(wiz->intro), label, FALSE, TRUE, 0); + wiz->intro = create_vbox (GTK_ASSISTANT_PAGE_INTRO , "SFLphone GNOME client" , _ ("Welcome to the Account creation wizard of SFLphone!")); + label = gtk_label_new (_ ("This installation wizard will help you configure an account.")) ; + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_widget_set_size_request (GTK_WIDGET (label), 380, -1); + gtk_box_pack_start (GTK_BOX (wiz->intro), label, FALSE, TRUE, 0); - gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->intro, TRUE); - return wiz->intro; + gtk_assistant_set_page_complete (GTK_ASSISTANT (wiz->assistant), wiz->intro, TRUE); + return wiz->intro; } -GtkWidget* build_select_account() { - GtkWidget* sip; - GtkWidget* iax; +GtkWidget* build_select_account() +{ + GtkWidget* sip; + GtkWidget* iax; - wiz->protocols = create_vbox( GTK_ASSISTANT_PAGE_CONTENT , _("VoIP Protocols") , _("Select an account type")); + wiz->protocols = create_vbox (GTK_ASSISTANT_PAGE_CONTENT , _ ("VoIP Protocols") , _ ("Select an account type")); - sip = gtk_radio_button_new_with_label(NULL, _("SIP (Session Initiation Protocol)")); - gtk_box_pack_start( GTK_BOX(wiz->protocols) , sip , TRUE, TRUE, 0); - iax = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sip), _("IAX2 (InterAsterix Exchange)")); - gtk_box_pack_start( GTK_BOX(wiz->protocols) , iax , TRUE, TRUE, 0); + sip = gtk_radio_button_new_with_label (NULL, _ ("SIP (Session Initiation Protocol)")); + gtk_box_pack_start (GTK_BOX (wiz->protocols) , sip , TRUE, TRUE, 0); + iax = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (sip), _ ("IAX2 (InterAsterix Exchange)")); + gtk_box_pack_start (GTK_BOX (wiz->protocols) , iax , TRUE, TRUE, 0); - g_signal_connect(G_OBJECT( sip ) , "clicked" , G_CALLBACK( set_account_type ) , NULL ); + g_signal_connect (G_OBJECT (sip) , "clicked" , G_CALLBACK (set_account_type) , NULL); - gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->protocols, TRUE); - return wiz->protocols; + gtk_assistant_set_page_complete (GTK_ASSISTANT (wiz->assistant), wiz->protocols, TRUE); + return wiz->protocols; } -GtkWidget* build_sfl_or_account() { - GtkWidget* sfl; - GtkWidget* cus; +GtkWidget* build_sfl_or_account() +{ + GtkWidget* sfl; + GtkWidget* cus; - wiz->sflphone_org = create_vbox( GTK_ASSISTANT_PAGE_CONTENT , _("Account") , _("Please select one of the following options")); + wiz->sflphone_org = create_vbox (GTK_ASSISTANT_PAGE_CONTENT , _ ("Account") , _ ("Please select one of the following options")); - sfl = gtk_radio_button_new_with_label( NULL, _("Create a free SIP/IAX2 account on sflphone.org")); - gtk_box_pack_start( GTK_BOX(wiz->sflphone_org) , sfl , TRUE, TRUE, 0); - cus = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sfl), _("Register an existing SIP or IAX2 account")); - gtk_box_pack_start( GTK_BOX(wiz->sflphone_org) , cus , TRUE, TRUE, 0); - g_signal_connect(G_OBJECT( sfl ) , "clicked" , G_CALLBACK( set_sflphone_org ) , NULL ); + sfl = gtk_radio_button_new_with_label (NULL, _ ("Create a free SIP/IAX2 account on sflphone.org")); + gtk_box_pack_start (GTK_BOX (wiz->sflphone_org) , sfl , TRUE, TRUE, 0); + cus = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (sfl), _ ("Register an existing SIP or IAX2 account")); + gtk_box_pack_start (GTK_BOX (wiz->sflphone_org) , cus , TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (sfl) , "clicked" , G_CALLBACK (set_sflphone_org) , NULL); - return wiz->sflphone_org; + return wiz->sflphone_org; } -GtkWidget* build_sip_account_configuration( void ) { - GtkWidget* table; - GtkWidget* label; - GtkWidget *image; - GtkWidget * clearTextCheckbox; - - wiz->sip_account = create_vbox( GTK_ASSISTANT_PAGE_CONTENT , _("SIP account settings") , _("Please fill the following information")); - // table - table = gtk_table_new ( 7, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(table), 10); - gtk_table_set_col_spacings( GTK_TABLE(table), 10); - gtk_box_pack_start( GTK_BOX(wiz->sip_account) , table , TRUE, TRUE, 0); - - // alias field - label = gtk_label_new_with_mnemonic (_("_Alias")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->sip_alias = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_alias); - gtk_table_attach ( GTK_TABLE( table ), wiz->sip_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // server field - label = gtk_label_new_with_mnemonic (_("_Host name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->sip_server = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_server); - gtk_table_attach ( GTK_TABLE( table ), wiz->sip_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // username field - label = gtk_label_new_with_mnemonic (_("_User name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); +GtkWidget* build_sip_account_configuration (void) +{ + GtkWidget* table; + GtkWidget* label; + GtkWidget * clearTextCheckbox; + + wiz->sip_account = create_vbox (GTK_ASSISTANT_PAGE_CONTENT , _ ("SIP account settings") , _ ("Please fill the following information")); + // table + table = gtk_table_new (7, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_box_pack_start (GTK_BOX (wiz->sip_account) , table , TRUE, TRUE, 0); + + // alias field + label = gtk_label_new_with_mnemonic (_ ("_Alias")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->sip_alias = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_alias); + gtk_table_attach (GTK_TABLE (table), wiz->sip_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // server field + label = gtk_label_new_with_mnemonic (_ ("_Host name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->sip_server = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_server); + gtk_table_attach (GTK_TABLE (table), wiz->sip_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // username field + label = gtk_label_new_with_mnemonic (_ ("_User name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - wiz->sip_username = gtk_entry_new(); - gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (wiz->sip_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL)); + wiz->sip_username = gtk_entry_new(); + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (wiz->sip_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL)); #else - wiz->sip_username = sexy_icon_entry_new(); - image = gtk_image_new_from_file( ICONS_DIR "/stock_person.svg" ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(wiz->sip_username), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + wiz->sip_username = sexy_icon_entry_new(); + image = gtk_image_new_from_file (ICONS_DIR "/stock_person.svg"); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (wiz->sip_username), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_username); - gtk_table_attach ( GTK_TABLE( table ), wiz->sip_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // password field - - label = gtk_label_new_with_mnemonic (_("_Password")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_username); + gtk_table_attach (GTK_TABLE (table), wiz->sip_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // password field + + label = gtk_label_new_with_mnemonic (_ ("_Password")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - wiz->sip_password = gtk_entry_new(); + wiz->sip_password = gtk_entry_new(); gtk_entry_set_icon_from_stock (GTK_ENTRY (wiz->sip_password), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); #else - - wiz->sip_password = sexy_icon_entry_new(); - image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(wiz->sip_password), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + + wiz->sip_password = sexy_icon_entry_new(); + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (wiz->sip_password), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_password); - gtk_entry_set_visibility(GTK_ENTRY(wiz->sip_password), FALSE); - gtk_table_attach ( GTK_TABLE( table ), wiz->sip_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - clearTextCheckbox = gtk_check_button_new_with_mnemonic (_("Show password")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_password); + gtk_entry_set_visibility (GTK_ENTRY (wiz->sip_password), FALSE); + gtk_table_attach (GTK_TABLE (table), wiz->sip_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + clearTextCheckbox = gtk_check_button_new_with_mnemonic (_ ("Show password")); g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), wiz->sip_password); gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // voicemail number field - label = gtk_label_new_with_mnemonic (_("_Voicemail number")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->sip_voicemail = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_voicemail); - gtk_table_attach ( GTK_TABLE( table ), wiz->sip_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + label = gtk_label_new_with_mnemonic (_ ("_Voicemail number")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->sip_voicemail = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->sip_voicemail); + gtk_table_attach (GTK_TABLE (table), wiz->sip_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // Security options - wiz->zrtp_enable = gtk_check_button_new_with_mnemonic(_("Secure communications with _ZRTP")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable), FALSE); - gtk_table_attach ( GTK_TABLE( table ), wiz->zrtp_enable, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( wiz->zrtp_enable ) , TRUE ); - - //gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->sip_account, TRUE); - return wiz->sip_account; + wiz->zrtp_enable = gtk_check_button_new_with_mnemonic (_ ("Secure communications with _ZRTP")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wiz->zrtp_enable), FALSE); + gtk_table_attach (GTK_TABLE (table), wiz->zrtp_enable, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->zrtp_enable) , TRUE); + + //gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->sip_account, TRUE); + return wiz->sip_account; } -GtkWidget* build_email_configuration( void ) { - GtkWidget* label; - GtkWidget* table; +GtkWidget* build_email_configuration (void) +{ + GtkWidget* label; + GtkWidget* table; - wiz->email = create_vbox( GTK_ASSISTANT_PAGE_CONTENT , _("Optional email address") , _("This email address will be used to send your voicemail messages.")); + wiz->email = create_vbox (GTK_ASSISTANT_PAGE_CONTENT , _ ("Optional email address") , _ ("This email address will be used to send your voicemail messages.")); - table = gtk_table_new ( 4, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(table), 10); - gtk_table_set_col_spacings( GTK_TABLE(table), 10); - gtk_box_pack_start( GTK_BOX(wiz->email) , table , TRUE, TRUE, 0); + table = gtk_table_new (4, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_box_pack_start (GTK_BOX (wiz->email) , table , TRUE, TRUE, 0); - // email field - label = gtk_label_new_with_mnemonic (_("_Email address")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->mailbox = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->mailbox); - gtk_table_attach ( GTK_TABLE( table ), wiz->mailbox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + // email field + label = gtk_label_new_with_mnemonic (_ ("_Email address")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->mailbox = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->mailbox); + gtk_table_attach (GTK_TABLE (table), wiz->mailbox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // Security options - wiz->zrtp_enable = gtk_check_button_new_with_mnemonic(_("Secure communications with _ZRTP")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable), FALSE); - gtk_table_attach ( GTK_TABLE( table ), wiz->zrtp_enable, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( wiz->zrtp_enable ) , TRUE ); - - return wiz->email; + wiz->zrtp_enable = gtk_check_button_new_with_mnemonic (_ ("Secure communications with _ZRTP")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wiz->zrtp_enable), FALSE); + gtk_table_attach (GTK_TABLE (table), wiz->zrtp_enable, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->zrtp_enable) , TRUE); + + return wiz->email; } -GtkWidget* build_iax_account_configuration( void ) { - GtkWidget* label; - GtkWidget* table; - GtkWidget *image; - GtkWidget * clearTextCheckbox; - - wiz->iax_account = create_vbox( GTK_ASSISTANT_PAGE_CONFIRM , _("IAX2 account settings") , _("Please fill the following information")); - - table = gtk_table_new ( 6, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(table), 10); - gtk_table_set_col_spacings( GTK_TABLE(table), 10); - gtk_box_pack_start( GTK_BOX(wiz->iax_account) , table , TRUE, TRUE, 0); - - // alias field - label = gtk_label_new_with_mnemonic (_("_Alias")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->iax_alias = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_alias); - gtk_table_attach ( GTK_TABLE( table ), wiz->iax_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // server field - label = gtk_label_new_with_mnemonic (_("_Host name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->iax_server = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_server); - gtk_table_attach ( GTK_TABLE( table ), wiz->iax_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // username field - label = gtk_label_new_with_mnemonic (_("_User name")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); +GtkWidget* build_iax_account_configuration (void) +{ + GtkWidget* label; + GtkWidget* table; + GtkWidget * clearTextCheckbox; + + wiz->iax_account = create_vbox (GTK_ASSISTANT_PAGE_CONFIRM , _ ("IAX2 account settings") , _ ("Please fill the following information")); + + table = gtk_table_new (6, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_box_pack_start (GTK_BOX (wiz->iax_account) , table , TRUE, TRUE, 0); + + // alias field + label = gtk_label_new_with_mnemonic (_ ("_Alias")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->iax_alias = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_alias); + gtk_table_attach (GTK_TABLE (table), wiz->iax_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // server field + label = gtk_label_new_with_mnemonic (_ ("_Host name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->iax_server = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_server); + gtk_table_attach (GTK_TABLE (table), wiz->iax_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // username field + label = gtk_label_new_with_mnemonic (_ ("_User name")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - wiz->iax_username = gtk_entry_new(); - gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (wiz->iax_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL)); + wiz->iax_username = gtk_entry_new(); + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (wiz->iax_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL)); #else - wiz->iax_username = sexy_icon_entry_new(); - image = gtk_image_new_from_file( ICONS_DIR "/stock_person.svg" ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(wiz->iax_username), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + wiz->iax_username = sexy_icon_entry_new(); + image = gtk_image_new_from_file (ICONS_DIR "/stock_person.svg"); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (wiz->iax_username), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_username); - gtk_table_attach ( GTK_TABLE( table ), wiz->iax_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_username); + gtk_table_attach (GTK_TABLE (table), wiz->iax_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - // password field - label = gtk_label_new_with_mnemonic (_("_Password")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); + // password field + label = gtk_label_new_with_mnemonic (_ ("_Password")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); #if GTK_CHECK_VERSION(2,16,0) - wiz->iax_password = gtk_entry_new(); + wiz->iax_password = gtk_entry_new(); gtk_entry_set_icon_from_stock (GTK_ENTRY (wiz->iax_password), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); #else - wiz->iax_password = sexy_icon_entry_new(); - image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR ); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(wiz->iax_password), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + wiz->iax_password = sexy_icon_entry_new(); + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (wiz->iax_password), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_password); - gtk_entry_set_visibility(GTK_ENTRY(wiz->iax_password), FALSE); - gtk_table_attach ( GTK_TABLE( table ), wiz->iax_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_password); + gtk_entry_set_visibility (GTK_ENTRY (wiz->iax_password), FALSE); + gtk_table_attach (GTK_TABLE (table), wiz->iax_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - clearTextCheckbox = gtk_check_button_new_with_mnemonic (_("Show password")); + clearTextCheckbox = gtk_check_button_new_with_mnemonic (_ ("Show password")); g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), wiz->iax_password); gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // voicemail number field - label = gtk_label_new_with_mnemonic (_("_Voicemail number")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->iax_voicemail = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_voicemail); - gtk_table_attach ( GTK_TABLE( table ), wiz->iax_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + label = gtk_label_new_with_mnemonic (_ ("_Voicemail number")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->iax_voicemail = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->iax_voicemail); + gtk_table_attach (GTK_TABLE (table), wiz->iax_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - current -> state = ACCOUNT_STATE_UNREGISTERED; + current -> state = ACCOUNT_STATE_UNREGISTERED; - g_signal_connect( G_OBJECT( wiz->assistant ) , "apply" , G_CALLBACK( iax_apply_callback ), NULL); + g_signal_connect (G_OBJECT (wiz->assistant) , "apply" , G_CALLBACK (iax_apply_callback), NULL); - return wiz->iax_account; + return wiz->iax_account; } -GtkWidget* build_nat_settings( void ) { - GtkWidget* label; - GtkWidget* table; - - wiz->nat = create_vbox( GTK_ASSISTANT_PAGE_CONFIRM , _("Network Address Translation (NAT)") , _("You should probably enable this if you are behind a firewall.")); - - // table - table = gtk_table_new ( 2, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(table), 10); - gtk_table_set_col_spacings( GTK_TABLE(table), 10); - gtk_box_pack_start( GTK_BOX(wiz->nat), table , TRUE, TRUE, 0); - - // enable - wiz->enable = gtk_check_button_new_with_mnemonic(_("E_nable STUN")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->enable), FALSE); - gtk_table_attach ( GTK_TABLE( table ), wiz->enable, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( wiz->enable ) , TRUE ); - g_signal_connect( G_OBJECT( GTK_TOGGLE_BUTTON(wiz->enable)) , "toggled" , G_CALLBACK( enable_stun ), NULL); - - // server address - label = gtk_label_new_with_mnemonic (_("_STUN server")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - wiz->addr = gtk_entry_new(); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->addr); - gtk_table_attach ( GTK_TABLE( table ), wiz->addr, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( wiz->addr ), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable))); - - g_signal_connect( G_OBJECT( wiz->assistant ) , "apply" , G_CALLBACK( sip_apply_callback ), NULL); - - return wiz->nat; +GtkWidget* build_nat_settings (void) +{ + GtkWidget* label; + GtkWidget* table; + + wiz->nat = create_vbox (GTK_ASSISTANT_PAGE_CONFIRM , _ ("Network Address Translation (NAT)") , _ ("You should probably enable this if you are behind a firewall.")); + + // table + table = gtk_table_new (2, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + gtk_box_pack_start (GTK_BOX (wiz->nat), table , TRUE, TRUE, 0); + + // enable + wiz->enable = gtk_check_button_new_with_mnemonic (_ ("E_nable STUN")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wiz->enable), FALSE); + gtk_table_attach (GTK_TABLE (table), wiz->enable, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->enable) , TRUE); + g_signal_connect (G_OBJECT (GTK_TOGGLE_BUTTON (wiz->enable)) , "toggled" , G_CALLBACK (enable_stun), NULL); + + // server address + label = gtk_label_new_with_mnemonic (_ ("_STUN server")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + wiz->addr = gtk_entry_new(); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), wiz->addr); + gtk_table_attach (GTK_TABLE (table), wiz->addr, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->addr), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wiz->enable))); + + g_signal_connect (G_OBJECT (wiz->assistant) , "apply" , G_CALLBACK (sip_apply_callback), NULL); + + return wiz->nat; } -GtkWidget* build_summary() { - wiz->summary = create_vbox( GTK_ASSISTANT_PAGE_SUMMARY , _("Account Registration") , _("Congratulations!")); +GtkWidget* build_summary() +{ + wiz->summary = create_vbox (GTK_ASSISTANT_PAGE_SUMMARY , _ ("Account Registration") , _ ("Congratulations!")); - strcpy(message,""); - wiz->label_summary = gtk_label_new(message) ; - gtk_label_set_selectable (GTK_LABEL(wiz->label_summary), TRUE); - gtk_misc_set_alignment(GTK_MISC(wiz->label_summary), 0, 0); - gtk_label_set_line_wrap(GTK_LABEL(wiz->label_summary), TRUE); - //gtk_widget_set_size_request(GTK_WIDGET(wiz->label_summary), 380, -1); - gtk_box_pack_start(GTK_BOX(wiz->summary), wiz->label_summary, FALSE, TRUE, 0); + strcpy (message,""); + wiz->label_summary = gtk_label_new (message) ; + gtk_label_set_selectable (GTK_LABEL (wiz->label_summary), TRUE); + gtk_misc_set_alignment (GTK_MISC (wiz->label_summary), 0, 0); + gtk_label_set_line_wrap (GTK_LABEL (wiz->label_summary), TRUE); + //gtk_widget_set_size_request(GTK_WIDGET(wiz->label_summary), 380, -1); + gtk_box_pack_start (GTK_BOX (wiz->summary), wiz->label_summary, FALSE, TRUE, 0); - return wiz->summary; + return wiz->summary; } -GtkWidget* build_registration_error() { - GtkWidget *label; - wiz->reg_failed = create_vbox( GTK_ASSISTANT_PAGE_SUMMARY , "Account Registration" , "Registration error"); +GtkWidget* build_registration_error() +{ + GtkWidget *label; + wiz->reg_failed = create_vbox (GTK_ASSISTANT_PAGE_SUMMARY , "Account Registration" , "Registration error"); - label = gtk_label_new(" Please correct the information.") ; - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1); - gtk_box_pack_start(GTK_BOX(wiz->reg_failed), label, FALSE, TRUE, 0); + label = gtk_label_new (" Please correct the information.") ; + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_widget_set_size_request (GTK_WIDGET (label), 380, -1); + gtk_box_pack_start (GTK_BOX (wiz->reg_failed), label, FALSE, TRUE, 0); - return wiz->reg_failed; + return wiz->reg_failed; } -void set_sip_infos_sentivite(gboolean b) { - gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_alias), b); - gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_server), b); - gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_username), b); - gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_password), b); +void set_sip_infos_sentivite (gboolean b) +{ + gtk_widget_set_sensitive (GTK_WIDGET (wiz->sip_alias), b); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->sip_server), b); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->sip_username), b); + gtk_widget_set_sensitive (GTK_WIDGET (wiz->sip_password), b); } -void prefill_sip(void) { - if (use_sflphone_org == 1) { - char alias[300]; - char *email; - email = (char *)gtk_entry_get_text (GTK_ENTRY(wiz->mailbox) ); - rest_account ra = get_rest_account(SFLPHONE_ORG_SERVER,email); - if (ra.success) { - set_sip_infos_sentivite(FALSE); - strcpy(alias,ra.user); - strcat(alias,"@"); - strcat(alias,"sip.sflphone.org"); - gtk_entry_set_text (GTK_ENTRY(wiz->sip_alias),alias ); - gtk_entry_set_text (GTK_ENTRY(wiz->sip_server), SFLPHONE_ORG_SERVER); - gtk_entry_set_text (GTK_ENTRY(wiz->sip_username), ra.user); - gtk_entry_set_text (GTK_ENTRY(wiz->sip_password), ra.passwd); - } - } +void prefill_sip (void) +{ + if (use_sflphone_org == 1) { + char alias[300]; + char *email; + email = (char *) gtk_entry_get_text (GTK_ENTRY (wiz->mailbox)); + rest_account ra = get_rest_account (SFLPHONE_ORG_SERVER,email); + + if (ra.success) { + set_sip_infos_sentivite (FALSE); + strcpy (alias,ra.user); + strcat (alias,"@"); + strcat (alias,"sip.sflphone.org"); + gtk_entry_set_text (GTK_ENTRY (wiz->sip_alias),alias); + gtk_entry_set_text (GTK_ENTRY (wiz->sip_server), SFLPHONE_ORG_SERVER); + gtk_entry_set_text (GTK_ENTRY (wiz->sip_username), ra.user); + gtk_entry_set_text (GTK_ENTRY (wiz->sip_password), ra.passwd); + } + } } typedef enum { - PAGE_INTRO, - PAGE_SFL, - PAGE_TYPE, - PAGE_SIP, - PAGE_STUN, - PAGE_IAX, - PAGE_EMAIL, - PAGE_SUMMARY + PAGE_INTRO, + PAGE_SFL, + PAGE_TYPE, + PAGE_SIP, + PAGE_STUN, + PAGE_IAX, + PAGE_EMAIL, + PAGE_SUMMARY } assistant_state; -static gint forward_page_func( gint current_page , gpointer data UNUSED) { - gint next_page = 0; - - switch( current_page ){ - case PAGE_INTRO: - next_page = PAGE_SFL; - break; - case PAGE_SFL: - if (use_sflphone_org) { - next_page = PAGE_EMAIL; - } else - next_page = PAGE_TYPE; - break; - case PAGE_TYPE: - if( account_type == _SIP ) { - set_sip_infos_sentivite(TRUE); - next_page = PAGE_SIP; - } else - next_page = PAGE_IAX; - break; - case PAGE_SIP: - next_page = PAGE_STUN; - break; - case PAGE_EMAIL: - next_page = PAGE_STUN; - break; - case PAGE_STUN: - next_page = PAGE_SUMMARY; - break; - case PAGE_IAX: - next_page = PAGE_SUMMARY; - break; - case PAGE_SUMMARY: - next_page = PAGE_SUMMARY; - break; - default: - next_page = -1; - } - return next_page; +static gint forward_page_func (gint current_page , gpointer data UNUSED) +{ + gint next_page = 0; + + switch (current_page) { + case PAGE_INTRO: + next_page = PAGE_SFL; + break; + case PAGE_SFL: + + if (use_sflphone_org) { + next_page = PAGE_EMAIL; + } else + next_page = PAGE_TYPE; + + break; + case PAGE_TYPE: + + if (account_type == _SIP) { + set_sip_infos_sentivite (TRUE); + next_page = PAGE_SIP; + } else + next_page = PAGE_IAX; + + break; + case PAGE_SIP: + next_page = PAGE_STUN; + break; + case PAGE_EMAIL: + next_page = PAGE_STUN; + break; + case PAGE_STUN: + next_page = PAGE_SUMMARY; + break; + case PAGE_IAX: + next_page = PAGE_SUMMARY; + break; + case PAGE_SUMMARY: + next_page = PAGE_SUMMARY; + break; + default: + next_page = -1; + } + + return next_page; } -static GtkWidget* create_vbox(GtkAssistantPageType type, const gchar *title, const gchar *section) { - GtkWidget *vbox; - GtkWidget *label; - gchar *str; +static GtkWidget* create_vbox (GtkAssistantPageType type, const gchar *title, const gchar *section) +{ + GtkWidget *vbox; + GtkWidget *label; + gchar *str; + + vbox = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 24); - vbox = gtk_vbox_new(FALSE, 6); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); + gtk_assistant_append_page (GTK_ASSISTANT (wiz->assistant), vbox); + gtk_assistant_set_page_type (GTK_ASSISTANT (wiz->assistant), vbox, type); + str = g_strdup_printf (" %s", title); + gtk_assistant_set_page_title (GTK_ASSISTANT (wiz->assistant), vbox, str); - gtk_assistant_append_page(GTK_ASSISTANT(wiz->assistant), vbox); - gtk_assistant_set_page_type(GTK_ASSISTANT(wiz->assistant), vbox, type); - str = g_strdup_printf(" %s", title); - gtk_assistant_set_page_title(GTK_ASSISTANT(wiz->assistant), vbox, str); + g_free (str); - g_free(str); + gtk_assistant_set_page_complete (GTK_ASSISTANT (wiz->assistant), vbox, TRUE); - gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), vbox, TRUE); + wiz->logo = gdk_pixbuf_new_from_file (LOGO, NULL); + gtk_assistant_set_page_header_image (GTK_ASSISTANT (wiz->assistant),vbox, wiz->logo); + g_object_unref (wiz->logo); - wiz->logo = gdk_pixbuf_new_from_file(LOGO, NULL); - gtk_assistant_set_page_header_image(GTK_ASSISTANT(wiz->assistant),vbox, wiz->logo); - g_object_unref(wiz->logo); + if (section) { + label = gtk_label_new (NULL); + str = g_strdup_printf ("<b>%s</b>\n", section); + gtk_label_set_markup (GTK_LABEL (label), str); + g_free (str); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + } - if (section) { - label = gtk_label_new(NULL); - str = g_strdup_printf("<b>%s</b>\n", section); - gtk_label_set_markup(GTK_LABEL(label), str); - g_free(str); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - } - return vbox; + return vbox; } #endif // GTK_CHECK_VERSION diff --git a/sflphone-client-gnome/src/config/assistant.h b/sflphone-client-gnome/src/config/assistant.h index 2ac083e04cb5d26ab14208291d50896a2bbe5f00..314ac7624e3e14e1fc0e3d6f3e66f5aedb486eb8 100644 --- a/sflphone-client-gnome/src/config/assistant.h +++ b/sflphone-client-gnome/src/config/assistant.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -42,49 +42,48 @@ #define _SIP 0 #define _IAX 1 -struct _wizard -{ - GtkWidget *window; - GtkWidget *assistant; - GdkPixbuf *logo; - GtkWidget *intro; - /** Page 1 - Protocol selection */ - GtkWidget *account_type; - GtkWidget *protocols; - GtkWidget *sip; - GtkWidget *email; - GtkWidget *iax; - /** Page 2 - SIP account creation */ - GtkWidget *sip_account; - GtkWidget *sip_alias; - GtkWidget *sip_server; - GtkWidget *sip_username; - GtkWidget *sip_password; - GtkWidget *sip_voicemail; - GtkWidget *test; - GtkWidget *state; - GtkWidget *mailbox; - GtkWidget *zrtp_enable; - /** Page 3 - IAX account creation */ - GtkWidget *iax_account; - GtkWidget *iax_alias; - GtkWidget *iax_server; - GtkWidget *iax_username; - GtkWidget *iax_password; - GtkWidget *iax_voicemail; - /** Page 4 - Nat detection */ - GtkWidget *nat; - GtkWidget *enable; - GtkWidget *addr; - /** Page 5 - Registration successful*/ - GtkWidget *summary; - GtkWidget *label_summary; - /** Page 6 - Registration failed*/ - GtkWidget *reg_failed; - - GtkWidget *sflphone_org; - -}; +struct _wizard { + GtkWidget *window; + GtkWidget *assistant; + GdkPixbuf *logo; + GtkWidget *intro; + /** Page 1 - Protocol selection */ + GtkWidget *account_type; + GtkWidget *protocols; + GtkWidget *sip; + GtkWidget *email; + GtkWidget *iax; + /** Page 2 - SIP account creation */ + GtkWidget *sip_account; + GtkWidget *sip_alias; + GtkWidget *sip_server; + GtkWidget *sip_username; + GtkWidget *sip_password; + GtkWidget *sip_voicemail; + GtkWidget *test; + GtkWidget *state; + GtkWidget *mailbox; + GtkWidget *zrtp_enable; + /** Page 3 - IAX account creation */ + GtkWidget *iax_account; + GtkWidget *iax_alias; + GtkWidget *iax_server; + GtkWidget *iax_username; + GtkWidget *iax_password; + GtkWidget *iax_voicemail; + /** Page 4 - Nat detection */ + GtkWidget *nat; + GtkWidget *enable; + GtkWidget *addr; + /** Page 5 - Registration successful*/ + GtkWidget *summary; + GtkWidget *label_summary; + /** Page 6 - Registration failed*/ + GtkWidget *reg_failed; + + GtkWidget *sflphone_org; + +}; /** * @file druid.h @@ -94,7 +93,7 @@ struct _wizard /** * Callbacks functions */ -void set_account_type( GtkWidget* widget , gpointer data ); +void set_account_type (GtkWidget* widget , gpointer data); //static void cancel_callback( void ); @@ -103,20 +102,20 @@ void set_account_type( GtkWidget* widget , gpointer data ); //static void sip_apply_callback( void ); //static void iax_apply_callback( void ); -void enable_stun( GtkWidget *widget ); +void enable_stun (GtkWidget *widget); /** * Related-pages function */ void build_wizard(); -GtkWidget* build_intro( void ); -GtkWidget* build_select_account( void ); -GtkWidget* build_sip_account_configuration( void ); -GtkWidget* build_nat_settings( void ); -GtkWidget* build_iax_account_configuration( void ); -GtkWidget* build_summary( void ); -GtkWidget* build_registration_error( void ); -GtkWidget* build_email_configuration( void ); +GtkWidget* build_intro (void); +GtkWidget* build_select_account (void); +GtkWidget* build_sip_account_configuration (void); +GtkWidget* build_nat_settings (void); +GtkWidget* build_iax_account_configuration (void); +GtkWidget* build_summary (void); +GtkWidget* build_registration_error (void); +GtkWidget* build_email_configuration (void); GtkWidget* build_sfl_or_account (void); /** diff --git a/sflphone-client-gnome/src/config/audioconf.c b/sflphone-client-gnome/src/config/audioconf.c index 6e53c63702e24b5126d18ec00df3dda07f379ee8..95916f25395b301eab08b9aeb04e5d91abb07635 100644 --- a/sflphone-client-gnome/src/config/audioconf.c +++ b/sflphone-client-gnome/src/config/audioconf.c @@ -31,6 +31,8 @@ #include <audioconf.h> #include <utils.h> #include <string.h> +#include <eel-gconf-extensions.h> +#include "dbus/dbus.h" GtkListStore *pluginlist; GtkListStore *outputlist; @@ -52,111 +54,111 @@ GtkWidget *noise_conf; // Codec properties ID enum { - COLUMN_CODEC_ACTIVE, - COLUMN_CODEC_NAME, - COLUMN_CODEC_FREQUENCY, - COLUMN_CODEC_BITRATE, - COLUMN_CODEC_BANDWIDTH, - CODEC_COLUMN_COUNT + COLUMN_CODEC_ACTIVE, + COLUMN_CODEC_NAME, + COLUMN_CODEC_FREQUENCY, + COLUMN_CODEC_BITRATE, + COLUMN_CODEC_BANDWIDTH, + CODEC_COLUMN_COUNT }; /** * Fills the tree list with supported codecs */ -void preferences_dialog_fill_codec_list (account_t **a) { - - GtkListStore *codecStore; - GtkTreeIter iter; - GQueue *current; - - // Get model of view and clear it - codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); - gtk_list_store_clear (codecStore); - - if ((*a) != NULL) { - current = (*a)->codecs; - } - else { - // Failover - current = get_system_codec_list (); - } - - - // Insert codecs - unsigned int i; - for(i = 0; i < current->length; i++) - { - codec_t *c = codec_list_get_nth (i, current); - if (c) - { - DEBUG ("%s", c->name); - gtk_list_store_append (codecStore, &iter); - gtk_list_store_set (codecStore, &iter, - COLUMN_CODEC_ACTIVE, c->is_active, // Active - COLUMN_CODEC_NAME, c->name, // Name - COLUMN_CODEC_FREQUENCY, g_strdup_printf("%d kHz", c->sample_rate/1000), // Frequency (kHz) - COLUMN_CODEC_BITRATE, g_strdup_printf("%.1f kbps", c->_bitrate), // Bitrate (kbps) - COLUMN_CODEC_BANDWIDTH, g_strdup_printf("%.1f kbps", c->_bandwidth), // Bandwidth (kpbs) - -1); - } - } +void preferences_dialog_fill_codec_list (account_t **a) +{ + + GtkListStore *codecStore; + GtkTreeIter iter; + GQueue *current; + + // Get model of view and clear it + codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); + gtk_list_store_clear (codecStore); + + if ( (*a) != NULL) { + current = (*a)->codecs; + } else { + // Failover + current = get_system_codec_list (); + } + + + // Insert codecs + unsigned int i; + + for (i = 0; i < current->length; i++) { + codec_t *c = codec_list_get_nth (i, current); + + if (c) { + DEBUG ("%s", c->name); + gtk_list_store_append (codecStore, &iter); + gtk_list_store_set (codecStore, &iter, + COLUMN_CODEC_ACTIVE, c->is_active, // Active + COLUMN_CODEC_NAME, c->name, // Name + COLUMN_CODEC_FREQUENCY, g_strdup_printf ("%d kHz", c->sample_rate/1000), // Frequency (kHz) + COLUMN_CODEC_BITRATE, g_strdup_printf ("%.1f kbps", c->_bitrate), // Bitrate (kbps) + COLUMN_CODEC_BANDWIDTH, g_strdup_printf ("%.1f kbps", c->_bandwidth), // Bandwidth (kpbs) + -1); + } + } } /** * Fill store with output audio plugins */ - void +void preferences_dialog_fill_audio_plugin_list() { - GtkTreeIter iter; - gchar** list; - gchar* managerName; - - gtk_list_store_clear(pluginlist); - - // Call dbus to retreive list - list = dbus_get_audio_plugin_list(); - // For each API name included in list - int c = 0; - - if (list != NULL){ - for(managerName = list[c]; managerName != NULL; managerName = list[c]) - { - c++; - gtk_list_store_append(pluginlist, &iter); - gtk_list_store_set(pluginlist, &iter, 0 , managerName, -1); - } - } - list = NULL; + GtkTreeIter iter; + gchar** list; + gchar* managerName; + + gtk_list_store_clear (pluginlist); + + // Call dbus to retreive list + list = dbus_get_audio_plugin_list(); + // For each API name included in list + int c = 0; + + if (list != NULL) { + for (managerName = list[c]; managerName != NULL; managerName = list[c]) { + c++; + gtk_list_store_append (pluginlist, &iter); + gtk_list_store_set (pluginlist, &iter, 0 , managerName, -1); + } + } + + list = NULL; } /** * Fill output audio device store */ - void +void preferences_dialog_fill_output_audio_device_list() { - GtkTreeIter iter; - gchar** list; - gchar** audioDevice; - int index; - - gtk_list_store_clear(outputlist); - - // Call dbus to retreive list - list = dbus_get_audio_output_device_list(); - - // For each device name included in list - int c = 0; - for(audioDevice = list; *list ; list++) - { - index = dbus_get_audio_device_index( *list ); - gtk_list_store_append(outputlist, &iter); - gtk_list_store_set(outputlist, &iter, 0, *list, 1, index, -1); - c++; - } + GtkTreeIter iter; + gchar** list; + gchar** audioDevice; + int index; + + gtk_list_store_clear (outputlist); + + // Call dbus to retreive list + list = dbus_get_audio_output_device_list(); + + // For each device name included in list + int c = 0; + + for (audioDevice = list; *list ; list++) { + index = dbus_get_audio_device_index (*list); + gtk_list_store_append (outputlist, &iter); + gtk_list_store_set (outputlist, &iter, 0, *list, 1, index, -1); + c++; + } } @@ -173,18 +175,19 @@ preferences_dialog_fill_ringtone_audio_device_list() gchar** audioDevice; int index; - gtk_list_store_clear(ringtonelist); + gtk_list_store_clear (ringtonelist); // Call dbus to retreive output device list = dbus_get_audio_output_device_list(); // For each device name in the list int c = 0; - for(audioDevice = list; *list; list++) { - index = dbus_get_audio_device_index( *list ); - gtk_list_store_append(ringtonelist, &iter); - gtk_list_store_set(ringtonelist, &iter, 0, *list, 1, index, -1); - c++; + + for (audioDevice = list; *list; list++) { + index = dbus_get_audio_device_index (*list); + gtk_list_store_append (ringtonelist, &iter); + gtk_list_store_set (ringtonelist, &iter, 0, *list, 1, index, -1); + c++; } } @@ -193,810 +196,788 @@ preferences_dialog_fill_ringtone_audio_device_list() /** * Select active output audio device */ - void +void select_active_output_audio_device() { - if( SHOW_ALSA_CONF ) - { - - GtkTreeModel* model; - GtkTreeIter iter; - gchar** devices; - int currentDeviceIndex; - int deviceIndex; - - // Select active output device on server - devices = dbus_get_current_audio_devices_index(); - currentDeviceIndex = atoi(devices[0]); - DEBUG("audio device index for output = %d", currentDeviceIndex); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(output)); - - // Find the currently set output device - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - if(deviceIndex == currentDeviceIndex) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(output), &iter); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active output device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(output), 0); - } + if (SHOW_ALSA_CONF) { + + GtkTreeModel* model; + GtkTreeIter iter; + gchar** devices; + int currentDeviceIndex; + int deviceIndex; + + // Select active output device on server + devices = dbus_get_current_audio_devices_index(); + currentDeviceIndex = atoi (devices[0]); + DEBUG ("audio device index for output = %d", currentDeviceIndex); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (output)); + + // Find the currently set output device + gtk_tree_model_get_iter_first (model, &iter); + + do { + gtk_tree_model_get (model, &iter, 1, &deviceIndex, -1); + + if (deviceIndex == currentDeviceIndex) { + // Set current iteration the active one + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (output), &iter); + return; + } + } while (gtk_tree_model_iter_next (model, &iter)); + + // No index was found, select first one + WARN ("Warning : No active output device found"); + gtk_combo_box_set_active (GTK_COMBO_BOX (output), 0); + } } /** * Select active output audio device */ - void +void select_active_ringtone_audio_device() { - if( SHOW_ALSA_CONF ) - { - - GtkTreeModel* model; - GtkTreeIter iter; - gchar** devices; - int currentDeviceIndex; - int deviceIndex; - - // Select active ringtone device on server - devices = dbus_get_current_audio_devices_index(); - currentDeviceIndex = atoi(devices[2]); - DEBUG("audio device index for ringtone = %d", currentDeviceIndex); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(ringtone)); - - // Find the currently set ringtone device - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - if(deviceIndex == currentDeviceIndex) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(ringtone), &iter); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active ringtone device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(ringtone), 0); - } + if (SHOW_ALSA_CONF) { + + GtkTreeModel* model; + GtkTreeIter iter; + gchar** devices; + int currentDeviceIndex; + int deviceIndex; + + // Select active ringtone device on server + devices = dbus_get_current_audio_devices_index(); + currentDeviceIndex = atoi (devices[2]); + DEBUG ("audio device index for ringtone = %d", currentDeviceIndex); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (ringtone)); + + // Find the currently set ringtone device + gtk_tree_model_get_iter_first (model, &iter); + + do { + gtk_tree_model_get (model, &iter, 1, &deviceIndex, -1); + + if (deviceIndex == currentDeviceIndex) { + // Set current iteration the active one + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (ringtone), &iter); + return; + } + } while (gtk_tree_model_iter_next (model, &iter)); + + // No index was found, select first one + WARN ("Warning : No active ringtone device found"); + gtk_combo_box_set_active (GTK_COMBO_BOX (ringtone), 0); + } } /** * Fill input audio device store */ - void +void preferences_dialog_fill_input_audio_device_list() { - GtkTreeIter iter; - gchar** list; - gchar** audioDevice; - int index ; - gtk_list_store_clear(inputlist); - - // Call dbus to retreive list - list = dbus_get_audio_input_device_list(); - - // For each device name included in list - //int c = 0; - for(audioDevice = list; *list; list++) - { - index = dbus_get_audio_device_index( *list ); - gtk_list_store_append(inputlist, &iter); - gtk_list_store_set(inputlist, &iter, 0, *list, 1, index, -1); - //c++; - } + GtkTreeIter iter; + gchar** list; + gchar** audioDevice; + int index ; + gtk_list_store_clear (inputlist); + + // Call dbus to retreive list + list = dbus_get_audio_input_device_list(); + + // For each device name included in list + //int c = 0; + for (audioDevice = list; *list; list++) { + index = dbus_get_audio_device_index (*list); + gtk_list_store_append (inputlist, &iter); + gtk_list_store_set (inputlist, &iter, 0, *list, 1, index, -1); + //c++; + } } /** * Select active input audio device */ - void +void select_active_input_audio_device() { - if( SHOW_ALSA_CONF) - { - - GtkTreeModel* model; - GtkTreeIter iter; - gchar** devices; - int currentDeviceIndex; - int deviceIndex; - - // Select active input device on server - devices = dbus_get_current_audio_devices_index(); - currentDeviceIndex = atoi(devices[1]); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(input)); - - // Find the currently set input device - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - if(deviceIndex == currentDeviceIndex) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(input), &iter); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active input device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(input), 0); - } + if (SHOW_ALSA_CONF) { + + GtkTreeModel* model; + GtkTreeIter iter; + gchar** devices; + int currentDeviceIndex; + int deviceIndex; + + // Select active input device on server + devices = dbus_get_current_audio_devices_index(); + currentDeviceIndex = atoi (devices[1]); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (input)); + + // Find the currently set input device + gtk_tree_model_get_iter_first (model, &iter); + + do { + gtk_tree_model_get (model, &iter, 1, &deviceIndex, -1); + + if (deviceIndex == currentDeviceIndex) { + // Set current iteration the active one + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (input), &iter); + return; + } + } while (gtk_tree_model_iter_next (model, &iter)); + + // No index was found, select first one + WARN ("Warning : No active input device found"); + gtk_combo_box_set_active (GTK_COMBO_BOX (input), 0); + } } /** * Select the output audio plugin by calling the server */ - static void -select_output_audio_plugin(GtkComboBox* widget, gpointer data UNUSED) +static void +select_output_audio_plugin (GtkComboBox* widget, gpointer data UNUSED) { - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - gchar* pluginName; - - comboBoxIndex = gtk_combo_box_get_active(widget); - - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(widget); - gtk_combo_box_get_active_iter(widget, &iter); - gtk_tree_model_get(model, &iter, 0, &pluginName, -1); - dbus_set_output_audio_plugin(pluginName); - //update_combo_box( pluginName); - } + GtkTreeModel* model; + GtkTreeIter iter; + int comboBoxIndex; + gchar* pluginName; + + comboBoxIndex = gtk_combo_box_get_active (widget); + + if (comboBoxIndex >= 0) { + model = gtk_combo_box_get_model (widget); + gtk_combo_box_get_active_iter (widget, &iter); + gtk_tree_model_get (model, &iter, 0, &pluginName, -1); + dbus_set_output_audio_plugin (pluginName); + //update_combo_box( pluginName); + } } /** * Select active output audio plugin */ - void +void select_active_output_audio_plugin() { - GtkTreeModel* model; - GtkTreeIter iter; - gchar* pluginname; - gchar* tmp; - - // Select active output device on server - pluginname = dbus_get_current_audio_output_plugin(); - tmp = pluginname; - model = gtk_combo_box_get_model(GTK_COMBO_BOX(plugin)); - - // Find the currently alsa plugin - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 0, &pluginname , -1); - if( g_strcasecmp( tmp , pluginname ) == 0 ) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter); - //update_combo_box( plugin ); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active output device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(plugin), 0); + GtkTreeModel* model; + GtkTreeIter iter; + gchar* pluginname; + gchar* tmp; + + // Select active output device on server + pluginname = dbus_get_current_audio_output_plugin(); + tmp = pluginname; + model = gtk_combo_box_get_model (GTK_COMBO_BOX (plugin)); + + // Find the currently alsa plugin + gtk_tree_model_get_iter_first (model, &iter); + + do { + gtk_tree_model_get (model, &iter, 0, &pluginname , -1); + + if (g_strcasecmp (tmp , pluginname) == 0) { + // Set current iteration the active one + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (plugin), &iter); + //update_combo_box( plugin ); + return; + } + } while (gtk_tree_model_iter_next (model, &iter)); + + // No index was found, select first one + WARN ("Warning : No active output device found"); + gtk_combo_box_set_active (GTK_COMBO_BOX (plugin), 0); } /** * Set the audio output device on the server with its index */ - static void -select_audio_output_device(GtkComboBox* comboBox, gpointer data UNUSED) +static void +select_audio_output_device (GtkComboBox* comboBox, gpointer data UNUSED) { - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - int deviceIndex; + GtkTreeModel* model; + GtkTreeIter iter; + int comboBoxIndex; + int deviceIndex; - comboBoxIndex = gtk_combo_box_get_active(comboBox); + comboBoxIndex = gtk_combo_box_get_active (comboBox); - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(comboBox); - gtk_combo_box_get_active_iter(comboBox, &iter); - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); + if (comboBoxIndex >= 0) { + model = gtk_combo_box_get_model (comboBox); + gtk_combo_box_get_active_iter (comboBox, &iter); + gtk_tree_model_get (model, &iter, 1, &deviceIndex, -1); - dbus_set_audio_output_device(deviceIndex); - } + dbus_set_audio_output_device (deviceIndex); + } } /** * Set the audio input device on the server with its index - */ - static void -select_audio_input_device(GtkComboBox* comboBox, gpointer data UNUSED) -{ - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - int deviceIndex; - - comboBoxIndex = gtk_combo_box_get_active(comboBox); - - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(comboBox); - gtk_combo_box_get_active_iter(comboBox, &iter); - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - - dbus_set_audio_input_device(deviceIndex); - } -} - -/** - * Set the audio ringtone device on the server with its index */ static void -select_audio_ringtone_device(GtkComboBox *comboBox, gpointer data UNUSED) +select_audio_input_device (GtkComboBox* comboBox, gpointer data UNUSED) { - GtkTreeModel *model; + GtkTreeModel* model; GtkTreeIter iter; int comboBoxIndex; int deviceIndex; - comboBoxIndex = gtk_combo_box_get_active(comboBox); + comboBoxIndex = gtk_combo_box_get_active (comboBox); - if(comboBoxIndex >= 0) { - model = gtk_combo_box_get_model(comboBox); - gtk_combo_box_get_active_iter(comboBox, &iter); + if (comboBoxIndex >= 0) { + model = gtk_combo_box_get_model (comboBox); + gtk_combo_box_get_active_iter (comboBox, &iter); + gtk_tree_model_get (model, &iter, 1, &deviceIndex, -1); - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - - dbus_set_audio_ringtone_device(deviceIndex); + dbus_set_audio_input_device (deviceIndex); } } /** * Toggle move buttons on if a codec is selected, off elsewise */ - static void -select_codec(GtkTreeSelection *selection, GtkTreeModel *model) +static void +select_codec (GtkTreeSelection *selection, GtkTreeModel *model) { - GtkTreeIter iter; - - if(!gtk_tree_selection_get_selected(selection, &model, &iter)) - { - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); - } - else - { - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), TRUE); - } + GtkTreeIter iter; + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveUpButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveDownButton), FALSE); + } else { + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveUpButton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveDownButton), TRUE); + } } /** * Toggle active value of codec on click and update changes to the deamon * and in configuration files */ - static void -codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data ) +static void +codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data) { - GtkTreeIter iter; - GtkTreePath *treePath; - GtkTreeModel *model; - gboolean active; - char* name; - char* srate; - codec_t* codec; - account_t *acc; - - // Get path of clicked codec active toggle box - treePath = gtk_tree_path_new_from_string(path); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); - gtk_tree_model_get_iter(model, &iter, treePath); - - // Retrieve userdata - acc = (account_t*) data; - - if (!acc) - ERROR ("Aie, no account selected"); - - // Get active value and name at iteration - gtk_tree_model_get(model, &iter, - COLUMN_CODEC_ACTIVE, &active, - COLUMN_CODEC_NAME, &name, - COLUMN_CODEC_FREQUENCY, &srate, - -1); - - printf("%s, %s\n", name, srate); - printf("%i\n", g_queue_get_length (acc->codecs)); - - // codec_list_get_by_name(name); - if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"8 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 110, acc->codecs); - else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"16 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 111, acc->codecs); - else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"32 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 112, acc->codecs); - else - codec = codec_list_get_by_name ((gconstpointer) name, acc->codecs); - - // Toggle active value - active = !active; - - // Store value - gtk_list_store_set(GTK_LIST_STORE(model), &iter, - COLUMN_CODEC_ACTIVE, active, - -1); - - gtk_tree_path_free(treePath); - - // Modify codec queue to represent change - if (active) - codec_set_active (&codec); - else - codec_set_inactive (&codec); - - // Perpetuate changes to the deamon - // codec_list_update_to_daemon (acc); + GtkTreeIter iter; + GtkTreePath *treePath; + GtkTreeModel *model; + gboolean active; + char* name; + char* srate; + codec_t* codec; + account_t *acc; + + // Get path of clicked codec active toggle box + treePath = gtk_tree_path_new_from_string (path); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); + gtk_tree_model_get_iter (model, &iter, treePath); + + // Retrieve userdata + acc = (account_t*) data; + + if (!acc) + ERROR ("Aie, no account selected"); + + // Get active value and name at iteration + gtk_tree_model_get (model, &iter, + COLUMN_CODEC_ACTIVE, &active, + COLUMN_CODEC_NAME, &name, + COLUMN_CODEC_FREQUENCY, &srate, + -1); + + printf ("%s, %s\n", name, srate); + printf ("%i\n", g_queue_get_length (acc->codecs)); + + // codec_list_get_by_name(name); + if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"8 kHz") ==0)) + codec = codec_list_get_by_payload ( (gconstpointer) 110, acc->codecs); + else if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"16 kHz") ==0)) + codec = codec_list_get_by_payload ( (gconstpointer) 111, acc->codecs); + else if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"32 kHz") ==0)) + codec = codec_list_get_by_payload ( (gconstpointer) 112, acc->codecs); + else + codec = codec_list_get_by_name ( (gconstpointer) name, acc->codecs); + + // Toggle active value + active = !active; + + // Store value + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COLUMN_CODEC_ACTIVE, active, + -1); + + gtk_tree_path_free (treePath); + + // Modify codec queue to represent change + if (active) + codec_set_active (&codec); + else + codec_set_inactive (&codec); + + // Perpetuate changes to the deamon + // codec_list_update_to_daemon (acc); } /** * Move codec in list depending on direction and selected codec and * update changes in the daemon list and the configuration files */ -static void codec_move (gboolean moveUp, gpointer data) { - - GtkTreeIter iter; - GtkTreeIter *iter2; - GtkTreeView *treeView; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreePath *treePath; - gchar *path; - account_t *acc; - GQueue *acc_q; - - // Get view, model and selection of codec store - model = gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView)); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); - - // Retrieve the user data - acc = (account_t*) data; - if (acc) - acc_q = acc->codecs; - - // Find selected iteration and create a copy - gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection), &model, &iter); - iter2 = gtk_tree_iter_copy(&iter); - - // Find path of iteration - path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(model), &iter); - treePath = gtk_tree_path_new_from_string(path); - gint *indices = gtk_tree_path_get_indices(treePath); - gint indice = indices[0]; - - // Depending on button direction get new path - if(moveUp) - gtk_tree_path_prev(treePath); - else - gtk_tree_path_next(treePath); - gtk_tree_model_get_iter(model, &iter, treePath); - - // Swap iterations if valid - if(gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter)) - gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter2); - - // Scroll to new position - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (codecTreeView), treePath, NULL, FALSE, 0, 0); - - // Free resources - gtk_tree_path_free(treePath); - gtk_tree_iter_free(iter2); - g_free(path); - - // Perpetuate changes in codec queue - if(moveUp) - codec_list_move_codec_up (indice, &acc_q); - else - codec_list_move_codec_down (indice, &acc_q); +static void codec_move (gboolean moveUp, gpointer data) +{ + + GtkTreeIter iter; + GtkTreeIter *iter2; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreePath *treePath; + gchar *path; + account_t *acc; + GQueue *acc_q; + + // Get view, model and selection of codec store + model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (codecTreeView)); + + // Retrieve the user data + acc = (account_t*) data; + + if (acc) + acc_q = acc->codecs; + + // Find selected iteration and create a copy + gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter); + iter2 = gtk_tree_iter_copy (&iter); + + // Find path of iteration + path = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), &iter); + treePath = gtk_tree_path_new_from_string (path); + gint *indices = gtk_tree_path_get_indices (treePath); + gint indice = indices[0]; + + // Depending on button direction get new path + if (moveUp) + gtk_tree_path_prev (treePath); + else + gtk_tree_path_next (treePath); + + gtk_tree_model_get_iter (model, &iter, treePath); + + // Swap iterations if valid + if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (model), &iter)) + gtk_list_store_swap (GTK_LIST_STORE (model), &iter, iter2); + + // Scroll to new position + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (codecTreeView), treePath, NULL, FALSE, 0, 0); + + // Free resources + gtk_tree_path_free (treePath); + gtk_tree_iter_free (iter2); + g_free (path); + + // Perpetuate changes in codec queue + if (moveUp) + codec_list_move_codec_up (indice, &acc_q); + else + codec_list_move_codec_down (indice, &acc_q); } /** * Called from move up codec button signal */ -static void codec_move_up (GtkButton *button UNUSED, gpointer data) { +static void codec_move_up (GtkButton *button UNUSED, gpointer data) +{ - // Change tree view ordering and get indice changed - codec_move (TRUE, data); + // Change tree view ordering and get indice changed + codec_move (TRUE, data); } /** * Called from move down codec button signal */ -static void codec_move_down(GtkButton *button UNUSED, gpointer data) { +static void codec_move_down (GtkButton *button UNUSED, gpointer data) +{ - // Change tree view ordering and get indice changed - codec_move (FALSE, data); + // Change tree view ordering and get indice changed + codec_move (FALSE, data); } GtkWidget* codecs_box (account_t **a) { - GtkWidget *ret; - GtkWidget *scrolledWindow; - GtkWidget *buttonBox; - - GtkListStore *codecStore; - GtkCellRenderer *renderer; - GtkTreeSelection *treeSelection; - GtkTreeViewColumn *treeViewColumn; - - ret = gtk_hbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); - - scrolledWindow = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_SHADOW_IN); - - gtk_box_pack_start(GTK_BOX(ret), scrolledWindow, TRUE, TRUE, 0); - codecStore = gtk_list_store_new(CODEC_COLUMN_COUNT, - G_TYPE_BOOLEAN, // Active - G_TYPE_STRING, // Name - G_TYPE_STRING, // Frequency - G_TYPE_STRING, // Bit rate - G_TYPE_STRING // Bandwith - ); - - // Create codec tree view with list store - codecTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore)); - - // Get tree selection manager - treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); - g_signal_connect(G_OBJECT(treeSelection), "changed", - G_CALLBACK (select_codec), - codecStore); - - // Active column - renderer = gtk_cell_renderer_toggle_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("", renderer, "active", COLUMN_CODEC_ACTIVE, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - - // Toggle codec active property on clicked - g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK (codec_active_toggled), (gpointer) *a); - - // Name column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "markup", COLUMN_CODEC_NAME, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - - // Bit rate column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Frequency"), renderer, "text", COLUMN_CODEC_FREQUENCY, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - - // Bandwith column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - - // Frequency column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - - g_object_unref(G_OBJECT(codecStore)); - gtk_container_add(GTK_CONTAINER(scrolledWindow), codecTreeView); - - // Create button box - buttonBox = gtk_vbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(buttonBox), 10); - gtk_box_pack_start(GTK_BOX(ret), buttonBox, FALSE, FALSE, 0); - - codecMoveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveUpButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(codecMoveUpButton), "clicked", G_CALLBACK(codec_move_up), *a); - - codecMoveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveDownButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked", G_CALLBACK(codec_move_down), *a); - - preferences_dialog_fill_codec_list (a); - - return ret; + GtkWidget *ret; + GtkWidget *scrolledWindow; + GtkWidget *buttonBox; + + GtkListStore *codecStore; + GtkCellRenderer *renderer; + GtkTreeSelection *treeSelection; + GtkTreeViewColumn *treeViewColumn; + + ret = gtk_hbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); + + scrolledWindow = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindow), GTK_SHADOW_IN); + + gtk_box_pack_start (GTK_BOX (ret), scrolledWindow, TRUE, TRUE, 0); + codecStore = gtk_list_store_new (CODEC_COLUMN_COUNT, + G_TYPE_BOOLEAN, // Active + G_TYPE_STRING, // Name + G_TYPE_STRING, // Frequency + G_TYPE_STRING, // Bit rate + G_TYPE_STRING // Bandwith + ); + + // Create codec tree view with list store + codecTreeView = gtk_tree_view_new_with_model (GTK_TREE_MODEL (codecStore)); + + // Get tree selection manager + treeSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (codecTreeView)); + g_signal_connect (G_OBJECT (treeSelection), "changed", + G_CALLBACK (select_codec), + codecStore); + + // Active column + renderer = gtk_cell_renderer_toggle_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes ("", renderer, "active", COLUMN_CODEC_ACTIVE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); + + // Toggle codec active property on clicked + g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (codec_active_toggled), (gpointer) *a); + + // Name column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Name"), renderer, "markup", COLUMN_CODEC_NAME, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); + + // Bit rate column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Frequency"), renderer, "text", COLUMN_CODEC_FREQUENCY, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); + + // Bandwith column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); + + // Frequency column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); + + g_object_unref (G_OBJECT (codecStore)); + gtk_container_add (GTK_CONTAINER (scrolledWindow), codecTreeView); + + // Create button box + buttonBox = gtk_vbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (buttonBox), 10); + gtk_box_pack_start (GTK_BOX (ret), buttonBox, FALSE, FALSE, 0); + + codecMoveUpButton = gtk_button_new_from_stock (GTK_STOCK_GO_UP); + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveUpButton), FALSE); + gtk_box_pack_start (GTK_BOX (buttonBox), codecMoveUpButton, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (codecMoveUpButton), "clicked", G_CALLBACK (codec_move_up), *a); + + codecMoveDownButton = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN); + gtk_widget_set_sensitive (GTK_WIDGET (codecMoveDownButton), FALSE); + gtk_box_pack_start (GTK_BOX (buttonBox), codecMoveDownButton, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (codecMoveDownButton), "clicked", G_CALLBACK (codec_move_down), *a); + + preferences_dialog_fill_codec_list (a); + + return ret; } - void -select_audio_manager( void ) +void +select_audio_manager (void) { - DEBUG("audio manager selected"); - - if( !SHOW_ALSA_CONF && !gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) ) ) - { - dbus_set_audio_manager( ALSA ); - DEBUG(" display alsa conf panel"); - alsabox = alsa_box(); - gtk_container_add( GTK_CONTAINER(alsa_conf ) , alsabox); - gtk_widget_show( alsa_conf ); - gtk_widget_set_sensitive(GTK_WIDGET(alsa_conf), TRUE); - - gtk_action_set_sensitive (GTK_ACTION (volumeToggle), TRUE); - } - else if( SHOW_ALSA_CONF && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) )) - { - dbus_set_audio_manager( PULSEAUDIO ); - DEBUG(" remove alsa conf panel"); - gtk_container_remove( GTK_CONTAINER(alsa_conf) , alsabox ); - gtk_widget_hide( alsa_conf ); - if (gtk_toggle_action_get_active ( GTK_TOGGLE_ACTION (volumeToggle))) - { - main_window_volume_controls(FALSE); - eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, FALSE); - gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (volumeToggle), FALSE); - } - gtk_action_set_sensitive (GTK_ACTION (volumeToggle), FALSE); - } else { - DEBUG("alsa conf panel...nothing"); - } + DEBUG ("audio manager selected"); + + if (!SHOW_ALSA_CONF && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pulse))) { + dbus_set_audio_manager (ALSA); + DEBUG (" display alsa conf panel"); + alsabox = alsa_box(); + gtk_container_add (GTK_CONTAINER (alsa_conf) , alsabox); + gtk_widget_show (alsa_conf); + gtk_widget_set_sensitive (GTK_WIDGET (alsa_conf), TRUE); + + gtk_action_set_sensitive (GTK_ACTION (volumeToggle), TRUE); + } else if (SHOW_ALSA_CONF && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pulse))) { + dbus_set_audio_manager (PULSEAUDIO); + DEBUG (" remove alsa conf panel"); + gtk_container_remove (GTK_CONTAINER (alsa_conf) , alsabox); + gtk_widget_hide (alsa_conf); + + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (volumeToggle))) { + main_window_volume_controls (FALSE); + eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, FALSE); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (volumeToggle), FALSE); + } + + gtk_action_set_sensitive (GTK_ACTION (volumeToggle), FALSE); + } else { + DEBUG ("alsa conf panel...nothing"); + } } void -active_echo_cancel(void) { +active_echo_cancel (void) +{ gchar* state; gchar* newstate; - DEBUG("Audio: Active echo cancel clicked"); + DEBUG ("Audio: Active echo cancel clicked"); state = dbus_get_echo_cancel_state(); - DEBUG("Audio: Get echo cancel state %s", state); + DEBUG ("Audio: Get echo cancel state %s", state); - if(strcmp(state, "enabled") == 0) - newstate = "disabled"; + if (strcmp (state, "enabled") == 0) + newstate = "disabled"; else - newstate = "enabled"; + newstate = "enabled"; + + dbus_set_echo_cancel_state (newstate); - dbus_set_echo_cancel_state(newstate); - } void -active_noise_suppress(void) { +active_noise_suppress (void) +{ gchar *state; gchar *newstate; - DEBUG("Audio: Active noise suppress clicked"); + DEBUG ("Audio: Active noise suppress clicked"); state = dbus_get_noise_suppress_state(); - DEBUG("Audio: Get echo cancel state %s", state); + DEBUG ("Audio: Get echo cancel state %s", state); - if(strcmp(state, "enabled") == 0) - newstate = "disabled"; + if (strcmp (state, "enabled") == 0) + newstate = "disabled"; else - newstate = "enabled"; + newstate = "enabled"; + + dbus_set_noise_suppress_state (newstate); - dbus_set_noise_suppress_state(newstate); - } GtkWidget* alsa_box() { - GtkWidget *ret; - GtkWidget *table; - GtkWidget *item; - GtkCellRenderer *renderer; - - ret = gtk_hbox_new(FALSE, 10); - gtk_widget_show( ret ); - - table = gtk_table_new(5, 3, FALSE); - gtk_table_set_col_spacing(GTK_TABLE(table), 0, 40); - gtk_box_pack_start( GTK_BOX(ret) , table , TRUE , TRUE , 1); - gtk_widget_show(table); - - DEBUG("Audio: Configuration plugin"); - item = gtk_label_new(_("ALSA plugin")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show( item ); - // Set choices of audio managers - pluginlist = gtk_list_store_new(1, G_TYPE_STRING); - preferences_dialog_fill_audio_plugin_list(); - plugin = gtk_combo_box_new_with_model(GTK_TREE_MODEL(pluginlist)); - select_active_output_audio_plugin(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), plugin); - g_signal_connect(G_OBJECT(plugin), "changed", G_CALLBACK(select_output_audio_plugin), plugin); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(plugin), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(plugin), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), plugin, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(plugin); - - // Device : Output device - // Create title label - DEBUG("Audio: Configuration output"); - item = gtk_label_new(_("Output")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(item); - // Set choices of output devices - outputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - preferences_dialog_fill_output_audio_device_list(); - output = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputlist)); - select_active_output_audio_device(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), output); - g_signal_connect(G_OBJECT(output), "changed", G_CALLBACK(select_audio_output_device), output); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(output), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(output), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), output, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(output); - - // Device : Input device - // Create title label - DEBUG("Audio: Configuration input"); - item = gtk_label_new(_("Input")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(item); - - // Set choices of output devices - inputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - preferences_dialog_fill_input_audio_device_list(); - input = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputlist)); - select_active_input_audio_device(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), input); - g_signal_connect(G_OBJECT(input), "changed", G_CALLBACK(select_audio_input_device), input); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(input), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(input), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), input, 2, 3, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(input); - - gtk_widget_show_all(ret); - - DEBUG("done"); - return ret; + GtkWidget *ret; + GtkWidget *table; + GtkWidget *item; + GtkCellRenderer *renderer; + + ret = gtk_hbox_new (FALSE, 10); + gtk_widget_show (ret); + + table = gtk_table_new (5, 3, FALSE); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 40); + gtk_box_pack_start (GTK_BOX (ret) , table , TRUE , TRUE , 1); + gtk_widget_show (table); + + DEBUG ("Audio: Configuration plugin"); + item = gtk_label_new (_ ("ALSA plugin")); + gtk_misc_set_alignment (GTK_MISC (item), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), item, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (item); + // Set choices of audio managers + pluginlist = gtk_list_store_new (1, G_TYPE_STRING); + preferences_dialog_fill_audio_plugin_list(); + plugin = gtk_combo_box_new_with_model (GTK_TREE_MODEL (pluginlist)); + select_active_output_audio_plugin(); + gtk_label_set_mnemonic_widget (GTK_LABEL (item), plugin); + g_signal_connect (G_OBJECT (plugin), "changed", G_CALLBACK (select_output_audio_plugin), plugin); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (plugin), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (plugin), renderer, "text", 0, NULL); + gtk_table_attach (GTK_TABLE (table), plugin, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (plugin); + + // Device : Output device + // Create title label + DEBUG ("Audio: Configuration output"); + item = gtk_label_new (_ ("Output")); + gtk_misc_set_alignment (GTK_MISC (item), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), item, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (item); + // Set choices of output devices + outputlist = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); + preferences_dialog_fill_output_audio_device_list(); + output = gtk_combo_box_new_with_model (GTK_TREE_MODEL (outputlist)); + select_active_output_audio_device(); + gtk_label_set_mnemonic_widget (GTK_LABEL (item), output); + g_signal_connect (G_OBJECT (output), "changed", G_CALLBACK (select_audio_output_device), output); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (output), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (output), renderer, "text", 0, NULL); + gtk_table_attach (GTK_TABLE (table), output, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (output); + + // Device : Input device + // Create title label + DEBUG ("Audio: Configuration input"); + item = gtk_label_new (_ ("Input")); + gtk_misc_set_alignment (GTK_MISC (item), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), item, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (item); + + // Set choices of output devices + inputlist = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); + preferences_dialog_fill_input_audio_device_list(); + input = gtk_combo_box_new_with_model (GTK_TREE_MODEL (inputlist)); + select_active_input_audio_device(); + gtk_label_set_mnemonic_widget (GTK_LABEL (item), input); + g_signal_connect (G_OBJECT (input), "changed", G_CALLBACK (select_audio_input_device), input); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (input), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (input), renderer, "text", 0, NULL); + gtk_table_attach (GTK_TABLE (table), input, 2, 3, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show (input); + + gtk_widget_show_all (ret); + + DEBUG ("done"); + return ret; } -static void record_path_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED) +static void record_path_changed (GtkFileChooser *chooser , GtkLabel *label UNUSED) { - DEBUG("record_path_changed"); + DEBUG ("record_path_changed"); - gchar* path; - path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER( chooser )); - DEBUG("path2 %s", path); - dbus_set_record_path( path ); + gchar* path; + path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); + DEBUG ("path2 %s", path); + dbus_set_record_path (path); } GtkWidget* create_audio_configuration() { - // Main widget - GtkWidget *ret; - // Sub boxes - GtkWidget *box; - GtkWidget *frame; - GtkWidget *enableEchoCancel; - GtkWidget *enableNoiseReduction; - gboolean echocancelActive, noisesuppressActive; - gchar *state; + // Main widget + GtkWidget *ret; + // Sub boxes + GtkWidget *frame; + GtkWidget *enableEchoCancel; + GtkWidget *enableNoiseReduction; + gboolean echocancelActive, noisesuppressActive; + gchar *state; - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); + + GtkWidget *alsa; + GtkWidget *table; + + gnome_main_section_new_with_table (_ ("Sound Manager"), &frame, &table, 1, 2); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + int audio_manager = dbus_get_audio_manager(); + gboolean pulse_audio = FALSE; + + if (audio_manager == PULSEAUDIO) { + pulse_audio = TRUE; + } - GtkWidget *alsa; - GtkWidget *table; - - gnome_main_section_new_with_table (_("Sound Manager"), &frame, &table, 1, 2); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - int audio_manager = dbus_get_audio_manager(); - gboolean pulse_audio = FALSE; - if (audio_manager == PULSEAUDIO) { - pulse_audio = TRUE; - } - - pulse = gtk_radio_button_new_with_mnemonic( NULL , _("_Pulseaudio")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(pulse), pulse_audio); - gtk_table_attach ( GTK_TABLE( table ), pulse, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - alsa = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(pulse), _("_ALSA")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(alsa), !pulse_audio); - g_signal_connect(G_OBJECT(alsa), "clicked", G_CALLBACK(select_audio_manager), NULL); - gtk_table_attach ( GTK_TABLE( table ), alsa, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // Box for the ALSA configuration - gnome_main_section_new (_("ALSA settings"), &alsa_conf); - gtk_box_pack_start(GTK_BOX(ret), alsa_conf, FALSE, FALSE, 0); - gtk_widget_show( alsa_conf ); - if( SHOW_ALSA_CONF ) - { - // Box for the ALSA configuration - printf("ALSA Created \n"); - alsabox = alsa_box(); - gtk_container_add( GTK_CONTAINER(alsa_conf) , alsabox ); - gtk_widget_hide( alsa_conf ); - } - - // Recorded file saving path - GtkWidget *label; - GtkWidget *folderChooser; - gchar *dftPath; - - /* Get the path where to save audio files */ - dftPath = dbus_get_record_path (); - DEBUG("load recording path %s\n", dftPath); - - gnome_main_section_new_with_table (_("Recordings"), &frame, &table, 1, 2); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - // label - label = gtk_label_new(_("Destination folder")); - gtk_table_attach( GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - // folder chooser button - folderChooser = gtk_file_chooser_button_new(_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( folderChooser), dftPath); - g_signal_connect( G_OBJECT( folderChooser ) , "selection_changed" , G_CALLBACK( record_path_changed ) , NULL ); - gtk_table_attach(GTK_TABLE(table), folderChooser, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - - // Box for the voice enhancement configuration - gnome_main_section_new_with_table (_("Voice enhancement settings"), &frame, &table, 2, 1); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - enableEchoCancel = gtk_check_button_new_with_mnemonic( _("_Echo Suppression")); + pulse = gtk_radio_button_new_with_mnemonic (NULL , _ ("_Pulseaudio")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pulse), pulse_audio); + gtk_table_attach (GTK_TABLE (table), pulse, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + alsa = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (pulse), _ ("_ALSA")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alsa), !pulse_audio); + g_signal_connect (G_OBJECT (alsa), "clicked", G_CALLBACK (select_audio_manager), NULL); + gtk_table_attach (GTK_TABLE (table), alsa, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // Box for the ALSA configuration + gnome_main_section_new (_ ("ALSA settings"), &alsa_conf); + gtk_box_pack_start (GTK_BOX (ret), alsa_conf, FALSE, FALSE, 0); + gtk_widget_show (alsa_conf); + + if (SHOW_ALSA_CONF) { + // Box for the ALSA configuration + printf ("ALSA Created \n"); + alsabox = alsa_box(); + gtk_container_add (GTK_CONTAINER (alsa_conf) , alsabox); + gtk_widget_hide (alsa_conf); + } + + // Recorded file saving path + GtkWidget *label; + GtkWidget *folderChooser; + gchar *dftPath; + + /* Get the path where to save audio files */ + dftPath = dbus_get_record_path (); + DEBUG ("load recording path %s\n", dftPath); + + gnome_main_section_new_with_table (_ ("Recordings"), &frame, &table, 1, 2); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + // label + label = gtk_label_new (_ ("Destination folder")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + // folder chooser button + folderChooser = gtk_file_chooser_button_new (_ ("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (folderChooser), dftPath); + g_signal_connect (G_OBJECT (folderChooser) , "selection_changed" , G_CALLBACK (record_path_changed) , NULL); + gtk_table_attach (GTK_TABLE (table), folderChooser, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + + // Box for the voice enhancement configuration + gnome_main_section_new_with_table (_ ("Voice enhancement settings"), &frame, &table, 2, 1); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + enableEchoCancel = gtk_check_button_new_with_mnemonic (_ ("_Echo Suppression")); state = dbus_get_echo_cancel_state(); echocancelActive = FALSE; - if(strcmp(state, "enabled") == 0) - echocancelActive = TRUE; + + if (strcmp (state, "enabled") == 0) + echocancelActive = TRUE; else - echocancelActive = FALSE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableEchoCancel), echocancelActive); - g_signal_connect(G_OBJECT(enableEchoCancel), "clicked", active_echo_cancel, NULL); - gtk_table_attach ( GTK_TABLE(table), enableEchoCancel, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + echocancelActive = FALSE; - enableNoiseReduction = gtk_check_button_new_with_mnemonic( _("_Noise Reduction")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableEchoCancel), echocancelActive); + g_signal_connect (G_OBJECT (enableEchoCancel), "clicked", active_echo_cancel, NULL); + gtk_table_attach (GTK_TABLE (table), enableEchoCancel, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + enableNoiseReduction = gtk_check_button_new_with_mnemonic (_ ("_Noise Reduction")); state = dbus_get_noise_suppress_state(); noisesuppressActive = FALSE; - if(strcmp(state, "enabled") == 0) - noisesuppressActive = TRUE; + + if (strcmp (state, "enabled") == 0) + noisesuppressActive = TRUE; else - noisesuppressActive = FALSE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableNoiseReduction), noisesuppressActive); - g_signal_connect(G_OBJECT(enableNoiseReduction), "clicked", active_noise_suppress, NULL); - gtk_table_attach ( GTK_TABLE(table), enableNoiseReduction, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + noisesuppressActive = FALSE; - gtk_widget_show_all(ret); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableNoiseReduction), noisesuppressActive); + g_signal_connect (G_OBJECT (enableNoiseReduction), "clicked", active_noise_suppress, NULL); + gtk_table_attach (GTK_TABLE (table), enableNoiseReduction, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - if(!pulse_audio) { - gtk_widget_show(alsa_conf); - } - else{ - gtk_widget_hide(alsa_conf); - } + gtk_widget_show_all (ret); - return ret; + if (!pulse_audio) { + gtk_widget_show (alsa_conf); + } else { + gtk_widget_hide (alsa_conf); + } + + return ret; } /* GtkWidget* create_codecs_configuration (account_t **a) { diff --git a/sflphone-client-gnome/src/config/audioconf.h b/sflphone-client-gnome/src/config/audioconf.h index b195b947d8ce1d0b6ff6f35ca0cb077469f56ce4..70fadb3dc3c06c1fc7af069d8e4e52bec6595b33 100644 --- a/sflphone-client-gnome/src/config/audioconf.h +++ b/sflphone-client-gnome/src/config/audioconf.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -42,6 +42,6 @@ GtkWidget* pulse_box(); GtkWidget* codecs_box(); GtkWidget* ringtone_box(); -gboolean get_api( ); +gboolean get_api(); #endif // __AUDIO_CONF_H diff --git a/sflphone-client-gnome/src/config/hooks-config.c b/sflphone-client-gnome/src/config/hooks-config.c index 7331cc88fc94e634f1097c7585ff12e71d66ee8c..df257d6eaa561cf777cadb03a55ada635b0ad325 100644 --- a/sflphone-client-gnome/src/config/hooks-config.c +++ b/sflphone-client-gnome/src/config/hooks-config.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,14 +34,15 @@ URLHook_Config *_urlhook_config; GtkWidget *field, *command, *prefix; -void hooks_load_parameters (URLHook_Config** settings){ +void hooks_load_parameters (URLHook_Config** settings) +{ GHashTable *_params = NULL; URLHook_Config *_settings; // Allocate a struct _settings = g_new0 (URLHook_Config, 1); - + // Fetch the settings from D-Bus _params = (GHashTable*) dbus_get_hook_settings (); @@ -52,38 +53,38 @@ void hooks_load_parameters (URLHook_Config** settings){ _settings->iax2_enabled = "0"; _settings->phone_number_enabled = "0"; _settings->phone_number_prefix = ""; + } else { + _settings->sip_field = (gchar*) (g_hash_table_lookup (_params, URLHOOK_SIP_FIELD)); + _settings->command = (gchar*) (g_hash_table_lookup (_params, URLHOOK_COMMAND)); + _settings->sip_enabled = (gchar*) (g_hash_table_lookup (_params, URLHOOK_SIP_ENABLED)); + _settings->iax2_enabled = (gchar*) (g_hash_table_lookup (_params, URLHOOK_IAX2_ENABLED)); + _settings->phone_number_enabled = (gchar*) (g_hash_table_lookup (_params, PHONE_NUMBER_HOOK_ENABLED)); + _settings->phone_number_prefix = (gchar*) (g_hash_table_lookup (_params, PHONE_NUMBER_HOOK_ADD_PREFIX)); } - else { - _settings->sip_field = (gchar*)(g_hash_table_lookup (_params, URLHOOK_SIP_FIELD)); - _settings->command = (gchar*)(g_hash_table_lookup (_params, URLHOOK_COMMAND)); - _settings->sip_enabled = (gchar*)(g_hash_table_lookup (_params, URLHOOK_SIP_ENABLED)); - _settings->iax2_enabled = (gchar*)(g_hash_table_lookup (_params, URLHOOK_IAX2_ENABLED)); - _settings->phone_number_enabled = (gchar*)(g_hash_table_lookup (_params, PHONE_NUMBER_HOOK_ENABLED )); - _settings->phone_number_prefix = (gchar*)(g_hash_table_lookup (_params, PHONE_NUMBER_HOOK_ADD_PREFIX )); - } - + *settings = _settings; } -void hooks_save_parameters (void){ +void hooks_save_parameters (void) +{ GHashTable *params = NULL; - + params = g_hash_table_new (NULL, g_str_equal); - g_hash_table_replace (params, (gpointer)URLHOOK_SIP_FIELD, - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(field)))); - g_hash_table_replace (params, (gpointer)URLHOOK_COMMAND, - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(command)))); - g_hash_table_replace (params, (gpointer)URLHOOK_SIP_ENABLED, - (gpointer)g_strdup(_urlhook_config->sip_enabled)); - g_hash_table_replace (params, (gpointer)URLHOOK_IAX2_ENABLED, - (gpointer)g_strdup(_urlhook_config->iax2_enabled)); - g_hash_table_replace (params, (gpointer)PHONE_NUMBER_HOOK_ENABLED, - (gpointer)g_strdup(_urlhook_config->phone_number_enabled)); - g_hash_table_replace (params, (gpointer)PHONE_NUMBER_HOOK_ADD_PREFIX, - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(prefix)))); - + g_hash_table_replace (params, (gpointer) URLHOOK_SIP_FIELD, + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (field)))); + g_hash_table_replace (params, (gpointer) URLHOOK_COMMAND, + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (command)))); + g_hash_table_replace (params, (gpointer) URLHOOK_SIP_ENABLED, + (gpointer) g_strdup (_urlhook_config->sip_enabled)); + g_hash_table_replace (params, (gpointer) URLHOOK_IAX2_ENABLED, + (gpointer) g_strdup (_urlhook_config->iax2_enabled)); + g_hash_table_replace (params, (gpointer) PHONE_NUMBER_HOOK_ENABLED, + (gpointer) g_strdup (_urlhook_config->phone_number_enabled)); + g_hash_table_replace (params, (gpointer) PHONE_NUMBER_HOOK_ADD_PREFIX, + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (prefix)))); + dbus_set_hook_settings (params); // Decrement the reference count @@ -91,104 +92,111 @@ void hooks_save_parameters (void){ } -static void sip_enabled_cb (GtkWidget *widget) { +static void sip_enabled_cb (GtkWidget *widget) +{ guint check; - check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + if (check) _urlhook_config->sip_enabled="1"; else _urlhook_config->sip_enabled="0"; } -static void iax2_enabled_cb (GtkWidget *widget) { +static void iax2_enabled_cb (GtkWidget *widget) +{ guint check; - check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + if (check) _urlhook_config->iax2_enabled="1"; else _urlhook_config->iax2_enabled="0"; } -static void phone_number_enabled_cb (GtkWidget *widget) { +static void phone_number_enabled_cb (GtkWidget *widget) +{ guint check; - check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); - if (check){ + check = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + if (check) { _urlhook_config->phone_number_enabled="1"; - gtk_widget_set_sensitive (GTK_WIDGET (prefix), TRUE); - }else{ + gtk_widget_set_sensitive (GTK_WIDGET (prefix), TRUE); + } else { _urlhook_config->phone_number_enabled="0"; - gtk_widget_set_sensitive (GTK_WIDGET (prefix), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefix), FALSE); } } -GtkWidget* create_hooks_settings (){ +GtkWidget* create_hooks_settings () +{ GtkWidget *ret, *frame, *table, *label, *widg; // Load the user value hooks_load_parameters (&_urlhook_config); - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new (FALSE, 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); + 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); - label = gtk_label_new(_("Custom commands on incoming calls with URL")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + label = gtk_label_new (_ ("Custom commands on incoming calls with URL")); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + label = gtk_label_new (_ ("%s will be replaced with the passed URL.")); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 1, 2, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - label = gtk_label_new(_("%s will be replaced with the passed URL.")); - gtk_table_attach ( GTK_TABLE( table ), label, 0, 2, 1, 2, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + widg = gtk_check_button_new_with_mnemonic (_ ("Trigger on specific _SIP header")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widg), (g_strcasecmp (_urlhook_config->sip_enabled, "1") ==0) ?TRUE:FALSE); + 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); - widg = gtk_check_button_new_with_mnemonic( _("Trigger on specific _SIP header")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widg), (g_strcasecmp (_urlhook_config->sip_enabled, "1")==0)?TRUE:FALSE); - 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); + 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), (g_strcasecmp (_urlhook_config->iax2_enabled, "1")==0)?TRUE:FALSE); - 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); + widg = gtk_check_button_new_with_mnemonic (_ ("Trigger on _IAX2 URL")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widg), (g_strcasecmp (_urlhook_config->iax2_enabled, "1") ==0) ?TRUE:FALSE); + 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); + 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); + 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); + 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), (g_strcasecmp (_urlhook_config->phone_number_enabled, "1")==0)?TRUE:FALSE); - 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); - + widg = gtk_check_button_new_with_mnemonic (_ ("_Prefix dialed numbers with")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widg), (g_strcasecmp (_urlhook_config->phone_number_enabled, "1") ==0) ?TRUE:FALSE); + 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_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); + gtk_widget_show_all (ret); return ret; } diff --git a/sflphone-client-gnome/src/config/hooks-config.h b/sflphone-client-gnome/src/config/hooks-config.h index 5fcd951b21c4105b25842955b2b1cfd75e73a40a..f1b575517ae1206156ed3967a00f46fc9809f0bd 100644 --- a/sflphone-client-gnome/src/config/hooks-config.h +++ b/sflphone-client-gnome/src/config/hooks-config.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -55,8 +55,8 @@ typedef struct _URLHook_Config { gchar *sip_field; gchar *command; gchar *phone_number_enabled; - gchar *phone_number_prefix; -}URLHook_Config; + gchar *phone_number_prefix; +} URLHook_Config; /** * Save the parameters through D-BUS diff --git a/sflphone-client-gnome/src/config/preferencesdialog.c b/sflphone-client-gnome/src/config/preferencesdialog.c index 65c34b25a0b7f8286c24be9c8c01db80b8cd9055..8551d5124f1a69589ad4958cf79f30dccd2fbfa5 100644 --- a/sflphone-client-gnome/src/config/preferencesdialog.c +++ b/sflphone-client-gnome/src/config/preferencesdialog.c @@ -35,6 +35,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <eel-gconf-extensions.h> #include <accountconfigdialog.h> #include <addressbook-config.h> @@ -42,6 +43,7 @@ #include <audioconf.h> #include <hooks-config.h> #include <audioconf.h> +#include <uimanager.h> /** * Local variables @@ -67,241 +69,237 @@ GtkWidget * notebook; enum { - PIXBUF_COL, - TEXT_COL, - PAGE_NUMBER + PIXBUF_COL, + TEXT_COL, + PAGE_NUMBER }; typedef struct { - gchar* icon_descr; - gchar* icon_name; - gint page_number; + gchar* icon_descr; + gchar* icon_name; + gint page_number; } browser_t; static int history_limit; static gboolean history_enabled = TRUE; - static void -set_md5_hash_cb (GtkWidget *widget UNUSED, gpointer data UNUSED) -{ - - gboolean enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); - dbus_set_md5_credential_hashing (enabled); -} - - static void +static void start_hidden (void) { - gboolean currentstate = eel_gconf_get_integer (START_HIDDEN); - eel_gconf_set_integer (START_HIDDEN, !currentstate); + gboolean currentstate = eel_gconf_get_integer (START_HIDDEN); + eel_gconf_set_integer (START_HIDDEN, !currentstate); } - static void -set_popup_mode (GtkWidget *widget, gpointer *userdata) +static void +set_popup_mode (GtkWidget *widget, gpointer *userdata UNUSED) { - gboolean currentstate = eel_gconf_get_integer (POPUP_ON_CALL); - if (currentstate || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { - eel_gconf_set_integer (POPUP_ON_CALL, !currentstate); - } + gboolean currentstate = eel_gconf_get_integer (POPUP_ON_CALL); + + if (currentstate || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + eel_gconf_set_integer (POPUP_ON_CALL, !currentstate); + } } - void +void set_notif_level () { - gboolean current_state = eel_gconf_get_integer (NOTIFY_ALL); - eel_gconf_set_integer (NOTIFY_ALL, !current_state); + gboolean current_state = eel_gconf_get_integer (NOTIFY_ALL); + eel_gconf_set_integer (NOTIFY_ALL, !current_state); } - static void -history_limit_cb (GtkSpinButton *button, void *ptr) +static void +history_limit_cb (GtkSpinButton *button UNUSED, void *ptr) { - history_limit = gtk_spin_button_get_value_as_int ((GtkSpinButton *) (ptr)); + history_limit = gtk_spin_button_get_value_as_int ( (GtkSpinButton *) (ptr)); } - static void +static void history_enabled_cb (GtkWidget *widget) { - history_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - gtk_widget_set_sensitive (GTK_WIDGET (history_value), history_enabled); + history_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + gtk_widget_set_sensitive (GTK_WIDGET (history_value), history_enabled); - // Toggle it through D-Bus - eel_gconf_set_integer (HISTORY_ENABLED, !eel_gconf_get_integer (HISTORY_ENABLED)); + // Toggle it through D-Bus + eel_gconf_set_integer (HISTORY_ENABLED, !eel_gconf_get_integer (HISTORY_ENABLED)); } - void +void clean_history (void) { - calllist_clean_history (); + calllist_clean_history (); } -void showstatusicon_cb (GtkWidget *widget, gpointer data) { +void showstatusicon_cb (GtkWidget *widget, gpointer data UNUSED) +{ - gboolean currentstatus = FALSE; + gboolean currentstatus = FALSE; - // data contains the previous value of dbus_is_status_icon_enabled () - ie before the click. - currentstatus = (gboolean) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + // data contains the previous value of dbus_is_status_icon_enabled () - ie before the click. + currentstatus = (gboolean) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - // Update the widget states - gtk_widget_set_sensitive (GTK_WIDGET (popupwindow), currentstatus); - gtk_widget_set_sensitive (GTK_WIDGET (neverpopupwindow), currentstatus); - gtk_widget_set_sensitive (GTK_WIDGET (starthidden), currentstatus); + // Update the widget states + gtk_widget_set_sensitive (GTK_WIDGET (popupwindow), currentstatus); + gtk_widget_set_sensitive (GTK_WIDGET (neverpopupwindow), currentstatus); + gtk_widget_set_sensitive (GTK_WIDGET (starthidden), currentstatus); - currentstatus ? show_status_icon () : hide_status_icon (); + currentstatus ? show_status_icon () : hide_status_icon (); - // Update through D-Bus - eel_gconf_set_integer (SHOW_STATUSICON, currentstatus); + // Update through D-Bus + eel_gconf_set_integer (SHOW_STATUSICON, currentstatus); } - GtkWidget* +GtkWidget* create_general_settings () { - GtkWidget *ret, *notifAll, *trayItem, *frame, *checkBoxWidget, *label, *table, *showstatusicon; - gboolean statusicon; - - // Load history configuration - history_load_configuration (); - - // Main widget - ret = gtk_vbox_new (FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER(ret), 10); - - // Notifications Frame - gnome_main_section_new_with_table (_("Desktop Notifications"), &frame, - &table, 2, 1); - gtk_box_pack_start (GTK_BOX(ret), frame, FALSE, FALSE, 0); - - // Notification All - notifAll = gtk_check_button_new_with_mnemonic (_("_Enable notifications")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(notifAll), eel_gconf_get_integer (NOTIFY_ALL)); - g_signal_connect(G_OBJECT( notifAll ) , "clicked" , G_CALLBACK( set_notif_level ) , NULL ); - gtk_table_attach (GTK_TABLE(table), notifAll, 0, 1, 0, 1, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - // System Tray option frame - gnome_main_section_new_with_table (_("System Tray Icon"), &frame, &table, 4, - 1); - gtk_box_pack_start (GTK_BOX(ret), frame, FALSE, FALSE, 0); - - // Whether or not displaying an icon in the system tray - statusicon = eel_gconf_get_integer (SHOW_STATUSICON); - - showstatusicon = gtk_check_button_new_with_mnemonic ( - _("Show SFLphone in the system tray")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(showstatusicon), statusicon); - g_signal_connect (G_OBJECT (showstatusicon) , "clicked" , G_CALLBACK (showstatusicon_cb), NULL); - gtk_table_attach (GTK_TABLE (table), showstatusicon, 0, 1, 0, 1, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - popupwindow = gtk_radio_button_new_with_mnemonic (NULL, - _("_Popup main window on incoming call")); - g_signal_connect(G_OBJECT (popupwindow), "toggled", G_CALLBACK (set_popup_mode), NULL); - gtk_table_attach (GTK_TABLE(table), popupwindow, 0, 1, 1, 2, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - neverpopupwindow = gtk_radio_button_new_with_mnemonic_from_widget ( - GTK_RADIO_BUTTON (popupwindow), _("Ne_ver popup main window")); - gtk_table_attach (GTK_TABLE(table), neverpopupwindow, 0, 1, 2, 3, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - // Toggle according to the user configuration - eel_gconf_get_integer (POPUP_ON_CALL) ? gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (popupwindow), - TRUE) : - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (neverpopupwindow), - TRUE); - - starthidden = gtk_check_button_new_with_mnemonic ( - _("Hide SFLphone window on _startup")); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(starthidden), - eel_gconf_get_integer (START_HIDDEN)); - g_signal_connect(G_OBJECT (starthidden) , "clicked" , G_CALLBACK( start_hidden ) , NULL); - gtk_table_attach (GTK_TABLE(table), starthidden, 0, 1, 3, 4, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - // Update the widget states - gtk_widget_set_sensitive (GTK_WIDGET (popupwindow),statusicon); - gtk_widget_set_sensitive (GTK_WIDGET (neverpopupwindow),statusicon); - gtk_widget_set_sensitive (GTK_WIDGET (starthidden),statusicon); - - // HISTORY CONFIGURATION - gnome_main_section_new_with_table (_("Calls History"), &frame, &table, 3, 1); - gtk_box_pack_start (GTK_BOX(ret), frame, FALSE, FALSE, 0); - - checkBoxWidget = gtk_check_button_new_with_mnemonic ( - _("_Keep my history for at least")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkBoxWidget), - history_enabled); - g_signal_connect (G_OBJECT (checkBoxWidget) , "clicked" , G_CALLBACK (history_enabled_cb) , NULL); - gtk_table_attach (GTK_TABLE(table), checkBoxWidget, 0, 1, 0, 1, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - history_value = gtk_spin_button_new_with_range (1, 99, 1); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(history_value), history_limit); - g_signal_connect( G_OBJECT (history_value) , "value-changed" , G_CALLBACK (history_limit_cb) , history_value); - gtk_widget_set_sensitive (GTK_WIDGET (history_value), - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkBoxWidget))); - gtk_table_attach (GTK_TABLE(table), history_value, 1, 2, 0, 1, GTK_EXPAND - | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - label = gtk_label_new (_("days")); - gtk_table_attach (GTK_TABLE(table), label, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, 0, 5); - - gtk_widget_show_all (ret); - - return ret; + GtkWidget *ret, *notifAll, *frame, *checkBoxWidget, *label, *table, *showstatusicon; + gboolean statusicon; + + // Load history configuration + history_load_configuration (); + + // Main widget + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); + + // Notifications Frame + gnome_main_section_new_with_table (_ ("Desktop Notifications"), &frame, + &table, 2, 1); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + // Notification All + notifAll = gtk_check_button_new_with_mnemonic (_ ("_Enable notifications")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notifAll), eel_gconf_get_integer (NOTIFY_ALL)); + g_signal_connect (G_OBJECT (notifAll) , "clicked" , G_CALLBACK (set_notif_level) , NULL); + gtk_table_attach (GTK_TABLE (table), notifAll, 0, 1, 0, 1, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + // System Tray option frame + gnome_main_section_new_with_table (_ ("System Tray Icon"), &frame, &table, 4, + 1); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + // Whether or not displaying an icon in the system tray + statusicon = eel_gconf_get_integer (SHOW_STATUSICON); + + showstatusicon = gtk_check_button_new_with_mnemonic ( + _ ("Show SFLphone in the system tray")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (showstatusicon), statusicon); + g_signal_connect (G_OBJECT (showstatusicon) , "clicked" , G_CALLBACK (showstatusicon_cb), NULL); + gtk_table_attach (GTK_TABLE (table), showstatusicon, 0, 1, 0, 1, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + popupwindow = gtk_radio_button_new_with_mnemonic (NULL, + _ ("_Popup main window on incoming call")); + g_signal_connect (G_OBJECT (popupwindow), "toggled", G_CALLBACK (set_popup_mode), NULL); + gtk_table_attach (GTK_TABLE (table), popupwindow, 0, 1, 1, 2, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + neverpopupwindow = gtk_radio_button_new_with_mnemonic_from_widget ( + GTK_RADIO_BUTTON (popupwindow), _ ("Ne_ver popup main window")); + gtk_table_attach (GTK_TABLE (table), neverpopupwindow, 0, 1, 2, 3, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + // Toggle according to the user configuration + eel_gconf_get_integer (POPUP_ON_CALL) ? gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (popupwindow), + TRUE) : + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (neverpopupwindow), + TRUE); + + starthidden = gtk_check_button_new_with_mnemonic ( + _ ("Hide SFLphone window on _startup")); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (starthidden), + eel_gconf_get_integer (START_HIDDEN)); + g_signal_connect (G_OBJECT (starthidden) , "clicked" , G_CALLBACK (start_hidden) , NULL); + gtk_table_attach (GTK_TABLE (table), starthidden, 0, 1, 3, 4, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + // Update the widget states + gtk_widget_set_sensitive (GTK_WIDGET (popupwindow),statusicon); + gtk_widget_set_sensitive (GTK_WIDGET (neverpopupwindow),statusicon); + gtk_widget_set_sensitive (GTK_WIDGET (starthidden),statusicon); + + // HISTORY CONFIGURATION + gnome_main_section_new_with_table (_ ("Calls History"), &frame, &table, 3, 1); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + checkBoxWidget = gtk_check_button_new_with_mnemonic ( + _ ("_Keep my history for at least")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkBoxWidget), + history_enabled); + g_signal_connect (G_OBJECT (checkBoxWidget) , "clicked" , G_CALLBACK (history_enabled_cb) , NULL); + gtk_table_attach (GTK_TABLE (table), checkBoxWidget, 0, 1, 0, 1, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + history_value = gtk_spin_button_new_with_range (1, 99, 1); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (history_value), history_limit); + g_signal_connect (G_OBJECT (history_value) , "value-changed" , G_CALLBACK (history_limit_cb) , history_value); + gtk_widget_set_sensitive (GTK_WIDGET (history_value), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkBoxWidget))); + gtk_table_attach (GTK_TABLE (table), history_value, 1, 2, 0, 1, GTK_EXPAND + | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + label = gtk_label_new (_ ("days")); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, 0, 5); + + gtk_widget_show_all (ret); + + return ret; } - void +void save_configuration_parameters (void) { - // Address book config - addressbook_config_save_parameters (); - hooks_save_parameters (); + // Address book config + addressbook_config_save_parameters (); + hooks_save_parameters (); - // History config - dbus_set_history_limit (history_limit); + // History config + dbus_set_history_limit (history_limit); - // Direct IP calls config - // dbus_set_ip2ip_details (directIpCallsProperties); + // Direct IP calls config + // dbus_set_ip2ip_details (directIpCallsProperties); } - void +void history_load_configuration () { - history_limit = dbus_get_history_limit (); - history_enabled = eel_gconf_get_integer (HISTORY_ENABLED); + history_limit = dbus_get_history_limit (); + history_enabled = eel_gconf_get_integer (HISTORY_ENABLED); } -gboolean selection_changed_cb (GtkIconView *view, gpointer user_data) { +void +selection_changed_cb (GtkIconView *view, gpointer user_data UNUSED) +{ + + GtkTreeModel *model; + GtkTreeIter iter; + GList *list; + gint page; - GtkTreeModel *model; - GtkTreeIter iter; - GList *list; - gint page; + model = gtk_icon_view_get_model (view); + list = gtk_icon_view_get_selected_items (view); - model = gtk_icon_view_get_model (view); - list = gtk_icon_view_get_selected_items (view); - - if (list == NULL) - return; + if (list == NULL) + return; - if (g_list_length (list) > 1) - return; + if (g_list_length (list) > 1) + return; - gtk_tree_model_get_iter (model, &iter, list->data); - gtk_tree_model_get (model, &iter, PAGE_NUMBER, &page, -1); + gtk_tree_model_get_iter (model, &iter, list->data); + gtk_tree_model_get (model, &iter, PAGE_NUMBER, &page, -1); - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page); - g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); - g_list_free (list); + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page); + g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); + g_list_free (list); } @@ -309,137 +307,137 @@ gboolean selection_changed_cb (GtkIconView *view, gpointer user_data) { /** * Show configuration window with tabs */ - void +void show_preferences_dialog () { - GtkDialog * dialog; - GtkWidget * hbox; - GtkWidget * tab; - guint result; - - dialogOpen = TRUE; - - dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Preferences"), - GTK_WINDOW(get_main_window()), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_ACCEPT, - NULL)); - - // Set window properties - gtk_dialog_set_has_separator (dialog, FALSE); - gtk_window_set_default_size (GTK_WINDOW(dialog), 600, 400); - gtk_container_set_border_width (GTK_CONTAINER(dialog), 0); - - - hbox = gtk_hbox_new(FALSE, 10); - - // Create tree view - iconview = gtk_icon_view_new_with_model (createModel ()); - g_object_set (iconview, - "selection-mode", GTK_SELECTION_BROWSE, - "text-column", TEXT_COL, - "pixbuf-column", PIXBUF_COL, - "columns", 1, - "margin", 10, - NULL); - // Connect the callback when clicking on an item - g_signal_connect(G_OBJECT (iconview), "selection-changed", G_CALLBACK (selection_changed_cb), NULL); - gtk_box_pack_start (GTK_BOX (hbox), iconview, TRUE, TRUE, 0); - - // Create tabs container - notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); - gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show_all(dialog->vbox); - gtk_container_set_border_width (GTK_CONTAINER(notebook), 10); - gtk_widget_show (notebook); - - // General settings tab - tab = create_general_settings (); - gtk_notebook_append_page (GTK_NOTEBOOK(notebook), tab, gtk_label_new ( - _("General"))); - gtk_notebook_page_num (GTK_NOTEBOOK(notebook), tab); - - // Audio tab - tab = create_audio_configuration (); - gtk_notebook_append_page (GTK_NOTEBOOK(notebook), tab, gtk_label_new ( - _("Audio"))); - gtk_notebook_page_num (GTK_NOTEBOOK(notebook), tab); - - // Addressbook tab - tab = create_addressbook_settings (); - gtk_notebook_append_page (GTK_NOTEBOOK(notebook), tab, gtk_label_new ( - _("Address Book"))); - gtk_notebook_page_num (GTK_NOTEBOOK(notebook), tab); - - // Hooks tab - tab = create_hooks_settings (); - gtk_notebook_append_page (GTK_NOTEBOOK(notebook), tab, gtk_label_new ( - _("Hooks"))); - gtk_notebook_page_num (GTK_NOTEBOOK(notebook), tab); - - // Shortcuts tab - tab = create_shortcuts_settings(); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Shortcuts"))); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); - - // By default, general settings - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); - // Highlight the corresponding icon - gtk_icon_view_select_path (iconview, gtk_tree_path_new_first ()); - - result = gtk_dialog_run (dialog); - - save_configuration_parameters (); - update_actions (); - - dialogOpen = FALSE; - - gtk_widget_destroy (GTK_WIDGET(dialog)); + GtkDialog * dialog; + GtkWidget * hbox; + GtkWidget * tab; + guint result; + + dialogOpen = TRUE; + + dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Preferences"), + GTK_WINDOW (get_main_window()), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLOSE, + GTK_RESPONSE_ACCEPT, + NULL)); + + // Set window properties + gtk_dialog_set_has_separator (dialog, FALSE); + gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 0); + + + hbox = gtk_hbox_new (FALSE, 10); + + // Create tree view + iconview = gtk_icon_view_new_with_model (createModel ()); + g_object_set (iconview, + "selection-mode", GTK_SELECTION_BROWSE, + "text-column", TEXT_COL, + "pixbuf-column", PIXBUF_COL, + "columns", 1, + "margin", 10, + NULL); + // Connect the callback when clicking on an item + g_signal_connect (G_OBJECT (iconview), "selection-changed", G_CALLBACK (selection_changed_cb), NULL); + gtk_box_pack_start (GTK_BOX (hbox), iconview, TRUE, TRUE, 0); + + // Create tabs container + notebook = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE); + gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, TRUE, TRUE, 0); + gtk_widget_show_all (dialog->vbox); + gtk_container_set_border_width (GTK_CONTAINER (notebook), 10); + gtk_widget_show (notebook); + + // General settings tab + tab = create_general_settings (); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new ( + _ ("General"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); + + // Audio tab + tab = create_audio_configuration (); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new ( + _ ("Audio"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); + + // Addressbook tab + tab = create_addressbook_settings (); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new ( + _ ("Address Book"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); + + // Hooks tab + tab = create_hooks_settings (); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new ( + _ ("Hooks"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); + + // Shortcuts tab + tab = create_shortcuts_settings(); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Shortcuts"))); + gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); + + // By default, general settings + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); + // Highlight the corresponding icon + gtk_icon_view_select_path (GTK_ICON_VIEW (iconview), gtk_tree_path_new_first ()); + + result = gtk_dialog_run (dialog); + + save_configuration_parameters (); + update_actions (); + + dialogOpen = FALSE; + + gtk_widget_destroy (GTK_WIDGET (dialog)); } -GtkTreeModel* createModel() { +GtkTreeModel* createModel() +{ - browser_t browser_entries[5] = { - {_("General"), "start-here", 0}, - {_("Audio"), "multimedia-volume-control", 1}, - {_("Address Book"), "address-book-new", 2}, - {_("Hooks"), "gnome-globe", 3}, - {_("Shortcuts"), "preferences-desktop-keyboard", 4} - }; + browser_t browser_entries[5] = { + {_ ("General"), "start-here", 0}, + {_ ("Audio"), "multimedia-volume-control", 1}, + {_ ("Address Book"), "address-book-new", 2}, + {_ ("Hooks"), "gnome-globe", 3}, + {_ ("Shortcuts"), "preferences-desktop-keyboard", 4} + }; - GdkPixbuf *pixbuf; - GtkTreeIter iter; - GtkListStore *store; - GError *error = NULL; - GtkIconSet *icon = NULL; - gint i; + GdkPixbuf *pixbuf; + GtkTreeIter iter; + GtkListStore *store; + GError *error = NULL; + gint i; - store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); - GtkIconTheme* theme = gtk_icon_theme_get_default(); + store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); + GtkIconTheme* theme = gtk_icon_theme_get_default(); - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { - gtk_list_store_append(store, &iter); + gtk_list_store_append (store, &iter); - pixbuf = gtk_icon_theme_load_icon (theme, browser_entries[i].icon_name, 48, 0, &error); + pixbuf = gtk_icon_theme_load_icon (theme, browser_entries[i].icon_name, 48, 0, &error); - gtk_list_store_set(store, &iter, - PIXBUF_COL, pixbuf, - TEXT_COL, browser_entries[i].icon_descr, - PAGE_NUMBER, browser_entries[i].page_number, - -1); + gtk_list_store_set (store, &iter, + PIXBUF_COL, pixbuf, + TEXT_COL, browser_entries[i].icon_descr, + PAGE_NUMBER, browser_entries[i].page_number, + -1); - if (pixbuf != NULL) { - gdk_pixbuf_unref (pixbuf); - } else { - DEBUG("Couldn't load icon: %s", error->message); - g_error_free (error); - } - } + if (pixbuf != NULL) { + gdk_pixbuf_unref (pixbuf); + } else { + DEBUG ("Couldn't load icon: %s", error->message); + g_error_free (error); + } + } - return GTK_TREE_MODEL(store); + return GTK_TREE_MODEL (store); } diff --git a/sflphone-client-gnome/src/config/preferencesdialog.h b/sflphone-client-gnome/src/config/preferencesdialog.h index 7f7db4d26e489968704e766184b9e121624090fc..c4a2a3f0be3036909f332490f96ab81afb8df3ed 100644 --- a/sflphone-client-gnome/src/config/preferencesdialog.h +++ b/sflphone-client-gnome/src/config/preferencesdialog.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -85,7 +85,7 @@ void select_active_output_audio_plugin(); * because the default plugin always use default audio device * @param plugin The description of the selected plugin */ -void update_combo_box( gchar* plugin ); +void update_combo_box (gchar* plugin); /** * Build the widget to display codec list @@ -97,7 +97,7 @@ GtkWidget * create_codec_table(); * Create the main account window in a new window * @return GtkWidget* The widget created */ -GtkWidget * create_accounts_tab(GtkDialog * dialog); +GtkWidget * create_accounts_tab (GtkDialog * dialog); /** * Create the audio configuration tab and add it to the main configuration window @@ -123,4 +123,4 @@ void history_load_configuration (void); GtkTreeModel* createModel(); -#endif +#endif diff --git a/sflphone-client-gnome/src/config/shortcuts-config.c b/sflphone-client-gnome/src/config/shortcuts-config.c index 1804b36d7cefa2333d099303a5778563f5636178..d57844f731af0a83ac4f32537a3b55ed120da449 100644 --- a/sflphone-client-gnome/src/config/shortcuts-config.c +++ b/sflphone-client-gnome/src/config/shortcuts-config.c @@ -33,48 +33,60 @@ #include <gdk/gdkx.h> -GtkWidget* -create_shortcuts_settings () +static void +accel_cleared (GtkCellRendererAccel *renderer UNUSED, gchar *path, + GtkTreeView *treeview) { - GtkWidget *vbox, *result_frame, *window, *treeview, *scrolled_window, *label; + DEBUG ("Accel cleared"); - GtkTreeIter iter; - guint i = 0; + GtkTreeModel *model; + GtkTreeIter iter; - vbox = gtk_vbox_new (FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER(vbox), 10); + // Update treeview + model = gtk_tree_view_get_model (treeview); - gnome_main_section_new (_("General"), &result_frame); + if (gtk_tree_model_get_iter_from_string (model, &iter, path)) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, -1); - label = gtk_label_new ( - _("Be careful: these shortcuts might override system-wide shortcuts.")); - treeview = gtk_tree_view_new (); - setup_tree_view (treeview); + // Update GDK bindings + shortcuts_update_bindings (atoi (path), 0, 0); +} - GtkListStore *store = gtk_list_store_new (COLUMNS, G_TYPE_STRING, G_TYPE_INT, - G_TYPE_UINT); +static void +accel_edited (GtkCellRendererAccel *renderer UNUSED, gchar *path, guint accel_key, + GdkModifierType mask, guint hardware_keycode UNUSED, GtkTreeView *treeview) +{ + DEBUG ("Accel edited"); - Accelerator* list = shortcuts_get_list (); + GtkTreeModel *model; + GtkTreeIter iter; - while (list[i].action != NULL) - { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, ACTION, _(list[i].action), MASK, - (gint) list[i].mask, VALUE, XKeycodeToKeysym (GDK_DISPLAY(), - list[i].key, 0), -1); - i++; - } + Accelerator* list = shortcuts_get_list (); + model = gtk_tree_view_get_model (treeview); + guint code = XKeysymToKeycode (GDK_DISPLAY(), accel_key); - gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); - g_object_unref (store); + // Disable existing binding if key already used + int i = 0; + gtk_tree_model_get_iter_first (model, &iter); - gtk_container_add (GTK_CONTAINER (result_frame), treeview); - gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(vbox), result_frame, FALSE, FALSE, 0); + while (list[i].action != NULL) { + if (list[i].key == code && list[i].mask == mask) { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, + -1); + WARN ("This key was already affected"); + } + + gtk_tree_model_iter_next (model, &iter); + i++; + } - gtk_widget_show_all (vbox); + // Update treeview + if (gtk_tree_model_get_iter_from_string (model, &iter, path)) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, (gint) mask, + VALUE, accel_key, -1); - return vbox; + // Update GDK bindings + shortcuts_update_bindings (atoi (path), code, mask); } /* @@ -84,76 +96,65 @@ create_shortcuts_settings () static void setup_tree_view (GtkWidget *treeview) { - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ("Action", renderer, - "text", ACTION, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); - - renderer = gtk_cell_renderer_accel_new (); - g_object_set (renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK, - "editable", TRUE, NULL); - column = gtk_tree_view_column_new_with_attributes ("Shortcut", renderer, - "accel-mods", MASK, "accel-key", VALUE, NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); - g_signal_connect (G_OBJECT (renderer), "accel_edited", G_CALLBACK (accel_edited), (gpointer) treeview); - g_signal_connect (G_OBJECT (renderer), "accel_cleared", G_CALLBACK (accel_cleared), (gpointer) treeview); + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Action", renderer, + "text", ACTION, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + renderer = gtk_cell_renderer_accel_new (); + g_object_set (renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK, + "editable", TRUE, NULL); + column = gtk_tree_view_column_new_with_attributes ("Shortcut", renderer, + "accel-mods", MASK, "accel-key", VALUE, NULL); + + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + g_signal_connect (G_OBJECT (renderer), "accel_edited", G_CALLBACK (accel_edited), (gpointer) treeview); + g_signal_connect (G_OBJECT (renderer), "accel_cleared", G_CALLBACK (accel_cleared), (gpointer) treeview); } -static void -accel_edited (GtkCellRendererAccel *renderer, gchar *path, guint accel_key, - GdkModifierType mask, guint hardware_keycode, GtkTreeView *treeview) +GtkWidget* +create_shortcuts_settings () { - DEBUG("Accel edited"); - - GtkTreeModel *model; - GtkTreeIter iter; - - Accelerator* list = shortcuts_get_list (); - model = gtk_tree_view_get_model (treeview); - gint code = XKeysymToKeycode (GDK_DISPLAY(), accel_key); - - // Disable existing binding if key already used - int i = 0; - gtk_tree_model_get_iter_first (model, &iter); - while (list[i].action != NULL) - { - if (list[i].key == code && list[i].mask == mask) - { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, - -1); - WARN("This key was already affected"); - } - gtk_tree_model_iter_next (model, &iter); - i++; - } + GtkWidget *vbox, *result_frame, *treeview, *label; - // Update treeview - if (gtk_tree_model_get_iter_from_string (model, &iter, path)) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, (gint) mask, - VALUE, accel_key, -1); + GtkTreeIter iter; + guint i = 0; - // Update GDK bindings - shortcuts_update_bindings (atoi (path), code, mask); -} + vbox = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 10); -static void -accel_cleared (GtkCellRendererAccel *renderer, gchar *path, - GtkTreeView *treeview) -{ - DEBUG("Accel cleared"); + gnome_main_section_new (_ ("General"), &result_frame); + + label = gtk_label_new ( + _ ("Be careful: these shortcuts might override system-wide shortcuts.")); + treeview = gtk_tree_view_new (); + setup_tree_view (treeview); - GtkTreeModel *model; - GtkTreeIter iter; + GtkListStore *store = gtk_list_store_new (COLUMNS, G_TYPE_STRING, G_TYPE_INT, + G_TYPE_UINT); - // Update treeview - model = gtk_tree_view_get_model (treeview); - if (gtk_tree_model_get_iter_from_string (model, &iter, path)) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, -1); + Accelerator* list = shortcuts_get_list (); - // Update GDK bindings - shortcuts_update_bindings (atoi (path), 0, 0); + while (list[i].action != NULL) { + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, ACTION, _ (list[i].action), MASK, + (gint) list[i].mask, VALUE, XKeycodeToKeysym (GDK_DISPLAY(), + list[i].key, 0), -1); + i++; + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); + g_object_unref (store); + + gtk_container_add (GTK_CONTAINER (result_frame), treeview); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), result_frame, FALSE, FALSE, 0); + + gtk_widget_show_all (vbox); + + return vbox; } + diff --git a/sflphone-client-gnome/src/config/shortcuts-config.h b/sflphone-client-gnome/src/config/shortcuts-config.h index 02682ab0a1631384205a7ae4939c4ae25fa48610..969ef27980bbb4d13c8f1882cf1cda54c92ee309 100644 --- a/sflphone-client-gnome/src/config/shortcuts-config.h +++ b/sflphone-client-gnome/src/config/shortcuts-config.h @@ -39,25 +39,13 @@ G_BEGIN_DECLS -enum -{ - ACTION = 0, MASK, VALUE, COLUMNS +enum { + ACTION = 0, MASK, VALUE, COLUMNS }; GtkWidget* create_shortcuts_settings (); -static void -setup_tree_view (GtkWidget *treeview); - -static void -accel_edited (GtkCellRendererAccel *renderer, gchar *path, guint accel_key, - GdkModifierType mask, guint hardware_keycode, GtkTreeView *treeview); - -static void -accel_cleared (GtkCellRendererAccel *renderer, gchar *path, - GtkTreeView *treeview); - G_END_DECLS #endif // _SHORTCUTS_CONFIG diff --git a/sflphone-client-gnome/src/config/tlsadvanceddialog.c b/sflphone-client-gnome/src/config/tlsadvanceddialog.c index 4050d0338f8ba1b2714ba083b29681444689afaf..05596dc27339ee75463516a5e8c71a38bb0fefc2 100644 --- a/sflphone-client-gnome/src/config/tlsadvanceddialog.c +++ b/sflphone-client-gnome/src/config/tlsadvanceddialog.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -41,328 +41,326 @@ #include <libsexy/sexy-icon-entry.h> #endif -void show_advanced_tls_options(GHashTable * properties) +void show_advanced_tls_options (GHashTable * properties) { GtkDialog * tlsDialog; GtkWidget * ret; - - tlsDialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Advanced options for TLS"), - GTK_WINDOW(get_main_window()), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, - GTK_RESPONSE_ACCEPT, - NULL)); - - gtk_window_set_policy( GTK_WINDOW(tlsDialog), FALSE, FALSE, FALSE ); - gtk_dialog_set_has_separator(tlsDialog, TRUE); - gtk_container_set_border_width (GTK_CONTAINER(tlsDialog), 0); - - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); - gtk_box_pack_start(GTK_BOX(tlsDialog->vbox), ret, FALSE, FALSE, 0); - - GtkWidget *frame, *table; - gnome_main_section_new_with_table (_("TLS transport"), &frame, &table, 3, 13); - gtk_container_set_border_width(GTK_CONTAINER (table), 10); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - gchar * description = g_markup_printf_escaped(_("TLS transport can be used along with UDP for those calls that would\n"\ - "require secure sip transactions (aka SIPS). You can configure a different\n"\ - "TLS transport for each account. However, each of them will run on a dedicated\n"\ - "port, different one from each other\n")); - GtkWidget * label; - label = gtk_label_new(NULL); - gtk_widget_set_size_request(label, 600, 70); - gtk_label_set_line_wrap (GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_label_set_markup(GTK_LABEL(label), description); - gtk_table_attach(GTK_TABLE(table), label, 0, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - gchar * account_id; - gchar * tls_listener_port; - gchar * tls_ca_list_file; - gchar * tls_certificate_file; - gchar * tls_private_key_file; - gchar * tls_password; - gchar * tls_method; - gchar * tls_ciphers; - gchar * tls_server_name; - gchar * verify_server; - gchar * verify_client; - gchar * require_client_certificate; - gchar * negotiation_timeout_sec; - gchar * negotiation_timeout_msec; + + tlsDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Advanced options for TLS"), + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, + NULL)); + + gtk_window_set_policy (GTK_WINDOW (tlsDialog), FALSE, FALSE, FALSE); + gtk_dialog_set_has_separator (tlsDialog, TRUE); + gtk_container_set_border_width (GTK_CONTAINER (tlsDialog), 0); + + ret = gtk_vbox_new (FALSE, 10); + gtk_container_set_border_width (GTK_CONTAINER (ret), 10); + gtk_box_pack_start (GTK_BOX (tlsDialog->vbox), ret, FALSE, FALSE, 0); + + GtkWidget *frame, *table; + gnome_main_section_new_with_table (_ ("TLS transport"), &frame, &table, 3, 13); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0); + + gchar * description = g_markup_printf_escaped (_ ("TLS transport can be used along with UDP for those calls that would\n"\ + "require secure sip transactions (aka SIPS). You can configure a different\n"\ + "TLS transport for each account. However, each of them will run on a dedicated\n"\ + "port, different one from each other\n")); + GtkWidget * label; + label = gtk_label_new (NULL); + gtk_widget_set_size_request (label, 600, 70); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_label_set_markup (GTK_LABEL (label), description); + gtk_table_attach (GTK_TABLE (table), label, 0, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + gchar * account_id = NULL; + gchar * tls_listener_port = NULL; + gchar * tls_ca_list_file = NULL; + gchar * tls_certificate_file = NULL; + gchar * tls_private_key_file = NULL; + gchar * tls_password = NULL; + gchar * tls_method = NULL; + gchar * tls_ciphers = NULL; + gchar * tls_server_name = NULL; + gchar * verify_server = NULL; + gchar * verify_client = NULL; + gchar * require_client_certificate = NULL; + gchar * negotiation_timeout_sec = NULL; + gchar * negotiation_timeout_msec = NULL; if (properties != NULL) { - account_id = g_hash_table_lookup(properties, ACCOUNT_ID); - tls_listener_port = g_hash_table_lookup(properties, TLS_LISTENER_PORT); - tls_ca_list_file = g_hash_table_lookup(properties, TLS_CA_LIST_FILE); - tls_certificate_file = g_hash_table_lookup(properties, TLS_CERTIFICATE_FILE); - tls_private_key_file = g_hash_table_lookup(properties, TLS_PRIVATE_KEY_FILE); - tls_password = g_hash_table_lookup(properties, TLS_PASSWORD); - tls_method = g_hash_table_lookup(properties, TLS_METHOD); - tls_ciphers = g_hash_table_lookup(properties, TLS_CIPHERS); - tls_server_name = g_hash_table_lookup(properties, TLS_SERVER_NAME); - verify_server = g_hash_table_lookup(properties, TLS_VERIFY_SERVER); - verify_client = g_hash_table_lookup(properties, TLS_VERIFY_CLIENT); - require_client_certificate = g_hash_table_lookup(properties, TLS_REQUIRE_CLIENT_CERTIFICATE); - negotiation_timeout_sec = g_hash_table_lookup(properties, TLS_NEGOTIATION_TIMEOUT_SEC); - negotiation_timeout_msec = g_hash_table_lookup(properties, TLS_NEGOTIATION_TIMEOUT_MSEC); + account_id = g_hash_table_lookup (properties, ACCOUNT_ID); + tls_listener_port = g_hash_table_lookup (properties, TLS_LISTENER_PORT); + tls_ca_list_file = g_hash_table_lookup (properties, TLS_CA_LIST_FILE); + tls_certificate_file = g_hash_table_lookup (properties, TLS_CERTIFICATE_FILE); + tls_private_key_file = g_hash_table_lookup (properties, TLS_PRIVATE_KEY_FILE); + tls_password = g_hash_table_lookup (properties, TLS_PASSWORD); + tls_method = g_hash_table_lookup (properties, TLS_METHOD); + tls_ciphers = g_hash_table_lookup (properties, TLS_CIPHERS); + tls_server_name = g_hash_table_lookup (properties, TLS_SERVER_NAME); + verify_server = g_hash_table_lookup (properties, TLS_VERIFY_SERVER); + verify_client = g_hash_table_lookup (properties, TLS_VERIFY_CLIENT); + require_client_certificate = g_hash_table_lookup (properties, TLS_REQUIRE_CLIENT_CERTIFICATE); + negotiation_timeout_sec = g_hash_table_lookup (properties, TLS_NEGOTIATION_TIMEOUT_SEC); + negotiation_timeout_msec = g_hash_table_lookup (properties, TLS_NEGOTIATION_TIMEOUT_MSEC); } - - label = gtk_label_new(_("Global TLS listener (all accounts)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - GtkWidget * tlsListenerPort; - GtkWidget * hbox = gtk_hbox_new(FALSE, 10); - gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - tlsListenerPort = gtk_spin_button_new_with_range(0, 65535, 1); - gtk_label_set_mnemonic_widget(GTK_LABEL (label), tlsListenerPort); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tlsListenerPort), g_ascii_strtod(tls_listener_port, NULL)); - gtk_box_pack_start_defaults(GTK_BOX(hbox), tlsListenerPort); - - if(g_strcmp0(account_id, IP2IP_PROFILE) != 0) { - gtk_widget_set_sensitive(tlsListenerPort, FALSE); + + label = gtk_label_new (_ ("Global TLS listener (all accounts)")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + GtkWidget * tlsListenerPort; + GtkWidget * hbox = gtk_hbox_new (FALSE, 10); + gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + tlsListenerPort = gtk_spin_button_new_with_range (0, 65535, 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), tlsListenerPort); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (tlsListenerPort), g_ascii_strtod (tls_listener_port, NULL)); + gtk_box_pack_start_defaults (GTK_BOX (hbox), tlsListenerPort); + + if (g_strcmp0 (account_id, IP2IP_PROFILE) != 0) { + gtk_widget_set_sensitive (tlsListenerPort, FALSE); } - - label = gtk_label_new( _("Certificate of Authority list")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + label = gtk_label_new (_ ("Certificate of Authority list")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * caListFileChooser; - caListFileChooser = gtk_file_chooser_button_new(_("Choose a CA list file (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); - gtk_table_attach (GTK_TABLE(table), caListFileChooser, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + caListFileChooser = gtk_file_chooser_button_new (_ ("Choose a CA list file (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_table_attach (GTK_TABLE (table), caListFileChooser, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (tls_ca_list_file == NULL) { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser)); + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (caListFileChooser)); - } - else { - if(g_strcmp0(tls_ca_list_file, "") == 0) { + } else { + if (g_strcmp0 (tls_ca_list_file, "") == 0) { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser)); - } - else{ + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (caListFileChooser)); + } else { - GFile * file = g_file_new_for_path(tls_ca_list_file); - gtk_file_chooser_set_file (GTK_FILE_CHOOSER(caListFileChooser), file, NULL); - g_object_unref(file); - } + GFile * file = g_file_new_for_path (tls_ca_list_file); + gtk_file_chooser_set_file (GTK_FILE_CHOOSER (caListFileChooser), file, NULL); + g_object_unref (file); + } } - label = gtk_label_new( _("Public endpoint certificate file")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + label = gtk_label_new (_ ("Public endpoint certificate file")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * certificateFileChooser; - certificateFileChooser = gtk_file_chooser_button_new(_("Choose a public endpoint certificate (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); - gtk_table_attach (GTK_TABLE(table), certificateFileChooser, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + certificateFileChooser = gtk_file_chooser_button_new (_ ("Choose a public endpoint certificate (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_table_attach (GTK_TABLE (table), certificateFileChooser, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (tls_certificate_file == NULL) { // gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(caListFileChooser), g_get_home_dir()); - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser)); + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (caListFileChooser)); } else { - if(g_strcmp0(tls_certificate_file, "") == 0){ + if (g_strcmp0 (tls_certificate_file, "") == 0) { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(certificateFileChooser)); - } - else { + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (certificateFileChooser)); + } else { - GFile * file = g_file_new_for_path(tls_certificate_file); - gtk_file_chooser_set_file (GTK_FILE_CHOOSER(certificateFileChooser), file, NULL); - g_object_unref(file); - } + GFile * file = g_file_new_for_path (tls_certificate_file); + gtk_file_chooser_set_file (GTK_FILE_CHOOSER (certificateFileChooser), file, NULL); + g_object_unref (file); + } } - - label = gtk_label_new(("Private key file")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + label = gtk_label_new ( ("Private key file")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * privateKeyFileChooser; - privateKeyFileChooser = gtk_file_chooser_button_new(_("Choose a private key file (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); - gtk_table_attach (GTK_TABLE(table), privateKeyFileChooser, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + privateKeyFileChooser = gtk_file_chooser_button_new (_ ("Choose a private key file (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_table_attach (GTK_TABLE (table), privateKeyFileChooser, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (tls_private_key_file == NULL) { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser)); + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (caListFileChooser)); } else { - if(g_strcmp0(tls_private_key_file, "") == 0) { + if (g_strcmp0 (tls_private_key_file, "") == 0) { - gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(privateKeyFileChooser)); - } - else { + gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (privateKeyFileChooser)); + } else { - GFile * file = g_file_new_for_path(tls_private_key_file); - gtk_file_chooser_set_file (GTK_FILE_CHOOSER(privateKeyFileChooser), file, NULL); - g_object_unref(file); + GFile * file = g_file_new_for_path (tls_private_key_file); + gtk_file_chooser_set_file (GTK_FILE_CHOOSER (privateKeyFileChooser), file, NULL); + g_object_unref (file); - } + } } - - label = gtk_label_new_with_mnemonic (_("Password for the private key")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - GtkWidget * privateKeyPasswordEntry; + + label = gtk_label_new_with_mnemonic (_ ("Password for the private key")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + GtkWidget * privateKeyPasswordEntry; #if GTK_CHECK_VERSION(2,16,0) - privateKeyPasswordEntry = gtk_entry_new(); - gtk_entry_set_icon_from_stock (GTK_ENTRY (privateKeyPasswordEntry), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); + privateKeyPasswordEntry = gtk_entry_new(); + gtk_entry_set_icon_from_stock (GTK_ENTRY (privateKeyPasswordEntry), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); #else - privateKeyPasswordEntry = sexy_icon_entry_new(); - GtkWidget * image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR ); - sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(privateKeyPasswordEntry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + privateKeyPasswordEntry = sexy_icon_entry_new(); + GtkWidget * image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (privateKeyPasswordEntry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); #endif - gtk_entry_set_visibility(GTK_ENTRY(privateKeyPasswordEntry), FALSE); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), privateKeyPasswordEntry); - gtk_entry_set_text(GTK_ENTRY(privateKeyPasswordEntry), tls_password); - gtk_table_attach (GTK_TABLE(table), privateKeyPasswordEntry, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - /* TLS protocol methods */ - GtkListStore * tlsProtocolMethodListStore; + gtk_entry_set_visibility (GTK_ENTRY (privateKeyPasswordEntry), FALSE); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), privateKeyPasswordEntry); + gtk_entry_set_text (GTK_ENTRY (privateKeyPasswordEntry), tls_password); + gtk_table_attach (GTK_TABLE (table), privateKeyPasswordEntry, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + /* TLS protocol methods */ + GtkListStore * tlsProtocolMethodListStore; GtkTreeIter iter; GtkWidget * tlsProtocolMethodCombo; - - tlsProtocolMethodListStore = gtk_list_store_new( 1, G_TYPE_STRING ); - label = gtk_label_new_with_mnemonic (_("TLS protocol method")); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); - - gchar** supported_tls_method = NULL; + + tlsProtocolMethodListStore = gtk_list_store_new (1, G_TYPE_STRING); + label = gtk_label_new_with_mnemonic (_ ("TLS protocol method")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + gchar** supported_tls_method = NULL; supported_tls_method = dbus_get_supported_tls_method(); GtkTreeIter supported_tls_method_iter = iter; + if (supported_tls_method != NULL) { char **supported_tls_method_ptr; + for (supported_tls_method_ptr = supported_tls_method; *supported_tls_method_ptr; supported_tls_method_ptr++) { - DEBUG("Supported Method %s", *supported_tls_method_ptr); - gtk_list_store_append(tlsProtocolMethodListStore, &iter ); - gtk_list_store_set(tlsProtocolMethodListStore, &iter, 0, *supported_tls_method_ptr, -1 ); - - if (g_strcmp0(*supported_tls_method_ptr, tls_method) == 0) { - DEBUG("Setting active element in TLS protocol combo box"); + DEBUG ("Supported Method %s", *supported_tls_method_ptr); + gtk_list_store_append (tlsProtocolMethodListStore, &iter); + gtk_list_store_set (tlsProtocolMethodListStore, &iter, 0, *supported_tls_method_ptr, -1); + + if (g_strcmp0 (*supported_tls_method_ptr, tls_method) == 0) { + DEBUG ("Setting active element in TLS protocol combo box"); supported_tls_method_iter = iter; } } } - - tlsProtocolMethodCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(tlsProtocolMethodListStore)); - gtk_label_set_mnemonic_widget(GTK_LABEL(label), tlsProtocolMethodCombo); - gtk_table_attach(GTK_TABLE(table), tlsProtocolMethodCombo, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - g_object_unref(G_OBJECT(tlsProtocolMethodListStore)); - + + tlsProtocolMethodCombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (tlsProtocolMethodListStore)); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), tlsProtocolMethodCombo); + gtk_table_attach (GTK_TABLE (table), tlsProtocolMethodCombo, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + g_object_unref (G_OBJECT (tlsProtocolMethodListStore)); + GtkCellRenderer *tlsProtocolMethodCellRenderer; tlsProtocolMethodCellRenderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(tlsProtocolMethodCombo), tlsProtocolMethodCellRenderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(tlsProtocolMethodCombo), tlsProtocolMethodCellRenderer, "text", 0, NULL); - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(tlsProtocolMethodCombo), &supported_tls_method_iter); - + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tlsProtocolMethodCombo), tlsProtocolMethodCellRenderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tlsProtocolMethodCombo), tlsProtocolMethodCellRenderer, "text", 0, NULL); + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (tlsProtocolMethodCombo), &supported_tls_method_iter); + /* Cipher list */ GtkWidget * cipherListEntry; - label = gtk_label_new_with_mnemonic (_("TLS cipher list")); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + label = gtk_label_new_with_mnemonic (_ ("TLS cipher list")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); cipherListEntry = gtk_entry_new(); - gtk_label_set_mnemonic_widget(GTK_LABEL(label), cipherListEntry); - gtk_entry_set_text(GTK_ENTRY(cipherListEntry), tls_ciphers); - gtk_table_attach (GTK_TABLE(table), cipherListEntry, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), cipherListEntry); + gtk_entry_set_text (GTK_ENTRY (cipherListEntry), tls_ciphers); + gtk_table_attach (GTK_TABLE (table), cipherListEntry, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + GtkWidget * serverNameInstance; - label = gtk_label_new_with_mnemonic (_("Server name instance for outgoing TLS connection")); - gtk_table_attach (GTK_TABLE(table), label, 0, 1, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + label = gtk_label_new_with_mnemonic (_ ("Server name instance for outgoing TLS connection")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); serverNameInstance = gtk_entry_new(); - gtk_label_set_mnemonic_widget(GTK_LABEL(label), serverNameInstance); - gtk_entry_set_text(GTK_ENTRY(serverNameInstance), tls_server_name); - gtk_table_attach (GTK_TABLE(table), serverNameInstance, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - label = gtk_label_new(_("Negotiation timeout (sec:msec)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - GtkWidget * tlsTimeOutSec; - hbox = gtk_hbox_new(FALSE, 10); - gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - tlsTimeOutSec = gtk_spin_button_new_with_range(0, pow(2,sizeof(long)), 1); - gtk_label_set_mnemonic_widget(GTK_LABEL (label), tlsTimeOutSec); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tlsTimeOutSec), g_ascii_strtod(negotiation_timeout_sec, NULL)); - gtk_box_pack_start_defaults(GTK_BOX(hbox), tlsTimeOutSec); - GtkWidget * tlsTimeOutMSec; - tlsTimeOutMSec = gtk_spin_button_new_with_range(0, pow(2,sizeof(long)), 1); - gtk_label_set_mnemonic_widget(GTK_LABEL (label), tlsTimeOutMSec); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tlsTimeOutMSec), g_ascii_strtod(negotiation_timeout_msec, NULL)); - gtk_box_pack_start_defaults(GTK_BOX(hbox), tlsTimeOutMSec); - + gtk_label_set_mnemonic_widget (GTK_LABEL (label), serverNameInstance); + gtk_entry_set_text (GTK_ENTRY (serverNameInstance), tls_server_name); + gtk_table_attach (GTK_TABLE (table), serverNameInstance, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + label = gtk_label_new (_ ("Negotiation timeout (sec:msec)")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + GtkWidget * tlsTimeOutSec; + hbox = gtk_hbox_new (FALSE, 10); + gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + tlsTimeOutSec = gtk_spin_button_new_with_range (0, pow (2,sizeof (long)), 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), tlsTimeOutSec); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (tlsTimeOutSec), g_ascii_strtod (negotiation_timeout_sec, NULL)); + gtk_box_pack_start_defaults (GTK_BOX (hbox), tlsTimeOutSec); + GtkWidget * tlsTimeOutMSec; + tlsTimeOutMSec = gtk_spin_button_new_with_range (0, pow (2,sizeof (long)), 1); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), tlsTimeOutMSec); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (tlsTimeOutMSec), g_ascii_strtod (negotiation_timeout_msec, NULL)); + gtk_box_pack_start_defaults (GTK_BOX (hbox), tlsTimeOutMSec); + GtkWidget * verifyCertificateServer; - verifyCertificateServer = gtk_check_button_new_with_mnemonic(_("Verify incoming certificates, as a server")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateServer), - g_strcasecmp(verify_server,"true") == 0 ? TRUE: FALSE); - gtk_table_attach (GTK_TABLE(table), verifyCertificateServer, 0, 1, 11, 12, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + verifyCertificateServer = gtk_check_button_new_with_mnemonic (_ ("Verify incoming certificates, as a server")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (verifyCertificateServer), + g_strcasecmp (verify_server,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (table), verifyCertificateServer, 0, 1, 11, 12, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * verifyCertificateClient; - verifyCertificateClient = gtk_check_button_new_with_mnemonic(_("Verify certificates from answer, as a client")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateClient), - g_strcasecmp(verify_client,"true") == 0 ? TRUE: FALSE); - gtk_table_attach (GTK_TABLE(table), verifyCertificateClient, 0, 1, 12, 13, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + verifyCertificateClient = gtk_check_button_new_with_mnemonic (_ ("Verify certificates from answer, as a client")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (verifyCertificateClient), + g_strcasecmp (verify_client,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (table), verifyCertificateClient, 0, 1, 12, 13, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * requireCertificate; - requireCertificate = gtk_check_button_new_with_mnemonic(_("Require certificate for incoming tls connections")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(requireCertificate), - g_strcasecmp(require_client_certificate,"true") == 0 ? TRUE: FALSE); - gtk_table_attach (GTK_TABLE(table), requireCertificate, 0, 1, 13, 14, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - gtk_widget_show_all(ret); - - if(gtk_dialog_run(GTK_DIALOG(tlsDialog)) == GTK_RESPONSE_ACCEPT) { - - g_hash_table_replace(properties, - g_strdup(TLS_LISTENER_PORT), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(tlsListenerPort)))); - g_hash_table_replace(properties, - g_strdup(TLS_CA_LIST_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(caListFileChooser)))); - - g_hash_table_replace(properties, - g_strdup(TLS_CERTIFICATE_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(certificateFileChooser)))); - - g_hash_table_replace(properties, - g_strdup(TLS_PRIVATE_KEY_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(privateKeyFileChooser)))); - - g_hash_table_replace(properties, - g_strdup(TLS_PASSWORD), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(privateKeyPasswordEntry)))); - - g_hash_table_replace(properties, - g_strdup(TLS_METHOD), - g_strdup((gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(tlsProtocolMethodCombo)))); - - g_hash_table_replace(properties, - g_strdup(TLS_CIPHERS), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(cipherListEntry)))); - - g_hash_table_replace(properties, - g_strdup(TLS_SERVER_NAME), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(serverNameInstance)))); - - g_hash_table_replace(properties, - g_strdup(TLS_VERIFY_SERVER), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(verifyCertificateServer)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(TLS_VERIFY_CLIENT), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(verifyCertificateClient)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(TLS_REQUIRE_CLIENT_CERTIFICATE), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(requireCertificate)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(TLS_NEGOTIATION_TIMEOUT_SEC), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(tlsTimeOutSec)))); - - g_hash_table_replace(properties, - g_strdup(TLS_NEGOTIATION_TIMEOUT_MSEC), - g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(tlsTimeOutMSec)))); - } - - gtk_widget_destroy (GTK_WIDGET(tlsDialog)); + requireCertificate = gtk_check_button_new_with_mnemonic (_ ("Require certificate for incoming tls connections")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (requireCertificate), + g_strcasecmp (require_client_certificate,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (table), requireCertificate, 0, 1, 13, 14, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + gtk_widget_show_all (ret); + + if (gtk_dialog_run (GTK_DIALOG (tlsDialog)) == GTK_RESPONSE_ACCEPT) { + + g_hash_table_replace (properties, + g_strdup (TLS_LISTENER_PORT), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (tlsListenerPort)))); + g_hash_table_replace (properties, + g_strdup (TLS_CA_LIST_FILE), g_strdup (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (caListFileChooser)))); + + g_hash_table_replace (properties, + g_strdup (TLS_CERTIFICATE_FILE), g_strdup (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (certificateFileChooser)))); + + g_hash_table_replace (properties, + g_strdup (TLS_PRIVATE_KEY_FILE), g_strdup (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (privateKeyFileChooser)))); + + g_hash_table_replace (properties, + g_strdup (TLS_PASSWORD), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (privateKeyPasswordEntry)))); + + g_hash_table_replace (properties, + g_strdup (TLS_METHOD), + g_strdup ( (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (tlsProtocolMethodCombo)))); + + g_hash_table_replace (properties, + g_strdup (TLS_CIPHERS), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (cipherListEntry)))); + + g_hash_table_replace (properties, + g_strdup (TLS_SERVER_NAME), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (serverNameInstance)))); + + g_hash_table_replace (properties, + g_strdup (TLS_VERIFY_SERVER), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (verifyCertificateServer)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (TLS_VERIFY_CLIENT), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (verifyCertificateClient)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (TLS_REQUIRE_CLIENT_CERTIFICATE), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (requireCertificate)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (TLS_NEGOTIATION_TIMEOUT_SEC), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (tlsTimeOutSec)))); + + g_hash_table_replace (properties, + g_strdup (TLS_NEGOTIATION_TIMEOUT_MSEC), + g_strdup ( (gchar *) gtk_entry_get_text (GTK_ENTRY (tlsTimeOutMSec)))); + } + + gtk_widget_destroy (GTK_WIDGET (tlsDialog)); } diff --git a/sflphone-client-gnome/src/config/tlsadvanceddialog.h b/sflphone-client-gnome/src/config/tlsadvanceddialog.h index 4c7ed3a37f04144264d4410b3d54c33d3209ca8b..d60fdf8e9a1c2f96339547e937699c9364c00fd8 100644 --- a/sflphone-client-gnome/src/config/tlsadvanceddialog.h +++ b/sflphone-client-gnome/src/config/tlsadvanceddialog.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __SFL_TLS_ADVANCED_DIALOG__ #define __SFL_TLS_ADVANCED_DIALOG__ /** @file tlsadvanceddialog.h @@ -37,10 +37,10 @@ #include <glib.h> #include <mainwindow.h> -/** +/** * Display the advanced options window for zrtp - */ + */ -void show_advanced_tls_options(GHashTable * properties); +void show_advanced_tls_options (GHashTable * properties); -#endif +#endif diff --git a/sflphone-client-gnome/src/config/utils.c b/sflphone-client-gnome/src/config/utils.c index 7049d796069507e169258f9e792f4c02ed8cb18a..66de3b7168f5f262678c6cc6420a1da6de16fc8e 100644 --- a/sflphone-client-gnome/src/config/utils.c +++ b/sflphone-client-gnome/src/config/utils.c @@ -29,10 +29,11 @@ */ #include "utils.h" +#include <sflphone_const.h> void gnome_main_section_new_with_table (gchar *title, GtkWidget **frame, GtkWidget **table, gint nb_col, gint nb_row) { - GtkWidget *_frame, *_table, *label, *align; + GtkWidget *_frame, *_table, *label, *align; PangoAttrList *attrs = NULL; PangoAttribute *attr = NULL; @@ -44,28 +45,28 @@ void gnome_main_section_new_with_table (gchar *title, GtkWidget **frame, GtkWidg _frame = gtk_frame_new (title); gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE); - gtk_container_set_border_width(GTK_CONTAINER(_frame), 2); - + gtk_container_set_border_width (GTK_CONTAINER (_frame), 2); + label = gtk_frame_get_label_widget (GTK_FRAME (_frame)); gtk_label_set_attributes (GTK_LABEL (label), attrs); pango_attr_list_unref (attrs); - align = gtk_alignment_new( 0.08, 0.2, 0.1, 0.1 ); - gtk_container_add( GTK_CONTAINER(_frame), align ); + align = gtk_alignment_new (0.08, 0.2, 0.1, 0.1); + gtk_container_add (GTK_CONTAINER (_frame), align); + + _table = gtk_table_new (nb_col, nb_row, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (_table), 2); + gtk_table_set_col_spacings (GTK_TABLE (_table), 2); + gtk_widget_show (_table); + gtk_container_add (GTK_CONTAINER (align), _table); - _table = gtk_table_new(nb_col, nb_row, FALSE); - gtk_table_set_row_spacings( GTK_TABLE(_table), 2); - gtk_table_set_col_spacings( GTK_TABLE(_table), 2); - gtk_widget_show(_table); - gtk_container_add( GTK_CONTAINER(align), _table ); - *table = _table; *frame = _frame; } -void gnome_main_section_new_with_vbox (gchar *title, GtkWidget **frame, GtkWidget **vbox, gint nb_row) +void gnome_main_section_new_with_vbox (gchar *title, GtkWidget **frame, GtkWidget **vbox, gint nb_row UNUSED) { - GtkWidget *_frame, *_vbox, *label, *align; + GtkWidget *_frame, *_vbox, *label, *align; PangoAttrList *attrs = NULL; PangoAttribute *attr = NULL; @@ -77,19 +78,19 @@ void gnome_main_section_new_with_vbox (gchar *title, GtkWidget **frame, GtkWidge _frame = gtk_frame_new (title); gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE); - gtk_container_set_border_width(GTK_CONTAINER(_frame), 2); - + gtk_container_set_border_width (GTK_CONTAINER (_frame), 2); + label = gtk_frame_get_label_widget (GTK_FRAME (_frame)); gtk_label_set_attributes (GTK_LABEL (label), attrs); pango_attr_list_unref (attrs); - align = gtk_alignment_new( 0.08, 0.2, 0.1, 0.1 ); - gtk_container_add( GTK_CONTAINER(_frame), align ); - - _vbox = gtk_vbox_new(FALSE, 10); - gtk_widget_show(_vbox); - gtk_container_add( GTK_CONTAINER(align), _vbox); - + align = gtk_alignment_new (0.08, 0.2, 0.1, 0.1); + gtk_container_add (GTK_CONTAINER (_frame), align); + + _vbox = gtk_vbox_new (FALSE, 10); + gtk_widget_show (_vbox); + gtk_container_add (GTK_CONTAINER (align), _vbox); + *vbox = _vbox; *frame = _frame; } @@ -99,7 +100,7 @@ void gnome_main_section_new (gchar *title, GtkWidget **frame) GtkWidget *_frame, *label; PangoAttrList *attrs = NULL; PangoAttribute *attr = NULL; - + attrs = pango_attr_list_new (); attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); attr->start_index = 0; @@ -108,8 +109,8 @@ void gnome_main_section_new (gchar *title, GtkWidget **frame) _frame = gtk_frame_new (title); gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE); - gtk_container_set_border_width(GTK_CONTAINER(_frame), 2); - + gtk_container_set_border_width (GTK_CONTAINER (_frame), 2); + label = gtk_frame_get_label_widget (GTK_FRAME (_frame)); gtk_label_set_attributes (GTK_LABEL (label), attrs); pango_attr_list_unref (attrs); diff --git a/sflphone-client-gnome/src/config/zrtpadvanceddialog.c b/sflphone-client-gnome/src/config/zrtpadvanceddialog.c index 469cf52a3c4230eef362788eab10485e329c3355..8d6594798f39d80a2fd7958bc345dda82ec0321e 100644 --- a/sflphone-client-gnome/src/config/zrtpadvanceddialog.c +++ b/sflphone-client-gnome/src/config/zrtpadvanceddialog.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,152 +34,152 @@ #include <gtk/gtk.h> -void show_advanced_zrtp_options(GHashTable * properties) +void show_advanced_zrtp_options (GHashTable * properties) { GtkDialog * securityDialog; - GtkWidget * zrtpFrame; GtkWidget * tableZrtp; GtkWidget * enableHelloHash; GtkWidget * enableSASConfirm; GtkWidget * enableZrtpNotSuppOther; GtkWidget * displaySasOnce; - + gchar * curSasConfirm = "true"; gchar * curHelloEnabled = "true"; gchar * curZrtpNotSuppOther = "true"; gchar * curDisplaySasOnce = "false"; - - if(properties != NULL) { - curHelloEnabled = g_hash_table_lookup(properties, ACCOUNT_ZRTP_HELLO_HASH); - curSasConfirm = g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS); - curZrtpNotSuppOther = g_hash_table_lookup(properties, ACCOUNT_ZRTP_NOT_SUPP_WARNING); - curDisplaySasOnce = g_hash_table_lookup(properties, ACCOUNT_DISPLAY_SAS_ONCE); + + if (properties != NULL) { + curHelloEnabled = g_hash_table_lookup (properties, ACCOUNT_ZRTP_HELLO_HASH); + curSasConfirm = g_hash_table_lookup (properties, ACCOUNT_ZRTP_DISPLAY_SAS); + curZrtpNotSuppOther = g_hash_table_lookup (properties, ACCOUNT_ZRTP_NOT_SUPP_WARNING); + curDisplaySasOnce = g_hash_table_lookup (properties, ACCOUNT_DISPLAY_SAS_ONCE); + } + + securityDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("ZRTP Options"), + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, + NULL) + ); + gtk_window_set_policy (GTK_WINDOW (securityDialog), FALSE, FALSE, FALSE); + gtk_dialog_set_has_separator (securityDialog, TRUE); + gtk_container_set_border_width (GTK_CONTAINER (securityDialog), 0); + + + tableZrtp = gtk_table_new (4, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (tableZrtp), 10); + gtk_table_set_col_spacings (GTK_TABLE (tableZrtp), 10); + gtk_box_pack_start (GTK_BOX (securityDialog->vbox), tableZrtp, FALSE, FALSE, 0); + gtk_widget_show (tableZrtp); + + enableHelloHash = gtk_check_button_new_with_mnemonic (_ ("Send Hello Hash in S_DP")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableHelloHash), + g_strcasecmp (curHelloEnabled,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (tableZrtp), enableHelloHash, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (enableHelloHash) , TRUE); + + enableSASConfirm = gtk_check_button_new_with_mnemonic (_ ("Ask User to Confirm SAS")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableSASConfirm), + g_strcasecmp (curSasConfirm,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (tableZrtp), enableSASConfirm, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (enableSASConfirm) , TRUE); + + enableZrtpNotSuppOther = gtk_check_button_new_with_mnemonic (_ ("_Warn if ZRTP not supported")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableZrtpNotSuppOther), + g_strcasecmp (curZrtpNotSuppOther,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (tableZrtp), enableZrtpNotSuppOther, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (enableZrtpNotSuppOther) , TRUE); + + displaySasOnce = gtk_check_button_new_with_mnemonic (_ ("Display SAS once for hold events")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (displaySasOnce), + g_strcasecmp (curDisplaySasOnce,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (tableZrtp), displaySasOnce, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (displaySasOnce) , TRUE); + + gtk_widget_show_all (tableZrtp); + + gtk_container_set_border_width (GTK_CONTAINER (tableZrtp), 10); + + if (gtk_dialog_run (GTK_DIALOG (securityDialog)) == GTK_RESPONSE_ACCEPT) { + g_hash_table_replace (properties, + g_strdup (ACCOUNT_ZRTP_DISPLAY_SAS), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enableSASConfirm)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (ACCOUNT_DISPLAY_SAS_ONCE), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (displaySasOnce)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (ACCOUNT_ZRTP_HELLO_HASH), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enableHelloHash)) ? "true": "false")); + + g_hash_table_replace (properties, + g_strdup (ACCOUNT_ZRTP_NOT_SUPP_WARNING), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enableZrtpNotSuppOther)) ? "true": "false")); } - - securityDialog = GTK_DIALOG (gtk_dialog_new_with_buttons ( _("ZRTP Options"), - GTK_WINDOW (get_main_window()), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, - GTK_RESPONSE_ACCEPT, - NULL) - ); - gtk_window_set_policy( GTK_WINDOW(securityDialog), FALSE, FALSE, FALSE ); - gtk_dialog_set_has_separator(securityDialog, TRUE); - gtk_container_set_border_width (GTK_CONTAINER(securityDialog), 0); - - - tableZrtp = gtk_table_new (4, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(tableZrtp), 10); - gtk_table_set_col_spacings( GTK_TABLE(tableZrtp), 10); - gtk_box_pack_start(GTK_BOX(securityDialog->vbox), tableZrtp, FALSE, FALSE, 0); - gtk_widget_show(tableZrtp); - - enableHelloHash = gtk_check_button_new_with_mnemonic(_("Send Hello Hash in S_DP")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableHelloHash), - g_strcasecmp(curHelloEnabled,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE(tableZrtp), enableHelloHash, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( enableHelloHash ) , TRUE ); - - enableSASConfirm = gtk_check_button_new_with_mnemonic(_("Ask User to Confirm SAS")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableSASConfirm), - g_strcasecmp(curSasConfirm,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE(tableZrtp), enableSASConfirm, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( enableSASConfirm ) , TRUE ); - - enableZrtpNotSuppOther = gtk_check_button_new_with_mnemonic(_("_Warn if ZRTP not supported")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableZrtpNotSuppOther), - g_strcasecmp(curZrtpNotSuppOther,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE(tableZrtp), enableZrtpNotSuppOther, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( enableZrtpNotSuppOther ) , TRUE ); - - displaySasOnce = gtk_check_button_new_with_mnemonic(_("Display SAS once for hold events")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(displaySasOnce), - g_strcasecmp(curDisplaySasOnce,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE(tableZrtp), displaySasOnce, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( displaySasOnce ) , TRUE ); - - gtk_widget_show_all(tableZrtp); - - gtk_container_set_border_width (GTK_CONTAINER(tableZrtp), 10); - - if(gtk_dialog_run(GTK_DIALOG(securityDialog)) == GTK_RESPONSE_ACCEPT) { - g_hash_table_replace(properties, - g_strdup(ACCOUNT_ZRTP_DISPLAY_SAS), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableSASConfirm)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(ACCOUNT_DISPLAY_SAS_ONCE), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(displaySasOnce)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(ACCOUNT_ZRTP_HELLO_HASH), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableHelloHash)) ? "true": "false")); - - g_hash_table_replace(properties, - g_strdup(ACCOUNT_ZRTP_NOT_SUPP_WARNING), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableZrtpNotSuppOther)) ? "true": "false")); - } - - gtk_widget_destroy (GTK_WIDGET(securityDialog)); + + gtk_widget_destroy (GTK_WIDGET (securityDialog)); } -void show_advanced_sdes_options(GHashTable * properties) { +void show_advanced_sdes_options (GHashTable * properties) +{ GtkDialog * securityDialog; GtkWidget * sdesTable; GtkWidget * enableRtpFallback; gchar * rtpFallback = "false"; - - if(properties != NULL) { - rtpFallback = g_hash_table_lookup(properties, ACCOUNT_SRTP_RTP_FALLBACK); + + if (properties != NULL) { + rtpFallback = g_hash_table_lookup (properties, ACCOUNT_SRTP_RTP_FALLBACK); } - securityDialog = GTK_DIALOG (gtk_dialog_new_with_buttons ( _("SDES Options"), + securityDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("SDES Options"), + + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_WINDOW (get_main_window()), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, - GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, - GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, - GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, - GTK_RESPONSE_ACCEPT, - - NULL)); + NULL)); - gtk_window_set_policy( GTK_WINDOW(securityDialog), FALSE, FALSE, FALSE ); - gtk_dialog_set_has_separator(securityDialog, TRUE); - gtk_container_set_border_width (GTK_CONTAINER(securityDialog), 0); + gtk_window_set_policy (GTK_WINDOW (securityDialog), FALSE, FALSE, FALSE); + gtk_dialog_set_has_separator (securityDialog, TRUE); + gtk_container_set_border_width (GTK_CONTAINER (securityDialog), 0); - sdesTable = gtk_table_new (1, 2 , FALSE/* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(sdesTable), 10); - gtk_table_set_col_spacings( GTK_TABLE(sdesTable), 10); - gtk_box_pack_start(GTK_BOX(securityDialog->vbox), sdesTable, FALSE, FALSE, 0); - gtk_widget_show(sdesTable); + sdesTable = gtk_table_new (1, 2 , FALSE/* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (sdesTable), 10); + gtk_table_set_col_spacings (GTK_TABLE (sdesTable), 10); + gtk_box_pack_start (GTK_BOX (securityDialog->vbox), sdesTable, FALSE, FALSE, 0); + gtk_widget_show (sdesTable); - enableRtpFallback = gtk_check_button_new_with_mnemonic(_("Fallback on RTP on SDES failure")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableRtpFallback), - g_strcasecmp(rtpFallback,"true") == 0 ? TRUE: FALSE); - gtk_table_attach ( GTK_TABLE(sdesTable), enableRtpFallback, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive( GTK_WIDGET( enableRtpFallback ) , TRUE ); + enableRtpFallback = gtk_check_button_new_with_mnemonic (_ ("Fallback on RTP on SDES failure")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableRtpFallback), + g_strcasecmp (rtpFallback,"true") == 0 ? TRUE: FALSE); + gtk_table_attach (GTK_TABLE (sdesTable), enableRtpFallback, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_set_sensitive (GTK_WIDGET (enableRtpFallback) , TRUE); - gtk_widget_show_all(sdesTable); + gtk_widget_show_all (sdesTable); + + gtk_container_set_border_width (GTK_CONTAINER (sdesTable), 10); + + if (gtk_dialog_run (GTK_DIALOG (securityDialog)) == GTK_RESPONSE_ACCEPT) { + g_hash_table_replace (properties, + g_strdup (ACCOUNT_SRTP_RTP_FALLBACK), + g_strdup (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enableRtpFallback)) ? "true": "false")); + } - gtk_container_set_border_width (GTK_CONTAINER(sdesTable), 10); - - if(gtk_dialog_run(GTK_DIALOG(securityDialog)) == GTK_RESPONSE_ACCEPT) { - g_hash_table_replace(properties, - g_strdup(ACCOUNT_SRTP_RTP_FALLBACK), - g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableRtpFallback)) ? "true": "false")); - } - - gtk_widget_destroy (GTK_WIDGET(securityDialog)); + gtk_widget_destroy (GTK_WIDGET (securityDialog)); } diff --git a/sflphone-client-gnome/src/config/zrtpadvanceddialog.h b/sflphone-client-gnome/src/config/zrtpadvanceddialog.h index c561d6a1f15f8e10167149ae91aa39e3f07e4678..fc6f4ec839887c5b6c9b19b2f2b26a4473482328 100644 --- a/sflphone-client-gnome/src/config/zrtpadvanceddialog.h +++ b/sflphone-client-gnome/src/config/zrtpadvanceddialog.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __SFL_ZRTP_ADVANCED_DIALOG__ #define __SFL_ZRTP_ADVANCED_DIALOG__ /** @file zrtpadvanceddialog.h @@ -36,12 +36,12 @@ #include <glib.h> #include <mainwindow.h> -/** +/** * Display the advanced options window for zrtp - */ + */ -void show_advanced_zrtp_options(GHashTable * properties); +void show_advanced_zrtp_options (GHashTable * properties); -void show_advanced_sdes_options(GHashTable * properties); +void show_advanced_sdes_options (GHashTable * properties); -#endif +#endif diff --git a/sflphone-client-gnome/src/contacts/addressbook.c b/sflphone-client-gnome/src/contacts/addressbook.c index f0d8c464cbf47f31eb7cdbb6d31511ea09c5951f..86cf1e67724a4588f53c2eba5f14baf0295cdc1d 100644 --- a/sflphone-client-gnome/src/contacts/addressbook.c +++ b/sflphone-client-gnome/src/contacts/addressbook.c @@ -34,45 +34,45 @@ #include <addressbook-config.h> static void -handler_async_search(GList *, gpointer); +handler_async_search (GList *, gpointer); /** * Perform a search on address book */ void -addressbook_search(GtkEntry* entry) +addressbook_search (GtkEntry* entry) { - const gchar* query = gtk_entry_get_text(GTK_ENTRY (entry)); - DEBUG("Addressbook: Search %s", query); + const gchar* query = gtk_entry_get_text (GTK_ENTRY (entry)); + DEBUG ("Addressbook: Search %s", query); AddressBook_Config *addressbook_config; activateWaitingLayer(); - addressbook_config_load_parameters(&addressbook_config); + addressbook_config_load_parameters (&addressbook_config); // search_by_contacts(gtk_entry_get_text(GTK_ENTRY(entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); - search_async_by_contacts(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); + search_async_by_contacts (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); - /* - if (strlen(query) >= 3) { + /* + if (strlen(query) >= 3) { - AddressBook_Config *addressbook_config; - - // Activate waiting layer - activateWaitingLayer(); + AddressBook_Config *addressbook_config; - // Load the address book parameters - addressbook_config_load_parameters(&addressbook_config); - - // Start the asynchronous search as soon as we have an entry - search_async(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); + // Activate waiting layer + activateWaitingLayer(); - } - */ + // Load the address book parameters + addressbook_config_load_parameters(&addressbook_config); + + // Start the asynchronous search as soon as we have an entry + search_async(gtk_entry_get_text(GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config); + + } + */ } @@ -82,12 +82,12 @@ addressbook_search(GtkEntry* entry) gboolean addressbook_is_enabled() { - AddressBook_Config *addressbook_config; - - // Load the address book parameters - addressbook_config_load_parameters(&addressbook_config); + AddressBook_Config *addressbook_config; - return (guint)addressbook_config->enable; + // Load the address book parameters + addressbook_config_load_parameters (&addressbook_config); + + return (guint) addressbook_config->enable; } /** @@ -96,7 +96,7 @@ addressbook_is_enabled() gboolean addressbook_is_ready() { - return books_ready(); + return books_ready(); } /** @@ -105,7 +105,7 @@ addressbook_is_ready() gboolean addressbook_is_active() { - return books_active(); + return books_active(); } /** @@ -116,31 +116,32 @@ static void addressbook_config_books() { - gchar **config_book_uid; - book_data_t *book_data; - gchar **list; + gchar **config_book_uid; + book_data_t *book_data; + gchar **list; + + // Retrieve list of books + list = (gchar **) dbus_get_addressbook_list(); - // Retrieve list of books - list = (gchar **) dbus_get_addressbook_list(); + if (list) { - if (list) { + for (config_book_uid = list; *config_book_uid; config_book_uid++) { - for (config_book_uid = list; *config_book_uid; config_book_uid++) { - - // Get corresponding book data - book_data = books_get_book_data_by_uid(*config_book_uid); + // Get corresponding book data + book_data = books_get_book_data_by_uid (*config_book_uid); + + // If book_data exists + if (book_data) + book_data->active = TRUE; + else + ERROR ("Addressbook: Error: Could not open book"); + } - // If book_data exists - if (book_data) - book_data->active = TRUE; - else - ERROR("Addressbook: Error: Could not open book"); + g_strfreev (list); } - g_strfreev(list); - } - // Update buttons - update_actions (); + // Update buttons + update_actions (); } /** @@ -149,10 +150,10 @@ addressbook_config_books() GSList * addressbook_get_books_data() { - DEBUG("Addressboook: Get books data"); + DEBUG ("Addressboook: Get books data"); - addressbook_config_books(); - return books_data; + addressbook_config_books(); + return books_data; } /** @@ -162,71 +163,75 @@ addressbook_get_books_data() void addressbook_init() { - DEBUG("Addressbook: Initialize addressbook"); - - // Call books initialization - init(&addressbook_config_books); + DEBUG ("Addressbook: Initialize addressbook"); + + // Call books initialization + init (&addressbook_config_books); } /** * Callback called after all book have been processed */ static void -handler_async_search(GList *hits, gpointer user_data) +handler_async_search (GList *hits, gpointer user_data) { - GList *i; - GdkPixbuf *photo = NULL; - AddressBook_Config *addressbook_config; - callable_obj_t *j; - - DEBUG("Addressbook: callback async search"); - - // freeing calls - while ((j = (callable_obj_t *) g_queue_pop_tail(contacts->callQueue)) != NULL) { - free_callable_obj_t(j); - } - - // Retrieve the address book parameters - addressbook_config = (AddressBook_Config*) user_data; - - // reset previous results - calltree_reset(contacts); - calllist_reset(contacts); - - for (i = hits; i != NULL; i = i->next) - { - DEBUG("while"); - - Hit *entry; - entry = i->data; - if (entry) - { - // Get the photo - if (addressbook_display(addressbook_config, - ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) - photo = entry->photo; - // Create entry for business phone information - if (addressbook_display(addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) - calllist_add_contact(entry->name, entry->phone_business, - CONTACT_PHONE_BUSINESS, photo); - // Create entry for home phone information - if (addressbook_display(addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_HOME)) - calllist_add_contact(entry->name, entry->phone_home, - CONTACT_PHONE_HOME, photo); - // Create entry for mobile phone information - if (addressbook_display(addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) - calllist_add_contact(entry->name, entry->phone_mobile, - CONTACT_PHONE_MOBILE, photo); + GList *i; + GdkPixbuf *photo = NULL; + AddressBook_Config *addressbook_config; + callable_obj_t *j; + + DEBUG ("Addressbook: callback async search"); + + // freeing calls + while ( (j = (callable_obj_t *) g_queue_pop_tail (contacts->callQueue)) != NULL) { + free_callable_obj_t (j); + } + + // Retrieve the address book parameters + addressbook_config = (AddressBook_Config*) user_data; + + // reset previous results + calltree_reset (contacts); + calllist_reset (contacts); + + for (i = hits; i != NULL; i = i->next) { + DEBUG ("while"); + + Hit *entry; + entry = i->data; + + if (entry) { + // Get the photo + if (addressbook_display (addressbook_config, + ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) + photo = entry->photo; + + // Create entry for business phone information + if (addressbook_display (addressbook_config, + ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) + calllist_add_contact (entry->name, entry->phone_business, + CONTACT_PHONE_BUSINESS, photo); + + // Create entry for home phone information + if (addressbook_display (addressbook_config, + ADDRESSBOOK_DISPLAY_PHONE_HOME)) + calllist_add_contact (entry->name, entry->phone_home, + CONTACT_PHONE_HOME, photo); + + // Create entry for mobile phone information + if (addressbook_display (addressbook_config, + ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) + calllist_add_contact (entry->name, entry->phone_mobile, + CONTACT_PHONE_MOBILE, photo); } - free_hit(entry); + + free_hit (entry); } - g_list_free(hits); - // Deactivate waiting image - deactivateWaitingLayer(); + g_list_free (hits); + + // Deactivate waiting image + deactivateWaitingLayer(); } diff --git a/sflphone-client-gnome/src/contacts/addressbook.h b/sflphone-client-gnome/src/contacts/addressbook.h index f87f9dba19ec292e18783d5abf57650e4bf12aa3..cc2760f035e558b431c234dacb434cfcfc8936ed 100644 --- a/sflphone-client-gnome/src/contacts/addressbook.h +++ b/sflphone-client-gnome/src/contacts/addressbook.h @@ -63,7 +63,7 @@ addressbook_is_active(); * Perform a search in addressbook */ void -addressbook_search(GtkEntry*); +addressbook_search (GtkEntry*); /** * Initialize addressbook diff --git a/sflphone-client-gnome/src/contacts/addressbook/eds.c b/sflphone-client-gnome/src/contacts/addressbook/eds.c index 12ef48757ddebca450f25128d003c0d2ebfbb5ac..9d433d173ff052963f0d938e2d13a67e80337193 100644 --- a/sflphone-client-gnome/src/contacts/addressbook/eds.c +++ b/sflphone-client-gnome/src/contacts/addressbook/eds.c @@ -45,22 +45,20 @@ /** * Structure used to store search callback and data */ -typedef struct _Search_Handler_And_Data -{ - int search_id; - SearchAsyncHandler handler; - gpointer user_data; - GList *hits; - int max_results_remaining; - int book_views_remaining; +typedef struct _Search_Handler_And_Data { + int search_id; + SearchAsyncHandler handler; + gpointer user_data; + GList *hits; + int max_results_remaining; + int book_views_remaining; } Search_Handler_And_Data; /** * Structure used to store open callback and data */ -typedef struct _Open_Handler_And_Data -{ - OpenAsyncHandler handler; +typedef struct _Open_Handler_And_Data { + OpenAsyncHandler handler; } Open_Handler_And_Data; /** @@ -76,8 +74,7 @@ int remaining_books_to_open; /** * Fields on which search will be performed */ -static EContactField search_fields[] = - { E_CONTACT_FULL_NAME, E_CONTACT_PHONE_BUSINESS, E_CONTACT_NICKNAME, 0 }; +static EContactField search_fields[] = { E_CONTACT_FULL_NAME, E_CONTACT_PHONE_BUSINESS, E_CONTACT_NICKNAME, 0 }; static int n_search_fields = G_N_ELEMENTS (search_fields) - 1; @@ -85,13 +82,13 @@ static int n_search_fields = G_N_ELEMENTS (search_fields) - 1; * Freeing a hit instance */ void -free_hit(Hit *h) +free_hit (Hit *h) { - g_free(h->name); - g_free(h->phone_business); - g_free(h->phone_home); - g_free(h->phone_mobile); - g_free(h); + g_free (h->name); + g_free (h->phone_business); + g_free (h->phone_home); + g_free (h->phone_mobile); + g_free (h); } /** @@ -100,7 +97,7 @@ free_hit(Hit *h) gboolean books_ready() { - return (g_slist_length(books_data) > 0); + return (g_slist_length (books_data) > 0); } /** @@ -109,288 +106,286 @@ books_ready() gboolean books_active() { - GSList *book_list_iterator; - book_data_t *book_data; - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) - { - book_data = (book_data_t *) book_list_iterator->data; - if (book_data->active) - return TRUE; + GSList *book_list_iterator; + book_data_t *book_data; + + // Iterate throw the list + for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator + = book_list_iterator->next) { + book_data = (book_data_t *) book_list_iterator->data; + + if (book_data->active) + return TRUE; } - // If no result - return FALSE; + + // If no result + return FALSE; } /** * Get a specific book data by UID */ book_data_t * -books_get_book_data_by_uid(gchar *uid) +books_get_book_data_by_uid (gchar *uid) { - GSList *book_list_iterator; - book_data_t *book_data; - - DEBUG("Addressbook: Get book data by uid: %s", uid); - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) - { - book_data = (book_data_t *) book_list_iterator->data; - if (strcmp(book_data->uid, uid) == 0) { - DEBUG("Addressbook: Book %s found", uid); - return book_data; - } + GSList *book_list_iterator; + book_data_t *book_data; + + DEBUG ("Addressbook: Get book data by uid: %s", uid); + + // Iterate throw the list + for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator + = book_list_iterator->next) { + book_data = (book_data_t *) book_list_iterator->data; + + if (strcmp (book_data->uid, uid) == 0) { + DEBUG ("Addressbook: Book %s found", uid); + return book_data; + } } - DEBUG("Addressbook: Could not found Book %s", uid); - // If no result - return NULL; + DEBUG ("Addressbook: Could not found Book %s", uid); + // If no result + return NULL; } /** * Split a string of tokens separated by whitespace into an array of tokens. */ static GArray * -split_query_string(const gchar *str) +split_query_string (const gchar *str) { - GArray *parts = g_array_sized_new(FALSE, FALSE, sizeof (char *), 2); - PangoLogAttr *attrs; - guint str_len = strlen (str), word_start = 0, i; - - attrs = g_new0 (PangoLogAttr, str_len + 1); - /* TODO: do we need to specify a particular language or is NULL ok? */ - pango_get_log_attrs (str, -1, -1, NULL, attrs, str_len + 1); - - for (i = 0; i < str_len + 1; i++) - { - char *start_word, *end_word, *word; - if (attrs[i].is_word_end) - { - start_word = g_utf8_offset_to_pointer (str, word_start); - end_word = g_utf8_offset_to_pointer (str, i); - word = g_strndup (start_word, end_word - start_word); - g_array_append_val (parts, word); + GArray *parts = g_array_sized_new (FALSE, FALSE, sizeof (char *), 2); + PangoLogAttr *attrs; + guint str_len = strlen (str), word_start = 0, i; + + attrs = g_new0 (PangoLogAttr, str_len + 1); + /* TODO: do we need to specify a particular language or is NULL ok? */ + pango_get_log_attrs (str, -1, -1, NULL, attrs, str_len + 1); + + for (i = 0; i < str_len + 1; i++) { + char *start_word, *end_word, *word; + + if (attrs[i].is_word_end) { + start_word = g_utf8_offset_to_pointer (str, word_start); + end_word = g_utf8_offset_to_pointer (str, i); + word = g_strndup (start_word, end_word - start_word); + g_array_append_val (parts, word); } - if (attrs[i].is_word_start) - { - word_start = i; + + if (attrs[i].is_word_start) { + word_start = i; } } - g_free (attrs); - return parts; + + g_free (attrs); + return parts; } - /** - * Create a query which looks for the specified string in a contact's full name, email addresses and - * nick name. - */ +/** + * Create a query which looks for the specified string in a contact's full name, email addresses and + * nick name. + */ static EBookQuery* -create_query(const char* s) +create_query (const char* s) { - EBookQuery *query; - GArray *parts = split_query_string(s); - EBookQuery ***field_queries; - EBookQuery **q; - EBookQuery **phone; - guint j; - int i; - - q = g_new0 (EBookQuery *, n_search_fields); - field_queries = g_new0 (EBookQuery **, n_search_fields); - - for (i = 0; i < n_search_fields; i++) - { - field_queries[i] = g_new0 (EBookQuery *, parts->len); - for (j = 0; j < parts->len; j++) - { - field_queries[i][j] = e_book_query_field_test(search_fields[i], - E_BOOK_QUERY_CONTAINS, g_array_index (parts, gchar *, j)); + EBookQuery *query; + GArray *parts = split_query_string (s); + EBookQuery ***field_queries; + EBookQuery **q; + EBookQuery **phone; + guint j; + int i; + + q = g_new0 (EBookQuery *, n_search_fields); + field_queries = g_new0 (EBookQuery **, n_search_fields); + + for (i = 0; i < n_search_fields; i++) { + field_queries[i] = g_new0 (EBookQuery *, parts->len); + + for (j = 0; j < parts->len; j++) { + field_queries[i][j] = e_book_query_field_test (search_fields[i], + E_BOOK_QUERY_CONTAINS, g_array_index (parts, gchar *, j)); } - q[i] = e_book_query_and(parts->len, field_queries[i], TRUE); + + q[i] = e_book_query_and (parts->len, field_queries[i], TRUE); } - g_array_free(parts, TRUE); - phone = g_new0 (EBookQuery *, 3); - phone[0] = e_book_query_field_exists(E_CONTACT_PHONE_BUSINESS); - phone[1] = e_book_query_field_exists(E_CONTACT_PHONE_HOME); - phone[2] = e_book_query_field_exists(E_CONTACT_PHONE_MOBILE); + g_array_free (parts, TRUE); + + phone = g_new0 (EBookQuery *, 3); + phone[0] = e_book_query_field_exists (E_CONTACT_PHONE_BUSINESS); + phone[1] = e_book_query_field_exists (E_CONTACT_PHONE_HOME); + phone[2] = e_book_query_field_exists (E_CONTACT_PHONE_MOBILE); - query = e_book_query_andv(e_book_query_or(n_search_fields, q, FALSE), - e_book_query_or(3, phone, FALSE), NULL); + query = e_book_query_andv (e_book_query_or (n_search_fields, q, FALSE), + e_book_query_or (3, phone, FALSE), NULL); - for (i = 0; i < n_search_fields; i++) - { - g_free(field_queries[i]); + for (i = 0; i < n_search_fields; i++) { + g_free (field_queries[i]); } - g_free(field_queries); - g_free(q); - g_free(phone); - return query; + g_free (field_queries); + g_free (q); + g_free (phone); + + return query; } /** * Retrieve the contact's picture */ static GdkPixbuf* -pixbuf_from_contact(EContact *contact) +pixbuf_from_contact (EContact *contact) { - GdkPixbuf *pixbuf = NULL; - EContactPhoto *photo = e_contact_get(contact, E_CONTACT_PHOTO); - if (photo) - { - GdkPixbufLoader *loader; + GdkPixbuf *pixbuf = NULL; + EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO); + + if (photo) { + GdkPixbufLoader *loader; - loader = gdk_pixbuf_loader_new(); + loader = gdk_pixbuf_loader_new(); - if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) - { - if (gdk_pixbuf_loader_write(loader, - (guchar *) photo->data.inlined.data, photo->data.inlined.length, - NULL)) - pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); + if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { + if (gdk_pixbuf_loader_write (loader, + (guchar *) photo->data.inlined.data, photo->data.inlined.length, + NULL)) + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); } - // If pixbuf has been found, check size and resize if needed - if (pixbuf) - { - GdkPixbuf *tmp; - gint width = gdk_pixbuf_get_width(pixbuf); - gint height = gdk_pixbuf_get_height(pixbuf); - double scale = 1.0; - - if (height > width) - { - scale = pixbuf_size / (double) height; - } - else - { - scale = pixbuf_size / (double) width; + // If pixbuf has been found, check size and resize if needed + if (pixbuf) { + GdkPixbuf *tmp; + gint width = gdk_pixbuf_get_width (pixbuf); + gint height = gdk_pixbuf_get_height (pixbuf); + double scale = 1.0; + + if (height > width) { + scale = pixbuf_size / (double) height; + } else { + scale = pixbuf_size / (double) width; } - if (scale < 1.0) - { - tmp = gdk_pixbuf_scale_simple(pixbuf, width * scale, height - * scale, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - pixbuf = tmp; + if (scale < 1.0) { + tmp = gdk_pixbuf_scale_simple (pixbuf, width * scale, height + * scale, GDK_INTERP_BILINEAR); + g_object_unref (pixbuf); + pixbuf = tmp; } } - e_contact_photo_free(photo); + + e_contact_photo_free (photo); } - return pixbuf; + + return pixbuf; } /** * Callback for asynchronous open of books */ static void -eds_async_open_callback(EBook *book, EBookStatus status, gpointer closure) +eds_async_open_callback (EBook *book, EBookStatus status, gpointer closure) { - DEBUG("Addressbook: Open book callback"); + DEBUG ("Addressbook: Open book callback"); Open_Handler_And_Data *had = (Open_Handler_And_Data *) closure; remaining_books_to_open--; - DEBUG("Addressbook: Remaining book to open: %i", remaining_books_to_open); + DEBUG ("Addressbook: Remaining book to open: %i", remaining_books_to_open); if (status == E_BOOK_ERROR_OK) { - book_data_t *book_data = g_new(book_data_t, 1); - book_data->active = TRUE; - book_data->name = g_strdup(e_source_peek_name(e_book_get_source(book))); - book_data->uid = g_strdup(e_source_peek_uid(e_book_get_source(book))); - DEBUG("Addressbook: Name: %s", book_data->name); - DEBUG("Addressbook: Uid: %s", book_data->uid); - book_data->ebook = book; - books_data = g_slist_prepend(books_data, book_data); - had->handler(); - - // if(remaining_books_to_open == 0) { - if(!e_book_is_opened(book_data->ebook)) { - // We must open the addressbook - e_book_open (book_data->ebook, FALSE, NULL); - } + book_data_t *book_data = g_new (book_data_t, 1); + book_data->active = TRUE; + book_data->name = g_strdup (e_source_peek_name (e_book_get_source (book))); + book_data->uid = g_strdup (e_source_peek_uid (e_book_get_source (book))); + DEBUG ("Addressbook: Name: %s", book_data->name); + DEBUG ("Addressbook: Uid: %s", book_data->uid); + book_data->ebook = book; + books_data = g_slist_prepend (books_data, book_data); + had->handler(); + + // if(remaining_books_to_open == 0) { + if (!e_book_is_opened (book_data->ebook)) { + // We must open the addressbook + e_book_open (book_data->ebook, FALSE, NULL); + } - } - else { - WARN("Addressbook: Got error when opening book"); - gchar *state_string; - switch ( status ){ - case E_BOOK_ERROR_INVALID_ARG : - state_string = g_strdup("E_BOOK_ERROR_INVALID_ARG"); - break; - case E_BOOK_ERROR_BUSY : - state_string = g_strdup("E_BOOK_ERROR_BUSY"); - break; - case E_BOOK_ERROR_REPOSITORY_OFFLINE : - state_string = g_strdup("E_BOOK_ERROR_REPOSITORY_OFFLINE"); - break; - case E_BOOK_ERROR_NO_SUCH_BOOK : - state_string = g_strdup("E_BOOK_ERROR_NO_SUCH_BOOK"); - break; - case E_BOOK_ERROR_NO_SELF_CONTACT : - state_string = g_strdup("E_BOOK_ERROR_NO_SELF_CONTACT"); - break; - case E_BOOK_ERROR_SOURCE_NOT_LOADED: - state_string = g_strdup("E_BOOK_ERROR_SOURCE_NOT_LOADED"); - break; - case E_BOOK_ERROR_SOURCE_ALREADY_LOADED : - state_string = g_strdup("E_BOOK_ERROR_SOURCE_ALREADY_LOADED"); - break; - case E_BOOK_ERROR_PERMISSION_DENIED : - state_string = g_strdup("E_BOOK_ERROR_PERMISSION_DENIED"); - break; - case E_BOOK_ERROR_CONTACT_NOT_FOUND : - state_string = g_strdup("E_BOOK_ERROR_CONTACT_NOT_FOUND"); - break; - case E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS : - state_string = g_strdup("E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS"); - break; - case E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED : - state_string = g_strdup("E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED"); - break; - case E_BOOK_ERROR_CANCELLED : - state_string = g_strdup("E_BOOK_ERROR_CANCELLED"); - break; - case E_BOOK_ERROR_COULD_NOT_CANCEL : - state_string = g_strdup("E_BOOK_ERROR_COULD_NOT_CANCEL"); - break; - case E_BOOK_ERROR_AUTHENTICATION_FAILED : - state_string = g_strdup("E_BOOK_ERROR_AUTHENTICATION_FAILED"); - break; - case E_BOOK_ERROR_AUTHENTICATION_REQUIRED : - state_string = g_strdup("E_BOOK_ERROR_AUTHENTICATION_REQUIRED"); - break; - case E_BOOK_ERROR_TLS_NOT_AVAILABLE : - state_string = g_strdup("E_BOOK_ERROR_TLS_NOT_AVAILABLE"); - break; - case E_BOOK_ERROR_CORBA_EXCEPTION : - state_string = g_strdup("E_BOOK_ERROR_CORBA_EXCEPTION"); - break; - case E_BOOK_ERROR_NO_SUCH_SOURCE : - state_string = g_strdup("E_BOOK_ERROR_NO_SUCH_SOURCE"); - break; - case E_BOOK_ERROR_OFFLINE_UNAVAILABLE : - state_string = g_strdup("E_BOOK_ERROR_OFFLINE_UNAVAILABLE"); - break; - case E_BOOK_ERROR_OTHER_ERROR : - state_string = g_strdup("E_BOOK_ERROR_OTHER_ERROR"); - break; - case E_BOOK_ERROR_INVALID_SERVER_VERSION : - state_string = g_strdup("E_BOOK_ERROR_INVALID_SERVER_VERSION"); - break; - default: - break; - - } - - ERROR("%s", state_string); - - g_free(state_string); + } else { + WARN ("Addressbook: Got error when opening book"); + gchar *state_string = NULL; + + switch (status) { + case E_BOOK_ERROR_INVALID_ARG : + state_string = g_strdup ("E_BOOK_ERROR_INVALID_ARG"); + break; + case E_BOOK_ERROR_BUSY : + state_string = g_strdup ("E_BOOK_ERROR_BUSY"); + break; + case E_BOOK_ERROR_REPOSITORY_OFFLINE : + state_string = g_strdup ("E_BOOK_ERROR_REPOSITORY_OFFLINE"); + break; + case E_BOOK_ERROR_NO_SUCH_BOOK : + state_string = g_strdup ("E_BOOK_ERROR_NO_SUCH_BOOK"); + break; + case E_BOOK_ERROR_NO_SELF_CONTACT : + state_string = g_strdup ("E_BOOK_ERROR_NO_SELF_CONTACT"); + break; + case E_BOOK_ERROR_SOURCE_NOT_LOADED: + state_string = g_strdup ("E_BOOK_ERROR_SOURCE_NOT_LOADED"); + break; + case E_BOOK_ERROR_SOURCE_ALREADY_LOADED : + state_string = g_strdup ("E_BOOK_ERROR_SOURCE_ALREADY_LOADED"); + break; + case E_BOOK_ERROR_PERMISSION_DENIED : + state_string = g_strdup ("E_BOOK_ERROR_PERMISSION_DENIED"); + break; + case E_BOOK_ERROR_CONTACT_NOT_FOUND : + state_string = g_strdup ("E_BOOK_ERROR_CONTACT_NOT_FOUND"); + break; + case E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS : + state_string = g_strdup ("E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS"); + break; + case E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED : + state_string = g_strdup ("E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED"); + break; + case E_BOOK_ERROR_CANCELLED : + state_string = g_strdup ("E_BOOK_ERROR_CANCELLED"); + break; + case E_BOOK_ERROR_COULD_NOT_CANCEL : + state_string = g_strdup ("E_BOOK_ERROR_COULD_NOT_CANCEL"); + break; + case E_BOOK_ERROR_AUTHENTICATION_FAILED : + state_string = g_strdup ("E_BOOK_ERROR_AUTHENTICATION_FAILED"); + break; + case E_BOOK_ERROR_AUTHENTICATION_REQUIRED : + state_string = g_strdup ("E_BOOK_ERROR_AUTHENTICATION_REQUIRED"); + break; + case E_BOOK_ERROR_TLS_NOT_AVAILABLE : + state_string = g_strdup ("E_BOOK_ERROR_TLS_NOT_AVAILABLE"); + break; + case E_BOOK_ERROR_CORBA_EXCEPTION : + state_string = g_strdup ("E_BOOK_ERROR_CORBA_EXCEPTION"); + break; + case E_BOOK_ERROR_NO_SUCH_SOURCE : + state_string = g_strdup ("E_BOOK_ERROR_NO_SUCH_SOURCE"); + break; + case E_BOOK_ERROR_OFFLINE_UNAVAILABLE : + state_string = g_strdup ("E_BOOK_ERROR_OFFLINE_UNAVAILABLE"); + break; + case E_BOOK_ERROR_OTHER_ERROR : + state_string = g_strdup ("E_BOOK_ERROR_OTHER_ERROR"); + break; + case E_BOOK_ERROR_INVALID_SERVER_VERSION : + state_string = g_strdup ("E_BOOK_ERROR_INVALID_SERVER_VERSION"); + break; + default: + break; + + } + + ERROR ("%s", state_string); + + g_free (state_string); } } @@ -399,108 +394,109 @@ eds_async_open_callback(EBook *book, EBookStatus status, gpointer closure) * Initialize address book */ void -init(OpenAsyncHandler callback) +init (OpenAsyncHandler callback) { - GSList *list, *l; - ESourceList *source_list = NULL; - remaining_books_to_open = 0; - books_data = NULL; - - source_list = e_source_list_new_for_gconf_default("/apps/evolution/addressbook/sources"); - - if (source_list == NULL) - { - ERROR("Addressbook: Error could not initialize source list for addressbook"); - return; + GSList *list, *l; + ESourceList *source_list = NULL; + remaining_books_to_open = 0; + books_data = NULL; + + source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); + + if (source_list == NULL) { + ERROR ("Addressbook: Error could not initialize source list for addressbook"); + return; } - list = e_source_list_peek_groups(source_list); + list = e_source_list_peek_groups (source_list); + + if (!list) { + WARN ("Addressbook: Address Book source groups are missing! Check your GConf setup."); + return; + } - if (!list) { - WARN("Addressbook: Address Book source groups are missing! Check your GConf setup."); - return; - } + Open_Handler_And_Data *had = g_new (Open_Handler_And_Data, 1); + had->handler = callback; - Open_Handler_And_Data *had = g_new (Open_Handler_And_Data, 1); - had->handler = callback; + for (l = list; l != NULL; l = l->next) { - for (l = list; l != NULL; l = l->next) { + ESourceGroup *group = l->data; + GSList *sources = NULL, *m; - ESourceGroup *group = l->data; - GSList *sources = NULL, *m; + DEBUG ("Addressbook: Source group name %s", e_source_group_peek_name (group)); + DEBUG ("Addressbook: Source group uid %s", e_source_group_peek_uid (group)); - DEBUG("Addressbook: Source group name %s", e_source_group_peek_name(group)); - DEBUG("Addressbook: Source group uid %s", e_source_group_peek_uid(group)); + sources = e_source_group_peek_sources (group); - sources = e_source_group_peek_sources(group); - for (m = sources; m != NULL; m = m->next) { + for (m = sources; m != NULL; m = m->next) { - ESource *source = m->data; - const gchar *property; + ESource *source = m->data; - DEBUG("Addressbook: Source name %s", e_source_peek_name(source)); - DEBUG("Addressbook: Source uid %s", e_source_peek_uid(source)); - // DEBUG("Addressbook: Source properties %s", e_source_get_property(source, property)); + DEBUG ("Addressbook: Source name %s", e_source_peek_name (source)); + DEBUG ("Addressbook: Source uid %s", e_source_peek_uid (source)); + // DEBUG("Addressbook: Source properties %s", e_source_get_property(source, property)); - EBook *book = e_book_new(source, NULL); - if (book) { - DEBUG("Addressbook: Created empty book successfully"); + EBook *book = e_book_new (source, NULL); - // e_book_get_uri(book); - // Keep count of remaining books to open - remaining_books_to_open++; - - // Add Notification callback - // g_signal_connect (book, "contacts_added", (GCallback) view_contacts_added_cb, had); + if (book) { + DEBUG ("Addressbook: Created empty book successfully"); - // Asynchronous open - e_book_async_open(book, TRUE, eds_async_open_callback, had); - } - else - ERROR("Addressbook: Error: Could not create empty book"); + // e_book_get_uri(book); + // Keep count of remaining books to open + remaining_books_to_open++; + + // Add Notification callback + // g_signal_connect (book, "contacts_added", (GCallback) view_contacts_added_cb, had); + + // Asynchronous open + e_book_async_open (book, TRUE, eds_async_open_callback, had); + } else + ERROR ("Addressbook: Error: Could not create empty book"); + } } - } - current_search_id = 0; - g_object_unref(source_list); + current_search_id = 0; + + g_object_unref (source_list); } /** * Final callback after all books have been processed. */ static void -view_finish(EBookView *book_view, Search_Handler_And_Data *had) { - - GList *i; - SearchAsyncHandler had_handler = had->handler; - GList *had_hits = had->hits; - gpointer had_user_data = had->user_data; - int search_id = had->search_id; - g_free(had); - - DEBUG("Addressbook: View finish"); - - if (book_view != NULL) - g_object_unref(book_view); - - if (search_id == current_search_id) { - - // Reinitialize search id to prevent overflow - if (current_search_id > 5000) - current_search_id = 0; - - // Call display callback - had_handler(had_hits, had_user_data); - } - else { - // Some hits could have been processed but will not be used - for (i = had_hits; i != NULL; i = i->next) { - Hit *entry; - entry = i->data; - free_hit(entry); +view_finish (EBookView *book_view, Search_Handler_And_Data *had) +{ + + GList *i; + SearchAsyncHandler had_handler = had->handler; + GList *had_hits = had->hits; + gpointer had_user_data = had->user_data; + int search_id = had->search_id; + g_free (had); + + DEBUG ("Addressbook: View finish"); + + if (book_view != NULL) + g_object_unref (book_view); + + if (search_id == current_search_id) { + + // Reinitialize search id to prevent overflow + if (current_search_id > 5000) + current_search_id = 0; + + // Call display callback + had_handler (had_hits, had_user_data); + } else { + // Some hits could have been processed but will not be used + for (i = had_hits; i != NULL; i = i->next) { + Hit *entry; + entry = i->data; + free_hit (entry); + } + + g_list_free (had_hits); } - g_list_free(had_hits); - } } /** @@ -508,81 +504,78 @@ view_finish(EBookView *book_view, Search_Handler_And_Data *had) { * Used to store book search results. */ static void -view_contacts_added_cb(EBookView *book_view, GList *contacts, - gpointer user_data) +view_contacts_added_cb (EBookView *book_view, GList *contacts, + gpointer user_data) { - GdkPixbuf *photo; + GdkPixbuf *photo; - Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; + Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; - DEBUG("Addressbook: Vew contact added callback"); + DEBUG ("Addressbook: Vew contact added callback"); - // If it's not the last search launched, stop it - if (had->search_id != current_search_id) - { - e_book_view_stop(book_view); - return; + // If it's not the last search launched, stop it + if (had->search_id != current_search_id) { + e_book_view_stop (book_view); + return; } - // If we reached max results - if (had->max_results_remaining <= 0) - { - e_book_view_stop(book_view); - had->book_views_remaining--; - - // All books have been computed - if (had->book_views_remaining == 0) - { - view_finish(book_view, had); - return; + // If we reached max results + if (had->max_results_remaining <= 0) { + e_book_view_stop (book_view); + had->book_views_remaining--; + + // All books have been computed + if (had->book_views_remaining == 0) { + view_finish (book_view, had); + return; } } - // For each contact - for (; contacts != NULL; contacts = g_list_next (contacts)) - { - EContact *contact; - Hit *hit; - gchar *number; - - contact = E_CONTACT (contacts->data); - hit = g_new (Hit, 1); - - // Get the photo contact - photo = pixbuf_from_contact(contact); - hit->photo = photo; - - // Get business phone information - fetch_information_from_contact(contact, E_CONTACT_PHONE_BUSINESS, &number); - hit->phone_business = g_strdup(number); - - // Get home phone information - fetch_information_from_contact(contact, E_CONTACT_PHONE_HOME, &number); - hit->phone_home = g_strdup(number); - - // Get mobile phone information - fetch_information_from_contact(contact, E_CONTACT_PHONE_MOBILE, &number); - hit->phone_mobile = g_strdup(number); - - hit->name = g_strdup((char*) e_contact_get_const(contact, - E_CONTACT_NAME_OR_ORG)); - if (!hit->name) - hit->name = ""; - - // Append list of contacts - had->hits = g_list_append(had->hits, hit); - had->max_results_remaining--; - - // If we reached max results - if (had->max_results_remaining <= 0) - { - e_book_view_stop(book_view); - had->book_views_remaining--; - if (had->book_views_remaining == 0) - { - view_finish(book_view, had); + // For each contact + for (; contacts != NULL; contacts = g_list_next (contacts)) { + EContact *contact; + Hit *hit; + gchar *number; + + contact = E_CONTACT (contacts->data); + hit = g_new (Hit, 1); + + // Get the photo contact + photo = pixbuf_from_contact (contact); + hit->photo = photo; + + // Get business phone information + fetch_information_from_contact (contact, E_CONTACT_PHONE_BUSINESS, &number); + hit->phone_business = g_strdup (number); + + // Get home phone information + fetch_information_from_contact (contact, E_CONTACT_PHONE_HOME, &number); + hit->phone_home = g_strdup (number); + + // Get mobile phone information + fetch_information_from_contact (contact, E_CONTACT_PHONE_MOBILE, &number); + hit->phone_mobile = g_strdup (number); + + hit->name = g_strdup ( (char*) e_contact_get_const (contact, + E_CONTACT_NAME_OR_ORG)); + + if (!hit->name) + hit->name = ""; + + // Append list of contacts + had->hits = g_list_append (had->hits, hit); + had->max_results_remaining--; + + // If we reached max results + if (had->max_results_remaining <= 0) { + e_book_view_stop (book_view); + had->book_views_remaining--; + + if (had->book_views_remaining == 0) { + view_finish (book_view, had); } - break; + + break; } } } @@ -593,80 +586,83 @@ view_contacts_added_cb(EBookView *book_view, GList *contacts, * Used to call final callback when all books have been read. */ static void -view_completed_cb(EBookView *book_view, EBookViewStatus status UNUSED, -gpointer user_data) +view_completed_cb (EBookView *book_view, EBookViewStatus status UNUSED, + gpointer user_data) { - DEBUG("Addressbook: View completed callback"); + DEBUG ("Addressbook: View completed callback"); - Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; - had->book_views_remaining--; + Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; + had->book_views_remaining--; - // All books have been prcessed - if (had->book_views_remaining == 0) { - // Call finish function - view_finish(book_view, had); - } + // All books have been prcessed + if (had->book_views_remaining == 0) { + // Call finish function + view_finish (book_view, had); + } } /** * Callback called after a contact have been found in EDS by search_async_by_contacts. */ static void -eds_query_result_cb(EBook *book, EBookStatus status, GList *contacts, gpointer user_data) { +eds_query_result_cb (EBook *book UNUSED, EBookStatus status, GList *contacts, gpointer user_data) +{ + + DEBUG ("Addressbook: Search Result callback callled"); - DEBUG("Addressbook: Search Result callback callled"); + if (!contacts) { + DEBUG ("Addressbook: Error: Contact is NULL"); + return; + } - if(!contacts) { - DEBUG("Addressbook: Error: Contact is NULL"); - return; - } + GList *l; - GList *l; + if (status == E_BOOK_ERROR_OK) { - if (status == E_BOOK_ERROR_OK) { + gchar *number; - GdkPixbuf *photo; - gchar *number; + Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; - Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; + l = contacts; - l = contacts; - while(l) { + while (l) { - Hit *hit = g_new(Hit, 1); + Hit *hit = g_new (Hit, 1); - // Get the photo contact - hit->photo = pixbuf_from_contact(E_CONTACT(l->data)); + // Get the photo contact + hit->photo = pixbuf_from_contact (E_CONTACT (l->data)); - // Get business phone information - fetch_information_from_contact(E_CONTACT(l->data), E_CONTACT_PHONE_BUSINESS, &number); - hit->phone_business = g_strdup(number); - - // Get home phone information - fetch_information_from_contact(E_CONTACT(l->data), E_CONTACT_PHONE_HOME, &number); - hit->phone_home = g_strdup(number); + // Get business phone information + fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_BUSINESS, &number); + hit->phone_business = g_strdup (number); - // Get mobile phone information - fetch_information_from_contact(E_CONTACT(l->data), E_CONTACT_PHONE_MOBILE, &number); - hit->phone_mobile = g_strdup(number); + // Get home phone information + fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_HOME, &number); + hit->phone_home = g_strdup (number); - hit->name = g_strdup((char *) e_contact_get_const(E_CONTACT(l->data), E_CONTACT_NAME_OR_ORG)); - if (!hit->name) - hit->name = ""; + // Get mobile phone information + fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_MOBILE, &number); + hit->phone_mobile = g_strdup (number); - DEBUG("Addressbook: Contact Found"); - DEBUG("Addressbook: Full Name %s", hit->name); - DEBUG("Addressbook: Phone Home %s", hit->phone_home); - DEBUG("Addressbook: Phone Business %s", hit->phone_business); - DEBUG("Addressbook: Phone Mobile %s", hit->phone_mobile); + hit->name = g_strdup ( (char *) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_NAME_OR_ORG)); - had->hits = g_list_append(had->hits, hit); - had->max_results_remaining--; + if (!hit->name) + hit->name = ""; - l = g_list_next(l); + DEBUG ("Addressbook: Contact Found"); + DEBUG ("Addressbook: Full Name %s", hit->name); + DEBUG ("Addressbook: Phone Home %s", hit->phone_home); + DEBUG ("Addressbook: Phone Business %s", hit->phone_business); + DEBUG ("Addressbook: Phone Mobile %s", hit->phone_mobile); + + had->hits = g_list_append (had->hits, hit); + had->max_results_remaining--; + + l = g_list_next (l); + } + + view_finish (NULL, had); } - view_finish(NULL, had); - } } @@ -675,224 +671,223 @@ eds_query_result_cb(EBook *book, EBookStatus status, GList *contacts, gpointer u * Perform an asynchronous search */ void -search_async(const char *query, int max_results, SearchAsyncHandler handler, - gpointer user_data) +search_async (const char *query, int max_results, SearchAsyncHandler handler, + gpointer user_data) { - // Increment search id - current_search_id++; + // Increment search id + current_search_id++; - DEBUG("Addressbook: Search %d: %s, max_results %d", current_search_id, query, max_results); + DEBUG ("Addressbook: Search %d: %s, max_results %d", current_search_id, query, max_results); - // If query is null - if (strlen(query) < 1 || g_slist_length(books_data) == 0) { + // If query is null + if (strlen (query) < 1 || g_slist_length (books_data) == 0) { - DEBUG("Addressbook: Query is empty or no addressbook opened"); + DEBUG ("Addressbook: Query is empty or no addressbook opened"); - // If data displayed (from previous search), directly call callback - handler(NULL, user_data); + // If data displayed (from previous search), directly call callback + handler (NULL, user_data); - return; - } + return; + } - GSList *iter; - EBookQuery* book_query = create_query(query); - Search_Handler_And_Data *had = g_new (Search_Handler_And_Data, 1); - int search_count = 0; + GSList *iter; + EBookQuery* book_query = create_query (query); + Search_Handler_And_Data *had = g_new (Search_Handler_And_Data, 1); + int search_count = 0; - // Initialize search data - had->search_id = current_search_id; - had->handler = handler; - had->user_data = user_data; - had->hits = NULL; - had->max_results_remaining = max_results; - had->book_views_remaining = 0; + // Initialize search data + had->search_id = current_search_id; + had->handler = handler; + had->user_data = user_data; + had->hits = NULL; + had->max_results_remaining = max_results; + had->book_views_remaining = 0; - // Iterate throw books data - for (iter = books_data; iter != NULL; iter = iter->next) { + // Iterate throw books data + for (iter = books_data; iter != NULL; iter = iter->next) { - book_data_t *book_data = (book_data_t *) iter->data; + book_data_t *book_data = (book_data_t *) iter->data; - // If book is active - if (book_data->active) { + // If book is active + if (book_data->active) { - EBookView *book_view = NULL; - if(!e_book_get_book_view(book_data->ebook, book_query, NULL, max_results, &book_view, NULL)) - ERROR("Addressbook: Error: Could not create a new book view"); + EBookView *book_view = NULL; - // If book view exists - if (book_view != NULL) { + if (!e_book_get_book_view (book_data->ebook, book_query, NULL, max_results, &book_view, NULL)) + ERROR ("Addressbook: Error: Could not create a new book view"); - DEBUG("Addressbook: BookView create, performing search"); - // Perform search - had->book_views_remaining++; - g_signal_connect (book_view, "contacts_added", (GCallback) view_contacts_added_cb, had); - g_signal_connect (book_view, "sequence_complete", (GCallback) view_completed_cb, had); - e_book_view_start(book_view); - search_count++; - } - else { - ERROR("Addressbook: Book's view does'not exit, could not perform search"); - } - } - else - { - ERROR("Addressbook: Book data not activated"); + // If book view exists + if (book_view != NULL) { + + DEBUG ("Addressbook: BookView create, performing search"); + // Perform search + had->book_views_remaining++; + g_signal_connect (book_view, "contacts_added", (GCallback) view_contacts_added_cb, had); + g_signal_connect (book_view, "sequence_complete", (GCallback) view_completed_cb, had); + e_book_view_start (book_view); + search_count++; + } else { + ERROR ("Addressbook: Book's view does'not exit, could not perform search"); + } + } else { + ERROR ("Addressbook: Book data not activated"); + } } - } - - e_book_query_unref(book_query); - - // If no search has been executed (no book selected) - if (search_count == 0) { - DEBUG("Addressbook: Error no search performed"); - // Call last callback anyway - view_finish(NULL, had); - } - else - DEBUG("Addressbook: Search Count %d", search_count); + + e_book_query_unref (book_query); + + // If no search has been executed (no book selected) + if (search_count == 0) { + DEBUG ("Addressbook: Error no search performed"); + // Call last callback anyway + view_finish (NULL, had); + } else + DEBUG ("Addressbook: Search Count %d", search_count); } void -search_by_contacts(const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data) { - - EBookQuery *equery; - EBookQuery *queries[4]; - GList *l, *list, *iter; - GError *error; - - current_search_id++; - - DEBUG("Addressbook: Search %d by contact %s, max results %d", current_search_id, query, max_results); - - if(strlen(query) < 1 || g_slist_length(books_data) == 0) { - DEBUG("Addressbook: Query is empty or no addresssbook opened"); - handler(NULL, user_data); - return; - } - - Search_Handler_And_Data *had = g_new(Search_Handler_And_Data, 1); - - had->search_id = current_search_id; - had->handler = handler; - had->user_data = user_data; - had->hits = NULL; - had->max_results_remaining = max_results; - had->book_views_remaining = 0; - - // create the query - int cpt; - queries[cpt++] = e_book_query_field_test(E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_HOME, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_BUSINESS, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_MOBILE, E_BOOK_QUERY_CONTAINS, query); - - equery = e_book_query_or(cpt, queries, TRUE); - - // Iterate through all opened books - for(iter = books_data; iter != NULL; iter=iter->next){ - book_data_t *book_data = (book_data_t *)iter->data; - - if(book_data->active) { - if(e_book_get_contacts(book_data->ebook, equery, &list, NULL)) { - DEBUG("Addressbook: Queries sent successfully"); - l = list; - while(l) { - - DEBUG("Addressbook: Contact found"); - Hit *hit = g_new(Hit, 1); - hit->name = g_strdup((const gchar*)e_contact_get_const(E_CONTACT(l->data), E_CONTACT_FULL_NAME)); - hit->phone_home = g_strdup((const gchar*)e_contact_get_const(E_CONTACT(l->data), E_CONTACT_PHONE_HOME)); - hit->phone_business = g_strdup((const gchar*)e_contact_get_const(E_CONTACT(l->data), E_CONTACT_PHONE_BUSINESS)); - hit->phone_mobile = g_strdup((const gchar*)e_contact_get_const(E_CONTACT(l->data), E_CONTACT_PHONE_MOBILE)); - hit->photo = pixbuf_from_contact(E_CONTACT(l->data)); - - DEBUG("Addressbook: Contact Found"); - DEBUG("Addressbook: Full Name %s", hit->name); - DEBUG("Addressbook: Phone Home %s", hit->phone_home); - DEBUG("Addressbook: Phone Business %s", hit->phone_business); - DEBUG("Addressbook: Phone Mobile %s", hit->phone_mobile); - - had->hits = g_list_append(had->hits, hit); - had->max_results_remaining--; - - l = g_list_next(l); - } - } +search_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data) +{ + + EBookQuery *equery; + EBookQuery *queries[4]; + GList *l, *list, *iter; + + current_search_id++; + + DEBUG ("Addressbook: Search %d by contact %s, max results %d", current_search_id, query, max_results); + + if (strlen (query) < 1 || g_slist_length (books_data) == 0) { + DEBUG ("Addressbook: Query is empty or no addresssbook opened"); + handler (NULL, user_data); + return; + } + + Search_Handler_And_Data *had = g_new (Search_Handler_And_Data, 1); + + had->search_id = current_search_id; + had->handler = handler; + had->user_data = user_data; + had->hits = NULL; + had->max_results_remaining = max_results; + had->book_views_remaining = 0; + + // create the query + int cpt = 0; + queries[cpt++] = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_HOME, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_BUSINESS, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_MOBILE, E_BOOK_QUERY_CONTAINS, query); + + equery = e_book_query_or (cpt, queries, TRUE); + + // Iterate through all opened books + for (iter = (GList *) books_data; iter != NULL; iter=iter->next) { + book_data_t *book_data = (book_data_t *) iter->data; + + if (book_data->active) { + if (e_book_get_contacts (book_data->ebook, equery, &list, NULL)) { + DEBUG ("Addressbook: Queries sent successfully"); + l = list; + + while (l) { + + DEBUG ("Addressbook: Contact found"); + Hit *hit = g_new (Hit, 1); + hit->name = g_strdup ( (const gchar*) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_FULL_NAME)); + hit->phone_home = g_strdup ( (const gchar*) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_PHONE_HOME)); + hit->phone_business = g_strdup ( (const gchar*) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_PHONE_BUSINESS)); + hit->phone_mobile = g_strdup ( (const gchar*) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_PHONE_MOBILE)); + hit->photo = pixbuf_from_contact (E_CONTACT (l->data)); + + DEBUG ("Addressbook: Contact Found"); + DEBUG ("Addressbook: Full Name %s", hit->name); + DEBUG ("Addressbook: Phone Home %s", hit->phone_home); + DEBUG ("Addressbook: Phone Business %s", hit->phone_business); + DEBUG ("Addressbook: Phone Mobile %s", hit->phone_mobile); + + had->hits = g_list_append (had->hits, hit); + had->max_results_remaining--; + + l = g_list_next (l); + } + } + } } - } - view_finish(NULL, had); - // handler + + view_finish (NULL, had); + // handler } void -search_async_by_contacts(const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data) { - EBookQuery *equery; - EBookQuery *queries[4]; - GList *l, *list, *iter; - GError *error; - - current_search_id++; - - DEBUG("Addressbook: Search %d: %s, max_results %d", current_search_id, query, max_results); - - if(strlen(query) < 1 || g_slist_length(books_data) == 0) { - DEBUG("Addressbook: Query is empty or no addressbook opened"); - - handler(NULL, user_data); - return; - } - - Search_Handler_And_Data *had = g_new(Search_Handler_And_Data, 1); - - // initialize search data - had->search_id = current_search_id; - had->handler = handler; - had->user_data = user_data; - had->hits = NULL; - had->max_results_remaining = max_results; - had->book_views_remaining = 0; - - - // Create the query - int cpt = 0; - - // We could also use E_BOOK_QUERY_IS instead of E_BOOK_QUERY_CONTAINS - queries[cpt++] = e_book_query_field_test(E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_HOME, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_BUSINESS, E_BOOK_QUERY_CONTAINS, query); - queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_MOBILE, E_BOOK_QUERY_CONTAINS, query); - - equery = e_book_query_or(cpt, queries, TRUE); - - // Iterate through all opened books - for(iter = books_data; iter != NULL; iter = iter->next) { - book_data_t *book_data = (book_data_t *)iter->data; - - if(book_data->active) { - - // if(e_book_get_contacts(book_data->ebook, equery, &list, NULL)) { - if(e_book_async_get_contacts(book_data->ebook, equery, eds_query_result_cb, had)) - DEBUG("Addressbook: Queries sent successfully"); +search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data) +{ + EBookQuery *equery; + EBookQuery *queries[4]; + GList *iter; + + current_search_id++; + + DEBUG ("Addressbook: Search %d: %s, max_results %d", current_search_id, query, max_results); + + if (strlen (query) < 1 || g_slist_length (books_data) == 0) { + DEBUG ("Addressbook: Query is empty or no addressbook opened"); + + handler (NULL, user_data); + return; + } + + Search_Handler_And_Data *had = g_new (Search_Handler_And_Data, 1); + + // initialize search data + had->search_id = current_search_id; + had->handler = handler; + had->user_data = user_data; + had->hits = NULL; + had->max_results_remaining = max_results; + had->book_views_remaining = 0; + + + // Create the query + int cpt = 0; + + // We could also use E_BOOK_QUERY_IS instead of E_BOOK_QUERY_CONTAINS + queries[cpt++] = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_HOME, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_BUSINESS, E_BOOK_QUERY_CONTAINS, query); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_MOBILE, E_BOOK_QUERY_CONTAINS, query); + + equery = e_book_query_or (cpt, queries, TRUE); + + // Iterate through all opened books + for (iter = (GList *) books_data; iter != NULL; iter = iter->next) { + book_data_t *book_data = (book_data_t *) iter->data; + + if (book_data->active) { + + // if(e_book_get_contacts(book_data->ebook, equery, &list, NULL)) { + if (e_book_async_get_contacts (book_data->ebook, equery, eds_query_result_cb, had)) + DEBUG ("Addressbook: Queries sent successfully"); + } } - } } /** * Fetch information for a specific contact */ void -fetch_information_from_contact(EContact *contact, EContactField field, gchar **info) +fetch_information_from_contact (EContact *contact, EContactField field, gchar **info) { - gchar *to_fetch; + gchar *to_fetch; + + to_fetch = g_strdup ( (char*) e_contact_get_const (contact, field)); - to_fetch = g_strdup((char*) e_contact_get_const(contact, field)); - if (!to_fetch) - { - to_fetch = g_strdup(EMPTY_ENTRY); + if (!to_fetch) { + to_fetch = g_strdup (EMPTY_ENTRY); } - *info = g_strdup(to_fetch); + *info = g_strdup (to_fetch); } diff --git a/sflphone-client-gnome/src/contacts/addressbook/eds.h b/sflphone-client-gnome/src/contacts/addressbook/eds.h index 6d496a57749c922bc587cee545f2932f24b7d5d8..63f78cea55dd77fe96e85b5a8e16e0d42555588d 100644 --- a/sflphone-client-gnome/src/contacts/addressbook/eds.h +++ b/sflphone-client-gnome/src/contacts/addressbook/eds.h @@ -57,24 +57,22 @@ int current_search_id; /** * Represent a contact entry */ -typedef struct _Hit -{ - gchar *name; - GdkPixbuf *photo; - gchar *phone_business; - gchar *phone_home; - gchar *phone_mobile; +typedef struct _Hit { + gchar *name; + GdkPixbuf *photo; + gchar *phone_business; + gchar *phone_home; + gchar *phone_mobile; } Hit; /** * Book structure for "outside world" */ -typedef struct -{ - gchar *uid; - gchar *name; - gboolean active; - EBook *ebook; +typedef struct { + gchar *uid; + gchar *name; + gboolean active; + EBook *ebook; } book_data_t; GSList *books_data; @@ -83,58 +81,58 @@ GSList *books_data; * Free a contact entry */ void -free_hit(Hit *h); +free_hit (Hit *h); /** * Template callback function for the asynchronous search */ typedef void -(* SearchAsyncHandler)(GList *hits, gpointer user_data); +(* SearchAsyncHandler) (GList *hits, gpointer user_data); /** * Template callback function for the asynchronous open */ typedef void -(* OpenAsyncHandler)(); +(* OpenAsyncHandler) (); /** * Initialize the address book. * Connection to evolution data server */ void -init(OpenAsyncHandler); +init (OpenAsyncHandler); /** * Asynchronous search function (without the get_contacts method) */ void -search_async(const char *query, int max_results, SearchAsyncHandler handler, - gpointer user_data); +search_async (const char *query, int max_results, SearchAsyncHandler handler, + gpointer user_data); /** * Synchronous query to EDS using get_contacts method. Block the application until a result is received. */ void -search_by_contacts(const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); +search_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); /** * Asynchronous query to EDS using get contact method. */ void -search_async_by_contacts(const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); +search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); /** * Retrieve the specified information from the contact */ void -fetch_information_from_contact(EContact *contact, EContactField field, - gchar **info); +fetch_information_from_contact (EContact *contact, EContactField field, + gchar **info); GSList* -get_books(void); +get_books (void); book_data_t * -books_get_book_data_by_uid(gchar *uid); +books_get_book_data_by_uid (gchar *uid); /** * Public way to know if we can perform a search diff --git a/sflphone-client-gnome/src/contacts/calllist.c b/sflphone-client-gnome/src/contacts/calllist.c index 71434ea5d8ee5e9cdd608f1332a5facb07d70c5b..5211a6cd4c6a78e92848dd3967be03e50c0cbcd5 100644 --- a/sflphone-client-gnome/src/contacts/calllist.c +++ b/sflphone-client-gnome/src/contacts/calllist.c @@ -31,68 +31,69 @@ #include <calllist.h> #include <calltree.h> #include <contacts/searchbar.h> +#include <eel-gconf-extensions.h> // TODO : sflphoneGTK : try to do this more generic -void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo){ +void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo) +{ callable_obj_t *new_call; GdkPixbuf *pixbuf; /* Check if the information is valid */ - if (g_strcasecmp (contact_phone, EMPTY_ENTRY) != 0){ + if (g_strcasecmp (contact_phone, EMPTY_ENTRY) != 0) { create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone, &new_call); // Attach a pixbuf to a contact if (photo) { - attach_thumbnail (new_call, gdk_pixbuf_copy(photo)); - } - else { + attach_thumbnail (new_call, gdk_pixbuf_copy (photo)); + } else { switch (type) { case CONTACT_PHONE_BUSINESS: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/users.svg", NULL); + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/users.svg", NULL); break; case CONTACT_PHONE_HOME: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/home.svg", NULL); + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/home.svg", NULL); break; case CONTACT_PHONE_MOBILE: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/phone.svg", NULL); + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/phone.svg", NULL); break; default: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/contact_default.svg", NULL); + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/contact_default.svg", NULL); break; } + attach_thumbnail (new_call, pixbuf); } calllist_add (contacts, new_call); - calltree_add_call(contacts, new_call, NULL); + calltree_add_call (contacts, new_call, NULL); } } void calllist_init (calltab_t* tab) { - tab->callQueue = g_queue_new (); - tab->selectedCall = NULL; + tab->callQueue = g_queue_new (); + tab->selectedCall = NULL; } void calllist_clean (calltab_t* tab) { - g_queue_free (tab->callQueue); + g_queue_free (tab->callQueue); } void calllist_reset (calltab_t* tab) { - g_queue_free (tab->callQueue); - tab->callQueue = g_queue_new(); + g_queue_free (tab->callQueue); + tab->callQueue = g_queue_new(); } void calllist_add_history_entry (callable_obj_t *obj) { - if (eel_gconf_get_integer (HISTORY_ENABLED)) - { + if (eel_gconf_get_integer (HISTORY_ENABLED)) { g_queue_push_tail (history->callQueue, (gpointer *) obj); calltree_add_call (history, obj, NULL); } @@ -101,89 +102,84 @@ void calllist_add_history_entry (callable_obj_t *obj) void calllist_add (calltab_t* tab, callable_obj_t * c) { - if( tab == history ) - { + if (tab == history) { calllist_add_history_entry (c); - } - else + } else g_queue_push_tail (tab->callQueue, (gpointer *) c); } // TODO : sflphoneGTK : try to do this more generic void -calllist_clean_history( void ) +calllist_clean_history (void) { - unsigned int i; - guint size = calllist_get_size( history ); - DEBUG("CallList: history list size = %i", calllist_get_size( history )); - for( i = 0 ; i < size ; i++ ) - { - DEBUG("CallList: Delete calls"); - callable_obj_t* c = calllist_get_nth( history , i ); - // Delete the call from the call tree - DEBUG("CallList: Delete calls"); - calltree_remove_call(history, c, NULL); - } - calllist_reset( history ); + unsigned int i; + guint size = calllist_get_size (history); + DEBUG ("CallList: history list size = %i", calllist_get_size (history)); + + for (i = 0 ; i < size ; i++) { + DEBUG ("CallList: Delete calls"); + callable_obj_t* c = calllist_get_nth (history , i); + // Delete the call from the call tree + DEBUG ("CallList: Delete calls"); + calltree_remove_call (history, c, NULL); + } + + calllist_reset (history); } // TODO : sflphoneGTK : try to do this more generic void -calllist_remove_from_history( callable_obj_t* c ) +calllist_remove_from_history (callable_obj_t* c) { - calllist_remove( history, c->_callID ); - calltree_remove_call(history, c, NULL); - DEBUG("CallList: Size of history = %i" , calllist_get_size( history )); + calllist_remove (history, c->_callID); + calltree_remove_call (history, c, NULL); + DEBUG ("CallList: Size of history = %i" , calllist_get_size (history)); } void calllist_remove (calltab_t* tab, const gchar * callID) { - callable_obj_t * c = calllist_get(tab, callID); - if (c) - { - g_queue_remove(tab->callQueue, c); - } + callable_obj_t * c = calllist_get (tab, callID); + + if (c) { + g_queue_remove (tab->callQueue, c); + } } callable_obj_t * -calllist_get_by_state (calltab_t* tab, call_state_t state ) +calllist_get_by_state (calltab_t* tab, call_state_t state) { - GList * c = g_queue_find_custom (tab->callQueue, &state, get_state_callstruct); - if (c) - { - return (callable_obj_t *)c->data; - } - else - { - return NULL; - } + GList * c = g_queue_find_custom (tab->callQueue, &state, get_state_callstruct); + + if (c) { + return (callable_obj_t *) c->data; + } else { + return NULL; + } } guint calllist_get_size (calltab_t* tab) { - return g_queue_get_length (tab->callQueue); + return g_queue_get_length (tab->callQueue); } callable_obj_t * -calllist_get_nth (calltab_t* tab, guint n ) +calllist_get_nth (calltab_t* tab, guint n) { - return g_queue_peek_nth (tab->callQueue, n); + return g_queue_peek_nth (tab->callQueue, n); } callable_obj_t * -calllist_get (calltab_t* tab, const gchar * callID ) +calllist_get (calltab_t* tab, const gchar * callID) { - GList * c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct); - if (c) - { - return (callable_obj_t *)c->data; - } - else - { - return NULL; - } + GList * c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct); + + if (c) { + return (callable_obj_t *) c->data; + } else { + return NULL; + } } diff --git a/sflphone-client-gnome/src/contacts/calllist.h b/sflphone-client-gnome/src/contacts/calllist.h index db3cee03dcb4df6adc6685db1a8ffe234532530d..7b6704600fb3cb0c6a4aa498d1b437d90351533c 100644 --- a/sflphone-client-gnome/src/contacts/calllist.h +++ b/sflphone-client-gnome/src/contacts/calllist.h @@ -40,17 +40,17 @@ */ typedef struct { - GtkTreeStore* store; - GtkWidget* view; - GtkWidget* tree; - GtkWidget* searchbar; - - // Calllist vars - GQueue* callQueue; - gint selectedType; - callable_obj_t* selectedCall; - conference_obj_t* selectedConf; - gchar *_name; + GtkTreeStore* store; + GtkWidget* view; + GtkWidget* tree; + GtkWidget* searchbar; + + // Calllist vars + GQueue* callQueue; + gint selectedType; + callable_obj_t* selectedCall; + conference_obj_t* selectedConf; + gchar *_name; } calltab_t; void @@ -64,7 +64,7 @@ calllist_init (calltab_t* tab); /** This function empty and free the call list. */ void -calllist_clean(calltab_t* tab); +calllist_clean (calltab_t* tab); /** This function empty, free the call list and allocate a new one. */ void @@ -72,11 +72,11 @@ calllist_reset (calltab_t* tab); /** Get the maximun number of calls in the history calltab */ gdouble -call_history_get_max_calls( void ); +call_history_get_max_calls (void); /** Set the maximun number of calls in the history calltab */ void -call_history_set_max_calls( const gdouble number ); +call_history_set_max_calls (const gdouble number); /** This function append a call to list. * @param c The call you want to add @@ -106,13 +106,13 @@ calllist_get_size (calltab_t* tab); * @param n The position of the call you want * @return A call or NULL */ callable_obj_t * -calllist_get_nth (calltab_t* tab, guint n ); +calllist_get_nth (calltab_t* tab, guint n); /** Return the call corresponding to the callID * @param n The callID of the call you want * @return A call or NULL */ callable_obj_t * -calllist_get (calltab_t* tab, const gchar * callID ); +calllist_get (calltab_t* tab, const gchar * callID); /** * Clean the history. Delete all calls @@ -125,7 +125,7 @@ calllist_clean_history(); * @param c The call to remove */ void -calllist_remove_from_history( callable_obj_t* c); +calllist_remove_from_history (callable_obj_t* c); /** * Initialize a non-empty call list diff --git a/sflphone-client-gnome/src/contacts/calltab.c b/sflphone-client-gnome/src/contacts/calltab.c index ac194bf8287fe4a233e827aae2d2c9acfc22afa8..fab48e76318b7810a5969b7edaeb47382af70125 100644 --- a/sflphone-client-gnome/src/contacts/calltab.c +++ b/sflphone-client-gnome/src/contacts/calltab.c @@ -36,28 +36,28 @@ calltab_t* calltab_init (gboolean searchbar_type, gchar *name) { - calltab_t* ret; + calltab_t* ret; - ret = malloc(sizeof(calltab_t)); + ret = malloc (sizeof (calltab_t)); - ret->store = NULL; - ret->view = NULL; - ret->tree = NULL; - ret->searchbar = NULL; - ret->callQueue = NULL; - ret->selectedCall = NULL; - ret->selectedConf = NULL; - ret->_name = g_strdup (name); + ret->store = NULL; + ret->view = NULL; + ret->tree = NULL; + ret->searchbar = NULL; + ret->callQueue = NULL; + ret->selectedCall = NULL; + ret->selectedConf = NULL; + ret->_name = g_strdup (name); - calltree_create (ret, searchbar_type); - calllist_init(ret); + calltree_create (ret, searchbar_type); + calllist_init (ret); - return ret; + return ret; } void -calltab_select_call (calltab_t* tab, callable_obj_t * c ) +calltab_select_call (calltab_t* tab, callable_obj_t * c) { tab->selectedType = A_CALL; tab->selectedCall = c; @@ -66,7 +66,7 @@ calltab_select_call (calltab_t* tab, callable_obj_t * c ) void -calltab_select_conf (conference_obj_t * c ) +calltab_select_conf (conference_obj_t * c) { current_calls->selectedType = A_CONFERENCE; current_calls->selectedConf = c; @@ -74,7 +74,7 @@ calltab_select_conf (conference_obj_t * c ) } gint -calltab_get_selected_type(calltab_t* tab) +calltab_get_selected_type (calltab_t* tab) { return tab->selectedType; } @@ -82,7 +82,7 @@ calltab_get_selected_type(calltab_t* tab) callable_obj_t * calltab_get_selected_call (calltab_t* tab) { - return tab->selectedCall; + return tab->selectedCall; } conference_obj_t* diff --git a/sflphone-client-gnome/src/contacts/calltab.h b/sflphone-client-gnome/src/contacts/calltab.h index db14867ac51839ec0c3eb85c2bea116576fe69d5..1d748620ba3f3e9e1dd908e0ae03b16332f78ec8 100644 --- a/sflphone-client-gnome/src/contacts/calltab.h +++ b/sflphone-client-gnome/src/contacts/calltab.h @@ -54,7 +54,7 @@ void calltab_select_conf (conference_obj_t *); gint -calltab_get_selected_type(calltab_t* tab); +calltab_get_selected_type (calltab_t* tab); /** Return the selected call. * @return The number of the caller */ diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 665e79af3070bae3b7edc546e75211fde0280902..443a09af0b261689a53659c5d3deb2f1ce526307 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -33,10 +33,13 @@ #include <calltree.h> #include <stdlib.h> #include <glib/gprintf.h> +#include <eel-gconf-extensions.h> #include <calllist.h> #include <conferencelist.h> #include <mainwindow.h> #include <history.h> +#include "uimanager.h" +#include "actions.h" GtkWidget *sw; GtkCellRenderer *rend; @@ -62,40 +65,40 @@ conference_obj_t *dragged_conf; conference_obj_t *selected_conf; -static void drag_begin_cb(GtkWidget *widget, GdkDragContext *dc, gpointer data); -static void drag_end_cb(GtkWidget * mblist, GdkDragContext * context, gpointer data); -void drag_data_received_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data); +static void drag_begin_cb (GtkWidget *widget, GdkDragContext *dc, gpointer data); +static void drag_end_cb (GtkWidget * mblist, GdkDragContext * context, gpointer data); +void drag_data_received_cb (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data); enum { - COLUMN_ACCOUNT_STATE = 0, - COLUMN_ACCOUNT_DESC, - COLUMN_ACCOUNT_SECURITY, - COLUMN_ACCOUNT_PTR, + COLUMN_ACCOUNT_STATE = 0, + COLUMN_ACCOUNT_DESC, + COLUMN_ACCOUNT_SECURITY, + COLUMN_ACCOUNT_PTR, }; /** * Show popup menu */ - static gboolean +static gboolean popup_menu (GtkWidget *widget, - gpointer user_data UNUSED) + gpointer user_data UNUSED) { - show_popup_menu(widget, NULL); - return TRUE; + show_popup_menu (widget, NULL); + return TRUE; } /* Call back when the user click on a call in the list */ - static void -call_selected_cb(GtkTreeSelection *sel, void* data UNUSED ) +static void +call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) { - DEBUG("CallTree: Selection callback"); + DEBUG ("CallTree: Selection callback"); GtkTreeIter iter; GValue val; - GtkTreeModel *model = (GtkTreeModel*)active_calltree->store; - + GtkTreeModel *model = (GtkTreeModel*) active_calltree->store; + GtkTreePath* path; gchar* string_path; @@ -105,163 +108,164 @@ call_selected_cb(GtkTreeSelection *sel, void* data UNUSED ) } // store info for dragndrop - path = gtk_tree_model_get_path(model, &iter); - string_path = gtk_tree_path_to_string(path); - selected_path_depth = gtk_tree_path_get_depth(path); + path = gtk_tree_model_get_path (model, &iter); + string_path = gtk_tree_path_to_string (path); + selected_path_depth = gtk_tree_path_get_depth (path); - if(gtk_tree_model_iter_has_child(GTK_TREE_MODEL(model), &iter)) { + if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (model), &iter)) { - DEBUG("CallTree: Selected a conference"); - selected_type = A_CONFERENCE; + DEBUG ("CallTree: Selected a conference"); + selected_type = A_CONFERENCE; - val.g_type = 0; - gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); + val.g_type = 0; + gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); - calltab_select_conf((conference_obj_t*) g_value_get_pointer(&val)); + calltab_select_conf ( (conference_obj_t*) g_value_get_pointer (&val)); - selected_conf = (conference_obj_t*)g_value_get_pointer(&val); + selected_conf = (conference_obj_t*) g_value_get_pointer (&val); - if(selected_conf) { + if (selected_conf) { - selected_call_id = selected_conf->_confID; - selected_path = string_path; - selected_call = NULL; + selected_call_id = selected_conf->_confID; + selected_path = string_path; + selected_call = NULL; - } + } - DEBUG("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", - selected_path, selected_call_id, selected_path_depth); + DEBUG ("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", + selected_path, selected_call_id, selected_path_depth); - } - else { - - DEBUG("CallTree: Selected a call"); - selected_type = A_CALL; - - val.g_type = 0; - gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); - - calltab_select_call(active_calltree, (callable_obj_t*) g_value_get_pointer(&val)); - - selected_call = (callable_obj_t*)g_value_get_pointer(&val); - - if(selected_call) { - - selected_call_id = selected_call->_callID; - selected_path = string_path; - selected_conf = NULL; - } - - DEBUG("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", - selected_path, selected_call_id, selected_path_depth); + } else { + + DEBUG ("CallTree: Selected a call"); + selected_type = A_CALL; + + val.g_type = 0; + gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); + + calltab_select_call (active_calltree, (callable_obj_t*) g_value_get_pointer (&val)); + + selected_call = (callable_obj_t*) g_value_get_pointer (&val); + + if (selected_call) { + + selected_call_id = selected_call->_callID; + selected_path = string_path; + selected_conf = NULL; + } + + DEBUG ("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", + selected_path, selected_call_id, selected_path_depth); } - g_value_unset(&val); + g_value_unset (&val); update_actions(); } /* A row is activated when it is double clicked */ - void -row_activated(GtkTreeView *tree_view UNUSED, - GtkTreePath *path UNUSED, - GtkTreeViewColumn *column UNUSED, - void * data UNUSED) { +void +row_activated (GtkTreeView *tree_view UNUSED, + GtkTreePath *path UNUSED, + GtkTreeViewColumn *column UNUSED, + void * data UNUSED) +{ callable_obj_t* selectedCall = NULL; callable_obj_t* new_call; conference_obj_t* selectedConf = NULL; gchar *account_id; - - DEBUG("CallTree: Double click action"); - - if(calltab_get_selected_type(active_calltree) == A_CALL) { - - selectedCall = calltab_get_selected_call(active_calltree); - - if (selectedCall) { - DEBUG("CallTree: Selected a call"); - - // Get the right event from the right calltree - if( active_calltree == current_calls ) { - - DEBUG("CallTree: Active tree is current calls"); - - switch(selectedCall->_state) { - case CALL_STATE_INCOMING: - dbus_accept(selectedCall); - stop_notification(); - break; - case CALL_STATE_HOLD: - dbus_unhold(selectedCall); - break; - case CALL_STATE_RINGING: - case CALL_STATE_CURRENT: - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - break; - case CALL_STATE_DIALING: - sflphone_place_call (selectedCall); - break; - default: - WARN("Row activated - Should not happen!"); - break; - } - } - - // If history or contact: double click action places a new call - else { - - DEBUG("CallTree: Active tree is history or contact"); - - account_id = g_strdup (selectedCall->_accountID); - - // Create a new call - create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call); - - calllist_add(current_calls, new_call); - calltree_add_call(current_calls, new_call, NULL); - sflphone_place_call(new_call); - calltree_display(current_calls); - } - } - } - else if(calltab_get_selected_type(current_calls) == A_CONFERENCE) { - - DEBUG("CallTree: Selected a conference"); - - if( active_calltree == current_calls ) { - - selectedConf = calltab_get_selected_conf(current_calls); - - if(selectedConf) { - - switch(selectedConf->_state) { - case CONFERENCE_STATE_ACTIVE_ATACHED: - // sflphone_add_main_participant(selectedConf); - break; - case CONFERENCE_STATE_ACTIVE_DETACHED: - sflphone_add_main_participant(selectedConf); - break; - case CONFERENCE_STATE_HOLD: - sflphone_conference_off_hold(selectedConf); - break; - } - } - } + + DEBUG ("CallTree: Double click action"); + + if (calltab_get_selected_type (active_calltree) == A_CALL) { + + selectedCall = calltab_get_selected_call (active_calltree); + + if (selectedCall) { + DEBUG ("CallTree: Selected a call"); + + // Get the right event from the right calltree + if (active_calltree == current_calls) { + + DEBUG ("CallTree: Active tree is current calls"); + + switch (selectedCall->_state) { + case CALL_STATE_INCOMING: + dbus_accept (selectedCall); + stop_notification(); + break; + case CALL_STATE_HOLD: + dbus_unhold (selectedCall); + break; + case CALL_STATE_RINGING: + case CALL_STATE_CURRENT: + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + break; + case CALL_STATE_DIALING: + sflphone_place_call (selectedCall); + break; + default: + WARN ("Row activated - Should not happen!"); + break; + } + } + + // If history or contact: double click action places a new call + else { + + DEBUG ("CallTree: Active tree is history or contact"); + + account_id = g_strdup (selectedCall->_accountID); + + // Create a new call + create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call); + + calllist_add (current_calls, new_call); + calltree_add_call (current_calls, new_call, NULL); + sflphone_place_call (new_call); + calltree_display (current_calls); + } + } + } else if (calltab_get_selected_type (current_calls) == A_CONFERENCE) { + + DEBUG ("CallTree: Selected a conference"); + + if (active_calltree == current_calls) { + + selectedConf = calltab_get_selected_conf (current_calls); + + if (selectedConf) { + + switch (selectedConf->_state) { + break; + case CONFERENCE_STATE_ACTIVE_DETACHED: + sflphone_add_main_participant (selectedConf); + break; + case CONFERENCE_STATE_HOLD: + sflphone_conference_off_hold (selectedConf); + break; + case CONFERENCE_STATE_ACTIVE_ATACHED: + case CONFERENCE_STATE_RECORD: + default: + break; + } + } + } } } /* Catch cursor-activated signal. That is, when the entry is single clicked */ - void -row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED) +void +row_single_click (GtkTreeView *tree_view UNUSED, void * data UNUSED) { callable_obj_t * selectedCall = NULL; account_t * account_details = NULL; gchar * displaySasOnce=""; - DEBUG("CallTree: Single click action"); + DEBUG ("CallTree: Single click action"); - selectedCall = calltab_get_selected_call( active_calltree ); + selectedCall = calltab_get_selected_call (active_calltree); /* if(!selected_call) { @@ -271,227 +275,225 @@ row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED) if (selectedCall) { - account_details = account_list_get_by_id(selectedCall->_accountID); - DEBUG("AccountID %s", selectedCall->_accountID); - - if(account_details != NULL) { - displaySasOnce = g_hash_table_lookup(account_details->properties, ACCOUNT_DISPLAY_SAS_ONCE); - DEBUG("Display SAS once %s", displaySasOnce); - } - else { - GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); - if(properties != NULL) - { displaySasOnce = g_hash_table_lookup(properties, ACCOUNT_DISPLAY_SAS_ONCE); DEBUG("IP2IP displaysasonce %s", displaySasOnce); } - } - - /* Make sure that we are not in the history tab since - * nothing is defined for it yet - */ - if( active_calltree == current_calls ) { - - // sflphone_selected_call_codec(selectedCall); - - // DEBUG("single click action: %s", dbus_get_current_codec_name(selectedCall)); - // sflphone_display_selected_codec(dbus_get_current_codec_name(selectedCall)); - - switch(selectedCall->_srtp_state) { - - case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: - selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED; - if(g_strcasecmp(displaySasOnce,"true") == 0) { - selectedCall->_zrtp_confirmed = TRUE; - } - dbus_confirm_sas(selectedCall); - calltree_update_call(current_calls, selectedCall, NULL); - break; - case SRTP_STATE_ZRTP_SAS_CONFIRMED: - selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED; - dbus_reset_sas(selectedCall); - calltree_update_call(current_calls, selectedCall, NULL); - break; - default: - DEBUG("Single click but no action"); - break; - } - } + account_details = account_list_get_by_id (selectedCall->_accountID); + DEBUG ("AccountID %s", selectedCall->_accountID); + + if (account_details != NULL) { + displaySasOnce = g_hash_table_lookup (account_details->properties, ACCOUNT_DISPLAY_SAS_ONCE); + DEBUG ("Display SAS once %s", displaySasOnce); + } else { + GHashTable * properties = NULL; + sflphone_get_ip2ip_properties (&properties); + + if (properties != NULL) { + displaySasOnce = g_hash_table_lookup (properties, ACCOUNT_DISPLAY_SAS_ONCE); + DEBUG ("IP2IP displaysasonce %s", displaySasOnce); + } + } + + /* Make sure that we are not in the history tab since + * nothing is defined for it yet + */ + if (active_calltree == current_calls) { + + // sflphone_selected_call_codec(selectedCall); + + // DEBUG("single click action: %s", dbus_get_current_codec_name(selectedCall)); + // sflphone_display_selected_codec(dbus_get_current_codec_name(selectedCall)); + + switch (selectedCall->_srtp_state) { + + case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: + selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED; + + if (g_strcasecmp (displaySasOnce,"true") == 0) { + selectedCall->_zrtp_confirmed = TRUE; + } + + dbus_confirm_sas (selectedCall); + calltree_update_call (current_calls, selectedCall, NULL); + break; + case SRTP_STATE_ZRTP_SAS_CONFIRMED: + selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_UNCONFIRMED; + dbus_reset_sas (selectedCall); + calltree_update_call (current_calls, selectedCall, NULL); + break; + default: + DEBUG ("Single click but no action"); + break; + } + } } } static gboolean -button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUSED) +button_pressed (GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUSED) { - if (event->button == 3 && event->type == GDK_BUTTON_PRESS){ - if( active_calltree == current_calls ) { - show_popup_menu(widget, event); - return TRUE; - } - else if (active_calltree == history) { - show_popup_menu_history (widget, event); - return TRUE; - } - else { - show_popup_menu_contacts (widget, event); - return TRUE; - } + if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { + if (active_calltree == current_calls) { + show_popup_menu (widget, event); + return TRUE; + } else if (active_calltree == history) { + show_popup_menu_history (widget, event); + return TRUE; + } else { + show_popup_menu_contacts (widget, event); + return TRUE; + } } + return FALSE; } -gchar* -calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gchar *audio_codec, gchar** display_info) +void calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type, gchar *audio_codec, gchar** display_info) { - gchar * description; + gchar * description = NULL; gchar * tmp_info; gchar * peer_number = c->_peer_number; gchar * hostname = NULL; - gchar * display_number = ""; + gchar * display_number = ""; - DEBUG("CallTree: Display call info"); + DEBUG ("CallTree: Display call info"); // If call is outgoing, keep the hostname, strip it elsewhere - if(c->_type == CALL && c->_history_state == OUTGOING) { + if (c->_type == CALL && c->_history_state == OUTGOING) { - display_number = peer_number; - } - else { + display_number = peer_number; + } else { // Get the hostname for this call (NULL if not existent) - hostname = g_strrstr(peer_number, "@"); - - // Test if we are dialing a new number - if(g_strcmp0("", c->_peer_number) != 0) { - - // Strip the hostname if existent - if(hostname) { - display_number = g_strndup(peer_number, hostname - peer_number); - } - else { - display_number = peer_number; - } - } - else { - - display_number = peer_number; - } + hostname = g_strrstr (peer_number, "@"); + + // Test if we are dialing a new number + if (g_strcmp0 ("", c->_peer_number) != 0) { + + // Strip the hostname if existent + if (hostname) { + display_number = g_strndup (peer_number, hostname - peer_number); + } else { + display_number = peer_number; + } + } else { + + display_number = peer_number; + } } + // Different display depending on type - switch(display_type) { - - case DISPLAY_TYPE_CALL: - - DEBUG("CallTree: Display a normal call"); - if(c->_state_code == 0) { - - if(g_strcmp0("", c->_peer_name) == 0) { - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>", - display_number, c->_peer_name); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_name, display_number); - } - - } - else { - if(g_strcmp0("", c->_peer_name) == 0) { - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i>", - display_number, c->_peer_name, - c->_state_code_description, c->_state_code); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", - c->_peer_name, display_number, - c->_state_code_description, c->_state_code); - } - } - break; - - - case DISPLAY_TYPE_CALL_TRANSFER: - - DEBUG("CallTree: Display a call transfer"); - - if(g_strcmp0("",c->_peer_name) == 0){ - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ", - display_number, c->_peer_name, c->_trsft_to); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", - c->_peer_name, display_number, c->_trsft_to); - } - break; - - - case DISPLAY_TYPE_STATE_CODE : - - DEBUG("CallTree: Display a state code"); - - if(g_strcmp0("",c->_peer_name) == 0){ - - if (c->_state_code) { - - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", - display_number, c->_peer_name, - c->_state_code_description, c->_state_code, - audio_codec); - } else { - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s</i>", - display_number, c->_peer_name, audio_codec); - } - } - else { - if (c->_state_code) { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", - c->_peer_name, display_number, - c->_state_code_description, c->_state_code, - audio_codec); - } else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s</i>", - c->_peer_name, display_number, audio_codec); - } - } - break; - - case DISPLAY_TYPE_SAS: - - DEBUG("CallTree: Display a call with sas"); - - if(g_strcmp0("", c->_peer_name) == 0){ - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", - display_number, c->_peer_name, c->_sas); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", - c->_peer_name, display_number, c->_sas); - } - break; - - case DISPLAY_TYPE_HISTORY : - - DEBUG("CallTree: Display history entry"); - - if(g_strcmp0("", c->_peer_name) == 0) { - description = g_markup_printf_escaped("<b>%s</b><i>%s</i>", - display_number, c->_peer_name); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_name, display_number); - } - break; - - default : - DEBUG("CallTree: Not an allowable type of display"); - break; + switch (display_type) { + + case DISPLAY_TYPE_CALL: + + DEBUG ("CallTree: Display a normal call"); + + if (c->_state_code == 0) { + + if (g_strcmp0 ("", c->_peer_name) == 0) { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>", + display_number, c->_peer_name); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>", + c->_peer_name, display_number); + } + + } else { + if (g_strcmp0 ("", c->_peer_name) == 0) { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>\n<i>%s (%d)</i>", + display_number, c->_peer_name, + c->_state_code_description, c->_state_code); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", + c->_peer_name, display_number, + c->_state_code_description, c->_state_code); + } + } + + break; + + + case DISPLAY_TYPE_CALL_TRANSFER: + + DEBUG ("CallTree: Display a call transfer"); + + if (g_strcmp0 ("",c->_peer_name) == 0) { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ", + display_number, c->_peer_name, c->_trsft_to); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", + c->_peer_name, display_number, c->_trsft_to); + } + + break; + + + case DISPLAY_TYPE_STATE_CODE : + + DEBUG ("CallTree: Display a state code"); + + if (g_strcmp0 ("",c->_peer_name) == 0) { + + if (c->_state_code) { + + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", + display_number, c->_peer_name, + c->_state_code_description, c->_state_code, + audio_codec); + } else { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>\n<i>%s</i>", + display_number, c->_peer_name, audio_codec); + } + } else { + if (c->_state_code) { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", + c->_peer_name, display_number, + c->_state_code_description, c->_state_code, + audio_codec); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>\n<i>%s</i>", + c->_peer_name, display_number, audio_codec); + } + } + + break; + + case DISPLAY_TYPE_SAS: + + DEBUG ("CallTree: Display a call with sas"); + + if (g_strcmp0 ("", c->_peer_name) == 0) { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", + display_number, c->_peer_name, c->_sas); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", + c->_peer_name, display_number, c->_sas); + } + + break; + + case DISPLAY_TYPE_HISTORY : + + DEBUG ("CallTree: Display history entry"); + + if (g_strcmp0 ("", c->_peer_name) == 0) { + description = g_markup_printf_escaped ("<b>%s</b><i>%s</i>", + display_number, c->_peer_name); + } else { + description = g_markup_printf_escaped ("<b>%s</b> <i>%s</i>", + c->_peer_name, display_number); + } + + break; + + default : + DEBUG ("CallTree: Not an allowable type of display"); + break; } - // return description; - tmp_info = g_strdup(description); + tmp_info = g_strdup (description); *display_info = tmp_info; } @@ -500,190 +502,185 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch /** * Reset call tree */ - void +void calltree_reset (calltab_t* tab) { - gtk_tree_store_clear (tab->store); + gtk_tree_store_clear (tab->store); } void -focus_on_calltree_out(){ - //DEBUG("set_focus_on_calltree_out"); - // gtk_widget_grab_focus(GTK_WIDGET(sw)); - focus_is_on_calltree = FALSE; +focus_on_calltree_out() +{ + focus_is_on_calltree = FALSE; } void -focus_on_calltree_in(){ - //DEBUG("set_focus_on_calltree_in"); - // gtk_widget_grab_focus(GTK_WIDGET(sw)); - focus_is_on_calltree = TRUE; +focus_on_calltree_in() +{ + focus_is_on_calltree = TRUE; } - void +void calltree_create (calltab_t* tab, gboolean searchbar_type) { - tab->tree = gtk_vbox_new(FALSE, 10); + tab->tree = gtk_vbox_new (FALSE, 10); - // Fix bug #708 (resize) - gtk_widget_set_size_request(tab->tree,100,80); + // Fix bug #708 (resize) + gtk_widget_set_size_request (tab->tree,100,80); - gtk_container_set_border_width (GTK_CONTAINER (tab->tree), 0); + gtk_container_set_border_width (GTK_CONTAINER (tab->tree), 0); - sw = gtk_scrolled_window_new( NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); - tab->store = gtk_tree_store_new (4, - GDK_TYPE_PIXBUF,// Icon - G_TYPE_STRING, // Description - GDK_TYPE_PIXBUF, // Security Icon - G_TYPE_POINTER // Pointer to the Object - ); + tab->store = gtk_tree_store_new (4, + GDK_TYPE_PIXBUF,// Icon + G_TYPE_STRING, // Description + GDK_TYPE_PIXBUF, // Security Icon + G_TYPE_POINTER // Pointer to the Object + ); - tab->view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tab->store)); - gtk_tree_view_set_enable_search( GTK_TREE_VIEW(tab->view), FALSE); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tab->view), FALSE); - g_signal_connect (G_OBJECT (tab->view), "row-activated", - G_CALLBACK (row_activated), - NULL); + tab->view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (tab->store)); + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tab->view), FALSE); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tab->view), FALSE); + g_signal_connect (G_OBJECT (tab->view), "row-activated", + G_CALLBACK (row_activated), + NULL); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(sw),GTK_CAN_FOCUS); - gtk_widget_grab_focus (GTK_WIDGET(sw)); + GTK_WIDGET_SET_FLAGS (GTK_WIDGET (sw),GTK_CAN_FOCUS); + gtk_widget_grab_focus (GTK_WIDGET (sw)); - g_signal_connect (G_OBJECT (tab->view), "cursor-changed", - G_CALLBACK (row_single_click), - NULL); + g_signal_connect (G_OBJECT (tab->view), "cursor-changed", + G_CALLBACK (row_single_click), + NULL); - // Connect the popup menu - g_signal_connect (G_OBJECT (tab->view), "popup-menu", - G_CALLBACK (popup_menu), - NULL); - g_signal_connect (G_OBJECT (tab->view), "button-press-event", - G_CALLBACK (button_pressed), - NULL); + // Connect the popup menu + g_signal_connect (G_OBJECT (tab->view), "popup-menu", + G_CALLBACK (popup_menu), + NULL); + g_signal_connect (G_OBJECT (tab->view), "button-press-event", + G_CALLBACK (button_pressed), + NULL); - // g_signal_connect (G_OBJECT (sw), "key-release-event", - // G_CALLBACK (on_key_released), NULL); + g_signal_connect_after (G_OBJECT (tab->view), "focus-in-event", + G_CALLBACK (focus_on_calltree_in), NULL); + g_signal_connect_after (G_OBJECT (tab->view), "focus-out-event", + G_CALLBACK (focus_on_calltree_out), NULL); - g_signal_connect_after (G_OBJECT (tab->view), "focus-in-event", - G_CALLBACK (focus_on_calltree_in), NULL); - g_signal_connect_after (G_OBJECT (tab->view), "focus-out-event", - G_CALLBACK (focus_on_calltree_out), NULL); + if (tab != history && tab!=contacts) { - if(tab != history && tab!=contacts) { + DEBUG ("SET TREE VIEW REORDABLE"); + // Make calltree reordable for drag n drop + gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tab->view), TRUE); - DEBUG("SET TREE VIEW REORDABLE"); - // Make calltree reordable for drag n drop - gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tab->view), TRUE); + // source widget drag n drop signals + g_signal_connect (G_OBJECT (tab->view), "drag_begin", G_CALLBACK (drag_begin_cb), NULL); + g_signal_connect (G_OBJECT (tab->view), "drag_end", G_CALLBACK (drag_end_cb), NULL); - // source widget drag n drop signals - g_signal_connect (G_OBJECT (tab->view), "drag_begin", G_CALLBACK (drag_begin_cb), NULL); - g_signal_connect (G_OBJECT (tab->view), "drag_end", G_CALLBACK (drag_end_cb), NULL); + // destination widget drag n drop signals + g_signal_connect (G_OBJECT (tab->view), "drag_data_received", G_CALLBACK (drag_data_received_cb), NULL); - // destination widget drag n drop signals - g_signal_connect (G_OBJECT (tab->view), "drag_data_received", G_CALLBACK (drag_data_received_cb), NULL); + } - } + gtk_widget_grab_focus (GTK_WIDGET (tab->view)); + + rend = gtk_cell_renderer_pixbuf_new(); + col = gtk_tree_view_column_new_with_attributes ("Icon", + rend, + "pixbuf", 0, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tab->view), col); + + rend = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new_with_attributes ("Description", + rend, + "markup", COLUMN_ACCOUNT_DESC, + NULL); + g_object_set (rend, "wrap-mode", (PangoWrapMode) PANGO_WRAP_WORD_CHAR, NULL); + g_object_set (rend, "wrap-width", (gint) CALLTREE_TEXT_WIDTH, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tab->view), col); + + /* Security icon */ + rend = gtk_cell_renderer_pixbuf_new(); + col = gtk_tree_view_column_new_with_attributes ("Icon", + rend, + "pixbuf", COLUMN_ACCOUNT_SECURITY, + NULL); + g_object_set (rend, "xalign", (gfloat) 1.0, NULL); + g_object_set (rend, "yalign", (gfloat) 0.0, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tab->view), col); + + + g_object_unref (G_OBJECT (tab->store)); + gtk_container_add (GTK_CONTAINER (sw), tab->view); + + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tab->view)); + g_signal_connect (G_OBJECT (sel), "changed", + G_CALLBACK (call_selected_cb), + NULL); + + gtk_box_pack_start (GTK_BOX (tab->tree), sw, TRUE, TRUE, 0); + + // search bar if tab is either "history" or "addressbook" + if (searchbar_type) { + calltab_create_searchbar (tab); + gtk_box_pack_start (GTK_BOX (tab->tree), tab->searchbar, FALSE, TRUE, 0); + } - gtk_widget_grab_focus(GTK_WIDGET(tab->view)); + gtk_widget_show (tab->tree); +} - rend = gtk_cell_renderer_pixbuf_new(); - col = gtk_tree_view_column_new_with_attributes ("Icon", - rend, - "pixbuf", 0, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(tab->view), col); - rend = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new_with_attributes ("Description", - rend, - "markup", COLUMN_ACCOUNT_DESC, - NULL); - g_object_set(rend, "wrap-mode", (PangoWrapMode) PANGO_WRAP_WORD_CHAR, NULL); - g_object_set(rend, "wrap-width", (gint) CALLTREE_TEXT_WIDTH, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(tab->view), col); +void +calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) +{ + + GtkTreeIter iter; + GValue val; + callable_obj_t * iterCall; + GtkTreeStore* store = tab->store; + + if (!c) + ERROR ("CallTree: Error: Not a valid call"); - /* Security icon */ - rend = gtk_cell_renderer_pixbuf_new(); - col = gtk_tree_view_column_new_with_attributes ("Icon", - rend, - "pixbuf", COLUMN_ACCOUNT_SECURITY, - NULL); - g_object_set(rend, "xalign", (gfloat) 1.0, NULL); - g_object_set(rend, "yalign", (gfloat) 0.0, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(tab->view), col); + DEBUG ("CallTree: Remove call %s", c->_callID); + int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); + int i; - g_object_unref(G_OBJECT(tab->store)); - gtk_container_add(GTK_CONTAINER(sw), tab->view); + for (i = 0; i < nbChild; i++) { + if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, parent, i)) { + if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (store), &iter)) { + calltree_remove_call (tab, c, &iter); + } - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tab->view)); - g_signal_connect (G_OBJECT (sel), "changed", - G_CALLBACK (call_selected_cb), - NULL); + val.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter, COLUMN_ACCOUNT_PTR, &val); - gtk_box_pack_start(GTK_BOX(tab->tree), sw, TRUE, TRUE, 0); + iterCall = (callable_obj_t*) g_value_get_pointer (&val); + g_value_unset (&val); - // search bar if tab is either "history" or "addressbook" - if(searchbar_type){ - calltab_create_searchbar (tab); - gtk_box_pack_start(GTK_BOX(tab->tree), tab->searchbar, FALSE, TRUE, 0); - } + if (iterCall == c) { + gtk_tree_store_remove (store, &iter); + } + } + } - gtk_widget_show(tab->tree); -} + callable_obj_t * selectedCall = calltab_get_selected_call (tab); + if (selectedCall == c) + calltab_select_call (tab, NULL); - void -calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) -{ + update_actions(); - GtkTreeIter iter; - GValue val; - callable_obj_t * iterCall; - GtkTreeStore* store = tab->store; - - if(!c) - ERROR("CallTree: Error: Not a valid call"); - - DEBUG("CallTree: Remove call %s", c->_callID); - - int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); - int i; - for( i = 0; i < nbChild; i++) - { - if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, parent, i)) - { - if(gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter)) - { - calltree_remove_call (tab, c, &iter); - } - - val.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, COLUMN_ACCOUNT_PTR, &val); - - iterCall = (callable_obj_t*) g_value_get_pointer(&val); - g_value_unset(&val); - - if(iterCall == c) - { - gtk_tree_store_remove(store, &iter); - } - } - } - callable_obj_t * selectedCall = calltab_get_selected_call(tab); - if(selectedCall == c) - calltab_select_call(tab, NULL); - update_actions(); - - calltree_update_clock(); - - DEBUG("Calltre remove call ended"); + calltree_update_clock(); + + DEBUG ("Calltre remove call ended"); } void @@ -698,169 +695,180 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) gchar* srtp_enabled = ""; gboolean display_sas = TRUE; - gboolean sdes_success = TRUE; account_t* account_details=NULL; gchar *audio_codec = ""; - int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); + int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); int i; - if(c != NULL) { - account_details = account_list_get_by_id(c->_accountID); - if(account_details != NULL) { - srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - if(g_strcasecmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - { display_sas = FALSE; } - } else { - GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); - if(properties != NULL) { - srtp_enabled = g_hash_table_lookup(properties, ACCOUNT_SRTP_ENABLED); - if(g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - { display_sas = FALSE; } - } - } - } - - for( i = 0; i < nbChild; i++) { - - if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, parent, i)) { - - if(gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter)) { - calltree_update_call (tab, c, &iter); - } - - val.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, COLUMN_ACCOUNT_PTR, &val); - - - iterCall = (callable_obj_t*) g_value_get_pointer(&val); - g_value_unset(&val); - - if(iterCall != c) { - continue; - } - - /* Update text */ - gchar * description; - gchar * date=""; - gchar * duration=""; - audio_codec = call_get_audio_codec (c); - - if(c->_state == CALL_STATE_TRANSFERT) { - - calltree_display_call_info(c, DISPLAY_TYPE_CALL_TRANSFER, NULL, &description); - - } - else { - - if((c->_sas != NULL) && (display_sas == TRUE) && (c->_srtp_state == SRTP_STATE_ZRTP_SAS_UNCONFIRMED) && (c->_zrtp_confirmed == FALSE)) { - calltree_display_call_info(c, DISPLAY_TYPE_SAS, NULL, &description); - } else { - calltree_display_call_info(c, DISPLAY_TYPE_STATE_CODE, audio_codec, &description); - } - } - - /* Update icons */ - if( tab == current_calls ) { - DEBUG("Receiving in state %d", c->_state); - switch(c->_state) { - case CALL_STATE_HOLD: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL); - break; - case CALL_STATE_INCOMING: - case CALL_STATE_RINGING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); - break; - case CALL_STATE_CURRENT: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL); - break; - case CALL_STATE_DIALING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL); - break; - case CALL_STATE_FAILURE: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL); - break; - case CALL_STATE_BUSY: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/busy.svg", NULL); - break; - case CALL_STATE_TRANSFERT: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/transfert.svg", NULL); - break; - case CALL_STATE_RECORD: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/icon_rec.svg", NULL); - break; - default: - WARN("Update calltree - Should not happen!"); - } - - switch(c->_srtp_state) { - case SRTP_STATE_SDES_SUCCESS: - DEBUG("SDES negotiation succes"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_confirmed.svg", NULL); - break; - case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: - DEBUG("Secure is ON"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_unconfirmed.svg", NULL); - if(c->_sas != NULL) { DEBUG("SAS is ready with value %s", c->_sas); } - break; - case SRTP_STATE_ZRTP_SAS_CONFIRMED: - DEBUG("SAS is confirmed"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_confirmed.svg", NULL); - break; - case SRTP_STATE_ZRTP_SAS_SIGNED: - DEBUG("Secure is ON with SAS signed and verified"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_certified.svg", NULL); - break; - case SRTP_STATE_UNLOCKED: - DEBUG("Secure is off calltree %d", c->_state); - if(g_strcasecmp(srtp_enabled,"true") == 0) { - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); - } - break; - default: - WARN("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); - if(g_strcasecmp(srtp_enabled,"true") == 0) { - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); - } - - } - - } - else if(tab == history) { - switch(c->_history_state) { - case INCOMING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/incoming.svg", NULL); - break; - case OUTGOING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/outgoing.svg", NULL); - break; - case MISSED: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/missed.svg", NULL); - break; - default: - WARN("History - Should not happen!"); - } - - calltree_display_call_info(c, DISPLAY_TYPE_HISTORY, NULL, &description); - - date = get_formatted_start_timestamp (c); - duration = get_call_duration (c); - duration = g_strconcat( date , duration , NULL); - description = g_strconcat( description , duration, NULL); - } - - gtk_tree_store_set(store, &iter, - 0, pixbuf, // Icon - 1, description, // Description - 2, pixbuf_security, - 3, c, - -1); - - if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); - } - + if (c != NULL) { + account_details = account_list_get_by_id (c->_accountID); + + if (account_details != NULL) { + srtp_enabled = g_hash_table_lookup (account_details->properties, ACCOUNT_SRTP_ENABLED); + + if (g_strcasecmp (g_hash_table_lookup (account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) { + display_sas = FALSE; + } + } else { + GHashTable * properties = NULL; + sflphone_get_ip2ip_properties (&properties); + + if (properties != NULL) { + srtp_enabled = g_hash_table_lookup (properties, ACCOUNT_SRTP_ENABLED); + + if (g_strcasecmp (g_hash_table_lookup (properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) { + display_sas = FALSE; + } + } + } + } + + for (i = 0; i < nbChild; i++) { + + if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, parent, i)) { + + if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (store), &iter)) { + calltree_update_call (tab, c, &iter); + } + + val.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter, COLUMN_ACCOUNT_PTR, &val); + + + iterCall = (callable_obj_t*) g_value_get_pointer (&val); + g_value_unset (&val); + + if (iterCall != c) { + continue; + } + + /* Update text */ + gchar * description; + gchar * date=""; + gchar * duration=""; + audio_codec = call_get_audio_codec (c); + + if (c->_state == CALL_STATE_TRANSFERT) { + + calltree_display_call_info (c, DISPLAY_TYPE_CALL_TRANSFER, NULL, &description); + + } else { + + if ( (c->_sas != NULL) && (display_sas == TRUE) && (c->_srtp_state == SRTP_STATE_ZRTP_SAS_UNCONFIRMED) && (c->_zrtp_confirmed == FALSE)) { + calltree_display_call_info (c, DISPLAY_TYPE_SAS, NULL, &description); + } else { + calltree_display_call_info (c, DISPLAY_TYPE_STATE_CODE, audio_codec, &description); + } + } + + /* Update icons */ + if (tab == current_calls) { + DEBUG ("Receiving in state %d", c->_state); + + switch (c->_state) { + case CALL_STATE_HOLD: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/hold.svg", NULL); + break; + case CALL_STATE_INCOMING: + case CALL_STATE_RINGING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/ring.svg", NULL); + break; + case CALL_STATE_CURRENT: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/current.svg", NULL); + break; + case CALL_STATE_DIALING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/dial.svg", NULL); + break; + case CALL_STATE_FAILURE: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/fail.svg", NULL); + break; + case CALL_STATE_BUSY: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/busy.svg", NULL); + break; + case CALL_STATE_TRANSFERT: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/transfert.svg", NULL); + break; + case CALL_STATE_RECORD: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/icon_rec.svg", NULL); + break; + default: + WARN ("Update calltree - Should not happen!"); + } + + switch (c->_srtp_state) { + case SRTP_STATE_SDES_SUCCESS: + DEBUG ("SDES negotiation succes"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_confirmed.svg", NULL); + break; + case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: + DEBUG ("Secure is ON"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_unconfirmed.svg", NULL); + + if (c->_sas != NULL) { + DEBUG ("SAS is ready with value %s", c->_sas); + } + + break; + case SRTP_STATE_ZRTP_SAS_CONFIRMED: + DEBUG ("SAS is confirmed"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_confirmed.svg", NULL); + break; + case SRTP_STATE_ZRTP_SAS_SIGNED: + DEBUG ("Secure is ON with SAS signed and verified"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_certified.svg", NULL); + break; + case SRTP_STATE_UNLOCKED: + DEBUG ("Secure is off calltree %d", c->_state); + + if (g_strcasecmp (srtp_enabled,"true") == 0) { + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_off.svg", NULL); + } + + break; + default: + WARN ("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); + + if (g_strcasecmp (srtp_enabled,"true") == 0) { + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_off.svg", NULL); + } + + } + + } else if (tab == history) { + switch (c->_history_state) { + case INCOMING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/incoming.svg", NULL); + break; + case OUTGOING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/outgoing.svg", NULL); + break; + case MISSED: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/missed.svg", NULL); + break; + default: + WARN ("History - Should not happen!"); + } + + calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, NULL, &description); + + date = get_formatted_start_timestamp (c); + duration = get_call_duration (c); + duration = g_strconcat (date , duration , NULL); + description = g_strconcat (description , duration, NULL); + } + + gtk_tree_store_set (store, &iter, + 0, pixbuf, // Icon + 1, description, // Description + 2, pixbuf_security, + 3, c, + -1); + + if (pixbuf != NULL) + g_object_unref (G_OBJECT (pixbuf)); + } + } update_actions(); @@ -870,191 +878,184 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) { - DEBUG("CallTree: Add call to calltree id: %s, peer name: %s", c->_callID, c->_peer_name); - - if (tab == history) - { - calltree_add_history_entry (c); - return; - } - - account_t* account_details=NULL; - - GdkPixbuf *pixbuf=NULL; - GdkPixbuf *pixbuf_security=NULL; - GtkTreeIter iter; - gchar* key_exchange=""; - gchar* srtp_enabled=""; - - // New call in the list - gchar * description; - gchar * date=""; - gchar *duration=""; - - calltree_display_call_info(c, DISPLAY_TYPE_CALL, NULL, &description); - - gtk_tree_store_prepend (tab->store, &iter, parent); - - if(c != NULL) { - account_details = account_list_get_by_id(c->_callID); - if(account_details != NULL) { - srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - key_exchange = g_hash_table_lookup(account_details->properties, ACCOUNT_KEY_EXCHANGE); - } - } - - DEBUG("Added call key exchange is %s", key_exchange); - - if( tab == current_calls ) - { - switch(c->_state) - { - case CALL_STATE_INCOMING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); - break; - case CALL_STATE_DIALING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL); - break; - case CALL_STATE_RINGING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); - break; - case CALL_STATE_CURRENT: - // If the call has been initiated by a another client and, when we start, it is already current - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL); - break; - case CALL_STATE_HOLD: - // If the call has been initiated by a another client and, when we start, it is already current - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL); - break; - case CALL_STATE_FAILURE: - // If the call has been initiated by a another client and, when we start, it is already current - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL); - break; - default: - WARN("Update calltree add - Should not happen!"); - } - - if(g_strcasecmp(srtp_enabled,"true") == 0) { - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/secure_off.svg", NULL); - } - } - - else if (tab == contacts) { - pixbuf = c->_contact_thumbnail; - description = g_strconcat( description , NULL); - } - - else { - WARN ("This widget doesn't exist - This is a bug in the application."); - } - - - //Resize it - if(pixbuf) - { - if(gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32) - { - pixbuf = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_BILINEAR); - } - } - - if(pixbuf_security) - { - if(gdk_pixbuf_get_width(pixbuf_security) > 32 || gdk_pixbuf_get_height(pixbuf_security) > 32) - { - pixbuf_security = gdk_pixbuf_scale_simple(pixbuf_security, 32, 32, GDK_INTERP_BILINEAR); - } - } - - gtk_tree_store_set(tab->store, &iter, - 0, pixbuf, // Icon - 1, description, // Description - 2, pixbuf_security, // Informs user about the state of security - 3, c, // Pointer - -1); - - if (pixbuf != NULL) - { g_object_unref(G_OBJECT(pixbuf)); } - if (pixbuf_security != NULL) - { g_object_unref(G_OBJECT(pixbuf)); } - - gtk_tree_view_set_model (GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(history->store)); - - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(tab->view)), &iter); - - history_reinit(history); + DEBUG ("CallTree: Add call to calltree id: %s, peer name: %s", c->_callID, c->_peer_name); + + if (tab == history) { + calltree_add_history_entry (c); + return; + } + + account_t* account_details=NULL; + + GdkPixbuf *pixbuf=NULL; + GdkPixbuf *pixbuf_security=NULL; + GtkTreeIter iter; + gchar* key_exchange=""; + gchar* srtp_enabled=""; + + // New call in the list + gchar * description; + + calltree_display_call_info (c, DISPLAY_TYPE_CALL, NULL, &description); + + gtk_tree_store_prepend (tab->store, &iter, parent); + + if (c != NULL) { + account_details = account_list_get_by_id (c->_callID); + + if (account_details != NULL) { + srtp_enabled = g_hash_table_lookup (account_details->properties, ACCOUNT_SRTP_ENABLED); + key_exchange = g_hash_table_lookup (account_details->properties, ACCOUNT_KEY_EXCHANGE); + } + } + + DEBUG ("Added call key exchange is %s", key_exchange); + + if (tab == current_calls) { + switch (c->_state) { + case CALL_STATE_INCOMING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/ring.svg", NULL); + break; + case CALL_STATE_DIALING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/dial.svg", NULL); + break; + case CALL_STATE_RINGING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/ring.svg", NULL); + break; + case CALL_STATE_CURRENT: + // If the call has been initiated by a another client and, when we start, it is already current + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/current.svg", NULL); + break; + case CALL_STATE_HOLD: + // If the call has been initiated by a another client and, when we start, it is already current + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/hold.svg", NULL); + break; + case CALL_STATE_FAILURE: + // If the call has been initiated by a another client and, when we start, it is already current + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/fail.svg", NULL); + break; + default: + WARN ("Update calltree add - Should not happen!"); + } + + if (g_strcasecmp (srtp_enabled,"true") == 0) { + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/secure_off.svg", NULL); + } + } + + else if (tab == contacts) { + pixbuf = c->_contact_thumbnail; + description = g_strconcat (description , NULL); + } + + else { + WARN ("This widget doesn't exist - This is a bug in the application."); + } + + + //Resize it + if (pixbuf) { + if (gdk_pixbuf_get_width (pixbuf) > 32 || gdk_pixbuf_get_height (pixbuf) > 32) { + pixbuf = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR); + } + } + + if (pixbuf_security) { + if (gdk_pixbuf_get_width (pixbuf_security) > 32 || gdk_pixbuf_get_height (pixbuf_security) > 32) { + pixbuf_security = gdk_pixbuf_scale_simple (pixbuf_security, 32, 32, GDK_INTERP_BILINEAR); + } + } + + gtk_tree_store_set (tab->store, &iter, + 0, pixbuf, // Icon + 1, description, // Description + 2, pixbuf_security, // Informs user about the state of security + 3, c, // Pointer + -1); + + if (pixbuf != NULL) { + g_object_unref (G_OBJECT (pixbuf)); + } + + if (pixbuf_security != NULL) { + g_object_unref (G_OBJECT (pixbuf)); + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (history->view), GTK_TREE_MODEL (history->store)); + + gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (tab->view)), &iter); + + history_reinit (history); } void calltree_add_history_entry (callable_obj_t * c) { - DEBUG("calltree_add_history_entry %s", c->_callID); - - if (!eel_gconf_get_integer (HISTORY_ENABLED)) - return; - - GdkPixbuf *pixbuf=NULL; - GdkPixbuf *pixbuf_security=NULL; - GtkTreeIter iter; - - // New call in the list - gchar * description, *date="", *duration=""; - - calltree_display_call_info(c, DISPLAY_TYPE_HISTORY, NULL, &description); - - gtk_tree_store_prepend (history->store, &iter, NULL); - - switch(c->_history_state) - { - case INCOMING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/incoming.svg", NULL); - break; - case OUTGOING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/outgoing.svg", NULL); - break; - case MISSED: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/missed.svg", NULL); - break; - default: - WARN("History - Should not happen!"); - } - - date = get_formatted_start_timestamp (c); - duration = get_call_duration (c); - duration = g_strconcat( date , duration , NULL); - description = g_strconcat( description , duration, NULL); - - //Resize it - if(pixbuf) - { - if(gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32) - { - pixbuf = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_BILINEAR); - } - } - - if(pixbuf_security != NULL) - { - if(gdk_pixbuf_get_width(pixbuf_security) > 32 || gdk_pixbuf_get_height(pixbuf_security) > 32) - { - pixbuf_security = gdk_pixbuf_scale_simple(pixbuf_security, 32, 32, GDK_INTERP_BILINEAR); - } - } - gtk_tree_store_set(history->store, &iter, - 0, pixbuf, // Icon - 1, description, // Description - 2, pixbuf_security, // Icon - 3, c, // Pointer - -1); - - if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); - if (pixbuf_security != NULL) - { g_object_unref(G_OBJECT(pixbuf_security)); } - - gtk_tree_view_set_model (GTK_TREE_VIEW(history->view), GTK_TREE_MODEL(history->store)); - - history_reinit(history); + DEBUG ("calltree_add_history_entry %s", c->_callID); + + if (!eel_gconf_get_integer (HISTORY_ENABLED)) + return; + + GdkPixbuf *pixbuf=NULL; + GdkPixbuf *pixbuf_security=NULL; + GtkTreeIter iter; + + // New call in the list + gchar * description, *date="", *duration=""; + + calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, NULL, &description); + + gtk_tree_store_prepend (history->store, &iter, NULL); + + switch (c->_history_state) { + case INCOMING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/incoming.svg", NULL); + break; + case OUTGOING: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/outgoing.svg", NULL); + break; + case MISSED: + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/missed.svg", NULL); + break; + default: + WARN ("History - Should not happen!"); + } + + date = get_formatted_start_timestamp (c); + duration = get_call_duration (c); + duration = g_strconcat (date , duration , NULL); + description = g_strconcat (description , duration, NULL); + + //Resize it + if (pixbuf) { + if (gdk_pixbuf_get_width (pixbuf) > 32 || gdk_pixbuf_get_height (pixbuf) > 32) { + pixbuf = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR); + } + } + + if (pixbuf_security != NULL) { + if (gdk_pixbuf_get_width (pixbuf_security) > 32 || gdk_pixbuf_get_height (pixbuf_security) > 32) { + pixbuf_security = gdk_pixbuf_scale_simple (pixbuf_security, 32, 32, GDK_INTERP_BILINEAR); + } + } + + gtk_tree_store_set (history->store, &iter, + 0, pixbuf, // Icon + 1, description, // Description + 2, pixbuf_security, // Icon + 3, c, // Pointer + -1); + + if (pixbuf != NULL) + g_object_unref (G_OBJECT (pixbuf)); + + if (pixbuf_security != NULL) { + g_object_unref (G_OBJECT (pixbuf_security)); + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (history->view), GTK_TREE_MODEL (history->store)); + + history_reinit (history); } @@ -1065,7 +1066,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) GdkPixbuf *pixbuf_security=NULL; GtkTreeIter iter; GtkTreePath *path; - GtkTreeModel *model = (GtkTreeModel*)active_calltree->store; + GtkTreeModel *model = (GtkTreeModel*) active_calltree->store; // gchar** participant = dbus_get_participant_list(conf->_confID); // gchar** pl; @@ -1078,211 +1079,205 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) gchar* srtp_enabled=""; // New call in the list - + gchar * description; - if(!conf) { - ERROR("Calltree: Error: Conference is null!!"); - return; + if (!conf) { + ERROR ("Calltree: Error: Conference is null!!"); + return; } - DEBUG("Calltree: Add conference %s", conf->_confID); + DEBUG ("Calltree: Add conference %s", conf->_confID); // description = g_markup_printf_escaped("<b>%s</b>", conf->_confID); - description = g_markup_printf_escaped("<b>%s</b>", ""); + description = g_markup_printf_escaped ("<b>%s</b>", ""); gtk_tree_store_append (tab->store, &iter, NULL); - if( tab == current_calls ) - { - - switch(conf->_state) - { - case CONFERENCE_STATE_ACTIVE_ATACHED: - { - - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/usersActive.svg", NULL); - break; - } - case CONFERENCE_STATE_ACTIVE_DETACHED: - case CONFERENCE_STATE_HOLD: - { - - - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/users.svg", NULL); - break; - } - default: - WARN("Update conference add - Should not happen!"); - } - } - else - { - DEBUG("Error Conference State NULL for conferece %s!!!!!", conf->_confID); + if (tab == current_calls) { + + switch (conf->_state) { + case CONFERENCE_STATE_ACTIVE_ATACHED: { + + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/usersActive.svg", NULL); + break; + } + case CONFERENCE_STATE_ACTIVE_DETACHED: + case CONFERENCE_STATE_HOLD: { + + + pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/users.svg", NULL); + break; + } + default: + WARN ("Update conference add - Should not happen!"); + } + } else { + DEBUG ("Error Conference State NULL for conferece %s!!!!!", conf->_confID); } //Resize it - if(pixbuf) { - if(gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32) { - pixbuf = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_BILINEAR); - } + if (pixbuf) { + if (gdk_pixbuf_get_width (pixbuf) > 32 || gdk_pixbuf_get_height (pixbuf) > 32) { + pixbuf = gdk_pixbuf_scale_simple (pixbuf, 32, 32, GDK_INTERP_BILINEAR); + } + } else { + DEBUG ("Error no pixbuff for conference from %s", ICONS_DIR); } - else { - DEBUG("Error no pixbuff for conference from %s", ICONS_DIR); - } - + // Used to determine if at least one participant use a security feature - // If true (at least on call use a security feature) we need to display security icons + // If true (at least on call use a security feature) we need to display security icons conf->_conf_srtp_enabled = FALSE; - + // Used to determine if the conference is secured // Every participant to a conference must be secured, the conference is not secured elsewhere conf->_conference_secured = TRUE; - DEBUG("Calltree: Determine if conference is secured"); - + DEBUG ("Calltree: Determine if conference is secured"); + // participant = conf->participant; // participant = dbus_get_participant_list(conf->_confID); conference_participant = conf->participant_list; - if(conference_participant) { - - DEBUG("Calltree: Determine if at least one participant uses SRTP"); - - // participant = conf->participant; - // participant = dbus_get_participant_list(conf->_confID); - // for (pl = participant; *pl; pl++) - while(conference_participant) { - - // call_id = (gchar*)(*pl); - call_id = (gchar*)(conference_participant->data); - call = calllist_get (tab, call_id); - - if(call != NULL) { - - account_details = account_list_get_by_id(call->_callID); - if(account_details != NULL) { - srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - } - - if(g_strcasecmp(srtp_enabled,"true") == 0) { - DEBUG("Calltree: SRTP enabled for participant %s", call_id); - conf->_conf_srtp_enabled = TRUE; - break; - } - else { - DEBUG("Calltree: SRTP is not enabled for participant %s", call_id); - } - - } - - conference_participant = conference_next_participant(conference_participant); - - } - - DEBUG("Calltree: Determine if all conference participant are secured"); - - if(conf->_conf_srtp_enabled) { - // participant = conf->participant; - conference_participant = conf->participant_list; - // for (pl = participant; *pl; pl++) - while(conference_participant) { - // call_id = (gchar*)(*pl); - call_id = (gchar*)(conference_participant->data); - call = calllist_get (tab, call_id); - - if(call != NULL) { - - if(call->_srtp_state == 0) { - DEBUG("Calltree: Participant %s is not secured", call_id); - conf->_conference_secured = FALSE; - break; - } - else { - DEBUG("Calltree: Participant %s is secured", call_id); - } - } - conference_participant = conference_next_participant(conference_participant); - } - } + + if (conference_participant) { + + DEBUG ("Calltree: Determine if at least one participant uses SRTP"); + + // participant = conf->participant; + // participant = dbus_get_participant_list(conf->_confID); + // for (pl = participant; *pl; pl++) + while (conference_participant) { + + // call_id = (gchar*)(*pl); + call_id = (gchar*) (conference_participant->data); + call = calllist_get (tab, call_id); + + if (call != NULL) { + + account_details = account_list_get_by_id (call->_callID); + + if (account_details != NULL) { + srtp_enabled = g_hash_table_lookup (account_details->properties, ACCOUNT_SRTP_ENABLED); + } + + if (g_strcasecmp (srtp_enabled,"true") == 0) { + DEBUG ("Calltree: SRTP enabled for participant %s", call_id); + conf->_conf_srtp_enabled = TRUE; + break; + } else { + DEBUG ("Calltree: SRTP is not enabled for participant %s", call_id); + } + + } + + conference_participant = conference_next_participant (conference_participant); + + } + + DEBUG ("Calltree: Determine if all conference participant are secured"); + + if (conf->_conf_srtp_enabled) { + // participant = conf->participant; + conference_participant = conf->participant_list; + + // for (pl = participant; *pl; pl++) + while (conference_participant) { + // call_id = (gchar*)(*pl); + call_id = (gchar*) (conference_participant->data); + call = calllist_get (tab, call_id); + + if (call != NULL) { + + if (call->_srtp_state == 0) { + DEBUG ("Calltree: Participant %s is not secured", call_id); + conf->_conference_secured = FALSE; + break; + } else { + DEBUG ("Calltree: Participant %s is secured", call_id); + } + } + + conference_participant = conference_next_participant (conference_participant); + } + } } - if(conf->_conf_srtp_enabled) { - if(conf->_conference_secured) { - DEBUG("Calltree: Conference is secured"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_confirmed.svg", NULL); - } - else { - DEBUG("Calltree: Conference is not secured"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); - } + if (conf->_conf_srtp_enabled) { + if (conf->_conference_secured) { + DEBUG ("Calltree: Conference is secured"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_confirmed.svg", NULL); + } else { + DEBUG ("Calltree: Conference is not secured"); + pixbuf_security = gdk_pixbuf_new_from_file (ICONS_DIR "/lock_off.svg", NULL); + } } - - DEBUG("Calltree: Add conference to tree store"); - - gtk_tree_store_set(tab->store, &iter, - 0, pixbuf, // Icon - 1, description, // Description - 2, pixbuf_security, - 3, conf, // Pointer - -1); + + DEBUG ("Calltree: Add conference to tree store"); + + gtk_tree_store_set (tab->store, &iter, + 0, pixbuf, // Icon + 1, description, // Description + 2, pixbuf_security, + 3, conf, // Pointer + -1); if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); - + g_object_unref (G_OBJECT (pixbuf)); + // participant = conf->participant; // participant = dbus_get_participant_list(conf->_confID); conference_participant = conf->participant_list; - if(conference_participant) { - - DEBUG("Calltre: Adding conference participant"); - // for (pl = participant; *pl; pl++) - while(conference_participant) { - - DEBUG("OK"); - call_id = (gchar*)(conference_participant->data); - call = calllist_get (tab, call_id); - // create_new_call_from_details (conf_id, conference_details, &c); - - calltree_remove_call(tab, call, NULL); - calltree_add_call (tab, call, &iter); - - conference_participant = conference_next_participant(conference_participant); - } + + if (conference_participant) { + + DEBUG ("Calltre: Adding conference participant"); + + // for (pl = participant; *pl; pl++) + while (conference_participant) { + + DEBUG ("OK"); + call_id = (gchar*) (conference_participant->data); + call = calllist_get (tab, call_id); + // create_new_call_from_details (conf_id, conference_details, &c); + + calltree_remove_call (tab, call, NULL); + calltree_add_call (tab, call, &iter); + + conference_participant = conference_next_participant (conference_participant); + } } + /* - else - { - WARN ("Conferences cannot be added in this widget - This is a bug in the application."); - } + else + { + WARN ("Conferences cannot be added in this widget - This is a bug in the application."); + } */ - gtk_tree_view_set_model(GTK_TREE_VIEW(tab->view), GTK_TREE_MODEL(tab->store)); + gtk_tree_view_set_model (GTK_TREE_VIEW (tab->view), GTK_TREE_MODEL (tab->store)); - path = gtk_tree_model_get_path(model, &iter); + path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_expand_row(GTK_TREE_VIEW(tab->view), path, FALSE); + gtk_tree_view_expand_row (GTK_TREE_VIEW (tab->view), path, FALSE); update_actions(); } -void calltree_update_conference (calltab_t* tab, const gchar* confID) +void calltree_update_conference (calltab_t* tab UNUSED, const gchar* confID UNUSED) { - - DEBUG("calltree_update_conference"); - - + DEBUG ("calltree_update_conference"); } void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent) { - DEBUG("calltree_remove_conference %s\n", conf->_confID); - + DEBUG ("calltree_remove_conference %s\n", conf->_confID); + GtkTreeIter iter_parent; GtkTreeIter iter_child; GValue confval; @@ -1291,50 +1286,53 @@ void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, G callable_obj_t * call; GtkTreeStore* store = tab->store; - int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); + int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); int nbParticipant; int i, j; - for( i = 0; i < nbChild; i++) { - if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter_parent, parent, i)) { + for (i = 0; i < nbChild; i++) { + + if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_parent, parent, i)) { + + if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (store), &iter_parent)) { + + calltree_remove_conference (tab, conf, &iter_parent); - if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter_parent)) { + confval.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter_parent, COLUMN_ACCOUNT_PTR, &confval); - calltree_remove_conference (tab, conf, &iter_parent); + tempconf = (conference_obj_t*) g_value_get_pointer (&confval); + g_value_unset (&confval); - confval.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter_parent, COLUMN_ACCOUNT_PTR, &confval); + if (tempconf == conf) { - tempconf = (conference_obj_t*) g_value_get_pointer(&confval); - g_value_unset(&confval); + nbParticipant = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), &iter_parent); + DEBUG ("nbParticipant: %i", nbParticipant); - if(tempconf == conf) { - - nbParticipant = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), &iter_parent); - DEBUG("nbParticipant: %i", nbParticipant); - for( j = 0; j < nbParticipant; j++) { - call = NULL; - if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter_child, &iter_parent, j)){ + for (j = 0; j < nbParticipant; j++) { + call = NULL; - callval.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter_child, COLUMN_ACCOUNT_PTR, &callval); + if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_child, &iter_parent, j)) { - call = (callable_obj_t*)g_value_get_pointer(&callval); - g_value_unset(&callval); - - if(call) { - calltree_add_call (tab, call, NULL); - } - } - - } + callval.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL (store), &iter_child, COLUMN_ACCOUNT_PTR, &callval); - gtk_tree_store_remove(store, &iter_parent); - } - } - } + call = (callable_obj_t*) g_value_get_pointer (&callval); + g_value_unset (&callval); + + if (call) { + calltree_add_call (tab, call, NULL); + } + } + + } + + gtk_tree_store_remove (store, &iter_parent); + } + } + } } // callable_obj_t * selectedCall = calltab_get_selected_call(tab); @@ -1342,13 +1340,14 @@ void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, G // calltab_select_call(tab, NULL); update_actions(); - + } -void calltree_display (calltab_t *tab) { +void calltree_display (calltab_t *tab) +{ + - GtkTreeSelection *sel; /* If we already are displaying the specified calltree */ @@ -1361,12 +1360,13 @@ void calltree_display (calltab_t *tab) { DEBUG ("display main tab"); - if (active_calltree==contacts) { - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, FALSE); - } else { - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, FALSE); - } - // gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)currentCallsButton, TRUE); + if (active_calltree==contacts) { + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton, FALSE); + } else { + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) historyButton, FALSE); + } + + // gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)currentCallsButton, TRUE); } @@ -1375,448 +1375,428 @@ void calltree_display (calltab_t *tab) { DEBUG ("display history tab"); - if (active_calltree==contacts) { - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, FALSE); - } + if (active_calltree==contacts) { + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton, FALSE); + } - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, TRUE); + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) historyButton, TRUE); } else if (tab==contacts) { DEBUG ("display contact tab"); - if (active_calltree==history) { - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, FALSE); - } + if (active_calltree==history) { + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) historyButton, FALSE); + } - gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, TRUE); + gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton, TRUE); } else ERROR ("calltree.c line %d . This is probably a bug in the application", __LINE__); - + gtk_widget_hide (active_calltree->tree); active_calltree = tab; gtk_widget_show (active_calltree->tree); - + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view)); - DEBUG("Emit signal changed from calltree_display"); - g_signal_emit_by_name(sel, "changed"); + DEBUG ("Emit signal changed from calltree_display"); + g_signal_emit_by_name (sel, "changed"); update_actions(); } -void calltree_update_clock() { - - callable_obj_t *c = calltab_get_selected_call(current_calls); - - // if(!selected_call) { - if(!c) { - statusbar_update_clock(""); - return; - } - - // if(!(selected_call->_timestr)) { - if(!(c->_timestr)) { - statusbar_update_clock(""); - return; - } - - if( (c->_state != CALL_STATE_INVALID) && - (c->_state != CALL_STATE_INCOMING) && - (c->_state != CALL_STATE_RINGING) && - (c->_state != CALL_STATE_DIALING) && - (c->_state != CALL_STATE_FAILURE) && - (c->_state != CALL_STATE_BUSY) ) { - - // TODO this make the whole thing crash... - // calltree_update_call(current_calls, c, NULL); - statusbar_update_clock(c->_timestr); - } - else { - statusbar_update_clock(""); - } -} +void calltree_update_clock() +{ + callable_obj_t *c = calltab_get_selected_call (current_calls); -static void drag_begin_cb(GtkWidget *widget, GdkDragContext *dc, gpointer data) -{ + // if(!selected_call) { + if (!c) { + statusbar_update_clock (""); + return; + } + + // if(!(selected_call->_timestr)) { + if (! (c->_timestr)) { + statusbar_update_clock (""); + return; + } + + if ( (c->_state != CALL_STATE_INVALID) && + (c->_state != CALL_STATE_INCOMING) && + (c->_state != CALL_STATE_RINGING) && + (c->_state != CALL_STATE_DIALING) && + (c->_state != CALL_STATE_FAILURE) && + (c->_state != CALL_STATE_BUSY)) { + + // TODO this make the whole thing crash... + statusbar_update_clock (c->_timestr); + } else { + statusbar_update_clock (""); + } +} - GtkTargetList* target_list; +static void drag_begin_cb (GtkWidget *widget UNUSED, GdkDragContext *dc UNUSED, gpointer data UNUSED) +{ } -static void drag_end_cb(GtkWidget * widget, GdkDragContext * context, gpointer data) +static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNUSED, gpointer data UNUSED) { - DEBUG("CallTree: Drag end callback"); - DEBUG("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", - selected_path, selected_call_id, selected_path_depth); - DEBUG("CallTree: dragged path %s, dragged_call_id %s, dragged_path_depth %d", - dragged_path, dragged_call_id, dragged_path_depth); - - GtkTreeModel *model = (GtkTreeModel*)current_calls->store; - GtkTreePath *path = gtk_tree_path_new_from_string(dragged_path); - GtkTreePath *dpath = gtk_tree_path_new_from_string(dragged_path); - GtkTreePath *spath = gtk_tree_path_new_from_string(selected_path); - + DEBUG ("CallTree: Drag end callback"); + DEBUG ("CallTree: selected_path %s, selected_call_id %s, selected_path_depth %d", + selected_path, selected_call_id, selected_path_depth); + DEBUG ("CallTree: dragged path %s, dragged_call_id %s, dragged_path_depth %d", + dragged_path, dragged_call_id, dragged_path_depth); + + GtkTreeModel *model = (GtkTreeModel*) current_calls->store; + GtkTreePath *path = gtk_tree_path_new_from_string (dragged_path); + GtkTreePath *dpath = gtk_tree_path_new_from_string (dragged_path); + GtkTreePath *spath = gtk_tree_path_new_from_string (selected_path); + GtkTreeIter iter; - GtkTreeIter iter_parent; - GtkTreeIter iter_children; GtkTreeIter parent_conference; // conference for which this call is attached GValue val; - - callable_obj_t* call; + conference_obj_t* conf; // Make sure drag n drop does not imply a dialing call for either selected and dragged call - if(selected_call && (selected_type == A_CALL)) { - - DEBUG("CallTree: Selected a call"); - if(selected_call->_state == CALL_STATE_DIALING || - selected_call->_state == CALL_STATE_INVALID || - selected_call->_state == CALL_STATE_FAILURE || - selected_call->_state == CALL_STATE_BUSY || - selected_call->_state == CALL_STATE_TRANSFERT) { - - DEBUG("CallTree: Selected an invalid call"); - - calltree_remove_call(current_calls, selected_call, NULL); - calltree_add_call(current_calls, selected_call, NULL); - - dragged_call = NULL; - return; - } - - - if(dragged_call && (dragged_type == A_CALL)) { - - DEBUG("CallTree: Dragged on a call"); - if(dragged_call->_state == CALL_STATE_DIALING || - dragged_call->_state == CALL_STATE_INVALID || - dragged_call->_state == CALL_STATE_FAILURE || - dragged_call->_state == CALL_STATE_BUSY || - dragged_call->_state == CALL_STATE_TRANSFERT) { - - DEBUG("CallTree: Dragged on an invalid call"); - - calltree_remove_call(current_calls, selected_call, NULL); - - if(selected_call->_confID) { - - gtk_tree_path_up(spath); - gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &parent_conference, spath); - - calltree_add_call(current_calls, selected_call, &parent_conference); - } - else { - - calltree_add_call(current_calls, selected_call, NULL); - } - - dragged_call = NULL; - return; - } - } + if (selected_call && (selected_type == A_CALL)) { + + DEBUG ("CallTree: Selected a call"); + + if (selected_call->_state == CALL_STATE_DIALING || + selected_call->_state == CALL_STATE_INVALID || + selected_call->_state == CALL_STATE_FAILURE || + selected_call->_state == CALL_STATE_BUSY || + selected_call->_state == CALL_STATE_TRANSFERT) { + + DEBUG ("CallTree: Selected an invalid call"); + + calltree_remove_call (current_calls, selected_call, NULL); + calltree_add_call (current_calls, selected_call, NULL); + + dragged_call = NULL; + return; + } + + + if (dragged_call && (dragged_type == A_CALL)) { + + DEBUG ("CallTree: Dragged on a call"); + + if (dragged_call->_state == CALL_STATE_DIALING || + dragged_call->_state == CALL_STATE_INVALID || + dragged_call->_state == CALL_STATE_FAILURE || + dragged_call->_state == CALL_STATE_BUSY || + dragged_call->_state == CALL_STATE_TRANSFERT) { + + DEBUG ("CallTree: Dragged on an invalid call"); + + calltree_remove_call (current_calls, selected_call, NULL); + + if (selected_call->_confID) { + + gtk_tree_path_up (spath); + gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &parent_conference, spath); + + calltree_add_call (current_calls, selected_call, &parent_conference); + } else { + + calltree_add_call (current_calls, selected_call, NULL); + } + + dragged_call = NULL; + return; + } + } } // Make sure a conference is only dragged on another conference - if(selected_conf && (selected_type == A_CONFERENCE)) { + if (selected_conf && (selected_type == A_CONFERENCE)) { - DEBUG("CallTree: Selected a conference"); + DEBUG ("CallTree: Selected a conference"); - if(!dragged_conf && (dragged_type == A_CALL)) { + if (!dragged_conf && (dragged_type == A_CALL)) { - DEBUG("CallTree: Dragged on a call"); + DEBUG ("CallTree: Dragged on a call"); - conf = selected_conf; + conf = selected_conf; - calltree_remove_conference(current_calls, conf, NULL); - calltree_add_conference(current_calls, conf); + calltree_remove_conference (current_calls, conf, NULL); + calltree_add_conference (current_calls, conf); - dragged_call = NULL; - return; - } + dragged_call = NULL; + return; + } } - if(selected_path_depth == 1) { + if (selected_path_depth == 1) { - if(dragged_path_depth == 1) { + if (dragged_path_depth == 1) { - if (selected_type == A_CALL && dragged_type == A_CALL) { + if (selected_type == A_CALL && dragged_type == A_CALL) { - if(gtk_tree_path_compare (dpath, spath) == 0) { - // draged a call on itself - } - else { - // dragged a single call on a single call - if(selected_call != NULL && dragged_call != NULL) - sflphone_join_participant(selected_call->_callID, dragged_call->_callID); - } - } - else if(selected_type == A_CALL && dragged_type == A_CONFERENCE) { + if (gtk_tree_path_compare (dpath, spath) == 0) { + // draged a call on itself + } else { + // dragged a single call on a single call + if (selected_call != NULL && dragged_call != NULL) + sflphone_join_participant (selected_call->_callID, dragged_call->_callID); + } + } else if (selected_type == A_CALL && dragged_type == A_CONFERENCE) { - // dragged a single call on a conference - if(!selected_call) { - DEBUG("Error: call dragged on a conference is null"); - return; - } + // dragged a single call on a conference + if (!selected_call) { + DEBUG ("Error: call dragged on a conference is null"); + return; + } - selected_call->_confID = g_strdup(dragged_call_id); - sflphone_add_participant(selected_call_id, dragged_call_id); - } - else if(selected_type == A_CONFERENCE && dragged_type == A_CALL) { + selected_call->_confID = g_strdup (dragged_call_id); + sflphone_add_participant (selected_call_id, dragged_call_id); + } else if (selected_type == A_CONFERENCE && dragged_type == A_CALL) { - // dragged a conference on a single call - conf = selected_conf; - - calltree_remove_conference(current_calls, conf, NULL); - calltree_add_conference(current_calls, conf); + // dragged a conference on a single call + conf = selected_conf; + calltree_remove_conference (current_calls, conf, NULL); + calltree_add_conference (current_calls, conf); - } - else if(selected_type == A_CONFERENCE && dragged_type == A_CONFERENCE){ - // dragged a conference on a conference - if(gtk_tree_path_compare (dpath, spath) == 0) { + } else if (selected_type == A_CONFERENCE && dragged_type == A_CONFERENCE) { - if(!current_calls) { - DEBUG("Error while joining the same conference\n"); - return; - } + // dragged a conference on a conference + if (gtk_tree_path_compare (dpath, spath) == 0) { - DEBUG("Joined the same conference!\n"); - gtk_tree_view_expand_row(GTK_TREE_VIEW(current_calls->view), path, FALSE); - } - else { + if (!current_calls) { + DEBUG ("Error while joining the same conference\n"); + return; + } - if(!selected_conf) { - DEBUG("Error: selected conference is null while joining 2 conference"); - } + DEBUG ("Joined the same conference!\n"); + gtk_tree_view_expand_row (GTK_TREE_VIEW (current_calls->view), path, FALSE); + } else { - if(!dragged_conf) { - DEBUG("Error: dragged conference is null while joining 2 conference"); - } + if (!selected_conf) { + DEBUG ("Error: selected conference is null while joining 2 conference"); + } - DEBUG("Joined two conference %s, %s!\n", dragged_path, selected_path); - sflphone_join_conference(selected_conf->_confID, dragged_conf->_confID); - } - } + if (!dragged_conf) { + DEBUG ("Error: dragged conference is null while joining 2 conference"); + } - // TODO: dragged a single call on a NULL element (should do nothing) - // TODO: dragged a conference on a NULL element (should do nothing) + DEBUG ("Joined two conference %s, %s!\n", dragged_path, selected_path); + sflphone_join_conference (selected_conf->_confID, dragged_conf->_confID); + } + } - } - else { - - // dragged_path_depth == 2 - if (selected_type == A_CALL && dragged_type == A_CALL) { + // TODO: dragged a single call on a NULL element (should do nothing) + // TODO: dragged a conference on a NULL element (should do nothing) - // TODO: dragged a call on a conference call - calltree_remove_call(current_calls, selected_call, NULL); - calltree_add_call(current_calls, selected_call, NULL); - } + } else { - else if(selected_type == A_CONFERENCE && dragged_type == A_CALL) { + // dragged_path_depth == 2 + if (selected_type == A_CALL && dragged_type == A_CALL) { - // TODO: dragged a conference on a conference call - calltree_remove_conference(current_calls, selected_conf, NULL); - calltree_add_conference(current_calls, selected_conf); - } + // TODO: dragged a call on a conference call + calltree_remove_call (current_calls, selected_call, NULL); + calltree_add_call (current_calls, selected_call, NULL); + } - // TODO: dragged a single call on a NULL element - // TODO: dragged a conference on a NULL element - } - } - else { + else if (selected_type == A_CONFERENCE && dragged_type == A_CALL) { + + // TODO: dragged a conference on a conference call + calltree_remove_conference (current_calls, selected_conf, NULL); + calltree_add_conference (current_calls, selected_conf); + } + + // TODO: dragged a single call on a NULL element + // TODO: dragged a conference on a NULL element + } + } else { // selected_path_depth == 2 - - if(dragged_path_depth == 1) { - - if(selected_type == A_CALL && dragged_type == A_CALL) { - - // dragged a conference call on a call - sflphone_detach_participant(selected_call_id); - - if(selected_call != NULL && dragged_call != NULL) - sflphone_join_participant(selected_call->_callID, dragged_call->_callID); - - } - else if(selected_type == A_CALL && dragged_type == A_CONFERENCE) { - - // dragged a conference call on a conference - sflphone_detach_participant(selected_call_id); - - if(selected_call != NULL && dragged_conf != NULL) { - - DEBUG("Adding a participant, since dragged call on a conference"); - - sflphone_add_participant(selected_call_id, dragged_call_id); - } - } - else { - - // dragged a conference call on a NULL element - sflphone_detach_participant(selected_call_id); - } - - } - else { - - // dragged_path_depth == 2 - // dragged a conference call on another conference call (same conference) - // TODO: dragged a conference call on another conference call (different conference) - - gtk_tree_path_up(path); - - gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &parent_conference, path); - - gtk_tree_path_up(dpath); - gtk_tree_path_up(spath); - - if(gtk_tree_path_compare (dpath, spath) == 0) { - - DEBUG("Dragged a call in the same conference"); - calltree_remove_call (current_calls, selected_call, NULL); - calltree_add_call (current_calls, selected_call, &parent_conference); - } - else { - - - DEBUG("Dragged a conference call onto another conference call %s, %s", gtk_tree_path_to_string(dpath), gtk_tree_path_to_string(spath)); - - conf = NULL; - - val.g_type = 0; - if(gtk_tree_model_get_iter (model, &iter, dpath)) { - - DEBUG("we got an iter!"); - gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); - - conf = (conference_obj_t*)g_value_get_pointer(&val); - } - g_value_unset(&val); - - sflphone_detach_participant(selected_call_id); - - if(conf) { - - DEBUG("we got a conf!"); - sflphone_add_participant(selected_call_id, conf->_confID); - } - else { - - DEBUG("didn't find a conf!"); - } - } - - // TODO: dragged a conference call on another conference call (different conference) - // TODO: dragged a conference call on a NULL element (same conference) - // TODO: dragged a conference call on a NULL element (different conference) - } - - } + + if (dragged_path_depth == 1) { + + if (selected_type == A_CALL && dragged_type == A_CALL) { + + // dragged a conference call on a call + sflphone_detach_participant (selected_call_id); + + if (selected_call != NULL && dragged_call != NULL) + sflphone_join_participant (selected_call->_callID, dragged_call->_callID); + + } else if (selected_type == A_CALL && dragged_type == A_CONFERENCE) { + + // dragged a conference call on a conference + sflphone_detach_participant (selected_call_id); + + if (selected_call != NULL && dragged_conf != NULL) { + + DEBUG ("Adding a participant, since dragged call on a conference"); + + sflphone_add_participant (selected_call_id, dragged_call_id); + } + } else { + + // dragged a conference call on a NULL element + sflphone_detach_participant (selected_call_id); + } + + } else { + + // dragged_path_depth == 2 + // dragged a conference call on another conference call (same conference) + // TODO: dragged a conference call on another conference call (different conference) + + gtk_tree_path_up (path); + + gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &parent_conference, path); + + gtk_tree_path_up (dpath); + gtk_tree_path_up (spath); + + if (gtk_tree_path_compare (dpath, spath) == 0) { + + DEBUG ("Dragged a call in the same conference"); + calltree_remove_call (current_calls, selected_call, NULL); + calltree_add_call (current_calls, selected_call, &parent_conference); + } else { + + + DEBUG ("Dragged a conference call onto another conference call %s, %s", gtk_tree_path_to_string (dpath), gtk_tree_path_to_string (spath)); + + conf = NULL; + + val.g_type = 0; + + if (gtk_tree_model_get_iter (model, &iter, dpath)) { + + DEBUG ("we got an iter!"); + gtk_tree_model_get_value (model, &iter, COLUMN_ACCOUNT_PTR, &val); + + conf = (conference_obj_t*) g_value_get_pointer (&val); + } + + g_value_unset (&val); + + sflphone_detach_participant (selected_call_id); + + if (conf) { + + DEBUG ("we got a conf!"); + sflphone_add_participant (selected_call_id, conf->_confID); + } else { + + DEBUG ("didn't find a conf!"); + } + } + + // TODO: dragged a conference call on another conference call (different conference) + // TODO: dragged a conference call on a NULL element (same conference) + // TODO: dragged a conference call on a NULL element (different conference) + } + + } } -void drag_data_received_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data) +void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, gint x UNUSED, gint y UNUSED, GtkSelectionData *selection_data UNUSED, guint info UNUSED, guint t UNUSED, gpointer data UNUSED) { - - // DEBUG("drag_data_received_cb\n"); - GtkTreeView *tree_view = GTK_TREE_VIEW(widget); + GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreePath *drop_path; GtkTreeViewDropPosition position; GValue val; - GtkTreeModel *model = (GtkTreeModel*)active_calltree->store; - GtkTreeModel* tree_model = gtk_tree_view_get_model(tree_view); + GtkTreeModel* tree_model = gtk_tree_view_get_model (tree_view); GtkTreeIter iter; - gchar value; - val.g_type = 0; - gtk_tree_view_get_drag_dest_row(tree_view, &drop_path, &position); - - if(drop_path) { - - gtk_tree_model_get_iter(tree_model, &iter, drop_path); - gtk_tree_model_get_value(tree_model, &iter, COLUMN_ACCOUNT_PTR, &val); - - - if(gtk_tree_model_iter_has_child(tree_model, &iter)) { - - DEBUG("CallTree: Dragging on a conference"); - dragged_type = A_CONFERENCE; - dragged_call = NULL; - } - else { - - DEBUG("CallTree: Dragging on a call"); - dragged_type = A_CALL; - dragged_conf = NULL; - } - - switch (position) { - - case GTK_TREE_VIEW_DROP_AFTER: - DEBUG("CallTree: GTK_TREE_VIEW_DROP_AFTER"); - dragged_path = gtk_tree_path_to_string(drop_path); - dragged_path_depth = gtk_tree_path_get_depth(drop_path); - dragged_call_id = "NULL"; - dragged_call = NULL; - dragged_conf = NULL; - break; - - case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: - DEBUG("CallTree: GTK_TREE_VIEW_DROP_INTO_OR_AFTER"); - dragged_path = gtk_tree_path_to_string(drop_path); - dragged_path_depth = gtk_tree_path_get_depth(drop_path); - if (dragged_type == A_CALL) { - - dragged_call_id = ((callable_obj_t*)g_value_get_pointer(&val))->_callID; - dragged_call = (callable_obj_t*)g_value_get_pointer(&val); - } - else { - - dragged_call_id = ((conference_obj_t*)g_value_get_pointer(&val))->_confID; - dragged_conf = (conference_obj_t*)g_value_get_pointer(&val); - } - break; - - case GTK_TREE_VIEW_DROP_BEFORE: - DEBUG("CallTree: GTK_TREE_VIEW_DROP_BEFORE"); - dragged_path = gtk_tree_path_to_string(drop_path); - dragged_path_depth = gtk_tree_path_get_depth(drop_path); - dragged_call_id = "NULL"; - dragged_call = NULL; - dragged_conf = NULL; - break; - - case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: - DEBUG("CallTree: GTK_TREE_VIEW_DROP_INTO_OR_BEFORE"); - dragged_path = gtk_tree_path_to_string(drop_path); - dragged_path_depth = gtk_tree_path_get_depth(drop_path); - if (dragged_type == A_CALL) { - dragged_call_id = ((callable_obj_t*)g_value_get_pointer(&val))->_callID; - dragged_call = (callable_obj_t*)g_value_get_pointer(&val); - } - else { - dragged_call_id = ((conference_obj_t*)g_value_get_pointer(&val))->_confID; - dragged_conf = (conference_obj_t*)g_value_get_pointer(&val); - } - break; - - default: - return; - } + gtk_tree_view_get_drag_dest_row (tree_view, &drop_path, &position); + + if (drop_path) { + + gtk_tree_model_get_iter (tree_model, &iter, drop_path); + gtk_tree_model_get_value (tree_model, &iter, COLUMN_ACCOUNT_PTR, &val); + + + if (gtk_tree_model_iter_has_child (tree_model, &iter)) { + + DEBUG ("CallTree: Dragging on a conference"); + dragged_type = A_CONFERENCE; + dragged_call = NULL; + } else { + + DEBUG ("CallTree: Dragging on a call"); + dragged_type = A_CALL; + dragged_conf = NULL; + } + + switch (position) { + + case GTK_TREE_VIEW_DROP_AFTER: + DEBUG ("CallTree: GTK_TREE_VIEW_DROP_AFTER"); + dragged_path = gtk_tree_path_to_string (drop_path); + dragged_path_depth = gtk_tree_path_get_depth (drop_path); + dragged_call_id = "NULL"; + dragged_call = NULL; + dragged_conf = NULL; + break; + + case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: + DEBUG ("CallTree: GTK_TREE_VIEW_DROP_INTO_OR_AFTER"); + dragged_path = gtk_tree_path_to_string (drop_path); + dragged_path_depth = gtk_tree_path_get_depth (drop_path); + + if (dragged_type == A_CALL) { + + dragged_call_id = ( (callable_obj_t*) g_value_get_pointer (&val))->_callID; + dragged_call = (callable_obj_t*) g_value_get_pointer (&val); + } else { + + dragged_call_id = ( (conference_obj_t*) g_value_get_pointer (&val))->_confID; + dragged_conf = (conference_obj_t*) g_value_get_pointer (&val); + } + + break; + + case GTK_TREE_VIEW_DROP_BEFORE: + DEBUG ("CallTree: GTK_TREE_VIEW_DROP_BEFORE"); + dragged_path = gtk_tree_path_to_string (drop_path); + dragged_path_depth = gtk_tree_path_get_depth (drop_path); + dragged_call_id = "NULL"; + dragged_call = NULL; + dragged_conf = NULL; + break; + + case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: + DEBUG ("CallTree: GTK_TREE_VIEW_DROP_INTO_OR_BEFORE"); + dragged_path = gtk_tree_path_to_string (drop_path); + dragged_path_depth = gtk_tree_path_get_depth (drop_path); + + if (dragged_type == A_CALL) { + dragged_call_id = ( (callable_obj_t*) g_value_get_pointer (&val))->_callID; + dragged_call = (callable_obj_t*) g_value_get_pointer (&val); + } else { + dragged_call_id = ( (conference_obj_t*) g_value_get_pointer (&val))->_confID; + dragged_conf = (conference_obj_t*) g_value_get_pointer (&val); + } + + break; + + default: + return; + } } } diff --git a/sflphone-client-gnome/src/contacts/calltree.h b/sflphone-client-gnome/src/contacts/calltree.h index b6a9eca3afcb974203e1b7e20f20936a06742ede..04f50cf46c494de2bfd727ed955f9514ce1b9b09 100644 --- a/sflphone-client-gnome/src/contacts/calltree.h +++ b/sflphone-client-gnome/src/contacts/calltree.h @@ -67,7 +67,7 @@ typedef enum { * @return GtkWidget* A new widget */ void -calltree_create(calltab_t* tab, gboolean searchbar_type); +calltree_create (calltab_t* tab, gboolean searchbar_type); /** * Add a call in the calltree @@ -90,7 +90,7 @@ calltree_update_call (calltab_t* ct, callable_obj_t * c, GtkTreeIter *parent); void calltree_remove_call (calltab_t* ct, callable_obj_t * c, GtkTreeIter *parent); -void +void calltree_add_history_entry (callable_obj_t * c); void @@ -109,11 +109,11 @@ void calltree_display (calltab_t *tab); void -row_activated(GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, void *); +row_activated (GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, void *); /** * Update elapced time based on selected calltree's call - */ + */ void calltree_update_clock(); diff --git a/sflphone-client-gnome/src/contacts/conferencelist.c b/sflphone-client-gnome/src/contacts/conferencelist.c index 42216fdcd0c6427457b1b34f7d22df3603829702..155b82d240820d8c261a6de7482858b59a2d1e38 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.c +++ b/sflphone-client-gnome/src/contacts/conferencelist.c @@ -31,13 +31,13 @@ #include <conferencelist.h> -gchar* +gchar* generate_conf_id (void) { gchar *conf_id; - conf_id = g_new0(gchar, 30); - g_sprintf(conf_id, "%d", rand()); + conf_id = g_new0 (gchar, 30); + g_sprintf (conf_id, "%d", rand()); return conf_id; } @@ -65,12 +65,12 @@ conferencelist_reset() void -conferencelist_add(const conference_obj_t* conf) +conferencelist_add (const conference_obj_t* conf) { - gchar* c = (gchar*)conferencelist_get(conf->_confID); - if(!c) - { - g_queue_push_tail (conferenceQueue, (gpointer)conf); + gchar* c = (gchar*) conferencelist_get (conf->_confID); + + if (!c) { + g_queue_push_tail (conferenceQueue, (gpointer) conf); } } @@ -78,40 +78,36 @@ conferencelist_add(const conference_obj_t* conf) void conferencelist_remove (const gchar* conf) { - gchar* c = (gchar*)conferencelist_get(conf); - if (c) - { - g_queue_remove(conferenceQueue, c); + gchar* c = (gchar*) conferencelist_get (conf); + + if (c) { + g_queue_remove (conferenceQueue, c); } } -conference_obj_t* +conference_obj_t* conferencelist_get (const gchar* conf_id) { - GList* c = g_queue_find_custom(conferenceQueue, conf_id, is_confID_confstruct); - if (c) - { - return (conference_obj_t*)c->data; - } - else - { - return NULL; + GList* c = g_queue_find_custom (conferenceQueue, conf_id, is_confID_confstruct); + + if (c) { + return (conference_obj_t*) c->data; + } else { + return NULL; } } -conference_obj_t* -conferencelist_get_nth ( guint n ) +conference_obj_t* +conferencelist_get_nth (guint n) { - GList* c = g_queue_peek_nth(conferenceQueue, n); - if (c) - { - return (conference_obj_t*)c->data; - } - else - { - return NULL; + GList* c = g_queue_peek_nth (conferenceQueue, n); + + if (c) { + return (conference_obj_t*) c->data; + } else { + return NULL; } } diff --git a/sflphone-client-gnome/src/contacts/conferencelist.h b/sflphone-client-gnome/src/contacts/conferencelist.h index 2652b892b7aba376bd1692224a8eafa3741f0bdc..afde7f2e0878d86035305ba27c19ec0580000fbf 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.h +++ b/sflphone-client-gnome/src/contacts/conferencelist.h @@ -74,7 +74,7 @@ conferencelist_get_size (); * @param n The position of the call you want * @return A call or NULL */ conference_obj_t* -conferencelist_get_nth (guint n ); +conferencelist_get_nth (guint n); /** Return the call corresponding to the callID * @param n The callID of the call you want diff --git a/sflphone-client-gnome/src/contacts/history.c b/sflphone-client-gnome/src/contacts/history.c index f354e73ceef65f5946a4b8386f4f68373d41c907..9853b5b2bb76ac857327652bafc7420234e3c1b5 100644 --- a/sflphone-client-gnome/src/contacts/history.c +++ b/sflphone-client-gnome/src/contacts/history.c @@ -39,9 +39,9 @@ GtkWidget * history_searchbar_widget; static GtkTreeModel* history_create_filter (GtkTreeModel*); static gboolean history_is_visible (GtkTreeModel*, GtkTreeIter*, gpointer); -void history_search (SearchType search_type) +void history_search (SearchType search_type UNUSED) { - if(history_filter != NULL) { + if (history_filter != NULL) { gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (history_filter)); } } @@ -64,58 +64,57 @@ void history_set_searchbar_widget (GtkWidget *searchbar) history_searchbar_widget = searchbar; } -static GtkTreeModel* history_create_filter (GtkTreeModel* child) +static GtkTreeModel* history_create_filter (GtkTreeModel* child) { GtkTreeModel* ret; - DEBUG("Create Filter"); + DEBUG ("Create Filter"); ret = gtk_tree_model_filter_new (child, NULL); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (ret), history_is_visible, NULL, NULL); return GTK_TREE_MODEL (ret); } -static gboolean history_is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED) +static gboolean history_is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED) { GValue val, obj; callable_obj_t *history_entry = NULL; gchar* text = NULL; - gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(history_searchbar_widget)); + gchar* search = (gchar*) gtk_entry_get_text (GTK_ENTRY (history_searchbar_widget)); + + memset (&val, 0, sizeof (val)); + memset (&obj, 0, sizeof (obj)); - memset (&val, 0, sizeof(val)); - memset (&obj, 0, sizeof(obj)); - // Fetch the call description - gtk_tree_model_get_value (GTK_TREE_MODEL(model), iter, 1, &val); - if(G_VALUE_HOLDS_STRING(&val)){ - text = (gchar *)g_value_get_string(&val); + gtk_tree_model_get_value (GTK_TREE_MODEL (model), iter, 1, &val); + + if (G_VALUE_HOLDS_STRING (&val)) { + text = (gchar *) g_value_get_string (&val); } - + // Fetch the call type - gtk_tree_model_get_value (GTK_TREE_MODEL(model), iter, 3, &obj); - if (G_VALUE_HOLDS_POINTER (&obj)){ + gtk_tree_model_get_value (GTK_TREE_MODEL (model), iter, 3, &obj); + + if (G_VALUE_HOLDS_POINTER (&obj)) { history_entry = (gpointer) g_value_get_pointer (&obj); } - if(text != NULL) - { - if (history_entry) - { + if (text != NULL) { + if (history_entry) { // Filter according to the type of call // MISSED, INCOMING, OUTGOING, ALL - if ((int)get_current_history_search_type () == SEARCH_ALL) - return g_regex_match_simple(search, text, G_REGEX_CASELESS, 0); - else - { + if ( (int) get_current_history_search_type () == SEARCH_ALL) + return g_regex_match_simple (search, text, G_REGEX_CASELESS, 0); + else { // We need a match on the history_state_t and the current search type - return (history_entry->_history_state + 1) == (int)get_current_history_search_type () && - g_regex_match_simple(search, text, G_REGEX_CASELESS, 0); + return (history_entry->_history_state + 1) == (guint) get_current_history_search_type () && + g_regex_match_simple (search, text, G_REGEX_CASELESS, 0); } } } - // Clean up + // Clean up g_value_unset (&val); g_value_unset (&obj); diff --git a/sflphone-client-gnome/src/contacts/history.h b/sflphone-client-gnome/src/contacts/history.h index f91393ccb1316d1da74bb171b7e8d7c2d5595ee8..a02e4857832d7f8c345beb7f7d4cba8d63bd0262 100644 --- a/sflphone-client-gnome/src/contacts/history.h +++ b/sflphone-client-gnome/src/contacts/history.h @@ -63,6 +63,6 @@ void history_reinit (calltab_t* history); * Set history search bar widget (needed for is_visible) */ void -history_set_searchbar_widget(GtkWidget *); +history_set_searchbar_widget (GtkWidget *); #endif diff --git a/sflphone-client-gnome/src/contacts/searchbar.c b/sflphone-client-gnome/src/contacts/searchbar.c index 09e2da62e4f79badf94d55b9010b7aeed909b3cf..173c3e7d22adabc691f5da05f8226ecb50845074 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.c +++ b/sflphone-client-gnome/src/contacts/searchbar.c @@ -47,77 +47,76 @@ GdkPixbuf *missed_pixbuf = NULL; void searchbar_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UNUSED) { - DEBUG("searchbar_entry_changed"); + DEBUG ("searchbar_entry_changed"); if (active_calltree == contacts) { addressbook_search (entry); - } - else if (active_calltree == history) { + } else if (active_calltree == history) { history_search (HistorySearchType); } } #if GTK_CHECK_VERSION(2,16,0) -static void search_all (GtkWidget *item, GtkEntry *entry) +static void search_all (GtkWidget *item UNUSED, GtkEntry *entry) { HistorySearchType = SEARCH_ALL; gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, - g_markup_printf_escaped("%s\n%s", - _("Search all"), - _("Click here to change the search type"))); + g_markup_printf_escaped ("%s\n%s", + _ ("Search all"), + _ ("Click here to change the search type"))); history_search (HistorySearchType); -} +} -static void search_by_missed (GtkWidget *item, GtkEntry *entry) +static void search_by_missed (GtkWidget *item UNUSED, GtkEntry *entry) { HistorySearchType = SEARCH_MISSED; gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, missed_pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, - g_markup_printf_escaped("%s\n%s", - _("Search by missed call"), - _("Click here to change the search type"))); + g_markup_printf_escaped ("%s\n%s", + _ ("Search by missed call"), + _ ("Click here to change the search type"))); history_search (HistorySearchType); -} +} -static void search_by_incoming (GtkWidget *item, GtkEntry *entry) +static void search_by_incoming (GtkWidget *item UNUSED, GtkEntry *entry) { HistorySearchType = SEARCH_INCOMING; gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, incoming_pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, - g_markup_printf_escaped("%s\n%s", - _("Search by incoming call"), - _("Click here to change the search type"))); + g_markup_printf_escaped ("%s\n%s", + _ ("Search by incoming call"), + _ ("Click here to change the search type"))); history_search (HistorySearchType); -} +} -static void search_by_outgoing (GtkWidget *item, GtkEntry *entry) +static void search_by_outgoing (GtkWidget *item UNUSED, GtkEntry *entry) { HistorySearchType = SEARCH_OUTGOING; gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, outgoing_pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, - g_markup_printf_escaped("%s\n%s", - _("Search by outgoing call"), - _("Click here to change the search type"))); + g_markup_printf_escaped ("%s\n%s", + _ ("Search by outgoing call"), + _ ("Click here to change the search type"))); history_search (HistorySearchType); -} +} -static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event, gpointer data) +static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event, gpointer data UNUSED) { if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == history) - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - event->button, event->time); - else + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, + event->button, event->time); + else gtk_entry_set_text (entry, ""); } -static void text_changed_cb (GtkEntry *entry, GParamSpec *pspec) +static void text_changed_cb (GtkEntry *entry, GParamSpec *pspec UNUSED) { gboolean has_text; @@ -128,30 +127,28 @@ static void text_changed_cb (GtkEntry *entry, GParamSpec *pspec) #endif void -focus_on_searchbar_out(){ - DEBUG("set_focus_on_searchbar_out"); +focus_on_searchbar_out() +{ + DEBUG ("set_focus_on_searchbar_out"); // gtk_widget_grab_focus(GTK_WIDGET(sw)); focus_is_on_searchbar = FALSE; } void -focus_on_searchbar_in(){ - DEBUG("set_focus_on_searchbar_in"); +focus_on_searchbar_in() +{ + DEBUG ("set_focus_on_searchbar_in"); // gtk_widget_grab_focus(GTK_WIDGET(sw)); focus_is_on_searchbar = TRUE; } -void searchbar_init(calltab_t *tab) +void searchbar_init (calltab_t *tab) { - if (g_strcasecmp (tab->_name, CONTACTS) == 0) - { + if (g_strcasecmp (tab->_name, CONTACTS) == 0) { addressbook_init(); - } - else if (g_strcasecmp (tab->_name, HISTORY) == 0) - { + } else if (g_strcasecmp (tab->_name, HISTORY) == 0) { history_init(); - } - else + } else ERROR ("searchbar.c - searchbar_init should not happen within this widget\n"); } @@ -160,7 +157,7 @@ GtkWidget* history_searchbar_new (void) GtkWidget *ret, *item, *image; - ret = gtk_hbox_new(FALSE, 0); + ret = gtk_hbox_new (FALSE, 0); #if GTK_CHECK_VERSION(2,16,0) @@ -213,40 +210,41 @@ GtkWidget* history_searchbar_new (void) #else searchbox = sexy_icon_entry_new(); - image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); - sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(searchbox) ); + image = gtk_image_new_from_stock (GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); + sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (searchbox)); #endif - g_signal_connect_after(GTK_ENTRY(searchbox), "changed", G_CALLBACK(searchbar_entry_changed), NULL); + g_signal_connect_after (GTK_ENTRY (searchbox), "changed", G_CALLBACK (searchbar_entry_changed), NULL); g_signal_connect_after (G_OBJECT (searchbox), "focus-in-event", - G_CALLBACK (focus_on_searchbar_in), NULL); + G_CALLBACK (focus_on_searchbar_in), NULL); g_signal_connect_after (G_OBJECT (searchbox), "focus-out-event", - G_CALLBACK (focus_on_searchbar_out), NULL); + G_CALLBACK (focus_on_searchbar_out), NULL); - gtk_box_pack_start(GTK_BOX(ret), searchbox, TRUE, TRUE, 0); - history_set_searchbar_widget(searchbox); + gtk_box_pack_start (GTK_BOX (ret), searchbox, TRUE, TRUE, 0); + history_set_searchbar_widget (searchbox); return ret; } -GtkWidget* contacts_searchbar_new () { +GtkWidget* contacts_searchbar_new () +{ GtkWidget *ret; - ret = gtk_hbox_new(FALSE, 0); + ret = gtk_hbox_new (FALSE, 0); #if GTK_CHECK_VERSION(2,16,0) - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf; searchbox = gtk_entry_new(); gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL); gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, pixbuf); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, - "Search contacts\n" - "GNOME evolution backend"); + "Search contacts\n" + "GNOME evolution backend"); // Set the clean insensitive @@ -260,29 +258,31 @@ GtkWidget* contacts_searchbar_new () { GtkWidget *image; searchbox = sexy_icon_entry_new(); - image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); - sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); - sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(searchbox) ); + image = gtk_image_new_from_stock (GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image)); + sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (searchbox)); #endif - g_signal_connect_after(GTK_ENTRY(searchbox), "changed", G_CALLBACK(searchbar_entry_changed), NULL); + g_signal_connect_after (GTK_ENTRY (searchbox), "changed", G_CALLBACK (searchbar_entry_changed), NULL); g_signal_connect_after (G_OBJECT (searchbox), "focus-in-event", - G_CALLBACK (focus_on_searchbar_in), NULL); + G_CALLBACK (focus_on_searchbar_in), NULL); g_signal_connect_after (G_OBJECT (searchbox), "focus-out-event", - G_CALLBACK (focus_on_searchbar_out), NULL); + G_CALLBACK (focus_on_searchbar_out), NULL); - gtk_box_pack_start(GTK_BOX(ret), searchbox, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (ret), searchbox, TRUE, TRUE, 0); return ret; } -void activateWaitingLayer() { - gtk_widget_show(waitingLayer); +void activateWaitingLayer() +{ + gtk_widget_show (waitingLayer); } -void deactivateWaitingLayer() { - gtk_widget_hide(waitingLayer); +void deactivateWaitingLayer() +{ + gtk_widget_hide (waitingLayer); } SearchType get_current_history_search_type (void) diff --git a/sflphone-client-gnome/src/contacts/searchbar.h b/sflphone-client-gnome/src/contacts/searchbar.h index f1464cd554a2d1385fa5bcfafab0d3faf1d5cfd9..0fa107cce7fd48f3b82d74b9f97c45fa3ca8cb4d 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.h +++ b/sflphone-client-gnome/src/contacts/searchbar.h @@ -69,7 +69,7 @@ SearchType get_current_history_search_type (void); /** * Initialize a specific search bar */ -void searchbar_init(calltab_t *); +void searchbar_init (calltab_t *); /** * Activate a waiting layer during search diff --git a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml index 8c8fc90c0018ebafec8e87e1376b5dc59c52f209..8ca26faf75d5e62086486a83848be75a0955b180 100755 --- a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml @@ -101,29 +101,15 @@ </arg> </method> - <method name="setNumberOfCredential" tp:name-for-bindings="setNumberOfCredential"> + <method name="deleteAllCredential" tp:name-for-bindings="deleteAllCredential"> <tp:docstring> </tp:docstring> <arg type="s" name="accountID" direction="in"> - <tp:docstring> - </tp:docstring> - </arg> - <arg type="i" name="number" direction="in"> <tp:docstring> </tp:docstring> </arg> </method> - <method name="deleteAllCredential" tp:name-for-bindings="deleteAllCredential"> - <tp:docstring> - </tp:docstring> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - Account ID - </tp:docstring> - </arg> - </method> - <method name="getIp2IpDetails" tp:name-for-bindings="getIp2IpDetails"> <tp:docstring> Get configuration settings of the IP2IP_PROFILE. They are sligthly different from account settings since no VoIP accounts are involved. @@ -207,55 +193,55 @@ <method name="addAccount" tp:name-for-bindings="addAccount"> <tp:docstring> - Add a new account. When created, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure. - <tp:rationale>If no details are specified, the default parameters are used.</tp:rationale> - <tp:rationale>The core tries to register the account as soon it is created.</tp:rationale> + Add a new account. When created, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure. + <tp:rationale>If no details are specified, the default parameters are used.</tp:rationale> + <tp:rationale>The core tries to register the account as soon it is created.</tp:rationale> </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/> <arg type="a{ss}" name="details" direction="in" tp:type="String_String_Map"> - <tp:docstring> - The new account settings - </tp:docstring> + <tp:docstring> + The new account settings + </tp:docstring> </arg> <arg type="s" name="createdAccountId" direction="out"> - <tp:docstring> - A new account ID - </tp:docstring> + <tp:docstring> + A new account ID + </tp:docstring> </arg> </method> <method name="setAccountsOrder" tp:name-for-bindings="setAccountsOrder"> <tp:docstring> - Update the accounts order. - <tp:rationale>When placing a call, the first registered account in the list is used.</tp:rationale> + Update the accounts order. + <tp:rationale>When placing a call, the first registered account in the list is used.</tp:rationale> </tp:docstring> <arg type="s" name="order" direction="in"> - <tp:docstring> - An ordered list of account IDs, delimited by '/' - </tp:docstring> + <tp:docstring> + An ordered list of account IDs, delimited by '/' + </tp:docstring> </arg> </method> <method name="removeAccount" tp:name-for-bindings="removeAccount"> - <tp:docstring> - Remove an existing account. When removed, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure. - </tp:docstring> - <arg type="s" name="accoundID" direction="in"> - <tp:docstring> - The account to remove, identified by its ID - </tp:docstring> - </arg> + <tp:docstring> + Remove an existing account. When removed, the signal <tp:member-ref>accountsChanged</tp:member-ref> is emitted. The clients must then call <tp:member-ref>getAccountList</tp:member-ref> to update their internal data structure. + </tp:docstring> + <arg type="s" name="accoundID" direction="in"> + <tp:docstring> + The account to remove, identified by its ID + </tp:docstring> + </arg> </method> <method name="getAccountList" tp:name-for-bindings="getAccountList"> - <tp:docstring> - Get a list of all created accounts, as stored by the core. - </tp:docstring> + <tp:docstring> + Get a list of all created accounts, as stored by the core. + </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - A list of account IDs - </tp:docstring> + <tp:docstring> + A list of account IDs + </tp:docstring> </arg> </method> @@ -268,15 +254,15 @@ @param[in] input accountID --> <arg type="s" name="accountID" direction="in"> - <tp:docstring> - The account ID - </tp:docstring> + <tp:docstring> + The account ID + </tp:docstring> </arg> <arg type="i" name="expire" direction="in"> - <tp:docstring> - <p>To register, expire must be 1.</p> - <p>To un-register, expire must be 0.</p> - </tp:docstring> + <tp:docstring> + <p>To register, expire must be 1.</p> + <p>To un-register, expire must be 0.</p> + </tp:docstring> </arg> </method> @@ -285,14 +271,13 @@ </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getVersion" tp:name-for-bindings="getVersion"> <tp:docstring> - Return SFLphone-daemon version </tp:docstring> <arg type="s" name="version" direction="out"> <tp:docstring> @@ -302,19 +287,16 @@ <method name="getRingtoneList" tp:name-for-bindings="getRingtoneList"> <tp:docstring> - Return a list of valid Sun's .au sound file used - as ringtones. </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getPlaybackDeviceList" tp:name-for-bindings="getPlaybackDeviceList"> <tp:docstring> - Provide a list of playback device from ALSA </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> @@ -325,7 +307,6 @@ <method name="getRecordDeviceList" tp:name-for-bindings="getRecordDeviceList"> <tp:docstring> - Provide a list of record device from ALSA </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> @@ -336,7 +317,6 @@ <method name="isRingtoneEnabled" tp:name-for-bindings="isRingtoneEnabled"> <tp:docstring> - Return true if ringtone is enabled, false otherwise </tp:docstring> <arg type="s" name="accountID" direction="in" /> <arg type="i" name="bool" direction="out"> @@ -353,24 +333,21 @@ <method name="getRingtoneChoice" tp:name-for-bindings="getRingtoneChoice"> <tp:docstring> - Get current ringtone .au file selected </tp:docstring> <arg type="s" name="accountID" direction="in"/> <arg type="s" name="tone" direction="out"> - <tp:docstring> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="setRingtoneChoice" tp:name-for-bindings="setRingtoneChoice"> <tp:docstring> - Set current ringtone .au file from list acquired using <tp:member-ref>getAccountList</tp:member-ref> </tp:docstring> <arg type="s" name="accountID" direction="in"/> <arg type="s" name="tone" direction="in"> - <tp:docstring> - A valid .au file path - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> @@ -669,7 +646,6 @@ </arg> </method> - <!-- Addressbook configuration --> <method name="getAddressbookSettings" tp:name-for-bindings="getAddressbookSettings"> <tp:docstring> @@ -748,144 +724,92 @@ </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/> <arg type="a{ss}" name="entries" direction="in"> - <tp:docstring> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <signal name="accountsChanged" tp:name-for-bindings="accountsChanged"> - <tp:docstring> - Signal emited on account changes. Clients should update - all account status with <tp:member-ref>getAccountDetails</tp:member-ref> - iterating over the list provided by <tp:member-ref>getAccountList</tp:member-ref> - </tp:docstring> </signal> <signal name="errorAlert" tp:name-for-bindings="errorAlert"> <arg type="i" name="code"> - <tp:docstring> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </signal> <!-- TLS Methods --> <method name="getSupportedTlsMethod" tp:name-for-bindings="getSupportedTlsMethod"> <tp:docstring> - Provide a list of supported TLS method </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - A list of TLS method: (TLSv1, SSLv1, SSLv2, - SSLv3, SSLv23) - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getTlsSettingsDefault" tp:name-for-bindings="getTlsSettingsDefault"> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/> <tp:docstring> - Get default TLS setting for new accounts </tp:docstring> <arg type="a{ss}" name="details" direction="out"> - <tp:docstring> - A hash table containing details. Refer - to <tp:member-ref>getTlsSettings</tp:member-ref> - for possible keys - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getTlsSettings" tp:name-for-bindings="getTlsSettings"> <tp:docstring> - Get current TLS setting for a specific account </tp:docstring> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - The account ID - </tp:docstring> - </arg> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/> <arg type="a{ss}" name="details" direction="out"> - <tp:docstring> - A hash table containing details with key: - <ul> - <li>"TLS.listenerPort": valid numerical port</li> - <li>"TLS.enable": true/false</li> - <li>"TLS.certificateListFile": A valid path to - a .pem file containing CA certificate</li> - <li>"TLS.certificateFile": A valid path to a - file containing the public end-point - certificate (optional)</li> - <li>"TLS.privateKeyFile": A valid path to a - file containing the public end-point private - key (optional)</li> - <li>"TLS.password": Public end-point private - key password (optional)</li> - <li>"TLS.method": (TLSv1, SSLv1, SSLv2, - SSLv3, SSLv23)</li> - </ul> - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="setTlsSettings" tp:name-for-bindings="setTlsSettings"> <tp:docstring> - Update TLS setting for a specific account </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="MapStringString"/> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - The account ID - </tp:docstring> - </arg> <arg type="a{ss}" name="details" direction="in"> - <tp:docstring> - A hash table containing details. Refer - to <tp:member-ref>getTlsSettings</tp:member-ref> - for possible keys. - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getAddrFromInterfaceName" tp:name-for-bindings="getAddrFromInterfaceName"> <tp:docstring> - Resolve interface IPv4 address provided its name. </tp:docstring> <arg type="s" name="interface" direction="in"> - <tp:docstring> - Interface name - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> <arg type="s" name="address" direction="out"> - <tp:docstring> - Interface IPv4 address - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getAllIpInterface" tp:name-for-bindings="getAllIpInterface"> <tp:docstring> - Provide a list of IP interface's IPv4 address. </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - A list of interface's IPv4 address - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> <method name="getAllIpInterfaceByName" tp:name-for-bindings="getAllIpInterfaceByName"> <tp:docstring> - Provide a list of IP interface's name: default - (0.0.0.0), lo, eth0 ... </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> <arg type="as" name="list" direction="out"> - <tp:docstring> - A list of interface's name - </tp:docstring> + <tp:docstring> + </tp:docstring> </arg> </method> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 6dd1183c99f096b9800b6d08699050982352f03e..8237f57cef529e5220f2c6e485e90ce024edc725 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -55,1169 +55,1088 @@ DBusGProxy * configurationManagerProxy; DBusGProxy * instanceProxy; static void -incoming_call_cb(DBusGProxy *proxy UNUSED, const gchar* accountID, - const gchar* callID, const gchar* from, void * foo UNUSED ) +incoming_call_cb (DBusGProxy *proxy UNUSED, const gchar* accountID, + const gchar* callID, const gchar* from, void * foo UNUSED) { - DEBUG("Incoming call (%s) from %s", callID, from); + DEBUG ("Incoming call (%s) from %s", callID, from); - callable_obj_t * c; - gchar *peer_name, *peer_number; - // We receive the from field under a formatted way. We want to extract the number and the name of the caller - peer_name = call_get_peer_name(from); - peer_number = call_get_peer_number(from); + callable_obj_t * c; + gchar *peer_name, *peer_number; + // We receive the from field under a formatted way. We want to extract the number and the name of the caller + peer_name = call_get_peer_name (from); + peer_number = call_get_peer_number (from); - DEBUG(" peer name: %s", peer_name); - DEBUG(" peer number: %s", peer_number); + DEBUG (" peer name: %s", peer_name); + DEBUG (" peer number: %s", peer_number); - create_new_call(CALL, CALL_STATE_INCOMING, g_strdup(callID), g_strdup( - accountID), peer_name, peer_number, &c); + create_new_call (CALL, CALL_STATE_INCOMING, g_strdup (callID), g_strdup ( + accountID), peer_name, peer_number, &c); #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink(TRUE); - popup_main_window(); + status_tray_icon_blink (TRUE); + popup_main_window(); #endif - set_timestamp(&c->_time_start); - notify_incoming_call(c); - sflphone_incoming_call(c); + set_timestamp (&c->_time_start); + notify_incoming_call (c); + sflphone_incoming_call (c); } static void -zrtp_negotiation_failed_cb(DBusGProxy *proxy UNUSED, const gchar* callID, - const gchar* reason, const gchar* severity, void * foo UNUSED ) +zrtp_negotiation_failed_cb (DBusGProxy *proxy UNUSED, const gchar* callID, + const gchar* reason, const gchar* severity, void * foo UNUSED) { - DEBUG ("Zrtp negotiation failed."); - main_window_zrtp_negotiation_failed(callID, reason, severity); - callable_obj_t * c = NULL; - c = calllist_get(current_calls, callID); - if (c) - { - notify_zrtp_negotiation_failed(c); + DEBUG ("Zrtp negotiation failed."); + main_window_zrtp_negotiation_failed (callID, reason, severity); + callable_obj_t * c = NULL; + c = calllist_get (current_calls, callID); + + if (c) { + notify_zrtp_negotiation_failed (c); } } static void -curent_selected_codec(DBusGProxy *proxy UNUSED, const gchar* callID, - const gchar* codecName, void * foo UNUSED ) +curent_selected_codec (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, + const gchar* codecName UNUSED, void * foo UNUSED) { - // DEBUG ("%s codec decided for call %s",codecName,callID); - // sflphone_display_selected_codec (codecName); } static void -volume_changed_cb(DBusGProxy *proxy UNUSED, const gchar* device, const gdouble value, - void * foo UNUSED ) +volume_changed_cb (DBusGProxy *proxy UNUSED, const gchar* device, const gdouble value, + void * foo UNUSED) { - DEBUG ("Volume of %s changed to %f.",device, value); - set_slider(device, value); + DEBUG ("Volume of %s changed to %f.",device, value); + set_slider (device, value); } static void -voice_mail_cb(DBusGProxy *proxy UNUSED, const gchar* accountID, const guint nb, - void * foo UNUSED ) +voice_mail_cb (DBusGProxy *proxy UNUSED, const gchar* accountID, const guint nb, + void * foo UNUSED) { - DEBUG ("%d Voice mail waiting!",nb); - sflphone_notify_voice_mail(accountID, nb); + DEBUG ("%d Voice mail waiting!",nb); + sflphone_notify_voice_mail (accountID, nb); } static void -incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar* accountID UNUSED, - const gchar* msg, void * foo UNUSED ) +incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* accountID UNUSED, + const gchar* msg, void * foo UNUSED) { - DEBUG ("Message %s!",msg); + DEBUG ("Message %s!",msg); } static void -call_state_cb(DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state, - void * foo UNUSED ) -{ - DEBUG ("Call %s state %s",callID, state); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - if (strcmp(state, "HUNGUP") == 0) - { - if (c->_state == CALL_STATE_CURRENT) - { - // peer hung up, the conversation was established, so _stop has been initialized with the current time value - DEBUG("call state current"); - set_timestamp(&c->_time_stop); - calltree_update_call(history, c, NULL); +call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state, + void * foo UNUSED) +{ + DEBUG ("Call %s state %s",callID, state); + callable_obj_t * c = calllist_get (current_calls, callID); + + if (c) { + if (strcmp (state, "HUNGUP") == 0) { + if (c->_state == CALL_STATE_CURRENT) { + // peer hung up, the conversation was established, so _stop has been initialized with the current time value + DEBUG ("call state current"); + set_timestamp (&c->_time_stop); + calltree_update_call (history, c, NULL); } - stop_notification(); - calltree_update_call(history, c, NULL); - status_bar_display_account(); - sflphone_hung_up(c); - } - else if (strcmp(state, "UNHOLD_CURRENT") == 0) - { - sflphone_current(c); - } - else if (strcmp(state, "UNHOLD_RECORD") == 0) - { - sflphone_record(c); - } - else if (strcmp(state, "HOLD") == 0) - { - sflphone_hold(c); - } - else if (strcmp(state, "RINGING") == 0) - { - sflphone_ringing(c); - } - else if (strcmp(state, "CURRENT") == 0) - { - sflphone_current(c); - } - else if (strcmp(state, "FAILURE") == 0) - { - sflphone_fail(c); - } - else if (strcmp(state, "BUSY") == 0) - { - sflphone_busy(c); + + stop_notification(); + calltree_update_call (history, c, NULL); + status_bar_display_account(); + sflphone_hung_up (c); + } else if (strcmp (state, "UNHOLD_CURRENT") == 0) { + sflphone_current (c); + } else if (strcmp (state, "UNHOLD_RECORD") == 0) { + sflphone_record (c); + } else if (strcmp (state, "HOLD") == 0) { + sflphone_hold (c); + } else if (strcmp (state, "RINGING") == 0) { + sflphone_ringing (c); + } else if (strcmp (state, "CURRENT") == 0) { + sflphone_current (c); + } else if (strcmp (state, "FAILURE") == 0) { + sflphone_fail (c); + } else if (strcmp (state, "BUSY") == 0) { + sflphone_busy (c); } - } - else - { - // The callID is unknow, threat it like a new call - // If it were an incoming call, we won't be here - // It means that a new call has been initiated with an other client (cli for instance) - if (strcmp(state, "RINGING") == 0 || strcmp(state, "CURRENT") == 0) - { - callable_obj_t *new_call; - GHashTable *call_details; - gchar *type; - - DEBUG ("New ringing call! accountID: %s", callID); - - // We fetch the details associated to the specified call - call_details = dbus_get_call_details(callID); - create_new_call_from_details(callID, call_details, &new_call); - - // Restore the callID to be synchronous with the daemon - new_call->_callID = g_strdup(callID); - type = g_hash_table_lookup(call_details, "CALL_TYPE"); - - if (g_strcasecmp(type, "0") == 0) - { - // DEBUG("incoming\n"); - new_call->_history_state = INCOMING; - } - else - { - // DEBUG("outgoing\n"); - new_call->_history_state = OUTGOING; + } else { + // The callID is unknow, threat it like a new call + // If it were an incoming call, we won't be here + // It means that a new call has been initiated with an other client (cli for instance) + if (strcmp (state, "RINGING") == 0 || strcmp (state, "CURRENT") == 0) { + callable_obj_t *new_call; + GHashTable *call_details; + gchar *type; + + DEBUG ("New ringing call! accountID: %s", callID); + + // We fetch the details associated to the specified call + call_details = dbus_get_call_details (callID); + create_new_call_from_details (callID, call_details, &new_call); + + // Restore the callID to be synchronous with the daemon + new_call->_callID = g_strdup (callID); + type = g_hash_table_lookup (call_details, "CALL_TYPE"); + + if (g_strcasecmp (type, "0") == 0) { + // DEBUG("incoming\n"); + new_call->_history_state = INCOMING; + } else { + // DEBUG("outgoing\n"); + new_call->_history_state = OUTGOING; } - calllist_add(current_calls, new_call); - calllist_add(history, new_call); - calltree_add_call(current_calls, new_call, NULL); - update_actions(); - calltree_display(current_calls); + calllist_add (current_calls, new_call); + calllist_add (history, new_call); + calltree_add_call (current_calls, new_call, NULL); + update_actions(); + calltree_display (current_calls); - //sflphone_incoming_call (new_call); + //sflphone_incoming_call (new_call); } } } static void -conference_changed_cb(DBusGProxy *proxy UNUSED, const gchar* confID, - const gchar* state, void * foo UNUSED ) +conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, + const gchar* state, void * foo UNUSED) { - // sflphone_display_transfer_status("Transfer successfull"); - conference_obj_t* changed_conf = conferencelist_get(confID); - gchar** participants; - gchar** part; + // sflphone_display_transfer_status("Transfer successfull"); + conference_obj_t* changed_conf = conferencelist_get (confID); + gchar** participants; - DEBUG("conference new state %s\n", state); + DEBUG ("conference new state %s\n", state); - if (changed_conf) - { - // remove old conference from calltree - calltree_remove_conference(current_calls, changed_conf, NULL); + if (changed_conf) { + // remove old conference from calltree + calltree_remove_conference (current_calls, changed_conf, NULL); - // update conference state - if (strcmp(state, "ACTIVE_ATACHED") == 0) - { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; - } - else if (strcmp(state, "ACTIVE_DETACHED") == 0) - { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; - } - else if (strcmp(state, "HOLD") == 0) - { - changed_conf->_state = CONFERENCE_STATE_HOLD; - } - else - { - DEBUG("Error: conference state not recognized"); + // update conference state + if (strcmp (state, "ACTIVE_ATACHED") == 0) { + changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; + } else if (strcmp (state, "ACTIVE_DETACHED") == 0) { + changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; + } else if (strcmp (state, "HOLD") == 0) { + changed_conf->_state = CONFERENCE_STATE_HOLD; + } else { + DEBUG ("Error: conference state not recognized"); } - participants = (gchar**) dbus_get_participant_list(changed_conf->_confID); + participants = (gchar**) dbus_get_participant_list (changed_conf->_confID); - // update conferece participants - conference_participant_list_update(participants, changed_conf); + // update conferece participants + conference_participant_list_update (participants, changed_conf); - // add new conference to calltree - calltree_add_conference(current_calls, changed_conf); + // add new conference to calltree + calltree_add_conference (current_calls, changed_conf); } } static void -conference_created_cb(DBusGProxy *proxy UNUSED, const gchar* confID, void * foo UNUSED ) +conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo UNUSED) { - DEBUG ("DBUS: Conference %s added", confID); + DEBUG ("DBUS: Conference %s added", confID); - conference_obj_t* new_conf; - callable_obj_t* call; - gchar* call_id; - gchar** participants; - gchar** part; + conference_obj_t* new_conf; + callable_obj_t* call; + gchar* call_id; + gchar** participants; + gchar** part; - create_new_conference(CONFERENCE_STATE_ACTIVE_ATACHED, confID, &new_conf); + create_new_conference (CONFERENCE_STATE_ACTIVE_ATACHED, confID, &new_conf); - participants = (gchar**) dbus_get_participant_list(new_conf->_confID); + participants = (gchar**) dbus_get_participant_list (new_conf->_confID); - // Update conference list - conference_participant_list_update(participants, new_conf); + // Update conference list + conference_participant_list_update (participants, new_conf); - // Add conference ID in in each calls - for (part = participants; *part; part++) { - call_id = (gchar*) (*part); - call = calllist_get(current_calls, call_id); - call->_confID = g_strdup(confID); - } + // Add conference ID in in each calls + for (part = participants; *part; part++) { + call_id = (gchar*) (*part); + call = calllist_get (current_calls, call_id); + call->_confID = g_strdup (confID); + } - conferencelist_add(new_conf); - calltree_add_conference(current_calls, new_conf); + conferencelist_add (new_conf); + calltree_add_conference (current_calls, new_conf); } static void -conference_removed_cb(DBusGProxy *proxy UNUSED, const gchar* confID, void * foo UNUSED ) +conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo UNUSED) { - DEBUG ("DBUS: Conference removed %s", confID); + DEBUG ("DBUS: Conference removed %s", confID); + + conference_obj_t * c = conferencelist_get (confID); + calltree_remove_conference (current_calls, c, NULL); + + GSList *participant = c->participant_list; + callable_obj_t *call; + + while (participant) { + + call = calllist_get (current_calls, (const gchar *) (participant->data)); + + if (call) { + DEBUG ("DBUS: Remove participant %s", call->_callID); - conference_obj_t * c = conferencelist_get(confID); - calltree_remove_conference(current_calls, c, NULL); + if (call->_confID) { + g_free (call->_confID); + call->_confID = NULL; + } + } - GSList *participant = c->participant_list; - callable_obj_t *call; - while(participant) { + participant = conference_next_participant (participant); + } - call = calllist_get(current_calls, (const gchar *)(participant->data)); - if(call) { - DEBUG("DBUS: Remove participant %s", call->_callID); - if(call->_confID){ - g_free(call->_confID); - call->_confID = NULL; - } - } - participant = conference_next_participant(participant); - } - - conferencelist_remove(c->_confID); + conferencelist_remove (c->_confID); } static void -accounts_changed_cb(DBusGProxy *proxy UNUSED, void * foo UNUSED ) +accounts_changed_cb (DBusGProxy *proxy UNUSED, void * foo UNUSED) { - DEBUG ("Accounts changed"); - sflphone_fill_account_list(); - sflphone_fill_ip2ip_profile(); - account_list_config_dialog_fill(); + DEBUG ("Accounts changed"); + sflphone_fill_account_list(); + sflphone_fill_ip2ip_profile(); + account_list_config_dialog_fill(); - // Update the status bar in case something happened - // Should fix ticket #1215 - status_bar_display_account(); + // Update the status bar in case something happened + // Should fix ticket #1215 + status_bar_display_account(); - // Update the tooltip on the status icon - statusicon_set_tooltip (); + // Update the tooltip on the status icon + statusicon_set_tooltip (); } static void -transfer_succeded_cb(DBusGProxy *proxy UNUSED, void * foo UNUSED ) +transfer_succeded_cb (DBusGProxy *proxy UNUSED, void * foo UNUSED) { - DEBUG ("Transfer succeded\n"); - sflphone_display_transfer_status("Transfer successfull"); + DEBUG ("Transfer succeded\n"); + sflphone_display_transfer_status ("Transfer successfull"); } static void -transfer_failed_cb(DBusGProxy *proxy UNUSED, void * foo UNUSED ) +transfer_failed_cb (DBusGProxy *proxy UNUSED, void * foo UNUSED) { - DEBUG ("Transfer failed\n"); - sflphone_display_transfer_status("Transfer failed"); + DEBUG ("Transfer failed\n"); + sflphone_display_transfer_status ("Transfer failed"); } static void -secure_sdes_on_cb(DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) +secure_sdes_on_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) { - DEBUG("SRTP using SDES is on"); - callable_obj_t *c = calllist_get(current_calls, callID); - if (c) - { - sflphone_srtp_sdes_on(c); - notify_secure_on(c); + DEBUG ("SRTP using SDES is on"); + callable_obj_t *c = calllist_get (current_calls, callID); + + if (c) { + sflphone_srtp_sdes_on (c); + notify_secure_on (c); } } static void -secure_sdes_off_cb(DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) +secure_sdes_off_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) { - DEBUG("SRTP using SDES is off"); - callable_obj_t *c = calllist_get(current_calls, callID); - if (c) - { - sflphone_srtp_sdes_off(c); - notify_secure_off(c); + DEBUG ("SRTP using SDES is off"); + callable_obj_t *c = calllist_get (current_calls, callID); + + if (c) { + sflphone_srtp_sdes_off (c); + notify_secure_off (c); } } static void -secure_zrtp_on_cb(DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* cipher, - void * foo UNUSED ) +secure_zrtp_on_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* cipher, + void * foo UNUSED) { - DEBUG ("SRTP using ZRTP is ON secure_on_cb"); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - c->_srtp_cipher = g_strdup(cipher); + DEBUG ("SRTP using ZRTP is ON secure_on_cb"); + callable_obj_t * c = calllist_get (current_calls, callID); - sflphone_srtp_zrtp_on(c); - notify_secure_on(c); + if (c) { + c->_srtp_cipher = g_strdup (cipher); + + sflphone_srtp_zrtp_on (c); + notify_secure_on (c); } } static void -secure_zrtp_off_cb(DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED ) +secure_zrtp_off_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { - DEBUG ("SRTP using ZRTP is OFF"); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - sflphone_srtp_zrtp_off(c); - notify_secure_off(c); + DEBUG ("SRTP using ZRTP is OFF"); + callable_obj_t * c = calllist_get (current_calls, callID); + + if (c) { + sflphone_srtp_zrtp_off (c); + notify_secure_off (c); } } static void -show_zrtp_sas_cb(DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* sas, - const gboolean verified, void * foo UNUSED ) +show_zrtp_sas_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* sas, + const gboolean verified, void * foo UNUSED) { - DEBUG ("Showing SAS"); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - sflphone_srtp_zrtp_show_sas(c, sas, verified); + DEBUG ("Showing SAS"); + callable_obj_t * c = calllist_get (current_calls, callID); + + if (c) { + sflphone_srtp_zrtp_show_sas (c, sas, verified); } } static void -confirm_go_clear_cb(DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED ) +confirm_go_clear_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { - DEBUG ("Confirm Go Clear request"); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - sflphone_confirm_go_clear(c); + DEBUG ("Confirm Go Clear request"); + callable_obj_t * c = calllist_get (current_calls, callID); + + if (c) { + sflphone_confirm_go_clear (c); } } static void -zrtp_not_supported_cb(DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED ) +zrtp_not_supported_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { - DEBUG ("ZRTP not supported on the other end"); - callable_obj_t * c = calllist_get(current_calls, callID); - if (c) - { - sflphone_srtp_zrtp_not_supported(c); - notify_zrtp_not_supported(c); + DEBUG ("ZRTP not supported on the other end"); + callable_obj_t * c = calllist_get (current_calls, callID); + + if (c) { + sflphone_srtp_zrtp_not_supported (c); + notify_zrtp_not_supported (c); } } static void -sip_call_state_cb(DBusGProxy *proxy UNUSED, const gchar* callID, - const gchar* description, const guint code, void * foo UNUSED ) +sip_call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, + const gchar* description, const guint code, void * foo UNUSED) { - callable_obj_t * c = NULL; - c = calllist_get(current_calls, callID); + callable_obj_t * c = NULL; + c = calllist_get (current_calls, callID); - if (c != NULL) - { - DEBUG("sip_call_state_cb received code %d", code); - sflphone_call_state_changed(c, description, code); + if (c != NULL) { + DEBUG ("sip_call_state_cb received code %d", code); + sflphone_call_state_changed (c, description, code); } } static void -error_alert(DBusGProxy *proxy UNUSED, int errCode, void * foo UNUSED ) +error_alert (DBusGProxy *proxy UNUSED, int errCode, void * foo UNUSED) { - ERROR ("Error notifying : (%i)", errCode); - sflphone_throw_exception(errCode); + ERROR ("Error notifying : (%i)", errCode); + sflphone_throw_exception (errCode); } gboolean dbus_connect() { - GError *error = NULL; - connection = NULL; - instanceProxy = NULL; - - g_type_init(); - - connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - - if (error) - { - ERROR ("Failed to open connection to bus: %s", - error->message); - g_error_free(error); - return FALSE; - } - - /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ - - instanceProxy = dbus_g_proxy_new_for_name(connection, - "org.sflphone.SFLphone", "/org/sflphone/SFLphone/Instance", - "org.sflphone.SFLphone.Instance"); - /* - instanceProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/Instance", - "org.sflphone.SFLphone.Instance", - &error); - */ - - if (instanceProxy == NULL) - { - ERROR ("Failed to get proxy to Instance"); - return FALSE; - } - - DEBUG ("DBus connected to Instance"); - - callManagerProxy = dbus_g_proxy_new_for_name(connection, - "org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", - "org.sflphone.SFLphone.CallManager"); - - /* - callManagerProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/CallManager", - "org.sflphone.SFLphone.CallManager", - &error); - */ - if (callManagerProxy == NULL) - { - ERROR ("Failed to get proxy to CallManagers"); - return FALSE; - } - - DEBUG ("DBus connected to CallManager"); - /* STRING STRING STRING Marshaller */ - /* Incoming call */ - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "incomingCall", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "incomingCall", - G_CALLBACK(incoming_call_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "zrtpNegotiationFailed", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "zrtpNegotiationFailed", - G_CALLBACK(zrtp_negotiation_failed_cb), NULL, NULL); - - /* Current codec */ - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "currentSelectedCodec", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "currentSelectedCodec", - G_CALLBACK(curent_selected_codec), NULL, NULL); - - /* Register a marshaller for STRING,STRING */ - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "callStateChanged", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "callStateChanged", - G_CALLBACK(call_state_cb), NULL, NULL); - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_INT, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "voiceMailNotify", G_TYPE_STRING, - G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "voiceMailNotify", - G_CALLBACK(voice_mail_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "incomingMessage", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "incomingMessage", - G_CALLBACK(incoming_message_cb), NULL, NULL); - - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_DOUBLE, G_TYPE_NONE, G_TYPE_STRING, - G_TYPE_DOUBLE, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "volumeChanged", G_TYPE_STRING, - G_TYPE_DOUBLE, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "volumeChanged", - G_CALLBACK(volume_changed_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "transferSucceded", G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "transferSucceded", - G_CALLBACK(transfer_succeded_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "transferFailed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "transferFailed", - G_CALLBACK(transfer_failed_cb), NULL, NULL); - - /* Conference related callback */ - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "conferenceChanged", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "conferenceChanged", - G_CALLBACK(conference_changed_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "conferenceCreated", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "conferenceCreated", - G_CALLBACK(conference_created_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "conferenceRemoved", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "conferenceRemoved", - G_CALLBACK(conference_removed_cb), NULL, NULL); - - /* Security related callbacks */ - - dbus_g_proxy_add_signal(callManagerProxy, "secureSdesOn", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "secureSdesOn", - G_CALLBACK(secure_sdes_on_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "secureSdesOff", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "secureSdesOff", - G_CALLBACK(secure_sdes_off_cb), NULL, NULL); - - /* Register a marshaller for STRING,STRING,BOOL */ - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_STRING_BOOL, G_TYPE_NONE, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "showSAS", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "showSAS", - G_CALLBACK(show_zrtp_sas_cb), NULL, NULL); - - dbus_g_proxy_add_signal(callManagerProxy, "secureZrtpOn", G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "secureZrtpOn", - G_CALLBACK(secure_zrtp_on_cb), NULL, NULL); - - /* Register a marshaller for STRING*/ - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(callManagerProxy, "secureZrtpOff", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "secureZrtpOff", - G_CALLBACK(secure_zrtp_off_cb), NULL, NULL); - dbus_g_proxy_add_signal(callManagerProxy, "zrtpNotSuppOther", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "zrtpNotSuppOther", - G_CALLBACK(zrtp_not_supported_cb), NULL, NULL); - dbus_g_proxy_add_signal(callManagerProxy, "confirmGoClear", G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "confirmGoClear", - G_CALLBACK(confirm_go_clear_cb), NULL, NULL); - - /* VOID STRING STRING INT */ - dbus_g_object_register_marshaller( - g_cclosure_user_marshal_VOID__STRING_STRING_INT, G_TYPE_NONE, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); - - dbus_g_proxy_add_signal(callManagerProxy, "sipCallStateChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(callManagerProxy, "sipCallStateChanged", - G_CALLBACK(sip_call_state_cb), NULL, NULL); - - configurationManagerProxy = dbus_g_proxy_new_for_name(connection, - "org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", - "org.sflphone.SFLphone.ConfigurationManager"); - - /* - configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/ConfigurationManager", - "org.sflphone.SFLphone.ConfigurationManager", - &error); - */ - if (!configurationManagerProxy) - { - ERROR ("Failed to get proxy to ConfigurationManager"); - return FALSE; - } - DEBUG ("DBus connected to ConfigurationManager"); - dbus_g_proxy_add_signal(configurationManagerProxy, "accountsChanged", - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(configurationManagerProxy, "accountsChanged", - G_CALLBACK(accounts_changed_cb), NULL, NULL); - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__INT, - G_TYPE_NONE, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_add_signal(configurationManagerProxy, "errorAlert", G_TYPE_INT, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(configurationManagerProxy, "errorAlert", - G_CALLBACK(error_alert), NULL, NULL); - - /* Defines a default timeout for the proxies */ + GError *error = NULL; + connection = NULL; + instanceProxy = NULL; + + g_type_init(); + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (error) { + ERROR ("Failed to open connection to bus: %s", + error->message); + g_error_free (error); + return FALSE; + } + + /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ + + instanceProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", "/org/sflphone/SFLphone/Instance", + "org.sflphone.SFLphone.Instance"); + /* + instanceProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/Instance", + "org.sflphone.SFLphone.Instance", + &error); + */ + + if (instanceProxy == NULL) { + ERROR ("Failed to get proxy to Instance"); + return FALSE; + } + + DEBUG ("DBus connected to Instance"); + + callManagerProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", + "org.sflphone.SFLphone.CallManager"); + + /* + callManagerProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/CallManager", + "org.sflphone.SFLphone.CallManager", + &error); + */ + if (callManagerProxy == NULL) { + ERROR ("Failed to get proxy to CallManagers"); + return FALSE; + } + + DEBUG ("DBus connected to CallManager"); + /* STRING STRING STRING Marshaller */ + /* Incoming call */ + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "incomingCall", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "incomingCall", + G_CALLBACK (incoming_call_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "zrtpNegotiationFailed", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "zrtpNegotiationFailed", + G_CALLBACK (zrtp_negotiation_failed_cb), NULL, NULL); + + /* Current codec */ + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "currentSelectedCodec", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "currentSelectedCodec", + G_CALLBACK (curent_selected_codec), NULL, NULL); + + /* Register a marshaller for STRING,STRING */ + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "callStateChanged", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "callStateChanged", + G_CALLBACK (call_state_cb), NULL, NULL); + + dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__STRING_INT, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "voiceMailNotify", G_TYPE_STRING, + G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "voiceMailNotify", + G_CALLBACK (voice_mail_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "incomingMessage", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "incomingMessage", + G_CALLBACK (incoming_message_cb), NULL, NULL); + + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_DOUBLE, G_TYPE_NONE, G_TYPE_STRING, + G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "volumeChanged", G_TYPE_STRING, + G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "volumeChanged", + G_CALLBACK (volume_changed_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "transferSucceded", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "transferSucceded", + G_CALLBACK (transfer_succeded_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "transferFailed", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "transferFailed", + G_CALLBACK (transfer_failed_cb), NULL, NULL); + + /* Conference related callback */ + + dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "conferenceChanged", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "conferenceChanged", + G_CALLBACK (conference_changed_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "conferenceCreated", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "conferenceCreated", + G_CALLBACK (conference_created_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "conferenceRemoved", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "conferenceRemoved", + G_CALLBACK (conference_removed_cb), NULL, NULL); + + /* Security related callbacks */ + + dbus_g_proxy_add_signal (callManagerProxy, "secureSdesOn", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "secureSdesOn", + G_CALLBACK (secure_sdes_on_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "secureSdesOff", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "secureSdesOff", + G_CALLBACK (secure_sdes_off_cb), NULL, NULL); + + /* Register a marshaller for STRING,STRING,BOOL */ + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_STRING_BOOL, G_TYPE_NONE, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "showSAS", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "showSAS", + G_CALLBACK (show_zrtp_sas_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, "secureZrtpOn", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "secureZrtpOn", + G_CALLBACK (secure_zrtp_on_cb), NULL, NULL); + + /* Register a marshaller for STRING*/ + dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "secureZrtpOff", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "secureZrtpOff", + G_CALLBACK (secure_zrtp_off_cb), NULL, NULL); + dbus_g_proxy_add_signal (callManagerProxy, "zrtpNotSuppOther", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "zrtpNotSuppOther", + G_CALLBACK (zrtp_not_supported_cb), NULL, NULL); + dbus_g_proxy_add_signal (callManagerProxy, "confirmGoClear", G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "confirmGoClear", + G_CALLBACK (confirm_go_clear_cb), NULL, NULL); + + /* VOID STRING STRING INT */ + dbus_g_object_register_marshaller ( + g_cclosure_user_marshal_VOID__STRING_STRING_INT, G_TYPE_NONE, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_add_signal (callManagerProxy, "sipCallStateChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, "sipCallStateChanged", + G_CALLBACK (sip_call_state_cb), NULL, NULL); + + configurationManagerProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", + "org.sflphone.SFLphone.ConfigurationManager"); + + /* + configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/ConfigurationManager", + "org.sflphone.SFLphone.ConfigurationManager", + &error); + */ + if (!configurationManagerProxy) { + ERROR ("Failed to get proxy to ConfigurationManager"); + return FALSE; + } + + DEBUG ("DBus connected to ConfigurationManager"); + dbus_g_proxy_add_signal (configurationManagerProxy, "accountsChanged", + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (configurationManagerProxy, "accountsChanged", + G_CALLBACK (accounts_changed_cb), NULL, NULL); + + dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__INT, + G_TYPE_NONE, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_add_signal (configurationManagerProxy, "errorAlert", G_TYPE_INT, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (configurationManagerProxy, "errorAlert", + G_CALLBACK (error_alert), NULL, NULL); + + /* Defines a default timeout for the proxies */ #if HAVE_DBUS_G_PROXY_SET_DEFAULT_TIMEOUT - dbus_g_proxy_set_default_timeout(callManagerProxy, DEFAULT_DBUS_TIMEOUT); - dbus_g_proxy_set_default_timeout(instanceProxy, DEFAULT_DBUS_TIMEOUT); - dbus_g_proxy_set_default_timeout(configurationManagerProxy, DEFAULT_DBUS_TIMEOUT); + dbus_g_proxy_set_default_timeout (callManagerProxy, DEFAULT_DBUS_TIMEOUT); + dbus_g_proxy_set_default_timeout (instanceProxy, DEFAULT_DBUS_TIMEOUT); + dbus_g_proxy_set_default_timeout (configurationManagerProxy, DEFAULT_DBUS_TIMEOUT); #endif - return TRUE; + return TRUE; } void dbus_clean() { - g_object_unref(callManagerProxy); - g_object_unref(configurationManagerProxy); - g_object_unref(instanceProxy); + g_object_unref (callManagerProxy); + g_object_unref (configurationManagerProxy); + g_object_unref (instanceProxy); } void -dbus_hold(const callable_obj_t * c) +dbus_hold (const callable_obj_t * c) { - DEBUG("dbus_hold %s\n", c->_callID); + DEBUG ("dbus_hold %s\n", c->_callID); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hold(callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call hold() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hold (callManagerProxy, c->_callID, &error); + + if (error) { + ERROR ("Failed to call hold() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_unhold(const callable_obj_t * c) +dbus_unhold (const callable_obj_t * c) { - DEBUG("dbus_unhold %s\n", c->_callID); + DEBUG ("dbus_unhold %s\n", c->_callID); + + GError *error = NULL; + org_sflphone_SFLphone_CallManager_unhold (callManagerProxy, c->_callID, &error); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_unhold(callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call unhold() on CallManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call unhold() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_hold_conference(const conference_obj_t * c) +dbus_hold_conference (const conference_obj_t * c) { - DEBUG("dbus_hold_conference %s\n", c->_confID); + DEBUG ("dbus_hold_conference %s\n", c->_confID); + + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hold_conference (callManagerProxy, + c->_confID, &error); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hold_conference(callManagerProxy, - c->_confID, &error); - if (error) - { - ERROR ("Failed to call hold() on CallManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call hold() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_unhold_conference(const conference_obj_t * c) +dbus_unhold_conference (const conference_obj_t * c) { - DEBUG("dbus_unhold_conference %s\n", c->_confID); + DEBUG ("dbus_unhold_conference %s\n", c->_confID); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_unhold_conference(callManagerProxy, - c->_confID, &error); - if (error) - { - ERROR ("Failed to call unhold() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_unhold_conference (callManagerProxy, + c->_confID, &error); + + if (error) { + ERROR ("Failed to call unhold() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_hang_up(const callable_obj_t * c) +dbus_hang_up (const callable_obj_t * c) { - DEBUG("dbus_hang_up %s\n", c->_callID); + DEBUG ("dbus_hang_up %s\n", c->_callID); + + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hang_up (callManagerProxy, c->_callID, + &error); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hang_up(callManagerProxy, c->_callID, - &error); - if (error) - { - ERROR ("Failed to call hang_up() on CallManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call hang_up() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_hang_up_conference(const conference_obj_t * c) +dbus_hang_up_conference (const conference_obj_t * c) { - DEBUG("dbus_hang_up_conference %s\n", c->_confID); + DEBUG ("dbus_hang_up_conference %s\n", c->_confID); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hang_up_conference(callManagerProxy, - c->_confID, &error); - if (error) - { - ERROR ("Failed to call hang_up() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hang_up_conference (callManagerProxy, + c->_confID, &error); + + if (error) { + ERROR ("Failed to call hang_up() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_transfert(const callable_obj_t * c) +dbus_transfert (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_transfert(callManagerProxy, c->_callID, - c->_trsft_to, &error); - if (error) - { - ERROR ("Failed to call transfert() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_transfert (callManagerProxy, c->_callID, + c->_trsft_to, &error); + + if (error) { + ERROR ("Failed to call transfert() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_accept(const callable_obj_t * c) +dbus_accept (const callable_obj_t * c) { #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink(FALSE); + status_tray_icon_blink (FALSE); #endif - DEBUG("dbus_accept %s\n", c->_callID); + DEBUG ("dbus_accept %s\n", c->_callID); + + GError *error = NULL; + org_sflphone_SFLphone_CallManager_accept (callManagerProxy, c->_callID, &error); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_accept(callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call accept(%s) on CallManager: %s", c->_callID, - (error->message == NULL ? g_quark_to_string(error->domain): error->message)); - g_error_free(error); + if (error) { + ERROR ("Failed to call accept(%s) on CallManager: %s", c->_callID, + (error->message == NULL ? g_quark_to_string (error->domain) : error->message)); + g_error_free (error); } } void -dbus_refuse(const callable_obj_t * c) +dbus_refuse (const callable_obj_t * c) { #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink(FALSE); + status_tray_icon_blink (FALSE); #endif - DEBUG("dbus_refuse %s\n", c->_callID); + DEBUG ("dbus_refuse %s\n", c->_callID); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_refuse(callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call refuse() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_refuse (callManagerProxy, c->_callID, &error); + + if (error) { + ERROR ("Failed to call refuse() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_place_call(const callable_obj_t * c) +dbus_place_call (const callable_obj_t * c) { - DEBUG("dbus_place_call %s\n", c->_callID); + DEBUG ("dbus_place_call %s\n", c->_callID); + + GError *error = NULL; + org_sflphone_SFLphone_CallManager_place_call (callManagerProxy, c->_accountID, + c->_callID, c->_peer_number, &error); - GError *error = NULL; - org_sflphone_SFLphone_CallManager_place_call(callManagerProxy, c->_accountID, - c->_callID, c->_peer_number, &error); - if (error) - { - ERROR ("Failed to call placeCall() on CallManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call placeCall() on CallManager: %s", + error->message); + g_error_free (error); } } gchar** dbus_account_list() { - GError *error = NULL; - char ** array; + GError *error = NULL; + char ** array; - if (!org_sflphone_SFLphone_ConfigurationManager_get_account_list( - configurationManagerProxy, &array, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_account_list) exception %s: %s", dbus_g_error_get_name(error), error->message); + if (!org_sflphone_SFLphone_ConfigurationManager_get_account_list ( + configurationManagerProxy, &array, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_account_list) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_account_list: %s", error->message); } - else - { - ERROR("Error while calling get_account_list: %s", error->message); - } - g_error_free(error); - return NULL; - } - else - { - DEBUG ("DBus called get_account_list() on ConfigurationManager"); - return array; + + g_error_free (error); + return NULL; + } else { + DEBUG ("DBus called get_account_list() on ConfigurationManager"); + return array; } } GHashTable* -dbus_account_details(gchar * accountID) +dbus_account_details (gchar * accountID) { - GError *error = NULL; - GHashTable * details; + GError *error = NULL; + GHashTable * details; - DEBUG("Dbus: Get account detail accountid %s", accountID); + DEBUG ("Dbus: Get account detail accountid %s", accountID); - if (!org_sflphone_SFLphone_ConfigurationManager_get_account_details( - configurationManagerProxy, accountID, &details, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name(error), error->message); + if (!org_sflphone_SFLphone_ConfigurationManager_get_account_details ( + configurationManagerProxy, accountID, &details, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_account_details: %s", error->message); } - else - { - ERROR("Error while calling get_account_details: %s", error->message); - } - g_error_free(error); - return NULL; - } - else - { - return details; + + g_error_free (error); + return NULL; + } else { + return details; } } void -dbus_set_credential(account_t *a, int index) +dbus_set_credential (account_t *a, int index) { - DEBUG("Sending credential %d to server", index); - GError *error = NULL; - GHashTable * credential = g_ptr_array_index(a->credential_information, index); + DEBUG ("Sending credential %d to server", index); + GError *error = NULL; + GHashTable * credential = g_ptr_array_index (a->credential_information, index); - if (credential == NULL) - { - DEBUG("Credential %d was deleted", index); - } - else - { - org_sflphone_SFLphone_ConfigurationManager_set_credential( - configurationManagerProxy, a->accountID, index, credential, &error); + if (credential == NULL) { + DEBUG ("Credential %d was deleted", index); + } else { + org_sflphone_SFLphone_ConfigurationManager_set_credential ( + configurationManagerProxy, a->accountID, index, credential, &error); } - if (error) - { - ERROR ("Failed to call set_credential() on ConfigurationManager: %s", - error->message); - g_error_free(error); - } -} -void -dbus_set_number_of_credential(account_t *a, int number) -{ - DEBUG("Sending number of credential %d to server", number); - GError *error = NULL; - - org_sflphone_SFLphone_ConfigurationManager_set_number_of_credential( - configurationManagerProxy, a->accountID, number, &error); - - if (error) - { - ERROR ("Failed to call set_number_of_credential() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call set_credential() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } void -dbus_delete_all_credential(account_t *a) +dbus_delete_all_credential (account_t *a) { - DEBUG("Deleting all credentials\n"); - GError *error = NULL; + DEBUG ("Deleting all credentials\n"); + GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_delete_all_credential( - configurationManagerProxy, a->accountID, &error); + org_sflphone_SFLphone_ConfigurationManager_delete_all_credential ( + configurationManagerProxy, a->accountID, &error); - if (error) - { - ERROR ("Failed to call deleteAllCredential on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call deleteAllCredential on ConfigurationManager: %s", + error->message); + g_error_free (error); } } int -dbus_get_number_of_credential(gchar * accountID) +dbus_get_number_of_credential (gchar * accountID) { - GError *error = NULL; - int number = 0; + GError *error = NULL; + int number = 0; - DEBUG("Getting number of credential for account %s", accountID); + DEBUG ("Getting number of credential for account %s", accountID); - if (!org_sflphone_SFLphone_ConfigurationManager_get_number_of_credential( - configurationManagerProxy, accountID, &number, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name(error), error->message); + if (!org_sflphone_SFLphone_ConfigurationManager_get_number_of_credential ( + configurationManagerProxy, accountID, &number, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_account_details: %s", error->message); } - else - { - ERROR("Error while calling get_account_details: %s", error->message); - } - g_error_free(error); - return 0; - } - else - { - DEBUG("%d credential(s) found for account %s", number, accountID); - return number; + + g_error_free (error); + return 0; + } else { + DEBUG ("%d credential(s) found for account %s", number, accountID); + return number; } } GHashTable* -dbus_get_credential(gchar * accountID, int index) -{ - GError *error = NULL; - GHashTable * details; - - if (!org_sflphone_SFLphone_ConfigurationManager_get_credential( - configurationManagerProxy, accountID, index, &details, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR("Error while calling get_account_details: %s", error->message); +dbus_get_credential (gchar * accountID, int index) +{ + GError *error = NULL; + GHashTable * details; + + if (!org_sflphone_SFLphone_ConfigurationManager_get_credential ( + configurationManagerProxy, accountID, index, &details, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_account_details: %s", error->message); } - g_error_free(error); - return NULL; - } - else - { - return details; + + g_error_free (error); + return NULL; + } else { + return details; } } GHashTable* -dbus_get_ip2_ip_details(void) -{ - GError *error = NULL; - GHashTable * details; - if (!org_sflphone_SFLphone_ConfigurationManager_get_ip2_ip_details( - configurationManagerProxy, &details, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_ip2_ip_details) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR("Error while calling get_ip2_ip_details: %s", error->message); +dbus_get_ip2_ip_details (void) +{ + GError *error = NULL; + GHashTable * details; + + if (!org_sflphone_SFLphone_ConfigurationManager_get_ip2_ip_details ( + configurationManagerProxy, &details, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_ip2_ip_details) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_ip2_ip_details: %s", error->message); } - g_error_free(error); - return NULL; - } - else - { - return details; + + g_error_free (error); + return NULL; + } else { + return details; } } void -dbus_set_ip2ip_details(GHashTable * properties) +dbus_set_ip2ip_details (GHashTable * properties) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_ip2_ip_details( - configurationManagerProxy, properties, &error); - if (error) - { - ERROR ("Failed to call set_ip_2ip_details() on ConfigurationManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_ip2_ip_details ( + configurationManagerProxy, properties, &error); + + if (error) { + ERROR ("Failed to call set_ip_2ip_details() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } void -dbus_send_register(gchar* accountID, const guint enable) +dbus_send_register (gchar* accountID, const guint enable) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_send_register( - configurationManagerProxy, accountID, enable, &error); - if (error) - { - ERROR ("Failed to call send_register() on ConfigurationManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_send_register ( + configurationManagerProxy, accountID, enable, &error); + + if (error) { + ERROR ("Failed to call send_register() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } void -dbus_remove_account(gchar * accountID) +dbus_remove_account (gchar * accountID) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_remove_account( - configurationManagerProxy, accountID, &error); - if (error) - { - ERROR ("Failed to call remove_account() on ConfigurationManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_remove_account ( + configurationManagerProxy, accountID, &error); + + if (error) { + ERROR ("Failed to call remove_account() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } void -dbus_set_account_details(account_t *a) +dbus_set_account_details (account_t *a) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_account_details( - configurationManagerProxy, a->accountID, a->properties, &error); - if (error) - { - ERROR ("Failed to call set_account_details() on ConfigurationManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_account_details ( + configurationManagerProxy, a->accountID, a->properties, &error); + + if (error) { + ERROR ("Failed to call set_account_details() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } gchar* -dbus_add_account(account_t *a) +dbus_add_account (account_t *a) { - gchar* accountId; - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_add_account( - configurationManagerProxy, a->properties, &accountId, &error); - if (error) - { - ERROR ("Failed to call add_account() on ConfigurationManager: %s", - error->message); - g_error_free(error); + gchar* accountId; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_add_account ( + configurationManagerProxy, a->properties, &accountId, &error); + + if (error) { + ERROR ("Failed to call add_account() on ConfigurationManager: %s", + error->message); + g_error_free (error); } - return accountId; + + return accountId; } void -dbus_set_volume(const gchar * device, gdouble value) +dbus_set_volume (const gchar * device, gdouble value) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_set_volume(callManagerProxy, device, value, - &error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_set_volume (callManagerProxy, device, value, + &error); - if (error) - { - ERROR ("Failed to call set_volume() on callManagerProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call set_volume() on callManagerProxy: %s", + error->message); + g_error_free (error); } } gdouble -dbus_get_volume(const gchar * device) +dbus_get_volume (const gchar * device) { - gdouble value; - GError *error = NULL; + gdouble value; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_get_volume(callManagerProxy, device, - &value, &error); + org_sflphone_SFLphone_CallManager_get_volume (callManagerProxy, device, + &value, &error); - if (error) - { - ERROR ("Failed to call get_volume() on callManagerProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call get_volume() on callManagerProxy: %s", + error->message); + g_error_free (error); } - return value; + + return value; } void -dbus_play_dtmf(const gchar * key) +dbus_play_dtmf (const gchar * key) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_play_dt_mf(callManagerProxy, key, &error); + org_sflphone_SFLphone_CallManager_play_dt_mf (callManagerProxy, key, &error); - if (error) - { - ERROR ("Failed to call playDTMF() on callManagerProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call playDTMF() on callManagerProxy: %s", + error->message); + g_error_free (error); } } void -dbus_start_tone(const int start, const guint type) +dbus_start_tone (const int start, const guint type) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_start_tone(callManagerProxy, start, type, - &error); + org_sflphone_SFLphone_CallManager_start_tone (callManagerProxy, start, type, + &error); - if (error) - { - ERROR ("Failed to call startTone() on callManagerProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call startTone() on callManagerProxy: %s", + error->message); + g_error_free (error); } } void -dbus_register(int pid, gchar * name) +dbus_register (int pid, gchar * name) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_Instance_register(instanceProxy, pid, name, &error); + org_sflphone_SFLphone_Instance_register (instanceProxy, pid, name, &error); - if (error) - { - ERROR ("Failed to call register() on instanceProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call register() on instanceProxy: %s", + error->message); + g_error_free (error); } } void -dbus_unregister(int pid) +dbus_unregister (int pid) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_Instance_unregister(instanceProxy, pid, &error); + org_sflphone_SFLphone_Instance_unregister (instanceProxy, pid, &error); - if (error) - { - ERROR ("Failed to call unregister() on instanceProxy: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call unregister() on instanceProxy: %s", + error->message); + g_error_free (error); } } @@ -1225,88 +1144,87 @@ gchar** dbus_codec_list() { - GError *error = NULL; - gchar** array = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_codec_list( - configurationManagerProxy, &array, &error); + GError *error = NULL; + gchar** array = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_codec_list ( + configurationManagerProxy, &array, &error); - if (error) - { - ERROR ("Failed to call get_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call get_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); } - return array; + + return array; } gchar** -dbus_codec_details(int payload) +dbus_codec_details (int payload) { - GError *error = NULL; - gchar ** array; - org_sflphone_SFLphone_ConfigurationManager_get_codec_details( - configurationManagerProxy, payload, &array, &error); + GError *error = NULL; + gchar ** array; + org_sflphone_SFLphone_ConfigurationManager_get_codec_details ( + configurationManagerProxy, payload, &array, &error); - if (error) - { - ERROR ("Failed to call get_codec_details() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call get_codec_details() on ConfigurationManager: %s", + error->message); + g_error_free (error); } - return array; + + return array; } gchar* -dbus_get_current_codec_name(const callable_obj_t * c) +dbus_get_current_codec_name (const callable_obj_t * c) { - gchar* codecName = ""; - GError* error = NULL; + gchar* codecName = ""; + GError* error = NULL; + + org_sflphone_SFLphone_CallManager_get_current_codec_name (callManagerProxy, + c->_callID, &codecName, &error); - org_sflphone_SFLphone_CallManager_get_current_codec_name(callManagerProxy, - c->_callID, &codecName, &error); - if (error) - { - g_error_free(error); + if (error) { + g_error_free (error); } - DEBUG("dbus_get_current_codec_name : codecName : %s", codecName); + DEBUG ("dbus_get_current_codec_name : codecName : %s", codecName); - return codecName; + return codecName; } gchar** -dbus_get_active_codec_list(gchar *accountID) +dbus_get_active_codec_list (gchar *accountID) { - gchar ** array; - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list( - configurationManagerProxy, accountID, &array, &error); + gchar ** array; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list ( + configurationManagerProxy, accountID, &array, &error); - if (error) - { - ERROR ("Failed to call get_active_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call get_active_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); } - return array; + + return array; } void -dbus_set_active_codec_list(const gchar** list, const gchar *accountID) +dbus_set_active_codec_list (const gchar** list, const gchar *accountID) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list( - configurationManagerProxy, list, accountID, &error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list ( + configurationManagerProxy, list, accountID, &error); - if (error) - { - ERROR ("Failed to call set_active_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error) { + ERROR ("Failed to call set_active_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } @@ -1317,53 +1235,48 @@ dbus_set_active_codec_list(const gchar** list, const gchar *accountID) gchar** dbus_get_audio_plugin_list() { - gchar** array; - GError* error = NULL; + gchar** array; + GError* error = NULL; - if (!org_sflphone_SFLphone_ConfigurationManager_get_audio_plugin_list( - configurationManagerProxy, &array, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_output_plugin_list) exception %s: %s", dbus_g_error_get_name(error), error->message); + if (!org_sflphone_SFLphone_ConfigurationManager_get_audio_plugin_list ( + configurationManagerProxy, &array, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_output_plugin_list) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_out_plugin_list: %s", error->message); } - else - { - ERROR("Error while calling get_out_plugin_list: %s", error->message); - } - g_error_free(error); - return NULL; - } - else - { - return array; + + g_error_free (error); + return NULL; + } else { + return array; } } void -dbus_set_input_audio_plugin(gchar* audioPlugin) +dbus_set_input_audio_plugin (gchar* audioPlugin) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin( - configurationManagerProxy, audioPlugin, &error); - if (error) - { - ERROR("Failed to call set_input_audio_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin ( + configurationManagerProxy, audioPlugin, &error); + + if (error) { + ERROR ("Failed to call set_input_audio_plugin() on ConfigurationManager: %s", error->message); + g_error_free (error); } } void -dbus_set_output_audio_plugin(gchar* audioPlugin) +dbus_set_output_audio_plugin (gchar* audioPlugin) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin( - configurationManagerProxy, audioPlugin, &error); - if (error) - { - ERROR("Failed to call set_output_audio_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin ( + configurationManagerProxy, audioPlugin, &error); + + if (error) { + ERROR ("Failed to call set_output_audio_plugin() on ConfigurationManager: %s", error->message); + g_error_free (error); } } @@ -1373,31 +1286,32 @@ dbus_set_output_audio_plugin(gchar* audioPlugin) gchar** dbus_get_audio_output_device_list() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_output_device_list( - configurationManagerProxy, &array, &error); - if (error) - { - ERROR("Failed to call get_audio_output_device_list() on ConfigurationManager: %s", error->message); - g_error_free(error); + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_output_device_list ( + configurationManagerProxy, &array, &error); + + if (error) { + ERROR ("Failed to call get_audio_output_device_list() on ConfigurationManager: %s", error->message); + g_error_free (error); } - return array; + + return array; } /** * Set audio output device from its index */ void -dbus_set_audio_output_device(const int index) +dbus_set_audio_output_device (const int index) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_output_device( - configurationManagerProxy, index, &error); - if (error) - { - ERROR("Failed to call set_audio_output_device() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_output_device ( + configurationManagerProxy, index, &error); + + if (error) { + ERROR ("Failed to call set_audio_output_device() on ConfigurationManager: %s", error->message); + g_error_free (error); } } @@ -1405,15 +1319,15 @@ dbus_set_audio_output_device(const int index) * Set audio input device from its index */ void -dbus_set_audio_input_device(const int index) +dbus_set_audio_input_device (const int index) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_input_device( - configurationManagerProxy, index, &error); - if (error) - { - ERROR("Failed to call set_audio_input_device() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_input_device ( + configurationManagerProxy, index, &error); + + if (error) { + ERROR ("Failed to call set_audio_input_device() on ConfigurationManager: %s", error->message); + g_error_free (error); } } @@ -1421,15 +1335,15 @@ dbus_set_audio_input_device(const int index) * Set adio ringtone device from its index */ void -dbus_set_audio_ringtone_device(const int index) +dbus_set_audio_ringtone_device (const int index) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_ringtone_device( - configurationManagerProxy, index, &error); - if(error) - { - ERROR("Failed to call set_audio_ringtone_device() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_ringtone_device ( + configurationManagerProxy, index, &error); + + if (error) { + ERROR ("Failed to call set_audio_ringtone_device() on ConfigurationManager: %s", error->message); + g_error_free (error); } } @@ -1439,16 +1353,17 @@ dbus_set_audio_ringtone_device(const int index) gchar** dbus_get_audio_input_device_list() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_input_device_list( - configurationManagerProxy, &array, &error); - if (error) - { - ERROR("Failed to call get_audio_input_device_list() on ConfigurationManager: %s", error->message); - g_error_free(error); + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_input_device_list ( + configurationManagerProxy, &array, &error); + + if (error) { + ERROR ("Failed to call get_audio_input_device_list() on ConfigurationManager: %s", error->message); + g_error_free (error); } - return array; + + return array; } /** @@ -1457,34 +1372,36 @@ dbus_get_audio_input_device_list() gchar** dbus_get_current_audio_devices_index() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_current_audio_devices_index( - configurationManagerProxy, &array, &error); - if (error) - { - ERROR("Failed to call get_current_audio_devices_index() on ConfigurationManager: %s", error->message); - g_error_free(error); + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_current_audio_devices_index ( + configurationManagerProxy, &array, &error); + + if (error) { + ERROR ("Failed to call get_current_audio_devices_index() on ConfigurationManager: %s", error->message); + g_error_free (error); } - return array; + + return array; } /** * Get index */ int -dbus_get_audio_device_index(const gchar *name) +dbus_get_audio_device_index (const gchar *name) { - int index; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_device_index( - configurationManagerProxy, name, &index, &error); - if (error) - { - ERROR("Failed to call get_audio_device_index() on ConfigurationManager: %s", error->message); - g_error_free(error); + int index; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_device_index ( + configurationManagerProxy, name, &index, &error); + + if (error) { + ERROR ("Failed to call get_audio_device_index() on ConfigurationManager: %s", error->message); + g_error_free (error); } - return index; + + return index; } /** @@ -1493,47 +1410,50 @@ dbus_get_audio_device_index(const gchar *name) gchar* dbus_get_current_audio_output_plugin() { - gchar* plugin = ""; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_current_audio_output_plugin( - configurationManagerProxy, &plugin, &error); - if (error) - { - ERROR("Failed to call get_current_audio_output_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); + gchar* plugin = ""; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_current_audio_output_plugin ( + configurationManagerProxy, &plugin, &error); + + if (error) { + ERROR ("Failed to call get_current_audio_output_plugin() on ConfigurationManager: %s", error->message); + g_error_free (error); } - return plugin; + + return plugin; } /** - * Get echo canceller state + * Get echo canceller state */ gchar* dbus_get_echo_cancel_state() { - gchar* state = ""; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_echo_cancel_state(configurationManagerProxy, &state, &error); - if(error) { - ERROR("DBus: Failed to call get_echo_cancel_state() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return state; + gchar* state = ""; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_echo_cancel_state (configurationManagerProxy, &state, &error); + + if (error) { + ERROR ("DBus: Failed to call get_echo_cancel_state() on ConfigurationManager: %s", error->message); + g_error_free (error); + } + + return state; } /** * Set echo canceller state */ void -dbus_set_echo_cancel_state(gchar* state) +dbus_set_echo_cancel_state (gchar* state) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_echo_cancel_state( - configurationManagerProxy, state, &error); - if (error) - { - ERROR("Failed to call set_echo_cancel_state() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_echo_cancel_state ( + configurationManagerProxy, state, &error); + + if (error) { + ERROR ("Failed to call set_echo_cancel_state() on ConfigurationManager: %s", error->message); + g_error_free (error); } } @@ -1544,315 +1464,325 @@ dbus_set_echo_cancel_state(gchar* state) gchar* dbus_get_noise_suppress_state() { - gchar* state = ""; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_noise_suppress_state(configurationManagerProxy, &state, &error); - if(error) { - ERROR("DBus: Failed to call get_noise_suppress_state() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return state; + gchar* state = ""; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_noise_suppress_state (configurationManagerProxy, &state, &error); + + if (error) { + ERROR ("DBus: Failed to call get_noise_suppress_state() on ConfigurationManager: %s", error->message); + g_error_free (error); + } + + return state; } /** * Set echo canceller state */ void -dbus_set_noise_suppress_state(gchar* state) +dbus_set_noise_suppress_state (gchar* state) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_noise_suppress_state( - configurationManagerProxy, state, &error); - if (error) - { - ERROR("Failed to call set_noise_suppress_state() on ConfigurationManager: %s", error->message); - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_noise_suppress_state ( + configurationManagerProxy, state, &error); + + if (error) { + ERROR ("Failed to call set_noise_suppress_state() on ConfigurationManager: %s", error->message); + g_error_free (error); } } gchar* -dbus_get_ringtone_choice(const gchar *accountID) +dbus_get_ringtone_choice (const gchar *accountID) { - gchar* tone; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_ringtone_choice( - configurationManagerProxy, accountID, &tone, &error); - if (error) - { - g_error_free(error); + gchar* tone; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_ringtone_choice ( + configurationManagerProxy, accountID, &tone, &error); + + if (error) { + g_error_free (error); } - return tone; + + return tone; } void -dbus_set_ringtone_choice(const gchar *accountID, const gchar* tone) +dbus_set_ringtone_choice (const gchar *accountID, const gchar* tone) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_ringtone_choice( - configurationManagerProxy, accountID, tone, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_ringtone_choice ( + configurationManagerProxy, accountID, tone, &error); + + if (error) { + g_error_free (error); } } int -dbus_is_ringtone_enabled(const gchar *accountID) +dbus_is_ringtone_enabled (const gchar *accountID) { - int res; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled( - configurationManagerProxy, accountID, &res, &error); - if (error) - { - g_error_free(error); + int res; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled ( + configurationManagerProxy, accountID, &res, &error); + + if (error) { + g_error_free (error); } - return res; + + return res; } void -dbus_ringtone_enabled(const gchar *accountID) +dbus_ringtone_enabled (const gchar *accountID) { - DEBUG("DBUS: Ringtone enabled %s", accountID); + DEBUG ("DBUS: Ringtone enabled %s", accountID); + + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled ( + configurationManagerProxy, accountID, &error); - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled( - configurationManagerProxy, accountID, &error); - if (error) - { - g_error_free(error); + if (error) { + g_error_free (error); } } gboolean dbus_is_md5_credential_hashing() { - int res; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_is_md5_credential_hashing( - configurationManagerProxy, &res, &error); - if (error) - { - g_error_free(error); + int res; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_is_md5_credential_hashing ( + configurationManagerProxy, &res, &error); + + if (error) { + g_error_free (error); } - return res; + + return res; } void -dbus_set_md5_credential_hashing(gboolean enabled) +dbus_set_md5_credential_hashing (gboolean enabled) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_md5_credential_hashing( - configurationManagerProxy, enabled, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_md5_credential_hashing ( + configurationManagerProxy, enabled, &error); + + if (error) { + g_error_free (error); } } int dbus_is_iax2_enabled() { - int res; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_is_iax2_enabled( - configurationManagerProxy, &res, &error); - if (error) - { - g_error_free(error); + int res; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_is_iax2_enabled ( + configurationManagerProxy, &res, &error); + + if (error) { + g_error_free (error); } - return res; + + return res; } void -dbus_join_participant(const gchar* sel_callID, const gchar* drag_callID) +dbus_join_participant (const gchar* sel_callID, const gchar* drag_callID) { - DEBUG("dbus_join_participant %s and %s\n", sel_callID, drag_callID); + DEBUG ("dbus_join_participant %s and %s\n", sel_callID, drag_callID); - GError* error = NULL; + GError* error = NULL; - org_sflphone_SFLphone_CallManager_join_participant(callManagerProxy, - sel_callID, drag_callID, &error); - if (error) - { - g_error_free(error); + org_sflphone_SFLphone_CallManager_join_participant (callManagerProxy, + sel_callID, drag_callID, &error); + + if (error) { + g_error_free (error); } } void -dbus_add_participant(const gchar* callID, const gchar* confID) +dbus_add_participant (const gchar* callID, const gchar* confID) { - DEBUG("dbus_add_participant %s and %s\n", callID, confID); + DEBUG ("dbus_add_participant %s and %s\n", callID, confID); + + GError* error = NULL; - GError* error = NULL; + org_sflphone_SFLphone_CallManager_add_participant (callManagerProxy, callID, + confID, &error); - org_sflphone_SFLphone_CallManager_add_participant(callManagerProxy, callID, - confID, &error); - if (error) - { - g_error_free(error); + if (error) { + g_error_free (error); } } void -dbus_add_main_participant(const gchar* confID) +dbus_add_main_participant (const gchar* confID) { - DEBUG("dbus_add_participant %s\n", confID); + DEBUG ("dbus_add_participant %s\n", confID); + + GError* error = NULL; - GError* error = NULL; + org_sflphone_SFLphone_CallManager_add_main_participant (callManagerProxy, + confID, &error); - org_sflphone_SFLphone_CallManager_add_main_participant(callManagerProxy, - confID, &error); - if (error) - { - g_error_free(error); + if (error) { + g_error_free (error); } } void -dbus_detach_participant(const gchar* callID) +dbus_detach_participant (const gchar* callID) { - DEBUG("dbus_detach_participant %s\n", callID); + DEBUG ("dbus_detach_participant %s\n", callID); - GError* error = NULL; - org_sflphone_SFLphone_CallManager_detach_participant(callManagerProxy, - callID, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_CallManager_detach_participant (callManagerProxy, + callID, &error); + + if (error) { + g_error_free (error); } } -dbus_join_conference(const gchar* sel_confID, const gchar* drag_confID) +void +dbus_join_conference (const gchar* sel_confID, const gchar* drag_confID) { - DEBUG("dbus_join_conference %s and %s\n", sel_confID, drag_confID); + DEBUG ("dbus_join_conference %s and %s\n", sel_confID, drag_confID); - GError* error = NULL; + GError* error = NULL; - org_sflphone_SFLphone_CallManager_join_conference(callManagerProxy, - sel_confID, drag_confID, &error); - if (error) - { - g_error_free(error); + org_sflphone_SFLphone_CallManager_join_conference (callManagerProxy, + sel_confID, drag_confID, &error); + + if (error) { + g_error_free (error); } } void -dbus_set_record(const gchar* id) +dbus_set_record (const gchar* id) { - DEBUG("dbus_set_record %s", id); + DEBUG ("dbus_set_record %s", id); + + GError* error = NULL; + org_sflphone_SFLphone_CallManager_set_recording (callManagerProxy, id, &error); - GError* error = NULL; - org_sflphone_SFLphone_CallManager_set_recording(callManagerProxy, id, &error); - if (error) - { - g_error_free(error); + if (error) { + g_error_free (error); } } gboolean -dbus_get_is_recording(const callable_obj_t * c) +dbus_get_is_recording (const callable_obj_t * c) { - DEBUG("dbus_get_is_recording %s", c->_callID); - GError* error = NULL; - gboolean isRecording; - org_sflphone_SFLphone_CallManager_get_is_recording(callManagerProxy, - c->_callID, &isRecording, &error); - if (error) - { - g_error_free(error); + DEBUG ("dbus_get_is_recording %s", c->_callID); + GError* error = NULL; + gboolean isRecording; + org_sflphone_SFLphone_CallManager_get_is_recording (callManagerProxy, + c->_callID, &isRecording, &error); + + if (error) { + g_error_free (error); } - //DEBUG("RECORDING: %i",isRecording); - return isRecording; + + //DEBUG("RECORDING: %i",isRecording); + return isRecording; } void -dbus_set_record_path(const gchar* path) +dbus_set_record_path (const gchar* path) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_record_path( - configurationManagerProxy, path, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_record_path ( + configurationManagerProxy, path, &error); + + if (error) { + g_error_free (error); } } gchar* -dbus_get_record_path(void) +dbus_get_record_path (void) { - GError* error = NULL; - gchar *path; - org_sflphone_SFLphone_ConfigurationManager_get_record_path( - configurationManagerProxy, &path, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + gchar *path; + org_sflphone_SFLphone_ConfigurationManager_get_record_path ( + configurationManagerProxy, &path, &error); + + if (error) { + g_error_free (error); } - return path; + + return path; } void -dbus_set_history_limit(const guint days) +dbus_set_history_limit (const guint days) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_history_limit( - configurationManagerProxy, days, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_history_limit ( + configurationManagerProxy, days, &error); + + if (error) { + g_error_free (error); } } guint -dbus_get_history_limit(void) +dbus_get_history_limit (void) { - GError* error = NULL; - gint days = 30; - org_sflphone_SFLphone_ConfigurationManager_get_history_limit( - configurationManagerProxy, &days, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + gint days = 30; + org_sflphone_SFLphone_ConfigurationManager_get_history_limit ( + configurationManagerProxy, &days, &error); + + if (error) { + g_error_free (error); } - return (guint) days; + + return (guint) days; } void -dbus_set_audio_manager(int api) +dbus_set_audio_manager (int api) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_manager( - configurationManagerProxy, api, &error); - if (error) - { - g_error_free(error); + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_manager ( + configurationManagerProxy, api, &error); + + if (error) { + g_error_free (error); } } int -dbus_get_audio_manager(void) +dbus_get_audio_manager (void) { - int api; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_manager( - configurationManagerProxy, &api, &error); - if (error) - { - ERROR("Error calling dbus_get_audio_manager"); - g_error_free(error); + int api; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_manager ( + configurationManagerProxy, &api, &error); + + if (error) { + ERROR ("Error calling dbus_get_audio_manager"); + g_error_free (error); } - return api; + return api; } /* @@ -1891,445 +1821,430 @@ dbus_get_audio_manager(void) */ GHashTable* -dbus_get_addressbook_settings(void) +dbus_get_addressbook_settings (void) { - GError *error = NULL; - GHashTable *results = NULL; + GError *error = NULL; + GHashTable *results = NULL; + + //DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); - //DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); + org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings ( + configurationManagerProxy, &results, &error); - org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings( - configurationManagerProxy, &results, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); + g_error_free (error); } - return results; + return results; } void -dbus_set_addressbook_settings(GHashTable * settings) +dbus_set_addressbook_settings (GHashTable * settings) { - GError *error = NULL; + GError *error = NULL; - DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings"); + DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings"); - org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings( - configurationManagerProxy, settings, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings"); - g_error_free(error); + org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings ( + configurationManagerProxy, settings, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings"); + g_error_free (error); } } gchar** -dbus_get_addressbook_list(void) +dbus_get_addressbook_list (void) { - GError *error = NULL; - gchar** array; + GError *error = NULL; + gchar** array; + + org_sflphone_SFLphone_ConfigurationManager_get_addressbook_list ( + configurationManagerProxy, &array, &error); - org_sflphone_SFLphone_ConfigurationManager_get_addressbook_list( - configurationManagerProxy, &array, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_list"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_list"); + g_error_free (error); } - return array; + return array; } void -dbus_set_addressbook_list(const gchar** list) +dbus_set_addressbook_list (const gchar** list) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_addressbook_list( - configurationManagerProxy, list, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_list"); - g_error_free(error); + org_sflphone_SFLphone_ConfigurationManager_set_addressbook_list ( + configurationManagerProxy, list, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_list"); + g_error_free (error); } } GHashTable* -dbus_get_hook_settings(void) +dbus_get_hook_settings (void) { - GError *error = NULL; - GHashTable *results = NULL; + GError *error = NULL; + GHashTable *results = NULL; + + //DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); - //DEBUG ("Calling org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings"); + org_sflphone_SFLphone_ConfigurationManager_get_hook_settings ( + configurationManagerProxy, &results, &error); - org_sflphone_SFLphone_ConfigurationManager_get_hook_settings( - configurationManagerProxy, &results, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_hook_settings"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_hook_settings"); + g_error_free (error); } - return results; + return results; } void -dbus_set_hook_settings(GHashTable * settings) +dbus_set_hook_settings (GHashTable * settings) { - GError *error = NULL; + GError *error = NULL; + + org_sflphone_SFLphone_ConfigurationManager_set_hook_settings ( + configurationManagerProxy, settings, &error); - org_sflphone_SFLphone_ConfigurationManager_set_hook_settings( - configurationManagerProxy, settings, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_hook_settings"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_hook_settings"); + g_error_free (error); } } GHashTable* -dbus_get_call_details(const gchar *callID) +dbus_get_call_details (const gchar *callID) { - GError *error = NULL; - GHashTable *details = NULL; + GError *error = NULL; + GHashTable *details = NULL; - org_sflphone_SFLphone_CallManager_get_call_details(callManagerProxy, callID, - &details, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_call_details"); - g_error_free(error); + org_sflphone_SFLphone_CallManager_get_call_details (callManagerProxy, callID, + &details, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_call_details"); + g_error_free (error); } - return details; + return details; } gchar** -dbus_get_call_list(void) +dbus_get_call_list (void) { - GError *error = NULL; - gchar **list = NULL; + GError *error = NULL; + gchar **list = NULL; + + org_sflphone_SFLphone_CallManager_get_call_list (callManagerProxy, &list, + &error); - org_sflphone_SFLphone_CallManager_get_call_list(callManagerProxy, &list, - &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_call_list"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_call_list"); + g_error_free (error); } - return list; + return list; } gchar** -dbus_get_conference_list(void) +dbus_get_conference_list (void) { - GError *error = NULL; - gchar **list = NULL; + GError *error = NULL; + gchar **list = NULL; - org_sflphone_SFLphone_CallManager_get_conference_list(callManagerProxy, - &list, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_conference_list"); - g_error_free(error); + org_sflphone_SFLphone_CallManager_get_conference_list (callManagerProxy, + &list, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_conference_list"); + g_error_free (error); } - return list; + return list; } gchar** -dbus_get_participant_list(const char *confID) +dbus_get_participant_list (const char *confID) { - GError *error = NULL; - gchar **list = NULL; + GError *error = NULL; + gchar **list = NULL; + + DEBUG ("DBUS: Get conference %s participant list", confID); - DEBUG("DBUS: Get conference %s participant list", confID); + org_sflphone_SFLphone_CallManager_get_participant_list (callManagerProxy, + confID, &list, &error); - org_sflphone_SFLphone_CallManager_get_participant_list(callManagerProxy, - confID, &list, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_participant_list"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_participant_list"); + g_error_free (error); } - return list; + return list; } GHashTable* -dbus_get_conference_details(const gchar *confID) +dbus_get_conference_details (const gchar *confID) { - GError *error = NULL; - GHashTable *details = NULL; + GError *error = NULL; + GHashTable *details = NULL; + + org_sflphone_SFLphone_CallManager_get_conference_details (callManagerProxy, + confID, &details, &error); - org_sflphone_SFLphone_CallManager_get_conference_details(callManagerProxy, - confID, &details, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_conference_details"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_conference_details"); + g_error_free (error); } - return details; + return details; } void -dbus_set_accounts_order(const gchar* order) +dbus_set_accounts_order (const gchar* order) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_accounts_order( - configurationManagerProxy, order, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_accounts_order"); - g_error_free(error); + org_sflphone_SFLphone_ConfigurationManager_set_accounts_order ( + configurationManagerProxy, order, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_accounts_order"); + g_error_free (error); } } GHashTable* -dbus_get_history(void) +dbus_get_history (void) { - GError *error = NULL; - GHashTable *entries = NULL; + GError *error = NULL; + GHashTable *entries = NULL; + + org_sflphone_SFLphone_ConfigurationManager_get_history ( + configurationManagerProxy, &entries, &error); - org_sflphone_SFLphone_ConfigurationManager_get_history( - configurationManagerProxy, &entries, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_history"); - g_error_free(error); + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_history"); + g_error_free (error); } - return entries; + return entries; } void -dbus_set_history(GHashTable* entries) +dbus_set_history (GHashTable* entries) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_history( - configurationManagerProxy, entries, &error); - if (error) - { - ERROR ("Error calling org_sflphone_SFLphone_CallManager_set_history"); - g_error_free(error); + org_sflphone_SFLphone_ConfigurationManager_set_history ( + configurationManagerProxy, entries, &error); + + if (error) { + ERROR ("Error calling org_sflphone_SFLphone_CallManager_set_history"); + g_error_free (error); } } void -dbus_confirm_sas(const callable_obj_t * c) +dbus_confirm_sas (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_set_sa_sverified(callManagerProxy, - c->_callID, &error); - if (error) - { - ERROR ("Failed to call setSASVerified() on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_set_sa_sverified (callManagerProxy, + c->_callID, &error); + + if (error) { + ERROR ("Failed to call setSASVerified() on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_reset_sas(const callable_obj_t * c) +dbus_reset_sas (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_reset_sa_sverified(callManagerProxy, - c->_callID, &error); - if (error) - { - ERROR ("Failed to call resetSASVerified on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_reset_sa_sverified (callManagerProxy, + c->_callID, &error); + + if (error) { + ERROR ("Failed to call resetSASVerified on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_set_confirm_go_clear(const callable_obj_t * c) +dbus_set_confirm_go_clear (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_set_confirm_go_clear(callManagerProxy, - c->_callID, &error); - if (error) - { - ERROR ("Failed to call set_confirm_go_clear on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_set_confirm_go_clear (callManagerProxy, + c->_callID, &error); + + if (error) { + ERROR ("Failed to call set_confirm_go_clear on CallManager: %s", + error->message); + g_error_free (error); } } void -dbus_request_go_clear(const callable_obj_t * c) +dbus_request_go_clear (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_request_go_clear(callManagerProxy, - c->_callID, &error); - if (error) - { - ERROR ("Failed to call request_go_clear on CallManager: %s", - error->message); - g_error_free(error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_request_go_clear (callManagerProxy, + c->_callID, &error); + + if (error) { + ERROR ("Failed to call request_go_clear on CallManager: %s", + error->message); + g_error_free (error); } } gchar** dbus_get_supported_tls_method() { - GError *error = NULL; - gchar** array = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_supported_tls_method( - configurationManagerProxy, &array, &error); + GError *error = NULL; + gchar** array = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_supported_tls_method ( + configurationManagerProxy, &array, &error); - if (error != NULL) - { - ERROR ("Failed to call get_supported_tls_method() on ConfigurationManager: %s", - error->message); - g_error_free(error); + if (error != NULL) { + ERROR ("Failed to call get_supported_tls_method() on ConfigurationManager: %s", + error->message); + g_error_free (error); } - return array; + + return array; } GHashTable* -dbus_get_tls_settings_default(void) +dbus_get_tls_settings_default (void) { - GError *error = NULL; - GHashTable *results = NULL; + GError *error = NULL; + GHashTable *results = NULL; + + org_sflphone_SFLphone_ConfigurationManager_get_tls_settings_default ( + configurationManagerProxy, &results, &error); - org_sflphone_SFLphone_ConfigurationManager_get_tls_settings_default( - configurationManagerProxy, &results, &error); - if (error != NULL) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_tls_settings_default"); - g_error_free(error); + if (error != NULL) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_tls_settings_default"); + g_error_free (error); } - return results; + return results; } gchar * -dbus_get_address_from_interface_name(gchar* interface) +dbus_get_address_from_interface_name (gchar* interface) { - GError *error = NULL; - gchar * address; + GError *error = NULL; + gchar * address; + + org_sflphone_SFLphone_ConfigurationManager_get_addr_from_interface_name ( + configurationManagerProxy, interface, &address, &error); - org_sflphone_SFLphone_ConfigurationManager_get_addr_from_interface_name( - configurationManagerProxy, interface, &address, &error); - if (error != NULL) - { - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addr_from_interface_name\n"); - g_error_free(error); + if (error != NULL) { + ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_addr_from_interface_name\n"); + g_error_free (error); } - return address; + return address; } gchar ** -dbus_get_all_ip_interface(void) -{ - GError *error = NULL; - gchar ** array; - - if (!org_sflphone_SFLphone_ConfigurationManager_get_all_ip_interface( - configurationManagerProxy, &array, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_all_ip_interface) exception %s: %s", dbus_g_error_get_name(error), error->message); +dbus_get_all_ip_interface (void) +{ + GError *error = NULL; + gchar ** array; + + if (!org_sflphone_SFLphone_ConfigurationManager_get_all_ip_interface ( + configurationManagerProxy, &array, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_all_ip_interface) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_all_ip_interface: %s", error->message); } - else - { - ERROR("Error while calling get_all_ip_interface: %s", error->message); - } - g_error_free(error); - return NULL; - } - else - { - DEBUG ("DBus called get_all_ip_interface() on ConfigurationManager"); - return array; + + g_error_free (error); + return NULL; + } else { + DEBUG ("DBus called get_all_ip_interface() on ConfigurationManager"); + return array; } } gchar ** -dbus_get_all_ip_interface_by_name(void) -{ - GError *error = NULL; - gchar ** array; - - if (!org_sflphone_SFLphone_ConfigurationManager_get_all_ip_interface_by_name( - configurationManagerProxy, &array, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_all_ip_interface) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR("Error while calling get_all_ip_interface: %s", error->message); +dbus_get_all_ip_interface_by_name (void) +{ + GError *error = NULL; + gchar ** array; + + if (!org_sflphone_SFLphone_ConfigurationManager_get_all_ip_interface_by_name ( + configurationManagerProxy, &array, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_all_ip_interface) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_all_ip_interface: %s", error->message); } - g_error_free(error); - return NULL; - } - else - { - DEBUG ("DBus called get_all_ip_interface() on ConfigurationManager"); - return array; + + g_error_free (error); + return NULL; + } else { + DEBUG ("DBus called get_all_ip_interface() on ConfigurationManager"); + return array; } } GHashTable* -dbus_get_shortcuts(void) -{ - GError *error = NULL; - GHashTable * shortcuts; - - if (!org_sflphone_SFLphone_ConfigurationManager_get_shortcuts( - configurationManagerProxy, &shortcuts, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_shortcuts) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR("Error while calling get_shortcuts: %s", error->message); +dbus_get_shortcuts (void) +{ + GError *error = NULL; + GHashTable * shortcuts; + + if (!org_sflphone_SFLphone_ConfigurationManager_get_shortcuts ( + configurationManagerProxy, &shortcuts, &error)) { + if (error->domain == DBUS_GERROR && error->code + == DBUS_GERROR_REMOTE_EXCEPTION) { + ERROR ("Caught remote method (get_shortcuts) exception %s: %s", dbus_g_error_get_name (error), error->message); + } else { + ERROR ("Error while calling get_shortcuts: %s", error->message); } - g_error_free(error); - return NULL; - } - else - { - return shortcuts; + + g_error_free (error); + return NULL; + } else { + return shortcuts; } } void -dbus_set_shortcuts(GHashTable * shortcuts) -{ - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_shortcuts( - configurationManagerProxy, shortcuts, &error); - if (error) - { - ERROR ("Failed to call set_shortcuts() on ConfigurationManager: %s", - error->message); - g_error_free(error); +dbus_set_shortcuts (GHashTable * shortcuts) +{ + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_shortcuts ( + configurationManagerProxy, shortcuts, &error); + + if (error) { + ERROR ("Failed to call set_shortcuts() on ConfigurationManager: %s", + error->message); + g_error_free (error); } } diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 9abaa0cc96f2bb3b37ddd3e5f7f381f4cb043783..62906fc5be1cb79bb81cf68b600697ddd3cf2d14 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -26,7 +26,7 @@ * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. * grants you additional permission to convey the resulting work. * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well +* shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ @@ -60,19 +60,19 @@ void dbus_clean (); * CallManager - Hold a call * @param c The call to hold */ -void dbus_hold (const callable_obj_t * c ); +void dbus_hold (const callable_obj_t * c); /** * CallManager - Unhold a call * @param c The call to unhold */ -void dbus_unhold (const callable_obj_t * c ); +void dbus_unhold (const callable_obj_t * c); /** * CallManager - Hang up a call * @param c The call to hang up */ -void dbus_hang_up (const callable_obj_t * c ); +void dbus_hang_up (const callable_obj_t * c); /** * CallManager - Transfer a call @@ -110,50 +110,43 @@ gchar ** dbus_account_list(); * @param accountID The unique of the account * @return GHashTable* The details of the account */ -GHashTable * dbus_account_details(gchar * accountID); +GHashTable * dbus_account_details (gchar * accountID); /** * ConfigurationManager - Set the details of a specific account * @param a The account to update */ -void dbus_set_account_details(account_t *a); +void dbus_set_account_details (account_t *a); /** - * ConfigurationManager - Set the additional credential information + * ConfigurationManager - Set the additional credential information * of a specific account, for a specific credential index. * This function will add the new section on the server side * if it cannot be found. * @param a The account to update * @param index The index for the credential to update */ -void dbus_set_credential(account_t *a, int index); +void dbus_set_credential (account_t *a, int index); /** - * ConfigurationManager - Set the additional credential information + * ConfigurationManager - Set the additional credential information * of a specific account, for a specific credential index. * This function will add the new section on the server side * if it cannot be found. * @param a The account to update * @return int The number of credentials specified */ -int dbus_get_number_of_credential(gchar * accountID); +int dbus_get_number_of_credential (gchar * accountID); /** * ConfigurationManager - Delete all credentials defined for * a given account. * @param a The account id */ -void dbus_delete_all_credential(account_t *a); +void dbus_delete_all_credential (account_t *a); /** - * ConfigurationManager - Set the number of credential that - * is being used. - * @param a The account id - */ -void dbus_set_number_of_credential(account_t *a, int number); - -/** - * ConfigurationManager - Set the additional credential information + * ConfigurationManager - Set the additional credential information * of a specific account, for a specific credential index. * This function will add the new section on the server side * if it cannot be found. @@ -161,17 +154,17 @@ void dbus_set_number_of_credential(account_t *a, int number); * @param index The credential index * @return GHashTable* The credential at index "index" for the given account */ -GHashTable* dbus_get_credential(gchar * accountID, int index); +GHashTable* dbus_get_credential (gchar * accountID, int index); /** - * ConfigurationManager - Get the details for the ip2ip profile + * ConfigurationManager - Get the details for the ip2ip profile */ -GHashTable * dbus_get_ip2_ip_details(void); +GHashTable * dbus_get_ip2_ip_details (void); /** - * ConfigurationManager - Set the details for the ip2ip profile + * ConfigurationManager - Set the details for the ip2ip profile */ -void dbus_set_ip2ip_details(GHashTable * properties); +void dbus_set_ip2ip_details (GHashTable * properties); /** * ConfigurationManager - Send registration request @@ -180,38 +173,38 @@ void dbus_set_ip2ip_details(GHashTable * properties); * 0 for unregistration request * 1 for registration request */ -void dbus_send_register( gchar* accountID , const guint enable ); +void dbus_send_register (gchar* accountID , const guint enable); /** * ConfigurationManager - Add an account to the list * @param a The account to add */ -gchar* dbus_add_account(account_t *a); +gchar* dbus_add_account (account_t *a); /** * ConfigurationManager - Remove an account from the list * @param accountID The account to remove */ -void dbus_remove_account(gchar * accountID); +void dbus_remove_account (gchar * accountID); /** * ConfigurationManager - Set volume for speaker/mic * @param device The speaker or the mic * @param value The new value */ -void dbus_set_volume(const gchar * device, gdouble value); +void dbus_set_volume (const gchar * device, gdouble value); /** * ConfigurationManager - Get the volume of a device * @param device The speaker or the mic */ -gdouble dbus_get_volume(const gchar * device); +gdouble dbus_get_volume (const gchar * device); /** * ConfigurationManager - Play DTMF * @param key The DTMF to send */ -void dbus_play_dtmf(const gchar * key); +void dbus_play_dtmf (const gchar * key); /** * ConfigurationManager - Get the codecs list @@ -224,7 +217,7 @@ gchar** dbus_codec_list(); * @param payload The payload of the codec * @return gchar** The codec details */ -gchar** dbus_codec_details(int payload); +gchar** dbus_codec_details (int payload); /** * ConfigurationManager - Get the default codec list @@ -249,7 +242,7 @@ void dbus_set_active_codec_list (const gchar** list, const gchar*); * CallManager - return the codec name * @param callable_obj_t* current call */ -gchar* dbus_get_current_codec_name(const callable_obj_t * c); +gchar* dbus_get_current_codec_name (const callable_obj_t * c); /** * ConfigurationManager - Get the list of available output audio plugins @@ -261,13 +254,13 @@ gchar** dbus_get_audio_plugin_list(); * ConfigurationManager - Select an input audio plugin * @param audioPlugin The string description of the plugin */ -void dbus_set_input_audio_plugin(gchar* audioPlugin); +void dbus_set_input_audio_plugin (gchar* audioPlugin); /** * ConfigurationManager - Select an output audio plugin * @param audioPlugin The string description of the plugin */ -void dbus_set_output_audio_plugin(gchar* audioPlugin); +void dbus_set_output_audio_plugin (gchar* audioPlugin); /** * ConfigurationManager - Get the list of available output audio devices @@ -279,7 +272,7 @@ gchar** dbus_get_audio_output_device_list(); * ConfigurationManager - Select an output audio device * @param index The index of the soundcard */ -void dbus_set_audio_output_device(const int index); +void dbus_set_audio_output_device (const int index); /** * ConfigurationManager - Get the list of available input audio devices @@ -291,7 +284,7 @@ gchar** dbus_get_audio_input_device_list(); * ConfigurationManager - Select an input audio device * @param index The index of the soundcard */ -void dbus_set_audio_input_device(const int index); +void dbus_set_audio_input_device (const int index); /** * ConfigurationManager - Get the current audio devices @@ -304,7 +297,7 @@ gchar** dbus_get_current_audio_devices_index(); * @param name The string description of the audio device * @return int The index of the device */ -int dbus_get_audio_device_index(const gchar* name); +int dbus_get_audio_device_index (const gchar* name); /** * ConfigurationManager - Get the current output audio plugin @@ -320,29 +313,29 @@ gchar* dbus_get_current_audio_output_plugin(); * ConfigurationManager - Get the current state of echo canceller * @return gchar* The state (enabled/disabled) */ -gchar *dbus_get_echo_cancel_state(void); +gchar *dbus_get_echo_cancel_state (void); /** * ConfigurationManager - Set the crrent state of echo canceller * @param gchar* The state (enabled/disabled) */ -void dbus_set_echo_cancel_state(gchar *state); +void dbus_set_echo_cancel_state (gchar *state); /** * ConfigurationManager - Get the current noise suppressor state * @return gchar* The state (enabled/disabled) */ -gchar *dbus_get_noise_suppress_state(void); +gchar *dbus_get_noise_suppress_state (void); /** * ConfigurationManager - Set the current noise suppressor state * @param gchar* The state (enabled/disabled) */ -void dbus_set_noise_suppress_state(gchar *state); +void dbus_set_noise_suppress_state (gchar *state); /** - * ConfigurationManager - Query to server to + * ConfigurationManager - Query to server to * know if MD5 credential hashing is enabled. * @return True if enabled, false otherwise * @@ -353,16 +346,16 @@ gboolean dbus_is_md5_credential_hashing(); * ConfigurationManager - Set whether or not * the server should store credential as * a md5 hash. - * @param enabled + * @param enabled */ -void dbus_set_md5_credential_hashing(gboolean enabled); +void dbus_set_md5_credential_hashing (gboolean enabled); /** * ConfigurationManager - Tells the GUI if IAX2 support is enabled * @return int 1 if IAX2 is enabled * 0 otherwise */ -int dbus_is_iax2_enabled( void ); +int dbus_is_iax2_enabled (void); /** * ConfigurationManager - Query the server about the ringtone option. @@ -370,31 +363,31 @@ int dbus_is_iax2_enabled( void ); * @return int 1 if enabled * 0 otherwise */ -int dbus_is_ringtone_enabled( const gchar *accountID ); +int dbus_is_ringtone_enabled (const gchar *accountID); /** * ConfigurationManager - Set the ringtone option * Inverse current value */ -void dbus_ringtone_enabled( const gchar *accountID ); +void dbus_ringtone_enabled (const gchar *accountID); /** * ConfigurationManager - Get the ringtone * @return gchar* The file name selected as a ringtone */ -gchar* dbus_get_ringtone_choice( const gchar *accountID ); +gchar* dbus_get_ringtone_choice (const gchar *accountID); /** * ConfigurationManager - Set a ringtone * @param tone The file name of the ringtone */ -void dbus_set_ringtone_choice( const gchar *accountID, const gchar* tone ); +void dbus_set_ringtone_choice (const gchar *accountID, const gchar* tone); /** * ConfigurationManager - Gives the maximum number of days the user wants to have in the history * @return double The maximum number of days */ -guint dbus_get_history_limit( void ); +guint dbus_get_history_limit (void); /** * ConfigurationManager - Gives the maximum number of days the user wants to have in the history @@ -406,14 +399,14 @@ void dbus_set_history_limit (const guint days); * @return int 0 ALSA * 1 PULSEAUDIO */ -int dbus_get_audio_manager( void ); +int dbus_get_audio_manager (void); /** * ConfigurationManager - Set the audio manager * @param api 0 ALSA * 1 PULSEAUDIO */ -void dbus_set_audio_manager( int api ); +void dbus_set_audio_manager (int api); /** * ConfigurationManager - Start a tone when a new call is open and no numbers have been dialed @@ -422,7 +415,7 @@ void dbus_set_audio_manager( int api ); * @param type TONE_WITH_MESSAGE * TONE_WITHOUT_MESSAGE */ -void dbus_start_tone(const int start , const guint type); +void dbus_start_tone (const int start , const guint type); /** * Instance - Send registration request to dbus service. @@ -430,19 +423,19 @@ void dbus_start_tone(const int start , const guint type); * @param pid The pid of the processus client * @param name The string description of the client. Here : GTK+ Client */ -void dbus_register( int pid, gchar * name); +void dbus_register (int pid, gchar * name); /** * Instance - Send unregistration request to dbus services * @param pid The pid of the processus */ -void dbus_unregister(int pid); +void dbus_unregister (int pid); -void dbus_set_sip_address(const gchar* address); +void dbus_set_sip_address (const gchar* address); -gint dbus_get_sip_address(void); +gint dbus_get_sip_address (void); -void dbus_add_participant(const gchar* callID, const gchar* confID); +void dbus_add_participant (const gchar* callID, const gchar* confID); void dbus_set_record (const gchar * id); @@ -468,17 +461,17 @@ void dbus_set_addressbook_list (const gchar** list); /** * Resolve the local address given an interface name */ -gchar * dbus_get_address_from_interface_name(gchar* interface); +gchar * dbus_get_address_from_interface_name (gchar* interface); /** * Query the daemon to return a list of network interface (described as there IP address) */ -gchar** dbus_get_all_ip_interface(void); +gchar** dbus_get_all_ip_interface (void); /** * Query the daemon to return a list of network interface (described as there name) */ -gchar** dbus_get_all_ip_interface_by_name(void); +gchar** dbus_get_all_ip_interface_by_name (void); /** * Encapsulate all the url hook-related configuration @@ -493,7 +486,7 @@ GHashTable* dbus_get_hook_settings (void); void dbus_set_hook_settings (GHashTable *); -gboolean dbus_get_is_recording(const callable_obj_t *); +gboolean dbus_get_is_recording (const callable_obj_t *); GHashTable* dbus_get_call_details (const gchar* callID); @@ -512,21 +505,21 @@ void dbus_set_history (GHashTable* entries); void sflphone_display_transfer_status (const gchar* message); /** - * CallManager - Confirm Short Authentication String + * CallManager - Confirm Short Authentication String * for a given callId * @param c The call to confirm SAS */ void dbus_confirm_sas (const callable_obj_t * c); /** - * CallManager - Reset Short Authentication String + * CallManager - Reset Short Authentication String * for a given callId * @param c The call to reset SAS */ void dbus_reset_sas (const callable_obj_t * c); /** - * CallManager - Request Go Clear in the ZRTP Protocol + * CallManager - Request Go Clear in the ZRTP Protocol * for a given callId * @param c The call that we want to go clear */ @@ -541,14 +534,37 @@ void dbus_set_confirm_go_clear (const callable_obj_t * c); /** * CallManager - Get the list of supported TLS methods from - * the server in textual form. + * the server in textual form. * @return an array of string representing supported methods */ gchar** dbus_get_supported_tls_method(); gchar** dbus_get_participant_list (const char * confID); -GHashTable* dbus_get_shortcuts(void); -void dbus_set_shortcuts(GHashTable * shortcuts); +GHashTable* dbus_get_shortcuts (void); +void dbus_set_shortcuts (GHashTable * shortcuts); + +void dbus_set_audio_ringtone_device (const int index); + +void +dbus_hang_up_conference (const conference_obj_t * c); + +void +dbus_hold_conference (const conference_obj_t * c); + +void +dbus_unhold_conference (const conference_obj_t * c); + +void +dbus_detach_participant (const gchar* callID); + +void +dbus_join_participant (const gchar* sel_callID, const gchar* drag_callID); + +void +dbus_join_conference (const gchar* sel_confID, const gchar* drag_confID); + +void +dbus_add_main_participant (const gchar* confID); #endif diff --git a/sflphone-client-gnome/src/dialpad.c b/sflphone-client-gnome/src/dialpad.c index 31ed1374132a772d02195a4d732c7f30ca195f8b..04009dc0450c9fb1e57f407f528965269251b900 100644 --- a/sflphone-client-gnome/src/dialpad.c +++ b/sflphone-client-gnome/src/dialpad.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #include <dialpad.h> #include <actions.h> @@ -37,80 +37,80 @@ static void dialpad_pressed (GtkWidget * widget UNUSED, gpointer data) { - gtk_widget_grab_focus(GTK_WIDGET(current_calls->view)); - sflphone_keypad(0, (gchar*) data); + gtk_widget_grab_focus (GTK_WIDGET (current_calls->view)); + sflphone_keypad (0, (gchar*) data); } -GtkWidget * +GtkWidget * get_numpad_button (const gchar* number, gboolean twolines, const gchar * letters) { - GtkWidget * button; - GtkWidget * label; - gchar * markup; - - button = gtk_button_new (); - label = gtk_label_new ( "1" ); - gtk_label_set_single_line_mode ( GTK_LABEL(label), FALSE ); - gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_CENTER ); - markup = g_markup_printf_escaped("<big><b>%s</b></big>%s%s", number, (twolines == TRUE ? "\n": ""), letters); - gtk_label_set_markup ( GTK_LABEL(label), markup); - gtk_container_add (GTK_CONTAINER (button), label); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (dialpad_pressed), (gchar*)number); - - return button; + GtkWidget * button; + GtkWidget * label; + gchar * markup; + + button = gtk_button_new (); + label = gtk_label_new ("1"); + gtk_label_set_single_line_mode (GTK_LABEL (label), FALSE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); + markup = g_markup_printf_escaped ("<big><b>%s</b></big>%s%s", number, (twolines == TRUE ? "\n": ""), letters); + gtk_label_set_markup (GTK_LABEL (label), markup); + gtk_container_add (GTK_CONTAINER (button), label); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (dialpad_pressed), (gchar*) number); + + return button; } -GtkWidget * +GtkWidget * create_dialpad() { - GtkWidget * button; - GtkWidget * table; - - table = gtk_table_new ( 4, 3, TRUE /* homogeneous */); - gtk_table_set_row_spacings( GTK_TABLE(table), 5); - gtk_table_set_col_spacings( GTK_TABLE(table), 5); - gtk_container_set_border_width (GTK_CONTAINER(table), 5); - - button = get_numpad_button("1", TRUE, ""); - gtk_table_attach ( GTK_TABLE( table ), button, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("2", TRUE, "a b c"); - gtk_table_attach ( GTK_TABLE( table ), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("3", TRUE, "d e f"); - gtk_table_attach ( GTK_TABLE( table ), button, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - - button = get_numpad_button("4", TRUE, "g h i"); - gtk_table_attach ( GTK_TABLE( table ), button, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("5", TRUE, "j k l"); - gtk_table_attach ( GTK_TABLE( table ), button, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("6", TRUE, "m n o"); - gtk_table_attach ( GTK_TABLE( table ), button, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - - button = get_numpad_button("7", TRUE, "p q r s"); - gtk_table_attach ( GTK_TABLE( table ), button, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("8", TRUE, "t u v"); - gtk_table_attach ( GTK_TABLE( table ), button, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("9", TRUE, "w x y z"); - gtk_table_attach ( GTK_TABLE( table ), button, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - - button = get_numpad_button("*", FALSE, ""); - gtk_table_attach ( GTK_TABLE( table ), button, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("0", FALSE, ""); - gtk_table_attach ( GTK_TABLE( table ), button, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - button = get_numpad_button("#", FALSE, ""); - gtk_table_attach ( GTK_TABLE( table ), button, 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - return table; - + GtkWidget * button; + GtkWidget * table; + + table = gtk_table_new (4, 3, TRUE /* homogeneous */); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); + gtk_table_set_col_spacings (GTK_TABLE (table), 5); + gtk_container_set_border_width (GTK_CONTAINER (table), 5); + + button = get_numpad_button ("1", TRUE, ""); + gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("2", TRUE, "a b c"); + gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("3", TRUE, "d e f"); + gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + + button = get_numpad_button ("4", TRUE, "g h i"); + gtk_table_attach (GTK_TABLE (table), button, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("5", TRUE, "j k l"); + gtk_table_attach (GTK_TABLE (table), button, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("6", TRUE, "m n o"); + gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + + button = get_numpad_button ("7", TRUE, "p q r s"); + gtk_table_attach (GTK_TABLE (table), button, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("8", TRUE, "t u v"); + gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("9", TRUE, "w x y z"); + gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + + button = get_numpad_button ("*", FALSE, ""); + gtk_table_attach (GTK_TABLE (table), button, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("0", FALSE, ""); + gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + button = get_numpad_button ("#", FALSE, ""); + gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + return table; + } diff --git a/sflphone-client-gnome/src/dialpad.h b/sflphone-client-gnome/src/dialpad.h index c95f5caf55541fd8db6fe6e4152c35db652fc945..c25f2ebff216bdfa52b1a98fc3313c84ec6676d1 100644 --- a/sflphone-client-gnome/src/dialpad.h +++ b/sflphone-client-gnome/src/dialpad.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __DIALPAD_H__ #define __DIALPAD_H__ @@ -42,4 +42,4 @@ */ GtkWidget * create_dialpad(); -#endif +#endif diff --git a/sflphone-client-gnome/src/eel-gconf-extensions.c b/sflphone-client-gnome/src/eel-gconf-extensions.c index 2bc4ab804f5d6d16e3bf586a9de8b189cba02fb0..1835935eeddfa86c22201518232f8a3a021dbcdd 100644 --- a/sflphone-client-gnome/src/eel-gconf-extensions.c +++ b/sflphone-client-gnome/src/eel-gconf-extensions.c @@ -37,280 +37,279 @@ static GConfClient *global_gconf_client = NULL; static void global_client_free (void) { - if (global_gconf_client == NULL) { - return; - } + if (global_gconf_client == NULL) { + return; + } - g_object_unref (G_OBJECT (global_gconf_client)); - global_gconf_client = NULL; + g_object_unref (G_OBJECT (global_gconf_client)); + global_gconf_client = NULL; } /* Public */ GConfClient * eel_gconf_client_get_global (void) { - /* Initialize gconf if needed */ - if (!gconf_is_initialized ()) { - char *argv[] = { "eel-preferences", NULL }; - GError *error = NULL; - char *teststr; - - if (!gconf_init (1, argv, &error)) { - if (eel_gconf_handle_error (&error)) { - return NULL; - } - } - - /* check if gconf schemas are working */ - teststr = gconf_client_get_string (eel_gconf_client_get_global(), - "/apps/gpdf/gconf_test", NULL); - if (!teststr) - { - GtkWidget *dialog; - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Cannot find a schema for gpdf preferences. \n" - "Check your gconf setup, look at gpdf FAQ for \n" - "more info")); - gtk_dialog_run (GTK_DIALOG (dialog)); - exit (0); - } - else - { - g_free (teststr); - } + /* Initialize gconf if needed */ + if (!gconf_is_initialized ()) { + char *argv[] = { "eel-preferences", NULL }; + GError *error = NULL; + char *teststr; + if (!gconf_init (1, argv, &error)) { + if (eel_gconf_handle_error (&error)) { + return NULL; + } } - if (global_gconf_client == NULL) { - global_gconf_client = gconf_client_get_default (); - g_atexit (global_client_free); + /* check if gconf schemas are working */ + teststr = gconf_client_get_string (eel_gconf_client_get_global(), + "/apps/gpdf/gconf_test", NULL); + + if (!teststr) { + GtkWidget *dialog; + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _ ("Cannot find a schema for gpdf preferences. \n" + "Check your gconf setup, look at gpdf FAQ for \n" + "more info")); + gtk_dialog_run (GTK_DIALOG (dialog)); + exit (0); + } else { + g_free (teststr); } - return global_gconf_client; + } + + if (global_gconf_client == NULL) { + global_gconf_client = gconf_client_get_default (); + g_atexit (global_client_free); + } + + return global_gconf_client; } gboolean eel_gconf_handle_error (GError **error) { - g_return_val_if_fail (error != NULL, FALSE); + g_return_val_if_fail (error != NULL, FALSE); - if (*error != NULL) { - g_warning (_("GConf error:\n %s"), (*error)->message); - g_error_free (*error); - *error = NULL; + if (*error != NULL) { + g_warning (_ ("GConf error:\n %s"), (*error)->message); + g_error_free (*error); + *error = NULL; - return TRUE; - } + return TRUE; + } - return FALSE; + return FALSE; } void eel_gconf_set_boolean (const char *key, - gboolean boolean_value) + gboolean boolean_value) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_set_bool (client, key, boolean_value, &error); - eel_gconf_handle_error (&error); + gconf_client_set_bool (client, key, boolean_value, &error); + eel_gconf_handle_error (&error); } gboolean eel_gconf_get_boolean (const char *key) { - gboolean result; - GConfClient *client; - GError *error = NULL; + gboolean result; + GConfClient *client; + GError *error = NULL; - g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, FALSE); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); - result = gconf_client_get_bool (client, key, &error); + result = gconf_client_get_bool (client, key, &error); - if (eel_gconf_handle_error (&error)) { - result = FALSE; - } + if (eel_gconf_handle_error (&error)) { + result = FALSE; + } - return result; + return result; } void eel_gconf_set_integer (const char *key, - int int_value) + int int_value) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_set_int (client, key, int_value, &error); - eel_gconf_handle_error (&error); + gconf_client_set_int (client, key, int_value, &error); + eel_gconf_handle_error (&error); } int eel_gconf_get_integer (const char *key) { - int result; - GConfClient *client; - GError *error = NULL; + int result; + GConfClient *client; + GError *error = NULL; - g_return_val_if_fail (key != NULL, 0); + g_return_val_if_fail (key != NULL, 0); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, 0); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, 0); - result = gconf_client_get_int (client, key, &error); + result = gconf_client_get_int (client, key, &error); - if (eel_gconf_handle_error (&error)) { - result = 0; - } + if (eel_gconf_handle_error (&error)) { + result = 0; + } - return result; + return result; } void eel_gconf_set_float (const char *key, - gfloat float_value) + gfloat float_value) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_set_float (client, key, float_value, &error); - eel_gconf_handle_error (&error); + gconf_client_set_float (client, key, float_value, &error); + eel_gconf_handle_error (&error); } gfloat eel_gconf_get_float (const char *key) { - gfloat result; - GConfClient *client; - GError *error = NULL; + gfloat result; + GConfClient *client; + GError *error = NULL; - g_return_val_if_fail (key != NULL, 0); + g_return_val_if_fail (key != NULL, 0); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, 0); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, 0); - result = gconf_client_get_float (client, key, &error); + result = gconf_client_get_float (client, key, &error); - if (eel_gconf_handle_error (&error)) { - result = 0; - } + if (eel_gconf_handle_error (&error)) { + result = 0; + } - return result; + return result; } void eel_gconf_set_string (const char *key, const char *string_value) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); - g_return_if_fail (string_value != NULL); + g_return_if_fail (key != NULL); + g_return_if_fail (string_value != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_set_string (client, key, string_value, &error); - eel_gconf_handle_error (&error); + gconf_client_set_string (client, key, string_value, &error); + eel_gconf_handle_error (&error); } void eel_gconf_unset (const char *key) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_unset (client, key, &error); - eel_gconf_handle_error (&error); + gconf_client_unset (client, key, &error); + eel_gconf_handle_error (&error); } char * eel_gconf_get_string (const char *key) { - char *result; - GConfClient *client; - GError *error = NULL; + char *result; + GConfClient *client; + GError *error = NULL; - g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, NULL); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); - result = gconf_client_get_string (client, key, &error); + result = gconf_client_get_string (client, key, &error); - if (eel_gconf_handle_error (&error)) { - result = g_strdup (""); - } + if (eel_gconf_handle_error (&error)) { + result = g_strdup (""); + } - return result; + return result; } void eel_gconf_set_string_list (const char *key, - const GSList *slist) + const GSList *slist) { - GConfClient *client; - GError *error; + GConfClient *client; + GError *error; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - error = NULL; - gconf_client_set_list (client, key, GCONF_VALUE_STRING, - /* Need cast cause of GConf api bug */ - (GSList *) slist, - &error); - eel_gconf_handle_error (&error); + error = NULL; + gconf_client_set_list (client, key, GCONF_VALUE_STRING, + /* Need cast cause of GConf api bug */ + (GSList *) slist, + &error); + eel_gconf_handle_error (&error); } GSList * eel_gconf_get_string_list (const char *key) { - GSList *slist; - GConfClient *client; - GError *error; + GSList *slist; + GConfClient *client; + GError *error; - g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, NULL); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); - error = NULL; - slist = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error); - if (eel_gconf_handle_error (&error)) { - slist = NULL; - } + error = NULL; + slist = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error); - return slist; + if (eel_gconf_handle_error (&error)) { + slist = NULL; + } + + return slist; } /* This code wasn't part of the original eel-gconf-extensions.c */ @@ -318,209 +317,212 @@ void eel_gconf_set_integer_list (const char *key, const GSList *slist) { - GConfClient *client; - GError *error; + GConfClient *client; + GError *error; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - error = NULL; - gconf_client_set_list (client, key, GCONF_VALUE_INT, - /* Need cast cause of GConf api bug */ - (GSList *) slist, - &error); - eel_gconf_handle_error (&error); + error = NULL; + gconf_client_set_list (client, key, GCONF_VALUE_INT, + /* Need cast cause of GConf api bug */ + (GSList *) slist, + &error); + eel_gconf_handle_error (&error); } GSList * eel_gconf_get_integer_list (const char *key) { - GSList *slist; - GConfClient *client; - GError *error; + GSList *slist; + GConfClient *client; + GError *error; - g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, NULL); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); - error = NULL; - slist = gconf_client_get_list (client, key, GCONF_VALUE_INT, &error); - if (eel_gconf_handle_error (&error)) { - slist = NULL; - } + error = NULL; + slist = gconf_client_get_list (client, key, GCONF_VALUE_INT, &error); - return slist; + if (eel_gconf_handle_error (&error)) { + slist = NULL; + } + + return slist; } /* End of added code */ gboolean eel_gconf_is_default (const char *key) { - gboolean result; - GConfValue *value; - GError *error = NULL; + gboolean result; + GConfValue *value; + GError *error = NULL; - g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); - value = gconf_client_get_without_default (eel_gconf_client_get_global (), key, &error); + value = gconf_client_get_without_default (eel_gconf_client_get_global (), key, &error); - if (eel_gconf_handle_error (&error)) { - if (value != NULL) { - gconf_value_free (value); - } - return FALSE; + if (eel_gconf_handle_error (&error)) { + if (value != NULL) { + gconf_value_free (value); } - result = (value == NULL); + return FALSE; + } - if (value != NULL) { - gconf_value_free (value); - } + result = (value == NULL); + + if (value != NULL) { + gconf_value_free (value); + } - return result; + return result; } gboolean eel_gconf_monitor_add (const char *directory) { - GError *error = NULL; - GConfClient *client; + GError *error = NULL; + GConfClient *client; - g_return_val_if_fail (directory != NULL, FALSE); + g_return_val_if_fail (directory != NULL, FALSE); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, FALSE); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); - gconf_client_add_dir (client, - directory, - GCONF_CLIENT_PRELOAD_NONE, - &error); + gconf_client_add_dir (client, + directory, + GCONF_CLIENT_PRELOAD_NONE, + &error); - if (eel_gconf_handle_error (&error)) { - return FALSE; - } + if (eel_gconf_handle_error (&error)) { + return FALSE; + } - return TRUE; + return TRUE; } gboolean eel_gconf_monitor_remove (const char *directory) { - GError *error = NULL; - GConfClient *client; + GError *error = NULL; + GConfClient *client; - if (directory == NULL) { - return FALSE; - } + if (directory == NULL) { + return FALSE; + } - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, FALSE); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); - gconf_client_remove_dir (client, - directory, - &error); + gconf_client_remove_dir (client, + directory, + &error); - if (eel_gconf_handle_error (&error)) { - return FALSE; - } + if (eel_gconf_handle_error (&error)) { + return FALSE; + } - return TRUE; + return TRUE; } void eel_gconf_suggest_sync (void) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_suggest_sync (client, &error); - eel_gconf_handle_error (&error); + gconf_client_suggest_sync (client, &error); + eel_gconf_handle_error (&error); } GConfValue* eel_gconf_get_value (const char *key) { - GConfValue *value = NULL; - GConfClient *client; - GError *error = NULL; + GConfValue *value = NULL; + GConfClient *client; + GError *error = NULL; - g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, NULL); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); - value = gconf_client_get (client, key, &error); + value = gconf_client_get (client, key, &error); - if (eel_gconf_handle_error (&error)) { - if (value != NULL) { - gconf_value_free (value); - value = NULL; - } + if (eel_gconf_handle_error (&error)) { + if (value != NULL) { + gconf_value_free (value); + value = NULL; } + } - return value; + return value; } void eel_gconf_set_value (const char *key, const GConfValue *value) { - GConfClient *client; - GError *error = NULL; + GConfClient *client; + GError *error = NULL; - g_return_if_fail (key != NULL); + g_return_if_fail (key != NULL); - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_set (client, key, value, &error); + gconf_client_set (client, key, value, &error); - if (eel_gconf_handle_error (&error)) { - return; - } + if (eel_gconf_handle_error (&error)) { + return; + } } gboolean eel_gconf_key_exists (const char *key) { - GConfValue *value = NULL; - GConfClient *client; - GError *error = NULL; - gboolean error_occurred; - gboolean value_found; + GConfValue *value = NULL; + GConfClient *client; + GError *error = NULL; + gboolean error_occurred; + gboolean value_found; - g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, FALSE); + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); - value = gconf_client_get (client, key, &error); + value = gconf_client_get (client, key, &error); - value_found = (value != NULL); - error_occurred = (error != NULL); + value_found = (value != NULL); + error_occurred = (error != NULL); - eel_gconf_value_free (value); - if (error != NULL) { - g_error_free (error); - } + eel_gconf_value_free (value); + + if (error != NULL) { + g_error_free (error); + } - return (!error_occurred && value_found); + return (!error_occurred && value_found); } void eel_gconf_value_free (GConfValue *value) { - if (value == NULL) { - return; - } + if (value == NULL) { + return; + } - gconf_value_free (value); + gconf_value_free (value); } guint @@ -528,46 +530,46 @@ eel_gconf_notification_add (const char *key, GConfClientNotifyFunc notification_callback, gpointer callback_data) { - guint notification_id; - GConfClient *client; - GError *error = NULL; - - g_return_val_if_fail (key != NULL, EEL_GCONF_UNDEFINED_CONNECTION); - g_return_val_if_fail (notification_callback != NULL, EEL_GCONF_UNDEFINED_CONNECTION); - - client = eel_gconf_client_get_global (); - g_return_val_if_fail (client != NULL, EEL_GCONF_UNDEFINED_CONNECTION); - - notification_id = gconf_client_notify_add (client, - key, - notification_callback, - callback_data, - NULL, - &error); - - if (eel_gconf_handle_error (&error)) { - if (notification_id != EEL_GCONF_UNDEFINED_CONNECTION) { - gconf_client_notify_remove (client, notification_id); - notification_id = EEL_GCONF_UNDEFINED_CONNECTION; - } + guint notification_id; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + g_return_val_if_fail (notification_callback != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + + notification_id = gconf_client_notify_add (client, + key, + notification_callback, + callback_data, + NULL, + &error); + + if (eel_gconf_handle_error (&error)) { + if (notification_id != EEL_GCONF_UNDEFINED_CONNECTION) { + gconf_client_notify_remove (client, notification_id); + notification_id = EEL_GCONF_UNDEFINED_CONNECTION; } + } - return notification_id; + return notification_id; } void eel_gconf_notification_remove (guint notification_id) { - GConfClient *client; + GConfClient *client; - if (notification_id == EEL_GCONF_UNDEFINED_CONNECTION) { - return; - } + if (notification_id == EEL_GCONF_UNDEFINED_CONNECTION) { + return; + } - client = eel_gconf_client_get_global (); - g_return_if_fail (client != NULL); + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); - gconf_client_notify_remove (client, notification_id); + gconf_client_notify_remove (client, notification_id); } /* Simple wrapper for eel_gconf_notifier_add which @@ -580,15 +582,16 @@ gpdf_notification_add (const char *key, gpointer callback_data, GList **notifiers) { - guint id = 0; - - id = eel_gconf_notification_add(key, - notification_callback, - callback_data); - if (notifiers != NULL) { - *notifiers = g_list_append(*notifiers, - (gpointer)id); - } + guint id = 0; + + id = eel_gconf_notification_add (key, + notification_callback, + callback_data); + + if (notifiers != NULL) { + *notifiers = g_list_append (*notifiers, + GINT_TO_POINTER (id)); + } } /* Removes all the notifiers listed in notifiers */ @@ -596,11 +599,11 @@ gpdf_notification_add (const char *key, void gpdf_notification_remove (GList **notifiers) { - g_list_foreach(*notifiers, - (GFunc)eel_gconf_notification_remove, - NULL); - g_list_free(*notifiers); - *notifiers = NULL; + g_list_foreach (*notifiers, + (GFunc) eel_gconf_notification_remove, + NULL); + g_list_free (*notifiers); + *notifiers = NULL; } diff --git a/sflphone-client-gnome/src/eel-gconf-extensions.h b/sflphone-client-gnome/src/eel-gconf-extensions.h index f4afab26067c4f0c2116dc2964f0cf6d3844ea19..f9e4f5c381159e79d732e5c55a687a009d7814c4 100644 --- a/sflphone-client-gnome/src/eel-gconf-extensions.h +++ b/sflphone-client-gnome/src/eel-gconf-extensions.h @@ -35,50 +35,50 @@ BEGIN_EXTERN_C #define EEL_GCONF_UNDEFINED_CONNECTION 0 -GConfClient *eel_gconf_client_get_global (void); -gboolean eel_gconf_handle_error (GError **error); -void eel_gconf_set_boolean (const char *key, - gboolean boolean_value); -gboolean eel_gconf_get_boolean (const char *key); -int eel_gconf_get_integer (const char *key); -void eel_gconf_set_integer (const char *key, - int int_value); -gfloat eel_gconf_get_float (const char *key); -void eel_gconf_set_float (const char *key, - gfloat float_value); -char * eel_gconf_get_string (const char *key); -void eel_gconf_set_string (const char *key, - const char *string_value); -GSList * eel_gconf_get_string_list (const char *key); -void eel_gconf_set_string_list (const char *key, - const GSList *string_list_value); -gboolean eel_gconf_is_default (const char *key); -gboolean eel_gconf_monitor_add (const char *directory); -gboolean eel_gconf_monitor_remove (const char *directory); -void eel_gconf_suggest_sync (void); -GConfValue* eel_gconf_get_value (const char *key); -gboolean eel_gconf_value_is_equal (const GConfValue *a, - const GConfValue *b); -void eel_gconf_set_value (const char *key, - const GConfValue *value); -gboolean eel_gconf_key_exists (const char *key); - -void eel_gconf_value_free (GConfValue *value); -void eel_gconf_unset (const char *key); +GConfClient *eel_gconf_client_get_global (void); +gboolean eel_gconf_handle_error (GError **error); +void eel_gconf_set_boolean (const char *key, + gboolean boolean_value); +gboolean eel_gconf_get_boolean (const char *key); +int eel_gconf_get_integer (const char *key); +void eel_gconf_set_integer (const char *key, + int int_value); +gfloat eel_gconf_get_float (const char *key); +void eel_gconf_set_float (const char *key, + gfloat float_value); +char * eel_gconf_get_string (const char *key); +void eel_gconf_set_string (const char *key, + const char *string_value); +GSList * eel_gconf_get_string_list (const char *key); +void eel_gconf_set_string_list (const char *key, + const GSList *string_list_value); +gboolean eel_gconf_is_default (const char *key); +gboolean eel_gconf_monitor_add (const char *directory); +gboolean eel_gconf_monitor_remove (const char *directory); +void eel_gconf_suggest_sync (void); +GConfValue* eel_gconf_get_value (const char *key); +gboolean eel_gconf_value_is_equal (const GConfValue *a, + const GConfValue *b); +void eel_gconf_set_value (const char *key, + const GConfValue *value); +gboolean eel_gconf_key_exists (const char *key); + +void eel_gconf_value_free (GConfValue *value); +void eel_gconf_unset (const char *key); /* Functions which weren't part of the eel-gconf-extensions.h file from eel */ -GSList *eel_gconf_get_integer_list (const char *key); -void eel_gconf_set_integer_list (const char *key, - const GSList *slist); -void gpdf_notification_add (const char *key, - GConfClientNotifyFunc notification_callback, - gpointer callback_data, - GList **notifiers); -void gpdf_notification_remove (GList **notifiers); -guint eel_gconf_notification_add (const char *key, - GConfClientNotifyFunc notification_callback, - gpointer callback_data); -void eel_gconf_notification_remove (guint notification_id); +GSList *eel_gconf_get_integer_list (const char *key); +void eel_gconf_set_integer_list (const char *key, + const GSList *slist); +void gpdf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data, + GList **notifiers); +void gpdf_notification_remove (GList **notifiers); +guint eel_gconf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data); +void eel_gconf_notification_remove (guint notification_id); #ifdef __cplusplus END_EXTERN_C diff --git a/sflphone-client-gnome/src/errors.c b/sflphone-client-gnome/src/errors.c index 0dbd1240014d8d810155b4484213bb4f06cfc989..87e05c83dcd48c8538c3da74092790e65feeb010 100644 --- a/sflphone-client-gnome/src/errors.c +++ b/sflphone-client-gnome/src/errors.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -31,21 +31,23 @@ #include <errors.h> #include <sflphone_const.h> - void -sflphone_throw_exception( int err ) +void +sflphone_throw_exception (int err) { - gchar* markup=""; - switch( err ){ - case ALSA_PLAYBACK_DEVICE: - markup = g_markup_printf_escaped(_("ALSA notification\n\nError while opening playback device")); - break; - case ALSA_CAPTURE_DEVICE: - markup = g_markup_printf_escaped(_("ALSA notification\n\nError while opening capture device")); - break; - case PULSEAUDIO_NOT_RUNNING: - markup = g_markup_printf_escaped(_("Pulseaudio notification\n\nPulseaudio is not running")); - break; - } - main_window_error_message( markup ); - free( markup ); + gchar* markup=""; + + switch (err) { + case ALSA_PLAYBACK_DEVICE: + markup = g_markup_printf_escaped (_ ("ALSA notification\n\nError while opening playback device")); + break; + case ALSA_CAPTURE_DEVICE: + markup = g_markup_printf_escaped (_ ("ALSA notification\n\nError while opening capture device")); + break; + case PULSEAUDIO_NOT_RUNNING: + markup = g_markup_printf_escaped (_ ("Pulseaudio notification\n\nPulseaudio is not running")); + break; + } + + main_window_error_message (markup); + free (markup); } diff --git a/sflphone-client-gnome/src/errors.h b/sflphone-client-gnome/src/errors.h index 2c87178ff3c020408fa40a1f9ab524c1167e5a86..80d1e08da2e13d1c1fbb3a8a435434813f41d610 100644 --- a/sflphone-client-gnome/src/errors.h +++ b/sflphone-client-gnome/src/errors.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __ERRORS_H #define __ERRORS_H @@ -45,6 +45,6 @@ * ALSA_PLAYBACK_ERROR * ALSA_CAPTURE_ERROR */ -void sflphone_throw_exception( int err ); +void sflphone_throw_exception (int err); #endif diff --git a/sflphone-client-gnome/src/icons/icon_factory.c b/sflphone-client-gnome/src/icons/icon_factory.c index 2d2d944fdb8b34676d2a26d375d27e9e49f522b1..6608a2b1aad0c971a137bc1fe12fd36f79a67af3 100644 --- a/sflphone-client-gnome/src/icons/icon_factory.c +++ b/sflphone-client-gnome/src/icons/icon_factory.c @@ -36,59 +36,59 @@ static GtkIconFactory *icon_factory = NULL; void add_icon (GtkIconFactory *factory, const gchar *stock_id, const guint8 *icon_data, GtkIconSize size) { - GtkIconSet *icons; - GtkIconSource *source; - GdkPixbuf *pixbuf; - - icons = gtk_icon_factory_lookup (factory, stock_id); - if (!icons) - { - pixbuf = gdk_pixbuf_new_from_inline (-1, icon_data, FALSE, NULL); - source = gtk_icon_source_new (); - gtk_icon_source_set_pixbuf (source, pixbuf); - gtk_icon_source_set_size (source, size); - - icons = gtk_icon_set_new (); - gtk_icon_set_add_source (icons, source); - - gtk_icon_factory_add (factory, stock_id, icons); - - g_object_unref (G_OBJECT (pixbuf)); - gtk_icon_source_free (source); - gtk_icon_set_unref (icons); - } - else - DEBUG ("Icon %s already exists in factory\n", stock_id); + GtkIconSet *icons; + GtkIconSource *source; + GdkPixbuf *pixbuf; + + icons = gtk_icon_factory_lookup (factory, stock_id); + + if (!icons) { + pixbuf = gdk_pixbuf_new_from_inline (-1, icon_data, FALSE, NULL); + source = gtk_icon_source_new (); + gtk_icon_source_set_pixbuf (source, pixbuf); + gtk_icon_source_set_size (source, size); + + icons = gtk_icon_set_new (); + gtk_icon_set_add_source (icons, source); + + gtk_icon_factory_add (factory, stock_id, icons); + + g_object_unref (G_OBJECT (pixbuf)); + gtk_icon_source_free (source); + gtk_icon_set_unref (icons); + } else + DEBUG ("Icon %s already exists in factory\n", stock_id); } -GtkIconSet* lookup_sflphone_factory (const gchar *stock_id) { +GtkIconSet* lookup_sflphone_factory (const gchar *stock_id) +{ - return gtk_icon_factory_lookup (icon_factory, stock_id); + return gtk_icon_factory_lookup (icon_factory, stock_id); } void register_sflphone_stock_icons (GtkIconFactory *factory) { - add_icon (factory, GTK_STOCK_PICKUP, gnome_stock_pickup, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_HANGUP, gnome_stock_hangup, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_DIAL, gnome_stock_dial, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_TRANSFER, gnome_stock_transfer, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_ONHOLD, gnome_stock_onhold, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_OFFHOLD, gnome_stock_offhold, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_CALL_CURRENT, gnome_stock_call_current, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_ADDRESSBOOK, gnome_stock_addressbook, GTK_ICON_SIZE_SMALL_TOOLBAR); - add_icon (factory, GTK_STOCK_CALLS, gnome_stock_calls, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_PICKUP, gnome_stock_pickup, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_HANGUP, gnome_stock_hangup, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_DIAL, gnome_stock_dial, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_TRANSFER, gnome_stock_transfer, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_ONHOLD, gnome_stock_onhold, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_OFFHOLD, gnome_stock_offhold, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_CALL_CURRENT, gnome_stock_call_current, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_ADDRESSBOOK, gnome_stock_addressbook, GTK_ICON_SIZE_SMALL_TOOLBAR); + add_icon (factory, GTK_STOCK_CALLS, gnome_stock_calls, GTK_ICON_SIZE_SMALL_TOOLBAR); } void init_icon_factory (void) { - // Init the factory - icon_factory = gtk_icon_factory_new (); + // Init the factory + icon_factory = gtk_icon_factory_new (); - // Load icons - register_sflphone_stock_icons (icon_factory); + // Load icons + register_sflphone_stock_icons (icon_factory); - // Specify a default icon set - gtk_icon_factory_add_default (icon_factory); + // Specify a default icon set + gtk_icon_factory_add_default (icon_factory); } diff --git a/sflphone-client-gnome/src/icons/pixmap_data.h b/sflphone-client-gnome/src/icons/pixmap_data.h index ce8fcc648c82673ca20b783dda03d1bdef575f04..26d4550ee13f4e71bd820b55de1e7604c6d6fd89 100644 --- a/sflphone-client-gnome/src/icons/pixmap_data.h +++ b/sflphone-client-gnome/src/icons/pixmap_data.h @@ -39,100 +39,101 @@ G_BEGIN_DECLS #pragma align 4 (gnome_stock_pickup) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_pickup[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_pickup[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_pickup[] = +static const guint8 gnome_stock_pickup[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0'\260\0\204&\260\0\222\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0'\261\0b&\260\0\357&\260\0\357'\262\0p\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\257\0F" - "&\260\0\342&\260\0\345&\260\0\345&\260\0\344%\256\0R\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\263\0/'\260\0\322" - "&\260\0\333&\260\0\333&\260\0\333&\260\0\333&\257\0\326(\256\0""9\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0#\260\0\35%\260\0\277" - "&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261" - "\0\304\"\254\0%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40\257\0\20'\261\0" - "\252'\260\0\306'\260\0\306'\260\0\306'\260\0\306'\260\0\306'\260\0\306" - "'\260\0\306'\260\0\306'\261\0\260#\256\0\26\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\266\0" - "\7&\261\0\223&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\274" - "&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\233.\271" - "\0\13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\200\0\2'\257\0|'\260\0\262'\260\0\262'\260\0\262'\260\0\262" - "'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260" - "\0\262'\260\0\262'\260\0\204@\277\0\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'\257\0c&\260\0\250&\260\0\250&\260\0" - "\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250" - "&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\261\0l\0\0\0" - "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\260\0J'\260\0\236" - "'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260" - "\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0" - "\236'\260\0\236'\260\0\236'\260\0T\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0&\255\0""5&\261\0\223&\260\0\224&\260\0\224&\260\0\224&\260\0\224" - "&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260" - "\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0" - "\224&\260\0=\0\0\0\0\0\0\0\0\0\0\0\0#\261\0$(\260\0\207'\260\0\212'\260" - "\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0" - "\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212" - "'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\210$\260\0*\0\0\0" - "\0!\261\0\27&\260\0x&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257" - "\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0" - "\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200" - "&\257\0\200&\257\0\200&\257\0\200%\260\0{$\255\0\34""3\231\0\5\40\237" - "\0\10\40\237\0\10\40\237\0\10\40\237\0\10&\256\0/'\257\0v'\257\0v'\257" - "\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'" - "\257\0v&\262\0""5\40\237\0\10\40\237\0\10\40\237\0\10\40\237\0\10""3" - "\231\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0(\256\0&&\260\0k&\260" - "\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&" - "\260\0k&\260\0k)\256\0,\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\264\0\"%\260\0a%\260\0a%\260\0a%" - "\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260" - "\0a&\263\0(\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0)\255\0\37&\260\0W&\260\0W&\260\0W&\260\0W&\260" - "\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W#\261\0$\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0&\263\0\33$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M" - "$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M(\257\0\40\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0+\252\0\30&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C" - "&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C$\255\0\34\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\263\0" - "\24$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256" - "\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9!\261\0\27\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\36\245\0\21&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/" - "&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/(\256\0\23\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0'\261\0\15)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%" - ")\263\0%)\263\0%)\263\0%)\263\0%)\263\0%\"\273\0\17\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32\263" - "\0\12&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263" - "\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33.\271\0\13\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0+\252\0\6-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-" - "\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21" - "$\266\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0'\260\0\204&\260\0\222\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0'\261\0b&\260\0\357&\260\0\357'\262\0p\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\257\0F" + "&\260\0\342&\260\0\345&\260\0\345&\260\0\344%\256\0R\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\263\0/'\260\0\322" + "&\260\0\333&\260\0\333&\260\0\333&\260\0\333&\257\0\326(\256\0""9\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0#\260\0\35%\260\0\277" + "&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261\0\320&\261" + "\0\304\"\254\0%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40\257\0\20'\261\0" + "\252'\260\0\306'\260\0\306'\260\0\306'\260\0\306'\260\0\306'\260\0\306" + "'\260\0\306'\260\0\306'\261\0\260#\256\0\26\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$\266\0" + "\7&\261\0\223&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\274" + "&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\274&\260\0\233.\271" + "\0\13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\200\0\2'\257\0|'\260\0\262'\260\0\262'\260\0\262'\260\0\262" + "'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260\0\262'\260" + "\0\262'\260\0\262'\260\0\204@\277\0\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'\257\0c&\260\0\250&\260\0\250&\260\0" + "\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250" + "&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\260\0\250&\261\0l\0\0\0" + "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\260\0J'\260\0\236" + "'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260" + "\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0\236'\260\0" + "\236'\260\0\236'\260\0\236'\260\0T\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0&\255\0""5&\261\0\223&\260\0\224&\260\0\224&\260\0\224&\260\0\224" + "&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260" + "\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0\224&\260\0" + "\224&\260\0=\0\0\0\0\0\0\0\0\0\0\0\0#\261\0$(\260\0\207'\260\0\212'\260" + "\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0" + "\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\212" + "'\260\0\212'\260\0\212'\260\0\212'\260\0\212'\260\0\210$\260\0*\0\0\0" + "\0!\261\0\27&\260\0x&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257" + "\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0" + "\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200&\257\0\200" + "&\257\0\200&\257\0\200&\257\0\200%\260\0{$\255\0\34""3\231\0\5\40\237" + "\0\10\40\237\0\10\40\237\0\10\40\237\0\10&\256\0/'\257\0v'\257\0v'\257" + "\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'\257\0v'" + "\257\0v&\262\0""5\40\237\0\10\40\237\0\10\40\237\0\10\40\237\0\10""3" + "\231\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0(\256\0&&\260\0k&\260" + "\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&\260\0k&" + "\260\0k&\260\0k)\256\0,\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\264\0\"%\260\0a%\260\0a%\260\0a%" + "\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260\0a%\260" + "\0a&\263\0(\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0)\255\0\37&\260\0W&\260\0W&\260\0W&\260\0W&\260" + "\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W&\260\0W#\261\0$\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0&\263\0\33$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M" + "$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M$\260\0M(\257\0\40\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0+\252\0\30&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C" + "&\257\0C&\257\0C&\257\0C&\257\0C&\257\0C$\255\0\34\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&\263\0" + "\24$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256" + "\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9$\256\0""9!\261\0\27\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\36\245\0\21&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/" + "&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/&\256\0/(\256\0\23\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0'\261\0\15)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%)\263\0%" + ")\263\0%)\263\0%)\263\0%)\263\0%)\263\0%\"\273\0\17\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32\263" + "\0\12&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263" + "\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33&\263\0\33.\271\0\13\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0+\252\0\6-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-" + "\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21-\264\0\21" + "$\266\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -141,108 +142,109 @@ static const guint8 gnome_stock_pickup[] = #pragma align 4 (gnome_stock_hangup) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_hangup[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_hangup[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_hangup[] = +static const guint8 gnome_stock_hangup[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\252\0\0\3\277\40\0\10\277\40" - "\0\10\277\40\0\10\277\40\0\10\277\40\0\10\277\40\0\10\266$\0\7\266$\0" - "\7\266$\0\7\266$\0\7\266$\0\7\266$\0\7\252\0\0\3\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\237\40\0" - "\10\256\33\0\23\256\33\0\23\252\34\0\22\252\34\0\22\252\34\0\22\252\34" - "\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252" - "\34\0\22\277\40\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\252\25\0\14\260\32\0\35\260\32\0\35" - "\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0" - "\35\255\33\0\34\255\33\0\34\255\33\0\34\255\33\0\34\261\24\0\15\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\277\40\0\20\263\32\0(\263\32\0(\263\32\0(\263\32\0(\261\32\0'" - "\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0" - "'\270\34\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\252\30\0\25\257\31\0""3\263\32\0""2\263\32\0" - "2\263\32\0""2\263\32\0""2\263\32\0""2\263\32\0""2\263\32\0""2\263\32" - "\0""2\263\32\0""2\261\32\0""1\261\32\0""1\261\26\0\27\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255" - "\24\0\31\260\31\0=\260\31\0=\260\31\0=\260\31\0=\260\31\0=\260\31\0=" - "\260\31\0=\256\32\0<\256\32\0<\256\32\0<\256\32\0<\256\32\0<\255\33\0" - "\34\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\263\21\0\36\261\25\0H\261\25\0H\261\25\0H\260\26\0G\260" - "\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260" - "\26\0G\262\27\0!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\27\0\"\261\26\0R\261\26\0R\261\26\0" - "R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\260\26" - "\0Q\260\26\0Q\260\26\0Q\256\24\0&\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\256\24\0&\257\23\0]\257" - "\23\0]\257\23\0]\257\23\0]\257\23\0]\257\26\0\\\257\26\0\\\257\26\0\\" - "\257\26\0\\\257\26\0\\\257\26\0\\\257\26\0\\\262\30\0+\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\262" - "\22\0+\261\24\0h\260\24\0g\260\24\0g\260\24\0g\260\24\0g\260\24\0g\260" - "\24\0g\260\24\0g\260\24\0g\260\24\0g\260\24\0g\257\24\0f\257\25\0""0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\263\20\0/\261\22\0r\261\22\0r\261\22\0r\261\22\0r\261\22" - "\0r\261\22\0r\261\22\0r\260\22\0q\260\22\0q\260\22\0q\260\22\0q\260\22" - "\0q\262\23\0""5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\257\17\0""3\257\20\0}\257\20\0}\257\20\0}" - "\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0" - "|\261\20\0|\261\20\0|\260\22\0:\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\255\22\0\34\260\21\0-\260\21\0-\260\21\0-\260\21\0-\261\20\0R\260" - "\17\0\207\260\17\0\207\260\17\0\207\260\17\0\207\260\17\0\207\260\17" - "\0\207\260\17\0\207\260\17\0\207\260\17\0\207\257\17\0\206\257\17\0\206" - "\257\17\0\206\260\17\0W\260\21\0-\260\21\0-\260\21\0-\260\21\0-\260\22" - "\0\35\261\24\0\15\256\15\0x\260\16\0\222\260\16\0\222\260\16\0\222\260" - "\16\0\222\260\16\0\222\260\16\0\222\260\16\0\222\260\16\0\222\260\16" - "\0\222\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221" - "\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\257" - "\16\0\220\257\17\0y\257\20\0\20\0\0\0\0\263\0\0\12\256\12\0{\257\13\0" - "\235\257\13\0\235\257\13\0\235\257\13\0\235\257\13\0\235\261\13\0\234" - "\261\13\0\234\261\13\0\234\261\13\0\234\261\13\0\234\261\13\0\234\261" - "\13\0\234\261\13\0\234\261\13\0\234\260\14\0\233\260\14\0\233\260\14" - "\0\233\260\14\0\233\260\14\0~\261\24\0\15\0\0\0\0\0\0\0\0\0\0\0\0\237" - "\0\0\10\260\12\0~\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247" - "\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247\260" - "\13\0\247\261\13\0\246\261\13\0\246\261\13\0\246\261\13\0\246\261\13" - "\0\246\261\13\0\246\261\12\0\202\271\0\0\13\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\252\0\0\6\260\10\0~\260\11\0\262\260\11\0\262\260\11\0" - "\262\260\11\0\262\260\11\0\262\260\12\0\261\260\12\0\261\260\12\0\261" - "\260\12\0\261\260\12\0\261\260\12\0\261\260\12\0\261\260\12\0\261\260" - "\12\0\261\257\12\0\203\277\0\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\277\0\0\4\257\10\0}\260\10\0\274\260\10\0\274\260" - "\10\0\274\260\10\0\274\260\10\0\274\260\10\0\274\260\10\0\274\260\10" - "\0\274\260\10\0\274\260\10\0\274\260\10\0\273\260\10\0\273\260\10\0\204" - "\266\0\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\377\0\0\2\257\6\0|\260\6\0\307\260\6\0\307\260\6\0\307" - "\260\6\0\307\260\6\0\307\260\6\0\306\260\6\0\306\260\6\0\306\260\6\0" - "\306\260\6\0\306\261\6\0\202\231\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\1" - "\260\4\0x\260\5\0\321\260\5\0\321\260\5\0\321\260\5\0\321\260\5\0\321" - "\260\5\0\321\260\5\0\321\260\5\0\321\260\4\0\201\377\0\0\2\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\261\4\0r\260\3\0\334\260\3\0\334\260" - "\3\0\334\260\3\0\334\260\3\0\334\260\3\0\333\257\4\0}\377\0\0\1\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\257\2\0m\260\3" - "\0\346\260\3\0\346\260\3\0\346\260\3\0\346\260\4\0w\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\260" - "\0\0d\257\1\0\360\260\1\0\361\257\0\0p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\257\0\0\\\257\0\0i\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\252\0\0\3\277\40\0\10\277\40" + "\0\10\277\40\0\10\277\40\0\10\277\40\0\10\277\40\0\10\266$\0\7\266$\0" + "\7\266$\0\7\266$\0\7\266$\0\7\266$\0\7\252\0\0\3\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\237\40\0" + "\10\256\33\0\23\256\33\0\23\252\34\0\22\252\34\0\22\252\34\0\22\252\34" + "\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252\34\0\22\252" + "\34\0\22\277\40\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\252\25\0\14\260\32\0\35\260\32\0\35" + "\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0\35\260\32\0" + "\35\255\33\0\34\255\33\0\34\255\33\0\34\255\33\0\34\261\24\0\15\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\277\40\0\20\263\32\0(\263\32\0(\263\32\0(\263\32\0(\261\32\0'" + "\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0'\261\32\0" + "'\270\34\0\22\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\252\30\0\25\257\31\0""3\263\32\0""2\263\32\0" + "2\263\32\0""2\263\32\0""2\263\32\0""2\263\32\0""2\263\32\0""2\263\32" + "\0""2\263\32\0""2\261\32\0""1\261\32\0""1\261\26\0\27\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255" + "\24\0\31\260\31\0=\260\31\0=\260\31\0=\260\31\0=\260\31\0=\260\31\0=" + "\260\31\0=\256\32\0<\256\32\0<\256\32\0<\256\32\0<\256\32\0<\255\33\0" + "\34\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\263\21\0\36\261\25\0H\261\25\0H\261\25\0H\260\26\0G\260" + "\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260\26\0G\260" + "\26\0G\262\27\0!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\27\0\"\261\26\0R\261\26\0R\261\26\0" + "R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\261\26\0R\260\26" + "\0Q\260\26\0Q\260\26\0Q\256\24\0&\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\256\24\0&\257\23\0]\257" + "\23\0]\257\23\0]\257\23\0]\257\23\0]\257\26\0\\\257\26\0\\\257\26\0\\" + "\257\26\0\\\257\26\0\\\257\26\0\\\257\26\0\\\262\30\0+\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\262" + "\22\0+\261\24\0h\260\24\0g\260\24\0g\260\24\0g\260\24\0g\260\24\0g\260" + "\24\0g\260\24\0g\260\24\0g\260\24\0g\260\24\0g\257\24\0f\257\25\0""0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\263\20\0/\261\22\0r\261\22\0r\261\22\0r\261\22\0r\261\22" + "\0r\261\22\0r\261\22\0r\260\22\0q\260\22\0q\260\22\0q\260\22\0q\260\22" + "\0q\262\23\0""5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\257\17\0""3\257\20\0}\257\20\0}\257\20\0}" + "\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0|\261\20\0" + "|\261\20\0|\261\20\0|\260\22\0:\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\255\22\0\34\260\21\0-\260\21\0-\260\21\0-\260\21\0-\261\20\0R\260" + "\17\0\207\260\17\0\207\260\17\0\207\260\17\0\207\260\17\0\207\260\17" + "\0\207\260\17\0\207\260\17\0\207\260\17\0\207\257\17\0\206\257\17\0\206" + "\257\17\0\206\260\17\0W\260\21\0-\260\21\0-\260\21\0-\260\21\0-\260\22" + "\0\35\261\24\0\15\256\15\0x\260\16\0\222\260\16\0\222\260\16\0\222\260" + "\16\0\222\260\16\0\222\260\16\0\222\260\16\0\222\260\16\0\222\260\16" + "\0\222\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221" + "\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\260\16\0\221\257" + "\16\0\220\257\17\0y\257\20\0\20\0\0\0\0\263\0\0\12\256\12\0{\257\13\0" + "\235\257\13\0\235\257\13\0\235\257\13\0\235\257\13\0\235\261\13\0\234" + "\261\13\0\234\261\13\0\234\261\13\0\234\261\13\0\234\261\13\0\234\261" + "\13\0\234\261\13\0\234\261\13\0\234\260\14\0\233\260\14\0\233\260\14" + "\0\233\260\14\0\233\260\14\0~\261\24\0\15\0\0\0\0\0\0\0\0\0\0\0\0\237" + "\0\0\10\260\12\0~\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247" + "\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247\260\13\0\247\260" + "\13\0\247\261\13\0\246\261\13\0\246\261\13\0\246\261\13\0\246\261\13" + "\0\246\261\13\0\246\261\12\0\202\271\0\0\13\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\252\0\0\6\260\10\0~\260\11\0\262\260\11\0\262\260\11\0" + "\262\260\11\0\262\260\11\0\262\260\12\0\261\260\12\0\261\260\12\0\261" + "\260\12\0\261\260\12\0\261\260\12\0\261\260\12\0\261\260\12\0\261\260" + "\12\0\261\257\12\0\203\277\0\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\277\0\0\4\257\10\0}\260\10\0\274\260\10\0\274\260" + "\10\0\274\260\10\0\274\260\10\0\274\260\10\0\274\260\10\0\274\260\10" + "\0\274\260\10\0\274\260\10\0\274\260\10\0\273\260\10\0\273\260\10\0\204" + "\266\0\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\377\0\0\2\257\6\0|\260\6\0\307\260\6\0\307\260\6\0\307" + "\260\6\0\307\260\6\0\307\260\6\0\306\260\6\0\306\260\6\0\306\260\6\0" + "\306\260\6\0\306\261\6\0\202\231\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\1" + "\260\4\0x\260\5\0\321\260\5\0\321\260\5\0\321\260\5\0\321\260\5\0\321" + "\260\5\0\321\260\5\0\321\260\5\0\321\260\4\0\201\377\0\0\2\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\261\4\0r\260\3\0\334\260\3\0\334\260" + "\3\0\334\260\3\0\334\260\3\0\334\260\3\0\333\257\4\0}\377\0\0\1\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\257\2\0m\260\3" + "\0\346\260\3\0\346\260\3\0\346\260\3\0\346\260\4\0w\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\260" + "\0\0d\257\1\0\360\260\1\0\361\257\0\0p\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\257\0\0\\\257\0\0i\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -250,101 +252,102 @@ static const guint8 gnome_stock_hangup[] = #pragma align 4 (gnome_stock_onhold) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_onhold[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_onhold[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_onhold[] = +static const guint8 gnome_stock_onhold[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\40jj\30\34knQ\35kp\217\33mq\330\35jo\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU\3\33mm/\35joj\34lr\254\33mq\350" - "\34jo\374\27sy\362\20~\207\374\13\207\217\377\35jo\377\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\"" - "fw\17\34jnH\35lp\202\33ns\310\35kq\367\33nr\365\24z\201\364\15\206\217" - "\377\6\220\231\377\1\231\242\377\0\230\242\377\0\227\241\377\2\222\235" - "\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "$mm\16\33ls\247\33ns\337\34ko\374\30sy\361\21\201\210\371\12\215\226" - "\377\3\227\242\377\0\234\247\377\0\233\246\377\1\231\243\377\6\216\230" - "\377\15\204\213\377\24sx\374\34kp\377\2\220\233\377\35jo\377\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32fo\36\35jo\377\7\224" - "\236\377\1\237\252\377\0\240\252\377\0\236\251\377\2\231\244\377\11\215" - "\226\377\17\201\210\376\27pv\371\34jo\375\33gk\370\26TW\341\22EG\324" - "\35jo\377\2\216\230\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\14\13+/G\33lp\373\1\236\251\377\13\213\223\377\22" - "{\203\374\30mr\372\34jn\376\30af\360\23IM\330\15.1\302\4\20\22\255\0" - "\0\0\243\0\0\0\243\4\22\23\256\33ko\373\2\214\225\377\35jo\377\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0x\4\22\23\254\33ko\375" - "\3\227\241\377\35jo\377\21@D\317\12%&\272\2\6\6\247\0\0\0\243\0\0\0\233" - "\0\0\0\232\0\0\0\234\0\0\0\243\0\0\0\237\4\22\23\256\33ko\373\2\212\223" - "\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t" - "\4\22\23\256\33jo\375\3\225\237\377\33im\374\0\0\0\231\0\0\0\237\0\0" - "\0\213\0\0\0c\0\0\0;\0\0\0\30\0\0\0\0\0\0\0:\0\0\0\234\4\22\23\256\33" - "ko\373\2\207\220\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\223\235\377\34ko\371\0\0\0$\0" - "\0\0\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0\234\4\22" - "\23\256\33ko\373\2\205\217\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\221\233\377\34lp\366" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0" - "\234\4\22\23\256\33ko\373\2\202\214\377\35jo\377\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\217\230\377" - "\34lp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0:\0\0\0\234\4\22\23\256\33ko\373\2\200\212\377\35jo\377\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jn\375\3\215" - "\226\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0:\0\0\0\234\4\22\23\256\33jo\373\2~\207\377\35jo\377\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jn\375" - "\3\212\224\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0:\0\0\0\234\4\22\23\256\33jo\373\2|\204\377\35jo\377" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33" - "jn\375\3\210\221\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\30mm\25\26QT\216\25UZ\342\31bf\364\35jo\377\2z\202\377\35jo" - "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256" - "\33jn\375\3\206\220\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU" - "\3\32bf\177\35ko\371\24ms\372\13u|\377\10w~\377\12t|\377\2w\177\377\35" - "jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23" - "\256\33jn\375\3\204\215\377\34ko\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0*\26" - "SV\325\27kq\373\5z\202\377\0|\204\377\0z\202\377\0y\201\377\0w\177\377" - "\5t{\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\36lp;\22EH" - "\264\25RV\342\35jo\377\3\202\213\377\34ko\366\0\0\0\0\0\0\0\0\0\0\0O" - "\15""13\275\27jp\373\1{\203\377\0z\203\377\0y\201\377\0x\200\377\0v~" - "\377\0u}\377\11qw\377\33kp\311\0\0\0\0\0\0\0\0\0\0\0\0\31aeG\32gn\350" - "\32lp\370\21tz\375\16x\200\377\20v}\377\3\200\211\377\34ko\366\0\0\0" - "\0\0\0\0%\0\0\0\233\26W]\347\13u{\377\0y\202\377\0x\200\377\0v~\377\0" - "u}\377\0t|\377\6px\377\34jp\366\35lq4\0\0\0\0\0\0\0\12\22GJ\251\33jn" - "\374\13}\203\377\0\206\217\377\0\205\216\377\0\204\214\377\0\202\213" - "\377\7{\203\377\35jo\377\0\0\0\0\0\0\0d\0\0\0\242\26SV\341\21ou\375\0" - "w\177\377\0v~\377\0t|\377\4rz\377\20kr\375\34jn\367\33jmT\0\0\0\0\0\0" - "\0\12\13$&\250\32jn\373\3\204\215\377\0\205\216\377\0\204\215\377\0\203" - "\213\377\0\201\212\377\0\200\210\377\11x\200\377\34lp\346\0\0\0\0\0\0" - "\0D\0\0\0\234\4\22\22\255\31`e\362\32gm\374\27gm\371\32hl\372\34hn\371" - "\34hl\245!kk\37\0\0\0\0\0\0\0\0\0\0\0h\24RX\340\14y\201\377\0\204\215" - "\377\0\203\214\377\0\201\212\377\0\200\211\377\0\177\207\377\3{\204\377" - "\32mq\364\34ipI\0\0\0\0\0\0\0\1\0\0\0G\0\0\0\202\0\0\0\222\5\25\26\225" - "\16""02\200\20@D@3ff\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\230\26W" - "]\347\15w\177\377\0\202\212\377\0\201\211\377\0\177\210\377\1}\206\377" - "\13v|\377\33kp\370\35io\205\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0k\11\40!\261\33hm\373\25jp\372\20pv\374\23lr\372\33in\374\33" - "gm\341\34jnH\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\3\0\0\0A\4\21\21z\16""47\241\23FI\245\25PTy\35ch,\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\40jj\30\34knQ\35kp\217\33mq\330\35jo\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU\3\33mm/\35joj\34lr\254\33mq\350" + "\34jo\374\27sy\362\20~\207\374\13\207\217\377\35jo\377\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\"" + "fw\17\34jnH\35lp\202\33ns\310\35kq\367\33nr\365\24z\201\364\15\206\217" + "\377\6\220\231\377\1\231\242\377\0\230\242\377\0\227\241\377\2\222\235" + "\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "$mm\16\33ls\247\33ns\337\34ko\374\30sy\361\21\201\210\371\12\215\226" + "\377\3\227\242\377\0\234\247\377\0\233\246\377\1\231\243\377\6\216\230" + "\377\15\204\213\377\24sx\374\34kp\377\2\220\233\377\35jo\377\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32fo\36\35jo\377\7\224" + "\236\377\1\237\252\377\0\240\252\377\0\236\251\377\2\231\244\377\11\215" + "\226\377\17\201\210\376\27pv\371\34jo\375\33gk\370\26TW\341\22EG\324" + "\35jo\377\2\216\230\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\14\13+/G\33lp\373\1\236\251\377\13\213\223\377\22" + "{\203\374\30mr\372\34jn\376\30af\360\23IM\330\15.1\302\4\20\22\255\0" + "\0\0\243\0\0\0\243\4\22\23\256\33ko\373\2\214\225\377\35jo\377\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0x\4\22\23\254\33ko\375" + "\3\227\241\377\35jo\377\21@D\317\12%&\272\2\6\6\247\0\0\0\243\0\0\0\233" + "\0\0\0\232\0\0\0\234\0\0\0\243\0\0\0\237\4\22\23\256\33ko\373\2\212\223" + "\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t" + "\4\22\23\256\33jo\375\3\225\237\377\33im\374\0\0\0\231\0\0\0\237\0\0" + "\0\213\0\0\0c\0\0\0;\0\0\0\30\0\0\0\0\0\0\0:\0\0\0\234\4\22\23\256\33" + "ko\373\2\207\220\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\223\235\377\34ko\371\0\0\0$\0" + "\0\0\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0\234\4\22" + "\23\256\33ko\373\2\205\217\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\221\233\377\34lp\366" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0" + "\234\4\22\23\256\33ko\373\2\202\214\377\35jo\377\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jo\375\3\217\230\377" + "\34lp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0:\0\0\0\234\4\22\23\256\33ko\373\2\200\212\377\35jo\377\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jn\375\3\215" + "\226\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0:\0\0\0\234\4\22\23\256\33jo\373\2~\207\377\35jo\377\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33jn\375" + "\3\212\224\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0:\0\0\0\234\4\22\23\256\33jo\373\2|\204\377\35jo\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256\33" + "jn\375\3\210\221\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\30mm\25\26QT\216\25UZ\342\31bf\364\35jo\377\2z\202\377\35jo" + "\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23\256" + "\33jn\375\3\206\220\377\34kp\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU" + "\3\32bf\177\35ko\371\24ms\372\13u|\377\10w~\377\12t|\377\2w\177\377\35" + "jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\4\22\23" + "\256\33jn\375\3\204\215\377\34ko\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0*\26" + "SV\325\27kq\373\5z\202\377\0|\204\377\0z\202\377\0y\201\377\0w\177\377" + "\5t{\377\35jo\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\36lp;\22EH" + "\264\25RV\342\35jo\377\3\202\213\377\34ko\366\0\0\0\0\0\0\0\0\0\0\0O" + "\15""13\275\27jp\373\1{\203\377\0z\203\377\0y\201\377\0x\200\377\0v~" + "\377\0u}\377\11qw\377\33kp\311\0\0\0\0\0\0\0\0\0\0\0\0\31aeG\32gn\350" + "\32lp\370\21tz\375\16x\200\377\20v}\377\3\200\211\377\34ko\366\0\0\0" + "\0\0\0\0%\0\0\0\233\26W]\347\13u{\377\0y\202\377\0x\200\377\0v~\377\0" + "u}\377\0t|\377\6px\377\34jp\366\35lq4\0\0\0\0\0\0\0\12\22GJ\251\33jn" + "\374\13}\203\377\0\206\217\377\0\205\216\377\0\204\214\377\0\202\213" + "\377\7{\203\377\35jo\377\0\0\0\0\0\0\0d\0\0\0\242\26SV\341\21ou\375\0" + "w\177\377\0v~\377\0t|\377\4rz\377\20kr\375\34jn\367\33jmT\0\0\0\0\0\0" + "\0\12\13$&\250\32jn\373\3\204\215\377\0\205\216\377\0\204\215\377\0\203" + "\213\377\0\201\212\377\0\200\210\377\11x\200\377\34lp\346\0\0\0\0\0\0" + "\0D\0\0\0\234\4\22\22\255\31`e\362\32gm\374\27gm\371\32hl\372\34hn\371" + "\34hl\245!kk\37\0\0\0\0\0\0\0\0\0\0\0h\24RX\340\14y\201\377\0\204\215" + "\377\0\203\214\377\0\201\212\377\0\200\211\377\0\177\207\377\3{\204\377" + "\32mq\364\34ipI\0\0\0\0\0\0\0\1\0\0\0G\0\0\0\202\0\0\0\222\5\25\26\225" + "\16""02\200\20@D@3ff\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\230\26W" + "]\347\15w\177\377\0\202\212\377\0\201\211\377\0\177\210\377\1}\206\377" + "\13v|\377\33kp\370\35io\205\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0k\11\40!\261\33hm\373\25jp\372\20pv\374\23lr\372\33in\374\33" + "gm\341\34jnH\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\3\0\0\0A\4\21\21z\16""47\241\23FI\245\25PTy\35ch,\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -352,109 +355,110 @@ static const guint8 gnome_stock_onhold[] = #pragma align 4 (gnome_stock_dial) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_dial[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_dial[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_dial[] = +static const guint8 gnome_stock_dial[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" - "\377\2f\231\\\31\200\257\200\20\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\5\377" - "\377\354)\374\374\352J\252\305\230r\316\335\271b\373\373\351G\377\377" - "\360#\377\377\377\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\377\377\377\11\377\377\354D\375\375\337g\375\375\332}\302\325\243" - "\236\334\347\271\222\375\375\332{\374\374\340b\373\373\352=\377\377\377" - "\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\2\210\256zk\347\355" - "\312t\374\374\323\222\374\373\313\257\307\330\243\262\341\351\267\253" - "\374\373\315\254\373\373\326\216\333\346\300r\204\255y]\0\0\0\0\0\0\0" - "\0\24v\0\15\27\200\0\247\30\200\0\270\30~\0\270\26~\0i\0\0\0\0$m\0\7" - "\26\200\0\241\30\200\0\270\30~\0\270\30~\0u\377\377\363\26\355\365\325" - "b\211\266o\335\231\276w\354\236\311\200\335\240\312\205\266\375\375\337" - "p\362\366\315\213\270\316\223\302\257\310\222\242\363\366\334X\377\377" - "\353\15\0\0\0\0\24z\0d\40\231\0\377!\232\0\377\40\226\0\377\30~\0\323" - "\0\0\0\0\24w\0M\37\225\0\375!\232\0\377\40\226\0\377\30\201\0\334\377" - "\377\356-\311\336\256\215\255\324\206\373\223\312q\377q\274T\377R\242" - ";\351\345\360\317E\365\367\331e\353\360\304\230\374\374\321\233\375\375" - "\337g\377\377\357\40\0\0\0\0\27|\0m\35\221\0\377\36\217\0\377\35\212" - "\0\377\26z\0\325\0\0\0\0\25w\0V\34\214\0\377\36\217\0\377\35\213\0\377" - "\27{\0\337\377\377\3545\310\336\253\225\264\326\213\373\216\306m\377" - "_\255E\377.\211\27\347\266\325\252*\374\374\346S\373\373\326\211\374" - "\372\317\243\375\375\336m\377\377\354(\0\0\0\0\25y\0c\34\206\0\377\34" - "\204\0\377\33\177\0\377\26v\0\321\0\0\0\0\24w\0K\33\204\0\374\34\204" - "\0\377\33\200\0\377\26w\0\333\377\377\356-\314\340\260\213\253\317\206" - "\372\203\266e\377l\254R\377P\232:\350\345\360\322D\351\356\316h\307\330" - "\246\244\374\374\321\233\375\375\337g\377\377\357\40\0\0\0\0\34q\0\11" - "\25w\0\235\25v\0\255\25t\0\255\25r\0b\0\0\0\0\0f\0\5\24v\0\227\25v\0" - "\255\25t\0\255\23p\0m\377\377\363\26\276\325\254r\204\260k\334\257\313" - "\211\346\241\306\204\327\234\300\201\266\361\366\326q\373\373\327\207" - "\324\341\254\270\237\275\206\252\313\334\267g\377\377\377\15\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\377\377\377\2\247\304\231Z\375\375\336m\374\374" - "\324\223\374\373\313\260\310\330\243\261\341\351\267\253\374\373\313" - "\255\373\373\324\217\370\372\333i\237\277\217P\0\0\0\0\0\0\0\0\0\0\0" - "\0\26y\0""9\23|\0P\23|\0P\24z\0\31\0\0\0\0\0\0\0\0\24x\0""3\23|\0P\23" - "|\0P\21w\0\36\0\0\0\0\377\377\346\12\262\320\236f\263\323\230\227\305" - "\337\245\247\262\315\226\254\335\347\272\224\375\375\332|\374\374\340" - "c\373\373\357>\377\377\377\5\0\0\0\0\0\0\0\0\25w\0<\34\217\0\365\37\225" - "\0\377\36\222\0\377\30~\0\316\0\0\0\0\23s\0(\33\214\0\360\37\225\0\377" - "\36\222\0\377\30\200\0\330\0\0\0\0\24v\0\32\40\213\5\352E\250(\377`\261" - "E\377_\242I\355\311\332\261h\373\373\352H\377\377\361%\377\377\377\3" - "\0\0\0\0\0\0\0\0\0\0\0\0\25w\0V\35\221\0\377\37\223\0\377\36\217\0\377" - "\30}\0\327\0\0\0\0\21s\0<\34\217\0\377\37\223\0\377\36\217\0\377\30~" - "\0\337\0\0\0\0\21q\0-\34\215\0\364\37\224\0\377!\220\3\377!\203\13\347" - "X\235N\32\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\25w\0" - "V\34\210\0\377\35\210\0\377\34\204\0\377\27y\0\327\0\0\0\0\21s\0<\33" - "\207\0\377\35\210\0\377\34\204\0\377\27x\0\337\0\0\0\0\21q\0-\33\206" - "\0\364\35\211\0\377\34\204\0\377\27y\0\345\21w\0\17\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20s\0\37\27x\0\325\26w\0\337\25u\0\337" - "\25t\0\251\0\0\0\0\15s\0\24\26x\0\322\26w\0\337\25v\0\337\25s\0\266\0" - "\0\0\0\25j\0\14\27w\0\314\26w\0\337\25v\0\337\24t\0\300\0\200\0\2\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\20x\0\40\31\204\0\316\32\210\0\322\32\206\0\322" - "\27\177\0\243\0\0\0\0\15s\0\24\30\204\0\313\32\210\0\322\32\206\0\322" - "\26}\0\257\0\0\0\0\25j\0\14\27\203\0\306\32\210\0\322\32\206\0\322\30" - "\200\0\266\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27" - "|\0m\36\224\0\377\40\227\0\377\37\222\0\377\30\177\0\327\0\0\0\0\24t" - "\0K\35\222\0\377\40\227\0\377\37\223\0\377\30\200\0\337\0\0\0\0\21q\0" - "-\35\220\0\364\40\230\0\377\37\223\0\377\32\201\0\345\21w\0\17\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27|\0m\35\213\0\377\36\214" - "\0\377\35\207\0\377\30z\0\327\0\0\0\0\24t\0K\34\212\0\377\36\214\0\377" - "\35\210\0\377\27z\0\337\0\0\0\0\21q\0-\33\210\0\364\36\215\0\377\35\210" - "\0\377\30|\0\345\21w\0\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\24w\0K\32~\0\367\32\177\0\377\32z\0\377\25u\0\315\0\0\0\0\24u\0" - "2\30}\0\363\32\177\0\377\32{\0\377\24u\0\327\0\0\0\0\22r\0\35\30}\0\352" - "\32\200\0\377\32{\0\377\26u\0\336$m\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\27v\0C\23r\0`\23r\0`\22r\0\35\0\0\0\0\0\0" - "\0\0\25q\0=\23r\0`\23r\0`\16q\0$\0\0\0\0\0\0\0\0\27r\0""8\23r\0`\23r" - "\0`\22w\0+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" + "\377\2f\231\\\31\200\257\200\20\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\5\377" + "\377\354)\374\374\352J\252\305\230r\316\335\271b\373\373\351G\377\377" + "\360#\377\377\377\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\377\377\377\11\377\377\354D\375\375\337g\375\375\332}\302\325\243" + "\236\334\347\271\222\375\375\332{\374\374\340b\373\373\352=\377\377\377" + "\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\2\210\256zk\347\355" + "\312t\374\374\323\222\374\373\313\257\307\330\243\262\341\351\267\253" + "\374\373\315\254\373\373\326\216\333\346\300r\204\255y]\0\0\0\0\0\0\0" + "\0\24v\0\15\27\200\0\247\30\200\0\270\30~\0\270\26~\0i\0\0\0\0$m\0\7" + "\26\200\0\241\30\200\0\270\30~\0\270\30~\0u\377\377\363\26\355\365\325" + "b\211\266o\335\231\276w\354\236\311\200\335\240\312\205\266\375\375\337" + "p\362\366\315\213\270\316\223\302\257\310\222\242\363\366\334X\377\377" + "\353\15\0\0\0\0\24z\0d\40\231\0\377!\232\0\377\40\226\0\377\30~\0\323" + "\0\0\0\0\24w\0M\37\225\0\375!\232\0\377\40\226\0\377\30\201\0\334\377" + "\377\356-\311\336\256\215\255\324\206\373\223\312q\377q\274T\377R\242" + ";\351\345\360\317E\365\367\331e\353\360\304\230\374\374\321\233\375\375" + "\337g\377\377\357\40\0\0\0\0\27|\0m\35\221\0\377\36\217\0\377\35\212" + "\0\377\26z\0\325\0\0\0\0\25w\0V\34\214\0\377\36\217\0\377\35\213\0\377" + "\27{\0\337\377\377\3545\310\336\253\225\264\326\213\373\216\306m\377" + "_\255E\377.\211\27\347\266\325\252*\374\374\346S\373\373\326\211\374" + "\372\317\243\375\375\336m\377\377\354(\0\0\0\0\25y\0c\34\206\0\377\34" + "\204\0\377\33\177\0\377\26v\0\321\0\0\0\0\24w\0K\33\204\0\374\34\204" + "\0\377\33\200\0\377\26w\0\333\377\377\356-\314\340\260\213\253\317\206" + "\372\203\266e\377l\254R\377P\232:\350\345\360\322D\351\356\316h\307\330" + "\246\244\374\374\321\233\375\375\337g\377\377\357\40\0\0\0\0\34q\0\11" + "\25w\0\235\25v\0\255\25t\0\255\25r\0b\0\0\0\0\0f\0\5\24v\0\227\25v\0" + "\255\25t\0\255\23p\0m\377\377\363\26\276\325\254r\204\260k\334\257\313" + "\211\346\241\306\204\327\234\300\201\266\361\366\326q\373\373\327\207" + "\324\341\254\270\237\275\206\252\313\334\267g\377\377\377\15\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\377\377\377\2\247\304\231Z\375\375\336m\374\374" + "\324\223\374\373\313\260\310\330\243\261\341\351\267\253\374\373\313" + "\255\373\373\324\217\370\372\333i\237\277\217P\0\0\0\0\0\0\0\0\0\0\0" + "\0\26y\0""9\23|\0P\23|\0P\24z\0\31\0\0\0\0\0\0\0\0\24x\0""3\23|\0P\23" + "|\0P\21w\0\36\0\0\0\0\377\377\346\12\262\320\236f\263\323\230\227\305" + "\337\245\247\262\315\226\254\335\347\272\224\375\375\332|\374\374\340" + "c\373\373\357>\377\377\377\5\0\0\0\0\0\0\0\0\25w\0<\34\217\0\365\37\225" + "\0\377\36\222\0\377\30~\0\316\0\0\0\0\23s\0(\33\214\0\360\37\225\0\377" + "\36\222\0\377\30\200\0\330\0\0\0\0\24v\0\32\40\213\5\352E\250(\377`\261" + "E\377_\242I\355\311\332\261h\373\373\352H\377\377\361%\377\377\377\3" + "\0\0\0\0\0\0\0\0\0\0\0\0\25w\0V\35\221\0\377\37\223\0\377\36\217\0\377" + "\30}\0\327\0\0\0\0\21s\0<\34\217\0\377\37\223\0\377\36\217\0\377\30~" + "\0\337\0\0\0\0\21q\0-\34\215\0\364\37\224\0\377!\220\3\377!\203\13\347" + "X\235N\32\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\25w\0" + "V\34\210\0\377\35\210\0\377\34\204\0\377\27y\0\327\0\0\0\0\21s\0<\33" + "\207\0\377\35\210\0\377\34\204\0\377\27x\0\337\0\0\0\0\21q\0-\33\206" + "\0\364\35\211\0\377\34\204\0\377\27y\0\345\21w\0\17\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20s\0\37\27x\0\325\26w\0\337\25u\0\337" + "\25t\0\251\0\0\0\0\15s\0\24\26x\0\322\26w\0\337\25v\0\337\25s\0\266\0" + "\0\0\0\25j\0\14\27w\0\314\26w\0\337\25v\0\337\24t\0\300\0\200\0\2\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\20x\0\40\31\204\0\316\32\210\0\322\32\206\0\322" + "\27\177\0\243\0\0\0\0\15s\0\24\30\204\0\313\32\210\0\322\32\206\0\322" + "\26}\0\257\0\0\0\0\25j\0\14\27\203\0\306\32\210\0\322\32\206\0\322\30" + "\200\0\266\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27" + "|\0m\36\224\0\377\40\227\0\377\37\222\0\377\30\177\0\327\0\0\0\0\24t" + "\0K\35\222\0\377\40\227\0\377\37\223\0\377\30\200\0\337\0\0\0\0\21q\0" + "-\35\220\0\364\40\230\0\377\37\223\0\377\32\201\0\345\21w\0\17\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27|\0m\35\213\0\377\36\214" + "\0\377\35\207\0\377\30z\0\327\0\0\0\0\24t\0K\34\212\0\377\36\214\0\377" + "\35\210\0\377\27z\0\337\0\0\0\0\21q\0-\33\210\0\364\36\215\0\377\35\210" + "\0\377\30|\0\345\21w\0\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\24w\0K\32~\0\367\32\177\0\377\32z\0\377\25u\0\315\0\0\0\0\24u\0" + "2\30}\0\363\32\177\0\377\32{\0\377\24u\0\327\0\0\0\0\22r\0\35\30}\0\352" + "\32\200\0\377\32{\0\377\26u\0\336$m\0\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\27v\0C\23r\0`\23r\0`\22r\0\35\0\0\0\0\0\0" + "\0\0\25q\0=\23r\0`\23r\0`\16q\0$\0\0\0\0\0\0\0\0\27r\0""8\23r\0`\23r" + "\0`\22w\0+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -462,104 +466,105 @@ static const guint8 gnome_stock_dial[] = #pragma align 4 (gnome_stock_transfer) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_transfer[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_transfer[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_transfer[] = +static const guint8 gnome_stock_transfer[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\21i\377=\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\21i\377\210\24h\377@\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\21i\377\210\22h\377\232\24i\3773\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\21i\377\210\22i\377\234\23h\377\237\22k\377+\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\21i\377\210\22i\377\234\22h\377\246\21h\377\247\17d\377" - "!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\377\4\27]\377" - "\13\17i\377\21\26o\377\27\22j\377\35\16c\377$\22e\377+\25h\3771\23k\377" - "7\20g\377>\23i\377D\21k\377J\20i\377P\22h\377\216\22i\377\234\22h\377" - "\246\21h\377\261\22h\377\246\27h\377\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<" - "\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22" - "h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22i\377\250" - "\17i\377\21\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22d\377" - "\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22" - "h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" - "\261\22h\377\273\22h\377\306\23h\377\244\34U\377\11\0\0\0\0\0\0\0\0\0" - "\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h" - "\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377" - "\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h" - "\377\321\21h\377\230\0f\377\5\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22" - "d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377" - "g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21" - "h\377\261\22h\377\273\22h\377\306\22h\377\321\21h\377\333\21g\377\224" - "\0\0\377\1\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21" - "f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377" - "\206\22h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h" - "\377\306\22h\377\321\21h\377\333\22h\377\346\22h\377\200\0\0\0\0\0m\377" - "\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377" - "Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377" - "\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h\377\321\21h" - "\377\333\22h\377\346\22h\377\361\23h\377n\0m\377\7\16c\377\22\22d\377" - "\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22" - "h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" - "\261\22h\377\273\22h\377\306\22h\377\321\21h\377\333\22h\377\346\22h" - "\377\361\21h\377v\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21" - "f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377" - "\206\22h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h" - "\377\306\22h\377\321\21h\377\333\22h\377\346\22g\377\212\0\0\0\0\0m\377" - "\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377" - "Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377" - "\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h\377\321\21h" - "\377\333\21g\377\224\0\0\377\1\0\0\0\0\0m\377\7\16c\377\22\22d\377\34" - "\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h" - "\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" - "\261\22h\377\273\22h\377\306\22h\377\321\21h\377\242\0f\377\5\0\0\0\0" - "\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22" - "h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h" - "\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306" - "\23h\377\245\24b\377\15\0\0\0\0\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22" - "d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377" - "g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21" - "h\377\261\22h\377\273\22i\377\252\17i\377\21\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\200\377\4\27]\377\13\17i\377\21\26o\377\27\22j\377\35\16c" - "\377$\22e\377+\25h\3771\23k\3777\20g\377>\23i\377D\21k\377J\20i\377P" - "\22h\377\216\22i\377\234\22h\377\246\21h\377\261\22h\377\254\22d\377" - "\34\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\21i\377\210\22i\377\234\22h\377\246\21h\377\247\17i\377\"" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\21i\377\210\22i\377\234\23h\377\242\21i\377.\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\21i\377\210\22h\377\232\22j\377:\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\21i\377\210\24h\377@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\23i\377D\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\21i\377=\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\21i\377\210\24h\377@\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\21i\377\210\22h\377\232\24i\3773\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\21i\377\210\22i\377\234\23h\377\237\22k\377+\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\21i\377\210\22i\377\234\22h\377\246\21h\377\247\17d\377" + "!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\377\4\27]\377" + "\13\17i\377\21\26o\377\27\22j\377\35\16c\377$\22e\377+\25h\3771\23k\377" + "7\20g\377>\23i\377D\21k\377J\20i\377P\22h\377\216\22i\377\234\22h\377" + "\246\21h\377\261\22h\377\246\27h\377\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<" + "\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22" + "h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22i\377\250" + "\17i\377\21\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22d\377" + "\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22" + "h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" + "\261\22h\377\273\22h\377\306\23h\377\244\34U\377\11\0\0\0\0\0\0\0\0\0" + "\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h" + "\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377" + "\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h" + "\377\321\21h\377\230\0f\377\5\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22" + "d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377" + "g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21" + "h\377\261\22h\377\273\22h\377\306\22h\377\321\21h\377\333\21g\377\224" + "\0\0\377\1\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21" + "f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377" + "\206\22h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h" + "\377\306\22h\377\321\21h\377\333\22h\377\346\22h\377\200\0\0\0\0\0m\377" + "\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377" + "Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377" + "\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h\377\321\21h" + "\377\333\22h\377\346\22h\377\361\23h\377n\0m\377\7\16c\377\22\22d\377" + "\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22" + "h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" + "\261\22h\377\273\22h\377\306\22h\377\321\21h\377\333\22h\377\346\22h" + "\377\361\21h\377v\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21" + "f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377" + "\206\22h\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h" + "\377\306\22h\377\321\21h\377\333\22h\377\346\22g\377\212\0\0\0\0\0m\377" + "\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377" + "Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377" + "\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306\22h\377\321\21h" + "\377\333\21g\377\224\0\0\377\1\0\0\0\0\0m\377\7\16c\377\22\22d\377\34" + "\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377g\22h" + "\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21h\377" + "\261\22h\377\273\22h\377\306\22h\377\321\21h\377\242\0f\377\5\0\0\0\0" + "\0\0\0\0\0m\377\7\16c\377\22\22d\377\34\24i\377'\20h\3771\21f\377<\22" + "h\377G\23h\377Q\21i\377\\\21h\377g\22h\377q\23i\377|\21i\377\206\22h" + "\377\221\22i\377\234\22h\377\246\21h\377\261\22h\377\273\22h\377\306" + "\23h\377\245\24b\377\15\0\0\0\0\0\0\0\0\0\0\0\0\0m\377\7\16c\377\22\22" + "d\377\34\24i\377'\20h\3771\21f\377<\22h\377G\23h\377Q\21i\377\\\21h\377" + "g\22h\377q\23i\377|\21i\377\206\22h\377\221\22i\377\234\22h\377\246\21" + "h\377\261\22h\377\273\22i\377\252\17i\377\21\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\200\377\4\27]\377\13\17i\377\21\26o\377\27\22j\377\35\16c" + "\377$\22e\377+\25h\3771\23k\3777\20g\377>\23i\377D\21k\377J\20i\377P" + "\22h\377\216\22i\377\234\22h\377\246\21h\377\261\22h\377\254\22d\377" + "\34\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\21i\377\210\22i\377\234\22h\377\246\21h\377\247\17i\377\"" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\21i\377\210\22i\377\234\23h\377\242\21i\377.\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\21i\377\210\22h\377\232\22j\377:\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\21i\377\210\24h\377@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\23i\377D\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -568,96 +573,97 @@ static const guint8 gnome_stock_transfer[] = #pragma align 4 (gnome_stock_offhold) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_offhold[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_offhold[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_offhold[] = +static const guint8 gnome_stock_offhold[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0ix\21\0mss\0mr\210\0lt@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "3ff\5\14kqV\14lr\250\0lr}\0mv\34\0\0\0\0\0ht\26\0ls\343\0ls\377\0ls\377" - "\0ls\377\0ms\242\0\200\200\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\34qq\11\33mm/\32kqX\33ms\205\26lq\320\17ou\377\22kp" - "\377\0ls\377\0ls\364\0lq-\0ks\212\0ls\377\0ls\377\0ls\377\0ls\377\0l" - "s\377\0ks\253\0ff\5\0\0\0\0\0\0\0\0\40`p\20\34mm6\35nta\33ms\214\34k" - "p\235\26tz\230\16\202\212\237\5\206\216\324\1\207\217\377\1\205\216\377" - "\21lq\377\0ls\377\0ls\377\0ks\262\0lr\256\0ls\377\0ls\377\0ls\377\0l" - "s\377\0ls\377\3lr\377\11lr\300\32mtn\34ns\222\34lq\234\26y\200\230\15" - "\207\217\240\6\222\233\241\0\233\245\241\0\232\245\241\0\216\226\324" - "\4\201\211\377\10z\200\377\2\203\213\377\21lq\377\0ls\377\0ls\377\0l" - "t\326\0lsv\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lq\377\16sy\377" - "\11\202\212\341\5\226\241\243\0\236\251\241\0\236\250\241\2\232\245\241" - "\6\217\230\241\16\202\212\237\20qy\321\21lq\377\17ls\377\22kp\377\2\201" - "\211\377\21kq\377\0ls\377\0ls\377\0ks\235\0\200\200\6\0ls\377\0ls\377" - "\0ls\377\0ls\377\0ls\377\17ls\377\3\210\220\377\1\212\223\377\6\205\215" - "\342\16\201\211\240\27rw\230\35ko\236\33lt\206\15lq\266\6ls\377\1ls\377" - "\0ls\377\21lq\377\2\177\207\377\21kq\377\0ls\377\0lr\341\0ju\30\0\0\0" - "\0\0pp\20\0ms\312\0ls\377\0ls\377\0ls\377\17ls\377\3\207\216\377\22k" - "p\377\15ms\377\13mr\314\26ot.$mm\7\0lr\223\0ls\377\0ls\377\0ls\377\0" - "ls\377\21lq\377\2~\206\377\21kq\377\0ls\340\0lt!\0\0\0\0\0\0\0\0\0\0" - "\0\0\0fw\17\0ls\307\0ls\377\0ls\377\17ls\377\3\205\216\377\22kp\377\0" - "ls\377\0ls\377\0ls\266\0kr\230\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377" - "\21lq\377\2}\204\377\22kq\362\0pp\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0fw\17\0ks\305\0ls\377\17ls\377\3\204\214\377\22kp\377\0ls\377" - "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\21l" - "q\377\2|\204\362\32ko\247\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0mm\16\0lr\304\17ls\377\3\202\213\377\22kp\377\0ls\377\0" - "ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lp\361" - "\3~\210\254\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0vv\15\21ls\345\3\201\211\377\22kp\377\0ls\377\0ls\377" - "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\332\32lo\247\3\177" - "\210\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\32mr\224\3\201\211\351\22kp\377\0ls\377\0ls\377" - "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0mt\332\0hq\33\34lo\234\3}\205" - "\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\33lq\220\3\201\211\335\22kp\377\0ls\377\0ls\377\0ls" - "\377\0ls\377\0ls\377\0ls\377\0ls\377\0ms\305\0f\200\12\34lo\234\3z\203" - "\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0UU\3\22lr\326\3}\205\377\22kp\377\0ls\377\0ls\377\0ls\377\0" - "ls\377\0ls\377\0ls\377\4ls\377\12lr\377\17mq\337\34ko\245\3x\200\241" - "\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0U" - "U\3\0ks\244\17lr\377\3|\204\377\22kp\377\0ls\377\0ls\377\0ls\377\0ls" - "\377\3ls\377\16lq\377\17lr\377\11rx\377\5sz\377\7rx\351\3w\177\245\35" - "ko\236\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU\3\0ls\246" - "\0ls\377\17kr\377\3{\202\377\22kp\377\0ls\377\0ls\377\0ls\377\2ls\377" - "\20lq\377\10rx\377\0v}\377\0u}\377\0t{\377\0sz\377\3rx\351\34jo\246\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\4\3ls\257\10lr\377\13" - "lr\377\22kp\377\3y\201\377\22kp\377\0ls\377\0ls\377\0ls\324\16lr\333" - "\10ry\377\0v}\377\0t|\377\0t{\377\0sz\377\0ry\377\6nv\377\16kr\337\0" - "fw\17\0\0\0\0\0\0\0\0\0\0\0\0\22mm\16\16lr\315\21lr\377\13qx\377\6v}" - "\377\10u{\377\2y\201\377\22kp\377\0ls\377\0ls\317\0ht\26\35kp\240\1u" - "|\344\0t{\377\0sz\377\0ry\377\0qx\377\4ov\377\20kq\377\3ls\377\0ls\307" - "\0fw\17\0\0\0\0\40\200\200\10\22lr\331\13qy\377\1}\204\377\0|\204\377" - "\0{\202\377\0z\202\377\1x\177\377\22kp\377\0ls\316\0ky\23\0\0\0\0\35" - "kp\217\13sy\242\1t|\343\0qx\377\4pv\377\13mt\377\20kp\377\4kr\377\0l" - "s\377\0ls\377\0ls\377\0\200\200\6\17mr\233\12ry\377\0}\204\377\0{\203" - "\377\0{\202\377\0y\201\377\0y\200\377\4u|\377\17lq\347\0qq\22\0\0\0\0" - "\0\0\0\0\34hq\33\32lp\200\34kp\235\23kp\341\17lq\377\11lr\377\1ks\377" - "\0ls\377\0ls\377\0ls\377\0ls\377\0lt\213\23kr\333\3y\201\377\0{\202\377" - "\0z\201\377\0y\200\377\0x\177\377\3v|\377\21jr\353\23mv6\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0mr\260\0ls\377\0ls" - "\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\322\22lr\313\10s{\377\0y\200" - "\377\0x\200\377\2v}\377\11qw\377\21kq\353\27koL\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0ls\255\0ls\377" - "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\273\14jnA\17lq\370\21kq\377\20k" - "r\377\20lq\377\15kr\335\24bo'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ff\5\0lt\252\0ls\377\0ls\377" - "\0ls\377\0ls\374\0ksE\0\0\0\0\0lq-\2ms\242\1ls\275\0lrt\0tt\13\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0lrU\0mt\267\0lt\254\0js<\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0ix\21\0mss\0mr\210\0lt@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "3ff\5\14kqV\14lr\250\0lr}\0mv\34\0\0\0\0\0ht\26\0ls\343\0ls\377\0ls\377" + "\0ls\377\0ms\242\0\200\200\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\34qq\11\33mm/\32kqX\33ms\205\26lq\320\17ou\377\22kp" + "\377\0ls\377\0ls\364\0lq-\0ks\212\0ls\377\0ls\377\0ls\377\0ls\377\0l" + "s\377\0ks\253\0ff\5\0\0\0\0\0\0\0\0\40`p\20\34mm6\35nta\33ms\214\34k" + "p\235\26tz\230\16\202\212\237\5\206\216\324\1\207\217\377\1\205\216\377" + "\21lq\377\0ls\377\0ls\377\0ks\262\0lr\256\0ls\377\0ls\377\0ls\377\0l" + "s\377\0ls\377\3lr\377\11lr\300\32mtn\34ns\222\34lq\234\26y\200\230\15" + "\207\217\240\6\222\233\241\0\233\245\241\0\232\245\241\0\216\226\324" + "\4\201\211\377\10z\200\377\2\203\213\377\21lq\377\0ls\377\0ls\377\0l" + "t\326\0lsv\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lq\377\16sy\377" + "\11\202\212\341\5\226\241\243\0\236\251\241\0\236\250\241\2\232\245\241" + "\6\217\230\241\16\202\212\237\20qy\321\21lq\377\17ls\377\22kp\377\2\201" + "\211\377\21kq\377\0ls\377\0ls\377\0ks\235\0\200\200\6\0ls\377\0ls\377" + "\0ls\377\0ls\377\0ls\377\17ls\377\3\210\220\377\1\212\223\377\6\205\215" + "\342\16\201\211\240\27rw\230\35ko\236\33lt\206\15lq\266\6ls\377\1ls\377" + "\0ls\377\21lq\377\2\177\207\377\21kq\377\0ls\377\0lr\341\0ju\30\0\0\0" + "\0\0pp\20\0ms\312\0ls\377\0ls\377\0ls\377\17ls\377\3\207\216\377\22k" + "p\377\15ms\377\13mr\314\26ot.$mm\7\0lr\223\0ls\377\0ls\377\0ls\377\0" + "ls\377\21lq\377\2~\206\377\21kq\377\0ls\340\0lt!\0\0\0\0\0\0\0\0\0\0" + "\0\0\0fw\17\0ls\307\0ls\377\0ls\377\17ls\377\3\205\216\377\22kp\377\0" + "ls\377\0ls\377\0ls\266\0kr\230\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377" + "\21lq\377\2}\204\377\22kq\362\0pp\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0fw\17\0ks\305\0ls\377\17ls\377\3\204\214\377\22kp\377\0ls\377" + "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\21l" + "q\377\2|\204\362\32ko\247\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0mm\16\0lr\304\17ls\377\3\202\213\377\22kp\377\0ls\377\0" + "ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lp\361" + "\3~\210\254\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0vv\15\21ls\345\3\201\211\377\22kp\377\0ls\377\0ls\377" + "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\332\32lo\247\3\177" + "\210\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\32mr\224\3\201\211\351\22kp\377\0ls\377\0ls\377" + "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0mt\332\0hq\33\34lo\234\3}\205" + "\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\33lq\220\3\201\211\335\22kp\377\0ls\377\0ls\377\0ls" + "\377\0ls\377\0ls\377\0ls\377\0ls\377\0ms\305\0f\200\12\34lo\234\3z\203" + "\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0UU\3\22lr\326\3}\205\377\22kp\377\0ls\377\0ls\377\0ls\377\0" + "ls\377\0ls\377\0ls\377\4ls\377\12lr\377\17mq\337\34ko\245\3x\200\241" + "\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0U" + "U\3\0ks\244\17lr\377\3|\204\377\22kp\377\0ls\377\0ls\377\0ls\377\0ls" + "\377\3ls\377\16lq\377\17lr\377\11rx\377\5sz\377\7rx\351\3w\177\245\35" + "ko\236\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU\3\0ls\246" + "\0ls\377\17kr\377\3{\202\377\22kp\377\0ls\377\0ls\377\0ls\377\2ls\377" + "\20lq\377\10rx\377\0v}\377\0u}\377\0t{\377\0sz\377\3rx\351\34jo\246\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\4\3ls\257\10lr\377\13" + "lr\377\22kp\377\3y\201\377\22kp\377\0ls\377\0ls\377\0ls\324\16lr\333" + "\10ry\377\0v}\377\0t|\377\0t{\377\0sz\377\0ry\377\6nv\377\16kr\337\0" + "fw\17\0\0\0\0\0\0\0\0\0\0\0\0\22mm\16\16lr\315\21lr\377\13qx\377\6v}" + "\377\10u{\377\2y\201\377\22kp\377\0ls\377\0ls\317\0ht\26\35kp\240\1u" + "|\344\0t{\377\0sz\377\0ry\377\0qx\377\4ov\377\20kq\377\3ls\377\0ls\307" + "\0fw\17\0\0\0\0\40\200\200\10\22lr\331\13qy\377\1}\204\377\0|\204\377" + "\0{\202\377\0z\202\377\1x\177\377\22kp\377\0ls\316\0ky\23\0\0\0\0\35" + "kp\217\13sy\242\1t|\343\0qx\377\4pv\377\13mt\377\20kp\377\4kr\377\0l" + "s\377\0ls\377\0ls\377\0\200\200\6\17mr\233\12ry\377\0}\204\377\0{\203" + "\377\0{\202\377\0y\201\377\0y\200\377\4u|\377\17lq\347\0qq\22\0\0\0\0" + "\0\0\0\0\34hq\33\32lp\200\34kp\235\23kp\341\17lq\377\11lr\377\1ks\377" + "\0ls\377\0ls\377\0ls\377\0ls\377\0lt\213\23kr\333\3y\201\377\0{\202\377" + "\0z\201\377\0y\200\377\0x\177\377\3v|\377\21jr\353\23mv6\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0mr\260\0ls\377\0ls" + "\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\322\22lr\313\10s{\377\0y\200" + "\377\0x\200\377\2v}\377\11qw\377\21kq\353\27koL\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0ls\255\0ls\377" + "\0ls\377\0ls\377\0ls\377\0ls\377\0ls\273\14jnA\17lq\370\21kq\377\20k" + "r\377\20lq\377\15kr\335\24bo'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ff\5\0lt\252\0ls\377\0ls\377" + "\0ls\377\0ls\374\0ksE\0\0\0\0\0lq-\2ms\242\1ls\275\0lrt\0tt\13\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0lrU\0mt\267\0lt\254\0js<\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -666,98 +672,99 @@ static const guint8 gnome_stock_offhold[] = #pragma align 4 (gnome_stock_call_current) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_call_current[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_call_current[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_call_current[] = +static const guint8 gnome_stock_call_current[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0\0" - "/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\12""8\0\205\21c\0\324\22f\0\326\12" - "-\0k\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\2\0\11\0:\20U\0\262\26\205\0\362\23r\0\364\24}\0\364\20e\0" - "\334\3\30\0J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0%\20^\0\316\33\241\0\376\32\241\0\377\30\224\0\377\21g\0\364" - "\23w\0\375\17S\0\277\0\0\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0=\214U*\0\377\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\20\20^\0\301\30\231\0\377\30\231\0\377\27\216\0\377" - "\24z\0\377\21b\0\363\17_\0\335\0\13\0-\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0<\214Ux:\217U0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15L\0\236\27\220\0\377\27\220\0\377\26\211" - "\0\377\23{\0\377\17]\0\356\17_\0\352\3\32\0M\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0""3\231M\12=\215S\\\0\0\0\0<\215Q/<\214Ux\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7+\0j\25\204\0\363\30\224\0\377" - "\26\211\0\377\24|\0\377\20Y\0\362\16M\0\265\0\5\0""2\0\0\0\0\0\0\0\0" - ":\216TF\0\377\0\1\0\0\0\0<\214T\203\0\0\0\0\0\377\0\1<\215S\245\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0""6\22o\0\332" - "\30\227\0\377\26\215\0\377\21h\0\355\12*\0\206\0\0\0\25\0\0\0\0\0\0\0" - "\0\0\0\0\0;\215R8>\213UB\0\0\0\0;\214S\201\0\0\0\0\0\0\0\0=\215T\244" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\20" - "`\0\305\31\233\0\377\27\220\0\377\24~\0\377\16I\0\250\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0<\216Ts\0\0\0\0;\215TyI\222I\7\0\0\0\0;\215T" - "\243\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\13A\0\212\27\214\0\370\30\224\0\377\26\211\0\377\17\\\0\326\0\0\0\26" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0;\215Tt\0\0\0\0;\216Sh;\211X\32\0\0\0" - "\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\11\0""9\22n\0\332\30\227\0\377\26\214\0\377\23s\0\363\12;" - "\0\201\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0;\215Tt\0\0\0\0<\216Ts3\231M\12" - "\0\0\0\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\11\17W\0\270\30\225\0\377\27\220\0\377\25\204\0" - "\377\16[\0\330\0\0\0\24\0\0\0\0\0\0\0\0""9\216U\11<\215Sn\0\0\0\0;\214" - "S\201\0\0\0\0\0\0\0\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\33\0T\24t\0\343\30\224\0\377\26" - "\211\0\377\22s\0\364\13=\0\215\0\0\0\0\0\0\0\0<\214SY>\213U!\0\0\0\0" - ";\216T\205\0\0\0\0""9\216U\11<\214T\236\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\17Z\0\273\27\221" - "\0\377\26\214\0\377\25\202\0\377\20^\0\337\5\35\0""5\0\0\0\0>\213U!\0" - "\0\0\0+\200U\6<\215U{\0\0\0\0=\214SG;\216S_\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\31\0R\22o\0" - "\341\27\220\0\377\25\205\0\377\23w\0\377\15Q\0\304\0\0\0\12\0\0\0\0\0" - "\0\0\0\0\0\0\0@\200@\4\0\0\0\0;\216T\205;\211X\32\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10" - "\15H\0\233\25\202\0\364\26\211\0\377\24~\0\377\21g\0\357\12@\0\224\0" - "\0\0\5\0\0\0\7\3\25\0J\0\0\0\35\0\0\0\0\0\377\0\1\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\40\20]\0\313\26\211\0\377\25\201\0\377\23w\0\377\20_\0" - "\345\11""1\0\210\16U\0\326\23l\0\346\20`\0\315\4\27\0C\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\27\0N\20d\0\334\25\204\0\377\23z\0\377" - "\21o\0\377\20a\0\357\21k\0\375\23g\0\366\24|\0\375\17Z\0\313\0\7\0#\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\11(\0l\21j\0\342\24~\0\377" - "\22s\0\377\20h\0\377\20b\0\377\20f\0\377\21b\0\365\21m\0\370\13:\0\210" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\11\11<\0\210\22i\0" - "\346\23w\0\377\21k\0\377\17a\0\377\17_\0\377\17[\0\373\20d\0\371\16S" - "\0\304\0\0\0\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15\12" - ";\0\206\21f\0\346\21o\0\377\17d\0\377\17_\0\377\17_\0\377\20Z\0\362\17" - "U\0\316\0\0\0\32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\15\12""7\0\202\20`\0\340\20h\0\377\17_\0\377\17\\\0\366\20V\0" - "\363\10,\0y\0\0\0\11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\12\7)\0k\17Z\0\336\16U\0\324\13""9\0\212\0\6\0(\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\4\3\15\0P\0\0\0+\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0\0" + "/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\12""8\0\205\21c\0\324\22f\0\326\12" + "-\0k\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\2\0\11\0:\20U\0\262\26\205\0\362\23r\0\364\24}\0\364\20e\0" + "\334\3\30\0J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0%\20^\0\316\33\241\0\376\32\241\0\377\30\224\0\377\21g\0\364" + "\23w\0\375\17S\0\277\0\0\0\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0=\214U*\0\377\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\20\20^\0\301\30\231\0\377\30\231\0\377\27\216\0\377" + "\24z\0\377\21b\0\363\17_\0\335\0\13\0-\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0<\214Ux:\217U0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15L\0\236\27\220\0\377\27\220\0\377\26\211" + "\0\377\23{\0\377\17]\0\356\17_\0\352\3\32\0M\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0""3\231M\12=\215S\\\0\0\0\0<\215Q/<\214Ux\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7+\0j\25\204\0\363\30\224\0\377" + "\26\211\0\377\24|\0\377\20Y\0\362\16M\0\265\0\5\0""2\0\0\0\0\0\0\0\0" + ":\216TF\0\377\0\1\0\0\0\0<\214T\203\0\0\0\0\0\377\0\1<\215S\245\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0""6\22o\0\332" + "\30\227\0\377\26\215\0\377\21h\0\355\12*\0\206\0\0\0\25\0\0\0\0\0\0\0" + "\0\0\0\0\0;\215R8>\213UB\0\0\0\0;\214S\201\0\0\0\0\0\0\0\0=\215T\244" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\24\20" + "`\0\305\31\233\0\377\27\220\0\377\24~\0\377\16I\0\250\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0<\216Ts\0\0\0\0;\215TyI\222I\7\0\0\0\0;\215T" + "\243\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\13A\0\212\27\214\0\370\30\224\0\377\26\211\0\377\17\\\0\326\0\0\0\26" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0;\215Tt\0\0\0\0;\216Sh;\211X\32\0\0\0" + "\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\11\0""9\22n\0\332\30\227\0\377\26\214\0\377\23s\0\363\12;" + "\0\201\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0;\215Tt\0\0\0\0<\216Ts3\231M\12" + "\0\0\0\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\11\17W\0\270\30\225\0\377\27\220\0\377\25\204\0" + "\377\16[\0\330\0\0\0\24\0\0\0\0\0\0\0\0""9\216U\11<\215Sn\0\0\0\0;\214" + "S\201\0\0\0\0\0\0\0\0=\215T\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\33\0T\24t\0\343\30\224\0\377\26" + "\211\0\377\22s\0\364\13=\0\215\0\0\0\0\0\0\0\0<\214SY>\213U!\0\0\0\0" + ";\216T\205\0\0\0\0""9\216U\11<\214T\236\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\17Z\0\273\27\221" + "\0\377\26\214\0\377\25\202\0\377\20^\0\337\5\35\0""5\0\0\0\0>\213U!\0" + "\0\0\0+\200U\6<\215U{\0\0\0\0=\214SG;\216S_\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\31\0R\22o\0" + "\341\27\220\0\377\25\205\0\377\23w\0\377\15Q\0\304\0\0\0\12\0\0\0\0\0" + "\0\0\0\0\0\0\0@\200@\4\0\0\0\0;\216T\205;\211X\32\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10" + "\15H\0\233\25\202\0\364\26\211\0\377\24~\0\377\21g\0\357\12@\0\224\0" + "\0\0\5\0\0\0\7\3\25\0J\0\0\0\35\0\0\0\0\0\377\0\1\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\40\20]\0\313\26\211\0\377\25\201\0\377\23w\0\377\20_\0" + "\345\11""1\0\210\16U\0\326\23l\0\346\20`\0\315\4\27\0C\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\27\0N\20d\0\334\25\204\0\377\23z\0\377" + "\21o\0\377\20a\0\357\21k\0\375\23g\0\366\24|\0\375\17Z\0\313\0\7\0#\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\11(\0l\21j\0\342\24~\0\377" + "\22s\0\377\20h\0\377\20b\0\377\20f\0\377\21b\0\365\21m\0\370\13:\0\210" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\11\11<\0\210\22i\0" + "\346\23w\0\377\21k\0\377\17a\0\377\17_\0\377\17[\0\373\20d\0\371\16S" + "\0\304\0\0\0\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\15\12" + ";\0\206\21f\0\346\21o\0\377\17d\0\377\17_\0\377\17_\0\377\20Z\0\362\17" + "U\0\316\0\0\0\32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\15\12""7\0\202\20`\0\340\20h\0\377\17_\0\377\17\\\0\366\20V\0" + "\363\10,\0y\0\0\0\11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\12\7)\0k\17Z\0\336\16U\0\324\13""9\0\212\0\6\0(\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\4\3\15\0P\0\0\0+\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -765,134 +772,135 @@ static const guint8 gnome_stock_call_current[] = #pragma align 4 (gnome_stock_addressbook) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_addressbook[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_addressbook[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_addressbook[] = +static const guint8 gnome_stock_addressbook[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0#Q\220n3[\226\3105]\231\3125]\231\3125]\231\312" - "5]\231\3125]\231\3125]\231\3125]\231\3125]\231\3125]\231\3125]\231\312" - "5]\231\3125]\231\3125]\231\3121[\227\306&Q\213X\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\200\200\200\2\227\241\244bGl\237\367\\\202\263\377" - "~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234" - "\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301" - "\377~\234\301\377~\234\301\377r\223\274\3778a\232\332\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\304\304\261\15\307\312\304\312\276\304\310\377Os\246" - "\376\237\263\313\377\334\343\352\377\334\343\352\377\334\343\352\377" - "\334\343\352\377\334\343\352\377\334\343\352\377\334\343\352\377\334" - "\343\352\377\334\343\352\377\334\343\352\377\334\343\352\377\334\343" - "\352\377\333\342\350\377\310\321\332\377=d\234\341\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\331\335\326\301\350\350\345\377f\201\242\264e\211\266" - "\375}\235\304\377\202\241\305\377\202\241\305\377\202\241\305\377\202" - "\241\305\377\202\241\305\377\202\241\305\377\201\240\305\377\201\240" - "\305\377\201\240\305\377\201\240\305\377\201\240\305\377\200\237\304" - "\377\177\236\304\377~\235\303\377Z~\257\374(U\2179\1\0\0\0\0\0\0\0\0" - "\0\0\0\326\330\324\376\326\330\322\373Dj\237\314\221\265\331\377a\215" - "\300\377q\236\316\377r\237\317\377r\237\317\377r\237\317\377r\237\317" - "\377r\237\317\377r\237\317\377r\237\317\377r\237\317\377p\235\315\377" - "o\234\315\377n\233\314\377l\232\313\377k\231\312\377\217\260\326\377" - "7gs\347a\253\32\261Z\251\13D\0\0\0\0\300\303\274\342\323\324\320\377" - "\223\241\255\377\247\257\264\377\257\267\272\377Lv\254\377r\237\317\377" - "r\237\317\377r\237\317\377r\237\317\377r\237\317\377r\237\317\377q\236" - "\316\377o\234\315\377n\233\314\377m\232\313\377k\231\312\377j\230\311" - "\377i\227\311\377\216\260\326\377Gw\200\377\257\347w\377q\267.\306\0" - "\0\0\0\310\313\305\257\275\277\271\377\305\306\303\377\274\276\274\377" - "|\216\237\377_\213\276\377r\237\317\377r\237\317\377r\237\317\377r\237" - "\317\377q\236\316\377p\235\315\377o\234\314\377m\232\313\377l\231\313" - "\377k\230\312\377j\227\311\377h\226\310\377g\225\307\377\213\255\324" - "\377Aut\377\232\342S\377v\2744\306\0\0\0\0\333\335\327\376\333\335\331" - "\374Hm\240\313\216\262\331\377n\233\314\377r\237\317\377r\237\317\377" - "r\237\317\377r\237\317\377\206\254\325\377\304\326\352\377\350\357\367" - "\377\362\366\372\377\344\354\365\377\273\320\346\377x\241\316\377g\225" - "\307\377f\224\307\377e\223\306\377\210\253\323\377Buv\377\237\343\\\377" - "t\2721\305\0\0\0\0\304\306\300\360\320\321\315\377\202\225\251\376\226" - "\247\262\377\230\245\262\377R~\262\377r\237\317\377q\236\316\377\250" - "\303\341\377\373\374\376\377\322\340\357\377\242\276\335\377\221\263" - "\327\377\237\274\334\377\324\341\357\377\367\371\374\377\217\260\325" - "\377d\222\305\377c\221\304\377\206\251\321\377Cux\377\242\343a\377r\271" - "-\305\0\0\0\0\274\277\271\234\276\301\273\377\313\314\310\377\307\310" - "\305\377\231\242\251\377W\203\267\377p\235\315\377\225\266\332\377\372" - "\373\375\377\227\270\332\377k\230\312\377o\232\313\377o\233\312\377g" - "\225\307\377f\223\306\377\244\277\335\377\370\372\374\377p\232\311\377" - "a\217\303\377\202\247\317\377Dlu\376\241\306A\376{\253\26\305\0\0\0\0" - "\337\342\334\375\337\340\333\375Xt\234\331\214\254\315\377p\235\316\377" - "o\234\315\377n\233\314\377\343\354\365\377\264\313\344\377j\227\311\377" - "\251\303\340\377\374\375\376\377\374\375\376\377\332\345\361\377\366" - "\371\374\377b\220\304\377\323\340\356\377\265\312\343\377_\215\301\377" - "\200\245\316\377Sn~\377\352\332l\377\347\322[\366\312\244\10C\311\314" - "\305\365\320\321\314\376r\213\247\372\214\241\267\377y\220\250\377W\202" - "\266\377}\245\320\377\377\377\377\377v\240\316\377z\241\316\377\375\375" - "\376\377\260\310\342\377s\234\312\377\340\351\363\377\366\370\373\377" - "`\216\303\377\246\300\335\377\323\337\356\377\\\213\300\377}\242\314" - "\377Tpw\377\364\342S\377\363\342o\377\311\246\10d\262\264\255\234\306" - "\310\302\377\314\315\311\377\314\315\311\377\257\263\263\377Mx\256\377" - "\214\257\325\377\367\372\374\377g\225\307\377\222\263\327\377\377\377" - "\377\377x\240\315\377b\220\304\377\260\307\341\377\366\370\373\377^\214" - "\301\377\245\277\334\377\317\335\354\377Z\211\277\377{\240\313\377To" - "z\377\364\345d\377\363\342r\377\311\246\10d\337\341\335\371\333\334\327" - "\376h}\231\352\207\242\275\377d\217\300\377i\226\310\377\201\246\321" - "\377\375\376\376\377j\227\310\377\203\250\321\377\377\377\377\377\217" - "\260\324\377`\216\302\377\310\330\352\377\365\370\373\377b\220\302\377" - "\337\350\363\377\246\277\334\377X\207\275\377w\235\311\377To{\377\364" - "\346q\377\362\342q\377\311\246\10d\316\320\312\371\316\321\313\376[z" - "\241\356\200\236\276\377]}\246\377Y\205\272\377f\224\306\377\361\365" - "\372\377\231\267\330\377b\220\303\377\321\337\356\377\366\371\374\377" - "\335\347\362\377\363\367\373\377\374\375\376\377\356\363\370\377\317" - "\335\354\377_\213\300\377V\205\274\377u\233\310\377Tp\200\377\365\350" - "|\377\360\336j\375\311\245\6U\263\266\256\261\314\316\311\377\313\314" - "\311\377\316\320\314\377\272\274\270\377Cm\245\377c\221\305\377\250\301" - "\336\377\356\363\371\377r\233\311\377a\217\302\377\220\257\324\377\221" - "\260\324\377{\241\314\377\230\265\327\377{\240\313\377W\205\274\377U" - "\204\273\377T\203\272\377r\231\306\377Xez\375\343\235N\367\347\240R\364" - "\333z\36\254\336\341\334\362\320\323\316\377z\213\235\366\206\233\260" - "\377[\201\254\377`\216\303\377a\217\303\377a\217\302\377\311\331\352" - "\377\360\364\371\377\233\270\330\377i\223\305\377^\213\300\377w\235\311" - "\377\271\315\343\377\305\325\350\377U\204\273\377S\202\272\377R\201\271" - "\377p\226\305\377_jw\377\371\260C\377\374\272Y\377\345\224E\326\320\322" - "\315\372\317\320\313\374Jn\235\340t\232\306\377Jr\243\377Z\207\274\377" - "_\215\302\377^\214\301\377^\213\300\377\235\271\331\377\347\356\366\377" - "\377\377\377\377\377\377\377\377\375\376\376\377\324\340\356\377~\242" - "\313\377S\202\271\377Q\200\270\377P\177\267\377l\223\302\377^iv\377\371" - "\261G\377\374\267S\377\344\221@\326\267\273\263\306\322\323\317\377\275" - "\300\277\377\306\310\304\377\300\300\275\377\77j\241\377]\213\300\377" - "\\\212\277\377Z\211\277\377Y\210\276\377X\207\275\377g\220\302\377p\227" - "\306\377_\213\276\377S\202\271\377R\201\270\377P\177\267\377O~\267\377" - "N}\266\377j\221\301\377^jy\377\372\271Y\377\374\273\\\377\343\216=\325" - "\333\335\331\336\306\307\304\377\231\243\251\375\226\243\256\377Zz\236" - "\377[\211\275\377`\216\302\377_\215\302\377_\214\301\377]\213\300\377" - "\\\212\277\377[\212\277\377Z\210\276\377Y\207\276\377X\206\275\377W\206" - "\274\377V\205\273\377U\203\272\377T\202\272\377m\225\304\377^l}\377\372" - "\276g\377\374\300f\377\342\2147\324\323\326\321\375\322\324\317\373=" - "g\235\303w\237\314\377N{\261\377a\220\303\377d\222\305\377c\221\305\377" - "b\221\304\377b\220\304\377a\217\303\377a\217\303\377_\216\302\377_\215" - "\302\377^\215\301\377]\214\301\377]\214\301\377\\\212\300\377[\212\277" - "\377s\233\311\377P]u\361\341\2105\314\342\2101\314\331r\23\206\273\275" - "\270\326\323\325\321\377\247\260\265\374\266\272\270\377\272\276\274" - "\377Fp\247\377i\227\311\377i\226\311\377h\226\311\377h\225\310\377h\225" - "\310\377g\225\310\377g\224\310\377f\224\307\377f\223\307\377e\223\307" - "\377e\223\306\377e\222\306\377d\222\306\377z\241\316\377%O\210\273\0" - "\0\0\3\0\0\0\0\0\0\0\0\221\230\221%\251\254\246\343\266\270\270\377\255" - "\263\264\377l\203\234\377c\221\303\377q\236\317\377q\236\317\377q\236" - "\316\377q\236\316\377q\236\316\377p\236\316\377p\236\316\377p\236\316" - "\377p\235\316\377p\235\316\377p\235\316\377p\235\316\377o\235\316\377" - "\177\247\322\377\"H\177\273\0\0\0\36\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\34" - "\30""0R`Qy\253\351e\214\273\364e\214\272\364e\213\272\364e\213\272\364" - "e\213\272\364d\213\272\364d\213\272\364c\212\271\364c\212\271\364b\212" - "\271\364b\212\271\364a\211\271\364a\211\270\364a\210\270\364`\210\270" - "\364Fo\242\344\21\37;J\0\0\0\32\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0#Q\220n3[\226\3105]\231\3125]\231\3125]\231\312" + "5]\231\3125]\231\3125]\231\3125]\231\3125]\231\3125]\231\3125]\231\312" + "5]\231\3125]\231\3125]\231\3121[\227\306&Q\213X\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\200\200\200\2\227\241\244bGl\237\367\\\202\263\377" + "~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234" + "\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301\377~\234\301" + "\377~\234\301\377~\234\301\377r\223\274\3778a\232\332\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\304\304\261\15\307\312\304\312\276\304\310\377Os\246" + "\376\237\263\313\377\334\343\352\377\334\343\352\377\334\343\352\377" + "\334\343\352\377\334\343\352\377\334\343\352\377\334\343\352\377\334" + "\343\352\377\334\343\352\377\334\343\352\377\334\343\352\377\334\343" + "\352\377\333\342\350\377\310\321\332\377=d\234\341\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\331\335\326\301\350\350\345\377f\201\242\264e\211\266" + "\375}\235\304\377\202\241\305\377\202\241\305\377\202\241\305\377\202" + "\241\305\377\202\241\305\377\202\241\305\377\201\240\305\377\201\240" + "\305\377\201\240\305\377\201\240\305\377\201\240\305\377\200\237\304" + "\377\177\236\304\377~\235\303\377Z~\257\374(U\2179\1\0\0\0\0\0\0\0\0" + "\0\0\0\326\330\324\376\326\330\322\373Dj\237\314\221\265\331\377a\215" + "\300\377q\236\316\377r\237\317\377r\237\317\377r\237\317\377r\237\317" + "\377r\237\317\377r\237\317\377r\237\317\377r\237\317\377p\235\315\377" + "o\234\315\377n\233\314\377l\232\313\377k\231\312\377\217\260\326\377" + "7gs\347a\253\32\261Z\251\13D\0\0\0\0\300\303\274\342\323\324\320\377" + "\223\241\255\377\247\257\264\377\257\267\272\377Lv\254\377r\237\317\377" + "r\237\317\377r\237\317\377r\237\317\377r\237\317\377r\237\317\377q\236" + "\316\377o\234\315\377n\233\314\377m\232\313\377k\231\312\377j\230\311" + "\377i\227\311\377\216\260\326\377Gw\200\377\257\347w\377q\267.\306\0" + "\0\0\0\310\313\305\257\275\277\271\377\305\306\303\377\274\276\274\377" + "|\216\237\377_\213\276\377r\237\317\377r\237\317\377r\237\317\377r\237" + "\317\377q\236\316\377p\235\315\377o\234\314\377m\232\313\377l\231\313" + "\377k\230\312\377j\227\311\377h\226\310\377g\225\307\377\213\255\324" + "\377Aut\377\232\342S\377v\2744\306\0\0\0\0\333\335\327\376\333\335\331" + "\374Hm\240\313\216\262\331\377n\233\314\377r\237\317\377r\237\317\377" + "r\237\317\377r\237\317\377\206\254\325\377\304\326\352\377\350\357\367" + "\377\362\366\372\377\344\354\365\377\273\320\346\377x\241\316\377g\225" + "\307\377f\224\307\377e\223\306\377\210\253\323\377Buv\377\237\343\\\377" + "t\2721\305\0\0\0\0\304\306\300\360\320\321\315\377\202\225\251\376\226" + "\247\262\377\230\245\262\377R~\262\377r\237\317\377q\236\316\377\250" + "\303\341\377\373\374\376\377\322\340\357\377\242\276\335\377\221\263" + "\327\377\237\274\334\377\324\341\357\377\367\371\374\377\217\260\325" + "\377d\222\305\377c\221\304\377\206\251\321\377Cux\377\242\343a\377r\271" + "-\305\0\0\0\0\274\277\271\234\276\301\273\377\313\314\310\377\307\310" + "\305\377\231\242\251\377W\203\267\377p\235\315\377\225\266\332\377\372" + "\373\375\377\227\270\332\377k\230\312\377o\232\313\377o\233\312\377g" + "\225\307\377f\223\306\377\244\277\335\377\370\372\374\377p\232\311\377" + "a\217\303\377\202\247\317\377Dlu\376\241\306A\376{\253\26\305\0\0\0\0" + "\337\342\334\375\337\340\333\375Xt\234\331\214\254\315\377p\235\316\377" + "o\234\315\377n\233\314\377\343\354\365\377\264\313\344\377j\227\311\377" + "\251\303\340\377\374\375\376\377\374\375\376\377\332\345\361\377\366" + "\371\374\377b\220\304\377\323\340\356\377\265\312\343\377_\215\301\377" + "\200\245\316\377Sn~\377\352\332l\377\347\322[\366\312\244\10C\311\314" + "\305\365\320\321\314\376r\213\247\372\214\241\267\377y\220\250\377W\202" + "\266\377}\245\320\377\377\377\377\377v\240\316\377z\241\316\377\375\375" + "\376\377\260\310\342\377s\234\312\377\340\351\363\377\366\370\373\377" + "`\216\303\377\246\300\335\377\323\337\356\377\\\213\300\377}\242\314" + "\377Tpw\377\364\342S\377\363\342o\377\311\246\10d\262\264\255\234\306" + "\310\302\377\314\315\311\377\314\315\311\377\257\263\263\377Mx\256\377" + "\214\257\325\377\367\372\374\377g\225\307\377\222\263\327\377\377\377" + "\377\377x\240\315\377b\220\304\377\260\307\341\377\366\370\373\377^\214" + "\301\377\245\277\334\377\317\335\354\377Z\211\277\377{\240\313\377To" + "z\377\364\345d\377\363\342r\377\311\246\10d\337\341\335\371\333\334\327" + "\376h}\231\352\207\242\275\377d\217\300\377i\226\310\377\201\246\321" + "\377\375\376\376\377j\227\310\377\203\250\321\377\377\377\377\377\217" + "\260\324\377`\216\302\377\310\330\352\377\365\370\373\377b\220\302\377" + "\337\350\363\377\246\277\334\377X\207\275\377w\235\311\377To{\377\364" + "\346q\377\362\342q\377\311\246\10d\316\320\312\371\316\321\313\376[z" + "\241\356\200\236\276\377]}\246\377Y\205\272\377f\224\306\377\361\365" + "\372\377\231\267\330\377b\220\303\377\321\337\356\377\366\371\374\377" + "\335\347\362\377\363\367\373\377\374\375\376\377\356\363\370\377\317" + "\335\354\377_\213\300\377V\205\274\377u\233\310\377Tp\200\377\365\350" + "|\377\360\336j\375\311\245\6U\263\266\256\261\314\316\311\377\313\314" + "\311\377\316\320\314\377\272\274\270\377Cm\245\377c\221\305\377\250\301" + "\336\377\356\363\371\377r\233\311\377a\217\302\377\220\257\324\377\221" + "\260\324\377{\241\314\377\230\265\327\377{\240\313\377W\205\274\377U" + "\204\273\377T\203\272\377r\231\306\377Xez\375\343\235N\367\347\240R\364" + "\333z\36\254\336\341\334\362\320\323\316\377z\213\235\366\206\233\260" + "\377[\201\254\377`\216\303\377a\217\303\377a\217\302\377\311\331\352" + "\377\360\364\371\377\233\270\330\377i\223\305\377^\213\300\377w\235\311" + "\377\271\315\343\377\305\325\350\377U\204\273\377S\202\272\377R\201\271" + "\377p\226\305\377_jw\377\371\260C\377\374\272Y\377\345\224E\326\320\322" + "\315\372\317\320\313\374Jn\235\340t\232\306\377Jr\243\377Z\207\274\377" + "_\215\302\377^\214\301\377^\213\300\377\235\271\331\377\347\356\366\377" + "\377\377\377\377\377\377\377\377\375\376\376\377\324\340\356\377~\242" + "\313\377S\202\271\377Q\200\270\377P\177\267\377l\223\302\377^iv\377\371" + "\261G\377\374\267S\377\344\221@\326\267\273\263\306\322\323\317\377\275" + "\300\277\377\306\310\304\377\300\300\275\377\77j\241\377]\213\300\377" + "\\\212\277\377Z\211\277\377Y\210\276\377X\207\275\377g\220\302\377p\227" + "\306\377_\213\276\377S\202\271\377R\201\270\377P\177\267\377O~\267\377" + "N}\266\377j\221\301\377^jy\377\372\271Y\377\374\273\\\377\343\216=\325" + "\333\335\331\336\306\307\304\377\231\243\251\375\226\243\256\377Zz\236" + "\377[\211\275\377`\216\302\377_\215\302\377_\214\301\377]\213\300\377" + "\\\212\277\377[\212\277\377Z\210\276\377Y\207\276\377X\206\275\377W\206" + "\274\377V\205\273\377U\203\272\377T\202\272\377m\225\304\377^l}\377\372" + "\276g\377\374\300f\377\342\2147\324\323\326\321\375\322\324\317\373=" + "g\235\303w\237\314\377N{\261\377a\220\303\377d\222\305\377c\221\305\377" + "b\221\304\377b\220\304\377a\217\303\377a\217\303\377_\216\302\377_\215" + "\302\377^\215\301\377]\214\301\377]\214\301\377\\\212\300\377[\212\277" + "\377s\233\311\377P]u\361\341\2105\314\342\2101\314\331r\23\206\273\275" + "\270\326\323\325\321\377\247\260\265\374\266\272\270\377\272\276\274" + "\377Fp\247\377i\227\311\377i\226\311\377h\226\311\377h\225\310\377h\225" + "\310\377g\225\310\377g\224\310\377f\224\307\377f\223\307\377e\223\307" + "\377e\223\306\377e\222\306\377d\222\306\377z\241\316\377%O\210\273\0" + "\0\0\3\0\0\0\0\0\0\0\0\221\230\221%\251\254\246\343\266\270\270\377\255" + "\263\264\377l\203\234\377c\221\303\377q\236\317\377q\236\317\377q\236" + "\316\377q\236\316\377q\236\316\377p\236\316\377p\236\316\377p\236\316" + "\377p\235\316\377p\235\316\377p\235\316\377p\235\316\377o\235\316\377" + "\177\247\322\377\"H\177\273\0\0\0\36\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\34" + "\30""0R`Qy\253\351e\214\273\364e\214\272\364e\213\272\364e\213\272\364" + "e\213\272\364d\213\272\364d\213\272\364c\212\271\364c\212\271\364b\212" + "\271\364b\212\271\364a\211\271\364a\211\270\364a\210\270\364`\210\270" + "\364Fo\242\344\21\37;J\0\0\0\32\0\0\0\0\0\0\0\0" + }; /* GdkPixbuf RGBA C-Source image dump */ @@ -900,109 +908,110 @@ static const guint8 gnome_stock_addressbook[] = #pragma align 4 (gnome_stock_calls) #endif #ifdef __GNUC__ -static const guint8 gnome_stock_calls[] __attribute__ ((__aligned__ (4))) = +static const guint8 gnome_stock_calls[] __attribute__ ( (__aligned__ (4))) = #else -static const guint8 gnome_stock_calls[] = +static const guint8 gnome_stock_calls[] = #endif -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (2304) */ - "\0\0\11\30" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (96) */ - "\0\0\0`" - /* width (24) */ - "\0\0\0\30" - /* height (24) */ - "\0\0\0\30" - /* pixel_data: */ - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34\0\0\0\2\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\22\11.\0p\20^\0\311\12\77\0\202\0\0\0\13\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34q\34\11\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3" - "\4\14\0>\15Z\0\275\23p\0\365\24w\0\361\24v\0\353\11<\0\210\0\0\0\4\0" - "\0\0\0\0\0\0\0\0\0\0\0\377\377\377\3\377\377\370#\377\377\370H\224\267" - "\207\206\377\377\366U\377\377\3655\377\377\355\16\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\31\0e\22s\0\344\32\241\0\376\31\234\0" - "\377\24y\0\367\22p\0\364\21c\0\335\4\21\0;\0\0\0\0\0\0\0\0\377\377\346" - "\12\377\377\365P\377\377\360{\375\375\360\225\261\312\242\272\375\375" - "\357\234\375\375\360\211\377\377\365h\377\377\370&\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\5\36\0]\24}\0\352\31\234\0\377\31\227\0\377\26" - "\210\0\377\21c\0\363\22o\0\375\14E\0\233\0\0\0\0t\242t\13\275\323\263" - "h\375\375\360\212\376\376\353\267\376\376\350\326\301\325\254\352\376" - "\376\347\340\376\376\352\307\375\375\355\240\360\364\345t\206\260}7\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""8\21o\0\333\30\225\0\377\27\221" - "\0\377\24\203\0\377\22i\0\375\20d\0\364\15Q\0\300\0\0\0\2\377\377\370" - "&\277\324\261\223\262\313\243\313\357\365\331\335\376\376\354\262\346" - "\356\330\244\375\375\354\245\374\374\351\306\314\335\272\331\256\311" - "\240\263\344\354\327_\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0!\20" - "g\0\313\31\230\0\377\27\216\0\377\25\203\0\377\22o\0\377\17W\0\365\13" - "A\0\244\0\0\0\4\377\377\365N\375\375\360\227\372\373\343\332\315\335" - "\276\275\377\377\362z\377\377\366Y\377\377\365f\336\347\321\240\346\356" - "\322\326\376\376\353\264\377\377\362r\377\377\377\22\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\5\16U\0\261\30\226\0\377\27\221\0\377\25\205\0\377\17" - "Y\0\347\7(\0r\0\0\0\26\377\377\377\1\377\377\364_\375\375\354\243\376" - "\376\347\337\375\375\356\232\377\377\366V\377\377\377\30\377\377\372" - "8\377\377\360{\376\376\352\300\376\376\352\303\377\377\361}\377\377\366" - "\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7-\0l\25\203\0\361\30\225\0\377\26" - "\212\0\377\21^\0\330\0\0\0!\0\0\0\0\377\377\377\1\377\377\364[\375\375" - "\355\240\376\376\350\344\347\356\326\250\377\377\364a\377\377\3724\377" - "\377\370I\351\360\335\211\367\372\345\306\376\376\352\276\377\377\362" - "z\377\377\377\31\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0""3\23m\0\330\31" - "\230\0\377\27\216\0\377\22q\0\361\7""1\0n\0\0\0\0\0\0\0\0\377\377\367" - "=\347\356\333\223\270\320\246\331\321\340\277\314\375\375\357\222\377" - "\377\362x\375\375\361\202\356\363\335\257\276\323\253\351\311\333\272" - "\270\377\377\363i\377\377\377\12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\11\17W\0\265\30\226\0\377\27\221\0\377\25\204\0\377\17V\0\314\0\0" - "\0\11\0\0\0\0\272\316\261\32\246\303\234\215\371\372\350\245\376\376" - "\350\324\376\376\351\315\270\317\247\316\376\376\352\303\376\376\347" - "\340\376\376\353\273\324\342\306\224\236\277\224_\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\36\0\\\25{\0\351\30\225\0\377\26\212\0" - "\377\21k\0\354\10/\0b\0\0\0\0\0\0\0\0\377\377\364.\377\377\362s\375\375" - "\357\234\376\376\352\271\273\320\251\325\376\376\352\301\376\376\355" - "\253\375\375\360\207\377\377\366U\377\377\377\7\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32\20a\0\313\30\226\0\377\27\215\0\377" - "\24\202\0\377\17V\0\317\0\0\0\13\0\0\0\0\0\0\0\0\377\377\370#\377\377" - "\364^\377\377\362w\245\302\231\242\377\377\361}\377\377\363k\377\377" - "\367@\377\377\377\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\7,\0m\25|\0\354\27\221\0\377\25\206\0\377\21l\0\360\13" - "=\0\206\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\4\377\377\363\26\230\274" - "\2179\377\377\366\35\377\377\377\13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\31\20_\0\312\30" - "\221\0\377\26\212\0\377\24\177\0\377\17\\\0\336\5\31\0""3\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\40" - "\0Y\22n\0\341\27\215\0\377\25\203\0\377\23s\0\376\15P\0\305\0\0\0\21" - "\0\0\0\0\0\0\0\7\0\0\0\31\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\10\15G\0\232\24\177\0\363\25\206\0\377\23{\0\377\22i\0\364\15" - "H\0\256\7\25\0I\16U\0\267\21b\0\323\12""1\0i\0\0\0\3\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\40\17[\0\310\26\204\0\376\24\177\0\377\22" - "t\0\377\17`\0\357\20`\0\352\23m\0\367\26\202\0\364\22k\0\337\6#\0X\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\0>\20`\0\324\25\177\0" - "\377\23w\0\377\21m\0\377\21j\0\377\24w\0\377\23t\0\370\24\201\0\374\17" - "]\0\311\0\0\0\27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\35\0Y" - "\20c\0\334\22z\0\377\22p\0\377\20e\0\377\21j\0\377\24y\0\377\21g\0\364" - "\22l\0\347\6\34\0R\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\3\5$\0b\20`\0\334\22s\0\377\20i\0\377\17_\0\377\22l\0\377\22i\0\363" - "\22q\0\377\12;\0z\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\3\5\40\0a\17^\0\331\21j\0\377\17b\0\377\17_\0\377\22b\0\365\17" - "Z\0\336\3\30\0V\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\3\3\26\0R\17X\0\320\20_\0\366\16W\0\327\13C\0\235\0\6\0" - "+\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\11\0<\13""5\0\213\0\5\0""0\0\0\0\2\0\0\0\0\0\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; + { "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (2304) */ + "\0\0\11\30" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" + /* rowstride (96) */ + "\0\0\0`" + /* width (24) */ + "\0\0\0\30" + /* height (24) */ + "\0\0\0\30" + /* pixel_data: */ + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34\0\0\0\2\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\22\11.\0p\20^\0\311\12\77\0\202\0\0\0\13\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34q\34\11\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3" + "\4\14\0>\15Z\0\275\23p\0\365\24w\0\361\24v\0\353\11<\0\210\0\0\0\4\0" + "\0\0\0\0\0\0\0\0\0\0\0\377\377\377\3\377\377\370#\377\377\370H\224\267" + "\207\206\377\377\366U\377\377\3655\377\377\355\16\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\31\0e\22s\0\344\32\241\0\376\31\234\0" + "\377\24y\0\367\22p\0\364\21c\0\335\4\21\0;\0\0\0\0\0\0\0\0\377\377\346" + "\12\377\377\365P\377\377\360{\375\375\360\225\261\312\242\272\375\375" + "\357\234\375\375\360\211\377\377\365h\377\377\370&\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\5\36\0]\24}\0\352\31\234\0\377\31\227\0\377\26" + "\210\0\377\21c\0\363\22o\0\375\14E\0\233\0\0\0\0t\242t\13\275\323\263" + "h\375\375\360\212\376\376\353\267\376\376\350\326\301\325\254\352\376" + "\376\347\340\376\376\352\307\375\375\355\240\360\364\345t\206\260}7\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""8\21o\0\333\30\225\0\377\27\221" + "\0\377\24\203\0\377\22i\0\375\20d\0\364\15Q\0\300\0\0\0\2\377\377\370" + "&\277\324\261\223\262\313\243\313\357\365\331\335\376\376\354\262\346" + "\356\330\244\375\375\354\245\374\374\351\306\314\335\272\331\256\311" + "\240\263\344\354\327_\377\377\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0!\20" + "g\0\313\31\230\0\377\27\216\0\377\25\203\0\377\22o\0\377\17W\0\365\13" + "A\0\244\0\0\0\4\377\377\365N\375\375\360\227\372\373\343\332\315\335" + "\276\275\377\377\362z\377\377\366Y\377\377\365f\336\347\321\240\346\356" + "\322\326\376\376\353\264\377\377\362r\377\377\377\22\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\5\16U\0\261\30\226\0\377\27\221\0\377\25\205\0\377\17" + "Y\0\347\7(\0r\0\0\0\26\377\377\377\1\377\377\364_\375\375\354\243\376" + "\376\347\337\375\375\356\232\377\377\366V\377\377\377\30\377\377\372" + "8\377\377\360{\376\376\352\300\376\376\352\303\377\377\361}\377\377\366" + "\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7-\0l\25\203\0\361\30\225\0\377\26" + "\212\0\377\21^\0\330\0\0\0!\0\0\0\0\377\377\377\1\377\377\364[\375\375" + "\355\240\376\376\350\344\347\356\326\250\377\377\364a\377\377\3724\377" + "\377\370I\351\360\335\211\367\372\345\306\376\376\352\276\377\377\362" + "z\377\377\377\31\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5\0""3\23m\0\330\31" + "\230\0\377\27\216\0\377\22q\0\361\7""1\0n\0\0\0\0\0\0\0\0\377\377\367" + "=\347\356\333\223\270\320\246\331\321\340\277\314\375\375\357\222\377" + "\377\362x\375\375\361\202\356\363\335\257\276\323\253\351\311\333\272" + "\270\377\377\363i\377\377\377\12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\11\17W\0\265\30\226\0\377\27\221\0\377\25\204\0\377\17V\0\314\0\0" + "\0\11\0\0\0\0\272\316\261\32\246\303\234\215\371\372\350\245\376\376" + "\350\324\376\376\351\315\270\317\247\316\376\376\352\303\376\376\347" + "\340\376\376\353\273\324\342\306\224\236\277\224_\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\36\0\\\25{\0\351\30\225\0\377\26\212\0" + "\377\21k\0\354\10/\0b\0\0\0\0\0\0\0\0\377\377\364.\377\377\362s\375\375" + "\357\234\376\376\352\271\273\320\251\325\376\376\352\301\376\376\355" + "\253\375\375\360\207\377\377\366U\377\377\377\7\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32\20a\0\313\30\226\0\377\27\215\0\377" + "\24\202\0\377\17V\0\317\0\0\0\13\0\0\0\0\0\0\0\0\377\377\370#\377\377" + "\364^\377\377\362w\245\302\231\242\377\377\361}\377\377\363k\377\377" + "\367@\377\377\377\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\7,\0m\25|\0\354\27\221\0\377\25\206\0\377\21l\0\360\13" + "=\0\206\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\4\377\377\363\26\230\274" + "\2179\377\377\366\35\377\377\377\13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\31\20_\0\312\30" + "\221\0\377\26\212\0\377\24\177\0\377\17\\\0\336\5\31\0""3\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\40" + "\0Y\22n\0\341\27\215\0\377\25\203\0\377\23s\0\376\15P\0\305\0\0\0\21" + "\0\0\0\0\0\0\0\7\0\0\0\31\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\10\15G\0\232\24\177\0\363\25\206\0\377\23{\0\377\22i\0\364\15" + "H\0\256\7\25\0I\16U\0\267\21b\0\323\12""1\0i\0\0\0\3\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\40\17[\0\310\26\204\0\376\24\177\0\377\22" + "t\0\377\17`\0\357\20`\0\352\23m\0\367\26\202\0\364\22k\0\337\6#\0X\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\0>\20`\0\324\25\177\0" + "\377\23w\0\377\21m\0\377\21j\0\377\24w\0\377\23t\0\370\24\201\0\374\17" + "]\0\311\0\0\0\27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\35\0Y" + "\20c\0\334\22z\0\377\22p\0\377\20e\0\377\21j\0\377\24y\0\377\21g\0\364" + "\22l\0\347\6\34\0R\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\3\5$\0b\20`\0\334\22s\0\377\20i\0\377\17_\0\377\22l\0\377\22i\0\363" + "\22q\0\377\12;\0z\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\3\5\40\0a\17^\0\331\21j\0\377\17b\0\377\17_\0\377\22b\0\365\17" + "Z\0\336\3\30\0V\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\3\3\26\0R\17X\0\320\20_\0\366\16W\0\327\13C\0\235\0\6\0" + "+\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\11\0<\13""5\0\213\0\5\0""0\0\0\0\2\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + }; G_END_DECLS diff --git a/sflphone-client-gnome/src/logger.c b/sflphone-client-gnome/src/logger.c index 57ecf27bd45ea89def4c8f6f45f20977a003cfcc..66994fe0a34c9ab845ea84a5dfc5edc2a0bf38d2 100644 --- a/sflphone-client-gnome/src/logger.c +++ b/sflphone-client-gnome/src/logger.c @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> - * + * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -33,55 +33,50 @@ #include <string.h> #include <stdio.h> -int log_level = LOG_INFO; +int log_level = LOG_INFO; -void internal_log(const int level, const char* format, ...) +void internal_log (const int level, const char* format, ...) { - if(level > log_level) - return; + if (level > log_level) + return; - va_list ap; - char *prefix = "<> "; - char buffer[4000]; - char message[4096]; + va_list ap; + char *prefix = "<> "; + char buffer[4000]; + char message[4096]; - switch(level) - { - case LOG_ERR: - { - prefix = "<error> "; - break; - } - case LOG_WARN: - { - prefix = "<warning> "; - break; - } - case LOG_INFO: - { - prefix = "<info> "; - break; - } - case LOG_DEBUG: - { - prefix = "<debug> "; - break; - } + switch (level) { + case LOG_ERR: { + prefix = "<error> "; + break; + } + case LOG_WARN: { + prefix = "<warning> "; + break; + } + case LOG_INFO: { + prefix = "<info> "; + break; + } + case LOG_DEBUG: { + prefix = "<debug> "; + break; } + } - va_start(ap, format); - vsprintf(buffer, format, ap); - va_end(ap); + va_start (ap, format); + vsprintf (buffer, format, ap); + va_end (ap); - message[0] = '\0'; - strncat(message, prefix, strlen(prefix)); - strncat(message, buffer, strlen(buffer)); - strncat(message, "\n", 1); + message[0] = '\0'; + strncat (message, prefix, strlen (prefix)); + strncat (message, buffer, strlen (buffer)); + strncat (message, "\n", 1); - fprintf(stderr, "%s", message); + fprintf (stderr, "%s", message); } -void set_log_level(const int level) +void set_log_level (const int level) { - log_level = level; + log_level = level; } diff --git a/sflphone-client-gnome/src/logger.h b/sflphone-client-gnome/src/logger.h index e445e981e3d80106ac68f6d7a71dd007ab10b8a1..0d2ac5c5e435320b242fa33f28e4f27dbdbc20c4 100644 --- a/sflphone-client-gnome/src/logger.h +++ b/sflphone-client-gnome/src/logger.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> - * + * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,12 +27,12 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __LOGGER_H #define __LOGGER_H -void internal_log(const int level, const char* format, ...); -void set_log_level(const int level); +void internal_log (const int level, const char* format, ...); +void set_log_level (const int level); #define LOG_ERR 1 #define LOG_WARN 2 diff --git a/sflphone-client-gnome/src/main.c b/sflphone-client-gnome/src/main.c index a2b18b57e757f142073590a95fed4d3735bc8aa6..b3b6b2ebb150358b78c2e8184bfd0ec63eb3a978 100644 --- a/sflphone-client-gnome/src/main.c +++ b/sflphone-client-gnome/src/main.c @@ -37,6 +37,7 @@ #include <statusicon.h> #include <libgnome/libgnome.h> #include <libgnomeui/libgnomeui.h> +#include <eel-gconf-extensions.h> #include <gtk/gtk.h> #include <stdlib.h> @@ -46,86 +47,84 @@ int main (int argc, char *argv[]) { - // Handle logging - int i; - - // Check arguments if debug mode is activated - for (i = 0; i < argc; i++) - if (g_strcmp0 (argv[i], "--debug") == 0) - set_log_level (LOG_DEBUG); - - // GtkWidget *window; - g_thread_init (NULL); - gdk_threads_init (); - gdk_threads_enter (); - - // Start GTK application - gtk_init (&argc, &argv); - - g_print ("%s %s\n", PACKAGE, VERSION); - g_print ("\nCopyright (c) 2005 2006 2007 2008 2009 2010 Savoir-faire Linux Inc.\n\n"); - g_print ("This is free software. You may redistribute copies of it under the terms of\n" \ - "the GNU General Public License Version 3 <http://www.gnu.org/licenses/gpl.html>.\n" \ - "There is NO WARRANTY, to the extent permitted by law.\n\n" \ - "Additional permission under GNU GPL version 3 section 7:\n\n" \ - "If you modify this program, or any covered work, by linking or\n" \ - "combining it with the OpenSSL project's OpenSSL library (or a\n" \ - "modified version of that library), containing parts covered by the\n" \ - "terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.\n" \ - "grants you additional permission to convey the resulting work.\n" \ - "Corresponding Source for a non-source form of such a combination\n" \ - "shall include the source code for the parts of OpenSSL used as well\n" \ - "as that of the covered work.\n\n"); - - srand (time (NULL)); - - // Internationalization - bindtextdomain ("sflphone-client-gnome", LOCALEDIR); - textdomain ("sflphone-client-gnome"); - - // Initialises the GNOME libraries - gnome_program_init ("sflphone", VERSION, LIBGNOMEUI_MODULE, argc, argv, - GNOME_PROGRAM_STANDARD_PROPERTIES, - NULL) ; - - if (sflphone_init ()) - { - - if (eel_gconf_get_integer (SHOW_STATUSICON)) - show_status_icon (); - - create_main_window (); - - if (eel_gconf_get_integer (SHOW_STATUSICON) && eel_gconf_get_integer (START_HIDDEN)) - { - gtk_widget_hide (GTK_WIDGET( get_main_window() )); - set_minimized (TRUE); + // Handle logging + int i; + + // Check arguments if debug mode is activated + for (i = 0; i < argc; i++) + if (g_strcmp0 (argv[i], "--debug") == 0) + set_log_level (LOG_DEBUG); + + // GtkWidget *window; + g_thread_init (NULL); + gdk_threads_init (); + gdk_threads_enter (); + + // Start GTK application + gtk_init (&argc, &argv); + + g_print ("%s %s\n", PACKAGE, VERSION); + g_print ("\nCopyright (c) 2005 2006 2007 2008 2009 2010 Savoir-faire Linux Inc.\n\n"); + g_print ("This is free software. You may redistribute copies of it under the terms of\n" \ + "the GNU General Public License Version 3 <http://www.gnu.org/licenses/gpl.html>.\n" \ + "There is NO WARRANTY, to the extent permitted by law.\n\n" \ + "Additional permission under GNU GPL version 3 section 7:\n\n" \ + "If you modify this program, or any covered work, by linking or\n" \ + "combining it with the OpenSSL project's OpenSSL library (or a\n" \ + "modified version of that library), containing parts covered by the\n" \ + "terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.\n" \ + "grants you additional permission to convey the resulting work.\n" \ + "Corresponding Source for a non-source form of such a combination\n" \ + "shall include the source code for the parts of OpenSSL used as well\n" \ + "as that of the covered work.\n\n"); + + srand (time (NULL)); + + // Internationalization + bindtextdomain ("sflphone-client-gnome", LOCALEDIR); + textdomain ("sflphone-client-gnome"); + + // Initialises the GNOME libraries + gnome_program_init ("sflphone", VERSION, LIBGNOMEUI_MODULE, argc, argv, + GNOME_PROGRAM_STANDARD_PROPERTIES, + NULL) ; + + if (sflphone_init ()) { + + if (eel_gconf_get_integer (SHOW_STATUSICON)) + show_status_icon (); + + create_main_window (); + + if (eel_gconf_get_integer (SHOW_STATUSICON) && eel_gconf_get_integer (START_HIDDEN)) { + gtk_widget_hide (GTK_WIDGET (get_main_window())); + set_minimized (TRUE); } - status_bar_display_account (); + status_bar_display_account (); - // Load the history - sflphone_fill_history (); + // Load the history + sflphone_fill_history (); - // Get the active calls and conferences at startup - sflphone_fill_call_list (); - sflphone_fill_conference_list (); + // Get the active calls and conferences at startup + sflphone_fill_call_list (); + sflphone_fill_conference_list (); - // Update the GUI - update_actions (); + // Update the GUI + update_actions (); - shortcuts_initialize_bindings(); + shortcuts_initialize_bindings(); - /* start the main loop */ - gtk_main (); + /* start the main loop */ + gtk_main (); } - gdk_threads_leave (); + gdk_threads_leave (); - shortcuts_destroy_bindings(); + shortcuts_destroy_bindings(); - return 0; + return 0; } /** @mainpage SFLphone GTK+ Client Documentation diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index 0cd6bd195f0e4bccce91dc34872d501af71f408e..5dc20a999347bb7e9f04b3299216757a20541a42 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -42,6 +42,7 @@ #include <assistant.h> #include <widget/gtkscrollbook.h> #include <widget/minidialog.h> +#include "uimanager.h" #include <gtk/gtk.h> #include <eel-gconf-extensions.h> @@ -65,511 +66,495 @@ pthread_mutex_t statusbar_message_mutex; /** * Handle main window resizing */ -static gboolean window_configure_cb (GtkWidget *win, GdkEventConfigure *event) { +static gboolean window_configure_cb (GtkWidget *win UNUSED, GdkEventConfigure *event) +{ - int pos_x, pos_y; + int pos_x, pos_y; - eel_gconf_set_integer (CONF_MAIN_WINDOW_WIDTH, event->width); - eel_gconf_set_integer (CONF_MAIN_WINDOW_HEIGHT, event->height); + eel_gconf_set_integer (CONF_MAIN_WINDOW_WIDTH, event->width); + eel_gconf_set_integer (CONF_MAIN_WINDOW_HEIGHT, event->height); - gtk_window_get_position (GTK_WINDOW (window), &pos_x, &pos_y); - eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_X, pos_x); - eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_Y, pos_y); + gtk_window_get_position (GTK_WINDOW (window), &pos_x, &pos_y); + eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_X, pos_x); + eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_Y, pos_y); - return FALSE; + return FALSE; } /** * Minimize the main window. */ - static gboolean +static gboolean on_delete (GtkWidget * widget UNUSED, gpointer data UNUSED) { - if (eel_gconf_get_integer (SHOW_STATUSICON)) { - gtk_widget_hide (GTK_WIDGET( get_main_window() )); - set_minimized (TRUE); - } - else { - sflphone_quit (); - } + if (eel_gconf_get_integer (SHOW_STATUSICON)) { + gtk_widget_hide (GTK_WIDGET (get_main_window())); + set_minimized (TRUE); + } else { + sflphone_quit (); + } - pthread_mutex_destroy(&statusbar_message_mutex); - return TRUE; + pthread_mutex_destroy (&statusbar_message_mutex); + return TRUE; } /** Ask the user if he wants to hangup current calls */ - gboolean +gboolean main_window_ask_quit () { - guint count = calllist_get_size (current_calls); - GtkWidget * dialog; - gint response; - gchar * question; + guint count = calllist_get_size (current_calls); + GtkWidget * dialog; + gint response; + gchar * question; - if (count == 1) - { - question = _("There is one call in progress."); - } - else - { - question = _("There are calls in progress."); - } + if (count == 1) { + question = _ ("There is one call in progress."); + } else { + question = _ ("There are calls in progress."); + } - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), - GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s\n%s", - question, _("Do you still want to quit?") ); + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (window), + GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s\n%s", + question, _ ("Do you still want to quit?")); - response = gtk_dialog_run (GTK_DIALOG (dialog)); + response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + gtk_widget_destroy (dialog); - return (response == GTK_RESPONSE_NO)? FALSE : TRUE ; + return (response == GTK_RESPONSE_NO) ? FALSE : TRUE ; } - static gboolean +static gboolean on_key_released (GtkWidget *widget, GdkEventKey *event, gpointer user_data UNUSED) { - DEBUG("On key released from Main Window : %s", gtk_widget_get_name(widget)); - - if (focus_is_on_searchbar == FALSE) - { - // If a modifier key is pressed, it's a shortcut, pass along - if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK - || event->keyval == 60 || // < - event->keyval == 62 || // > - event->keyval == 34 || // " - event->keyval == 65289 || // tab - event->keyval == 65361 || // left arrow - event->keyval == 65363 || // right arrow - event->keyval >= 65470 || // F-keys - event->keyval == 32 // space - ) - return FALSE; - else - sflphone_keypad (event->keyval, event->string); - } - - return TRUE; + DEBUG ("On key released from Main Window : %s", gtk_widget_get_name (widget)); + + if (focus_is_on_searchbar == FALSE) { + // If a modifier key is pressed, it's a shortcut, pass along + if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK + || event->keyval == 60 || // < + event->keyval == 62 || // > + event->keyval == 34 || // " + event->keyval == 65289 || // tab + event->keyval == 65361 || // left arrow + event->keyval == 65363 || // right arrow + event->keyval >= 65470 || // F-keys + event->keyval == 32 // space + ) + return FALSE; + else + sflphone_keypad (event->keyval, event->string); + } + + return TRUE; } - void +void focus_on_mainwindow_out () { - // gtk_widget_grab_focus(GTK_WIDGET(window)); + // gtk_widget_grab_focus(GTK_WIDGET(window)); } - void +void focus_on_mainwindow_in () { - // gtk_widget_grab_focus(GTK_WIDGET(window)); + // gtk_widget_grab_focus(GTK_WIDGET(window)); } - void +void create_main_window () { - GtkWidget *widget; - gchar *path; - GError *error = NULL; - gboolean ret; - const char *window_title = "SFLphone VoIP Client"; - int width, height, position_x, position_y; - - focus_is_on_calltree = FALSE; - focus_is_on_searchbar = FALSE; - - // Get configuration stored in gconf - width = eel_gconf_get_integer (CONF_MAIN_WINDOW_WIDTH); - height = eel_gconf_get_integer (CONF_MAIN_WINDOW_HEIGHT); - position_x = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X); - position_y = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - gtk_window_set_title (GTK_WINDOW (window), window_title); - gtk_window_set_default_size (GTK_WINDOW (window), width, height); - gtk_window_set_default_icon_from_file (LOGO, - NULL); - gtk_window_set_position (GTK_WINDOW(window) , GTK_WIN_POS_MOUSE); - - /* Connect the destroy event of the window with our on_destroy function - * When the window is about to be destroyed we get a notificaiton and - * stop the main GTK loop - */ - g_signal_connect (G_OBJECT (window), "delete-event", - G_CALLBACK (on_delete), NULL); - - g_signal_connect (G_OBJECT (window), "key-release-event", - G_CALLBACK (on_key_released), NULL); - - g_signal_connect_after (G_OBJECT (window), "focus-in-event", - G_CALLBACK (focus_on_mainwindow_in), NULL); - - g_signal_connect_after (G_OBJECT (window), "focus-out-event", - G_CALLBACK (focus_on_mainwindow_out), NULL); - - g_signal_connect_object (G_OBJECT (window), "configure-event", - G_CALLBACK (window_configure_cb), NULL, 0); - - gtk_widget_set_name (window, "mainwindow"); - - ret = uimanager_new (&ui_manager); - if (!ret) - { - ERROR ("Could not load xml GUI\n"); - g_error_free (error); - exit (1); - } - - /* Create an accel group for window's shortcuts */ - gtk_window_add_accel_group (GTK_WINDOW(window), - gtk_ui_manager_get_accel_group (ui_manager)); - - vbox = gtk_vbox_new (FALSE /*homogeneous*/, 0 /*spacing*/); - subvbox = gtk_vbox_new (FALSE /*homogeneous*/, 5 /*spacing*/); - - create_menus (ui_manager, &widget); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, - 0 /*padding*/); - - create_toolbar_actions (ui_manager, &widget); - // Do not override GNOME user settings - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, - 0 /*padding*/); - - gtk_box_pack_start (GTK_BOX (vbox), current_calls->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_box_pack_start (GTK_BOX (vbox), history->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_box_pack_start (GTK_BOX (vbox), contacts->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - - g_signal_connect_object (G_OBJECT (window), "configure-event", - G_CALLBACK (window_configure_cb), NULL, 0); - gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, - FALSE /*fill*/, 0 /*padding*/); - - embedded_error_notebook = PIDGIN_SCROLL_BOOK(pidgin_scroll_book_new()); - gtk_box_pack_start (GTK_BOX(subvbox), GTK_WIDGET(embedded_error_notebook), - FALSE, FALSE, 0); - - if (SHOW_VOLUME) - { - speaker_control = create_slider ("speaker"); - gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (speaker_control); - mic_control = create_slider ("mic"); - gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (mic_control); - } - - - if (eel_gconf_get_boolean (CONF_SHOW_DIALPAD)){ - dialpad = create_dialpad(); - gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (dialpad); - } - - /* Status bar */ - statusBar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox), statusBar, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_container_add (GTK_CONTAINER (window), vbox); - - /* make sure that everything, window and label, are visible */ - gtk_widget_show_all (window); - - /* dont't show the history */ - gtk_widget_hide (history->tree); - - /* dont't show the contact list */ - gtk_widget_hide (contacts->tree); - - searchbar_init (history); - searchbar_init (contacts); - - /* don't show waiting layer */ - gtk_widget_hide (waitingLayer); - - pthread_mutex_init(&statusbar_message_mutex, NULL); - - // Configuration wizard - if (account_list_get_size () == 1) - { + GtkWidget *widget; + GError *error = NULL; + gboolean ret; + const char *window_title = "SFLphone VoIP Client"; + int width, height, position_x, position_y; + + focus_is_on_calltree = FALSE; + focus_is_on_searchbar = FALSE; + + // Get configuration stored in gconf + width = eel_gconf_get_integer (CONF_MAIN_WINDOW_WIDTH); + height = eel_gconf_get_integer (CONF_MAIN_WINDOW_HEIGHT); + position_x = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X); + position_y = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width (GTK_CONTAINER (window), 0); + gtk_window_set_title (GTK_WINDOW (window), window_title); + gtk_window_set_default_size (GTK_WINDOW (window), width, height); + gtk_window_set_default_icon_from_file (LOGO, + NULL); + gtk_window_set_position (GTK_WINDOW (window) , GTK_WIN_POS_MOUSE); + + /* Connect the destroy event of the window with our on_destroy function + * When the window is about to be destroyed we get a notificaiton and + * stop the main GTK loop + */ + g_signal_connect (G_OBJECT (window), "delete-event", + G_CALLBACK (on_delete), NULL); + + g_signal_connect (G_OBJECT (window), "key-release-event", + G_CALLBACK (on_key_released), NULL); + + g_signal_connect_after (G_OBJECT (window), "focus-in-event", + G_CALLBACK (focus_on_mainwindow_in), NULL); + + g_signal_connect_after (G_OBJECT (window), "focus-out-event", + G_CALLBACK (focus_on_mainwindow_out), NULL); + + g_signal_connect_object (G_OBJECT (window), "configure-event", + G_CALLBACK (window_configure_cb), NULL, 0); + + gtk_widget_set_name (window, "mainwindow"); + + ret = uimanager_new (&ui_manager); + + if (!ret) { + ERROR ("Could not load xml GUI\n"); + g_error_free (error); + exit (1); + } + + /* Create an accel group for window's shortcuts */ + gtk_window_add_accel_group (GTK_WINDOW (window), + gtk_ui_manager_get_accel_group (ui_manager)); + + vbox = gtk_vbox_new (FALSE /*homogeneous*/, 0 /*spacing*/); + subvbox = gtk_vbox_new (FALSE /*homogeneous*/, 5 /*spacing*/); + + create_menus (ui_manager, &widget); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, + 0 /*padding*/); + + create_toolbar_actions (ui_manager, &widget); + // Do not override GNOME user settings + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, + 0 /*padding*/); + + gtk_box_pack_start (GTK_BOX (vbox), current_calls->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_box_pack_start (GTK_BOX (vbox), history->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_box_pack_start (GTK_BOX (vbox), contacts->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + + g_signal_connect_object (G_OBJECT (window), "configure-event", + G_CALLBACK (window_configure_cb), NULL, 0); + gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, + FALSE /*fill*/, 0 /*padding*/); + + embedded_error_notebook = PIDGIN_SCROLL_BOOK (pidgin_scroll_book_new()); + gtk_box_pack_start (GTK_BOX (subvbox), GTK_WIDGET (embedded_error_notebook), + FALSE, FALSE, 0); + + if (SHOW_VOLUME) { + speaker_control = create_slider ("speaker"); + gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (speaker_control); + mic_control = create_slider ("mic"); + gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (mic_control); + } + + + if (eel_gconf_get_boolean (CONF_SHOW_DIALPAD)) { + dialpad = create_dialpad(); + gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (dialpad); + } + + /* Status bar */ + statusBar = gtk_statusbar_new (); + gtk_box_pack_start (GTK_BOX (vbox), statusBar, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_container_add (GTK_CONTAINER (window), vbox); + + /* make sure that everything, window and label, are visible */ + gtk_widget_show_all (window); + + /* dont't show the history */ + gtk_widget_hide (history->tree); + + /* dont't show the contact list */ + gtk_widget_hide (contacts->tree); + + searchbar_init (history); + searchbar_init (contacts); + + /* don't show waiting layer */ + gtk_widget_hide (waitingLayer); + + pthread_mutex_init (&statusbar_message_mutex, NULL); + + // Configuration wizard + if (account_list_get_size () == 1) { #if GTK_CHECK_VERSION(2,10,0) - build_wizard (); + build_wizard (); #else - GtkWidget * dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_YES_NO, - "<b><big>Welcome to SFLphone!</big></b>\n\nThere are no VoIP accounts configured, would you like to edit the preferences now?"); + GtkWidget * dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_YES_NO, + "<b><big>Welcome to SFLphone!</big></b>\n\nThere are no VoIP accounts configured, would you like to edit the preferences now?"); + + int response = gtk_dialog_run (GTK_DIALOG (dialog)); - int response = gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); - gtk_widget_destroy (GTK_WIDGET(dialog)); + if (response == GTK_RESPONSE_YES) { + show_preferences_dialog(); + } - if (response == GTK_RESPONSE_YES) - { - show_preferences_dialog(); - } #endif - } + } - // Restore position according to the configuration stored in gconf - gtk_window_move (GTK_WINDOW (window), position_x, position_y); + // Restore position according to the configuration stored in gconf + gtk_window_move (GTK_WINDOW (window), position_x, position_y); } - GtkAccelGroup * +GtkAccelGroup * get_accel_group () { - return accelGroup; + return accelGroup; } - GtkWidget * +GtkWidget * get_main_window () { - return window; + return window; } - void +void main_window_message (GtkMessageType type, gchar * markup) { - GtkWidget * dialog = gtk_message_dialog_new_with_markup ( - GTK_WINDOW(get_main_window()), GTK_DIALOG_MODAL - | GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_CLOSE, NULL); + GtkWidget * dialog = gtk_message_dialog_new_with_markup ( + GTK_WINDOW (get_main_window()), GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_CLOSE, NULL); - gtk_window_set_title (GTK_WINDOW(dialog), _("SFLphone Error")); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog), markup); + gtk_window_set_title (GTK_WINDOW (dialog), _ ("SFLphone Error")); + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup); - gtk_dialog_run (GTK_DIALOG(dialog)); - gtk_widget_destroy (GTK_WIDGET(dialog)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); } - void +void main_window_error_message (gchar * markup) { - main_window_message (GTK_MESSAGE_ERROR, markup); + main_window_message (GTK_MESSAGE_ERROR, markup); } - void +void main_window_warning_message (gchar * markup) { - main_window_message (GTK_MESSAGE_WARNING, markup); + main_window_message (GTK_MESSAGE_WARNING, markup); } - void +void main_window_info_message (gchar * markup) { - main_window_message (GTK_MESSAGE_INFO, markup); + main_window_message (GTK_MESSAGE_INFO, markup); } - void +void main_window_dialpad (gboolean state) { - g_print ("main_window_dialpad\n"); - - if (state) - { - dialpad = create_dialpad (); - gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (dialpad); - } - else - { - gtk_container_remove (GTK_CONTAINER (subvbox), dialpad); - } + g_print ("main_window_dialpad\n"); + + if (state) { + dialpad = create_dialpad (); + gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (dialpad); + } else { + gtk_container_remove (GTK_CONTAINER (subvbox), dialpad); + } } - void +void main_window_volume_controls (gboolean state) { - if (state) - { - speaker_control = create_slider ("speaker"); - gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (speaker_control); - mic_control = create_slider ("mic"); - gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (mic_control); - } - else - { - gtk_container_remove (GTK_CONTAINER(subvbox), speaker_control); - gtk_container_remove (GTK_CONTAINER(subvbox), mic_control); - } + if (state) { + speaker_control = create_slider ("speaker"); + gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (speaker_control); + mic_control = create_slider ("mic"); + gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (mic_control); + } else { + gtk_container_remove (GTK_CONTAINER (subvbox), speaker_control); + gtk_container_remove (GTK_CONTAINER (subvbox), mic_control); + } } - void +void statusbar_push_message (const gchar *left_hand_message, const gchar *right_hand_message, guint id) { - // The actual message to be push in the statusbar - gchar *message_to_display; - - pthread_mutex_lock(&statusbar_message_mutex); - - g_free(status_current_message); - // store the left hand message so that it can be reused in case of clock update - status_current_message = g_strdup(left_hand_message); - - // Format message according to right hand member - if(right_hand_message) - message_to_display = g_strdup_printf("%s %s", - left_hand_message, right_hand_message); - else - message_to_display = g_strdup(left_hand_message); - - // Push into the statusbar - gtk_statusbar_push (GTK_STATUSBAR(statusBar), id, message_to_display); - - g_free(message_to_display); - - pthread_mutex_unlock(&statusbar_message_mutex); + // The actual message to be push in the statusbar + gchar *message_to_display; + + pthread_mutex_lock (&statusbar_message_mutex); + + g_free (status_current_message); + // store the left hand message so that it can be reused in case of clock update + status_current_message = g_strdup (left_hand_message); + + // Format message according to right hand member + if (right_hand_message) + message_to_display = g_strdup_printf ("%s %s", + left_hand_message, right_hand_message); + else + message_to_display = g_strdup (left_hand_message); + + // Push into the statusbar + gtk_statusbar_push (GTK_STATUSBAR (statusBar), id, message_to_display); + + g_free (message_to_display); + + pthread_mutex_unlock (&statusbar_message_mutex); } - void +void statusbar_pop_message (guint id) { - gtk_statusbar_pop (GTK_STATUSBAR(statusBar), id); + gtk_statusbar_pop (GTK_STATUSBAR (statusBar), id); } void -statusbar_update_clock(gchar *msg) -{ - gchar *message = NULL; - - if(!msg) { - statusbar_pop_message(__MSG_ACCOUNT_DEFAULT); - statusbar_push_message(message, NULL, __MSG_ACCOUNT_DEFAULT); - } - - - pthread_mutex_lock(&statusbar_message_mutex); - message = g_strdup(status_current_message); - pthread_mutex_unlock(&statusbar_message_mutex); - - if(message) { - statusbar_pop_message(__MSG_ACCOUNT_DEFAULT); - statusbar_push_message(message, msg, __MSG_ACCOUNT_DEFAULT); - } - - g_free(message); - message = NULL; - +statusbar_update_clock (gchar *msg) +{ + gchar *message = NULL; + + if (!msg) { + statusbar_pop_message (__MSG_ACCOUNT_DEFAULT); + statusbar_push_message (message, NULL, __MSG_ACCOUNT_DEFAULT); + } + + + pthread_mutex_lock (&statusbar_message_mutex); + message = g_strdup (status_current_message); + pthread_mutex_unlock (&statusbar_message_mutex); + + if (message) { + statusbar_pop_message (__MSG_ACCOUNT_DEFAULT); + statusbar_push_message (message, msg, __MSG_ACCOUNT_DEFAULT); + } + + g_free (message); + message = NULL; + } static void add_error_dialog (GtkWidget *dialog, callable_obj_t * call) { - gtk_container_add (GTK_CONTAINER(embedded_error_notebook), dialog); + gtk_container_add (GTK_CONTAINER (embedded_error_notebook), dialog); call_add_error (call, dialog); } - static void +static void destroy_error_dialog_cb (GtkObject *dialog, callable_obj_t * call) { - call_remove_error (call, dialog); + call_remove_error (call, dialog); } - void +void main_window_zrtp_not_supported (callable_obj_t * c) { - account_t* account_details = NULL; - gchar* warning_enabled = ""; - - account_details = account_list_get_by_id (c->_accountID); - if (account_details != NULL) - { - warning_enabled = g_hash_table_lookup (account_details->properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); - DEBUG("Warning Enabled %s", warning_enabled); - } - else - { - DEBUG("Account is null callID %s", c->_callID); - GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); - if (properties != NULL) - { - warning_enabled = g_hash_table_lookup (properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); - } - } - - if (g_strcasecmp (warning_enabled, "true") == 0) - { - PidginMiniDialog *mini_dialog; - gchar *desc = g_markup_printf_escaped ( - _("ZRTP is not supported by peer %s\n"), c->_peer_number); - mini_dialog = pidgin_mini_dialog_new ( - _("Secure Communication Unavailable"), desc, - GTK_STOCK_DIALOG_WARNING); - pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), - sflphone_hang_up, NULL); - - g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); - } + account_t* account_details = NULL; + gchar* warning_enabled = ""; + + account_details = account_list_get_by_id (c->_accountID); + + if (account_details != NULL) { + warning_enabled = g_hash_table_lookup (account_details->properties, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); + DEBUG ("Warning Enabled %s", warning_enabled); + } else { + DEBUG ("Account is null callID %s", c->_callID); + GHashTable * properties = NULL; + sflphone_get_ip2ip_properties (&properties); + + if (properties != NULL) { + warning_enabled = g_hash_table_lookup (properties, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); + } + } + + if (g_strcasecmp (warning_enabled, "true") == 0) { + PidginMiniDialog *mini_dialog; + gchar *desc = g_markup_printf_escaped ( + _ ("ZRTP is not supported by peer %s\n"), c->_peer_number); + mini_dialog = pidgin_mini_dialog_new ( + _ ("Secure Communication Unavailable"), desc, + GTK_STOCK_DIALOG_WARNING); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Continue"), NULL, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Stop Call"), + sflphone_hang_up, NULL); + + g_signal_connect_after (mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); + + add_error_dialog (GTK_WIDGET (mini_dialog), c); + } } - void +void main_window_zrtp_negotiation_failed (const gchar* callID, const gchar* reason, - const gchar* severity) + const gchar* severity) { - gchar* peer_number = "(number unknown)"; - callable_obj_t * c = NULL; - c = calllist_get (current_calls, callID); - if (c != NULL) - { - peer_number = c->_peer_number; - } - - PidginMiniDialog *mini_dialog; - gchar - *desc = - g_markup_printf_escaped ( - _("A %s error forced the call with %s to fall under unencrypted mode.\nExact reason: %s\n"), - severity, peer_number, reason); - mini_dialog = pidgin_mini_dialog_new (_("ZRTP negotiation failed"), desc, - GTK_STOCK_DIALOG_WARNING); - pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, - NULL); - - g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); + gchar* peer_number = "(number unknown)"; + callable_obj_t * c = NULL; + c = calllist_get (current_calls, callID); + + if (c != NULL) { + peer_number = c->_peer_number; + } + + PidginMiniDialog *mini_dialog; + gchar + *desc = + g_markup_printf_escaped ( + _ ("A %s error forced the call with %s to fall under unencrypted mode.\nExact reason: %s\n"), + severity, peer_number, reason); + mini_dialog = pidgin_mini_dialog_new (_ ("ZRTP negotiation failed"), desc, + GTK_STOCK_DIALOG_WARNING); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Continue"), NULL, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Stop Call"), sflphone_hang_up, + NULL); + + g_signal_connect_after (mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); + + add_error_dialog (GTK_WIDGET (mini_dialog), c); } - void +void main_window_confirm_go_clear (callable_obj_t * c) { - PidginMiniDialog *mini_dialog; - gchar - *desc = - g_markup_printf_escaped ( - _("%s wants to stop using secure communication. Confirm will resume conversation without SRTP.\n"), - c->_peer_number); - mini_dialog = pidgin_mini_dialog_new (_("Confirm Go Clear"), desc, - GTK_STOCK_STOP); - pidgin_mini_dialog_add_button (mini_dialog, _("Confirm"), - (PidginMiniDialogCallback) sflphone_set_confirm_go_clear, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, - NULL); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); + PidginMiniDialog *mini_dialog; + gchar + *desc = + g_markup_printf_escaped ( + _ ("%s wants to stop using secure communication. Confirm will resume conversation without SRTP.\n"), + c->_peer_number); + mini_dialog = pidgin_mini_dialog_new (_ ("Confirm Go Clear"), desc, + GTK_STOCK_STOP); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Confirm"), + (PidginMiniDialogCallback) sflphone_set_confirm_go_clear, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _ ("Stop Call"), sflphone_hang_up, + NULL); + + add_error_dialog (GTK_WIDGET (mini_dialog), c); } diff --git a/sflphone-client-gnome/src/mainwindow.h b/sflphone-client-gnome/src/mainwindow.h index 84dbc383888f8e4543b971514f0a7097f33a33b7..991bbcb6cc826563159e464537ff93d31bda1714 100644 --- a/sflphone-client-gnome/src/mainwindow.h +++ b/sflphone-client-gnome/src/mainwindow.h @@ -54,7 +54,7 @@ GtkWidget *waitingLayer; /** * Build the main window */ -void create_main_window ( ); +void create_main_window (); /** * Display a dialog window @@ -67,50 +67,50 @@ gboolean main_window_ask_quit() ; /** * Shows/Hides the dialpad on the mainwindow */ -void main_window_dialpad( gboolean state ); +void main_window_dialpad (gboolean state); /** * Shows/Hides the dialpad on the mainwindow */ -void main_window_volume_controls( gboolean state ); +void main_window_volume_controls (gboolean state); /** * Display an error message * @param markup The error message */ -void main_window_error_message(gchar * markup); +void main_window_error_message (gchar * markup); /** * Display a warning message * @param markup The warning message */ -void main_window_warning_message(gchar * markup); +void main_window_warning_message (gchar * markup); /** * Display an info message * @param markup The info message */ -void main_window_info_message(gchar * markup); +void main_window_info_message (gchar * markup); /** * Push a message on the statusbar stack * @param left_hand_message The message to display on the left side - * @param right_hand_message The message to display on the right side + * @param right_hand_message The message to display on the right side * @param id The identifier of the message */ -void statusbar_push_message( const gchar *left_hand_message, const gchar *right_hand_message, guint id ); +void statusbar_push_message (const gchar *left_hand_message, const gchar *right_hand_message, guint id); /** * Pop a message from the statusbar stack * @param id The identifier of the message */ -void statusbar_pop_message( guint id ); +void statusbar_pop_message (guint id); /** * Update selected call's clock in statusbar * @param id The identifier of the message */ -void statusbar_update_clock( gchar *time); +void statusbar_update_clock (gchar *time); //static gboolean @@ -122,10 +122,10 @@ gboolean focus_is_on_calltree; gboolean focus_is_on_searchbar; -void main_window_zrtp_not_supported(callable_obj_t * c); +void main_window_zrtp_not_supported (callable_obj_t * c); -void main_window_zrtp_negotiation_failed(const gchar* callID, const gchar* reason, const gchar* severity); +void main_window_zrtp_negotiation_failed (const gchar* callID, const gchar* reason, const gchar* severity); -void main_window_confirm_go_clear(callable_obj_t * c); +void main_window_confirm_go_clear (callable_obj_t * c); #endif diff --git a/sflphone-client-gnome/src/reqaccount.c b/sflphone-client-gnome/src/reqaccount.c index dda30b8dc6b2e549bd081e1b3340d291ddc822e0..463298d563168494c6fc9904c155220abcd8bc9e 100644 --- a/sflphone-client-gnome/src/reqaccount.c +++ b/sflphone-client-gnome/src/reqaccount.c @@ -50,96 +50,108 @@ #include "reqaccount.h" -int req(char *host, int port, char *req, char *ret) { - - int s; - struct sockaddr_in servSockAddr; - struct hostent *servHostEnt; - long int length=0; - long int status=0; - int i=0; - FILE *f; - char buf[1024]; - - bzero(&servSockAddr, sizeof(servSockAddr)); - servHostEnt = gethostbyname(host); - if (servHostEnt == NULL) { - strcpy(ret, "gethostbyname"); - return -1; - } - bcopy((char *)servHostEnt->h_addr, (char *)&servSockAddr.sin_addr, servHostEnt->h_length); - servSockAddr.sin_port = htons(port); - servSockAddr.sin_family = AF_INET; - - if ((s = socket(AF_INET,SOCK_STREAM,0)) < 0) { - strcpy(ret, "socket"); - return -1; - } - - if(connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) { - perror("foo"); - strcpy(ret, "connect"); - return -1; - } - - f = fdopen(s, "r+"); - - fprintf(f, "%s HTTP/1.1\r\n", req); - fprintf(f, "Host: %s\r\n", host); - fputs("User-Agent: SFLphone\r\n", f); - fputs("\r\n", f); - - while (strncmp(fgets(buf, sizeof(buf), f), "\r\n", 2)) { - const char *len_h = "content-length"; - const char *status_h = "HTTP/1.1"; - if (strncasecmp(buf, len_h, strlen(len_h)) == 0) - length = atoi(buf + strlen(len_h) + 1); - if (strncasecmp(buf, status_h, strlen(status_h)) == 0) - status = atoi(buf + strlen(status_h) + 1); - } - for (i = 0; i < length; i++) - ret[i] = fgetc(f); - - if (status != 200) { - sprintf(ret, "http error: %ld", status); - return -1; - } - - fclose(f); - shutdown(s, 2); - close(s); - return 0; +int req (char *host, int port, char *req, char *ret) +{ + + int s; + struct sockaddr_in servSockAddr; + struct hostent *servHostEnt; + long int length=0; + long int status=0; + int i=0; + FILE *f; + char buf[1024]; + + bzero (&servSockAddr, sizeof (servSockAddr)); + servHostEnt = gethostbyname (host); + + if (servHostEnt == NULL) { + strcpy (ret, "gethostbyname"); + return -1; + } + + bcopy ( (char *) servHostEnt->h_addr, (char *) &servSockAddr.sin_addr, servHostEnt->h_length); + servSockAddr.sin_port = htons (port); + servSockAddr.sin_family = AF_INET; + + if ( (s = socket (AF_INET,SOCK_STREAM,0)) < 0) { + strcpy (ret, "socket"); + return -1; + } + + if (connect (s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof (servSockAddr)) < 0) { + perror ("foo"); + strcpy (ret, "connect"); + return -1; + } + + f = fdopen (s, "r+"); + + fprintf (f, "%s HTTP/1.1\r\n", req); + fprintf (f, "Host: %s\r\n", host); + fputs ("User-Agent: SFLphone\r\n", f); + fputs ("\r\n", f); + + while (strncmp (fgets (buf, sizeof (buf), f), "\r\n", 2)) { + const char *len_h = "content-length"; + const char *status_h = "HTTP/1.1"; + + if (strncasecmp (buf, len_h, strlen (len_h)) == 0) + length = atoi (buf + strlen (len_h) + 1); + + if (strncasecmp (buf, status_h, strlen (status_h)) == 0) + status = atoi (buf + strlen (status_h) + 1); + } + + for (i = 0; i < length; i++) + ret[i] = fgetc (f); + + if (status != 200) { + sprintf (ret, "http error: %ld", status); + return -1; + } + + fclose (f); + shutdown (s, 2); + close (s); + return 0; } -rest_account get_rest_account(char *host,char *email) { - char ret[4096]; - rest_account ra; - bzero(ret, sizeof(ret)); - DEBUG("HOST: %s", host); - strcpy(ret,"GET /rest/accountcreator?email="); - strcat(ret, email); - if (req(host, 80, ret, ret) != -1) { - strcpy(ra.user, strtok(ret, "\n")); - strcpy(ra.passwd, strtok(NULL, "\n"));\ - ra.success = 1; - } else { - ra.success = 0; - strcpy(ra.reason, ret); - } - puts(ret); - return ra; +rest_account get_rest_account (char *host,char *email) +{ + char ret[4096]; + rest_account ra; + bzero (ret, sizeof (ret)); + DEBUG ("HOST: %s", host); + strcpy (ret,"GET /rest/accountcreator?email="); + strcat (ret, email); + + if (req (host, 80, ret, ret) != -1) { + strcpy (ra.user, strtok (ret, "\n")); + strcpy (ra.passwd, strtok (NULL, "\n")); + \ + ra.success = 1; + } else { + ra.success = 0; + strcpy (ra.reason, ret); + } + + puts (ret); + return ra; } #ifdef BUILD_EXAMPLE -int main (void) { - rest_account acc = get_rest_account("sip.sflphone.org","email@email.com"); - if (acc.success) { - puts(acc.user); - puts(acc.passwd); - } else { - ERROR("FAILED: %s", acc.reason); - } +int main (void) +{ + rest_account acc = get_rest_account ("sip.sflphone.org","email@email.com"); + + if (acc.success) { + puts (acc.user); + puts (acc.passwd); + } else { + ERROR ("FAILED: %s", acc.reason); + } } #endif diff --git a/sflphone-client-gnome/src/reqaccount.h b/sflphone-client-gnome/src/reqaccount.h index 3a17154a4b07c7885f268dc56bf88604e39f4c0c..4bd9366eabb1d886ddd3025218ef464eda4fb363 100644 --- a/sflphone-client-gnome/src/reqaccount.h +++ b/sflphone-client-gnome/src/reqaccount.h @@ -29,10 +29,10 @@ */ typedef struct { - char success; - char reason[200]; - char user[200]; - char passwd[200]; + char success; + char reason[200]; + char user[200]; + char passwd[200]; } rest_account; -rest_account get_rest_account(char *host, char *email); +rest_account get_rest_account (char *host, char *email); diff --git a/sflphone-client-gnome/src/sflnotify.c b/sflphone-client-gnome/src/sflnotify.c index 4a2f000cfa3704fc045981d386ce5cd7f2a29c36..256c9b70a72fe14341a6ab804d0b71eadda9993e 100644 --- a/sflphone-client-gnome/src/sflnotify.c +++ b/sflphone-client-gnome/src/sflnotify.c @@ -28,7 +28,8 @@ * as that of the covered work. */ -#include <sflnotify.h> +#include "sflnotify.h" +#include <eel-gconf-extensions.h> GnomeNotification *_gnome_notification; @@ -36,7 +37,7 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg { GnomeNotification *_notif; - if (eel_gconf_get_integer (NOTIFY_ALL)){ + if (eel_gconf_get_integer (NOTIFY_ALL)) { _notif = g_new0 (GnomeNotification, 1); @@ -47,11 +48,11 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg //_notif->icon = gdk_pixbuf_new_from_file_at_size (LOGO, 120, 120, NULL); _notif->icon = gdk_pixbuf_new_from_file (LOGO_SMALL, NULL); #if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon (_notif->notification , get_status_icon() ); + notify_notification_attach_to_status_icon (_notif->notification , get_status_icon()); #endif notify_notification_set_urgency (_notif->notification, urgency); - + if (_notif->icon != NULL) notify_notification_set_icon_from_pixbuf (_notif->notification, _notif->icon); else @@ -60,7 +61,7 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg notify_notification_set_timeout (_notif->notification, timeout); if (!notify_notification_show (_notif->notification, NULL)) { - ERROR("notify(), failed to send notification"); + ERROR ("notify(), failed to send notification"); } *notif = _notif; @@ -68,105 +69,105 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg } - void +void notify_incoming_call (callable_obj_t* c) { - gchar* callerid; - gchar* title; + gchar* callerid; + gchar* title; - if (g_strcasecmp (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) ) ; - } - callerid = g_markup_printf_escaped(_("<i>From</i> %s"), c->_peer_number); + if (g_strcasecmp (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)) ; + } + + callerid = g_markup_printf_escaped (_ ("<i>From</i> %s"), c->_peer_number); - create_new_gnome_notification (title, - callerid, - NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, - &_gnome_notification); + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp (__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } - void +void notify_voice_mails (guint count, account_t* acc) { - // the account is different from NULL - gchar* title; - gchar* body; - - title = g_markup_printf_escaped(_("%s account : %s") , - (gchar*)g_hash_table_lookup(acc->properties , ACCOUNT_TYPE) , - (gchar*) g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) ) ; - body = g_markup_printf_escaped(n_("%d voice mail", "%d voice mails", count), count); - - create_new_gnome_notification (title, - body, - NOTIFY_URGENCY_LOW, - NOTIFY_EXPIRES_DEFAULT, - &_gnome_notification); + // the account is different from NULL + gchar* title; + gchar* body; + + title = g_markup_printf_escaped (_ ("%s account : %s") , + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_TYPE) , + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_ALIAS)) ; + body = g_markup_printf_escaped (n_ ("%d voice mail", "%d voice mails", count), count); + + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_LOW, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } - void +void notify_current_account (account_t* acc) { - // the account is different from NULL - gchar* title; - gchar* body=""; + // the account is different from NULL + gchar* title; + gchar* body=""; - body = g_markup_printf_escaped(_("Calling with %s account <i>%s</i>") , - (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE) , - (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS)); + body = g_markup_printf_escaped (_ ("Calling with %s account <i>%s</i>") , + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_TYPE) , + (gchar*) g_hash_table_lookup (acc->properties , ACCOUNT_ALIAS)); - title = g_markup_printf_escaped(_("Current account")); + title = g_markup_printf_escaped (_ ("Current account")); - create_new_gnome_notification (title, - body, - NOTIFY_URGENCY_NORMAL, - NOTIFY_EXPIRES_DEFAULT, - &_gnome_notification); + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_NORMAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } - void +void notify_no_accounts () { gchar* title; gchar* body=""; - body = g_markup_printf_escaped(_("You have no accounts set up")); - title = g_markup_printf_escaped(_("Error")); + body = g_markup_printf_escaped (_ ("You have no accounts set up")); + title = g_markup_printf_escaped (_ ("Error")); create_new_gnome_notification (title, - body, - NOTIFY_URGENCY_CRITICAL, - NOTIFY_EXPIRES_DEFAULT, - &_gnome_notification); + body, + NOTIFY_URGENCY_CRITICAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } - void +void notify_no_registered_accounts () { gchar* title; gchar* body=""; - body = g_markup_printf_escaped(_("You have no registered accounts")); - title = g_markup_printf_escaped(_("Error")); + body = g_markup_printf_escaped (_ ("You have no registered accounts")); + title = g_markup_printf_escaped (_ ("Error")); create_new_gnome_notification (title, - body, - NOTIFY_URGENCY_CRITICAL, - NOTIFY_EXPIRES_DEFAULT, - &_gnome_notification); + body, + NOTIFY_URGENCY_CRITICAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } - void -stop_notification( void ) +void +stop_notification (void) { /* if( _gnome_notification != NULL ) @@ -186,67 +187,67 @@ stop_notification( void ) */ void free_notification (GnomeNotification *g) { - g_free(g->title); - g_free(g->body); - g_free(g); + g_free (g->title); + g_free (g->body); + g_free (g); } - void +void notify_secure_on (callable_obj_t* c) { - gchar* callerid; - gchar* title; - title = g_markup_printf_escaped ("Secure mode on."); - callerid = g_markup_printf_escaped(_("<i>With:</i> %s \nusing %s") , c->_peer_number, c->_srtp_cipher); - create_new_gnome_notification (title, - callerid, - NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, - &_gnome_notification); + gchar* callerid; + gchar* title; + title = g_markup_printf_escaped ("Secure mode on."); + callerid = g_markup_printf_escaped (_ ("<i>With:</i> %s \nusing %s") , c->_peer_number, c->_srtp_cipher); + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp (__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } - void +void notify_zrtp_not_supported (callable_obj_t* c) { - gchar* callerid; - gchar* title; - title = g_markup_printf_escaped ("ZRTP Error."); - callerid = g_markup_printf_escaped(_("%s does not support ZRTP.") , c->_peer_number); - create_new_gnome_notification (title, - callerid, - NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, - &_gnome_notification); + gchar* callerid; + gchar* title; + title = g_markup_printf_escaped ("ZRTP Error."); + callerid = g_markup_printf_escaped (_ ("%s does not support ZRTP.") , c->_peer_number); + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp (__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } - void +void notify_zrtp_negotiation_failed (callable_obj_t* c) { - gchar* callerid; - gchar* title; - title = g_markup_printf_escaped ("ZRTP Error."); - callerid = g_markup_printf_escaped(_("ZRTP negotiation failed with %s") , c->_peer_number); - create_new_gnome_notification (title, - callerid, - NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, - &_gnome_notification); + gchar* callerid; + gchar* title; + title = g_markup_printf_escaped ("ZRTP Error."); + callerid = g_markup_printf_escaped (_ ("ZRTP negotiation failed with %s") , c->_peer_number); + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp (__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } - void +void notify_secure_off (callable_obj_t* c) { - gchar* callerid; - gchar* title; - title = g_markup_printf_escaped ("Secure mode is off."); - callerid = g_markup_printf_escaped(_("<i>With:</i> %s") , c->_peer_number); - create_new_gnome_notification (title, - callerid, - NOTIFY_URGENCY_CRITICAL, - (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, - &_gnome_notification); + gchar* callerid; + gchar* title; + title = g_markup_printf_escaped ("Secure mode is off."); + callerid = g_markup_printf_escaped (_ ("<i>With:</i> %s") , c->_peer_number); + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp (__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } diff --git a/sflphone-client-gnome/src/sflnotify.h b/sflphone-client-gnome/src/sflnotify.h index 71cfc916658ef94a196d8c9f5d2d2e2a9181e732..b5bf8631a6539c4dcc487e00e2c85302d14e9e5c 100644 --- a/sflphone-client-gnome/src/sflnotify.h +++ b/sflphone-client-gnome/src/sflnotify.h @@ -60,7 +60,7 @@ void free_notification (GnomeNotification *g); * A dialog box is attached to the status icon * @param c The incoming call */ -void notify_incoming_call( callable_obj_t* c); +void notify_incoming_call (callable_obj_t* c); /** * Notify voice mails count @@ -68,28 +68,28 @@ void notify_incoming_call( callable_obj_t* c); * @param count The number of voice mails * @param acc The account that received the notification */ -void notify_voice_mails( guint count , account_t* acc ); +void notify_voice_mails (guint count , account_t* acc); /** * Notify the current account used to make calls with * @param acc The current account */ -void notify_current_account( account_t* acc ); +void notify_current_account (account_t* acc); /** * Notify that no accounts have been setup */ -void notify_no_accounts( ); +void notify_no_accounts(); /** * Notify that there is no registered account */ -void notify_no_registered_accounts( ); +void notify_no_registered_accounts(); /** * Stop and close the current notification if an action occured before the timeout */ -void stop_notification( void ); +void stop_notification (void); /** * Notify that the RTP session is secured @@ -104,7 +104,7 @@ void notify_secure_off (callable_obj_t* c); /** * Notify that the ZRTP negotiation failed */ - + void notify_zrtp_negotiation_failed (callable_obj_t* c); /** diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 6d453123db089225e65a36fc9f2e58c4f3f204c6..0e849b969aa43b80af3a598702ee055c3a4f56d0 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -34,6 +34,7 @@ #include <libintl.h> #include "logger.h" #include "dbus.h" +#include <glib/gi18n.h> /* @file sflphone_const.h * @brief Contains the global variables for the client code @@ -49,9 +50,9 @@ #define CONTACTS "contacts" /** Locale */ -#define _(STRING) gettext( STRING ) -#define N_(STRING) (STRING) -#define c_(COMMENT,STRING) gettext(STRING) +//#define _(STRING) gettext( STRING ) +//#define N_(STRING) (STRING) +#define c_(COMMENT,STRING) gettext(STRING) #define n_(SING,PLUR,COUNT) ngettext(SING,PLUR,COUNT) #define IP2IP "IP2IP" @@ -106,7 +107,7 @@ #define TLS_SERVER_NAME "TLS.serverName" #define TLS_VERIFY_SERVER "TLS.verifyServer" #define TLS_VERIFY_CLIENT "TLS.verifyClient" -#define TLS_REQUIRE_CLIENT_CERTIFICATE "TLS.requireClientCertificate" +#define TLS_REQUIRE_CLIENT_CERTIFICATE "TLS.requireClientCertificate" #define TLS_NEGOTIATION_TIMEOUT_SEC "TLS.negotiationTimeoutSec" #define TLS_NEGOTIATION_TIMEOUT_MSEC "TLS.negotiationTimemoutMsec" @@ -117,7 +118,7 @@ #define PUBLISHED_ADDRESS "Account.publishedAddress" #define REGISTRATION_STATUS "Status" -#define REGISTRATION_STATE_CODE "Registration.code" +#define REGISTRATION_STATE_CODE "Registration.code" #define REGISTRATION_STATE_DESCRIPTION "Registration.description" #define SHORTCUT_PICKUP "pickUp" @@ -150,7 +151,7 @@ #define ALSA 0 #define PULSEAUDIO 1 - /** DTMF type */ +/** DTMF type */ #define OVERRTP "overrtp" #define SIPINFO "sipinfo" @@ -182,9 +183,9 @@ #define CONF_MAIN_WINDOW_POSITION_X CONF_PREFIX "/state/window_position_x" #define CONF_MAIN_WINDOW_POSITION_Y CONF_PREFIX "/state/window_position_y" /** Show/Hide the dialpad */ -#define CONF_SHOW_DIALPAD CONF_PREFIX "/state/dialpad" -#define SHOW_VOLUME_CONTROLS CONF_PREFIX "/state/volume_controls" -#define SHOW_STATUSICON CONF_PREFIX "/state/statusicon" +#define CONF_SHOW_DIALPAD CONF_PREFIX "/state/dialpad" +#define SHOW_VOLUME_CONTROLS CONF_PREFIX "/state/volume_controls" +#define SHOW_STATUSICON CONF_PREFIX "/state/statusicon" #define NOTIFY_ALL CONF_PREFIX "/state/notify_all" #define START_HIDDEN CONF_PREFIX "/state/start_hidden" #define POPUP_ON_CALL CONF_PREFIX "/state/popup" diff --git a/sflphone-client-gnome/src/shortcuts.c b/sflphone-client-gnome/src/shortcuts.c index 4e95667171ebce1496d3270f7fa403d96031bda7..217254687d89b2e8ff9052f0f756fedc2cfe2bda 100644 --- a/sflphone-client-gnome/src/shortcuts.c +++ b/sflphone-client-gnome/src/shortcuts.c @@ -43,6 +43,14 @@ #include "callable_obj.h" #include "sflphone_const.h" #include "dbus.h" +#include "actions.h" + +static void +ungrab_key (guint key, GdkModifierType mask, const GdkWindow *root); + +static void +grab_key (guint key, GdkModifierType mask, const GdkWindow *root); + // used to store accelerator config static Accelerator* accelerators_list; @@ -50,95 +58,136 @@ static Accelerator* accelerators_list; // used to store config (for dbus calls) static GHashTable* shortcutsMap; + /* - * Callbacks + * XLib functions */ -static void -toggle_pick_up_hang_up_callback () +/* + * filter used when an event is catched + */ +static GdkFilterReturn +filter_keys (const GdkXEvent *xevent, const GdkEvent *event UNUSED, gpointer data UNUSED) { - callable_obj_t * selectedCall = calltab_get_selected_call (active_calltree); - conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + XEvent *xev = NULL; + XKeyEvent *key = NULL; + GdkModifierType keystate = 0; + int i = 0; - g_print ("toggle_pick_up_hang_up_callback\n"); + xev = (XEvent *) xevent; - if (selectedCall) - { - switch (selectedCall->_state) - { - case CALL_STATE_INCOMING: - case CALL_STATE_TRANSFERT: - sflphone_pick_up (); - break; - case CALL_STATE_DIALING: - case CALL_STATE_HOLD: - case CALL_STATE_CURRENT: - case CALL_STATE_RECORD: - case CALL_STATE_RINGING: - sflphone_hang_up (); - break; - } + if (xev->type != KeyPress) { + return GDK_FILTER_CONTINUE; } - else if (selectedConf) - { - dbus_hang_up_conference (selectedConf); + + key = (XKeyEvent *) xevent; + keystate = key->state & ~ (Mod2Mask | Mod5Mask | LockMask); + + // try to find corresponding action + while (accelerators_list[i].action != NULL) { + if (accelerators_list[i].key == key->keycode && accelerators_list[i].mask + == keystate) { + DEBUG ("catched key for action: %s", accelerators_list[i].action, + accelerators_list[i].key); + + // call associated callback function + accelerators_list[i].callback (); + + return GDK_FILTER_REMOVE; + } + + i++; } - else - sflphone_pick_up (); + + DEBUG ("Should not be reached"); + + return GDK_FILTER_CONTINUE; +} + +/* + * Callbacks + */ +static void +toggle_pick_up_hang_up_callback () +{ + callable_obj_t * selectedCall = calltab_get_selected_call (active_calltree); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + + g_print ("toggle_pick_up_hang_up_callback\n"); + + if (selectedCall) { + switch (selectedCall->_state) { + case CALL_STATE_INCOMING: + case CALL_STATE_TRANSFERT: + sflphone_pick_up (); + break; + case CALL_STATE_DIALING: + case CALL_STATE_HOLD: + case CALL_STATE_CURRENT: + case CALL_STATE_RECORD: + case CALL_STATE_RINGING: + sflphone_hang_up (); + break; + default: + break; + } + } else if (selectedConf) { + dbus_hang_up_conference (selectedConf); + } else + sflphone_pick_up (); } static void pick_up_callback () { - sflphone_pick_up (); + sflphone_pick_up (); } static void hang_up_callback () { - sflphone_hang_up (); + sflphone_hang_up (); } static void toggle_hold_callback () { - callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); - - if (selectedCall) - { - switch (selectedCall->_state) - { - case CALL_STATE_CURRENT: - case CALL_STATE_RECORD: - g_print ("on hold\n"); - sflphone_on_hold (); - break; - case CALL_STATE_HOLD: - g_print ("off hold\n"); - sflphone_off_hold (); - break; + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + + if (selectedCall) { + switch (selectedCall->_state) { + case CALL_STATE_CURRENT: + case CALL_STATE_RECORD: + g_print ("on hold\n"); + sflphone_on_hold (); + break; + case CALL_STATE_HOLD: + g_print ("off hold\n"); + sflphone_off_hold (); + break; + default: + break; } - } - else if (selectedConf) - dbus_hold_conference (selectedConf); - else - ERROR("Should not happen"); + } else if (selectedConf) + dbus_hold_conference (selectedConf); + else + ERROR ("Should not happen"); } static void popup_window_callback () { - gtk_widget_hide (GTK_WIDGET(get_main_window())); - gtk_widget_show (GTK_WIDGET(get_main_window())); - //gtk_window_move (GTK_WINDOW (get_main_window ()), - // dbus_get_window_position_x (), dbus_get_window_position_y ()); + gtk_widget_hide (GTK_WIDGET (get_main_window())); + gtk_widget_show (GTK_WIDGET (get_main_window())); + //gtk_window_move (GTK_WINDOW (get_main_window ()), + // dbus_get_window_position_x (), dbus_get_window_position_y ()); } static void default_callback () { - ERROR("Missing shortcut callback"); + ERROR ("Missing shortcut callback"); } /* @@ -147,22 +196,22 @@ default_callback () static void* get_action_callback (const gchar* action) { - if (strcmp (action, SHORTCUT_PICKUP) == 0) - return pick_up_callback; + if (strcmp (action, SHORTCUT_PICKUP) == 0) + return pick_up_callback; - if (strcmp (action, SHORTCUT_HANGUP) == 0) - return hang_up_callback; + if (strcmp (action, SHORTCUT_HANGUP) == 0) + return hang_up_callback; - if (strcmp (action, SHORTCUT_POPUP) == 0) - return popup_window_callback; + if (strcmp (action, SHORTCUT_POPUP) == 0) + return popup_window_callback; - if (strcmp (action, SHORTCUT_TOGGLEPICKUPHANGUP) == 0) - return toggle_pick_up_hang_up_callback; + if (strcmp (action, SHORTCUT_TOGGLEPICKUPHANGUP) == 0) + return toggle_pick_up_hang_up_callback; - if (strcmp (action, SHORTCUT_TOGGLEHOLD) == 0) - return toggle_hold_callback; + if (strcmp (action, SHORTCUT_TOGGLEHOLD) == 0) + return toggle_hold_callback; - return default_callback; + return default_callback; } /* @@ -175,33 +224,31 @@ get_action_callback (const gchar* action) static void remove_bindings () { - GdkDisplay *display = NULL; - GdkScreen *screen = NULL; - GdkWindow *root = NULL; - int i, j = 0; - - display = gdk_display_get_default (); - - for (i = 0; i < gdk_display_get_n_screens (display); i++) - { - screen = gdk_display_get_screen (display, i); - if (screen != NULL) - { - j = 0; - root = gdk_screen_get_root_window (screen); - - // remove filter - gdk_window_remove_filter (root, filter_keys, NULL); - - // unbind shortcuts - while (accelerators_list[j].action != NULL) - { - if (accelerators_list[j].key != 0) - { - ungrab_key (accelerators_list[j].key, - accelerators_list[j].mask, root); + GdkDisplay *display = NULL; + GdkScreen *screen = NULL; + GdkWindow *root = NULL; + int i, j = 0; + + display = gdk_display_get_default (); + + for (i = 0; i < gdk_display_get_n_screens (display); i++) { + screen = gdk_display_get_screen (display, i); + + if (screen != NULL) { + j = 0; + root = gdk_screen_get_root_window (screen); + + // remove filter + gdk_window_remove_filter (root, (GdkFilterFunc) filter_keys, NULL); + + // unbind shortcuts + while (accelerators_list[j].action != NULL) { + if (accelerators_list[j].key != 0) { + ungrab_key (accelerators_list[j].key, + accelerators_list[j].mask, root); } - j++; + + j++; } } } @@ -213,33 +260,31 @@ remove_bindings () static void create_bindings () { - GdkDisplay *display; - GdkScreen *screen; - GdkWindow *root; - int i, j = 0; - - display = gdk_display_get_default (); - - for (i = 0; i < gdk_display_get_n_screens (display); i++) - { - screen = gdk_display_get_screen (display, i); - if (screen != NULL) - { - j = 0; - root = gdk_screen_get_root_window (screen); - - // add filter - gdk_window_add_filter (root, filter_keys, NULL); - - // bind shortcuts - while (accelerators_list[j].action != NULL) - { - if (accelerators_list[j].key != 0) - { - grab_key (accelerators_list[j].key, - accelerators_list[j].mask, root); + GdkDisplay *display; + GdkScreen *screen; + GdkWindow *root; + int i, j = 0; + + display = gdk_display_get_default (); + + for (i = 0; i < gdk_display_get_n_screens (display); i++) { + screen = gdk_display_get_screen (display, i); + + if (screen != NULL) { + j = 0; + root = gdk_screen_get_root_window (screen); + + // add filter + gdk_window_add_filter (root, (GdkFilterFunc) filter_keys, NULL); + + // bind shortcuts + while (accelerators_list[j].action != NULL) { + if (accelerators_list[j].key != 0) { + grab_key (accelerators_list[j].key, + accelerators_list[j].mask, root); } - j++; + + j++; } } } @@ -251,29 +296,27 @@ create_bindings () static void initialize_binding (const gchar* action, guint key, GdkModifierType mask) { - int i = 0; + int i = 0; - while (accelerators_list[i].action != NULL) - { - if (strcmp (action, accelerators_list[i].action) == 0) - { - break; + while (accelerators_list[i].action != NULL) { + if (strcmp (action, accelerators_list[i].action) == 0) { + break; } - i++; + + i++; } - if (accelerators_list[i].action == NULL) - { - ERROR("Should not happen: cannot find corresponding action"); - return; + if (accelerators_list[i].action == NULL) { + ERROR ("Should not happen: cannot find corresponding action"); + return; } - // update config value - accelerators_list[i].key = key; - accelerators_list[i].mask = mask; + // update config value + accelerators_list[i].key = key; + accelerators_list[i].mask = mask; - // update bindings - create_bindings (); + // update bindings + create_bindings (); } /* @@ -282,76 +325,74 @@ initialize_binding (const gchar* action, guint key, GdkModifierType mask) static void initialize_accelerators_list () { - GList* shortcutsKeysElement, *shortcutsKeys = NULL; - int i = 0; + GList* shortcutsKeysElement, *shortcutsKeys = NULL; + int i = 0; - shortcutsKeys = g_hash_table_get_keys (shortcutsMap); + shortcutsKeys = g_hash_table_get_keys (shortcutsMap); - accelerators_list = (Accelerator*) malloc ( - (g_list_length (shortcutsKeys) + 1) * sizeof(Accelerator)); + accelerators_list = (Accelerator*) malloc ( + (g_list_length (shortcutsKeys) + 1) * sizeof (Accelerator)); - for (shortcutsKeysElement = shortcutsKeys; shortcutsKeysElement; shortcutsKeysElement - = shortcutsKeysElement->next) - { - gchar* action = shortcutsKeysElement->data; + for (shortcutsKeysElement = shortcutsKeys; shortcutsKeysElement; shortcutsKeysElement + = shortcutsKeysElement->next) { + gchar* action = shortcutsKeysElement->data; - accelerators_list[i].action = g_strdup (action); - accelerators_list[i].callback = get_action_callback (action); - accelerators_list[i].mask = 0; - accelerators_list[i].key = 0; + accelerators_list[i].action = g_strdup (action); + accelerators_list[i].callback = get_action_callback (action); + accelerators_list[i].mask = 0; + accelerators_list[i].key = 0; - i++; + i++; } - // last element must be null - accelerators_list[i].action = 0; - accelerators_list[i].callback = 0; - accelerators_list[i].mask = 0; - accelerators_list[i].key = 0; + // last element must be null + accelerators_list[i].action = 0; + accelerators_list[i].callback = 0; + accelerators_list[i].mask = 0; + accelerators_list[i].key = 0; } static void update_shortcuts_map (const gchar* action, guint key, GdkModifierType mask) { - gchar buffer[7]; + gchar buffer[7]; - // Bindings: MASKxCODE - sprintf (buffer, "%dx%d", mask, key); + // Bindings: MASKxCODE + sprintf (buffer, "%dx%d", mask, key); - g_hash_table_replace (shortcutsMap, g_strdup (action), g_strdup (buffer)); + g_hash_table_replace (shortcutsMap, g_strdup (action), g_strdup (buffer)); } static void update_bindings_data (guint index, guint key, GdkModifierType mask) { - int i = 0; - - // we need to be sure this code is not already affected - // to another action - while (accelerators_list[i].action != NULL) - { - if (accelerators_list[i].key == key && accelerators_list[i].mask == mask - && accelerators_list[i].key != 0) - { - DEBUG("Existing mapping found %d+%d", mask, key); - - // disable old binding - accelerators_list[i].key = 0; - accelerators_list[i].mask = 0; - - // update config table - update_shortcuts_map (accelerators_list[i].action, 0, 0); + int i = 0; + + // we need to be sure this code is not already affected + // to another action + while (accelerators_list[i].action != NULL) { + if (accelerators_list[i].key == key && accelerators_list[i].mask == mask + && accelerators_list[i].key != 0) { + DEBUG ("Existing mapping found %d+%d", mask, key); + + // disable old binding + accelerators_list[i].key = 0; + accelerators_list[i].mask = 0; + + // update config table + update_shortcuts_map (accelerators_list[i].action, 0, 0); } - i++; + + i++; } - // store new key - accelerators_list[index].key = key; - accelerators_list[index].mask = mask; + // store new key + accelerators_list[index].key = key; + accelerators_list[index].mask = mask; - // update value in hashtable (used for dbus calls) - update_shortcuts_map (accelerators_list[index].action, - accelerators_list[index].key, accelerators_list[index].mask); + // update value in hashtable (used for dbus calls) + update_shortcuts_map (accelerators_list[index].action, + accelerators_list[index].key, accelerators_list[index].mask); } /* @@ -364,17 +405,17 @@ update_bindings_data (guint index, guint key, GdkModifierType mask) void shortcuts_update_bindings (guint index, guint key, GdkModifierType mask) { - // first remove all existing bindings - remove_bindings (); + // first remove all existing bindings + remove_bindings (); - // update data - update_bindings_data (index, key, mask); + // update data + update_bindings_data (index, key, mask); - // recreate all bindings - create_bindings (); + // recreate all bindings + create_bindings (); - // update configuration - dbus_set_shortcuts (shortcutsMap); + // update configuration + dbus_set_shortcuts (shortcutsMap); } /* @@ -383,43 +424,42 @@ shortcuts_update_bindings (guint index, guint key, GdkModifierType mask) void shortcuts_initialize_bindings () { - GList* shortcutsKeys, *shortcutsKeysElement = NULL; - gchar* action, *maskAndKey, *token1, *token2 = NULL; - guint mask, key = 0; + GList* shortcutsKeys, *shortcutsKeysElement = NULL; + gchar* action, *maskAndKey, *token1, *token2 = NULL; + guint mask, key = 0; + + DEBUG ("Shortcuts: Initialize bindings"); - DEBUG("Shortcuts: Initialize bindings"); + // get shortcuts stored in config through dbus + shortcutsMap = dbus_get_shortcuts (); - // get shortcuts stored in config through dbus - shortcutsMap = dbus_get_shortcuts (); + // initialize list of keys + initialize_accelerators_list (); - // initialize list of keys - initialize_accelerators_list (); + // iterate through keys to initialize bindings + shortcutsKeys = g_hash_table_get_keys (shortcutsMap); - // iterate through keys to initialize bindings - shortcutsKeys = g_hash_table_get_keys (shortcutsMap); + for (shortcutsKeysElement = shortcutsKeys; shortcutsKeysElement; shortcutsKeysElement + = shortcutsKeysElement->next) { + action = shortcutsKeysElement->data; + maskAndKey = g_strdup (g_hash_table_lookup (shortcutsMap, action)); - for (shortcutsKeysElement = shortcutsKeys; shortcutsKeysElement; shortcutsKeysElement - = shortcutsKeysElement->next) - { - action = shortcutsKeysElement->data; - maskAndKey = g_strdup (g_hash_table_lookup (shortcutsMap, action)); + token1 = strtok (maskAndKey, "x"); + token2 = strtok (NULL, "x"); - token1 = strtok (maskAndKey, "x"); - token2 = strtok (NULL, "x"); + mask = 0; + key = 0; - mask = 0; - key = 0; + // Value not setted + if (token1 && token2) { + DEBUG ("Ahortcuts: token1 %s, token2 %s", token1, token2); - // Value not setted - if (token1 && token2){ - DEBUG("Ahortcuts: token1 %s, token2 %s", token1, token2); - - mask = atoi (token1); - key = atoi (token2); - } + mask = atoi (token1); + key = atoi (token2); + } - if (key != 0) - initialize_binding (action, key, mask); + if (key != 0) + initialize_binding (action, key, mask); } } @@ -429,69 +469,24 @@ shortcuts_initialize_bindings () void shortcuts_destroy_bindings () { - int i = 0; + int i = 0; - // remove bindings - remove_bindings (); + // remove bindings + remove_bindings (); - // free pointers - while (accelerators_list[i].action != NULL) - { - g_free (accelerators_list[i].action); - i++; + // free pointers + while (accelerators_list[i].action != NULL) { + g_free (accelerators_list[i].action); + i++; } - free (accelerators_list); + free (accelerators_list); } Accelerator* shortcuts_get_list () { - return accelerators_list; -} - -/* - * XLib functions - */ - -/* - * filter used when an event is catched - */ -static GdkFilterReturn -filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data) -{ - XEvent *xev = NULL; - XKeyEvent *key = NULL; - GdkModifierType keystate = 0; - int i = 0; - - xev = (XEvent *) xevent; - if (xev->type != KeyPress) { - return GDK_FILTER_CONTINUE; - } - - key = (XKeyEvent *) xevent; - keystate = key->state & ~(Mod2Mask | Mod5Mask | LockMask); - - // try to find corresponding action - while (accelerators_list[i].action != NULL) { - if (accelerators_list[i].key == key->keycode && accelerators_list[i].mask - == keystate) - { - DEBUG("catched key for action: %s", accelerators_list[i].action, - accelerators_list[i].key); - - // call associated callback function - accelerators_list[i].callback (); - - return GDK_FILTER_REMOVE; - } - i++; - } - - DEBUG("Should not be reached"); - - return GDK_FILTER_CONTINUE; + return accelerators_list; } /* @@ -500,27 +495,27 @@ filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data) static void ungrab_key (guint key, GdkModifierType mask, const GdkWindow *root) { - DEBUG("Ungrabbing key %d+%d", mask, key); - - gdk_error_trap_push (); - - XUngrabKey (GDK_DISPLAY (), key, mask, GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | mask, GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod5Mask | mask, GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, LockMask | mask, GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | mask, - GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | LockMask | mask, - GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod5Mask | LockMask | mask, - GDK_WINDOW_XID (root)); - XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | LockMask | mask, - GDK_WINDOW_XID (root)); - - gdk_flush (); - if (gdk_error_trap_pop ()) - { - DEBUG ( "Error ungrabbing key %d+%d", mask, key); + DEBUG ("Ungrabbing key %d+%d", mask, key); + + gdk_error_trap_push (); + + XUngrabKey (GDK_DISPLAY (), key, mask, GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod5Mask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, LockMask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod5Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root)); + XUngrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root)); + + gdk_flush (); + + if (gdk_error_trap_pop ()) { + DEBUG ("Error ungrabbing key %d+%d", mask, key); } } @@ -530,30 +525,30 @@ ungrab_key (guint key, GdkModifierType mask, const GdkWindow *root) static void grab_key (guint key, GdkModifierType mask, const GdkWindow *root) { - gdk_error_trap_push (); - - DEBUG("Grabbing key %d+%d", mask, key); - - XGrabKey (GDK_DISPLAY (), key, mask, GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod2Mask | mask, GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod5Mask | mask, GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, LockMask | mask, GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | mask, - GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod2Mask | LockMask | mask, - GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod5Mask | LockMask | mask, - GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync); - XGrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | LockMask | mask, - GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync); - - gdk_flush (); - if (gdk_error_trap_pop ()) - { - DEBUG ("Error grabbing key %d+%d", mask, key); + gdk_error_trap_push (); + + DEBUG ("Grabbing key %d+%d", mask, key); + + XGrabKey (GDK_DISPLAY(), key, mask, GDK_WINDOW_XID ( (GdkDrawable*) root), True, + GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod2Mask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root), True, + GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod5Mask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root), True, + GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, LockMask | mask, GDK_WINDOW_XID ( (GdkDrawable*) root), True, + GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root), True, GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod2Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root), True, GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod5Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root), True, GrabModeAsync, GrabModeAsync); + XGrabKey (GDK_DISPLAY (), key, Mod2Mask | Mod5Mask | LockMask | mask, + GDK_WINDOW_XID ( (GdkDrawable*) root), True, GrabModeAsync, GrabModeAsync); + + gdk_flush (); + + if (gdk_error_trap_pop ()) { + DEBUG ("Error grabbing key %d+%d", mask, key); } } diff --git a/sflphone-client-gnome/src/shortcuts.h b/sflphone-client-gnome/src/shortcuts.h index ac71bc8c0b9a768c79809bf7846a16fe6873518b..20703ce8ada5cb94e6d15c3afd709528cf9119f7 100644 --- a/sflphone-client-gnome/src/shortcuts.h +++ b/sflphone-client-gnome/src/shortcuts.h @@ -31,61 +31,14 @@ #ifndef SHORTCUTS_H_ #define SHORTCUTS_H_ -typedef struct -{ - gchar *action; - guint key; - GdkModifierType mask; - void - (*callback) (void); +typedef struct { + gchar *action; + guint key; + GdkModifierType mask; + void + (*callback) (void); } Accelerator; -static void -grab_key (guint key, GdkModifierType mask, const GdkWindow *root); - -static void -ungrab_key (guint key, GdkModifierType mask, const GdkWindow *root); - -static GdkFilterReturn -filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data); - -static void -remove_bindings (); - -static void -create_bindings (); - -static void -pick_up_callback (); - -static void -hang_up_callback (); - -static void -toggle_pick_up_hang_up_callback (); - -static void -toggle_hold_callback (); - -static void -initialize_binding (const gchar* action, guint key, GdkModifierType mask); - -static void -initialize_shortcuts_keys (); - -static void* -get_action_callback (const gchar* action); - -static void -update_bindings_data (guint index, guint key, GdkModifierType mask); - -static void -update_shortcuts_map (const gchar* action, guint value, GdkModifierType mask); - -/* - * "Public" functions - */ - void shortcuts_initialize_bindings (); diff --git a/sflphone-client-gnome/src/sliders.c b/sflphone-client-gnome/src/sliders.c index 65e393c8e787ed1ccb7a22d4377d41d9fd730da3..45ac5645790a7865587ad244b0203bfd6d0fdb75 100644 --- a/sflphone-client-gnome/src/sliders.c +++ b/sflphone-client-gnome/src/sliders.c @@ -40,16 +40,16 @@ GtkWidget * button[2]; // icons GtkWidget * images[2][4]; enum device_t { - SPEAKER = 0, - MIKE, - DEVICE_COUNT + SPEAKER = 0, + MIKE, + DEVICE_COUNT } ; enum volume_t { - MUTED = 0, - VOL25, - VOL50, - VOL75 + MUTED = 0, + VOL25, + VOL50, + VOL75 } ; guint toggledConnId[2]; // The button toggled signal connection ID @@ -58,137 +58,139 @@ guint movedConnId[2]; // The slider_moved signal connection ID void update_icons (int dev) { - float val = gtk_range_get_value(GTK_RANGE(slider[dev])); - if(button[dev]) - { - int icon = MUTED; - if(val == 0) - icon = MUTED; - else if( val < 0.33) - icon = VOL25; - else if( val < 0.66) - icon = VOL50; - else if( val <= 1) - icon = VOL75; - gtk_button_set_image(GTK_BUTTON(button[dev]), GTK_WIDGET(images[dev][icon])); - } + float val = gtk_range_get_value (GTK_RANGE (slider[dev])); + + if (button[dev]) { + int icon = MUTED; + + if (val == 0) + icon = MUTED; + else if (val < 0.33) + icon = VOL25; + else if (val < 0.66) + icon = VOL50; + else if (val <= 1) + icon = VOL75; + + gtk_button_set_image (GTK_BUTTON (button[dev]), GTK_WIDGET (images[dev][icon])); + } } void -slider_moved(GtkRange* range, gchar* device) +slider_moved (GtkRange* range, gchar* device) { - gdouble value = gtk_range_get_value(range); - DEBUG("Volume changed for %s: %f ", device, value); - dbus_set_volume(device, value); - if(strcmp(device, "speaker") == 0) - update_icons(SPEAKER); - else - update_icons(MIKE); + gdouble value = gtk_range_get_value (range); + DEBUG ("Volume changed for %s: %f ", device, value); + dbus_set_volume (device, value); + + if (strcmp (device, "speaker") == 0) + update_icons (SPEAKER); + else + update_icons (MIKE); } static void -mute_cb( GtkWidget *widget, gchar* device ) +mute_cb (GtkWidget *widget, gchar* device) { - int dev; - if(strcmp(device, "speaker") == 0) - dev = SPEAKER; - else - dev = MIKE; - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) - { // Save value - DEBUG("Save"); - value[dev] = gtk_range_get_value(GTK_RANGE(slider[dev])); - dbus_set_volume(device, 0); - } - else - { //Restore value - DEBUG("Restore"); - dbus_set_volume(device, value[dev]); - } - update_icons (dev); + int dev; + + if (strcmp (device, "speaker") == 0) + dev = SPEAKER; + else + dev = MIKE; + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { // Save value + DEBUG ("Save"); + value[dev] = gtk_range_get_value (GTK_RANGE (slider[dev])); + dbus_set_volume (device, 0); + } else { //Restore value + DEBUG ("Restore"); + dbus_set_volume (device, value[dev]); + } + + update_icons (dev); } void -set_slider(const gchar * device, gdouble newval) +set_slider (const gchar * device, gdouble newval) { - int dev; - if(strcmp(device, "speaker") == 0) - dev = SPEAKER; - else - dev = MIKE; + int dev; - gtk_signal_handler_block(GTK_OBJECT(slider[dev]), movedConnId[dev]); - gtk_range_set_value(GTK_RANGE(slider[dev]), newval); - gtk_signal_handler_unblock(slider[dev], movedConnId[dev]); + if (strcmp (device, "speaker") == 0) + dev = SPEAKER; + else + dev = MIKE; - gtk_signal_handler_block(GTK_OBJECT(button[dev]),toggledConnId[dev]); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button[dev]), (newval == 0 ? TRUE: FALSE)); - gtk_signal_handler_unblock(button[dev], toggledConnId[dev]); + gtk_signal_handler_block (GTK_OBJECT (slider[dev]), movedConnId[dev]); + gtk_range_set_value (GTK_RANGE (slider[dev]), newval); + gtk_signal_handler_unblock (slider[dev], movedConnId[dev]); - update_icons (dev); + gtk_signal_handler_block (GTK_OBJECT (button[dev]),toggledConnId[dev]); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button[dev]), (newval == 0 ? TRUE: FALSE)); + gtk_signal_handler_unblock (button[dev], toggledConnId[dev]); + + update_icons (dev); } /** Generates the speaker slider and mute button */ GtkWidget * -create_slider(const gchar * device) +create_slider (const gchar * device) { - // Increment the references count for the images - // When the image is removed from a button, if the ref count = 0, then it is destroyed - // which we don't want ;) - - GtkWidget * ret; - int dev=0; - - if(strcmp(device, "speaker") == 0) - { - dev = SPEAKER; - images[SPEAKER][MUTED] = gtk_image_new_from_file( ICONS_DIR "/speaker.svg"); - images[SPEAKER][VOL25] = gtk_image_new_from_file( ICONS_DIR "/speaker_25.svg"); - images[SPEAKER][VOL50] = gtk_image_new_from_file( ICONS_DIR "/speaker_50.svg"); - images[SPEAKER][VOL75] = gtk_image_new_from_file( ICONS_DIR "/speaker_75.svg"); - g_object_ref(images[SPEAKER][MUTED]); - g_object_ref(images[SPEAKER][VOL25]); - g_object_ref(images[SPEAKER][VOL50]); - g_object_ref(images[SPEAKER][VOL75]); - } - else if (strcmp(device, "mic") == 0) - { - dev = MIKE; - images[MIKE][MUTED] = gtk_image_new_from_file( ICONS_DIR "/mic.svg"); - images[MIKE][VOL25] = gtk_image_new_from_file( ICONS_DIR "/mic_25.svg"); - images[MIKE][VOL50] = gtk_image_new_from_file( ICONS_DIR "/mic_50.svg"); - images[MIKE][VOL75] = gtk_image_new_from_file( ICONS_DIR "/mic_75.svg"); - g_object_ref(images[MIKE][MUTED]); - g_object_ref(images[MIKE][VOL25]); - g_object_ref(images[MIKE][VOL50]); - g_object_ref(images[MIKE][VOL75]); - } - - ret = gtk_hbox_new ( FALSE /*homogeneous*/, 5 /*spacing*/); - gtk_container_set_border_width (GTK_CONTAINER(ret), 5); - + // Increment the references count for the images + // When the image is removed from a button, if the ref count = 0, then it is destroyed + // which we don't want ;) + + GtkWidget * ret; + int dev=0; + + if (strcmp (device, "speaker") == 0) { + dev = SPEAKER; + images[SPEAKER][MUTED] = gtk_image_new_from_file (ICONS_DIR "/speaker.svg"); + images[SPEAKER][VOL25] = gtk_image_new_from_file (ICONS_DIR "/speaker_25.svg"); + images[SPEAKER][VOL50] = gtk_image_new_from_file (ICONS_DIR "/speaker_50.svg"); + images[SPEAKER][VOL75] = gtk_image_new_from_file (ICONS_DIR "/speaker_75.svg"); + g_object_ref (images[SPEAKER][MUTED]); + g_object_ref (images[SPEAKER][VOL25]); + g_object_ref (images[SPEAKER][VOL50]); + g_object_ref (images[SPEAKER][VOL75]); + } else if (strcmp (device, "mic") == 0) { + dev = MIKE; + images[MIKE][MUTED] = gtk_image_new_from_file (ICONS_DIR "/mic.svg"); + images[MIKE][VOL25] = gtk_image_new_from_file (ICONS_DIR "/mic_25.svg"); + images[MIKE][VOL50] = gtk_image_new_from_file (ICONS_DIR "/mic_50.svg"); + images[MIKE][VOL75] = gtk_image_new_from_file (ICONS_DIR "/mic_75.svg"); + g_object_ref (images[MIKE][MUTED]); + g_object_ref (images[MIKE][VOL25]); + g_object_ref (images[MIKE][VOL50]); + g_object_ref (images[MIKE][VOL75]); + } + + ret = gtk_hbox_new (FALSE /*homogeneous*/, 5 /*spacing*/); + gtk_container_set_border_width (GTK_CONTAINER (ret), 5); + #if GTK_CHECK_VERSION(2,12,0) - if( strcmp( device , "speaker") == 0 ) - gtk_widget_set_tooltip_text( GTK_WIDGET( ret ), _("Speakers volume")); - else - gtk_widget_set_tooltip_text( GTK_WIDGET( ret ), _("Mic volume")); + + if (strcmp (device , "speaker") == 0) + gtk_widget_set_tooltip_text (GTK_WIDGET (ret), _ ("Speakers volume")); + else + gtk_widget_set_tooltip_text (GTK_WIDGET (ret), _ ("Mic volume")); + #endif - button[dev] = gtk_toggle_button_new(); - gtk_box_pack_start (GTK_BOX (ret), button[dev], FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); - toggledConnId[dev] = g_signal_connect (G_OBJECT (button[dev]), "toggled", - G_CALLBACK (mute_cb), (gpointer)device); + button[dev] = gtk_toggle_button_new(); + gtk_box_pack_start (GTK_BOX (ret), button[dev], FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + toggledConnId[dev] = g_signal_connect (G_OBJECT (button[dev]), "toggled", + G_CALLBACK (mute_cb), (gpointer) device); - slider[dev] = gtk_hscale_new_with_range(0, 1, 0.05); - gtk_scale_set_draw_value(GTK_SCALE(slider[dev]), FALSE); - //gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED); - movedConnId[dev] = g_signal_connect (G_OBJECT (slider[dev]), "value_changed", - G_CALLBACK (slider_moved), (gpointer)device); - gtk_box_pack_start (GTK_BOX (ret), slider[dev], TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + slider[dev] = gtk_hscale_new_with_range (0, 1, 0.05); + gtk_scale_set_draw_value (GTK_SCALE (slider[dev]), FALSE); + //gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED); + movedConnId[dev] = g_signal_connect (G_OBJECT (slider[dev]), "value_changed", + G_CALLBACK (slider_moved), (gpointer) device); + gtk_box_pack_start (GTK_BOX (ret), slider[dev], TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/); - set_slider(device, dbus_get_volume(device)); + set_slider (device, dbus_get_volume (device)); - return ret; + return ret; } diff --git a/sflphone-client-gnome/src/sliders.h b/sflphone-client-gnome/src/sliders.h index 531a1b22bd9a435e967c270efb39704fd02c7c15..574af9104d14befe50634bc620c39a0aff3fff31 100644 --- a/sflphone-client-gnome/src/sliders.h +++ b/sflphone-client-gnome/src/sliders.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __SLIDERS_H__ #define __SLIDERS_H__ @@ -41,16 +41,16 @@ * @param device Mic or speaker * @return GtkWidget* The slider */ -GtkWidget * create_slider(const gchar * device); +GtkWidget * create_slider (const gchar * device); -/** +/** * This function updates the sliders without sending the value to the server. * This behavior prevents an infinite loop when receiving an updated volume from * the server. * @param device The device slider to update {speaker, mic} * @param value The value to set [0, 1.0] */ -void set_slider(const gchar * device, gdouble value); +void set_slider (const gchar * device, gdouble value); -#endif +#endif diff --git a/sflphone-client-gnome/src/statusicon.c b/sflphone-client-gnome/src/statusicon.c index 72ce9d2e78c2089097606e11702eebacc13968cb..134dfbeeca42a38f59cb0f52e6476bc9708003d4 100644 --- a/sflphone-client-gnome/src/statusicon.c +++ b/sflphone-client-gnome/src/statusicon.c @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,6 +34,7 @@ #include <mainwindow.h> #include <accountlist.h> #include <statusicon.h> +#include <eel-gconf-extensions.h> #if GTK_CHECK_VERSION(2,10,0) GtkStatusIcon *status; @@ -41,147 +42,143 @@ GtkWidget *show_menu_item, *hangup_menu_item; gboolean __minimized = MINIMIZED; void -popup_main_window(void) -{ - if (__POPUP_WINDOW) - { - gtk_widget_show(get_main_window()); - //gtk_window_move(GTK_WINDOW (get_main_window ()), - // dbus_get_window_position_x(), dbus_get_window_position_y()); - set_minimized(FALSE); +popup_main_window (void) +{ + if (__POPUP_WINDOW) { + gtk_widget_show (get_main_window()); + //gtk_window_move(GTK_WINDOW (get_main_window ()), + // dbus_get_window_position_x(), dbus_get_window_position_y()); + set_minimized (FALSE); } } void show_status_hangup_icon() { - if (__POPUP_WINDOW) - { - gtk_widget_show (get_main_window ()); - gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); - set_minimized (FALSE); - } + if (__POPUP_WINDOW) { + gtk_widget_show (get_main_window ()); + gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); + set_minimized (FALSE); + } } void hide_status_hangup_icon() { - if (status) { - DEBUG("Hide Hangup in Systray"); - gtk_widget_hide(GTK_WIDGET(hangup_menu_item)); - } + if (status) { + DEBUG ("Hide Hangup in Systray"); + gtk_widget_hide (GTK_WIDGET (hangup_menu_item)); + } } void -status_quit(void * foo UNUSED) +status_quit (void * foo UNUSED) { - sflphone_quit(); + sflphone_quit(); } void status_hangup() { - sflphone_hang_up(); + sflphone_hang_up(); } void status_icon_unminimize() { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), TRUE); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_menu_item), TRUE); } gboolean main_widget_minimized() { - return __minimized; + return __minimized; } void -show_hide(void) -{ - if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item))) - { - gtk_widget_show(GTK_WIDGET(get_main_window())); - gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); - set_minimized( !MINIMIZED ); - } - else - { - gtk_widget_hide(GTK_WIDGET(get_main_window())); - set_minimized( MINIMIZED ); - } +show_hide (void) +{ + if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (show_menu_item))) { + gtk_widget_show (GTK_WIDGET (get_main_window())); + gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); + set_minimized (!MINIMIZED); + } else { + gtk_widget_hide (GTK_WIDGET (get_main_window())); + set_minimized (MINIMIZED); + } } void -status_click(GtkStatusIcon *status_icon UNUSED, void * foo UNUSED) +status_click (GtkStatusIcon *status_icon UNUSED, void * foo UNUSED) { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), - !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item))); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_menu_item), + !gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (show_menu_item))); } void -menu(GtkStatusIcon *status_icon, guint button, guint activate_time, - GtkWidget * menu) +menu (GtkStatusIcon *status_icon, guint button, guint activate_time, + GtkWidget * menu) { - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, gtk_status_icon_position_menu, - status_icon, button, activate_time); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, + status_icon, button, activate_time); } GtkWidget* create_menu() { - GtkWidget * menu; - GtkWidget * menu_items; - GtkWidget * image; + GtkWidget * menu; + GtkWidget * menu_items; + GtkWidget * image; - menu = gtk_menu_new(); + menu = gtk_menu_new(); - show_menu_item - = gtk_check_menu_item_new_with_mnemonic(_("_Show main window")); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), TRUE); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), show_menu_item); - g_signal_connect(G_OBJECT (show_menu_item), "toggled", - G_CALLBACK (show_hide), - NULL); + show_menu_item + = gtk_check_menu_item_new_with_mnemonic (_ ("_Show main window")); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_menu_item), TRUE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), show_menu_item); + g_signal_connect (G_OBJECT (show_menu_item), "toggled", + G_CALLBACK (show_hide), + NULL); - hangup_menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Hang up")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_hangup.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(hangup_menu_item), image); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), hangup_menu_item); - g_signal_connect(G_OBJECT (hangup_menu_item), "activate", - G_CALLBACK (status_hangup), - NULL); + hangup_menu_item = gtk_image_menu_item_new_with_mnemonic (_ ("_Hang up")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_hangup.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (hangup_menu_item), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), hangup_menu_item); + g_signal_connect (G_OBJECT (hangup_menu_item), "activate", + G_CALLBACK (status_hangup), + NULL); - menu_items = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); + menu_items = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, - get_accel_group()); - g_signal_connect_swapped (G_OBJECT (menu_items), "activate", - G_CALLBACK (status_quit), - NULL); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, + get_accel_group()); + g_signal_connect_swapped (G_OBJECT (menu_items), "activate", + G_CALLBACK (status_quit), + NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); - gtk_widget_show_all(menu); + gtk_widget_show_all (menu); - return menu; + return menu; } void show_status_icon() { - status = gtk_status_icon_new_from_file(LOGO); - g_signal_connect (G_OBJECT (status), "activate", - G_CALLBACK (status_click), - NULL); - g_signal_connect (G_OBJECT (status), "popup-menu", - G_CALLBACK (menu), - create_menu()); + status = gtk_status_icon_new_from_file (LOGO); + g_signal_connect (G_OBJECT (status), "activate", + G_CALLBACK (status_click), + NULL); + g_signal_connect (G_OBJECT (status), "popup-menu", + G_CALLBACK (menu), + create_menu()); - statusicon_set_tooltip(); + statusicon_set_tooltip(); } -void hide_status_icon (void) { +void hide_status_icon (void) +{ g_object_unref (status); status = NULL; @@ -191,52 +188,52 @@ void hide_status_icon (void) { void statusicon_set_tooltip() { - int count; - gchar *tip; + int count; + gchar *tip; - if(status) { + if (status) { - // Add a tooltip to the system tray icon - count = account_list_get_registered_accounts(); - tip = g_markup_printf_escaped("%s - %s", _("SFLphone"), - g_markup_printf_escaped(n_("%i active account", "%i active accounts", count), count)); - gtk_status_icon_set_tooltip(status, tip); - g_free(tip); + // Add a tooltip to the system tray icon + count = account_list_get_registered_accounts(); + tip = g_markup_printf_escaped ("%s - %s", _ ("SFLphone"), + g_markup_printf_escaped (n_ ("%i active account", "%i active accounts", count), count)); + gtk_status_icon_set_tooltip (status, tip); + g_free (tip); - } + } } void -status_tray_icon_blink(gboolean active) +status_tray_icon_blink (gboolean active) { - if (status) { - // Set a different icon to notify of an event - active ? gtk_status_icon_set_from_file(status, LOGO_NOTIF) - : gtk_status_icon_set_from_file(status, LOGO); - } + if (status) { + // Set a different icon to notify of an event + active ? gtk_status_icon_set_from_file (status, LOGO_NOTIF) + : gtk_status_icon_set_from_file (status, LOGO); + } } void -status_tray_icon_online(gboolean online) +status_tray_icon_online (gboolean online) { - if (status) { - // Set a different icon to notify of an event - online ? gtk_status_icon_set_from_file(status, LOGO) - : gtk_status_icon_set_from_file(status, LOGO_OFFLINE); - } + if (status) { + // Set a different icon to notify of an event + online ? gtk_status_icon_set_from_file (status, LOGO) + : gtk_status_icon_set_from_file (status, LOGO_OFFLINE); + } } GtkStatusIcon* -get_status_icon(void) +get_status_icon (void) { - return status; + return status; } void -set_minimized(gboolean state) +set_minimized (gboolean state) { - __minimized = state; - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), !state); + __minimized = state; + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_menu_item), !state); } #endif diff --git a/sflphone-client-gnome/src/statusicon.h b/sflphone-client-gnome/src/statusicon.h index ad9303d360ade39150b5b4dcbccc34ecdcb2c714..951276cfeaef4f739f7ccbfce2637cb24018e9b2 100644 --- a/sflphone-client-gnome/src/statusicon.h +++ b/sflphone-client-gnome/src/statusicon.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,7 +28,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __STATUSICON_H__ #define __STATUSICON_H__ @@ -36,7 +36,7 @@ #include <gtk/gtk.h> #include <sflphone_const.h> -/** +/** * @file statusicon.h * @brief The status icon in the system tray. */ @@ -58,18 +58,18 @@ void show_status_icon (); void hide_status_icon (); /** - * Set the menu active - */ + * Set the menu active + */ void status_icon_unminimize(); /** - * Show hangup icon + * Show hangup icon */ void show_status_hangup_icon(); /** - * Show hangup icon + * Show hangup icon */ void hide_status_hangup_icon(); @@ -87,26 +87,28 @@ gboolean main_widget_minimized(); * @param state TRUE if the main window is minimized * FALSE otherwise */ -void set_minimized( gboolean state ); +void set_minimized (gboolean state); /** * Make the system tray icon blink on incoming call * @return active TRUE to make it blink * FALSE to make it stop */ -void status_tray_icon_blink( gboolean active ); +void status_tray_icon_blink (gboolean active); /** * Accessor * @return GtkStatusIcon* The status icon */ -GtkStatusIcon* get_status_icon( void ); +GtkStatusIcon* get_status_icon (void); /** * Attach a tooltip to the status icon */ void statusicon_set_tooltip (void); +void status_tray_icon_online (gboolean online); + #endif // GTK_CHECK_VERSION #endif diff --git a/sflphone-client-gnome/src/toolbar.c b/sflphone-client-gnome/src/toolbar.c index a9373cdcafc43345a5c52ea6502283fb9b82da22..95713da293b7ea4c4a6f85556f40cd4fdae37a62 100644 --- a/sflphone-client-gnome/src/toolbar.c +++ b/sflphone-client-gnome/src/toolbar.c @@ -32,63 +32,59 @@ #include <contacts/addressbook.h> - static void -call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED) +static void +call_mailbox (GtkWidget* widget UNUSED, gpointer data UNUSED) { account_t* current; callable_obj_t *mailbox_call; gchar *to, *from, *account_id; current = account_list_get_current (); - if( current == NULL ) // Should not happens + + if (current == NULL) // Should not happens return; - to = g_strdup(g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX)); + to = g_strdup (g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX)); account_id = g_strdup (current->accountID); - create_new_call (CALL, CALL_STATE_DIALING, "", account_id, _("Voicemail"), to, &mailbox_call); - DEBUG("Call: TO : %s" , mailbox_call->_peer_number); - calllist_add( current_calls , mailbox_call ); - calltree_add_call( current_calls, mailbox_call, NULL); + create_new_call (CALL, CALL_STATE_DIALING, "", account_id, _ ("Voicemail"), to, &mailbox_call); + DEBUG ("Call: TO : %s" , mailbox_call->_peer_number); + calllist_add (current_calls , mailbox_call); + calltree_add_call (current_calls, mailbox_call, NULL); update_actions(); - sflphone_place_call( mailbox_call ); - calltree_display(current_calls); + sflphone_place_call (mailbox_call); + calltree_display (current_calls); } /** * Make a call */ - static void -call_button( GtkWidget *widget UNUSED, gpointer data UNUSED) +static void +call_button (GtkWidget *widget UNUSED, gpointer data UNUSED) { callable_obj_t * selectedCall; callable_obj_t* new_call; - selectedCall = calltab_get_selected_call(active_calltree); + selectedCall = calltab_get_selected_call (active_calltree); - if(calllist_get_size(current_calls)>0) + if (calllist_get_size (current_calls) >0) sflphone_pick_up(); - else if(calllist_get_size(active_calltree) > 0){ - if( selectedCall) - { + else if (calllist_get_size (active_calltree) > 0) { + if (selectedCall) { create_new_call (CALL, CALL_STATE_DIALING, "", "", "", selectedCall->_peer_number, &new_call); - calllist_add(current_calls, new_call); - calltree_add_call(current_calls, new_call, NULL); - sflphone_place_call(new_call); + calllist_add (current_calls, new_call); + calltree_add_call (current_calls, new_call, NULL); + sflphone_place_call (new_call); calltree_display (current_calls); - } - else - { + } else { sflphone_new_call(); - calltree_display(current_calls); + calltree_display (current_calls); } - } - else - { + } else { sflphone_new_call(); - calltree_display(current_calls); + calltree_display (current_calls); } } diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 44099f19435d968dd5a4f1aa736901d95815df2a..bfba38e43f6c871be6a209342faea0287f8a661e 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -37,11 +37,16 @@ #include <string.h> #include <glib/gprintf.h> #include <libgnome/gnome-help.h> -#include <uimanager.h> -#include <statusicon.h> +#include <eel-gconf-extensions.h> +#include "uimanager.h" +#include "statusicon.h" +#include "contacts/addressbook.h" +#include "accountlist.h" +#include "config/accountlistconfigdialog.h" + +void show_edit_number (callable_obj_t *call); static GtkWidget *toolbar; -static GtkWidget *toolbarWindows; guint transfertButtonConnId; //The button toggled signal connection ID guint recordButtonConnId; //The button toggled signal connection ID @@ -66,694 +71,666 @@ GtkWidget * voicemailToolbar; GtkWidget * editable_num; GtkDialog * edit_dialog; -enum -{ - CALLTREE_CALLS, CALLTREE_HISTORY, CALLTREE_CONTACTS +enum { + CALLTREE_CALLS, CALLTREE_HISTORY, CALLTREE_CONTACTS }; static gboolean -is_inserted(GtkWidget* button, GtkWidget *current_toolbar) +is_inserted (GtkWidget* button, GtkWidget *current_toolbar) { - return (GTK_WIDGET (button)->parent == GTK_WIDGET (current_toolbar)); + return (GTK_WIDGET (button)->parent == GTK_WIDGET (current_toolbar)); } void update_actions() { - DEBUG("Update action"); + DEBUG ("Update action"); - gtk_action_set_sensitive(GTK_ACTION (newCallAction), TRUE); - gtk_action_set_sensitive(GTK_ACTION (pickUpAction), FALSE); - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), FALSE); + gtk_action_set_sensitive (GTK_ACTION (newCallAction), TRUE); + gtk_action_set_sensitive (GTK_ACTION (pickUpAction), FALSE); + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), FALSE); - g_object_ref(hangUpWidget); - g_object_ref(recordWidget); - g_object_ref(holdToolbar); - g_object_ref(offHoldToolbar); - g_object_ref(contactButton); - g_object_ref(historyButton); - g_object_ref(transferToolbar); - g_object_ref(voicemailToolbar); + g_object_ref (hangUpWidget); + g_object_ref (recordWidget); + g_object_ref (holdToolbar); + g_object_ref (offHoldToolbar); + g_object_ref (contactButton); + g_object_ref (historyButton); + g_object_ref (transferToolbar); + g_object_ref (voicemailToolbar); - if (is_inserted(GTK_WIDGET(hangUpWidget), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (hangUpWidget)); + if (is_inserted (GTK_WIDGET (hangUpWidget), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (hangUpWidget)); } - if (is_inserted(GTK_WIDGET(recordWidget), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (recordWidget)); + if (is_inserted (GTK_WIDGET (recordWidget), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (recordWidget)); } - if (is_inserted(GTK_WIDGET(transferToolbar), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), - GTK_WIDGET (transferToolbar)); + if (is_inserted (GTK_WIDGET (transferToolbar), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), + GTK_WIDGET (transferToolbar)); } - if (is_inserted(GTK_WIDGET(historyButton), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (historyButton)); + if (is_inserted (GTK_WIDGET (historyButton), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (historyButton)); } - if (is_inserted(GTK_WIDGET(contactButton), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (contactButton)); + if (is_inserted (GTK_WIDGET (contactButton), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (contactButton)); } - if (is_inserted(GTK_WIDGET (voicemailToolbar), GTK_WIDGET (toolbar))) - { - gtk_container_remove(GTK_CONTAINER (toolbar), - GTK_WIDGET (voicemailToolbar)); + if (is_inserted (GTK_WIDGET (voicemailToolbar), GTK_WIDGET (toolbar))) { + gtk_container_remove (GTK_CONTAINER (toolbar), + GTK_WIDGET (voicemailToolbar)); } - gtk_widget_set_sensitive(GTK_WIDGET (holdMenu), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET (offHoldToolbar), FALSE); - gtk_action_set_sensitive(GTK_ACTION (recordAction), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET (recordWidget), FALSE); - gtk_action_set_sensitive(GTK_ACTION (copyAction), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(contactButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(historyButton), FALSE); - gtk_widget_set_tooltip_text(GTK_WIDGET (contactButton), - _("No address book selected")); - - if (is_inserted(GTK_WIDGET (holdToolbar), GTK_WIDGET (toolbar))) - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (holdToolbar)); - if (is_inserted(GTK_WIDGET (offHoldToolbar), GTK_WIDGET (toolbar))) - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (offHoldToolbar)); - - if (is_inserted(GTK_WIDGET (newCallWidget), GTK_WIDGET (toolbar))) - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (newCallWidget)); - if (is_inserted(GTK_WIDGET (pickUpWidget), GTK_WIDGET (toolbar))) - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (pickUpWidget)); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (newCallWidget), 0); - - - if (eel_gconf_get_integer (HISTORY_ENABLED)) { - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (historyButton), -1); - gtk_widget_set_sensitive(GTK_WIDGET(historyButton), TRUE); - } - // If addressbook support has been enabled and all addressbooks are loaded, display the icon - if (addressbook_is_enabled() && addressbook_is_ready()) - { - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (contactButton), - -1); - // Make the icon clickable only if at least one address book is active - if (addressbook_is_active()) - { - gtk_widget_set_sensitive(GTK_WIDGET(contactButton), TRUE); - gtk_widget_set_tooltip_text(GTK_WIDGET (contactButton), - _("Address book")); - } - } + gtk_widget_set_sensitive (GTK_WIDGET (holdMenu), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (offHoldToolbar), FALSE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (recordWidget), FALSE); + gtk_action_set_sensitive (GTK_ACTION (copyAction), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (contactButton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (historyButton), FALSE); + gtk_widget_set_tooltip_text (GTK_WIDGET (contactButton), + _ ("No address book selected")); - // g_signal_handler_block (GTK_OBJECT (recordWidget), recordButtonConnId); - // gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); - // g_signal_handler_unblock ( GTK_OBJECT (recordWidget), recordButtonConnId); - - callable_obj_t * selectedCall = calltab_get_selected_call(active_calltree); - conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree); - - if (selectedCall) - { - // update icon in systray - show_status_hangup_icon(); - - gtk_action_set_sensitive(GTK_ACTION (copyAction), TRUE); - - switch (selectedCall->_state) - { - case CALL_STATE_INCOMING: - // Make the button toolbar clickable - gtk_action_set_sensitive(GTK_ACTION (pickUpAction), TRUE); - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - // Replace the dial button with the hangup button - g_object_ref(newCallWidget); - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET(newCallWidget)); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (pickUpWidget), - 0); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), - 1); - break; - case CALL_STATE_HOLD: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdMenu), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (offHoldToolbar), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (newCallWidget), TRUE); - // Replace the hold button with the off-hold button - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), - 1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM (offHoldToolbar), 2); - break; - case CALL_STATE_RINGING: - gtk_action_set_sensitive(GTK_ACTION (pickUpAction), TRUE); - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), - 1); - break; - case CALL_STATE_DIALING: - gtk_action_set_sensitive(GTK_ACTION(pickUpAction), TRUE); - if (active_calltree == current_calls) - gtk_action_set_sensitive(GTK_ACTION(hangUpAction), TRUE); - //gtk_action_set_sensitive( GTK_ACTION(newCallMenu),TRUE); - g_object_ref(newCallWidget); - gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (newCallWidget)); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (pickUpWidget), 0); - if (active_calltree == current_calls) - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - break; - case CALL_STATE_CURRENT: - case CALL_STATE_RECORD: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_widget_set_sensitive(GTK_WIDGET (holdMenu), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (transferToolbar), TRUE); - gtk_action_set_sensitive(GTK_ACTION (recordAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (transferToolbar), 3); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 4); - gtk_signal_handler_block (GTK_OBJECT (transferToolbar), transfertButtonConnId); - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON (transferToolbar), FALSE); - gtk_signal_handler_unblock (transferToolbar, transfertButtonConnId); - break; - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - gtk_action_set_sensitive(GTK_ACTION(hangUpAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - break; - case CALL_STATE_TRANSFERT: - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (transferToolbar), 2); - gtk_signal_handler_block (GTK_OBJECT (transferToolbar), transfertButtonConnId); - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON (transferToolbar), TRUE); - gtk_signal_handler_unblock (transferToolbar, transfertButtonConnId); - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdMenu), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (transferToolbar), TRUE); - break; - default: - WARN("Should not happen in update_actions()!"); - break; - } - } - else if (selectedConf) - { + if (is_inserted (GTK_WIDGET (holdToolbar), GTK_WIDGET (toolbar))) + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (holdToolbar)); - // update icon in systray - show_status_hangup_icon(); + if (is_inserted (GTK_WIDGET (offHoldToolbar), GTK_WIDGET (toolbar))) + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (offHoldToolbar)); - switch (selectedConf->_state) { + if (is_inserted (GTK_WIDGET (newCallWidget), GTK_WIDGET (toolbar))) + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (newCallWidget)); - case CONFERENCE_STATE_ACTIVE_ATACHED: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - gtk_action_set_sensitive(GTK_ACTION (recordAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); - break; + if (is_inserted (GTK_WIDGET (pickUpWidget), GTK_WIDGET (toolbar))) + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (pickUpWidget)); - case CONFERENCE_STATE_ACTIVE_DETACHED: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - gtk_action_set_sensitive(GTK_ACTION (recordAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); - break; + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (newCallWidget), 0); - case CONFERENCE_STATE_RECORD: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (holdToolbar), TRUE); - gtk_action_set_sensitive(GTK_ACTION (recordAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); - break; - case CONFERENCE_STATE_HOLD: - gtk_action_set_sensitive(GTK_ACTION (hangUpAction), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET (offHoldToolbar), TRUE); - gtk_widget_set_sensitive(GTK_ACTION (recordAction), TRUE); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (offHoldToolbar), 2); - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); - break; + if (eel_gconf_get_integer (HISTORY_ENABLED)) { + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (historyButton), -1); + gtk_widget_set_sensitive (GTK_WIDGET (historyButton), TRUE); + } - default: - WARN("Should not happen in update_action()!"); - break; + // If addressbook support has been enabled and all addressbooks are loaded, display the icon + if (addressbook_is_enabled() && addressbook_is_ready()) { + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (contactButton), + -1); + + // Make the icon clickable only if at least one address book is active + if (addressbook_is_active()) { + gtk_widget_set_sensitive (GTK_WIDGET (contactButton), TRUE); + gtk_widget_set_tooltip_text (GTK_WIDGET (contactButton), + _ ("Address book")); + } + } + + // g_signal_handler_block (GTK_OBJECT (recordWidget), recordButtonConnId); + // gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); + // g_signal_handler_unblock ( GTK_OBJECT (recordWidget), recordButtonConnId); + + callable_obj_t * selectedCall = calltab_get_selected_call (active_calltree); + conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree); + + if (selectedCall) { + // update icon in systray + show_status_hangup_icon(); + + gtk_action_set_sensitive (GTK_ACTION (copyAction), TRUE); + + switch (selectedCall->_state) { + case CALL_STATE_INCOMING: + // Make the button toolbar clickable + gtk_action_set_sensitive (GTK_ACTION (pickUpAction), TRUE); + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + // Replace the dial button with the hangup button + g_object_ref (newCallWidget); + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (newCallWidget)); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (pickUpWidget), + 0); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), + 1); + break; + case CALL_STATE_HOLD: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdMenu), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (offHoldToolbar), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (newCallWidget), TRUE); + // Replace the hold button with the off-hold button + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), + 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), + GTK_TOOL_ITEM (offHoldToolbar), 2); + break; + case CALL_STATE_RINGING: + gtk_action_set_sensitive (GTK_ACTION (pickUpAction), TRUE); + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), + 1); + break; + case CALL_STATE_DIALING: + gtk_action_set_sensitive (GTK_ACTION (pickUpAction), TRUE); + + if (active_calltree == current_calls) + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + + //gtk_action_set_sensitive( GTK_ACTION(newCallMenu),TRUE); + g_object_ref (newCallWidget); + gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (newCallWidget)); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (pickUpWidget), 0); + + if (active_calltree == current_calls) + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + + break; + case CALL_STATE_CURRENT: + case CALL_STATE_RECORD: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_widget_set_sensitive (GTK_WIDGET (holdMenu), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (transferToolbar), TRUE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (transferToolbar), 3); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 4); + gtk_signal_handler_block (GTK_OBJECT (transferToolbar), transfertButtonConnId); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (transferToolbar), FALSE); + gtk_signal_handler_unblock (transferToolbar, transfertButtonConnId); + break; + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + break; + case CALL_STATE_TRANSFERT: + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (transferToolbar), 2); + gtk_signal_handler_block (GTK_OBJECT (transferToolbar), transfertButtonConnId); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (transferToolbar), TRUE); + gtk_signal_handler_unblock (transferToolbar, transfertButtonConnId); + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdMenu), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (transferToolbar), TRUE); + break; + default: + WARN ("Should not happen in update_actions()!"); + break; + } + } else if (selectedConf) { + + // update icon in systray + show_status_hangup_icon(); + + switch (selectedConf->_state) { + + case CONFERENCE_STATE_ACTIVE_ATACHED: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), TRUE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); + break; + + case CONFERENCE_STATE_ACTIVE_DETACHED: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), TRUE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); + break; + + case CONFERENCE_STATE_RECORD: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (holdToolbar), TRUE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (holdToolbar), 2); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); + break; + + case CONFERENCE_STATE_HOLD: + gtk_action_set_sensitive (GTK_ACTION (hangUpAction), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (offHoldToolbar), TRUE); + gtk_action_set_sensitive (GTK_ACTION (recordAction), TRUE); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (hangUpWidget), 1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (offHoldToolbar), 2); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (recordWidget), 3); + break; + + default: + WARN ("Should not happen in update_action()!"); + break; } } - else - { + else { - // update icon in systray - hide_status_hangup_icon(); + // update icon in systray + hide_status_hangup_icon(); - if (account_list_get_size() > 0 && current_account_has_mailbox()) - { - gtk_toolbar_insert(GTK_TOOLBAR (toolbar), - GTK_TOOL_ITEM (voicemailToolbar), -2); - update_voicemail_status(); + if (account_list_get_size() > 0 && current_account_has_mailbox()) { + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), + GTK_TOOL_ITEM (voicemailToolbar), -2); + update_voicemail_status(); } } } void -update_voicemail_status(void) +update_voicemail_status (void) { - gchar *messages = ""; - messages = g_markup_printf_escaped(_("Voicemail (%i)"), - current_account_get_message_number()); - (current_account_has_new_message()) ? gtk_tool_button_set_icon_name( - GTK_TOOL_BUTTON (voicemailToolbar), "mail-message-new") - : gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (voicemailToolbar), - "mail-read"); - gtk_tool_button_set_label(GTK_TOOL_BUTTON (voicemailToolbar), messages); - g_free(messages); + gchar *messages = ""; + messages = g_markup_printf_escaped (_ ("Voicemail (%i)"), + current_account_get_message_number()); + (current_account_has_new_message()) ? gtk_tool_button_set_icon_name ( + GTK_TOOL_BUTTON (voicemailToolbar), "mail-message-new") + : gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (voicemailToolbar), + "mail-read"); + gtk_tool_button_set_label (GTK_TOOL_BUTTON (voicemailToolbar), messages); + g_free (messages); } static void -volume_bar_cb(GtkToggleAction *togglemenuitem, gpointer user_data) +volume_bar_cb (GtkToggleAction *togglemenuitem, gpointer user_data UNUSED) { - gboolean toggled = gtk_toggle_action_get_active(togglemenuitem); - if (toggled == SHOW_VOLUME) - return; - main_window_volume_controls(toggled); - if (toggled || SHOW_VOLUME) - eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, toggled); + gboolean toggled = gtk_toggle_action_get_active (togglemenuitem); + + if (toggled == SHOW_VOLUME) + return; + + main_window_volume_controls (toggled); + + if (toggled || SHOW_VOLUME) + eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, toggled); } static void -dialpad_bar_cb(GtkToggleAction *togglemenuitem, gpointer user_data) +dialpad_bar_cb (GtkToggleAction *togglemenuitem, gpointer user_data UNUSED) { - gboolean toggled = gtk_toggle_action_get_active (togglemenuitem); - gboolean conf_dialpad = eel_gconf_get_boolean (CONF_SHOW_DIALPAD); - if (toggled == conf_dialpad) - return; - main_window_dialpad (toggled); - if (toggled || conf_dialpad) - eel_gconf_set_boolean (CONF_SHOW_DIALPAD, toggled); //dbus_set_dialpad (toggled); + gboolean toggled = gtk_toggle_action_get_active (togglemenuitem); + gboolean conf_dialpad = eel_gconf_get_boolean (CONF_SHOW_DIALPAD); + + if (toggled == conf_dialpad) + return; + + main_window_dialpad (toggled); + + if (toggled || conf_dialpad) + eel_gconf_set_boolean (CONF_SHOW_DIALPAD, toggled); //dbus_set_dialpad (toggled); } static void -help_contents_cb(GtkAction *action) +help_contents_cb (GtkAction *action UNUSED) { - GError *error = NULL; + GError *error = NULL; + + gnome_help_display ("sflphone.xml", NULL, &error); - gnome_help_display("sflphone.xml", NULL, &error); - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void -help_about(void * foo UNUSED) +help_about (void * foo UNUSED) { - gchar - *authors[] = - { - "Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>", - "Jean-Philippe Barrette-LaPierre", - "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>", - "Julien Bonjean <julien.bonjean@savoirfairelinux.com>", - "Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>", - "Laurielle Lea", - "Yun Liu <yun.liu@savoirfairelinux.com>", - "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>", - "Yan Morin <yan.morin@savoirfairelinux.com>", - "Jérôme Oufella <jerome.oufella@savoirfairelinux.com>", - "Julien Plissonneau Duquene <julien.plissonneau.duquene@savoirfairelinux.com>", - "Alexandre Savard <alexandre.savard@savoirfairelinux.com>", NULL }; - gchar *artists[] = - { "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>", - "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>", NULL }; - - gtk_show_about_dialog(GTK_WINDOW(get_main_window()), "artists", artists, - "authors", authors, "comments", - _("SFLphone is a VoIP client compatible with SIP and IAX2 protocols."), - "copyright", "Copyright © 2004-2009 Savoir-faire Linux Inc.", "name", - PACKAGE, "title", _("About SFLphone"), "version", VERSION, "website", - "http://www.sflphone.org", NULL); + gchar + *authors[] = { + "Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>", + "Jean-Philippe Barrette-LaPierre", + "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>", + "Julien Bonjean <julien.bonjean@savoirfairelinux.com>", + "Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>", + "Laurielle Lea", + "Yun Liu <yun.liu@savoirfairelinux.com>", + "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>", + "Yan Morin <yan.morin@savoirfairelinux.com>", + "Jérôme Oufella <jerome.oufella@savoirfairelinux.com>", + "Julien Plissonneau Duquene <julien.plissonneau.duquene@savoirfairelinux.com>", + "Alexandre Savard <alexandre.savard@savoirfairelinux.com>", NULL + }; + gchar *artists[] = { "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>", + "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>", NULL + }; + + gtk_show_about_dialog (GTK_WINDOW (get_main_window()), "artists", artists, + "authors", authors, "comments", + _ ("SFLphone is a VoIP client compatible with SIP and IAX2 protocols."), + "copyright", "Copyright © 2004-2009 Savoir-faire Linux Inc.", "name", + PACKAGE, "title", _ ("About SFLphone"), "version", VERSION, "website", + "http://www.sflphone.org", NULL); } /* ----------------------------------------------------------------- */ static void -call_new_call(void * foo UNUSED) +call_new_call (void * foo UNUSED) { - sflphone_new_call(); + sflphone_new_call(); } static void -call_quit(void * foo UNUSED) +call_quit (void * foo UNUSED) { - sflphone_quit(); + sflphone_quit(); } static void -call_minimize(void * foo UNUSED) +call_minimize (void * foo UNUSED) { - if (eel_gconf_get_integer (SHOW_STATUSICON)) { - gtk_widget_hide(GTK_WIDGET( get_main_window() )); - set_minimized(TRUE); - } - else { - sflphone_quit (); + if (eel_gconf_get_integer (SHOW_STATUSICON)) { + gtk_widget_hide (GTK_WIDGET (get_main_window())); + set_minimized (TRUE); + } else { + sflphone_quit (); } } static void -switch_account(GtkWidget* item, gpointer data UNUSED) +switch_account (GtkWidget* item, gpointer data UNUSED) { - account_t* acc = g_object_get_data(G_OBJECT(item), "account"); - DEBUG("%s" , acc->accountID); - account_list_set_current(acc); - status_bar_display_account(); + account_t* acc = g_object_get_data (G_OBJECT (item), "account"); + DEBUG ("%s" , acc->accountID); + account_list_set_current (acc); + status_bar_display_account(); } static void -call_hold(void* foo UNUSED) +call_hold (void* foo UNUSED) { - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - conference_obj_t * selectedConf = calltab_get_selected_conf(); - - if (selectedCall) - { - if (selectedCall->_state == CALL_STATE_HOLD) - { - sflphone_off_hold(); - } - else - { - sflphone_on_hold(); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + conference_obj_t * selectedConf = calltab_get_selected_conf(); + + if (selectedCall) { + if (selectedCall->_state == CALL_STATE_HOLD) { + sflphone_off_hold(); + } else { + sflphone_on_hold(); } - } - else if (selectedConf) - { + } else if (selectedConf) { - switch (selectedConf->_state) - { + switch (selectedConf->_state) { - case CONFERENCE_STATE_HOLD: - { - selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; - sflphone_conference_off_hold(selectedConf); - } - break; + case CONFERENCE_STATE_HOLD: { + selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; + sflphone_conference_off_hold (selectedConf); + } + break; - case CONFERENCE_STATE_ACTIVE_ATACHED: - case CONFERENCE_STATE_ACTIVE_DETACHED: - { - selectedConf->_state = CONFERENCE_STATE_HOLD; - sflphone_conference_on_hold(selectedConf); - } - break; - default: - break; + case CONFERENCE_STATE_ACTIVE_ATACHED: + case CONFERENCE_STATE_ACTIVE_DETACHED: { + selectedConf->_state = CONFERENCE_STATE_HOLD; + sflphone_conference_on_hold (selectedConf); + } + break; + default: + break; } } } static void -conference_hold(void* foo UNUSED) +conference_hold (void* foo UNUSED) { - conference_obj_t * selectedConf = calltab_get_selected_conf(); - - switch (selectedConf->_state) - { - case CONFERENCE_STATE_HOLD: - { - selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; - sflphone_conference_off_hold(selectedConf); - } - break; + conference_obj_t * selectedConf = calltab_get_selected_conf(); - case CONFERENCE_STATE_ACTIVE_ATACHED: - case CONFERENCE_STATE_ACTIVE_DETACHED: - { - selectedConf->_state = CONFERENCE_STATE_HOLD; - sflphone_conference_on_hold(selectedConf); - } - break; - default: - break; + switch (selectedConf->_state) { + case CONFERENCE_STATE_HOLD: { + selectedConf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; + sflphone_conference_off_hold (selectedConf); + } + break; + + case CONFERENCE_STATE_ACTIVE_ATACHED: + case CONFERENCE_STATE_ACTIVE_DETACHED: { + selectedConf->_state = CONFERENCE_STATE_HOLD; + sflphone_conference_on_hold (selectedConf); + } + break; + default: + break; } } static void -call_pick_up(void * foo UNUSED) +call_pick_up (void * foo UNUSED) { - DEBUG("------ call_button -----"); - callable_obj_t * selectedCall; - callable_obj_t* new_call; - - selectedCall = calltab_get_selected_call(active_calltree); - - if (calllist_get_size(current_calls) > 0) - sflphone_pick_up(); - - else if (calllist_get_size(active_calltree) > 0) - { - if (selectedCall) - { - create_new_call(CALL, CALL_STATE_DIALING, "", "", "", - selectedCall->_peer_number, &new_call); - - calllist_add(current_calls, new_call); - calltree_add_call(current_calls, new_call, NULL); - sflphone_place_call(new_call); - calltree_display(current_calls); + DEBUG ("------ call_button -----"); + callable_obj_t * selectedCall; + callable_obj_t* new_call; + + selectedCall = calltab_get_selected_call (active_calltree); + + if (calllist_get_size (current_calls) > 0) + sflphone_pick_up(); + + else if (calllist_get_size (active_calltree) > 0) { + if (selectedCall) { + create_new_call (CALL, CALL_STATE_DIALING, "", "", "", + selectedCall->_peer_number, &new_call); + + calllist_add (current_calls, new_call); + calltree_add_call (current_calls, new_call, NULL); + sflphone_place_call (new_call); + calltree_display (current_calls); + } else { + sflphone_new_call(); + calltree_display (current_calls); } - else - { - sflphone_new_call(); - calltree_display(current_calls); - } - } - else - { - sflphone_new_call(); - calltree_display(current_calls); + } else { + sflphone_new_call(); + calltree_display (current_calls); } } static void -call_hang_up(void) +call_hang_up (void) { - /* - * [#3020] Restore the record toggle button - * We set it to FALSE, as when we hang up a call, the recording is stopped. - */ - gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); - - sflphone_hang_up(); + /* + * [#3020] Restore the record toggle button + * We set it to FALSE, as when we hang up a call, the recording is stopped. + */ + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (recordWidget), FALSE); + + sflphone_hang_up(); } static void -conference_hang_up(void) +conference_hang_up (void) { - sflphone_conference_hang_up(); + sflphone_conference_hang_up(); } static void -call_record(void) +call_record (void) { - sflphone_rec_call(); + sflphone_rec_call(); } static void -call_configuration_assistant(void * foo UNUSED) +call_configuration_assistant (void * foo UNUSED) { #if GTK_CHECK_VERSION(2,10,0) - build_wizard(); + build_wizard(); #endif } static void -remove_from_history(void * foo UNUSED) +remove_from_history (void * foo UNUSED) { - callable_obj_t* c = calltab_get_selected_call(history); - if (c) - { - DEBUG("Remove the call from the history"); - calllist_remove_from_history(c); + callable_obj_t* c = calltab_get_selected_call (history); + + if (c) { + DEBUG ("Remove the call from the history"); + calllist_remove_from_history (c); } } static void -call_back(void * foo UNUSED) +call_back (void * foo UNUSED) { - callable_obj_t *selected_call, *new_call; + callable_obj_t *selected_call, *new_call; - selected_call = calltab_get_selected_call(active_calltree); + selected_call = calltab_get_selected_call (active_calltree); - if (selected_call) - { - create_new_call(CALL, CALL_STATE_DIALING, "", "", - selected_call->_peer_name, selected_call->_peer_number, &new_call); + if (selected_call) { + create_new_call (CALL, CALL_STATE_DIALING, "", "", + selected_call->_peer_name, selected_call->_peer_number, &new_call); - calllist_add(current_calls, new_call); - calltree_add_call(current_calls, new_call, NULL); - sflphone_place_call(new_call); - calltree_display(current_calls); + calllist_add (current_calls, new_call); + calltree_add_call (current_calls, new_call, NULL); + sflphone_place_call (new_call); + calltree_display (current_calls); } } static void -edit_preferences(void * foo UNUSED) +edit_preferences (void * foo UNUSED) { - show_preferences_dialog(); + show_preferences_dialog(); } static void -edit_accounts(void * foo UNUSED) +edit_accounts (void * foo UNUSED) { - show_account_list_config_dialog(); + show_account_list_config_dialog(); } // The menu Edit/Copy should copy the current selected call's number static void -edit_copy(void * foo UNUSED) +edit_copy (void * foo UNUSED) { - GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - gchar * no = NULL; - - if (selectedCall) - { - switch (selectedCall->_state) - { - case CALL_STATE_TRANSFERT: - case CALL_STATE_DIALING: - case CALL_STATE_RINGING: - no = selectedCall->_peer_number; - break; - case CALL_STATE_CURRENT: - case CALL_STATE_HOLD: - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - case CALL_STATE_INCOMING: - default: - no = selectedCall->_peer_number; - break; + GtkClipboard* clip = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + gchar * no = NULL; + + if (selectedCall) { + switch (selectedCall->_state) { + case CALL_STATE_TRANSFERT: + case CALL_STATE_DIALING: + case CALL_STATE_RINGING: + no = selectedCall->_peer_number; + break; + case CALL_STATE_CURRENT: + case CALL_STATE_HOLD: + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + case CALL_STATE_INCOMING: + default: + no = selectedCall->_peer_number; + break; } - DEBUG("Clipboard number: %s\n", no); - gtk_clipboard_set_text(clip, no, strlen(no)); + + DEBUG ("Clipboard number: %s\n", no); + gtk_clipboard_set_text (clip, no, strlen (no)); } } // The menu Edit/Paste should paste the clipboard into the current selected call static void -edit_paste(void * foo UNUSED) +edit_paste (void * foo UNUSED) { - GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - callable_obj_t * selectedCall = calltab_get_selected_call(current_calls); - gchar * no = gtk_clipboard_wait_for_text(clip); - - if (no && selectedCall) - { - switch (selectedCall->_state) - { - case CALL_STATE_TRANSFERT: - case CALL_STATE_DIALING: - // Add the text to the number - { - gchar * before; - before = selectedCall->_peer_number; - DEBUG("TO: %s\n", before); - selectedCall->_peer_number = g_strconcat(before, no, NULL); - - if (selectedCall->_state == CALL_STATE_DIALING) + GtkClipboard* clip = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); + gchar * no = gtk_clipboard_wait_for_text (clip); + + if (no && selectedCall) { + switch (selectedCall->_state) { + case CALL_STATE_TRANSFERT: + case CALL_STATE_DIALING: + // Add the text to the number { - selectedCall->_peer_info = g_strconcat("\"\" <", - selectedCall->_peer_number, ">", NULL); + gchar * before; + before = selectedCall->_peer_number; + DEBUG ("TO: %s\n", before); + selectedCall->_peer_number = g_strconcat (before, no, NULL); + + if (selectedCall->_state == CALL_STATE_DIALING) { + selectedCall->_peer_info = g_strconcat ("\"\" <", + selectedCall->_peer_number, ">", NULL); + } + + calltree_update_call (current_calls, selectedCall, NULL); } - calltree_update_call(current_calls, selectedCall, NULL); - } - break; - case CALL_STATE_RINGING: - case CALL_STATE_INCOMING: - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - case CALL_STATE_HOLD: - { // Create a new call to hold the new text - selectedCall = sflphone_new_call(); - - gchar * before = selectedCall->_peer_number; - selectedCall->_peer_number = g_strconcat(selectedCall->_peer_number, - no, NULL); - DEBUG("TO: %s", selectedCall->_peer_number); - - selectedCall->_peer_info = g_strconcat("\"\" <", - selectedCall->_peer_number, ">", NULL); - - calltree_update_call(current_calls, selectedCall, NULL); - } - break; - case CALL_STATE_CURRENT: - default: - { - unsigned int i; - for (i = 0; i < strlen(no); i++) - { - gchar * oneNo = g_strndup(&no[i], 1); - DEBUG("<%s>", oneNo); - dbus_play_dtmf(oneNo); + break; + case CALL_STATE_RINGING: + case CALL_STATE_INCOMING: + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + case CALL_STATE_HOLD: { // Create a new call to hold the new text + selectedCall = sflphone_new_call(); - gchar * temp = g_strconcat(selectedCall->_peer_number, oneNo, - NULL); - selectedCall->_peer_info = get_peer_info(temp, - selectedCall->_peer_name); - // g_free(temp); - calltree_update_call(current_calls, selectedCall, NULL); + selectedCall->_peer_number = g_strconcat (selectedCall->_peer_number, + no, NULL); + DEBUG ("TO: %s", selectedCall->_peer_number); + selectedCall->_peer_info = g_strconcat ("\"\" <", + selectedCall->_peer_number, ">", NULL); + + calltree_update_call (current_calls, selectedCall, NULL); } - } - break; + break; + case CALL_STATE_CURRENT: + default: { + unsigned int i; + + for (i = 0; i < strlen (no); i++) { + gchar * oneNo = g_strndup (&no[i], 1); + DEBUG ("<%s>", oneNo); + dbus_play_dtmf (oneNo); + + gchar * temp = g_strconcat (selectedCall->_peer_number, oneNo, + NULL); + selectedCall->_peer_info = get_peer_info (temp, + selectedCall->_peer_name); + // g_free(temp); + calltree_update_call (current_calls, selectedCall, NULL); + + } + } + break; } - } - else // There is no current call, create one - { - selectedCall = sflphone_new_call(); - - gchar * before = selectedCall->_peer_number; - selectedCall->_peer_number = g_strconcat(selectedCall->_peer_number, no, - NULL); - g_free(before); - DEBUG("TO: %s", selectedCall->_peer_number); - - g_free(selectedCall->_peer_info); - selectedCall->_peer_info = g_strconcat("\"\" <", - selectedCall->_peer_number, ">", NULL); - calltree_update_call(current_calls, selectedCall, NULL); + } else { // There is no current call, create one + selectedCall = sflphone_new_call(); + + gchar * before = selectedCall->_peer_number; + selectedCall->_peer_number = g_strconcat (selectedCall->_peer_number, no, + NULL); + g_free (before); + DEBUG ("TO: %s", selectedCall->_peer_number); + + g_free (selectedCall->_peer_info); + selectedCall->_peer_info = g_strconcat ("\"\" <", + selectedCall->_peer_number, ">", NULL); + calltree_update_call (current_calls, selectedCall, NULL); } } static void -clear_history(void) +clear_history (void) { - if (calllist_get_size(history) != 0) - { - calllist_clean_history(); + if (calllist_get_size (history) != 0) { + calllist_clean_history(); } } @@ -763,759 +740,698 @@ clear_history(void) static void call_transfer_cb() { - gboolean active = gtk_toggle_tool_button_get_active( - GTK_TOGGLE_TOOL_BUTTON (transferToolbar)); - active ? sflphone_set_transfert() : sflphone_unset_transfert(); + gboolean active = gtk_toggle_tool_button_get_active ( + GTK_TOGGLE_TOOL_BUTTON (transferToolbar)); + active ? sflphone_set_transfert() : sflphone_unset_transfert(); } static void -call_mailbox_cb(void) +call_mailbox_cb (void) { - account_t* current; - callable_obj_t *mailbox_call; - gchar *to, *from, *account_id; - - current = account_list_get_current(); - if (current == NULL) // Should not happens - return; - - to = g_strdup(g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX)); - account_id = g_strdup(current->accountID); - - create_new_call(CALL, CALL_STATE_DIALING, "", account_id, _("Voicemail"), to, - &mailbox_call); - DEBUG("TO : %s" , mailbox_call->_peer_number); - calllist_add(current_calls, mailbox_call); - calltree_add_call(current_calls, mailbox_call, NULL); - update_actions(); - sflphone_place_call(mailbox_call); - calltree_display(current_calls); + account_t* current; + callable_obj_t *mailbox_call; + gchar *to, *account_id; + + current = account_list_get_current(); + + if (current == NULL) // Should not happens + return; + + to = g_strdup (g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX)); + account_id = g_strdup (current->accountID); + + create_new_call (CALL, CALL_STATE_DIALING, "", account_id, _ ("Voicemail"), to, + &mailbox_call); + DEBUG ("TO : %s" , mailbox_call->_peer_number); + calllist_add (current_calls, mailbox_call); + calltree_add_call (current_calls, mailbox_call, NULL); + update_actions(); + sflphone_place_call (mailbox_call); + calltree_display (current_calls); } static void -toggle_history_cb(GtkToggleAction *action, gpointer user_data) +toggle_history_cb (GtkToggleAction *action, gpointer user_data UNUSED) { - gboolean toggle; - toggle = gtk_toggle_action_get_active(action); - (toggle) ? calltree_display(history) : calltree_display(current_calls); + gboolean toggle; + toggle = gtk_toggle_action_get_active (action); + (toggle) ? calltree_display (history) : calltree_display (current_calls); } static void -toggle_addressbook_cb(GtkToggleAction *action, gpointer user_data) +toggle_addressbook_cb (GtkToggleAction *action, gpointer user_data UNUSED) { - gboolean toggle; - toggle = gtk_toggle_action_get_active(action); - (toggle) ? calltree_display(contacts) : calltree_display(current_calls); + gboolean toggle; + toggle = gtk_toggle_action_get_active (action); + (toggle) ? calltree_display (contacts) : calltree_display (current_calls); } -static const GtkActionEntry menu_entries[] = - { - - // Call Menu - { "Call", NULL, N_("Call") }, - { "NewCall", GTK_STOCK_DIAL, N_("_New call"), "<control>N", - N_("Place a new call"), G_CALLBACK (call_new_call) }, - { "PickUp", GTK_STOCK_PICKUP, N_("_Pick up"), NULL, - N_("Answer the call"), G_CALLBACK (call_pick_up) }, - { "HangUp", GTK_STOCK_HANGUP, N_("_Hang up"), "<control>S", - N_("Finish the call"), G_CALLBACK (call_hang_up) }, - { "OnHold", GTK_STOCK_ONHOLD, N_("O_n hold"), "<control>P", - N_("Place the call on hold"), G_CALLBACK (call_hold) }, - { "OffHold", GTK_STOCK_OFFHOLD, N_("O_ff hold"), "<control>P", - N_("Place the call off hold"), G_CALLBACK (call_hold) }, - { "AccountAssistant", NULL, N_("Configuration _Assistant"), NULL, - N_("Run the configuration assistant"), - G_CALLBACK (call_configuration_assistant) }, - { "Voicemail", "mail-read", N_("Voicemail"), NULL, - N_("Call your voicemail"), G_CALLBACK (call_mailbox_cb) }, - { "Close", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", - N_("Minimize to system tray"), G_CALLBACK (call_minimize) }, - { "Quit", GTK_STOCK_CLOSE, N_("_Quit"), "<control>Q", - N_("Quit the program"), G_CALLBACK (call_quit) }, - - // Edit Menu - { "Edit", NULL, N_("_Edit") }, - { "Copy", GTK_STOCK_COPY, N_("_Copy"), "<control>C", - N_("Copy the selection"), G_CALLBACK (edit_copy) }, - { "Paste", GTK_STOCK_PASTE, N_("_Paste"), "<control>V", - N_("Paste the clipboard"), G_CALLBACK (edit_paste) }, - { "ClearHistory", GTK_STOCK_CLEAR, N_("Clear _history"), NULL, - N_("Clear the call history"), G_CALLBACK (clear_history) }, - { "Accounts", NULL, N_("_Accounts"), NULL, N_("Edit your accounts"), - G_CALLBACK (edit_accounts) }, - { "Preferences", GTK_STOCK_PREFERENCES, N_("_Preferences"), NULL, - N_("Change your preferences"), G_CALLBACK (edit_preferences) }, - - // View Menu - { "View", NULL, N_("_View") }, - - // Help menu - { "Help", NULL, N_("_Help") }, - { "HelpContents", GTK_STOCK_HELP, N_("Contents"), "F1", - N_("Open the manual"), G_CALLBACK (help_contents_cb) }, - { "About", GTK_STOCK_ABOUT, NULL, NULL, N_("About this application"), - G_CALLBACK (help_about) } - - }; - -static const GtkToggleActionEntry toggle_menu_entries[] = - { - - { "Transfer", GTK_STOCK_TRANSFER, N_("_Transfer"), "<control>T", - N_("Transfer the call"), NULL }, //G_CALLBACK (call_transfer_cb) }, - { "Record", GTK_STOCK_MEDIA_RECORD, N_("_Record"), "<control>R", - N_("Record the current conversation"), NULL }, // G_CALLBACK (call_record) }, - { "Toolbar", NULL, N_("_Show toolbar"), "<control>T", - N_("Show the toolbar"), NULL }, - { "Dialpad", NULL, N_("_Dialpad"), "<control>D", - N_("Show the dialpad"), G_CALLBACK (dialpad_bar_cb) }, - { "VolumeControls", NULL, N_("_Volume controls"), "<control>V", - N_("Show the volume controls"), G_CALLBACK (volume_bar_cb) }, - { "History", "appointment-soon", N_("_History"), NULL, - N_("Calls history"), G_CALLBACK (toggle_history_cb), FALSE }, - { "Addressbook", GTK_STOCK_ADDRESSBOOK, N_("_Address book"), NULL, - N_("Address book"), G_CALLBACK (toggle_addressbook_cb), FALSE } - - }; +static const GtkActionEntry menu_entries[] = { + + // Call Menu + { "Call", NULL, N_ ("Call"), NULL, NULL, NULL }, + { "NewCall", GTK_STOCK_DIAL, N_ ("_New call"), "<control>N", N_ ("Place a new call"), G_CALLBACK (call_new_call) }, + { "PickUp", GTK_STOCK_PICKUP, N_ ("_Pick up"), NULL, N_ ("Answer the call"), G_CALLBACK (call_pick_up) }, + { "HangUp", GTK_STOCK_HANGUP, N_ ("_Hang up"), "<control>S", N_ ("Finish the call"), G_CALLBACK (call_hang_up) }, + { "OnHold", GTK_STOCK_ONHOLD, N_ ("O_n hold"), "<control>P", N_ ("Place the call on hold"), G_CALLBACK (call_hold) }, + { "OffHold", GTK_STOCK_OFFHOLD, N_ ("O_ff hold"), "<control>P", N_ ("Place the call off hold"), G_CALLBACK (call_hold) }, + { "AccountAssistant", NULL, N_ ("Configuration _Assistant"), NULL, N_ ("Run the configuration assistant"), G_CALLBACK (call_configuration_assistant) }, + { "Voicemail", "mail-read", N_ ("Voicemail"), NULL, N_ ("Call your voicemail"), G_CALLBACK (call_mailbox_cb) }, + { "Close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Minimize to system tray"), G_CALLBACK (call_minimize) }, + { "Quit", GTK_STOCK_CLOSE, N_ ("_Quit"), "<control>Q", N_ ("Quit the program"), G_CALLBACK (call_quit) }, + + // Edit Menu + { "Edit", NULL, N_ ("_Edit"), NULL, NULL, NULL }, + { "Copy", GTK_STOCK_COPY, N_ ("_Copy"), "<control>C", N_ ("Copy the selection"), G_CALLBACK (edit_copy) }, + { "Paste", GTK_STOCK_PASTE, N_ ("_Paste"), "<control>V", N_ ("Paste the clipboard"), G_CALLBACK (edit_paste) }, + { "ClearHistory", GTK_STOCK_CLEAR, N_ ("Clear _history"), NULL, N_ ("Clear the call history"), G_CALLBACK (clear_history) }, + { "Accounts", NULL, N_ ("_Accounts"), NULL, N_ ("Edit your accounts"), G_CALLBACK (edit_accounts) }, + { "Preferences", GTK_STOCK_PREFERENCES, N_ ("_Preferences"), NULL, N_ ("Change your preferences"), G_CALLBACK (edit_preferences) }, + + // View Menu + { "View", NULL, N_ ("_View"), NULL, NULL, NULL }, + + // Help menu + { "Help", NULL, N_ ("_Help"), NULL, NULL, NULL }, + { "HelpContents", GTK_STOCK_HELP, N_ ("Contents"), "F1", N_ ("Open the manual"), G_CALLBACK (help_contents_cb) }, + { "About", GTK_STOCK_ABOUT, NULL, NULL, N_ ("About this application"), G_CALLBACK (help_about) } +}; + +static const GtkToggleActionEntry toggle_menu_entries[] = { + + { "Transfer", GTK_STOCK_TRANSFER, N_ ("_Transfer"), "<control>T", N_ ("Transfer the call"), NULL, TRUE }, + { "Record", GTK_STOCK_MEDIA_RECORD, N_ ("_Record"), "<control>R", N_ ("Record the current conversation"), NULL, TRUE }, + { "Toolbar", NULL, N_ ("_Show toolbar"), "<control>T", N_ ("Show the toolbar"), NULL, TRUE }, + { "Dialpad", NULL, N_ ("_Dialpad"), "<control>D", N_ ("Show the dialpad"), G_CALLBACK (dialpad_bar_cb), TRUE }, + { "VolumeControls", NULL, N_ ("_Volume controls"), "<control>V", N_ ("Show the volume controls"), G_CALLBACK (volume_bar_cb), TRUE }, + { "History", "appointment-soon", N_ ("_History"), NULL, N_ ("Calls history"), G_CALLBACK (toggle_history_cb), FALSE }, + { "Addressbook", GTK_STOCK_ADDRESSBOOK, N_ ("_Address book"), NULL, N_ ("Address book"), G_CALLBACK (toggle_addressbook_cb), FALSE } +}; gboolean -uimanager_new(GtkUIManager **_ui_manager) +uimanager_new (GtkUIManager **_ui_manager) { - GtkUIManager *ui_manager; - GtkActionGroup *action_group; - GtkWidget *window; - gchar *path; - GError *error = NULL; - - window = get_main_window(); - ui_manager = gtk_ui_manager_new(); - - /* Create an accel group for window's shortcuts */ - path = g_build_filename(SFLPHONE_UIDIR_UNINSTALLED, "./ui.xml", NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - { - gtk_ui_manager_add_ui_from_file(ui_manager, path, &error); - - if (error != NULL) - { - g_error_free(error); - return FALSE; + GtkUIManager *ui_manager; + GtkActionGroup *action_group; + GtkWidget *window; + gchar *path; + GError *error = NULL; + + window = get_main_window(); + ui_manager = gtk_ui_manager_new(); + + /* Create an accel group for window's shortcuts */ + path = g_build_filename (SFLPHONE_UIDIR_UNINSTALLED, "./ui.xml", NULL); + + if (g_file_test (path, G_FILE_TEST_EXISTS)) { + gtk_ui_manager_add_ui_from_file (ui_manager, path, &error); + + if (error != NULL) { + g_error_free (error); + return FALSE; } - g_free(path); - } - else - { - path = g_build_filename(SFLPHONE_UIDIR, "./ui.xml", NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - { - gtk_ui_manager_add_ui_from_file(ui_manager, path, &error); - - if (error != NULL) - { - g_error_free(error); - return FALSE; + + g_free (path); + } else { + path = g_build_filename (SFLPHONE_UIDIR, "./ui.xml", NULL); + + if (g_file_test (path, G_FILE_TEST_EXISTS)) { + gtk_ui_manager_add_ui_from_file (ui_manager, path, &error); + + if (error != NULL) { + g_error_free (error); + return FALSE; } - g_free(path); - } - else - return FALSE; + + g_free (path); + } else + return FALSE; } - action_group = gtk_action_group_new("SFLphoneWindowActions"); - // To translate label and tooltip entries - gtk_action_group_set_translation_domain(action_group, "sflphone-client-gnome"); - gtk_action_group_add_actions(action_group, menu_entries, - G_N_ELEMENTS (menu_entries), window); - gtk_action_group_add_toggle_actions(action_group, toggle_menu_entries, - G_N_ELEMENTS (toggle_menu_entries), window); - //gtk_action_group_add_radio_actions (action_group, radio_menu_entries, G_N_ELEMENTS (radio_menu_entries), CALLTREE_CALLS, G_CALLBACK (calltree_switch_cb), window); - gtk_ui_manager_insert_action_group(ui_manager, action_group, 0); - - *_ui_manager = ui_manager; - - return TRUE; + + action_group = gtk_action_group_new ("SFLphoneWindowActions"); + // To translate label and tooltip entries + gtk_action_group_set_translation_domain (action_group, "sflphone-client-gnome"); + gtk_action_group_add_actions (action_group, menu_entries, + G_N_ELEMENTS (menu_entries), window); + gtk_action_group_add_toggle_actions (action_group, toggle_menu_entries, + G_N_ELEMENTS (toggle_menu_entries), window); + //gtk_action_group_add_radio_actions (action_group, radio_menu_entries, G_N_ELEMENTS (radio_menu_entries), CALLTREE_CALLS, G_CALLBACK (calltree_switch_cb), window); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + *_ui_manager = ui_manager; + + return TRUE; } static void -edit_number_cb(GtkWidget *widget UNUSED, gpointer user_data) +edit_number_cb (GtkWidget *widget UNUSED, gpointer user_data) { - show_edit_number((callable_obj_t*) user_data); + show_edit_number ( (callable_obj_t*) user_data); } void -add_registered_accounts_to_menu(GtkWidget *menu) +add_registered_accounts_to_menu (GtkWidget *menu) { - GtkWidget *menu_items; - unsigned int i; - account_t* acc, *current; - gchar* alias; - - menu_items = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - gtk_widget_show(menu_items); - - for (i = 0; i < account_list_get_size(); i++) - { - acc = account_list_get_nth(i); - // Display only the registered accounts - if (g_strcasecmp(account_state_name(acc->state), account_state_name( - ACCOUNT_STATE_REGISTERED)) == 0) - { - alias = g_strconcat(g_hash_table_lookup(acc->properties, - ACCOUNT_ALIAS), " - ", g_hash_table_lookup(acc->properties, - ACCOUNT_TYPE), NULL); - menu_items = gtk_check_menu_item_new_with_mnemonic(alias); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_object_set_data(G_OBJECT( menu_items ), "account", acc); - g_free(alias); - current = account_list_get_current(); - if (current) - { - gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(menu_items), - (g_strcasecmp(acc->accountID, current->accountID) == 0) ? TRUE - : FALSE); + GtkWidget *menu_items; + unsigned int i; + account_t* acc, *current; + gchar* alias; + + menu_items = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + gtk_widget_show (menu_items); + + for (i = 0; i < account_list_get_size(); i++) { + acc = account_list_get_nth (i); + + // Display only the registered accounts + if (g_strcasecmp (account_state_name (acc->state), account_state_name ( + ACCOUNT_STATE_REGISTERED)) == 0) { + alias = g_strconcat (g_hash_table_lookup (acc->properties, + ACCOUNT_ALIAS), " - ", g_hash_table_lookup (acc->properties, + ACCOUNT_TYPE), NULL); + menu_items = gtk_check_menu_item_new_with_mnemonic (alias); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_object_set_data (G_OBJECT (menu_items), "account", acc); + g_free (alias); + current = account_list_get_current(); + + if (current) { + gtk_check_menu_item_set_active ( + GTK_CHECK_MENU_ITEM (menu_items), + (g_strcasecmp (acc->accountID, current->accountID) == 0) ? TRUE + : FALSE); } - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (switch_account), - NULL); - gtk_widget_show(menu_items); + + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (switch_account), + NULL); + gtk_widget_show (menu_items); } // fi } } void -show_popup_menu(GtkWidget *my_widget, GdkEventButton *event) +show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) { - // TODO update the selection to make sure the call under the mouse is the call selected - - // call type boolean - gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record = - FALSE, detach = FALSE; - gboolean accounts = FALSE; - - // conference type boolean - gboolean hangup_conf = FALSE, hold_conf = FALSE; - - callable_obj_t * selectedCall; - conference_obj_t * selectedConf; - - if (calltab_get_selected_type(current_calls) == A_CALL) - { - DEBUG("MENUS: SELECTED A CALL"); - selectedCall = calltab_get_selected_call(current_calls); - - if (selectedCall) - { - copy = TRUE; - switch (selectedCall->_state) - { - case CALL_STATE_INCOMING: - pickup = TRUE; - hangup = TRUE; - detach = TRUE; - break; - case CALL_STATE_HOLD: - hangup = TRUE; - hold = TRUE; - detach = TRUE; - break; - case CALL_STATE_RINGING: - hangup = TRUE; - detach = TRUE; - break; - case CALL_STATE_DIALING: - pickup = TRUE; - hangup = TRUE; - accounts = TRUE; - break; - case CALL_STATE_RECORD: - case CALL_STATE_CURRENT: - hangup = TRUE; - hold = TRUE; - record = TRUE; - detach = TRUE; - break; - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - hangup = TRUE; - break; - default: - WARN("Should not happen in show_popup_menu for calls!") - ; - break; + // TODO update the selection to make sure the call under the mouse is the call selected + + // call type boolean + gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record = + FALSE, detach = FALSE; + gboolean accounts = FALSE; + + // conference type boolean + gboolean hangup_conf = FALSE, hold_conf = FALSE; + + callable_obj_t * selectedCall = NULL; + conference_obj_t * selectedConf; + + if (calltab_get_selected_type (current_calls) == A_CALL) { + DEBUG ("MENUS: SELECTED A CALL"); + selectedCall = calltab_get_selected_call (current_calls); + + if (selectedCall) { + copy = TRUE; + + switch (selectedCall->_state) { + case CALL_STATE_INCOMING: + pickup = TRUE; + hangup = TRUE; + detach = TRUE; + break; + case CALL_STATE_HOLD: + hangup = TRUE; + hold = TRUE; + detach = TRUE; + break; + case CALL_STATE_RINGING: + hangup = TRUE; + detach = TRUE; + break; + case CALL_STATE_DIALING: + pickup = TRUE; + hangup = TRUE; + accounts = TRUE; + break; + case CALL_STATE_RECORD: + case CALL_STATE_CURRENT: + hangup = TRUE; + hold = TRUE; + record = TRUE; + detach = TRUE; + break; + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + hangup = TRUE; + break; + default: + WARN ("Should not happen in show_popup_menu for calls!") + ; + break; } } - } - else - { - DEBUG("MENUS: SELECTED A CONF"); - selectedConf = calltab_get_selected_conf(); - - if (selectedConf) - { - switch (selectedConf->_state) - { - case CONFERENCE_STATE_ACTIVE_ATACHED: - hangup_conf = TRUE; - hold_conf = TRUE; - break; - case CONFERENCE_STATE_ACTIVE_DETACHED: - break; - case CONFERENCE_STATE_HOLD: - hangup_conf = TRUE; - hold_conf = TRUE; - break; - default: - WARN("Should not happen in show_popup_menu for conferences!") - ; - break; + } else { + DEBUG ("MENUS: SELECTED A CONF"); + selectedConf = calltab_get_selected_conf(); + + if (selectedConf) { + switch (selectedConf->_state) { + case CONFERENCE_STATE_ACTIVE_ATACHED: + hangup_conf = TRUE; + hold_conf = TRUE; + break; + case CONFERENCE_STATE_ACTIVE_DETACHED: + break; + case CONFERENCE_STATE_HOLD: + hangup_conf = TRUE; + hold_conf = TRUE; + break; + default: + WARN ("Should not happen in show_popup_menu for conferences!") + ; + break; } } } - GtkWidget *menu; - GtkWidget *image; - int button, event_time; - GtkWidget * menu_items; - - menu = gtk_menu_new(); - //g_signal_connect (menu, "deactivate", - // G_CALLBACK (gtk_widget_destroy), NULL); - if (calltab_get_selected_type(current_calls) == A_CALL) - { - DEBUG("BUILD CALL MENU"); - - if (copy) - { - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, - get_accel_group()); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (edit_copy), - NULL); - gtk_widget_show(menu_items); + GtkWidget *menu; + GtkWidget *image; + int button, event_time; + GtkWidget * menu_items; + + menu = gtk_menu_new(); + + //g_signal_connect (menu, "deactivate", + // G_CALLBACK (gtk_widget_destroy), NULL); + if (calltab_get_selected_type (current_calls) == A_CALL) { + DEBUG ("BUILD CALL MENU"); + + if (copy) { + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, + get_accel_group()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (edit_copy), + NULL); + gtk_widget_show (menu_items); } - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, - get_accel_group()); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (edit_paste), - NULL); - gtk_widget_show(menu_items); - - if (pickup || hangup || hold) - { - menu_items = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - gtk_widget_show(menu_items); + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_PASTE, + get_accel_group()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (edit_paste), + NULL); + gtk_widget_show (menu_items); + + if (pickup || hangup || hold) { + menu_items = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + gtk_widget_show (menu_items); } - if (pickup) - { - - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Pick up")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_accept.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (call_pick_up), - NULL); - gtk_widget_show(menu_items); + if (pickup) { + + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Pick up")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_accept.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (call_pick_up), + NULL); + gtk_widget_show (menu_items); } - if (hangup) - { - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_hangup.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (call_hang_up), - NULL); - gtk_widget_show(menu_items); + if (hangup) { + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Hang up")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_hangup.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (call_hang_up), + NULL); + gtk_widget_show (menu_items); } - if (hold) - { - menu_items = gtk_check_menu_item_new_with_mnemonic(_("On _Hold")); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items), - (selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE)); - g_signal_connect(G_OBJECT (menu_items), "activate", - G_CALLBACK (call_hold), - NULL); - gtk_widget_show(menu_items); + if (hold) { + menu_items = gtk_check_menu_item_new_with_mnemonic (_ ("On _Hold")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_items), + (selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE)); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (call_hold), + NULL); + gtk_widget_show (menu_items); } - if (record) - { - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record")); - image = gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (call_record), - NULL); - gtk_widget_show(menu_items); + if (record) { + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Record")); + image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, + GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (call_record), + NULL); + gtk_widget_show (menu_items); } - } - else - { - DEBUG("BUILD CONFERENCE MENU"); - - if (hangup_conf) - { - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_hangup.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", - G_CALLBACK (conference_hang_up), - NULL); - gtk_widget_show(menu_items); + } else { + DEBUG ("BUILD CONFERENCE MENU"); + + if (hangup_conf) { + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Hang up")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_hangup.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (conference_hang_up), + NULL); + gtk_widget_show (menu_items); } - if (hold_conf) - { - menu_items = gtk_check_menu_item_new_with_mnemonic(_("On _Hold")); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items), - (selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE)); - g_signal_connect(G_OBJECT (menu_items), "activate", - G_CALLBACK (conference_hold), - NULL); - gtk_widget_show(menu_items); + if (hold_conf) { + menu_items = gtk_check_menu_item_new_with_mnemonic (_ ("On _Hold")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_items), + (selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE)); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (conference_hold), + NULL); + gtk_widget_show (menu_items); } } - if (accounts) - { - add_registered_accounts_to_menu(menu); + if (accounts) { + add_registered_accounts_to_menu (menu); } - if (event) - { - button = event->button; - event_time = event->time; - } - else - { - button = 0; - event_time = gtk_get_current_event_time(); + if (event) { + button = event->button; + event_time = event->time; + } else { + button = 0; + event_time = gtk_get_current_event_time(); } - gtk_menu_attach_to_widget(GTK_MENU (menu), my_widget, NULL); - gtk_menu_popup(GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); + gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); } void -show_popup_menu_history(GtkWidget *my_widget, GdkEventButton *event) +show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event) { - gboolean pickup = FALSE; - gboolean remove = FALSE; - gboolean edit = FALSE; - gboolean accounts = FALSE; - - callable_obj_t * selectedCall = calltab_get_selected_call(history); - if (selectedCall) - { - remove = TRUE; - pickup = TRUE; - edit = TRUE; - accounts = TRUE; + gboolean pickup = FALSE; + gboolean remove = FALSE; + gboolean edit = FALSE; + gboolean accounts = FALSE; + + callable_obj_t * selectedCall = calltab_get_selected_call (history); + + if (selectedCall) { + remove = TRUE; + pickup = TRUE; + edit = TRUE; + accounts = TRUE; } - GtkWidget *menu; - GtkWidget *image; - int button, event_time; - GtkWidget * menu_items; + GtkWidget *menu; + GtkWidget *image; + int button, event_time; + GtkWidget * menu_items; - menu = gtk_menu_new(); - //g_signal_connect (menu, "deactivate", - // G_CALLBACK (gtk_widget_destroy), NULL); + menu = gtk_menu_new(); + //g_signal_connect (menu, "deactivate", + // G_CALLBACK (gtk_widget_destroy), NULL); - if (pickup) - { + if (pickup) { - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Call back")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_accept.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM ( menu_items ), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (call_back), NULL); - gtk_widget_show(menu_items); + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Call back")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_accept.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (call_back), NULL); + gtk_widget_show (menu_items); } - menu_items = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - gtk_widget_show(menu_items); - - if (edit) - { - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_EDIT, - get_accel_group()); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (edit_number_cb), selectedCall); - gtk_widget_show(menu_items); - } + menu_items = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + gtk_widget_show (menu_items); - if (remove) - { - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, - get_accel_group()); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate", G_CALLBACK (remove_from_history), NULL); - gtk_widget_show(menu_items); + if (edit) { + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_EDIT, + get_accel_group()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (edit_number_cb), selectedCall); + gtk_widget_show (menu_items); } - if (accounts) - { - add_registered_accounts_to_menu(menu); + if (remove) { + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, + get_accel_group()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", G_CALLBACK (remove_from_history), NULL); + gtk_widget_show (menu_items); } - if (event) - { - button = event->button; - event_time = event->time; + if (accounts) { + add_registered_accounts_to_menu (menu); } - else - { - button = 0; - event_time = gtk_get_current_event_time(); + + if (event) { + button = event->button; + event_time = event->time; + } else { + button = 0; + event_time = gtk_get_current_event_time(); } - gtk_menu_attach_to_widget(GTK_MENU (menu), my_widget, NULL); - gtk_menu_popup(GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); + gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); } void -show_popup_menu_contacts(GtkWidget *my_widget, GdkEventButton *event) +show_popup_menu_contacts (GtkWidget *my_widget, GdkEventButton *event) { - gboolean pickup = FALSE; - gboolean accounts = FALSE; - gboolean edit = FALSE; + gboolean pickup = FALSE; + gboolean accounts = FALSE; + gboolean edit = FALSE; + + callable_obj_t * selectedCall = calltab_get_selected_call (contacts); - callable_obj_t * selectedCall = calltab_get_selected_call(contacts); - if (selectedCall) - { - pickup = TRUE; - accounts = TRUE; - edit = TRUE; + if (selectedCall) { + pickup = TRUE; + accounts = TRUE; + edit = TRUE; } - GtkWidget *menu; - GtkWidget *image; - int button, event_time; - GtkWidget * menu_items; + GtkWidget *menu; + GtkWidget *image; + int button, event_time; + GtkWidget * menu_items; - menu = gtk_menu_new(); - //g_signal_connect (menu, "deactivate", - // G_CALLBACK (gtk_widget_destroy), NULL); + menu = gtk_menu_new(); + //g_signal_connect (menu, "deactivate", + // G_CALLBACK (gtk_widget_destroy), NULL); - if (pickup) - { + if (pickup) { - menu_items = gtk_image_menu_item_new_with_mnemonic(_("_New call")); - image = gtk_image_new_from_file(ICONS_DIR "/icon_accept.svg"); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM ( menu_items ), image); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (call_back), NULL); - gtk_widget_show(menu_items); + menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_New call")); + image = gtk_image_new_from_file (ICONS_DIR "/icon_accept.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (call_back), NULL); + gtk_widget_show (menu_items); } - if (edit) - { - menu_items = gtk_image_menu_item_new_from_stock(GTK_STOCK_EDIT, - get_accel_group()); - gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items); - g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (edit_number_cb), selectedCall); - gtk_widget_show(menu_items); + if (edit) { + menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_EDIT, + get_accel_group()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (edit_number_cb), selectedCall); + gtk_widget_show (menu_items); } - if (accounts) - { - add_registered_accounts_to_menu(menu); + if (accounts) { + add_registered_accounts_to_menu (menu); } - if (event) - { - button = event->button; - event_time = event->time; - } - else - { - button = 0; - event_time = gtk_get_current_event_time(); + if (event) { + button = event->button; + event_time = event->time; + } else { + button = 0; + event_time = gtk_get_current_event_time(); } - gtk_menu_attach_to_widget(GTK_MENU (menu), my_widget, NULL); - gtk_menu_popup(GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); + gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); } static void -ok_cb(GtkWidget *widget UNUSED, gpointer userdata) +ok_cb (GtkWidget *widget UNUSED, gpointer userdata) { - gchar *new_number; - callable_obj_t *modified_call, *original; + gchar *new_number; + callable_obj_t *modified_call, *original; - // Change the number of the selected call before calling - new_number = (gchar*) gtk_entry_get_text(GTK_ENTRY (editable_num)); - original = (callable_obj_t*) userdata; + // Change the number of the selected call before calling + new_number = (gchar*) gtk_entry_get_text (GTK_ENTRY (editable_num)); + original = (callable_obj_t*) userdata; - // Create the new call - create_new_call(CALL, CALL_STATE_DIALING, "", g_strdup(original->_accountID), - original->_peer_name, g_strdup(new_number), &modified_call); + // Create the new call + create_new_call (CALL, CALL_STATE_DIALING, "", g_strdup (original->_accountID), + original->_peer_name, g_strdup (new_number), &modified_call); - // Update the internal data structure and the GUI - calllist_add(current_calls, modified_call); - calltree_add_call(current_calls, modified_call, NULL); - sflphone_place_call(modified_call); - calltree_display(current_calls); + // Update the internal data structure and the GUI + calllist_add (current_calls, modified_call); + calltree_add_call (current_calls, modified_call, NULL); + sflphone_place_call (modified_call); + calltree_display (current_calls); - // Close the contextual menu - gtk_widget_destroy(GTK_WIDGET (edit_dialog)); + // Close the contextual menu + gtk_widget_destroy (GTK_WIDGET (edit_dialog)); } static void -on_delete(GtkWidget * widget) +on_delete (GtkWidget * widget) { - gtk_widget_destroy(widget); + gtk_widget_destroy (widget); } void -show_edit_number(callable_obj_t *call) +show_edit_number (callable_obj_t *call) { - GtkWidget *ok, *hbox, *image; - GdkPixbuf *pixbuf; + GtkWidget *ok, *hbox, *image; + GdkPixbuf *pixbuf; - edit_dialog = GTK_DIALOG (gtk_dialog_new()); + edit_dialog = GTK_DIALOG (gtk_dialog_new()); - // Set window properties - gtk_window_set_default_size(GTK_WINDOW(edit_dialog), 300, 20); - gtk_window_set_title(GTK_WINDOW(edit_dialog), _("Edit phone number")); - gtk_window_set_resizable(GTK_WINDOW (edit_dialog), FALSE); + // Set window properties + gtk_window_set_default_size (GTK_WINDOW (edit_dialog), 300, 20); + gtk_window_set_title (GTK_WINDOW (edit_dialog), _ ("Edit phone number")); + gtk_window_set_resizable (GTK_WINDOW (edit_dialog), FALSE); - g_signal_connect (G_OBJECT (edit_dialog), "delete-event", G_CALLBACK (on_delete), NULL); + g_signal_connect (G_OBJECT (edit_dialog), "delete-event", G_CALLBACK (on_delete), NULL); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (edit_dialog->vbox), hbox, TRUE, TRUE, 0); + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (edit_dialog->vbox), hbox, TRUE, TRUE, 0); - // Set the number to be edited - editable_num = gtk_entry_new(); + // Set the number to be edited + editable_num = gtk_entry_new(); #if GTK_CHECK_VERSION(2,12,0) - gtk_widget_set_tooltip_text(GTK_WIDGET(editable_num), - _("Edit the phone number before making a call")); + gtk_widget_set_tooltip_text (GTK_WIDGET (editable_num), + _ ("Edit the phone number before making a call")); #endif - if (call) - gtk_entry_set_text(GTK_ENTRY(editable_num), g_strdup(call->_peer_number)); - else - ERROR ("This a bug, the call should be defined. menus.c line 1051"); - gtk_box_pack_start(GTK_BOX (hbox), editable_num, TRUE, TRUE, 0); + if (call) + gtk_entry_set_text (GTK_ENTRY (editable_num), g_strdup (call->_peer_number)); + else + ERROR ("This a bug, the call should be defined. menus.c line 1051"); + + gtk_box_pack_start (GTK_BOX (hbox), editable_num, TRUE, TRUE, 0); - // Set a custom image for the button - pixbuf = gdk_pixbuf_new_from_file_at_scale(ICONS_DIR "/outgoing.svg", 32, 32, - TRUE, NULL); - image = gtk_image_new_from_pixbuf(pixbuf); - ok = gtk_button_new(); - gtk_button_set_image(GTK_BUTTON (ok), image); - gtk_box_pack_start(GTK_BOX (hbox), ok, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT (ok), "clicked", G_CALLBACK (ok_cb), call); + // Set a custom image for the button + pixbuf = gdk_pixbuf_new_from_file_at_scale (ICONS_DIR "/outgoing.svg", 32, 32, + TRUE, NULL); + image = gtk_image_new_from_pixbuf (pixbuf); + ok = gtk_button_new(); + gtk_button_set_image (GTK_BUTTON (ok), image); + gtk_box_pack_start (GTK_BOX (hbox), ok, TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (ok), "clicked", G_CALLBACK (ok_cb), call); - gtk_widget_show_all(edit_dialog->vbox); + gtk_widget_show_all (edit_dialog->vbox); - gtk_dialog_run(edit_dialog); + gtk_dialog_run (edit_dialog); } GtkWidget* create_waiting_icon() { - GtkWidget * waiting_icon; - waiting_icon = gtk_image_menu_item_new_with_label(""); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(waiting_icon), - gtk_image_new_from_animation(gdk_pixbuf_animation_new_from_file( - ICONS_DIR "/wait-on.gif", NULL))); - gtk_menu_item_set_right_justified(GTK_MENU_ITEM(waiting_icon), TRUE); - - return waiting_icon; + GtkWidget * waiting_icon; + waiting_icon = gtk_image_menu_item_new_with_label (""); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (waiting_icon), + gtk_image_new_from_animation (gdk_pixbuf_animation_new_from_file ( + ICONS_DIR "/wait-on.gif", NULL))); + gtk_menu_item_set_right_justified (GTK_MENU_ITEM (waiting_icon), TRUE); + + return waiting_icon; } void -create_menus(GtkUIManager *ui_manager, GtkWidget **widget) +create_menus (GtkUIManager *ui_manager, GtkWidget **widget) { - GtkWidget * menu_bar; + GtkWidget * menu_bar; - menu_bar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar"); - pickUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/PickUp"); - newCallAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/NewCall"); - hangUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/HangUp"); - holdMenu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar/CallMenu/OnHoldMenu"); - recordAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/Record"); - copyAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Copy"); - pasteAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Paste"); - volumeToggle = gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/VolumeControls"); + menu_bar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar"); + pickUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/PickUp"); + newCallAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/NewCall"); + hangUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/HangUp"); + holdMenu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar/CallMenu/OnHoldMenu"); + recordAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/Record"); + copyAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Copy"); + pasteAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Paste"); + volumeToggle = gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/VolumeControls"); - // Set the toggle buttons - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Dialpad")), eel_gconf_get_boolean (CONF_SHOW_DIALPAD)); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (volumeToggle), (gboolean) SHOW_VOLUME); + // Set the toggle buttons + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Dialpad")), eel_gconf_get_boolean (CONF_SHOW_DIALPAD)); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (volumeToggle), (gboolean) SHOW_VOLUME); - gtk_action_set_sensitive (GTK_ACTION (volumeToggle), SHOW_ALSA_CONF); + gtk_action_set_sensitive (GTK_ACTION (volumeToggle), SHOW_ALSA_CONF); - // Disable it right now - gtk_action_set_sensitive (GTK_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Toolbar")), FALSE); + // Disable it right now + gtk_action_set_sensitive (GTK_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Toolbar")), FALSE); - waitingLayer = create_waiting_icon (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), waitingLayer); + waitingLayer = create_waiting_icon (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), waitingLayer); - *widget = menu_bar; + *widget = menu_bar; } void -create_toolbar_actions(GtkUIManager *ui_manager, GtkWidget **widget) +create_toolbar_actions (GtkUIManager *ui_manager, GtkWidget **widget) { - toolbar = gtk_ui_manager_get_widget(ui_manager, "/ToolbarActions"); - - holdToolbar = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/OnHoldToolbar"); - offHoldToolbar = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/OffHoldToolbar"); - transferToolbar = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/TransferToolbar"); - voicemailAction = gtk_ui_manager_get_action(ui_manager, - "/ToolbarActions/Voicemail"); - voicemailToolbar = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/VoicemailToolbar"); - newCallWidget = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/NewCallToolbar"); - pickUpWidget = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/PickUpToolbar"); - hangUpWidget = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/HangUpToolbar"); - recordWidget = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/RecordToolbar"); - historyButton = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/HistoryToolbar"); - contactButton = gtk_ui_manager_get_widget(ui_manager, - "/ToolbarActions/AddressbookToolbar"); - - // Set the handler ID for the transfer - transfertButtonConnId - = g_signal_connect (G_OBJECT (transferToolbar), "toggled", G_CALLBACK (call_transfer_cb), NULL); - recordButtonConnId - = g_signal_connect (G_OBJECT (recordWidget), "toggled", G_CALLBACK (call_record), NULL); - active_calltree = current_calls; - - *widget = toolbar; + toolbar = gtk_ui_manager_get_widget (ui_manager, "/ToolbarActions"); + + holdToolbar = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/OnHoldToolbar"); + offHoldToolbar = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/OffHoldToolbar"); + transferToolbar = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/TransferToolbar"); + voicemailAction = gtk_ui_manager_get_action (ui_manager, + "/ToolbarActions/Voicemail"); + voicemailToolbar = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/VoicemailToolbar"); + newCallWidget = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/NewCallToolbar"); + pickUpWidget = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/PickUpToolbar"); + hangUpWidget = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/HangUpToolbar"); + recordWidget = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/RecordToolbar"); + historyButton = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/HistoryToolbar"); + contactButton = gtk_ui_manager_get_widget (ui_manager, + "/ToolbarActions/AddressbookToolbar"); + + // Set the handler ID for the transfer + transfertButtonConnId + = g_signal_connect (G_OBJECT (transferToolbar), "toggled", G_CALLBACK (call_transfer_cb), NULL); + recordButtonConnId + = g_signal_connect (G_OBJECT (recordWidget), "toggled", G_CALLBACK (call_record), NULL); + active_calltree = current_calls; + + *widget = toolbar; } diff --git a/sflphone-client-gnome/src/uimanager.h b/sflphone-client-gnome/src/uimanager.h index 23bebef995e10ce8406c2fa82853faf2dbc62b8d..33bd0279393641c2cb4122c15e75fdcfc77b45f8 100644 --- a/sflphone-client-gnome/src/uimanager.h +++ b/sflphone-client-gnome/src/uimanager.h @@ -44,10 +44,20 @@ GtkAction *volumeToggle; gboolean uimanager_new (GtkUIManager**); -static void show_edit_number (); - void update_voicemail_status (void); +void update_actions (void); + +void show_popup_menu (GtkWidget *my_widget, GdkEventButton *event); + +void show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event); + +void show_popup_menu_contacts (GtkWidget *my_widget, GdkEventButton *event); + +void create_menus (GtkUIManager *ui_manager, GtkWidget **widget); + +void create_toolbar_actions (GtkUIManager *ui_manager, GtkWidget **widget); + G_END_DECLS #endif diff --git a/sflphone-client-gnome/src/widget/gtkscrollbook.c b/sflphone-client-gnome/src/widget/gtkscrollbook.c index 9e9a9f12fd814720012728bed3a0730cb10e8c6f..0b481a5ef179b9577d67d83863dbaa5d9ee1e414 100644 --- a/sflphone-client-gnome/src/widget/gtkscrollbook.c +++ b/sflphone-client-gnome/src/widget/gtkscrollbook.c @@ -25,292 +25,298 @@ */ #include "gtkscrollbook.h" - +#include "sflphone_const.h" static void pidgin_scroll_book_init (PidginScrollBook *scroll_book); static void pidgin_scroll_book_class_init (PidginScrollBookClass *klass); static void pidgin_scroll_book_forall (GtkContainer *c, - gboolean include_internals, - GtkCallback callback, - gpointer user_data); + gboolean include_internals, + GtkCallback callback, + gpointer user_data); GType pidgin_scroll_book_get_type (void) { - static GType scroll_book_type = 0; - - if (!scroll_book_type) - { - static const GTypeInfo scroll_book_info = - { - sizeof (PidginScrollBookClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) pidgin_scroll_book_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PidginScrollBook), - 0, - (GInstanceInitFunc) pidgin_scroll_book_init, - NULL /* value_table */ - }; - - scroll_book_type = g_type_register_static(GTK_TYPE_VBOX, - "PidginScrollBook", - &scroll_book_info, - 0); - } - - return scroll_book_type; + static GType scroll_book_type = 0; + + if (!scroll_book_type) { + static const GTypeInfo scroll_book_info = { + sizeof (PidginScrollBookClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) pidgin_scroll_book_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (PidginScrollBook), + 0, + (GInstanceInitFunc) pidgin_scroll_book_init, + NULL /* value_table */ + }; + + scroll_book_type = g_type_register_static (GTK_TYPE_VBOX, + "PidginScrollBook", + &scroll_book_info, + 0); + } + + return scroll_book_type; } static gboolean -scroll_left_cb(PidginScrollBook *scroll_book) +scroll_left_cb (PidginScrollBook *scroll_book) { - int index; - index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)); + int index; + index = gtk_notebook_get_current_page (GTK_NOTEBOOK (scroll_book->notebook)); + + if (index > 0) + gtk_notebook_set_current_page (GTK_NOTEBOOK (scroll_book->notebook), index - 1); - if (index > 0) - gtk_notebook_set_current_page(GTK_NOTEBOOK(scroll_book->notebook), index - 1); - return TRUE; + return TRUE; } static gboolean -scroll_right_cb(PidginScrollBook *scroll_book) +scroll_right_cb (PidginScrollBook *scroll_book) { - int index, count; - index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)); + int index, count; + index = gtk_notebook_get_current_page (GTK_NOTEBOOK (scroll_book->notebook)); #if GTK_CHECK_VERSION(2,2,0) - count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); + count = gtk_notebook_get_n_pages (GTK_NOTEBOOK (scroll_book->notebook)); #else - count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); + count = g_list_length (GTK_NOTEBOOK (scroll_book->notebook)->children); #endif - if (index + 1 < count) - gtk_notebook_set_current_page(GTK_NOTEBOOK(scroll_book->notebook), index + 1); - return TRUE; + if (index + 1 < count) + gtk_notebook_set_current_page (GTK_NOTEBOOK (scroll_book->notebook), index + 1); + + return TRUE; } static void -refresh_scroll_box(PidginScrollBook *scroll_book, int index, int count) +refresh_scroll_box (PidginScrollBook *scroll_book, int index, int count) { - char *label; - - gtk_widget_show_all(GTK_WIDGET(scroll_book)); - if (count < 1) - gtk_widget_hide_all(scroll_book->hbox); - else { - gtk_widget_show_all(scroll_book->hbox); - if (count == 1) { - gtk_widget_hide(scroll_book->label); - gtk_widget_hide(scroll_book->left_arrow); - gtk_widget_hide(scroll_book->right_arrow); - } - } - - label = g_strdup_printf("<span size='smaller' weight='bold'>(%d/%d)</span>", index+1, count); - gtk_label_set_markup(GTK_LABEL(scroll_book->label), label); - g_free(label); - - if (index == 0) - gtk_widget_set_sensitive(scroll_book->left_arrow, FALSE); - else - gtk_widget_set_sensitive(scroll_book->left_arrow, TRUE); - - - if (index + 1 == count) - gtk_widget_set_sensitive(scroll_book->right_arrow, FALSE); - else - gtk_widget_set_sensitive(scroll_book->right_arrow, TRUE); + char *label; + + gtk_widget_show_all (GTK_WIDGET (scroll_book)); + + if (count < 1) + gtk_widget_hide_all (scroll_book->hbox); + else { + gtk_widget_show_all (scroll_book->hbox); + + if (count == 1) { + gtk_widget_hide (scroll_book->label); + gtk_widget_hide (scroll_book->left_arrow); + gtk_widget_hide (scroll_book->right_arrow); + } + } + + label = g_strdup_printf ("<span size='smaller' weight='bold'>(%d/%d)</span>", index+1, count); + gtk_label_set_markup (GTK_LABEL (scroll_book->label), label); + g_free (label); + + if (index == 0) + gtk_widget_set_sensitive (scroll_book->left_arrow, FALSE); + else + gtk_widget_set_sensitive (scroll_book->left_arrow, TRUE); + + + if (index + 1 == count) + gtk_widget_set_sensitive (scroll_book->right_arrow, FALSE); + else + gtk_widget_set_sensitive (scroll_book->right_arrow, TRUE); } static void -page_count_change_cb(PidginScrollBook *scroll_book) +page_count_change_cb (PidginScrollBook *scroll_book) { - int count; - int index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)); + int count; + int index = gtk_notebook_get_current_page (GTK_NOTEBOOK (scroll_book->notebook)); #if GTK_CHECK_VERSION(2,2,0) - count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); + count = gtk_notebook_get_n_pages (GTK_NOTEBOOK (scroll_book->notebook)); #else - count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); + count = g_list_length (GTK_NOTEBOOK (scroll_book->notebook)->children); #endif - refresh_scroll_box(scroll_book, index, count); + refresh_scroll_box (scroll_book, index, count); } static gboolean -scroll_close_cb(PidginScrollBook *scroll_book) +scroll_close_cb (PidginScrollBook *scroll_book) { - gtk_widget_destroy(gtk_notebook_get_nth_page(GTK_NOTEBOOK(scroll_book->notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)))); - return FALSE; + gtk_widget_destroy (gtk_notebook_get_nth_page (GTK_NOTEBOOK (scroll_book->notebook), gtk_notebook_get_current_page (GTK_NOTEBOOK (scroll_book->notebook)))); + return FALSE; } static void -switch_page_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, PidginScrollBook *scroll_book) +switch_page_cb (GtkNotebook *notebook UNUSED, GtkNotebookPage *page UNUSED, guint page_num, PidginScrollBook *scroll_book) { - int count; + int count; #if GTK_CHECK_VERSION(2,2,0) - count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); + count = gtk_notebook_get_n_pages (GTK_NOTEBOOK (scroll_book->notebook)); #else - count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); + count = g_list_length (GTK_NOTEBOOK (scroll_book->notebook)->children); #endif - refresh_scroll_box(scroll_book, page_num, count); + refresh_scroll_box (scroll_book, page_num, count); } static void -pidgin_scroll_book_add(GtkContainer *container, GtkWidget *widget) +pidgin_scroll_book_add (GtkContainer *container, GtkWidget *widget) { - PidginScrollBook *scroll_book; + PidginScrollBook *scroll_book; - g_return_if_fail(GTK_IS_WIDGET (widget)); - g_return_if_fail (widget->parent == NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (widget->parent == NULL); - scroll_book = PIDGIN_SCROLL_BOOK(container); - scroll_book->children = g_list_append(scroll_book->children, widget); - gtk_widget_show(widget); - gtk_notebook_append_page(GTK_NOTEBOOK(scroll_book->notebook), widget, NULL); - page_count_change_cb(PIDGIN_SCROLL_BOOK(container)); + scroll_book = PIDGIN_SCROLL_BOOK (container); + scroll_book->children = g_list_append (scroll_book->children, widget); + gtk_widget_show (widget); + gtk_notebook_append_page (GTK_NOTEBOOK (scroll_book->notebook), widget, NULL); + page_count_change_cb (PIDGIN_SCROLL_BOOK (container)); } static void -pidgin_scroll_book_remove(GtkContainer *container, GtkWidget *widget) +pidgin_scroll_book_remove (GtkContainer *container, GtkWidget *widget) { - int page; - PidginScrollBook *scroll_book; - g_return_if_fail(GTK_IS_WIDGET(widget)); - - scroll_book = PIDGIN_SCROLL_BOOK(container); - scroll_book->children = g_list_remove(scroll_book->children, widget); - /* gtk_widget_unparent(widget); */ - - page = gtk_notebook_page_num(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget); - if (page >= 0) { - gtk_notebook_remove_page(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), page); - } + int page; + PidginScrollBook *scroll_book; + g_return_if_fail (GTK_IS_WIDGET (widget)); + + scroll_book = PIDGIN_SCROLL_BOOK (container); + scroll_book->children = g_list_remove (scroll_book->children, widget); + /* gtk_widget_unparent(widget); */ + + page = gtk_notebook_page_num (GTK_NOTEBOOK (PIDGIN_SCROLL_BOOK (container)->notebook), widget); + + if (page >= 0) { + gtk_notebook_remove_page (GTK_NOTEBOOK (PIDGIN_SCROLL_BOOK (container)->notebook), page); + } } static void -pidgin_scroll_book_forall(GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) +pidgin_scroll_book_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) { #if 0 - GList *children; + GList *children; #endif - PidginScrollBook *scroll_book; + PidginScrollBook *scroll_book; - g_return_if_fail(GTK_IS_CONTAINER(container)); + g_return_if_fail (GTK_IS_CONTAINER (container)); - scroll_book = PIDGIN_SCROLL_BOOK(container); + scroll_book = PIDGIN_SCROLL_BOOK (container); - if (include_internals) { - (*callback)(scroll_book->hbox, callback_data); - (*callback)(scroll_book->notebook, callback_data); - } + if (include_internals) { + (*callback) (scroll_book->hbox, callback_data); + (*callback) (scroll_book->notebook, callback_data); + } #if 0 - children = scroll_book->children; - - while (children) { - GtkWidget *child; - child = children->data; - children = children->next; - (*callback)(child, callback_data); - } + children = scroll_book->children; + + while (children) { + GtkWidget *child; + child = children->data; + children = children->next; + (*callback) (child, callback_data); + } + #endif } static void pidgin_scroll_book_class_init (PidginScrollBookClass *klass) { - GtkContainerClass *container_class = (GtkContainerClass*)klass; + GtkContainerClass *container_class = (GtkContainerClass*) klass; - container_class->add = pidgin_scroll_book_add; - container_class->remove = pidgin_scroll_book_remove; - container_class->forall = pidgin_scroll_book_forall; + container_class->add = pidgin_scroll_book_add; + container_class->remove = pidgin_scroll_book_remove; + container_class->forall = pidgin_scroll_book_forall; } static gboolean -close_button_left_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label) +close_button_left_cb (GtkWidget *widget UNUSED, GdkEventCrossing *event, GtkLabel *label) { - static GdkCursor *ptr = NULL; - if (ptr == NULL) { - ptr = gdk_cursor_new(GDK_LEFT_PTR); - } - - gtk_label_set_markup(label, "×"); - gdk_window_set_cursor(event->window, ptr); - return FALSE; + static GdkCursor *ptr = NULL; + + if (ptr == NULL) { + ptr = gdk_cursor_new (GDK_LEFT_PTR); + } + + gtk_label_set_markup (label, "×"); + gdk_window_set_cursor (event->window, ptr); + return FALSE; } static gboolean -close_button_entered_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label) +close_button_entered_cb (GtkWidget *widget UNUSED, GdkEventCrossing *event, GtkLabel *label) { - static GdkCursor *hand = NULL; - if (hand == NULL) { - hand = gdk_cursor_new(GDK_HAND2); - } - - gtk_label_set_markup(label, "<u>×</u>"); - gdk_window_set_cursor(event->window, hand); - return FALSE; + static GdkCursor *hand = NULL; + + if (hand == NULL) { + hand = gdk_cursor_new (GDK_HAND2); + } + + gtk_label_set_markup (label, "<u>×</u>"); + gdk_window_set_cursor (event->window, hand); + return FALSE; } static void pidgin_scroll_book_init (PidginScrollBook *scroll_book) { - GtkWidget *eb; - GtkWidget *close_button; + GtkWidget *eb; + GtkWidget *close_button; - scroll_book->hbox = gtk_hbox_new(FALSE, 0); + scroll_book->hbox = gtk_hbox_new (FALSE, 0); - /* Close */ - eb = gtk_event_box_new(); - gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); + /* Close */ + eb = gtk_event_box_new(); + gtk_box_pack_end (GTK_BOX (scroll_book->hbox), eb, FALSE, FALSE, 0); #if GTK_CHECK_VERSION(2,4,0) - gtk_event_box_set_visible_window(GTK_EVENT_BOX(eb), FALSE); + gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb), FALSE); #endif - gtk_widget_set_events(eb, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - close_button = gtk_label_new("×"); - g_signal_connect(G_OBJECT(eb), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_button); - g_signal_connect(G_OBJECT(eb), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_button); - gtk_container_add(GTK_CONTAINER(eb), close_button); - g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_close_cb), scroll_book); - - /* Right arrow */ - eb = gtk_event_box_new(); - gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); - scroll_book->right_arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - gtk_container_add(GTK_CONTAINER(eb), scroll_book->right_arrow); - g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_right_cb), scroll_book); - - /* Count */ - scroll_book->label = gtk_label_new(NULL); - gtk_box_pack_end(GTK_BOX(scroll_book->hbox), scroll_book->label, FALSE, FALSE, 0); - - /* Left arrow */ - eb = gtk_event_box_new(); - gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); - scroll_book->left_arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); - gtk_container_add(GTK_CONTAINER(eb), scroll_book->left_arrow); - g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_left_cb), scroll_book); - - gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->hbox, FALSE, FALSE, 0); - - scroll_book->notebook = gtk_notebook_new(); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(scroll_book->notebook), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(scroll_book->notebook), FALSE); - - gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->notebook, TRUE, TRUE, 0); - - g_signal_connect_swapped(G_OBJECT(scroll_book->notebook), "remove", G_CALLBACK(page_count_change_cb), scroll_book); - g_signal_connect(G_OBJECT(scroll_book->notebook), "switch-page", G_CALLBACK(switch_page_cb), scroll_book); - gtk_widget_show_all(scroll_book->notebook); + gtk_widget_set_events (eb, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + close_button = gtk_label_new ("×"); + g_signal_connect (G_OBJECT (eb), "enter-notify-event", G_CALLBACK (close_button_entered_cb), close_button); + g_signal_connect (G_OBJECT (eb), "leave-notify-event", G_CALLBACK (close_button_left_cb), close_button); + gtk_container_add (GTK_CONTAINER (eb), close_button); + g_signal_connect_swapped (G_OBJECT (eb), "button-press-event", G_CALLBACK (scroll_close_cb), scroll_book); + + /* Right arrow */ + eb = gtk_event_box_new(); + gtk_box_pack_end (GTK_BOX (scroll_book->hbox), eb, FALSE, FALSE, 0); + scroll_book->right_arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (eb), scroll_book->right_arrow); + g_signal_connect_swapped (G_OBJECT (eb), "button-press-event", G_CALLBACK (scroll_right_cb), scroll_book); + + /* Count */ + scroll_book->label = gtk_label_new (NULL); + gtk_box_pack_end (GTK_BOX (scroll_book->hbox), scroll_book->label, FALSE, FALSE, 0); + + /* Left arrow */ + eb = gtk_event_box_new(); + gtk_box_pack_end (GTK_BOX (scroll_book->hbox), eb, FALSE, FALSE, 0); + scroll_book->left_arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (eb), scroll_book->left_arrow); + g_signal_connect_swapped (G_OBJECT (eb), "button-press-event", G_CALLBACK (scroll_left_cb), scroll_book); + + gtk_box_pack_start (GTK_BOX (scroll_book), scroll_book->hbox, FALSE, FALSE, 0); + + scroll_book->notebook = gtk_notebook_new(); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (scroll_book->notebook), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (scroll_book->notebook), FALSE); + + gtk_box_pack_start (GTK_BOX (scroll_book), scroll_book->notebook, TRUE, TRUE, 0); + + g_signal_connect_swapped (G_OBJECT (scroll_book->notebook), "remove", G_CALLBACK (page_count_change_cb), scroll_book); + g_signal_connect (G_OBJECT (scroll_book->notebook), "switch-page", G_CALLBACK (switch_page_cb), scroll_book); + gtk_widget_show_all (scroll_book->notebook); } GtkWidget * pidgin_scroll_book_new() { - return g_object_new(PIDGIN_TYPE_SCROLL_BOOK, NULL); + return g_object_new (PIDGIN_TYPE_SCROLL_BOOK, NULL); } diff --git a/sflphone-client-gnome/src/widget/gtkscrollbook.h b/sflphone-client-gnome/src/widget/gtkscrollbook.h index 859488c14510f4487fe64296ce5301b516cf9536..a012f7825923bb04a5ccf5a8e39eebfac2729627 100644 --- a/sflphone-client-gnome/src/widget/gtkscrollbook.h +++ b/sflphone-client-gnome/src/widget/gtkscrollbook.h @@ -41,39 +41,37 @@ G_BEGIN_DECLS typedef struct _PidginScrollBook PidginScrollBook; typedef struct _PidginScrollBookClass PidginScrollBookClass; -struct _PidginScrollBook -{ - GtkVBox parent_instance; - - GtkWidget *notebook; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *left_arrow; - GtkWidget *right_arrow; - GList *children; - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); +struct _PidginScrollBook { + GtkVBox parent_instance; + + GtkWidget *notebook; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *left_arrow; + GtkWidget *right_arrow; + GList *children; + + /* Padding for future expansion */ + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); }; -struct _PidginScrollBookClass -{ - GtkContainerClass parent_class; +struct _PidginScrollBookClass { + GtkContainerClass parent_class; - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); + /* Padding for future expansion */ + void (*_gtk_reserved0) (void); + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); }; -GType pidgin_scroll_book_get_type (void) G_GNUC_CONST; -GtkWidget *pidgin_scroll_book_new (void); +GType pidgin_scroll_book_get_type (void) G_GNUC_CONST; +GtkWidget *pidgin_scroll_book_new (void); G_END_DECLS diff --git a/sflphone-client-gnome/src/widget/minidialog.c b/sflphone-client-gnome/src/widget/minidialog.c index 2d2a8d05600229319a74ef9a0421d426cdbe98d1..3867d19e7373031ab9e1f76bbd466e9fb1654eca 100644 --- a/sflphone-client-gnome/src/widget/minidialog.c +++ b/sflphone-client-gnome/src/widget/minidialog.c @@ -26,13 +26,13 @@ #include <gtk/gtkhbox.h> #include <gtk/gtkbutton.h> #include <gtk/gtk.h> - +#include "sflphone_const.h" #include "minidialog.h" #define HIG_BOX_SPACE 6 #define LABEL_WIDTH 200 -static void pidgin_mini_dialog_init (PidginMiniDialog *self); +static void pidgin_mini_dialog_init (PidginMiniDialog *self); static void pidgin_mini_dialog_class_init (PidginMiniDialogClass *klass); static gpointer pidgin_mini_dialog_parent_class = NULL; @@ -40,318 +40,313 @@ static gpointer pidgin_mini_dialog_parent_class = NULL; static void pidgin_mini_dialog_class_intern_init (gpointer klass) { - pidgin_mini_dialog_parent_class = g_type_class_peek_parent (klass); - pidgin_mini_dialog_class_init ((PidginMiniDialogClass*) klass); + pidgin_mini_dialog_parent_class = g_type_class_peek_parent (klass); + pidgin_mini_dialog_class_init ( (PidginMiniDialogClass*) klass); } GType pidgin_mini_dialog_get_type (void) { - static GType g_define_type_id = 0; - if (g_define_type_id == 0) - { - static const GTypeInfo g_define_type_info = { - sizeof (PidginMiniDialogClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) pidgin_mini_dialog_class_intern_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (PidginMiniDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) pidgin_mini_dialog_init, - NULL, - }; - g_define_type_id = g_type_register_static (GTK_TYPE_VBOX, - "PidginMiniDialog", &g_define_type_info, 0); - } - return g_define_type_id; + static GType g_define_type_id = 0; + + if (g_define_type_id == 0) { + static const GTypeInfo g_define_type_info = { + sizeof (PidginMiniDialogClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) pidgin_mini_dialog_class_intern_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (PidginMiniDialog), + 0, /* n_preallocs */ + (GInstanceInitFunc) pidgin_mini_dialog_init, + NULL, + }; + g_define_type_id = g_type_register_static (GTK_TYPE_VBOX, + "PidginMiniDialog", &g_define_type_info, 0); + } + + return g_define_type_id; } -enum -{ - PROP_TITLE = 1, - PROP_DESCRIPTION, - PROP_ICON_NAME, +enum { + PROP_TITLE = 1, + PROP_DESCRIPTION, + PROP_ICON_NAME, - LAST_PROPERTY + LAST_PROPERTY } HazeConnectionProperties; -typedef struct _PidginMiniDialogPrivate -{ - GtkImage *icon; - GtkBox *title_box; - GtkLabel *title; - GtkLabel *desc; - GtkBox *buttons; +typedef struct _PidginMiniDialogPrivate { + GtkImage *icon; + GtkBox *title_box; + GtkLabel *title; + GtkLabel *desc; + GtkBox *buttons; - guint idle_destroy_cb_id; + guint idle_destroy_cb_id; } PidginMiniDialogPrivate; #define PIDGIN_MINI_DIALOG_GET_PRIVATE(dialog) \ ((PidginMiniDialogPrivate *) ((dialog)->priv)) PidginMiniDialog * -pidgin_mini_dialog_new(const gchar *title, - const gchar *description, - const gchar *icon_name) +pidgin_mini_dialog_new (const gchar *title, + const gchar *description, + const gchar *icon_name) { - PidginMiniDialog *mini_dialog = g_object_new(PIDGIN_TYPE_MINI_DIALOG, - "title", title, - "description", description, - "icon-name", icon_name, - NULL); + PidginMiniDialog *mini_dialog = g_object_new (PIDGIN_TYPE_MINI_DIALOG, + "title", title, + "description", description, + "icon-name", icon_name, + NULL); - return mini_dialog; + return mini_dialog; } void -pidgin_mini_dialog_set_title(PidginMiniDialog *mini_dialog, - const char *title) +pidgin_mini_dialog_set_title (PidginMiniDialog *mini_dialog, + const char *title) { - g_object_set(G_OBJECT(mini_dialog), "title", title, NULL); + g_object_set (G_OBJECT (mini_dialog), "title", title, NULL); } void -pidgin_mini_dialog_set_description(PidginMiniDialog *mini_dialog, - const char *description) +pidgin_mini_dialog_set_description (PidginMiniDialog *mini_dialog, + const char *description) { - g_object_set(G_OBJECT(mini_dialog), "description", description, NULL); + g_object_set (G_OBJECT (mini_dialog), "description", description, NULL); } void -pidgin_mini_dialog_set_icon_name(PidginMiniDialog *mini_dialog, - const char *icon_name) +pidgin_mini_dialog_set_icon_name (PidginMiniDialog *mini_dialog, + const char *icon_name) { - g_object_set(G_OBJECT(mini_dialog), "icon_name", icon_name, NULL); + g_object_set (G_OBJECT (mini_dialog), "icon_name", icon_name, NULL); } -struct _mini_dialog_button_clicked_cb_data -{ - PidginMiniDialog *mini_dialog; - PidginMiniDialogCallback callback; - gpointer user_data; +struct _mini_dialog_button_clicked_cb_data { + PidginMiniDialog *mini_dialog; + PidginMiniDialogCallback callback; + gpointer user_data; }; guint -pidgin_mini_dialog_get_num_children(PidginMiniDialog *mini_dialog) +pidgin_mini_dialog_get_num_children (PidginMiniDialog *mini_dialog) { - return g_list_length(mini_dialog->contents->children); + return g_list_length (mini_dialog->contents->children); } static gboolean -idle_destroy_cb(GtkWidget *mini_dialog) +idle_destroy_cb (GtkWidget *mini_dialog) { - gtk_widget_destroy(mini_dialog); - return FALSE; + gtk_widget_destroy (mini_dialog); + return FALSE; } static void -mini_dialog_button_clicked_cb(GtkButton *button, - gpointer user_data) +mini_dialog_button_clicked_cb (GtkButton *button, + gpointer user_data) { - struct _mini_dialog_button_clicked_cb_data *data = user_data; - PidginMiniDialogPrivate *priv = - PIDGIN_MINI_DIALOG_GET_PRIVATE(data->mini_dialog); + struct _mini_dialog_button_clicked_cb_data *data = user_data; + PidginMiniDialogPrivate *priv = + PIDGIN_MINI_DIALOG_GET_PRIVATE (data->mini_dialog); - /* Set up the destruction callback before calling the clicked callback, - * so that if the mini-dialog gets destroyed during the clicked callback - * the idle_destroy_cb is correctly removed by _finalize. - */ - priv->idle_destroy_cb_id = - g_idle_add((GSourceFunc) idle_destroy_cb, data->mini_dialog); + /* Set up the destruction callback before calling the clicked callback, + * so that if the mini-dialog gets destroyed during the clicked callback + * the idle_destroy_cb is correctly removed by _finalize. + */ + priv->idle_destroy_cb_id = + g_idle_add ( (GSourceFunc) idle_destroy_cb, data->mini_dialog); - if (data->callback != NULL) - data->callback(data->mini_dialog, button, data->user_data); + if (data->callback != NULL) + data->callback (data->mini_dialog, button, data->user_data); } static void -mini_dialog_button_destroy_cb(GtkButton *button, - gpointer user_data) +mini_dialog_button_destroy_cb (GtkButton *button UNUSED, + gpointer user_data) { - struct _mini_dialog_button_clicked_cb_data *data = user_data; - g_free(data); + struct _mini_dialog_button_clicked_cb_data *data = user_data; + g_free (data); } void -pidgin_mini_dialog_add_button(PidginMiniDialog *self, - const char *text, - PidginMiniDialogCallback clicked_cb, - gpointer user_data) +pidgin_mini_dialog_add_button (PidginMiniDialog *self, + const char *text, + PidginMiniDialogCallback clicked_cb, + gpointer user_data) { - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); - struct _mini_dialog_button_clicked_cb_data *callback_data - = g_new0(struct _mini_dialog_button_clicked_cb_data, 1); - GtkWidget *button = gtk_button_new(); - GtkWidget *label = gtk_label_new(NULL); - char *button_text = - g_strdup_printf("<span size=\"smaller\">%s</span>", text); - - gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), button_text); - g_free(button_text); - - callback_data->mini_dialog = self; - callback_data->callback = clicked_cb; - callback_data->user_data = user_data; - g_signal_connect(G_OBJECT(button), "clicked", - (GCallback) mini_dialog_button_clicked_cb, callback_data); - g_signal_connect(G_OBJECT(button), "destroy", - (GCallback) mini_dialog_button_destroy_cb, callback_data); - - gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); - gtk_container_add(GTK_CONTAINER(button), label); - - gtk_box_pack_end(GTK_BOX(priv->buttons), button, FALSE, FALSE, - 0); - gtk_widget_show_all(GTK_WIDGET(button)); + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); + struct _mini_dialog_button_clicked_cb_data *callback_data + = g_new0 (struct _mini_dialog_button_clicked_cb_data, 1); + GtkWidget *button = gtk_button_new(); + GtkWidget *label = gtk_label_new (NULL); + char *button_text = + g_strdup_printf ("<span size=\"smaller\">%s</span>", text); + + gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), button_text); + g_free (button_text); + + callback_data->mini_dialog = self; + callback_data->callback = clicked_cb; + callback_data->user_data = user_data; + g_signal_connect (G_OBJECT (button), "clicked", + (GCallback) mini_dialog_button_clicked_cb, callback_data); + g_signal_connect (G_OBJECT (button), "destroy", + (GCallback) mini_dialog_button_destroy_cb, callback_data); + + gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); + gtk_container_add (GTK_CONTAINER (button), label); + + gtk_box_pack_end (GTK_BOX (priv->buttons), button, FALSE, FALSE, + 0); + gtk_widget_show_all (GTK_WIDGET (button)); } static void -pidgin_mini_dialog_get_property(GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +pidgin_mini_dialog_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - PidginMiniDialog *self = PIDGIN_MINI_DIALOG(object); - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); - - switch (property_id) { - case PROP_TITLE: - g_value_set_string(value, gtk_label_get_text(priv->title)); - break; - case PROP_DESCRIPTION: - g_value_set_string(value, gtk_label_get_text(priv->desc)); - break; - case PROP_ICON_NAME: - { - gchar *icon_name = NULL; - GtkIconSize size; - gtk_image_get_stock(priv->icon, &icon_name, &size); - g_value_set_string(value, icon_name); - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + PidginMiniDialog *self = PIDGIN_MINI_DIALOG (object); + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); + + switch (property_id) { + case PROP_TITLE: + g_value_set_string (value, gtk_label_get_text (priv->title)); + break; + case PROP_DESCRIPTION: + g_value_set_string (value, gtk_label_get_text (priv->desc)); + break; + case PROP_ICON_NAME: { + gchar *icon_name = NULL; + GtkIconSize size; + gtk_image_get_stock (priv->icon, &icon_name, &size); + g_value_set_string (value, icon_name); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } } static void -mini_dialog_set_title(PidginMiniDialog *self, - const char *title) +mini_dialog_set_title (PidginMiniDialog *self, + const char *title) { - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); - char *title_esc = g_markup_escape_text(title, -1); - char *title_markup = g_strdup_printf( - "<span weight=\"bold\" size=\"smaller\">%s</span>", - title_esc ? title_esc : ""); + char *title_esc = g_markup_escape_text (title, -1); + char *title_markup = g_strdup_printf ( + "<span weight=\"bold\" size=\"smaller\">%s</span>", + title_esc ? title_esc : ""); - gtk_label_set_markup(priv->title, title_markup); + gtk_label_set_markup (priv->title, title_markup); - g_free(title_esc); - g_free(title_markup); + g_free (title_esc); + g_free (title_markup); } static void -mini_dialog_set_description(PidginMiniDialog *self, - const char *description) +mini_dialog_set_description (PidginMiniDialog *self, + const char *description) { - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); - if(description) - { - char *desc_esc = g_markup_escape_text(description, -1); - char *desc_markup = g_strdup_printf( - "<span size=\"smaller\">%s</span>", desc_esc); - - gtk_label_set_markup(priv->desc, desc_markup); - - g_free(desc_esc); - g_free(desc_markup); - - gtk_widget_show(GTK_WIDGET(priv->desc)); - g_object_set(G_OBJECT(priv->desc), "no-show-all", FALSE, NULL); - } - else - { - gtk_label_set_text(priv->desc, NULL); - gtk_widget_hide(GTK_WIDGET(priv->desc)); - /* make calling show_all() on the minidialog not affect desc - * even though it's packed inside it. - */ - g_object_set(G_OBJECT(priv->desc), "no-show-all", TRUE, NULL); - } + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); + + if (description) { + char *desc_esc = g_markup_escape_text (description, -1); + char *desc_markup = g_strdup_printf ( + "<span size=\"smaller\">%s</span>", desc_esc); + + gtk_label_set_markup (priv->desc, desc_markup); + + g_free (desc_esc); + g_free (desc_markup); + + gtk_widget_show (GTK_WIDGET (priv->desc)); + g_object_set (G_OBJECT (priv->desc), "no-show-all", FALSE, NULL); + } else { + gtk_label_set_text (priv->desc, NULL); + gtk_widget_hide (GTK_WIDGET (priv->desc)); + /* make calling show_all() on the minidialog not affect desc + * even though it's packed inside it. + */ + g_object_set (G_OBJECT (priv->desc), "no-show-all", TRUE, NULL); + } } static void -pidgin_mini_dialog_set_property(GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +pidgin_mini_dialog_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - PidginMiniDialog *self = PIDGIN_MINI_DIALOG(object); - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); - - switch (property_id) { - case PROP_TITLE: - mini_dialog_set_title(self, g_value_get_string(value)); - break; - case PROP_DESCRIPTION: - mini_dialog_set_description(self, g_value_get_string(value)); - break; - case PROP_ICON_NAME: - gtk_image_set_from_stock(priv->icon, g_value_get_string(value), - GTK_ICON_SIZE_BUTTON); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } + PidginMiniDialog *self = PIDGIN_MINI_DIALOG (object); + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); + + switch (property_id) { + case PROP_TITLE: + mini_dialog_set_title (self, g_value_get_string (value)); + break; + case PROP_DESCRIPTION: + mini_dialog_set_description (self, g_value_get_string (value)); + break; + case PROP_ICON_NAME: + gtk_image_set_from_stock (priv->icon, g_value_get_string (value), + GTK_ICON_SIZE_BUTTON); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } } static void -pidgin_mini_dialog_finalize(GObject *object) +pidgin_mini_dialog_finalize (GObject *object) { - PidginMiniDialog *self = PIDGIN_MINI_DIALOG(object); - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); + PidginMiniDialog *self = PIDGIN_MINI_DIALOG (object); + PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE (self); - if (priv->idle_destroy_cb_id) - g_source_remove(priv->idle_destroy_cb_id); + if (priv->idle_destroy_cb_id) + g_source_remove (priv->idle_destroy_cb_id); - g_free(priv); - self->priv = NULL; + g_free (priv); + self->priv = NULL; - G_OBJECT_CLASS (pidgin_mini_dialog_parent_class)->finalize (object); + G_OBJECT_CLASS (pidgin_mini_dialog_parent_class)->finalize (object); } static void -pidgin_mini_dialog_class_init(PidginMiniDialogClass *klass) +pidgin_mini_dialog_class_init (PidginMiniDialogClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); - GParamSpec *param_spec; - - object_class->get_property = pidgin_mini_dialog_get_property; - object_class->set_property = pidgin_mini_dialog_set_property; - object_class->finalize = pidgin_mini_dialog_finalize; - - param_spec = g_param_spec_string("title", "title", - "String specifying the mini-dialog's title", NULL, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_TITLE, param_spec); - - param_spec = g_param_spec_string("description", "description", - "Description text for the mini-dialog, if desired", NULL, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_DESCRIPTION, param_spec); - - param_spec = g_param_spec_string("icon-name", "icon-name", - "String specifying the Gtk stock name of the dialog's icon", - NULL, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_ICON_NAME, param_spec); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GParamSpec *param_spec; + + object_class->get_property = pidgin_mini_dialog_get_property; + object_class->set_property = pidgin_mini_dialog_set_property; + object_class->finalize = pidgin_mini_dialog_finalize; + + param_spec = g_param_spec_string ("title", "title", + "String specifying the mini-dialog's title", NULL, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_TITLE, param_spec); + + param_spec = g_param_spec_string ("description", "description", + "Description text for the mini-dialog, if desired", NULL, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_DESCRIPTION, param_spec); + + param_spec = g_param_spec_string ("icon-name", "icon-name", + "String specifying the Gtk stock name of the dialog's icon", + NULL, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ICON_NAME, param_spec); } /* 16 is the width of the icon, due to PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL */ @@ -362,62 +357,48 @@ pidgin_mini_dialog_class_init(PidginMiniDialogClass *klass) (PIDGIN_PREFS_ROOT "/blist/width") static void -blist_width_changed_cb(const char *name, - gconstpointer val, - gpointer data) -{ - PidginMiniDialog *self = PIDGIN_MINI_DIALOG(data); - PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); - guint blist_width = GPOINTER_TO_INT(val); - guint label_width = LABEL_WIDTH; - - gtk_widget_set_size_request(GTK_WIDGET(priv->title), label_width, -1); - gtk_widget_set_size_request(GTK_WIDGET(priv->desc), label_width, -1); -} - -static void -pidgin_mini_dialog_init(PidginMiniDialog *self) +pidgin_mini_dialog_init (PidginMiniDialog *self) { - GtkBox *self_box = GTK_BOX(self); - guint label_width = LABEL_WIDTH; + GtkBox *self_box = GTK_BOX (self); + guint label_width = LABEL_WIDTH; - PidginMiniDialogPrivate *priv = g_new0(PidginMiniDialogPrivate, 1); - self->priv = priv; + PidginMiniDialogPrivate *priv = g_new0 (PidginMiniDialogPrivate, 1); + self->priv = priv; - gtk_container_set_border_width(GTK_CONTAINER(self), HIG_BOX_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (self), HIG_BOX_SPACE); - priv->title_box = GTK_BOX(gtk_hbox_new(FALSE, HIG_BOX_SPACE)); + priv->title_box = GTK_BOX (gtk_hbox_new (FALSE, HIG_BOX_SPACE)); - priv->icon = GTK_IMAGE(gtk_image_new()); - gtk_misc_set_alignment(GTK_MISC(priv->icon), 0, 0); + priv->icon = GTK_IMAGE (gtk_image_new()); + gtk_misc_set_alignment (GTK_MISC (priv->icon), 0, 0); - priv->title = GTK_LABEL(gtk_label_new(NULL)); - gtk_widget_set_size_request(GTK_WIDGET(priv->title), label_width, -1); - gtk_label_set_line_wrap(priv->title, TRUE); - gtk_label_set_selectable(priv->title, TRUE); - gtk_misc_set_alignment(GTK_MISC(priv->title), 0, 0); + priv->title = GTK_LABEL (gtk_label_new (NULL)); + gtk_widget_set_size_request (GTK_WIDGET (priv->title), label_width, -1); + gtk_label_set_line_wrap (priv->title, TRUE); + gtk_label_set_selectable (priv->title, TRUE); + gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0); - gtk_box_pack_start(priv->title_box, GTK_WIDGET(priv->icon), FALSE, FALSE, 0); - gtk_box_pack_start(priv->title_box, GTK_WIDGET(priv->title), TRUE, TRUE, 0); + gtk_box_pack_start (priv->title_box, GTK_WIDGET (priv->icon), FALSE, FALSE, 0); + gtk_box_pack_start (priv->title_box, GTK_WIDGET (priv->title), TRUE, TRUE, 0); - priv->desc = GTK_LABEL(gtk_label_new(NULL)); - gtk_widget_set_size_request(GTK_WIDGET(priv->desc), label_width, -1); - gtk_label_set_line_wrap(priv->desc, TRUE); - gtk_misc_set_alignment(GTK_MISC(priv->desc), 0, 0); - gtk_label_set_selectable(priv->desc, TRUE); - /* make calling show_all() on the minidialog not affect desc even though - * it's packed inside it. - */ - g_object_set(G_OBJECT(priv->desc), "no-show-all", TRUE, NULL); + priv->desc = GTK_LABEL (gtk_label_new (NULL)); + gtk_widget_set_size_request (GTK_WIDGET (priv->desc), label_width, -1); + gtk_label_set_line_wrap (priv->desc, TRUE); + gtk_misc_set_alignment (GTK_MISC (priv->desc), 0, 0); + gtk_label_set_selectable (priv->desc, TRUE); + /* make calling show_all() on the minidialog not affect desc even though + * it's packed inside it. + */ + g_object_set (G_OBJECT (priv->desc), "no-show-all", TRUE, NULL); - self->contents = GTK_BOX(gtk_vbox_new(FALSE, 0)); + self->contents = GTK_BOX (gtk_vbox_new (FALSE, 0)); - priv->buttons = GTK_BOX(gtk_hbox_new(FALSE, 0)); + priv->buttons = GTK_BOX (gtk_hbox_new (FALSE, 0)); - gtk_box_pack_start(self_box, GTK_WIDGET(priv->title_box), FALSE, FALSE, 0); - gtk_box_pack_start(self_box, GTK_WIDGET(priv->desc), FALSE, FALSE, 0); - gtk_box_pack_start(self_box, GTK_WIDGET(self->contents), TRUE, TRUE, 0); - gtk_box_pack_start(self_box, GTK_WIDGET(priv->buttons), FALSE, FALSE, 0); + gtk_box_pack_start (self_box, GTK_WIDGET (priv->title_box), FALSE, FALSE, 0); + gtk_box_pack_start (self_box, GTK_WIDGET (priv->desc), FALSE, FALSE, 0); + gtk_box_pack_start (self_box, GTK_WIDGET (self->contents), TRUE, TRUE, 0); + gtk_box_pack_start (self_box, GTK_WIDGET (priv->buttons), FALSE, FALSE, 0); - gtk_widget_show_all(GTK_WIDGET(self)); + gtk_widget_show_all (GTK_WIDGET (self)); } diff --git a/sflphone-client-gnome/src/widget/minidialog.h b/sflphone-client-gnome/src/widget/minidialog.h index 2b5e6a4d1c57b53e7561bd9d00fa19ee8569e3bc..55d83d9c0c93547bd8349b07b1d73f36c7e96ce2 100644 --- a/sflphone-client-gnome/src/widget/minidialog.h +++ b/sflphone-client-gnome/src/widget/minidialog.h @@ -77,23 +77,23 @@ G_BEGIN_DECLS * </dl> */ typedef struct { - GtkVBox parent; + GtkVBox parent; - /** A GtkVBox into which extra widgets for the dialog should be packed. - */ - GtkBox *contents; + /** A GtkVBox into which extra widgets for the dialog should be packed. + */ + GtkBox *contents; - gpointer priv; + gpointer priv; } PidginMiniDialog; /** The class of #PidginMiniDialog objects. */ typedef struct { - GtkBoxClass parent_class; + GtkBoxClass parent_class; - void (*_purple_reserved1) (void); - void (*_purple_reserved2) (void); - void (*_purple_reserved3) (void); - void (*_purple_reserved4) (void); + void (*_purple_reserved1) (void); + void (*_purple_reserved2) (void); + void (*_purple_reserved3) (void); + void (*_purple_reserved4) (void); } PidginMiniDialogClass; /** The type of a callback triggered by a button in a mini-dialog being pressed. @@ -103,8 +103,8 @@ typedef struct { * pidgin_mini_dialog_add_button() when the button was * created. */ -typedef void (*PidginMiniDialogCallback)(PidginMiniDialog *mini_dialog, - GtkButton *button, gpointer user_data); +typedef void (*PidginMiniDialogCallback) (PidginMiniDialog *mini_dialog, + GtkButton *button, gpointer user_data); /** Get the GType of #PidginMiniDialog. */ GType pidgin_mini_dialog_get_type (void); @@ -113,30 +113,30 @@ GType pidgin_mini_dialog_get_type (void); * with @c g_object_new() then setting each property yourself. * @return a new #PidginMiniDialog. */ -PidginMiniDialog *pidgin_mini_dialog_new(const gchar *title, - const gchar *description, const gchar *icon_name); +PidginMiniDialog *pidgin_mini_dialog_new (const gchar *title, + const gchar *description, const gchar *icon_name); /** Shortcut for setting a mini-dialog's title via GObject properties. * @param mini_dialog a mini-dialog * @param title the new title for @a mini_dialog */ -void pidgin_mini_dialog_set_title(PidginMiniDialog *mini_dialog, - const char *title); +void pidgin_mini_dialog_set_title (PidginMiniDialog *mini_dialog, + const char *title); /** Shortcut for setting a mini-dialog's description via GObject properties. * @param mini_dialog a mini-dialog * @param description the new description for @a mini_dialog, or @c NULL to * hide the description widget. */ -void pidgin_mini_dialog_set_description(PidginMiniDialog *mini_dialog, - const char *description); +void pidgin_mini_dialog_set_description (PidginMiniDialog *mini_dialog, + const char *description); /** Shortcut for setting a mini-dialog's icon via GObject properties. * @param mini_dialog a mini-dialog * @param icon_name the Gtk stock ID of an icon, or @c NULL for no icon. */ -void pidgin_mini_dialog_set_icon_name(PidginMiniDialog *mini_dialog, - const char *icon_name); +void pidgin_mini_dialog_set_icon_name (PidginMiniDialog *mini_dialog, + const char *icon_name); /** Adds a new button to a mini-dialog, and attaches the supplied callback to * its <tt>clicked</tt> signal. After a button is clicked, the dialog is @@ -147,15 +147,15 @@ void pidgin_mini_dialog_set_icon_name(PidginMiniDialog *mini_dialog, * @param user_data arbitrary data to pass to @a clicked_cb when it is * called. */ -void pidgin_mini_dialog_add_button(PidginMiniDialog *mini_dialog, - const char *text, PidginMiniDialogCallback clicked_cb, - gpointer user_data); +void pidgin_mini_dialog_add_button (PidginMiniDialog *mini_dialog, + const char *text, PidginMiniDialogCallback clicked_cb, + gpointer user_data); /** Gets the number of widgets packed into PidginMiniDialog.contents. * @param mini_dialog a mini-dialog * @return the number of widgets in @a mini_dialog->contents. */ -guint pidgin_mini_dialog_get_num_children(PidginMiniDialog *mini_dialog); +guint pidgin_mini_dialog_get_num_children (PidginMiniDialog *mini_dialog); G_END_DECLS diff --git a/sflphone-common/Makefile.am b/sflphone-common/Makefile.am index c5de2501fbb765d640061938f15ce4b259270a3a..22a5bfd63002c0aad55e909ccf821d0dd87b2988 100644 --- a/sflphone-common/Makefile.am +++ b/sflphone-common/Makefile.am @@ -24,13 +24,6 @@ doc: @echo "D-Bus API HTML documentation has been generated in doc/dbus-api/doc/spec" @echo "" -indent: - @echo "Indenting code:" - if [ -f $(ASTYLERC) ] ; then \ - $(indent) --options=$(ASTYLERC) --recursive *.cpp *.h; \ - fi - - ACLOCAL_AMFLAGS = -I m4 SUBDIRS = libs src ringtones man $(TESTS_DIR) EXTRA_DIST = m4/*.m4 tools/*.sh platform/* images/* README.gentoo diff --git a/sflphone-common/globals.mak b/sflphone-common/globals.mak index 0c408d19286bdf59a1202bd2ccf87bb04ce3c928..16656d11a2b224e4893a497affd2bc629f55429d 100644 --- a/sflphone-common/globals.mak +++ b/sflphone-common/globals.mak @@ -1,10 +1,13 @@ # Global variables + +#CXXFLAGS=-Wall -Werror -Wextra + src=$(top_srcdir) sfllibdir=$(DESTDIR)$(libdir)/sflphone sflcodecdir=$(sfllibdir)/codecs sflplugindir=$(sfllibdir)/plugins -ASTYLERC="../astylerc" +ASTYLERC="$(top_srcdir)/../astylerc" indent="/usr/bin/astyle" # for pjsip @@ -66,3 +69,10 @@ AM_CPPFLAGS = \ -DENABLE_TRACE \ $(SPEEXCODEC) \ $(GSMCODEC) + + +indent: + @echo "Indenting code:" + if [ -f $(ASTYLERC) ] ; then \ + find $(top_srcdir)/src/ -regex ".*\.\(h\|cpp\)" -exec $(indent) --options=$(ASTYLERC) {} \; ; \ + fi diff --git a/sflphone-common/src/Makefile.am b/sflphone-common/src/Makefile.am index d97477c85f4debd7a397253f4053b4ebeb966c89..fff35078332d02e3e7d3abe45747ec52f11dee66 100644 --- a/sflphone-common/src/Makefile.am +++ b/sflphone-common/src/Makefile.am @@ -102,9 +102,4 @@ libsflphone_la_CFLAGS = \ libsflphone_la_SOURCES = -indent: - @echo "Indenting code:" - if [ -f $(ASTYLERC) ] ; then \ - $(indent) --options=$(ASTYLERC) --recursive *.cpp *.h; \ - fi - +all: indent diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index 521e79e2b11a47a8a96c64a7273fb59dac74a7b8..fd75f67a67abf365aab9046bd59ab8ee44ae192c 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -52,25 +52,25 @@ typedef std::string AccountID; /** Contains all the state an Voip can be in */ typedef enum RegistrationState { - Unregistered, - Trying, - Registered, - Error, - ErrorAuth , - ErrorNetwork , - ErrorHost, - ErrorExistStun, - ErrorConfStun, - NumberOfState + Unregistered, + Trying, + Registered, + Error, + ErrorAuth , + ErrorNetwork , + ErrorHost, + ErrorExistStun, + ErrorConfStun, + NumberOfState } RegistrationState; #define AccountNULL "" -// Account identifier +// Account identifier #define ACCOUNT_ID "Account.id" // Common account parameters -#define CONFIG_ACCOUNT_TYPE "Account.type" +#define CONFIG_ACCOUNT_TYPE "Account.type" #define CONFIG_ACCOUNT_ALIAS "Account.alias" #define CONFIG_ACCOUNT_MAILBOX "Account.mailbox" #define CONFIG_ACCOUNT_ENABLE "Account.enable" @@ -125,51 +125,52 @@ typedef enum RegistrationState { #define TLS_SERVER_NAME "TLS.serverName" #define TLS_VERIFY_SERVER "TLS.verifyServer" #define TLS_VERIFY_CLIENT "TLS.verifyClient" -#define TLS_REQUIRE_CLIENT_CERTIFICATE "TLS.requireClientCertificate" +#define TLS_REQUIRE_CLIENT_CERTIFICATE "TLS.requireClientCertificate" #define TLS_NEGOTIATION_TIMEOUT_SEC "TLS.negotiationTimeoutSec" #define TLS_NEGOTIATION_TIMEOUT_MSEC "TLS.negotiationTimemoutMsec" #define REGISTRATION_STATUS "Status" -#define REGISTRATION_STATE_CODE "Registration.code" +#define REGISTRATION_STATE_CODE "Registration.code" #define REGISTRATION_STATE_DESCRIPTION "Registration.description" // General configuration keys for accounts -const Conf::Key aliasKey("alias"); -const Conf::Key typeKey("type"); -const Conf::Key idKey("id"); -const Conf::Key usernameKey("username"); -const Conf::Key passwordKey("password"); -const Conf::Key hostnameKey("hostname"); -const Conf::Key accountEnableKey("enable"); -const Conf::Key mailboxKey("mailbox"); - -const Conf::Key codecsKey("codecs"); // 0/9/110/111/112/ -const Conf::Key ringtonePathKey("ringtonePath"); -const Conf::Key ringtoneEnabledKey("ringtoneEnabled"); -const Conf::Key displayNameKey("displayName"); +const Conf::Key aliasKey ("alias"); +const Conf::Key typeKey ("type"); +const Conf::Key idKey ("id"); +const Conf::Key usernameKey ("username"); +const Conf::Key passwordKey ("password"); +const Conf::Key hostnameKey ("hostname"); +const Conf::Key accountEnableKey ("enable"); +const Conf::Key mailboxKey ("mailbox"); + +const Conf::Key codecsKey ("codecs"); // 0/9/110/111/112/ +const Conf::Key ringtonePathKey ("ringtonePath"); +const Conf::Key ringtoneEnabledKey ("ringtoneEnabled"); +const Conf::Key displayNameKey ("displayName"); #define find_in_map(X, Y) if((iter = map_cpy.find(X)) != map_cpy.end()) { Y = iter->second; } -class Account : public Serializable{ +class Account : public Serializable +{ public: - Account(const AccountID& accountID, std::string type); + Account (const AccountID& accountID, std::string type); /** * Virtual destructor */ virtual ~Account(); - virtual void serialize(Conf::YamlEmitter *emitter) = 0; + virtual void serialize (Conf::YamlEmitter *emitter) = 0; - virtual void unserialize(Conf::MappingNode *map) = 0; + virtual void unserialize (Conf::MappingNode *map) = 0; - virtual void setAccountDetails(const std::map<std::string, std::string>& details) = 0; + virtual void setAccountDetails (const std::map<std::string, std::string>& details) = 0; + + virtual std::map<std::string, std::string> getAccountDetails() = 0; - virtual std::map<std::string, std::string> getAccountDetails() = 0; - /** * Load the settings for this account. @@ -180,13 +181,17 @@ class Account : public Serializable{ * Get the account ID * @return constant account id */ - inline const AccountID& getAccountID() { return _accountID; } + inline const AccountID& getAccountID() { + return _accountID; + } /** * Get the voiplink pointer * @return VoIPLink* the pointer or 0 */ - inline VoIPLink* getVoIPLink() { return _link; } + inline VoIPLink* getVoIPLink() { + return _link; + } virtual void setVoIPLink () = 0; @@ -203,89 +208,137 @@ class Account : public Serializable{ virtual int unregisterVoIPLink() = 0; /** - * Tell if the account is enable or not. + * Tell if the account is enable or not. * @return true if enabled * false otherwise */ - bool isEnabled() { return _enabled; } + bool isEnabled() { + return _enabled; + } - void setEnabled(bool enabl) { _enabled = enabl; } + void setEnabled (bool enabl) { + _enabled = enabl; + } /** * Get the registration state of the specified link * @return RegistrationState The registration state of underlying VoIPLink */ - inline RegistrationState getRegistrationState() { return _registrationState; } + inline RegistrationState getRegistrationState() { + return _registrationState; + } /** * Set the registration state of the specified link * @param state The registration state of underlying VoIPLink */ - void setRegistrationState( RegistrationState state ); - + void setRegistrationState (RegistrationState state); + /** * Set the latest up-to-date state code - * for that account. These codes are + * for that account. These codes are * those used in SIP and IAX (eg. 200, 500 ...) * @param state The Code:Description state * @return void */ - void setRegistrationStateDetailed(std::pair<int, std::string> state) { _registrationStateDetailed = state; } - + void setRegistrationStateDetailed (std::pair<int, std::string> state) { + _registrationStateDetailed = state; + } + /** * Get the latest up-to-date state code - * for that account. These codes are + * for that account. These codes are * those used in SIP and IAX (eg. 200, 500 ...) * @param void * @return std::pair<int, std::string> A Code:Description state */ - std::pair<int, std::string> getRegistrationStateDetailed(void) { return _registrationStateDetailed; } - + std::pair<int, std::string> getRegistrationStateDetailed (void) { + return _registrationStateDetailed; + } + /* inline functions */ /* They should be treated like macro definitions by the C++ compiler */ - inline std::string getUsername( void ) { return _username; } - inline void setUsername( std::string username) { _username = username; } - - inline std::string getHostname( void ) { return _hostname; } - inline void setHostname( std::string hostname) { _hostname = hostname; } - - inline std::string getPassword( void ) { return _password; } - inline void setPassword( std::string password ) { _password = password; } + inline std::string getUsername (void) { + return _username; + } + inline void setUsername (std::string username) { + _username = username; + } + + inline std::string getHostname (void) { + return _hostname; + } + inline void setHostname (std::string hostname) { + _hostname = hostname; + } + + inline std::string getPassword (void) { + return _password; + } + inline void setPassword (std::string password) { + _password = password; + } + + inline std::string getAlias (void) { + return _alias; + } + inline void setAlias (std::string alias) { + _alias = alias; + } + + inline std::string getType (void) { + return _type; + } + inline void setType (std::string type) { + _type = type; + } - inline std::string getAlias( void ) { return _alias; } - inline void setAlias( std::string alias ) { _alias = alias; } - - inline std::string getType( void ) { return _type; } - inline void setType( std::string type ) { _type = type; } - - /** - * Accessor to data structures - * @return CodecOrder& The list that reflects the user's choice - */ - inline CodecOrder& getActiveCodecs(void) { return _codecOrder; } - void setActiveCodecs (const std::vector <std::string>& list); - - inline std::string getRingtonePath(void) { return _ringtonePath; } - inline void setRingtonePath(std::string path) { _ringtonePath = path; } - - inline bool getRingtoneEnabled(void) { return _ringtoneEnabled; } - inline void setRingtoneEnabled(bool enabl) { _ringtoneEnabled = enabl; } - - inline std::string getDisplayName(void) { return _displayName; } - inline void setDisplayName(std::string name) { _displayName = name; } - - std::string getUseragent(void) { return _useragent; } - void setUseragent(std::string ua) { _useragent = ua; } + /** + * Accessor to data structures + * @return CodecOrder& The list that reflects the user's choice + */ + inline CodecOrder& getActiveCodecs (void) { + return _codecOrder; + } + void setActiveCodecs (const std::vector <std::string>& list); + + inline std::string getRingtonePath (void) { + return _ringtonePath; + } + inline void setRingtonePath (std::string path) { + _ringtonePath = path; + } + + inline bool getRingtoneEnabled (void) { + return _ringtoneEnabled; + } + inline void setRingtoneEnabled (bool enabl) { + _ringtoneEnabled = enabl; + } + + inline std::string getDisplayName (void) { + return _displayName; + } + inline void setDisplayName (std::string name) { + _displayName = name; + } + + std::string getUseragent (void) { + return _useragent; + } + void setUseragent (std::string ua) { + _useragent = ua; + } private: // copy constructor - Account(const Account& rh); + Account (const Account& rh); // assignment operator - Account& operator=(const Account& rh); + Account& operator= (const Account& rh); - void loadAudioCodecs (void); + void loadAudioCodecs (void); protected: /** @@ -332,47 +385,47 @@ class Account : public Serializable{ std::string _type; /* - * The general, protocol neutral registration + * The general, protocol neutral registration * state of the account */ RegistrationState _registrationState; - + /* * Details about the registration state. - * This is a protocol Code:Description pair. + * This is a protocol Code:Description pair. */ std::pair<int, std::string> _registrationStateDetailed; - /** - * Vector containing the order of the codecs - */ - CodecOrder _codecOrder; - - /** - * List of codec obtained when parsing configuration and used - * to generate codec order list - */ - std::string _codecStr; - - /** - * Ringtone .au file used for this account - */ - std::string _ringtonePath; - - /** - * Play ringtone when receiving a call - */ - bool _ringtoneEnabled; - - /** - * Display name when calling - */ + /** + * Vector containing the order of the codecs + */ + CodecOrder _codecOrder; + + /** + * List of codec obtained when parsing configuration and used + * to generate codec order list + */ + std::string _codecStr; + + /** + * Ringtone .au file used for this account + */ + std::string _ringtonePath; + + /** + * Play ringtone when receiving a call + */ + bool _ringtoneEnabled; + + /** + * Display name when calling + */ std::string _displayName; - /** - * Useragent used for registration - */ - std::string _useragent; + /** + * Useragent used for registration + */ + std::string _useragent; }; diff --git a/sflphone-common/src/accountcreator.h b/sflphone-common/src/accountcreator.h index b0c93191201635f99c84d5061478f178865e3000..71f8e36ab8295d886fb205c15d9a3516445df07f 100644 --- a/sflphone-common/src/accountcreator.h +++ b/sflphone-common/src/accountcreator.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -39,24 +39,25 @@ class Account; * @file accountcreator.h * @brief Create protocol-specific account */ -class AccountCreator{ -public: - ~AccountCreator(); - /** - * Public account type - */ - enum AccountType {SIP_ACCOUNT, SIP_DIRECT_IP_ACCOUNT, IAX_ACCOUNT }; - - /** - * Create a new account or null - * @param type type of the account - * @param accountID accountID (must be unique for each account) - */ - static Account* createAccount(AccountType type, AccountID accountID); +class AccountCreator +{ + public: + ~AccountCreator(); + /** + * Public account type + */ + enum AccountType {SIP_ACCOUNT, SIP_DIRECT_IP_ACCOUNT, IAX_ACCOUNT }; + + /** + * Create a new account or null + * @param type type of the account + * @param accountID accountID (must be unique for each account) + */ + static Account* createAccount (AccountType type, AccountID accountID); -private: - /** Hidden constructor */ - AccountCreator(); + private: + /** Hidden constructor */ + AccountCreator(); }; #endif diff --git a/sflphone-common/src/audio/algorithm.h b/sflphone-common/src/audio/algorithm.h index 6f147471860f97504107db69ae1ba9294c518632..84f9d8136cc9b2f9b2441a75b613a8077c8e1ed6 100644 --- a/sflphone-common/src/audio/algorithm.h +++ b/sflphone-common/src/audio/algorithm.h @@ -35,45 +35,46 @@ /** * \class Algorithm - * + * * Abstract interface used to implement audio processing algorithm */ -class Algorithm { +class Algorithm +{ - public: + public: - virtual void reset(void) = 0; + virtual void reset (void) = 0; - /** - * Put data to be processed - */ - virtual void putData(SFLDataFormat *inputData, int nbBytes) = 0; + /** + * Put data to be processed + */ + virtual void putData (SFLDataFormat *inputData, int nbBytes) = 0; - /** - * - */ - virtual int getData(SFLDataFormat *outputData) = 0; + /** + * + */ + virtual int getData (SFLDataFormat *outputData) = 0; - /** - * Class implementing this interface must define this function - * for audio processing that require synchronization between spkrdata and - */ - virtual void process(SFLDataFormat *inputData, int nbBytes) = 0; + /** + * Class implementing this interface must define this function + * for audio processing that require synchronization between spkrdata and + */ + virtual void process (SFLDataFormat *inputData, int nbBytes) = 0; - /** - * Class implementing this interface must define this function - * for audio processing that require synchronization between spkrdata and - */ - virtual int process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) = 0; + /** + * Class implementing this interface must define this function + * for audio processing that require synchronization between spkrdata and + */ + virtual int process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) = 0; - /** - * Class implementing this interface must define this function - * for audio processing that require synchronization between spkr and mic - * \param micData - * \param spkrData - * \param outputData - */ - virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) = 0; + /** + * Class implementing this interface must define this function + * for audio processing that require synchronization between spkr and mic + * \param micData + * \param spkrData + * \param outputData + */ + virtual void process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) = 0; }; diff --git a/sflphone-common/src/audio/alsa/alsalayer.cpp b/sflphone-common/src/audio/alsa/alsalayer.cpp index 0e316fd99373d7e155d8ee5af645ac097e39908e..1518ecd835fda1fb666ec945034ff12a7e5de4c9 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.cpp +++ b/sflphone-common/src/audio/alsa/alsalayer.cpp @@ -900,7 +900,7 @@ AlsaLayer::soundCardGetIndex (std::string description) void AlsaLayer::audioCallback (void) { - int toGet, urgentAvailBytes, normalAvailBytes, maxBytes; + int toGet, urgentAvailBytes, normalAvailBytes; unsigned short spkrVolume, micVolume; AudioLoop *tone; AudioLoop *file_tone; diff --git a/sflphone-common/src/audio/alsa/alsalayer.h b/sflphone-common/src/audio/alsa/alsalayer.h index 8bcacb28987353f95c7a422e80aa9a69b2ee55f5..ca42673f39fbd198585b09b10fcf1bc7fd4819b0 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.h +++ b/sflphone-common/src/audio/alsa/alsalayer.h @@ -7,12 +7,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -45,269 +45,310 @@ typedef std::pair<int , std::string> HwIDPair; /** * @file AlsaLayer.h - * @brief Main sound class. Manages the data transfers between the application and the hardware. + * @brief Main sound class. Manages the data transfers between the application and the hardware. */ -class AlsaLayer : public AudioLayer { - public: - /** - * Constructor - * @param manager An instance of managerimpl - */ - AlsaLayer( ManagerImpl* manager ); - - /** - * Destructor - */ - ~AlsaLayer(void); - - bool closeLayer( void ); - - /** - * Check if no devices are opened, otherwise close them. - * Then open the specified devices by calling the private functions open_device - * @param indexIn The number of the card chosen for capture - * @param indexOut The number of the card chosen for playback - * @param sampleRate The sample rate - * @param frameSize The frame size - * @param stream To indicate which kind of stream you want to open - * SFL_PCM_CAPTURE - * SFL_PCM_PLAYBACK - * SFL_PCM_BOTH - * @param plugin The alsa plugin ( dmix , default , front , surround , ...) - */ - bool openDevice(int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream, std::string plugin); - - /** - * Start the capture stream and prepare the playback stream. - * The playback starts accordingly to its threshold - * ALSA Library API - */ - void startStream(void); - - /** - * Stop the playback and capture streams. - * Drops the pending frames and put the capture and playback handles to PREPARED state - * ALSA Library API - */ - void stopStream(void); - - /** - * Query the capture device for number of bytes available in the hardware ring buffer - * @return int The number of bytes available - */ - int canGetMic(); - - /** - * Get data from the capture device - * @param buffer The buffer for data - * @param toCopy The number of bytes to get - * @return int The number of bytes acquired ( 0 if an error occured) - */ - int getMic(void * buffer, int toCopy); - - /** - * Concatenate two strings. Used to build a valid pcm device name. - * @param plugin the alsa PCM name - * @param card the sound card number - * @param subdevice the subdevice number - * @return std::string the concatenated string - */ - std::string buildDeviceTopo( std::string plugin, int card, int subdevice ); - - /** - * Scan the sound card available on the system - * @param stream To indicate whether we are looking for capture devices or playback devices - * SFL_PCM_CAPTURE - * SFL_PCM_PLAYBACK - * SFL_PCM_BOTH - * @return std::vector<std::string> The vector containing the string description of the card - */ - std::vector<std::string> getSoundCardsInfo( int stream ); - - /** - * Check if the given index corresponds to an existing sound card and supports the specified streaming mode - * @param card An index - * @param stream The stream mode - * SFL_PCM_CAPTURE - * SFL_PCM_PLAYBACK - * SFL_PCM_BOTH - * @return bool True if it exists and supports the mode - * false otherwise - */ - bool soundCardIndexExist( int card , int stream ); - - /** - * An index is associated with its string description - * @param description The string description - * @return int Its index - */ - int soundCardGetIndex( std::string description ); - - /** - * Get the current audio plugin. - * @return std::string The name of the audio plugin - */ - std::string getAudioPlugin( void ) { return _audioPlugin; } - - void audioCallback (void); - - bool isCaptureActive (void); - - /** - * Get the echo canceller state - * @return true if echo cancel activated - */ - virtual bool getEchoCancelState(void) { return AudioLayer::_echocancelstate; } - - /** - * Set the echo canceller state - * @param state true if echocancel active, false elsewhere - */ - virtual void setEchoCancelState(bool state); - - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - virtual bool getNoiseSuppressState(void) { return AudioLayer::_noisesuppressstate; } - - /** - * Set the noise suppressor state - * @param state true if noise suppressor active, false elsewhere - */ - virtual void setNoiseSuppressState(bool state); - - private: - - // Copy Constructor - AlsaLayer(const AlsaLayer& rh); - - // Assignment Operator - AlsaLayer& operator=( const AlsaLayer& rh); - - bool is_playback_prepared (void) { return _is_prepared_playback; } - bool is_capture_prepared (void) { return _is_prepared_capture; } - void prepare_playback (void) { _is_prepared_playback = true; } - void prepare_capture (void) { _is_prepared_capture = true; } - bool is_capture_running (void) { return _is_running_capture; } - bool is_playback_running (void) { return _is_running_playback; } - void start_playback (void) { _is_running_playback = true; } - void stop_playback (void) { _is_running_playback = false; _is_prepared_playback = false; } - void start_capture (void) { _is_running_capture = true; } - void stop_capture (void) { _is_running_capture = false; _is_prepared_capture = false; } - void close_playback (void) { _is_open_playback = false; } - void close_capture (void) { _is_open_capture = false; } - void open_playback (void) { _is_open_playback = true; } - void open_capture (void) { _is_open_capture = true; } - bool is_capture_open (void) { return _is_open_capture; } - bool is_playback_open (void) { return _is_open_playback; } - - /** - * Drop the pending frames and close the capture device - * ALSA Library API - */ - void closeCaptureStream( void ); - void stopCaptureStream( void ); - void startCaptureStream( void ); - void prepareCaptureStream( void ); - - void closePlaybackStream( void ); - void stopPlaybackStream( void ); - void startPlaybackStream( void ); - void preparePlaybackStream( void ); - - /** - * Open the specified device. - * ALSA Library API - * @param pcm_p The string name for the playback device - * @param pcm_c The string name for the capture device - * @param flag To indicate which kind of stream you want to open - * SFL_PCM_CAPTURE - * SFL_PCM_PLAYBACK - * SFL_PCM_BOTH - * @return true if successful - * false otherwise - */ - bool open_device( std::string pcm_p, std::string pcm_c, std::string pcm_r, int flag); - - bool alsa_set_params( snd_pcm_t *pcm_handle, int type, int rate ); - - /** - * Copy a data buffer in the internal ring buffer - * ALSA Library API - * @param buffer The data to be copied - * @param length The size of the buffer - * @return int The number of frames actually copied - */ - int write( void* buffer, int length, snd_pcm_t *handle); - - /** - * Read data from the internal ring buffer - * ALSA Library API - * @param buffer The buffer to stock the read data - * @param toCopy The number of bytes to get - * @return int The number of frames actually read - */ - int read( void* buffer, int toCopy); - - /** - * Recover from XRUN state for capture - * ALSA Library API - */ - void handle_xrun_capture( void ); - - /** - * Recover from XRUN state for playback - * ALSA Library API - */ - void handle_xrun_playback( snd_pcm_t *handle ); - - void* adjustVolume( void* buffer , int len, int stream ); - - /** - * Handles to manipulate playback stream - * ALSA Library API - */ - snd_pcm_t* _PlaybackHandle; - - /** - * Handles to manipulate ringtone stream - * - */ - snd_pcm_t *_RingtoneHandle; - - /** - * Handles to manipulate capture stream - * ALSA Library API - */ - snd_pcm_t* _CaptureHandle; - - /** - * Alsa parameter - Size of a period in the hardware ring buffer - */ - snd_pcm_uframes_t _periodSize; - - /** - * name of the alsa audio plugin used - */ - std::string _audioPlugin; - - /** Vector to manage all soundcard index - description association of the system */ - std::vector<HwIDPair> IDSoundCards; - - bool _is_prepared_playback; - bool _is_prepared_capture; - bool _is_running_playback; - bool _is_running_capture; - bool _is_open_playback; - bool _is_open_capture; - bool _trigger_request; - - AudioThread* _audioThread; - - /** Sample rate converter object */ - SamplerateConverter* _converter; +class AlsaLayer : public AudioLayer +{ + public: + /** + * Constructor + * @param manager An instance of managerimpl + */ + AlsaLayer (ManagerImpl* manager); + + /** + * Destructor + */ + ~AlsaLayer (void); + + bool closeLayer (void); + + /** + * Check if no devices are opened, otherwise close them. + * Then open the specified devices by calling the private functions open_device + * @param indexIn The number of the card chosen for capture + * @param indexOut The number of the card chosen for playback + * @param sampleRate The sample rate + * @param frameSize The frame size + * @param stream To indicate which kind of stream you want to open + * SFL_PCM_CAPTURE + * SFL_PCM_PLAYBACK + * SFL_PCM_BOTH + * @param plugin The alsa plugin ( dmix , default , front , surround , ...) + */ + bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream, std::string plugin); + + /** + * Start the capture stream and prepare the playback stream. + * The playback starts accordingly to its threshold + * ALSA Library API + */ + void startStream (void); + + /** + * Stop the playback and capture streams. + * Drops the pending frames and put the capture and playback handles to PREPARED state + * ALSA Library API + */ + void stopStream (void); + + /** + * Query the capture device for number of bytes available in the hardware ring buffer + * @return int The number of bytes available + */ + int canGetMic(); + + /** + * Get data from the capture device + * @param buffer The buffer for data + * @param toCopy The number of bytes to get + * @return int The number of bytes acquired ( 0 if an error occured) + */ + int getMic (void * buffer, int toCopy); + + /** + * Concatenate two strings. Used to build a valid pcm device name. + * @param plugin the alsa PCM name + * @param card the sound card number + * @param subdevice the subdevice number + * @return std::string the concatenated string + */ + std::string buildDeviceTopo (std::string plugin, int card, int subdevice); + + /** + * Scan the sound card available on the system + * @param stream To indicate whether we are looking for capture devices or playback devices + * SFL_PCM_CAPTURE + * SFL_PCM_PLAYBACK + * SFL_PCM_BOTH + * @return std::vector<std::string> The vector containing the string description of the card + */ + std::vector<std::string> getSoundCardsInfo (int stream); + + /** + * Check if the given index corresponds to an existing sound card and supports the specified streaming mode + * @param card An index + * @param stream The stream mode + * SFL_PCM_CAPTURE + * SFL_PCM_PLAYBACK + * SFL_PCM_BOTH + * @return bool True if it exists and supports the mode + * false otherwise + */ + bool soundCardIndexExist (int card , int stream); + + /** + * An index is associated with its string description + * @param description The string description + * @return int Its index + */ + int soundCardGetIndex (std::string description); + + /** + * Get the current audio plugin. + * @return std::string The name of the audio plugin + */ + std::string getAudioPlugin (void) { + return _audioPlugin; + } + + void audioCallback (void); + + bool isCaptureActive (void); + + /** + * Get the echo canceller state + * @return true if echo cancel activated + */ + virtual bool getEchoCancelState (void) { + return AudioLayer::_echocancelstate; + } + + /** + * Set the echo canceller state + * @param state true if echocancel active, false elsewhere + */ + virtual void setEchoCancelState (bool state); + + /** + * Get the noise suppressor state + * @return true if noise suppressor activated + */ + virtual bool getNoiseSuppressState (void) { + return AudioLayer::_noisesuppressstate; + } + + /** + * Set the noise suppressor state + * @param state true if noise suppressor active, false elsewhere + */ + virtual void setNoiseSuppressState (bool state); + + private: + + // Copy Constructor + AlsaLayer (const AlsaLayer& rh); + + // Assignment Operator + AlsaLayer& operator= (const AlsaLayer& rh); + + bool is_playback_prepared (void) { + return _is_prepared_playback; + } + bool is_capture_prepared (void) { + return _is_prepared_capture; + } + void prepare_playback (void) { + _is_prepared_playback = true; + } + void prepare_capture (void) { + _is_prepared_capture = true; + } + bool is_capture_running (void) { + return _is_running_capture; + } + bool is_playback_running (void) { + return _is_running_playback; + } + void start_playback (void) { + _is_running_playback = true; + } + void stop_playback (void) { + _is_running_playback = false; + _is_prepared_playback = false; + } + void start_capture (void) { + _is_running_capture = true; + } + void stop_capture (void) { + _is_running_capture = false; + _is_prepared_capture = false; + } + void close_playback (void) { + _is_open_playback = false; + } + void close_capture (void) { + _is_open_capture = false; + } + void open_playback (void) { + _is_open_playback = true; + } + void open_capture (void) { + _is_open_capture = true; + } + bool is_capture_open (void) { + return _is_open_capture; + } + bool is_playback_open (void) { + return _is_open_playback; + } + + /** + * Drop the pending frames and close the capture device + * ALSA Library API + */ + void closeCaptureStream (void); + void stopCaptureStream (void); + void startCaptureStream (void); + void prepareCaptureStream (void); + + void closePlaybackStream (void); + void stopPlaybackStream (void); + void startPlaybackStream (void); + void preparePlaybackStream (void); + + /** + * Open the specified device. + * ALSA Library API + * @param pcm_p The string name for the playback device + * @param pcm_c The string name for the capture device + * @param flag To indicate which kind of stream you want to open + * SFL_PCM_CAPTURE + * SFL_PCM_PLAYBACK + * SFL_PCM_BOTH + * @return true if successful + * false otherwise + */ + bool open_device (std::string pcm_p, std::string pcm_c, std::string pcm_r, int flag); + + bool alsa_set_params (snd_pcm_t *pcm_handle, int type, int rate); + + /** + * Copy a data buffer in the internal ring buffer + * ALSA Library API + * @param buffer The data to be copied + * @param length The size of the buffer + * @return int The number of frames actually copied + */ + int write (void* buffer, int length, snd_pcm_t *handle); + + /** + * Read data from the internal ring buffer + * ALSA Library API + * @param buffer The buffer to stock the read data + * @param toCopy The number of bytes to get + * @return int The number of frames actually read + */ + int read (void* buffer, int toCopy); + + /** + * Recover from XRUN state for capture + * ALSA Library API + */ + void handle_xrun_capture (void); + + /** + * Recover from XRUN state for playback + * ALSA Library API + */ + void handle_xrun_playback (snd_pcm_t *handle); + + void* adjustVolume (void* buffer , int len, int stream); + + /** + * Handles to manipulate playback stream + * ALSA Library API + */ + snd_pcm_t* _PlaybackHandle; + + /** + * Handles to manipulate ringtone stream + * + */ + snd_pcm_t *_RingtoneHandle; + + /** + * Handles to manipulate capture stream + * ALSA Library API + */ + snd_pcm_t* _CaptureHandle; + + /** + * Alsa parameter - Size of a period in the hardware ring buffer + */ + snd_pcm_uframes_t _periodSize; + + /** + * name of the alsa audio plugin used + */ + std::string _audioPlugin; + + /** Vector to manage all soundcard index - description association of the system */ + std::vector<HwIDPair> IDSoundCards; + + bool _is_prepared_playback; + bool _is_prepared_capture; + bool _is_running_playback; + bool _is_running_capture; + bool _is_open_playback; + bool _is_open_capture; + bool _trigger_request; + + AudioThread* _audioThread; + + /** Sample rate converter object */ + SamplerateConverter* _converter; }; diff --git a/sflphone-common/src/audio/audiodevice.h b/sflphone-common/src/audio/audiodevice.h index 306afbeb8c24bc1d41a111f5b95d3683c34eb6e9..4fa6c25e922a934f7b11b247794ed90c747c2f9c 100644 --- a/sflphone-common/src/audio/audiodevice.h +++ b/sflphone-common/src/audio/audiodevice.h @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -40,57 +40,66 @@ * @brief Container device for attribute storage * Have almost only get/set method */ -class AudioDevice { -public: - /** - * Constructor - * @param id Identifier - * @param name Name - */ - AudioDevice(int id, const std::string& name); - - /** - * Destructor - */ - ~AudioDevice(); - - /** Default sample rate */ - const static double DEFAULT_RATE; - - /** - * Read accessor to the ID - * @return int The ID of the audiodevice - */ - int getId() { return _id; } - - /** - * Read accessor to the name - * @return std::string& A string description - */ - const std::string& getName() {return _name; } - - /** - * Write accessor to the sample rate - * @param rate The sample rate - */ - void setRate(double rate) { _rate = rate;} - - /** - * Read accessor to the sample rate - * @return double The sample rate - */ - double getRate() { return _rate; } - -private: - - /** Integer id of the device, can not be 0 */ - int _id; - - /** Name of the device */ - std::string _name; - - /** Default rate in Hz, like 8000.0, default is AudioDevice::DEFAULT_RATE */ - double _rate; +class AudioDevice +{ + public: + /** + * Constructor + * @param id Identifier + * @param name Name + */ + AudioDevice (int id, const std::string& name); + + /** + * Destructor + */ + ~AudioDevice(); + + /** Default sample rate */ + const static double DEFAULT_RATE; + + /** + * Read accessor to the ID + * @return int The ID of the audiodevice + */ + int getId() { + return _id; + } + + /** + * Read accessor to the name + * @return std::string& A string description + */ + const std::string& getName() { + return _name; + } + + /** + * Write accessor to the sample rate + * @param rate The sample rate + */ + void setRate (double rate) { + _rate = rate; + } + + /** + * Read accessor to the sample rate + * @return double The sample rate + */ + double getRate() { + return _rate; + } + + private: + + /** Integer id of the device, can not be 0 */ + int _id; + + /** Name of the device */ + std::string _name; + + /** Default rate in Hz, like 8000.0, default is AudioDevice::DEFAULT_RATE */ + double _rate; }; #endif // _AUDIO_DEVICE_H_ diff --git a/sflphone-common/src/audio/audiolayer.h b/sflphone-common/src/audio/audiolayer.h index ab2a4559fa144d10278c53ba69c624ba6457eced..9859398d6728879af718bdb286c49ab2254bd3bf 100644 --- a/sflphone-common/src/audio/audiolayer.h +++ b/sflphone-common/src/audio/audiolayer.h @@ -1,19 +1,19 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Jerome Oufella <jerome.oufella@savoirfairelinux.com> + * Author: Jerome Oufella <jerome.oufella@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -45,56 +45,56 @@ /** * @file audiolayer.h - * @brief Main sound class. Manages the data transfers between the application and the hardware. + * @brief Main sound class. Manages the data transfers between the application and the hardware. */ class ManagerImpl; -class AudioLayer { +class AudioLayer +{ private: //copy constructor - AudioLayer(const AudioLayer& rh); + AudioLayer (const AudioLayer& rh); // assignment operator - AudioLayer& operator=(const AudioLayer& rh); + AudioLayer& operator= (const AudioLayer& rh); public: /** * Constructor * @param manager An instance of managerimpl */ - AudioLayer( ManagerImpl* manager , int type ) - : _defaultVolume(100) - , _layerType( type ) - , _manager(manager) - , _urgentRingBuffer( SIZEBUF, default_id ) - , _indexIn ( 0 ) - , _indexOut ( 0 ) - , _audioSampleRate ( 0 ) - , _frameSize ( 0 ) - , _inChannel( 1 ) - , _outChannel ( 1 ) - , _errorMessage ( 0 ) - , _mutex () - { - - } + AudioLayer (ManagerImpl* manager , int type) + : _defaultVolume (100) + , _layerType (type) + , _manager (manager) + , _urgentRingBuffer (SIZEBUF, default_id) + , _indexIn (0) + , _indexOut (0) + , _audioSampleRate (0) + , _frameSize (0) + , _inChannel (1) + , _outChannel (1) + , _errorMessage (0) + , _mutex () { + + } /** * Destructor */ - virtual ~AudioLayer(void) {} + virtual ~AudioLayer (void) {} - virtual bool closeLayer( void ) = 0; + virtual bool closeLayer (void) = 0; /** * Check if no devices are opened, otherwise close them. * Then open the specified devices by calling the private functions open_device * @param indexIn The number of the card chosen for capture * @param indexOut The number of the card chosen for playback - * @param sampleRate The sample rate + * @param sampleRate The sample rate * @param frameSize The frame size * @param stream To indicate which kind of stream you want to open * SFL_PCM_CAPTURE @@ -102,30 +102,30 @@ class AudioLayer { * SFL_PCM_BOTH * @param plugin The alsa plugin ( dmix , default , front , surround , ...) */ - virtual bool openDevice(int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) = 0; + virtual bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize, int stream , std::string plugin) = 0; /** - * Start the capture stream and prepare the playback stream. + * Start the capture stream and prepare the playback stream. * The playback starts accordingly to its threshold * ALSA Library API */ - virtual void startStream(void) = 0; + virtual void startStream (void) = 0; /** - * Stop the playback and capture streams. + * Stop the playback and capture streams. * Drops the pending frames and put the capture and playback handles to PREPARED state * ALSA Library API */ - virtual void stopStream(void) = 0; + virtual void stopStream (void) = 0; /** * Send a chunk of data to the hardware buffer to start the playback - * Copy data in the urgent buffer. + * Copy data in the urgent buffer. * @param buffer The buffer containing the data to be played ( ringtones ) * @param toCopy The size of the buffer * @return int The number of bytes copied in the urgent buffer */ - int putUrgent(void* buffer, int toCopy); + int putUrgent (void* buffer, int toCopy); /** * Put voice data in the main sound buffer @@ -133,7 +133,7 @@ class AudioLayer { * @param toCopy The size of the buffer * @return int The number of bytes copied */ - int putMain(void* buffer, int toCopy, CallID call_id = default_id); + int putMain (void* buffer, int toCopy, CallID call_id = default_id); void flushMain (void); @@ -147,116 +147,143 @@ class AudioLayer { * @param error The error code * Could be: ALSA_PLAYBACK_DEVICE * ALSA_CAPTURE_DEVICE - */ - void setErrorMessage(const int& error) { _errorMessage = error; } + */ + void setErrorMessage (const int& error) { + _errorMessage = error; + } /** * Read accessor to the error state * @return int The error code */ - int getErrorMessage() { return _errorMessage; } + int getErrorMessage() { + return _errorMessage; + } /** * Get the index of the audio card for capture * @return int The index of the card used for capture * 0 for the first available card on the system, 1 ... */ - int getIndexIn() { return _indexIn; } + int getIndexIn() { + return _indexIn; + } /** * Get the index of the audio card for playback * @return int The index of the card used for playback * 0 for the first available card on the system, 1 ... */ - int getIndexOut() { return _indexOut; } + int getIndexOut() { + return _indexOut; + } - /** - * Get the index of the audio card for ringtone (could be differnet from playback) - * @return int The index of the card used for ringtone - * 0 for the first available card on the system, 1 ... - */ - int getIndexRing() {return _indexRing; } + /** + * Get the index of the audio card for ringtone (could be differnet from playback) + * @return int The index of the card used for ringtone + * 0 for the first available card on the system, 1 ... + */ + int getIndexRing() { + return _indexRing; + } /** * Get the sample rate of the audio layer * @return unsigned int The sample rate * default: 44100 HZ */ - unsigned int getSampleRate() { return _audioSampleRate; } + unsigned int getSampleRate() { + return _audioSampleRate; + } /** * Get the frame size of the audio layer * @return unsigned int The frame size * default: 20 ms */ - unsigned int getFrameSize() { return _frameSize; } + unsigned int getFrameSize() { + return _frameSize; + } - /** - * Get the layer type for this instance (either Alsa or PulseAudio) - * @return unsigned int The layer type + /** + * Get the layer type for this instance (either Alsa or PulseAudio) + * @return unsigned int The layer type + * + */ + int getLayerType (void) { + return _layerType; + } + + /** + * Get a pointer to the application MainBuffer class. * - */ - int getLayerType( void ) { return _layerType; } + * In order to send signal to other parts of the application, one must pass through the mainbuffer. + * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. + * + * @return MainBuffer* a pointer to the MainBuffer instance + */ + MainBuffer* getMainBuffer (void) { + return _mainBuffer; + } - /** - * Get a pointer to the application MainBuffer class. - * - * In order to send signal to other parts of the application, one must pass through the mainbuffer. - * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. - * - * @return MainBuffer* a pointer to the MainBuffer instance + /** + * Set the mainbuffer once the audiolayer is created */ - MainBuffer* getMainBuffer( void ) { return _mainBuffer; } - - /** - * Set the mainbuffer once the audiolayer is created - */ - void setMainBuffer( MainBuffer* mainbuffer ) { _mainBuffer = mainbuffer; } + void setMainBuffer (MainBuffer* mainbuffer) { + _mainBuffer = mainbuffer; + } /** * Default volume for incoming RTP and Urgent sounds. */ unsigned short _defaultVolume; // 100 - - /** - * Set the audio recorder - */ - inline void setRecorderInstance (Recordable* rec) {_recorder = NULL; _recorder = rec;} - /** - * Get the audio recorder - */ - inline Recordable* getRecorderInstance (void) {return _recorder;} + /** + * Set the audio recorder + */ + inline void setRecorderInstance (Recordable* rec) { + _recorder = NULL; + _recorder = rec; + } - /** - * Get the echo canceller state - * @return true if echo cancel activated + /** + * Get the audio recorder */ - virtual bool getEchoCancelState(void) = 0; + inline Recordable* getRecorderInstance (void) { + return _recorder; + } + + /** + * Get the echo canceller state + * @return true if echo cancel activated + */ + virtual bool getEchoCancelState (void) = 0; - /** - * Set the echo canceller state - * @param state true if echocancel active, false elsewhere - */ - virtual void setEchoCancelState(bool state) = 0; + /** + * Set the echo canceller state + * @param state true if echocancel active, false elsewhere + */ + virtual void setEchoCancelState (bool state) = 0; - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - virtual bool getNoiseSuppressState(void) = 0; + /** + * Get the noise suppressor state + * @return true if noise suppressor activated + */ + virtual bool getNoiseSuppressState (void) = 0; - /** - * Set the noise suppressor state - * @param state true if noise suppressor active, false elsewhere - */ - virtual void setNoiseSuppressState(bool state) = 0; + /** + * Set the noise suppressor state + * @param state true if noise suppressor active, false elsewhere + */ + virtual void setNoiseSuppressState (bool state) = 0; - /** - * Get the mutex lock for the entire audio layer - */ - inline ost::Mutex* getMutexLock(void) { return &_mutex; } + /** + * Get the mutex lock for the entire audio layer + */ + inline ost::Mutex* getMutexLock (void) { + return &_mutex; + } protected: @@ -266,52 +293,52 @@ class AudioLayer { /** * Drop the pending frames and close the capture device */ - virtual void closeCaptureStream( void ) = 0; + virtual void closeCaptureStream (void) = 0; /** * Drop the pending frames and close the playback device */ - virtual void closePlaybackStream( void ) = 0; + virtual void closePlaybackStream (void) = 0; /** Augment coupling, reduce indirect access */ - ManagerImpl* _manager; + ManagerImpl* _manager; /** * Urgent ring buffer used for ringtones */ RingBuffer _urgentRingBuffer; - /** - * Instance of the MainBuffer for the whole application - * - * In order to send signal to other parts of the application, one must pass through the mainbuffer. - * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. - * - */ - MainBuffer* _mainBuffer; + /** + * Instance of the MainBuffer for the whole application + * + * In order to send signal to other parts of the application, one must pass through the mainbuffer. + * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. + * + */ + MainBuffer* _mainBuffer; - /** - * A pointer to the recordable instance (may be a call or a conference) - */ - Recordable* _recorder; + /** + * A pointer to the recordable instance (may be a call or a conference) + */ + Recordable* _recorder; /** - * Number of audio cards on which capture stream has been opened + * Number of audio cards on which capture stream has been opened */ int _indexIn; /** - * Number of audio cards on which playback stream has been opened + * Number of audio cards on which playback stream has been opened */ int _indexOut; - /** - * Number of audio cards on which ringtone stream has been opened - */ - int _indexRing; + /** + * Number of audio cards on which ringtone stream has been opened + */ + int _indexRing; /** - * Sample Rate SFLphone should send sound data to the sound card + * Sample Rate SFLphone should send sound data to the sound card * The value can be set in the user config file- now: 44100HZ */ unsigned int _audioSampleRate; @@ -319,36 +346,36 @@ class AudioLayer { /** * Length of the sound frame we capture or read in ms * The value can be set in the user config file - now: 20ms - */ + */ unsigned int _frameSize; /** * Input channel (mic) should be 1 mono */ - unsigned int _inChannel; + unsigned int _inChannel; /** * Output channel (stereo) should be 1 mono */ - unsigned int _outChannel; + unsigned int _outChannel; /** Contains the current error code */ int _errorMessage; - /** - * Lock for the entire audio layer - */ + /** + * Lock for the entire audio layer + */ ost::Mutex _mutex; - EchoCancel *_echoCancel; - AudioProcessing *_echoCanceller; + EchoCancel *_echoCancel; + AudioProcessing *_echoCanceller; - DcBlocker *_dcblocker; - AudioProcessing *_audiofilter; + DcBlocker *_dcblocker; + AudioProcessing *_audiofilter; - bool _echocancelstate; + bool _echocancelstate; - bool _noisesuppressstate; + bool _noisesuppressstate; }; diff --git a/sflphone-common/src/audio/audioloop.h b/sflphone-common/src/audio/audioloop.h index 98f01726f12317ae8c8b60e3bcba671f2ce41a8b..adaa4087b4b571941a0b0a38d92327e772a0c7bf 100644 --- a/sflphone-common/src/audio/audioloop.h +++ b/sflphone-common/src/audio/audioloop.h @@ -2,9 +2,9 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * - * Inspired by tonegenerator of + * Inspired by tonegenerator of * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -41,60 +41,65 @@ * @brief Loop on a sound file */ -class AudioLoop { -public: - /** - * Constructor - */ - AudioLoop(); - - /** - * Virtual destructor - */ - virtual ~AudioLoop(); - - /** - * Get the next fragment of the tone - * the function change the intern position, and will loop - * @param output The data buffer - * @param nb of int16 to send - * @param volume The volume - * @return the number of int16 sent (nb*2) - */ - int getNext(SFLDataFormat* output, int nb, short volume=100); - - /** - * Reset the pointer position - */ - void reset() { _pos = 0; } - - /** - * Accessor to the size of the buffer - * @return unsigned int The size - */ - unsigned int getSize() { return _size; } - - -protected: - /** The data buffer */ - SFLDataFormat* _buffer; - - /** Number of int16 inside the buffer, not the delay */ - int _size; - - /** current position, set to 0, when initialize */ - int _pos; - - /** Sample rate */ - int _sampleRate; - -private: - - // Copy Constructor - AudioLoop(const AudioLoop& rh); - - // Assignment Operator - AudioLoop& operator=( const AudioLoop& rh); +class AudioLoop +{ + public: + /** + * Constructor + */ + AudioLoop(); + + /** + * Virtual destructor + */ + virtual ~AudioLoop(); + + /** + * Get the next fragment of the tone + * the function change the intern position, and will loop + * @param output The data buffer + * @param nb of int16 to send + * @param volume The volume + * @return the number of int16 sent (nb*2) + */ + int getNext (SFLDataFormat* output, int nb, short volume=100); + + /** + * Reset the pointer position + */ + void reset() { + _pos = 0; + } + + /** + * Accessor to the size of the buffer + * @return unsigned int The size + */ + unsigned int getSize() { + return _size; + } + + + protected: + /** The data buffer */ + SFLDataFormat* _buffer; + + /** Number of int16 inside the buffer, not the delay */ + int _size; + + /** current position, set to 0, when initialize */ + int _pos; + + /** Sample rate */ + int _sampleRate; + + private: + + // Copy Constructor + AudioLoop (const AudioLoop& rh); + + // Assignment Operator + AudioLoop& operator= (const AudioLoop& rh); }; #endif // __AUDIOLOOP_H__ diff --git a/sflphone-common/src/audio/audioprocessing.h b/sflphone-common/src/audio/audioprocessing.h index b69d6fc5058eef3611c602e3173703e196d1542c..a26078b5473f099d12d63c345904d055d797ba2b 100644 --- a/sflphone-common/src/audio/audioprocessing.h +++ b/sflphone-common/src/audio/audioprocessing.h @@ -35,59 +35,62 @@ #include "algorithm.h" /** - * Process audio buffers using specified at instantiation which may be + * Process audio buffers using specified at instantiation which may be * changed dynamically at runtime. */ -class AudioProcessing { +class AudioProcessing +{ -public: + public: - /** - * The constructor for this class - */ - AudioProcessing(Algorithm *_algo); + /** + * The constructor for this class + */ + AudioProcessing (Algorithm *_algo); - ~AudioProcessing(void); + ~AudioProcessing (void); - /** - * Set a new algorithm to process audio. Algorithm must be a subclass of abstract class Algorithm - */ - void setAlgorithm(Algorithm *_algo) { _algorithm = _algo; } + /** + * Set a new algorithm to process audio. Algorithm must be a subclass of abstract class Algorithm + */ + void setAlgorithm (Algorithm *_algo) { + _algorithm = _algo; + } - /** - * Reset parameters for the algorithm - */ - void resetAlgorithm(); + /** + * Reset parameters for the algorithm + */ + void resetAlgorithm(); - /** - * Put data in internal buffer - */ - void putData(SFLDataFormat *inputData, int nbBytes); + /** + * Put data in internal buffer + */ + void putData (SFLDataFormat *inputData, int nbBytes); - /** - * Get data from internal buffer - */ - int getData(SFLDataFormat *outputData); + /** + * Get data from internal buffer + */ + int getData (SFLDataFormat *outputData); - /** - * Process some audio data - */ - void processAudio(SFLDataFormat *inputData, int nbBytes); + /** + * Process some audio data + */ + void processAudio (SFLDataFormat *inputData, int nbBytes); - /** - * Process some audio data - */ - int processAudio(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); + /** + * Process some audio data + */ + int processAudio (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); - /** - * Process some audio data. - */ - void processAudio(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); + /** + * Process some audio data. + */ + void processAudio (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); -private: + private: - Algorithm *_algorithm; + Algorithm *_algorithm; }; diff --git a/sflphone-common/src/audio/audiorecord.cpp b/sflphone-common/src/audio/audiorecord.cpp index 977275e993c67f2ee345af9af0a87f0e6e31019f..4abc0093ebc7583e055f07643ba823e0c19096fb 100644 --- a/sflphone-common/src/audio/audiorecord.cpp +++ b/sflphone-common/src/audio/audiorecord.cpp @@ -496,7 +496,7 @@ void AudioRecord::recData (SFLDataFormat* buffer, int nSamples) } -void AudioRecord::recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2) +void AudioRecord::recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2 UNUSED) { if (recordingEnabled_) { diff --git a/sflphone-common/src/audio/audiorecord.h b/sflphone-common/src/audio/audiorecord.h index 8e42bd2a245f50c2874b8f313df28f98509510ce..f97401441ade6f6ead309c52b1ace4401d3a0a0e 100644 --- a/sflphone-common/src/audio/audiorecord.h +++ b/sflphone-common/src/audio/audiorecord.h @@ -45,196 +45,196 @@ typedef std::string CallID; class AudioRecord { -public: - - AudioRecord(); - - ~AudioRecord(); - - void setSndSamplingRate(int smplRate); - - void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path); - - void initFileName( std::string peerNumber ); - - /** - * Check if no otehr file is opened, then create a new one - * @param fileName A string containing teh file (with/without extension) - * @param type The sound file format (FILE_RAW, FILE_WAVE) - * @param format Internal sound format (INT16 / INT32) - */ - void openFile(); - - /** - * Close the opend recording file. If wave: cout the number of byte - */ - void closeFile(); - - /** - * Check if a file is already opened - */ - bool isOpenFile(); - - /** - * Check if a file already exist - */ - bool isFileExist(); - - /** - * Check recording state - */ - bool isRecording(); - - /** - * Set recording flag - */ - bool setRecording(); - - /** - * Stop recording flag - */ - void stopRecording(); - - - /** - * Record a chunk of data in an internal buffer - * @param buffer The data chunk to be recorded - * @param nSamples Number of samples (number of bytes) to be recorded - */ - void recSpkrData(SFLDataFormat* buffer, int nSamples); - - /** - * Record a chunk of data in an internal buffer - * @param buffer The data chunk to be recorded - * @param nSamples Number of samples (number of bytes) to be recorded - */ - void recMicData(SFLDataFormat* buffer, int nSamples); - - /** - * Record a chunk of data in an openend file - * @param buffer The data chunk to be recorded - * @param nSamples Number of samples (number of bytes) to be recorded - */ - void recData(SFLDataFormat* buffer, int nSamples); - - /** - * Record a chunk of data in an openend file, Mix two differnet buffer - * @param buffer_1 The first data chunk to be recorded - * @param buffer_2 The second data chunk to be recorded - * @param nSamples_1 Number of samples (number of bytes) of buffer_1 - * @param nSamples_2 Number of samples (number of bytes) of buffer_2 - */ - void recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2); - - -protected: - - /** - * Create name file according to current date - */ - void createFilename(); - - /** - * Set the header for raw files - */ - bool setRawFile(); - - /** - * Set the header for wave files - */ - bool setWavFile(); - - /** - * Open an existing raw file, used when the call is set on hold - */ - bool openExistingRawFile(); - - /** - * Open an existing wav file, used when the call is set on hold - */ - bool openExistingWavFile(); - - /** - * Compute the number of byte recorded and close the file - */ - void closeWavFile(); - - - /** - * Pointer to the recorded file - */ - FILE *fp; //file pointer - - /** - * File format (RAW / WAVE) - */ - FILE_TYPE fileType_; - - /** - * Sound format (SINT16/SINT32) - */ - SOUND_FORMAT sndFormat_; - - /** - * Number of channels - */ - int channels_; - - /** - * Number of byte recorded - */ - unsigned long byteCounter_; - - /** - * Sampling rate - */ - int sndSmplRate_; - - /** - * number of samples recorded for mic buffer - */ - int nbSamplesMic_; - - /** - * number of samples recorded for speaker buffer - */ - int nbSamplesSpk_; - - /** - * Maximum number of samples - */ - int nbSamplesMax_; - - /** - * Recording flage - */ - bool recordingEnabled_; - - /** - * Buffer used for mixing two channels - */ - SFLDataFormat* mixBuffer_; - - /** - * Buffer used to copy mic info - */ - SFLDataFormat* micBuffer_; - - /** - * Buffer used to copy spkr info - */ - SFLDataFormat* spkBuffer_; - - /** - * Filename for this recording - */ - char fileName_[8192]; - - /** - * Path for this recording - */ - std::string savePath_; - + public: + + AudioRecord(); + + ~AudioRecord(); + + void setSndSamplingRate (int smplRate); + + void setRecordingOption (FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path); + + void initFileName (std::string peerNumber); + + /** + * Check if no otehr file is opened, then create a new one + * @param fileName A string containing teh file (with/without extension) + * @param type The sound file format (FILE_RAW, FILE_WAVE) + * @param format Internal sound format (INT16 / INT32) + */ + void openFile(); + + /** + * Close the opend recording file. If wave: cout the number of byte + */ + void closeFile(); + + /** + * Check if a file is already opened + */ + bool isOpenFile(); + + /** + * Check if a file already exist + */ + bool isFileExist(); + + /** + * Check recording state + */ + bool isRecording(); + + /** + * Set recording flag + */ + bool setRecording(); + + /** + * Stop recording flag + */ + void stopRecording(); + + + /** + * Record a chunk of data in an internal buffer + * @param buffer The data chunk to be recorded + * @param nSamples Number of samples (number of bytes) to be recorded + */ + void recSpkrData (SFLDataFormat* buffer, int nSamples); + + /** + * Record a chunk of data in an internal buffer + * @param buffer The data chunk to be recorded + * @param nSamples Number of samples (number of bytes) to be recorded + */ + void recMicData (SFLDataFormat* buffer, int nSamples); + + /** + * Record a chunk of data in an openend file + * @param buffer The data chunk to be recorded + * @param nSamples Number of samples (number of bytes) to be recorded + */ + void recData (SFLDataFormat* buffer, int nSamples); + + /** + * Record a chunk of data in an openend file, Mix two differnet buffer + * @param buffer_1 The first data chunk to be recorded + * @param buffer_2 The second data chunk to be recorded + * @param nSamples_1 Number of samples (number of bytes) of buffer_1 + * @param nSamples_2 Number of samples (number of bytes) of buffer_2 + */ + void recData (SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2); + + + protected: + + /** + * Create name file according to current date + */ + void createFilename(); + + /** + * Set the header for raw files + */ + bool setRawFile(); + + /** + * Set the header for wave files + */ + bool setWavFile(); + + /** + * Open an existing raw file, used when the call is set on hold + */ + bool openExistingRawFile(); + + /** + * Open an existing wav file, used when the call is set on hold + */ + bool openExistingWavFile(); + + /** + * Compute the number of byte recorded and close the file + */ + void closeWavFile(); + + + /** + * Pointer to the recorded file + */ + FILE *fp; //file pointer + + /** + * File format (RAW / WAVE) + */ + FILE_TYPE fileType_; + + /** + * Sound format (SINT16/SINT32) + */ + SOUND_FORMAT sndFormat_; + + /** + * Number of channels + */ + int channels_; + + /** + * Number of byte recorded + */ + unsigned long byteCounter_; + + /** + * Sampling rate + */ + int sndSmplRate_; + + /** + * number of samples recorded for mic buffer + */ + int nbSamplesMic_; + + /** + * number of samples recorded for speaker buffer + */ + int nbSamplesSpk_; + + /** + * Maximum number of samples + */ + int nbSamplesMax_; + + /** + * Recording flage + */ + bool recordingEnabled_; + + /** + * Buffer used for mixing two channels + */ + SFLDataFormat* mixBuffer_; + + /** + * Buffer used to copy mic info + */ + SFLDataFormat* micBuffer_; + + /** + * Buffer used to copy spkr info + */ + SFLDataFormat* spkBuffer_; + + /** + * Filename for this recording + */ + char fileName_[8192]; + + /** + * Path for this recording + */ + std::string savePath_; + }; #endif // _AUDIO_RECORD_H diff --git a/sflphone-common/src/audio/audiorecorder.cpp b/sflphone-common/src/audio/audiorecorder.cpp index 559c4f0f34d2657b8ffbf14b4e8a92ba62b3e043..d5763aaa3c3b32012c678f29783810a7bd8afd90 100644 --- a/sflphone-common/src/audio/audiorecorder.cpp +++ b/sflphone-common/src/audio/audiorecorder.cpp @@ -70,10 +70,6 @@ void AudioRecorder::run (void) if (availBytes > 0) { - int got = mbuffer->getData (buffer, availBytes, 100, recorderId); - - int availBytesAfter = mbuffer->availForGet (recorderId); - arecord->recData (buffer, availBytes/sizeof (SFLDataFormat)); } diff --git a/sflphone-common/src/audio/audiorecorder.h b/sflphone-common/src/audio/audiorecorder.h index b1c15f3a489a49fa058b320cb81caa8153e93208..66e79d4bc54cfaa155a5c1aba3439c1396364a7a 100644 --- a/sflphone-common/src/audio/audiorecorder.h +++ b/sflphone-common/src/audio/audiorecorder.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Alexandre Savard <alexandre.savard@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -37,28 +37,33 @@ class MainBuffer; -class AudioRecorder : public ost::Thread { +class AudioRecorder : public ost::Thread +{ - public: - AudioRecorder(AudioRecord *arec, MainBuffer *mb); + public: + AudioRecorder (AudioRecord *arec, MainBuffer *mb); - ~AudioRecorder(void){ terminate(); } + ~AudioRecorder (void) { + terminate(); + } - static int count; + static int count; - std::string getRecorderID() { return recorderId; } + std::string getRecorderID() { + return recorderId; + } - virtual void run(); + virtual void run(); - private: - AudioRecorder (const AudioRecorder& ar); - AudioRecorder& operator=(const AudioRecorder& ar); + private: + AudioRecorder (const AudioRecorder& ar); + AudioRecorder& operator= (const AudioRecorder& ar); - std::string recorderId; + std::string recorderId; - MainBuffer *mbuffer; + MainBuffer *mbuffer; - AudioRecord *arecord; + AudioRecord *arecord; }; #endif diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h index 74de2364b94a16cf169aeadda853ec98ebc4becf..b870333fb055a655aa842e8cd1c833511b6a6d70 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -39,146 +39,163 @@ class SdesNegotiator; class SIPCall; -namespace sfl { - class AudioZrtpSession; - class AudioSrtpSession; - class AudioSymmetricRtpSession; +namespace sfl +{ +class AudioZrtpSession; +class AudioSrtpSession; +class AudioSymmetricRtpSession; } -namespace sfl { +namespace sfl +{ - class AudioZrtpSession; - class AudioSrtpSession; +class AudioZrtpSession; +class AudioSrtpSession; - // Possible kind of rtp session - typedef enum RtpMethod { - Symmetric, - Zrtp, - Sdes - } RtpMethod; +// Possible kind of rtp session +typedef enum RtpMethod { + Symmetric, + Zrtp, + Sdes +} RtpMethod; - class UnsupportedRtpSessionType : public std::logic_error { - public: - UnsupportedRtpSessionType(const std::string& msg = "") : std::logic_error(msg) {} - }; - - class AudioRtpFactoryException : public std::logic_error { - public: - AudioRtpFactoryException(const std::string& msg = "") : std::logic_error(msg) {} - }; +class UnsupportedRtpSessionType : public std::logic_error +{ + public: + UnsupportedRtpSessionType (const std::string& msg = "") : std::logic_error (msg) {} +}; + +class AudioRtpFactoryException : public std::logic_error +{ + public: + AudioRtpFactoryException (const std::string& msg = "") : std::logic_error (msg) {} +}; - class AudioRtpFactory { - public: +class AudioRtpFactory +{ + public: AudioRtpFactory(); - AudioRtpFactory(SIPCall * ca); + AudioRtpFactory (SIPCall * ca); ~AudioRtpFactory(); - void initAudioRtpConfig(SIPCall *ca); - - /** - * Lazy instantiation method. Create a new RTP session of a given - * type according to the content of the configuration file. - * @param ca A pointer on a SIP call - * @return A new AudioRtpSession object - */ - void initAudioRtpSession(SIPCall *ca); - - /** - * Start the audio rtp thread of the type specified in the configuration - * file. initAudioRtpSession must have been called prior to that. - * @param None - */ - void start(AudioCodec*); - - /** - * Stop the audio rtp thread of the type specified in the configuration - * file. initAudioRtpSession must have been called prior to that. - * @param None - */ - void stop(); - - /** - * Update current RTP destination address with one stored in call - * @param None - */ - void updateDestinationIpAddress (void); - - /** - * @param None - * @return The internal audio rtp thread of the type specified in the configuration - * file. initAudioRtpSession must have been called prior to that. - */ - inline void * getAudioRtpSession(void) { return _rtpSession; } - - AudioSymmetricRtpSession * getAudioSymetricRtpSession(); - - /** - * @param None - * @return The internal audio rtp session type - * Symmetric = 0 - * Zrtp = 1 - * Sdes = 2 - */ - inline RtpMethod getAudioRtpType(void) { return _rtpSessionType; } - - /** - * @param Set internal audio rtp session type (Symmetric, Zrtp, Sdes) - */ - inline void setAudioRtpType(RtpMethod type) { _rtpSessionType = type; } - - /** - * Manually set the srtpEnable option (usefull for RTP fallback) - */ - void setSrtpEnabled(bool enable){ _srtpEnabled = enable; } - - /** - * Manually set the keyExchangeProtocol parameter (usefull for RTP fallback) - */ - void setKeyExchangeProtocol(int proto){ _keyExchangeProtocol = proto; } - - /** - * Manually set the setHelloHashEnabled parameter (usefull for RTP fallback) - */ - void setHelloHashEnabled(bool enable){ _helloHashEnabled = enable; } - - /** - * Get the current AudioZrtpSession. Throws an AudioRtpFactoryException - * if the current rtp thread is null, or if it's not of the correct type. - * @return The current AudioZrtpSession thread. - */ - sfl::AudioZrtpSession * getAudioZrtpSession(); - - /** - * Set remote cryptographic info. Should be called after negotiation in SDP - * offer/answer session. - */ - void setRemoteCryptoInfo(sfl::SdesNegotiator& nego); - - /** - * Send DTMF over RTP (RFC2833). The timestamp and sequence number must be - * incremented as if it was microphone audio. This function change the payload type of the rtp session, - * send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get - * back the codec payload for further audio processing. - */ - void sendDtmfDigit(int digit); - -private: - void * _rtpSession; - RtpMethod _rtpSessionType; - ost::Mutex _audioRtpThreadMutex; - - // Field used when initializinga udio rtp session - // May be set manually or from config using initAudioRtpConfig - bool _srtpEnabled; - - // Field used when initializinga udio rtp session - // May be set manually or from config using initAudioRtpConfig - int _keyExchangeProtocol; - - // Field used when initializinga udio rtp session - // May be set manually or from config using initAudioRtpConfig - bool _helloHashEnabled; + void initAudioRtpConfig (SIPCall *ca); + + /** + * Lazy instantiation method. Create a new RTP session of a given + * type according to the content of the configuration file. + * @param ca A pointer on a SIP call + * @return A new AudioRtpSession object + */ + void initAudioRtpSession (SIPCall *ca); + + /** + * Start the audio rtp thread of the type specified in the configuration + * file. initAudioRtpSession must have been called prior to that. + * @param None + */ + void start (AudioCodec*); + + /** + * Stop the audio rtp thread of the type specified in the configuration + * file. initAudioRtpSession must have been called prior to that. + * @param None + */ + void stop(); + + /** + * Update current RTP destination address with one stored in call + * @param None + */ + void updateDestinationIpAddress (void); + + /** + * @param None + * @return The internal audio rtp thread of the type specified in the configuration + * file. initAudioRtpSession must have been called prior to that. + */ + inline void * getAudioRtpSession (void) { + return _rtpSession; + } + + AudioSymmetricRtpSession * getAudioSymetricRtpSession(); + + /** + * @param None + * @return The internal audio rtp session type + * Symmetric = 0 + * Zrtp = 1 + * Sdes = 2 + */ + inline RtpMethod getAudioRtpType (void) { + return _rtpSessionType; + } + + /** + * @param Set internal audio rtp session type (Symmetric, Zrtp, Sdes) + */ + inline void setAudioRtpType (RtpMethod type) { + _rtpSessionType = type; + } + + /** + * Manually set the srtpEnable option (usefull for RTP fallback) + */ + void setSrtpEnabled (bool enable) { + _srtpEnabled = enable; + } + + /** + * Manually set the keyExchangeProtocol parameter (usefull for RTP fallback) + */ + void setKeyExchangeProtocol (int proto) { + _keyExchangeProtocol = proto; + } + + /** + * Manually set the setHelloHashEnabled parameter (usefull for RTP fallback) + */ + void setHelloHashEnabled (bool enable) { + _helloHashEnabled = enable; + } + + /** + * Get the current AudioZrtpSession. Throws an AudioRtpFactoryException + * if the current rtp thread is null, or if it's not of the correct type. + * @return The current AudioZrtpSession thread. + */ + sfl::AudioZrtpSession * getAudioZrtpSession(); + + /** + * Set remote cryptographic info. Should be called after negotiation in SDP + * offer/answer session. + */ + void setRemoteCryptoInfo (sfl::SdesNegotiator& nego); + + /** + * Send DTMF over RTP (RFC2833). The timestamp and sequence number must be + * incremented as if it was microphone audio. This function change the payload type of the rtp session, + * send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get + * back the codec payload for further audio processing. + */ + void sendDtmfDigit (int digit); + + private: + void * _rtpSession; + RtpMethod _rtpSessionType; + ost::Mutex _audioRtpThreadMutex; + + // Field used when initializinga udio rtp session + // May be set manually or from config using initAudioRtpConfig + bool _srtpEnabled; + + // Field used when initializinga udio rtp session + // May be set manually or from config using initAudioRtpConfig + int _keyExchangeProtocol; + + // Field used when initializinga udio rtp session + // May be set manually or from config using initAudioRtpConfig + bool _helloHashEnabled; }; } #endif // __AUDIO_RTP_FACTORY_H__ diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.h b/sflphone-common/src/audio/audiortp/AudioRtpSession.h index cd4f7edc3cea7a36f2a38aa498970c714e1f130f..6f5b94b9ff9d07d944081fce6869ab87801c7073 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.h @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -57,768 +57,774 @@ // Frequency (in packet number) #define RTP_TIMESTAMP_RESET_FREQ 100 -namespace sfl { - - static const int schedulingTimeout = 100000; - static const int expireTimeout = 1000000; - - - class AudioRtpSessionException: public std::exception - { - virtual const char* what() const throw() - { - return "AudioRtpSessionException occured"; - } - }; - - typedef struct DtmfEvent { - ost::RTPPacket::RFC2833Payload payload; - int length; - bool newevent; - } DtmfEvent; - - typedef list<DtmfEvent *> EventQueue; - - template <typename D> - class AudioRtpSession : public ost::Thread, public ost::TimerPort { - public: - /** - * Constructor - * @param sipcall The pointer on the SIP call - */ - AudioRtpSession (ManagerImpl * manager, SIPCall* sipcall); - - ~AudioRtpSession(); - - // Thread associated method - virtual void run (); - - int startRtpThread(AudioCodec*); - - /** - * Used mostly when receiving a reinvite - */ - void updateDestinationIpAddress(void); - - void putDtmfEvent(int digit); - - /** - * Send DTMF over RTP (RFC2833). The timestamp and sequence number must be - * incremented as if it was microphone audio. This function change the payload type of the rtp session, - * send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get - * back the codec payload for further audio processing. - */ - void sendDtmfEvent(sfl::DtmfEvent *dtmf); - - inline float computeCodecFrameSize (int codecSamplePerFrame, int codecClockRate) { - return ( (float) codecSamplePerFrame * 1000.0) / (float) codecClockRate; - } +namespace sfl +{ - int computeNbByteAudioLayer (float codecFrameSize) { - return (int) ( ((float) _converterSamplingRate * codecFrameSize * sizeof(SFLDataFormat))/ 1000.0); - } +static const int schedulingTimeout = 100000; +static const int expireTimeout = 1000000; - private: - - void initBuffers(void); - - void setSessionTimeouts(void); - void setSessionMedia(AudioCodec*); - void setDestinationIpAddress(void); - - int processDataEncode(void); - void processDataDecode(unsigned char * spkrData, unsigned int size); - - void sendMicData(); - void receiveSpeakerData (); - - ost::Time * _time; - - // This semaphore is not used - // but is needed in order to avoid - // ambiguous compiling problem. - // It is set to 0, and since it is - // optional in ost::thread, then - // it amounts to the same as doing - // start() with no semaphore at all. - ost::Semaphore * _mainloopSemaphore; - - // Main destination address for this rtp session. - // Stored in case or reINVITE, which may require to forget - // this destination and update a new one. - ost::InetHostAddress _remote_ip; - - - // Main destination port for this rtp session. - // Stored in case reINVITE, which may require to forget - // this destination and update a new one - unsigned short _remote_port; - - AudioCodec * _audiocodec; - - AudioLayer * _audiolayer; - - /** Mic-data related buffers */ - SFLDataFormat* _micData; - SFLDataFormat* _micDataConverted; - unsigned char* _micDataEncoded; - - /** Speaker-data related buffers */ - SFLDataFormat* _spkrDataDecoded; - SFLDataFormat* _spkrDataConverted; - - /** Sample rate converter object */ - SamplerateConverter * _converter; - - /** Variables to process audio stream: sample rate for playing sound (typically 44100HZ) */ - int _layerSampleRate; - - /** Sample rate of the codec we use to encode and decode (most of time 8000HZ) */ - int _codecSampleRate; - - /** Length of the sound frame we capture in ms (typically 20ms) */ - int _layerFrameSize; - - /** Codecs frame size in samples (20 ms => 882 at 44.1kHz) - The exact value is stored in the codec */ - int _codecFrameSize; - - /** Speaker buffer length in samples once the data are resampled - * (used for mixing and recording) - */ - int _nSamplesSpkr; - - /** Mic buffer length in samples once the data are resampled - * (used for mixing and recording) - */ - int _nSamplesMic; - - /** - * Maximum number of sample for audio buffers (mic and spkr) - */ - int _nbSamplesMax; - - /** - * Manager instance. - */ - ManagerImpl * _manager; - - /** - * Sampling rate of audio converter - */ - int _converterSamplingRate; - - /** - * Timestamp for this session - */ - int _timestamp; - - /** - * Timestamp incrementation value based on codec period length (framesize) - * except for G722 which require a 8 kHz incrementation. - */ - int _timestampIncrement; - - /** - * Timestamp reset freqeuncy specified in number of packet sent - */ - short _timestampCount; - - /** - * Time counter used to trigger incoming call notification - */ - int _countNotificationTime; - - /** - * EventQueue used to store list of DTMF- - */ - EventQueue _eventQueue; - - /** - * Adaptive jitter buffer - */ - jitterbuf * _jbuffer; - - /** - * Packet size in ms - */ - int _packetLength; - - int _ts; - - /** - * Current time in ms - */ - int _currentTime; - - SpeexPreprocessState *_noiseState; - - protected: - - SIPCall * _ca; - - bool onRTPPacketRecv(ost::IncomingRTPPkt&); - }; - - template <typename D> - AudioRtpSession<D>::AudioRtpSession(ManagerImpl * manager, SIPCall * sipcall) : - _time (new ost::Time()), - _mainloopSemaphore(0), - _audiocodec (NULL), - _audiolayer (NULL), - _micData (NULL), - _micDataConverted (NULL), - _micDataEncoded (NULL), - _spkrDataDecoded (NULL), - _spkrDataConverted (NULL), - _converter (NULL), - _layerSampleRate(0), - _codecSampleRate(0), - _layerFrameSize(0), - _manager(manager), - _converterSamplingRate(0), - _timestamp(0), - _timestampIncrement(0), - _timestampCount(0), - _countNotificationTime(0), - _jbuffer(NULL), - _noiseState(NULL), - _ca (sipcall) - { - setCancel (cancelDefault); - - assert(_ca); - - _info ("Rtp: Local audio port %i will be used", _ca->getLocalAudioPort()); - - //mic, we receive from soundcard in stereo, and we send encoded - _audiolayer = _manager->getAudioDriver(); - - if (_audiolayer == NULL) { throw AudioRtpSessionException(); } - - _layerFrameSize = _audiolayer->getFrameSize(); // in ms - _layerSampleRate = _audiolayer->getSampleRate(); - - _jbuffer = jb_new(); - - _jbuffer->info.conf.max_jitterbuf = 1000; - _jbuffer->info.conf.target_extra = 100; - _jbuffer->info.silence_begin_ts = 0; - - _ts= 0; - _packetLength = 20; - _currentTime = 0; - } - - template <typename D> - AudioRtpSession<D>::~AudioRtpSession() - { - _debug ("RTP: Delete AudioRtpSession instance"); - - try { - terminate(); - } catch (...) { - _debugException ("Thread destructor didn't terminate correctly"); - throw; + +class AudioRtpSessionException: public std::exception +{ + virtual const char* what() const throw() { + return "AudioRtpSessionException occured"; + } +}; + +typedef struct DtmfEvent { + ost::RTPPacket::RFC2833Payload payload; + int length; + bool newevent; +} DtmfEvent; + +typedef list<DtmfEvent *> EventQueue; + +template <typename D> +class AudioRtpSession : public ost::Thread, public ost::TimerPort +{ + public: + /** + * Constructor + * @param sipcall The pointer on the SIP call + */ + AudioRtpSession (ManagerImpl * manager, SIPCall* sipcall); + + ~AudioRtpSession(); + + // Thread associated method + virtual void run (); + + int startRtpThread (AudioCodec*); + + /** + * Used mostly when receiving a reinvite + */ + void updateDestinationIpAddress (void); + + void putDtmfEvent (int digit); + + /** + * Send DTMF over RTP (RFC2833). The timestamp and sequence number must be + * incremented as if it was microphone audio. This function change the payload type of the rtp session, + * send the appropriate DTMF digit using this payload, discard coresponding data from mainbuffer and get + * back the codec payload for further audio processing. + */ + void sendDtmfEvent (sfl::DtmfEvent *dtmf); + + inline float computeCodecFrameSize (int codecSamplePerFrame, int codecClockRate) { + return ( (float) codecSamplePerFrame * 1000.0) / (float) codecClockRate; + } + + int computeNbByteAudioLayer (float codecFrameSize) { + return (int) ( ( (float) _converterSamplingRate * codecFrameSize * sizeof (SFLDataFormat)) / 1000.0); } - _manager->getAudioDriver()->getMainBuffer()->unBindAll(_ca->getCallId()); + private: - delete [] _micData; - delete [] _micDataConverted; - delete [] _micDataEncoded; - delete [] _spkrDataDecoded; - delete [] _spkrDataConverted; - delete _time; - delete _converter; + void initBuffers (void); - if (_audiocodec) { - delete _audiocodec; _audiocodec = NULL; - } + void setSessionTimeouts (void); + void setSessionMedia (AudioCodec*); + void setDestinationIpAddress (void); + + int processDataEncode (void); + void processDataDecode (unsigned char * spkrData, unsigned int size); + + void sendMicData(); + void receiveSpeakerData (); + + ost::Time * _time; + + // This semaphore is not used + // but is needed in order to avoid + // ambiguous compiling problem. + // It is set to 0, and since it is + // optional in ost::thread, then + // it amounts to the same as doing + // start() with no semaphore at all. + ost::Semaphore * _mainloopSemaphore; + + // Main destination address for this rtp session. + // Stored in case or reINVITE, which may require to forget + // this destination and update a new one. + ost::InetHostAddress _remote_ip; + + + // Main destination port for this rtp session. + // Stored in case reINVITE, which may require to forget + // this destination and update a new one + unsigned short _remote_port; + + AudioCodec * _audiocodec; - if(_jbuffer) { - jb_destroy(_jbuffer); - } + AudioLayer * _audiolayer; - if(_noiseState) { - speex_preprocess_state_destroy(_noiseState); - } - + /** Mic-data related buffers */ + SFLDataFormat* _micData; + SFLDataFormat* _micDataConverted; + unsigned char* _micDataEncoded; + + /** Speaker-data related buffers */ + SFLDataFormat* _spkrDataDecoded; + SFLDataFormat* _spkrDataConverted; + + /** Sample rate converter object */ + SamplerateConverter * _converter; + + /** Variables to process audio stream: sample rate for playing sound (typically 44100HZ) */ + int _layerSampleRate; + + /** Sample rate of the codec we use to encode and decode (most of time 8000HZ) */ + int _codecSampleRate; + + /** Length of the sound frame we capture in ms (typically 20ms) */ + int _layerFrameSize; + + /** Codecs frame size in samples (20 ms => 882 at 44.1kHz) + The exact value is stored in the codec */ + int _codecFrameSize; + + /** Speaker buffer length in samples once the data are resampled + * (used for mixing and recording) + */ + int _nSamplesSpkr; + + /** Mic buffer length in samples once the data are resampled + * (used for mixing and recording) + */ + int _nSamplesMic; + + /** + * Maximum number of sample for audio buffers (mic and spkr) + */ + int _nbSamplesMax; + + /** + * Manager instance. + */ + ManagerImpl * _manager; + + /** + * Sampling rate of audio converter + */ + int _converterSamplingRate; + + /** + * Timestamp for this session + */ + int _timestamp; + + /** + * Timestamp incrementation value based on codec period length (framesize) + * except for G722 which require a 8 kHz incrementation. + */ + int _timestampIncrement; + + /** + * Timestamp reset freqeuncy specified in number of packet sent + */ + short _timestampCount; + + /** + * Time counter used to trigger incoming call notification + */ + int _countNotificationTime; + + /** + * EventQueue used to store list of DTMF- + */ + EventQueue _eventQueue; + + /** + * Adaptive jitter buffer + */ + jitterbuf * _jbuffer; + + /** + * Packet size in ms + */ + int _packetLength; + + int _ts; + + /** + * Current time in ms + */ + int _currentTime; + + SpeexPreprocessState *_noiseState; + + protected: + + SIPCall * _ca; + + bool onRTPPacketRecv (ost::IncomingRTPPkt&); +}; + +template <typename D> +AudioRtpSession<D>::AudioRtpSession (ManagerImpl * manager, SIPCall * sipcall) : + _time (new ost::Time()), + _mainloopSemaphore (0), + _audiocodec (NULL), + _audiolayer (NULL), + _micData (NULL), + _micDataConverted (NULL), + _micDataEncoded (NULL), + _spkrDataDecoded (NULL), + _spkrDataConverted (NULL), + _converter (NULL), + _layerSampleRate (0), + _codecSampleRate (0), + _layerFrameSize (0), + _manager (manager), + _converterSamplingRate (0), + _timestamp (0), + _timestampIncrement (0), + _timestampCount (0), + _countNotificationTime (0), + _jbuffer (NULL), + _noiseState (NULL), + _ca (sipcall) +{ + setCancel (cancelDefault); + + assert (_ca); + + _info ("Rtp: Local audio port %i will be used", _ca->getLocalAudioPort()); + + //mic, we receive from soundcard in stereo, and we send encoded + _audiolayer = _manager->getAudioDriver(); + + if (_audiolayer == NULL) { + throw AudioRtpSessionException(); } - - template <typename D> - void AudioRtpSession<D>::initBuffers() - { - // Set sampling rate, main buffer choose the highest one - _manager->getAudioDriver()->getMainBuffer()->setInternalSamplingRate(_codecSampleRate); - - // may be different than one already setted - _converterSamplingRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - // initialize SampleRate converter using AudioLayer's sampling rate - // (internal buffers initialized with maximal sampling rate and frame size) - _converter = new SamplerateConverter(_layerSampleRate, _layerFrameSize); + _layerFrameSize = _audiolayer->getFrameSize(); // in ms + _layerSampleRate = _audiolayer->getSampleRate(); + + _jbuffer = jb_new(); + + _jbuffer->info.conf.max_jitterbuf = 1000; + _jbuffer->info.conf.target_extra = 100; + _jbuffer->info.silence_begin_ts = 0; + + _ts= 0; + _packetLength = 20; + _currentTime = 0; +} - int nbSamplesMax = (int)(_codecSampleRate * _layerFrameSize /1000)*2; - _micData = new SFLDataFormat[nbSamplesMax]; - _micDataConverted = new SFLDataFormat[nbSamplesMax]; - _micDataEncoded = new unsigned char[nbSamplesMax]; - _spkrDataConverted = new SFLDataFormat[nbSamplesMax]; - _spkrDataDecoded = new SFLDataFormat[nbSamplesMax]; +template <typename D> +AudioRtpSession<D>::~AudioRtpSession() +{ + _debug ("RTP: Delete AudioRtpSession instance"); - _manager->addStream(_ca->getCallId()); + try { + terminate(); + } catch (...) { + _debugException ("Thread destructor didn't terminate correctly"); + throw; } - - template <typename D> - void AudioRtpSession<D>::setSessionTimeouts(void) - { - try { - static_cast<D*>(this)->setSchedulingTimeout (schedulingTimeout); - static_cast<D*>(this)->setExpireTimeout (expireTimeout); - } catch (...) { - _debugException ("Initialization failed while setting timeouts"); - throw AudioRtpSessionException(); - } + + _manager->getAudioDriver()->getMainBuffer()->unBindAll (_ca->getCallId()); + + delete [] _micData; + delete [] _micDataConverted; + delete [] _micDataEncoded; + delete [] _spkrDataDecoded; + delete [] _spkrDataConverted; + delete _time; + delete _converter; + + if (_audiocodec) { + delete _audiocodec; + _audiocodec = NULL; } - - template <typename D> - void AudioRtpSession<D>::setSessionMedia(AudioCodec* audiocodec) - { - _audiocodec = audiocodec; - - _debug ("RTP: Init codec payload %i", _audiocodec->getPayload()); - - _codecSampleRate = _audiocodec->getClockRate(); - _codecFrameSize = _audiocodec->getFrameSize(); - - // G722 requires timestamp to be incremented at 8 kHz - if (_audiocodec->getPayload() == 9) - _timestampIncrement = 160; - else - _timestampIncrement = _codecFrameSize; - - - _debug("RTP: Codec sampling rate: %d", _codecSampleRate); - _debug("RTP: Codec frame size: %d", _codecFrameSize); - _debug("RTP: RTP timestamp increment: %d", _timestampIncrement); - - // Even if specified as a 16 kHz codec, G722 requires rtp sending rate to be 8 kHz - if (_audiocodec->getPayload() == 9) { - _debug ("RTP: Setting G722 payload format"); - static_cast<D*>(this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate())); - } else if (_audiocodec->hasDynamicPayload()) { - _debug ("RTP: Setting dynamic payload format"); - static_cast<D*>(this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate())); - } else if (!_audiocodec->hasDynamicPayload() && _audiocodec->getPayload() != 9) { - _debug ("RTP: Setting static payload format"); - static_cast<D*>(this)->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) _audiocodec->getPayload())); - } - if(_noiseState) { - speex_preprocess_state_destroy(_noiseState); - _noiseState = NULL; - } - - _noiseState = speex_preprocess_state_init(_codecSampleRate, _codecFrameSize); - int i=1; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i); - i=-20; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i); - i=0; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC, &i); - i=8000; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC_TARGET, &i); - i=16000; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i); - i=0; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB, &i); - float f=0.0; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f); - f=0.0; - speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f); + if (_jbuffer) { + jb_destroy (_jbuffer); } - - template <typename D> - void AudioRtpSession<D>::setDestinationIpAddress(void) - { - if (_ca == NULL) { - _error ("RTP: Sipcall is gone."); - throw AudioRtpSessionException(); - } - - _info ("RTP: Setting IP address for the RTP session"); - // Store remote ip in case we would need to forget current destination - _remote_ip = ost::InetHostAddress(_ca->getLocalSDP()->get_remote_ip().c_str()); + if (_noiseState) { + speex_preprocess_state_destroy (_noiseState); + } - if (!_remote_ip) { - _warn("RTP: Target IP address (%s) is not correct!", - _ca->getLocalSDP()->get_remote_ip().data()); - return; - } +} - // Store remote port in case we would need to forget current destination - _remote_port = (unsigned short) _ca->getLocalSDP()->get_remote_audio_port(); +template <typename D> +void AudioRtpSession<D>::initBuffers() +{ + // Set sampling rate, main buffer choose the highest one + _manager->getAudioDriver()->getMainBuffer()->setInternalSamplingRate (_codecSampleRate); - _info("RTP: New remote address for session: %s:%d", - _ca->getLocalSDP()->get_remote_ip().data(), _remote_port); + // may be different than one already setted + _converterSamplingRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - if (! static_cast<D*>(this)->addDestination (_remote_ip, _remote_port)) { - _warn("RTP: Can't add new destination to session!"); - return; - } + // initialize SampleRate converter using AudioLayer's sampling rate + // (internal buffers initialized with maximal sampling rate and frame size) + _converter = new SamplerateConverter (_layerSampleRate, _layerFrameSize); + + int nbSamplesMax = (int) (_codecSampleRate * _layerFrameSize /1000) *2; + _micData = new SFLDataFormat[nbSamplesMax]; + _micDataConverted = new SFLDataFormat[nbSamplesMax]; + _micDataEncoded = new unsigned char[nbSamplesMax]; + _spkrDataConverted = new SFLDataFormat[nbSamplesMax]; + _spkrDataDecoded = new SFLDataFormat[nbSamplesMax]; + + _manager->addStream (_ca->getCallId()); +} + +template <typename D> +void AudioRtpSession<D>::setSessionTimeouts (void) +{ + try { + static_cast<D*> (this)->setSchedulingTimeout (schedulingTimeout); + static_cast<D*> (this)->setExpireTimeout (expireTimeout); + } catch (...) { + _debugException ("Initialization failed while setting timeouts"); + throw AudioRtpSessionException(); } +} - template <typename D> - void AudioRtpSession<D>::updateDestinationIpAddress(void) - { - // Destination address are stored in a list in ccrtp - // This method remove the current destination entry +template <typename D> +void AudioRtpSession<D>::setSessionMedia (AudioCodec* audiocodec) +{ + _audiocodec = audiocodec; + + _debug ("RTP: Init codec payload %i", _audiocodec->getPayload()); + + _codecSampleRate = _audiocodec->getClockRate(); + _codecFrameSize = _audiocodec->getFrameSize(); + + // G722 requires timestamp to be incremented at 8 kHz + if (_audiocodec->getPayload() == 9) + _timestampIncrement = 160; + else + _timestampIncrement = _codecFrameSize; + + + _debug ("RTP: Codec sampling rate: %d", _codecSampleRate); + _debug ("RTP: Codec frame size: %d", _codecFrameSize); + _debug ("RTP: RTP timestamp increment: %d", _timestampIncrement); + + // Even if specified as a 16 kHz codec, G722 requires rtp sending rate to be 8 kHz + if (_audiocodec->getPayload() == 9) { + _debug ("RTP: Setting G722 payload format"); + static_cast<D*> (this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate())); + } else if (_audiocodec->hasDynamicPayload()) { + _debug ("RTP: Setting dynamic payload format"); + static_cast<D*> (this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate())); + } else if (!_audiocodec->hasDynamicPayload() && _audiocodec->getPayload() != 9) { + _debug ("RTP: Setting static payload format"); + static_cast<D*> (this)->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) _audiocodec->getPayload())); + } - if(!static_cast<D*>(this)->forgetDestination(_remote_ip, _remote_port, _remote_port+1)) - _warn("RTP: Could not remove previous destination"); + if (_noiseState) { + speex_preprocess_state_destroy (_noiseState); + _noiseState = NULL; + } - // new destination is stored in call - // we just need to recall this method - setDestinationIpAddress(); + _noiseState = speex_preprocess_state_init (_codecSampleRate, _codecFrameSize); + int i=1; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i); + i=-20; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i); + i=0; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC, &i); + i=8000; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC_TARGET, &i); + i=16000; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i); + i=0; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB, &i); + float f=0.0; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f); + f=0.0; + speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f); +} + +template <typename D> +void AudioRtpSession<D>::setDestinationIpAddress (void) +{ + if (_ca == NULL) { + _error ("RTP: Sipcall is gone."); + throw AudioRtpSessionException(); } - - template<typename D> - void AudioRtpSession<D>::putDtmfEvent(int digit) - { - sfl::DtmfEvent *dtmf = new sfl::DtmfEvent(); + _info ("RTP: Setting IP address for the RTP session"); - dtmf->payload.event = digit; - dtmf->payload.ebit = false; // end of event bit - dtmf->payload.rbit = false; // reserved bit - dtmf->payload.duration = 1; // duration for this event - dtmf->newevent = true; - dtmf->length = 1000; + // Store remote ip in case we would need to forget current destination + _remote_ip = ost::InetHostAddress (_ca->getLocalSDP()->get_remote_ip().c_str()); + + if (!_remote_ip) { + _warn ("RTP: Target IP address (%s) is not correct!", + _ca->getLocalSDP()->get_remote_ip().data()); + return; + } - _eventQueue.push_back(dtmf); + // Store remote port in case we would need to forget current destination + _remote_port = (unsigned short) _ca->getLocalSDP()->get_remote_audio_port(); - _debug("RTP: Put Dtmf Event %d", _eventQueue.size()); + _info ("RTP: New remote address for session: %s:%d", + _ca->getLocalSDP()->get_remote_ip().data(), _remote_port); + if (! static_cast<D*> (this)->addDestination (_remote_ip, _remote_port)) { + _warn ("RTP: Can't add new destination to session!"); + return; } +} + +template <typename D> +void AudioRtpSession<D>::updateDestinationIpAddress (void) +{ + // Destination address are stored in a list in ccrtp + // This method remove the current destination entry - template<typename D> - void AudioRtpSession<D>::sendDtmfEvent(sfl::DtmfEvent *dtmf) - { - _debug("RTP: Send Dtmf %d", _eventQueue.size()); - - _timestamp += 160; - - // discard equivalent size of audio - processDataEncode(); - - // change Payload type for DTMF payload - static_cast<D*>(this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) 101, 8000)); - - // Set marker in case this is a new Event - if(dtmf->newevent) - static_cast<D*>(this)->setMark (true); - - static_cast<D*>(this)->putData (_timestamp, (const unsigned char*)(&(dtmf->payload)), sizeof(ost::RTPPacket::RFC2833Payload)); - - // This is no more a new event - if(dtmf->newevent) { - dtmf->newevent = false; - static_cast<D*>(this)->setMark (false); - } - - // get back the payload to audio - static_cast<D*>(this)->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) _audiocodec->getPayload())); - - // decrease length remaining to process for this event - dtmf->length -= 160; - - dtmf->payload.duration += 1; - - // next packet is going to be the last one - if((dtmf->length - 160) < 160) - dtmf->payload.ebit = true; - - if(dtmf->length < 160) { - delete dtmf; - _eventQueue.pop_front(); - } + if (!static_cast<D*> (this)->forgetDestination (_remote_ip, _remote_port, _remote_port+1)) + _warn ("RTP: Could not remove previous destination"); + + // new destination is stored in call + // we just need to recall this method + setDestinationIpAddress(); +} + +template<typename D> +void AudioRtpSession<D>::putDtmfEvent (int digit) +{ + + sfl::DtmfEvent *dtmf = new sfl::DtmfEvent(); + + dtmf->payload.event = digit; + dtmf->payload.ebit = false; // end of event bit + dtmf->payload.rbit = false; // reserved bit + dtmf->payload.duration = 1; // duration for this event + dtmf->newevent = true; + dtmf->length = 1000; + + _eventQueue.push_back (dtmf); + + _debug ("RTP: Put Dtmf Event %d", _eventQueue.size()); + +} + +template<typename D> +void AudioRtpSession<D>::sendDtmfEvent (sfl::DtmfEvent *dtmf) +{ + _debug ("RTP: Send Dtmf %d", _eventQueue.size()); + + _timestamp += 160; + + // discard equivalent size of audio + processDataEncode(); + + // change Payload type for DTMF payload + static_cast<D*> (this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) 101, 8000)); + + // Set marker in case this is a new Event + if (dtmf->newevent) + static_cast<D*> (this)->setMark (true); + + static_cast<D*> (this)->putData (_timestamp, (const unsigned char*) (& (dtmf->payload)), sizeof (ost::RTPPacket::RFC2833Payload)); + + // This is no more a new event + if (dtmf->newevent) { + dtmf->newevent = false; + static_cast<D*> (this)->setMark (false); } - template <typename D> - bool onRTPPacketRecv(ost::IncomingRTPPkt&) - { - _debug("AudioRtpSession: onRTPPacketRecv"); + // get back the payload to audio + static_cast<D*> (this)->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) _audiocodec->getPayload())); + + // decrease length remaining to process for this event + dtmf->length -= 160; + + dtmf->payload.duration += 1; - return true; + // next packet is going to be the last one + if ( (dtmf->length - 160) < 160) + dtmf->payload.ebit = true; + + if (dtmf->length < 160) { + delete dtmf; + _eventQueue.pop_front(); } +} +template <typename D> +bool onRTPPacketRecv (ost::IncomingRTPPkt&) +{ + _debug ("AudioRtpSession: onRTPPacketRecv"); - template <typename D> - int AudioRtpSession<D>::processDataEncode(void) - { - assert(_audiocodec); - assert(_audiolayer); + return true; +} - int _mainBufferSampleRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - // compute codec framesize in ms - float fixed_codec_framesize = computeCodecFrameSize (_audiocodec->getFrameSize(), _audiocodec->getClockRate()); +template <typename D> +int AudioRtpSession<D>::processDataEncode (void) +{ + assert (_audiocodec); + assert (_audiolayer); - // compute nb of byte to get coresponding to 20 ms at audio layer frame size (44.1 khz) - int maxBytesToGet = computeNbByteAudioLayer (fixed_codec_framesize); + int _mainBufferSampleRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - // available bytes inside ringbuffer - int availBytesFromMic = _manager->getAudioDriver()->getMainBuffer()->availForGet(_ca->getCallId()); + // compute codec framesize in ms + float fixed_codec_framesize = computeCodecFrameSize (_audiocodec->getFrameSize(), _audiocodec->getClockRate()); - // set available byte to maxByteToGet - int bytesAvail = (availBytesFromMic < maxBytesToGet) ? availBytesFromMic : maxBytesToGet; + // compute nb of byte to get coresponding to 20 ms at audio layer frame size (44.1 khz) + int maxBytesToGet = computeNbByteAudioLayer (fixed_codec_framesize); - if (bytesAvail == 0) { - memset(_micDataEncoded, 0, sizeof(SFLDataFormat)); - return _audiocodec->getFrameSize(); - } + // available bytes inside ringbuffer + int availBytesFromMic = _manager->getAudioDriver()->getMainBuffer()->availForGet (_ca->getCallId()); - // Get bytes from micRingBuffer to data_from_mic - int nbSample = _manager->getAudioDriver()->getMainBuffer()->getData(_micData , bytesAvail, 100, _ca->getCallId()) / sizeof (SFLDataFormat); + // set available byte to maxByteToGet + int bytesAvail = (availBytesFromMic < maxBytesToGet) ? availBytesFromMic : maxBytesToGet; - // nb bytes to be sent over RTP - int compSize = 0; + if (bytesAvail == 0) { + memset (_micDataEncoded, 0, sizeof (SFLDataFormat)); + return _audiocodec->getFrameSize(); + } - // test if resampling is required - if (_audiocodec->getClockRate() != _mainBufferSampleRate) { - int nb_sample_up = nbSample; + // Get bytes from micRingBuffer to data_from_mic + int nbSample = _manager->getAudioDriver()->getMainBuffer()->getData (_micData , bytesAvail, 100, _ca->getCallId()) / sizeof (SFLDataFormat); - _nSamplesMic = nbSample; + // nb bytes to be sent over RTP + int compSize = 0; - nbSample = _converter->downsampleData (_micData , _micDataConverted , _audiocodec->getClockRate(), _mainBufferSampleRate, nb_sample_up); + // test if resampling is required + if (_audiocodec->getClockRate() != _mainBufferSampleRate) { + int nb_sample_up = nbSample; - compSize = _audiocodec->codecEncode (_micDataEncoded, _micDataConverted, nbSample*sizeof (int16)); + _nSamplesMic = nbSample; - } else { + nbSample = _converter->downsampleData (_micData , _micDataConverted , _audiocodec->getClockRate(), _mainBufferSampleRate, nb_sample_up); - _nSamplesMic = nbSample; + compSize = _audiocodec->codecEncode (_micDataEncoded, _micDataConverted, nbSample*sizeof (int16)); - // no resampling required - compSize = _audiocodec->codecEncode (_micDataEncoded, _micData, nbSample*sizeof (int16)); - } + } else { - return compSize; + _nSamplesMic = nbSample; + + // no resampling required + compSize = _audiocodec->codecEncode (_micDataEncoded, _micData, nbSample*sizeof (int16)); } - - template <typename D> - void AudioRtpSession<D>::processDataDecode(unsigned char * spkrData, unsigned int size) { - if (_audiocodec != NULL) { + return compSize; +} +template <typename D> +void AudioRtpSession<D>::processDataDecode (unsigned char * spkrData, unsigned int size) +{ - int _mainBufferSampleRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); + if (_audiocodec != NULL) { - // Return the size of data in bytes - int expandedSize = _audiocodec->codecDecode (_spkrDataDecoded , spkrData , size); - // buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes - int nbSample = expandedSize / sizeof (SFLDataFormat); + int _mainBufferSampleRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - // test if resampling is required - if (_audiocodec->getClockRate() != _mainBufferSampleRate) { + // Return the size of data in bytes + int expandedSize = _audiocodec->codecDecode (_spkrDataDecoded , spkrData , size); - // Do sample rate conversion - int nb_sample_down = nbSample; + // buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes + int nbSample = expandedSize / sizeof (SFLDataFormat); - nbSample = _converter->upsampleData (_spkrDataDecoded, _spkrDataConverted, _codecSampleRate, _mainBufferSampleRate, nb_sample_down); + // test if resampling is required + if (_audiocodec->getClockRate() != _mainBufferSampleRate) { - // Store the number of samples for recording - _nSamplesSpkr = nbSample; + // Do sample rate conversion + int nb_sample_down = nbSample; - speex_preprocess_run(_noiseState, _spkrDataConverted); + nbSample = _converter->upsampleData (_spkrDataDecoded, _spkrDataConverted, _codecSampleRate, _mainBufferSampleRate, nb_sample_down); - // put data in audio layer, size in byte - _manager->getAudioDriver()->getMainBuffer()->putData (_spkrDataConverted, nbSample * sizeof (SFLDataFormat), 100, _ca->getCallId()); + // Store the number of samples for recording + _nSamplesSpkr = nbSample; + speex_preprocess_run (_noiseState, _spkrDataConverted); - } else { - // Store the number of samples for recording - _nSamplesSpkr = nbSample; + // put data in audio layer, size in byte + _manager->getAudioDriver()->getMainBuffer()->putData (_spkrDataConverted, nbSample * sizeof (SFLDataFormat), 100, _ca->getCallId()); - // speex_preprocess_run(_noiseState, _spkrDataDecoded); - // put data in audio layer, size in byte - _manager->getAudioDriver()->getMainBuffer()->putData (_spkrDataDecoded, expandedSize, 100, _ca->getCallId()); - } + } else { + // Store the number of samples for recording + _nSamplesSpkr = nbSample; - // Notify (with a beep) an incoming call when there is already a call - if (_manager->incomingCallWaiting() > 0) { - _countNotificationTime += _time->getSecond(); - int countTimeModulo = _countNotificationTime % 5000; - // _debug("countNotificationTime: %d\n", countNotificationTime); - // _debug("countTimeModulo: %d\n", countTimeModulo); - if ((countTimeModulo - _countNotificationTime) < 0) { - _manager->notificationIncomingCall(); - } - - _countNotificationTime = countTimeModulo; - } + // speex_preprocess_run(_noiseState, _spkrDataDecoded); - } - } - - template <typename D> - void AudioRtpSession<D>::sendMicData() - { - // STEP: - // 1. get data from mic - // 2. convert it to int16 - good sample, good rate - // 3. encode it - // 4. send it - - // Increment timestamp for outgoing packet - _timestamp += _timestampIncrement; - - if (!_audiolayer) { - _debug ("No audiolayer available for MIC"); - return; + // put data in audio layer, size in byte + _manager->getAudioDriver()->getMainBuffer()->putData (_spkrDataDecoded, expandedSize, 100, _ca->getCallId()); } - if (!_audiocodec) { - _debug ("No audiocodec available for MIC"); - return; + // Notify (with a beep) an incoming call when there is already a call + if (_manager->incomingCallWaiting() > 0) { + _countNotificationTime += _time->getSecond(); + int countTimeModulo = _countNotificationTime % 5000; + + // _debug("countNotificationTime: %d\n", countNotificationTime); + // _debug("countTimeModulo: %d\n", countTimeModulo); + if ( (countTimeModulo - _countNotificationTime) < 0) { + _manager->notificationIncomingCall(); + } + + _countNotificationTime = countTimeModulo; } - int compSize = processDataEncode(); + } +} - // putData put the data on RTP queue, sendImmediate bypass this queue - static_cast<D*>(this)->putData (_timestamp, _micDataEncoded, compSize); +template <typename D> +void AudioRtpSession<D>::sendMicData() +{ + // STEP: + // 1. get data from mic + // 2. convert it to int16 - good sample, good rate + // 3. encode it + // 4. send it + + // Increment timestamp for outgoing packet + _timestamp += _timestampIncrement; + + if (!_audiolayer) { + _debug ("No audiolayer available for MIC"); + return; } - - - template <typename D> - void AudioRtpSession<D>::receiveSpeakerData () - { - - if (!_audiolayer) { - _debug ("No audiolayer available for speaker"); - return; - } - if (!_audiocodec) { - _debug ("No audiocodec available for speaker"); - return; - } + if (!_audiocodec) { + _debug ("No audiocodec available for MIC"); + return; + } - const ost::AppDataUnit* adu = NULL; - int packetTimestamp = static_cast<D*>(this)->getFirstTimestamp(); - adu = static_cast<D*>(this)->getData(packetTimestamp); + int compSize = processDataEncode(); + + // putData put the data on RTP queue, sendImmediate bypass this queue + static_cast<D*> (this)->putData (_timestamp, _micDataEncoded, compSize); +} - if(!adu) { - return; - } - unsigned char* spkrDataIn = NULL; - unsigned int size = 0; - int result; +template <typename D> +void AudioRtpSession<D>::receiveSpeakerData () +{ - jb_frame frame; + if (!_audiolayer) { + _debug ("No audiolayer available for speaker"); + return; + } - _jbuffer->info.conf.resync_threshold = 0; + if (!_audiocodec) { + _debug ("No audiocodec available for speaker"); + return; + } - if (adu) { + const ost::AppDataUnit* adu = NULL; - spkrDataIn = (unsigned char*) adu->getData(); // data in char - size = adu->getSize(); // size in char + int packetTimestamp = static_cast<D*> (this)->getFirstTimestamp(); - result = jb_put(_jbuffer, spkrDataIn, JB_TYPE_VOICE, _packetLength, _ts+=20, _currentTime); + adu = static_cast<D*> (this)->getData (packetTimestamp); - } - else { - _debug("No RTP packet available !!!!!!!!!!!!!!!!!!!!!!!\n"); - } + if (!adu) { + return; + } - result = jb_get(_jbuffer, &frame, _currentTime+=20, _packetLength); + unsigned char* spkrDataIn = NULL; + unsigned int size = 0; + int result; - // DTMF over RTP, size must be over 4 in order to process it as voice data - if(size > 4) { - processDataDecode(spkrDataIn, size); - //if(result == JB_OK) { - // processDataDecode((unsigned char *)(frame.data), 160); - //} - } + jb_frame frame; - delete adu; + _jbuffer->info.conf.resync_threshold = 0; + + if (adu) { + + spkrDataIn = (unsigned char*) adu->getData(); // data in char + size = adu->getSize(); // size in char + + result = jb_put (_jbuffer, spkrDataIn, JB_TYPE_VOICE, _packetLength, _ts+=20, _currentTime); + + } else { + _debug ("No RTP packet available !!!!!!!!!!!!!!!!!!!!!!!\n"); } - - template <typename D> - int AudioRtpSession<D>::startRtpThread (AudioCodec* audiocodec) - { - _debug("RTP: Starting main thread"); - setSessionTimeouts(); - setSessionMedia(audiocodec); - initBuffers(); - return start(_mainloopSemaphore); + + result = jb_get (_jbuffer, &frame, _currentTime+=20, _packetLength); + + // DTMF over RTP, size must be over 4 in order to process it as voice data + if (size > 4) { + processDataDecode (spkrDataIn, size); + //if(result == JB_OK) { + // processDataDecode((unsigned char *)(frame.data), 160); + //} } - - template <typename D> - void AudioRtpSession<D>::run () - { - - // Timestamp must be initialized randomly - _timestamp = static_cast<D*>(this)->getCurrentTimestamp(); - - int sessionWaiting; - int threadSleep = 0; - - if (_codecSampleRate != 0){ - threadSleep = (_codecFrameSize * 1000) / _codecSampleRate; - } - else { - threadSleep = _layerFrameSize; - } - TimerPort::setTimer (threadSleep); - - if (_audiolayer == NULL) { - _error("RTP: Error: Audiolayer is null, cannot start the audio stream"); - throw AudioRtpSessionException(); - } + delete adu; +} + +template <typename D> +int AudioRtpSession<D>::startRtpThread (AudioCodec* audiocodec) +{ + _debug ("RTP: Starting main thread"); + setSessionTimeouts(); + setSessionMedia (audiocodec); + initBuffers(); + return start (_mainloopSemaphore); +} + +template <typename D> +void AudioRtpSession<D>::run () +{ - _ca->setRecordingSmplRate(_audiocodec->getClockRate()); + // Timestamp must be initialized randomly + _timestamp = static_cast<D*> (this)->getCurrentTimestamp(); - // Start audio stream (if not started) AND flush all buffers (main and urgent) - _manager->getAudioDriver()->startStream(); - static_cast<D*>(this)->startRunning(); + int sessionWaiting; + int threadSleep = 0; + if (_codecSampleRate != 0) { + threadSleep = (_codecFrameSize * 1000) / _codecSampleRate; + } else { + threadSleep = _layerFrameSize; + } - _debug ("RTP: Entering mainloop for call %s",_ca->getCallId().c_str()); + TimerPort::setTimer (threadSleep); - while (!testCancel()) { + if (_audiolayer == NULL) { + _error ("RTP: Error: Audiolayer is null, cannot start the audio stream"); + throw AudioRtpSessionException(); + } - // Reset timestamp to make sure the timing information are up to date - if(_timestampCount > RTP_TIMESTAMP_RESET_FREQ) { - _timestamp = static_cast<D*>(this)->getCurrentTimestamp(); - _timestampCount = 0; - } - _timestampCount++; + _ca->setRecordingSmplRate (_audiocodec->getClockRate()); - - _manager->getAudioLayerMutex()->enter(); + // Start audio stream (if not started) AND flush all buffers (main and urgent) + _manager->getAudioDriver()->startStream(); + static_cast<D*> (this)->startRunning(); - // converterSamplingRate = _audiolayer->getMainBuffer()->getInternalSamplingRate(); - _converterSamplingRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); - sessionWaiting = static_cast<D*>(this)->isWaiting(); + _debug ("RTP: Entering mainloop for call %s",_ca->getCallId().c_str()); - // Send session - if(_eventQueue.size() > 0) { - sendDtmfEvent(_eventQueue.front()); - } - else { - sendMicData (); - } + while (!testCancel()) { - // Recv session - receiveSpeakerData (); + // Reset timestamp to make sure the timing information are up to date + if (_timestampCount > RTP_TIMESTAMP_RESET_FREQ) { + _timestamp = static_cast<D*> (this)->getCurrentTimestamp(); + _timestampCount = 0; + } + + _timestampCount++; + + + _manager->getAudioLayerMutex()->enter(); + + // converterSamplingRate = _audiolayer->getMainBuffer()->getInternalSamplingRate(); + _converterSamplingRate = _manager->getAudioDriver()->getMainBuffer()->getInternalSamplingRate(); + + sessionWaiting = static_cast<D*> (this)->isWaiting(); + + // Send session + if (_eventQueue.size() > 0) { + sendDtmfEvent (_eventQueue.front()); + } else { + sendMicData (); + } - /* + // Recv session + receiveSpeakerData (); + + /* // Let's wait for the next transmit cycle if (sessionWaiting == 1) { @@ -828,18 +834,18 @@ namespace sfl { // Record mic only while leaving a message _ca->recAudio.recData (_micData,_nSamplesMic); } - */ + */ - _manager->getAudioLayerMutex()->leave(); + _manager->getAudioLayerMutex()->leave(); - // Let's wait for the next transmit cycle - Thread::sleep (TimerPort::getTimer()); - TimerPort::incTimer (threadSleep); - } - - _debug ("RTP: Left main loop for call%s", _ca->getCallId().c_str()); + // Let's wait for the next transmit cycle + Thread::sleep (TimerPort::getTimer()); + TimerPort::incTimer (threadSleep); } - + + _debug ("RTP: Left main loop for call%s", _ca->getCallId().c_str()); +} + } #endif // __AUDIO_RTP_SESSION_H__ diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp index 097567f2dfeadb8915aa193be31faff2713b931a..1054624e58deb7395e275abb504ea15060efd31b 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp @@ -256,7 +256,7 @@ void AudioSrtpSession::initializeLocalCryptoContext (void) } - +#pragma GCC diagnostic ignored "-Wunused-value" char* AudioSrtpSession::encodeBase64 (unsigned char *input, int length) { BIO *b64, *bmem; @@ -288,6 +288,7 @@ char* AudioSrtpSession::encodeBase64 (unsigned char *input, int length) return buffer; } +#pragma GCC diagnostic warning "-Wunused-value" char* AudioSrtpSession::decodeBase64 (unsigned char *input, int length, int *length_out) { diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h index 6b21cd329086c64ed6069dcaad53868d6668809c..48e6055df6a6c79caf36b456a8686d546552f6e0 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h @@ -11,7 +11,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -40,8 +40,8 @@ class SdesNegotiator; class ManagerImpl; class SIPCall; -/* - Table from RFC 4568 6.2. Crypto-Suites, which define key parameters for supported +/* + Table from RFC 4568 6.2. Crypto-Suites, which define key parameters for supported cipher suite +---------------------+-------------+--------------+---------------+ @@ -64,75 +64,75 @@ class SIPCall; */ -namespace sfl { +namespace sfl +{ - class SrtpException: public std::exception - { - virtual const char* what() const throw() - { - return "ZRTP ZID initialization failed."; +class SrtpException: public std::exception +{ + virtual const char* what() const throw() { + return "ZRTP ZID initialization failed."; } - }; +}; + +class AudioSrtpSession : public ost::SymmetricRTPSession, public AudioRtpSession<AudioSrtpSession> +{ + public: - class AudioSrtpSession : public ost::SymmetricRTPSession, public AudioRtpSession<AudioSrtpSession> - { - public: + AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall); - AudioSrtpSession(ManagerImpl * manager, SIPCall * sipcall); + std::vector<std::string> getLocalCryptoInfo (void); - std::vector<std::string> getLocalCryptoInfo(void); + void setRemoteCryptoInfo (sfl::SdesNegotiator& nego); - void setRemoteCryptoInfo(sfl::SdesNegotiator& nego); + private: - private: + void initializeLocalMasterKey (void); - void initializeLocalMasterKey(void); + void initializeLocalMasterSalt (void); - void initializeLocalMasterSalt(void); + void initializeRemoteCryptoContext (void); - void initializeRemoteCryptoContext(void); + void initializeLocalCryptoContext (void); - void initializeLocalCryptoContext(void); + std::string getBase64ConcatenatedKeys(); - std::string getBase64ConcatenatedKeys(); + void unBase64ConcatenatedKeys (std::string base64keys); - void unBase64ConcatenatedKeys(std::string base64keys); + char* encodeBase64 (unsigned char *input, int length); - char* encodeBase64(unsigned char *input, int length); + char* decodeBase64 (unsigned char *input, int length, int *length_out); - char* decodeBase64(unsigned char *input, int length, int *length_out); + /** Default local crypto suite is AES_CM_128_HMAC_SHA1_80*/ + int _localCryptoSuite; - /** Default local crypto suite is AES_CM_128_HMAC_SHA1_80*/ - int _localCryptoSuite; + /** Remote crypto suite is initialized at AES_CM_128_HMAC_SHA1_80*/ + int _remoteCryptoSuite; - /** Remote crypto suite is initialized at AES_CM_128_HMAC_SHA1_80*/ - int _remoteCryptoSuite; + uint8 _localMasterKey[16]; - uint8 _localMasterKey[16]; + /** local master key length in byte */ + int _localMasterKeyLength; - /** local master key length in byte */ - int _localMasterKeyLength; + uint8 _localMasterSalt[14]; - uint8 _localMasterSalt[14]; + /** local master salt length in byte */ + int _localMasterSaltLength; - /** local master salt length in byte */ - int _localMasterSaltLength; + uint8 _remoteMasterKey[16]; - uint8 _remoteMasterKey[16]; + /** remote master key length in byte */ + int _remoteMasterKeyLength; - /** remote master key length in byte */ - int _remoteMasterKeyLength; + uint8 _remoteMasterSalt[14]; - uint8 _remoteMasterSalt[14]; + /** remote master salt length in byte */ + int _remoteMasterSaltLength; - /** remote master salt length in byte */ - int _remoteMasterSaltLength; + ost::CryptoContext* _remoteCryptoCtx; - ost::CryptoContext* _remoteCryptoCtx; + ost::CryptoContext* _localCryptoCtx; +}; - ost::CryptoContext* _localCryptoCtx; - }; - } #endif // __AUDIO_SRTP_SESSION_H__ diff --git a/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.h b/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.h index c1260a6fc327529763dead3ef12f9cf4b001db59..a2275e3b508da1727d365fb03c2bfb10ff8bee80 100644 --- a/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioSymmetricRtpSession.h @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -35,17 +35,17 @@ class ManagerImpl; -namespace sfl { - class AudioSymmetricRtpSession : public ost::SymmetricRTPSession, public AudioRtpSession<AudioSymmetricRtpSession> - { - public: - AudioSymmetricRtpSession(ManagerImpl * manager, SIPCall * sipcall) : - ost::SymmetricRTPSession(ost::InetHostAddress(sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()), - AudioRtpSession<AudioSymmetricRtpSession>(manager, sipcall) - { - _debug("AudioSymmetricRtpSession initialized\n"); - } - }; +namespace sfl +{ +class AudioSymmetricRtpSession : public ost::SymmetricRTPSession, public AudioRtpSession<AudioSymmetricRtpSession> +{ + public: + AudioSymmetricRtpSession (ManagerImpl * manager, SIPCall * sipcall) : + ost::SymmetricRTPSession (ost::InetHostAddress (sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort()), + AudioRtpSession<AudioSymmetricRtpSession> (manager, sipcall) { + _debug ("AudioSymmetricRtpSession initialized\n"); + } +}; } #endif // __AUDIO_SYMMETRIC_RTP_SESSION_H__ diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h index f62515bcc9ad1712f59d49ecd6b91c9b5743bf1f..4eb68d364d8a6e057dc74de65bf2d13e9706dcc2 100644 --- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -36,26 +36,26 @@ class ManagerImpl; class SIPCall; -namespace sfl { +namespace sfl +{ - class ZrtpZidException: public std::exception - { - virtual const char* what() const throw() - { - return "ZRTP ZID initialization failed."; +class ZrtpZidException: public std::exception +{ + virtual const char* what() const throw() { + return "ZRTP ZID initialization failed."; } - }; - - class AudioZrtpSession : public ost::SymmetricZRTPSession, public AudioRtpSession<AudioZrtpSession> - { - public: - AudioZrtpSession(ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename); - - private: - void initializeZid(void); - std::string _zidFilename; - }; - +}; + +class AudioZrtpSession : public ost::SymmetricZRTPSession, public AudioRtpSession<AudioZrtpSession> +{ + public: + AudioZrtpSession (ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename); + + private: + void initializeZid (void); + std::string _zidFilename; +}; + } #endif // __AUDIO_ZRTP_SESSION_H__ diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h index 41e417e3f58aa0da0bca2f10e772bf08ee857145..f883e09dd8c5aec7de936995b3a4ad6aa972d087 100644 --- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h +++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h @@ -27,7 +27,7 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __SFL_ZRTP_CALLBACK_H__ #define __SFL_ZRTP_CALLBACK_H__ @@ -40,36 +40,37 @@ class SIPCall; class DBusManagerImpl; -namespace sfl { +namespace sfl +{ - class ZrtpSessionCallbackException: public std::exception - { - virtual const char* what() const throw() - { - return "An exception occured while being in a zrtp callback\n"; +class ZrtpSessionCallbackException: public std::exception +{ + virtual const char* what() const throw() { + return "An exception occured while being in a zrtp callback\n"; } - }; - - class ZrtpSessionCallback: public ZrtpUserCallback { +}; + +class ZrtpSessionCallback: public ZrtpUserCallback +{ public: - ZrtpSessionCallback(SIPCall *sipcall); + ZrtpSessionCallback (SIPCall *sipcall); - void secureOn(std::string cipher); - void secureOff(void); - void showSAS(std::string sas, bool verified); - void zrtpNotSuppOther(void); - void showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subCode); - void zrtpNegotiationFailed(GnuZrtpCodes::MessageSeverity severity, int subCode); + void secureOn (std::string cipher); + void secureOff (void); + void showSAS (std::string sas, bool verified); + void zrtpNotSuppOther (void); + void showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t subCode); + void zrtpNegotiationFailed (GnuZrtpCodes::MessageSeverity severity, int subCode); void confirmGoClear(); - + private: SIPCall* _sipcall; - + static std::map<int32, std::string*> _infoMap; static std::map<int32, std::string*> _warningMap; static std::map<int32, std::string*> _severeMap; static std::map<int32, std::string*> _zrtpMap; static bool _mapInitialized; - }; +}; } #endif diff --git a/sflphone-common/src/audio/codecs/audiocodec.h b/sflphone-common/src/audio/codecs/audiocodec.h index d0d299ca8718fb0f153ec1318853c69c49a1f73d..485cf9d3042bceb0194514fbbbfc5e7b6d73dd87 100644 --- a/sflphone-common/src/audio/codecs/audiocodec.h +++ b/sflphone-common/src/audio/codecs/audiocodec.h @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -33,96 +33,115 @@ #ifndef _CODEC_AUDIO_H #define _CODEC_AUDIO_H -#include <string> +#include <string> #include <iostream> #include <dlfcn.h> -class AudioCodec { -protected: - /** Holds SDP-compliant codec name */ - std::string _codecName; // what we put inside sdp - - /** Clock rate or sample rate of the codec, in Hz */ - int _clockRate; - - /** Number of channel 1 = mono, 2 = stereo */ - int _channel; - - /** codec frame size in samples*/ - int _frameSize; - - /** Bitrate */ - double _bitrate; - /** Bandwidth */ - double _bandwidth; - -private: - int _payload; - bool _hasDynamicPayload; - bool _state; - -public: - AudioCodec(int payload, const std::string &codecName) - : _codecName(codecName), _clockRate(8000), _channel(1), _bitrate(0.0),_bandwidth(0),_payload(payload), _hasDynamicPayload(false),_state(true) { - - _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; - - // If g722 (payload 9), we need to init libccrtp symetric sessions with using - // dynamic payload format. This way we get control on rtp clockrate. - - if(_payload == 9) - { - _hasDynamicPayload = true; - } - -} - - AudioCodec( const AudioCodec& codec ) - : _codecName(codec._codecName), _clockRate(codec._clockRate), _channel(codec._channel), _bitrate(codec._bitrate),_bandwidth(codec._bandwidth),_payload(codec._payload), _hasDynamicPayload(false),_state(true) { - - _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; - - // If g722 (payload 9), we need to init libccrtp symetric sessions with using - // dynamic payload format. This way we get control on rtp clockrate. - - if(_payload == 9) - { - _hasDynamicPayload = true; - } - -} - - virtual ~AudioCodec() { - } - /** - * Decode an input buffer and fill the output buffer with the decoded data - * @return the number of bytes decoded - */ - virtual int codecDecode(short *, unsigned char *, unsigned int) = 0; - - /** - * Encode an input buffer and fill the output buffer with the encoded data - * @return the number of bytes encoded - */ - virtual int codecEncode(unsigned char *, short *, unsigned int) = 0; - - - /** Value used for SDP negotiation */ - std::string getCodecName( void ) { return _codecName; } - int getPayload( void ) { return _payload; } - bool hasDynamicPayload( void ) { return _hasDynamicPayload; } - int getClockRate( void ) { return _clockRate; } - int getFrameSize( void ) { return _frameSize; } - int getChannel( void ) { return _channel; } - bool getState( void ) { return _state; } - void setState(bool b) { _state = b; } - double getBitRate( void ) { return _bitrate; } - double getBandwidth( void ) { return _bandwidth; } +class AudioCodec +{ + protected: + /** Holds SDP-compliant codec name */ + std::string _codecName; // what we put inside sdp + + /** Clock rate or sample rate of the codec, in Hz */ + int _clockRate; + + /** Number of channel 1 = mono, 2 = stereo */ + int _channel; + + /** codec frame size in samples*/ + int _frameSize; + + /** Bitrate */ + double _bitrate; + /** Bandwidth */ + double _bandwidth; + + private: + int _payload; + bool _hasDynamicPayload; + bool _state; + + public: + AudioCodec (int payload, const std::string &codecName) + : _codecName (codecName), _clockRate (8000), _channel (1), _bitrate (0.0),_bandwidth (0),_payload (payload), _hasDynamicPayload (false),_state (true) { + + _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; + + // If g722 (payload 9), we need to init libccrtp symetric sessions with using + // dynamic payload format. This way we get control on rtp clockrate. + + if (_payload == 9) { + _hasDynamicPayload = true; + } + + } + + AudioCodec (const AudioCodec& codec) + : _codecName (codec._codecName), _clockRate (codec._clockRate), _channel (codec._channel), _bitrate (codec._bitrate),_bandwidth (codec._bandwidth),_payload (codec._payload), _hasDynamicPayload (false),_state (true) { + + _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; + + // If g722 (payload 9), we need to init libccrtp symetric sessions with using + // dynamic payload format. This way we get control on rtp clockrate. + + if (_payload == 9) { + _hasDynamicPayload = true; + } + + } + + virtual ~AudioCodec() { + } + /** + * Decode an input buffer and fill the output buffer with the decoded data + * @return the number of bytes decoded + */ + virtual int codecDecode (short *, unsigned char *, unsigned int) = 0; + + /** + * Encode an input buffer and fill the output buffer with the encoded data + * @return the number of bytes encoded + */ + virtual int codecEncode (unsigned char *, short *, unsigned int) = 0; + + + /** Value used for SDP negotiation */ + std::string getCodecName (void) { + return _codecName; + } + int getPayload (void) { + return _payload; + } + bool hasDynamicPayload (void) { + return _hasDynamicPayload; + } + int getClockRate (void) { + return _clockRate; + } + int getFrameSize (void) { + return _frameSize; + } + int getChannel (void) { + return _channel; + } + bool getState (void) { + return _state; + } + void setState (bool b) { + _state = b; + } + double getBitRate (void) { + return _bitrate; + } + double getBandwidth (void) { + return _bandwidth; + } }; // the types of the class factories typedef AudioCodec* create_t(); -typedef void destroy_t(AudioCodec*); +typedef void destroy_t (AudioCodec*); #endif diff --git a/sflphone-common/src/audio/codecs/codecDescriptor.h b/sflphone-common/src/audio/codecs/codecDescriptor.h index 9b5b1ea126f3e43b07a3679094d49b0a63af2d21..4393a0892afa37396eb11ce90cdef3d70ef6d00b 100644 --- a/sflphone-common/src/audio/codecs/codecDescriptor.h +++ b/sflphone-common/src/audio/codecs/codecDescriptor.h @@ -3,17 +3,17 @@ * Author: Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -45,7 +45,7 @@ typedef std::pair<AudioCodec* , void*> CodecHandlePointer; /** Maps a pointer on an audiocodec object to a payload */ typedef std::map<AudioCodecType , AudioCodec*> CodecsMap; -/** A codec is identified by its payload. A payload is associated with a name. */ +/** A codec is identified by its payload. A payload is associated with a name. */ typedef std::map<AudioCodecType, std::string> CodecMap; /* @@ -53,189 +53,194 @@ typedef std::map<AudioCodecType, std::string> CodecMap; * @brief Handle audio codecs, load them in memory */ -class CodecDescriptor { - public: - /** - * Constructor - */ - CodecDescriptor(); - - /** - * Destructor - */ - ~CodecDescriptor(); - - /** - * Accessor to data structures - * @return CodecsMap& The available codec - */ - CodecsMap& getCodecsMap() { return _CodecsMap; } - - /** - * Accessor to data structures - * @return CodecOrder& The list that reflects the user's choice - */ - // CodecOrder& getActiveCodecs() { return _codecOrder; } - - /** - * Get codec name by its payload - * @param payload the payload looked for - * same as getPayload() - * @return std::string The name of the codec - */ - std::string getCodecName(AudioCodecType payload); - - /** - * Get the codec object associated with the payload - * @param payload The payload looked for - * @return AudioCodec* A pointer on a AudioCodec object - */ - AudioCodec* getCodec( AudioCodecType payload ); - - /** - * Initialiaze the map with all the supported codecs, even those inactive - */ - void init(); - - /** - * Set the default codecs order. - * This order will be apply to each account by default - */ - void setDefaultOrder(); - - /** - * Get the bit rate of the specified codec. - * @param payload The payload of the codec - * @return double The bit rate - */ - double getBitRate(AudioCodecType payload); - - /** - * Get the bandwidth for one call with the specified codec. - * The value has been calculated with the further information: - * RTp communication, SIP protocol (the value with IAX2 is very close), no RTCP, one simultaneous call, for one channel (the incoming one). - * @param payload The payload of the codec - * @return double The bandwidth - */ - double getBandwidthPerCall(AudioCodecType payload); - - /** - * Get the clock rate of the specified codec - * @param payload The payload of the codec - * @return int The clock rate of the specified codec - */ - int getSampleRate(AudioCodecType payload); - - /** - * Set the order of codecs by their payload - * @param list The ordered list sent by DBus - */ - void saveActiveCodecs(const std::vector<std::string>& list); - - /** - * Get the number of codecs loaded in dynamic memory - * @return int The number - */ - int getCodecsNumber( void ) { return _nbCodecs; } - - /** - * Unreferences the codecs loaded in memory - */ - void deleteHandlePointer( void ); - - /** - * Get the first element of the CodecsMap struct. - * i.e the one with the lowest payload - * @return AudioCodec The pointer on the codec object - */ - AudioCodec* getFirstCodecAvailable( void ); - - /** - * Instantiate a codec, used in AudioRTP to get an instance of Codec per call - * @param CodecHandlePointer The map containing the pointer on the object and the pointer on the handle function - */ - AudioCodec* instantiateCodec(AudioCodecType payload); - - /** - * For a given codec, return its specification - * - * @param payload The RTP payload of the codec - * @return std::vector <std::string> A vector containing codec's name, sample rate, bandwidth and bit rate - */ - std::vector <std::string> getCodecSpecifications (const int32_t& payload); - - /** - * Check if the audiocodec object has been successfully created - * @param payload The payload of the codec - * @return bool True if the audiocodec has been created - * false otherwise - */ - bool isCodecLoaded( int payload ); - - private: - - /** - * Scan the installation directory ( --prefix configure option ) - * And load the dynamic library - * @return std::vector<AudioCodec*> The list of the codec object successfully loaded in memory - */ - std::vector<AudioCodec *> scanCodecDirectory( void ); - - /** - * Load a codec - * @param std::string The path of the shared ( dynamic ) library. - * @return AudioCodec* the pointer of the object loaded. - */ - AudioCodec* loadCodec( std::string ); - - /** - * Unload a codec - * @param CodecHandlePointer The map containing the pointer on the object and the pointer on the handle function - */ - void unloadCodec( CodecHandlePointer ); - - /** - * Check if the files found in searched directories seems valid - * @param std::string The name of the file - * @return bool True if the file name begins with libcodec_ and ends with .so - * false otherwise - */ - bool seemsValid( std::string ); - - /** - * Check if the codecs shared library has already been scanned during the session - * Useful not to load twice the same codec saved in the different directory - * @param std::string The complete name of the shared directory ( without the path ) - * @return bool True if the codecs has been scanned - * false otherwise - */ - bool alreadyInCache( std::string ); - - /** - * Map the payload of a codec and the object associated ( AudioCodec * ) - */ - CodecsMap _CodecsMap; - - /** - * Vector containing a default order for the codecs - */ - CodecOrder _defaultCodecOrder; - - /** - * Vector containing the complete name of the codec shared library scanned - */ - std::vector<std::string> _Cache; - - /** - * Number of codecs loaded - */ - int _nbCodecs; - - /** - * Vector containing pairs - * Pair between pointer on function handle and pointer on audiocodec object - */ - std::vector< CodecHandlePointer > _CodecInMemory; +class CodecDescriptor +{ + public: + /** + * Constructor + */ + CodecDescriptor(); + + /** + * Destructor + */ + ~CodecDescriptor(); + + /** + * Accessor to data structures + * @return CodecsMap& The available codec + */ + CodecsMap& getCodecsMap() { + return _CodecsMap; + } + + /** + * Accessor to data structures + * @return CodecOrder& The list that reflects the user's choice + */ + // CodecOrder& getActiveCodecs() { return _codecOrder; } + + /** + * Get codec name by its payload + * @param payload the payload looked for + * same as getPayload() + * @return std::string The name of the codec + */ + std::string getCodecName (AudioCodecType payload); + + /** + * Get the codec object associated with the payload + * @param payload The payload looked for + * @return AudioCodec* A pointer on a AudioCodec object + */ + AudioCodec* getCodec (AudioCodecType payload); + + /** + * Initialiaze the map with all the supported codecs, even those inactive + */ + void init(); + + /** + * Set the default codecs order. + * This order will be apply to each account by default + */ + void setDefaultOrder(); + + /** + * Get the bit rate of the specified codec. + * @param payload The payload of the codec + * @return double The bit rate + */ + double getBitRate (AudioCodecType payload); + + /** + * Get the bandwidth for one call with the specified codec. + * The value has been calculated with the further information: + * RTp communication, SIP protocol (the value with IAX2 is very close), no RTCP, one simultaneous call, for one channel (the incoming one). + * @param payload The payload of the codec + * @return double The bandwidth + */ + double getBandwidthPerCall (AudioCodecType payload); + + /** + * Get the clock rate of the specified codec + * @param payload The payload of the codec + * @return int The clock rate of the specified codec + */ + int getSampleRate (AudioCodecType payload); + + /** + * Set the order of codecs by their payload + * @param list The ordered list sent by DBus + */ + void saveActiveCodecs (const std::vector<std::string>& list); + + /** + * Get the number of codecs loaded in dynamic memory + * @return int The number + */ + int getCodecsNumber (void) { + return _nbCodecs; + } + + /** + * Unreferences the codecs loaded in memory + */ + void deleteHandlePointer (void); + + /** + * Get the first element of the CodecsMap struct. + * i.e the one with the lowest payload + * @return AudioCodec The pointer on the codec object + */ + AudioCodec* getFirstCodecAvailable (void); + + /** + * Instantiate a codec, used in AudioRTP to get an instance of Codec per call + * @param CodecHandlePointer The map containing the pointer on the object and the pointer on the handle function + */ + AudioCodec* instantiateCodec (AudioCodecType payload); + + /** + * For a given codec, return its specification + * + * @param payload The RTP payload of the codec + * @return std::vector <std::string> A vector containing codec's name, sample rate, bandwidth and bit rate + */ + std::vector <std::string> getCodecSpecifications (const int32_t& payload); + + /** + * Check if the audiocodec object has been successfully created + * @param payload The payload of the codec + * @return bool True if the audiocodec has been created + * false otherwise + */ + bool isCodecLoaded (int payload); + + private: + + /** + * Scan the installation directory ( --prefix configure option ) + * And load the dynamic library + * @return std::vector<AudioCodec*> The list of the codec object successfully loaded in memory + */ + std::vector<AudioCodec *> scanCodecDirectory (void); + + /** + * Load a codec + * @param std::string The path of the shared ( dynamic ) library. + * @return AudioCodec* the pointer of the object loaded. + */ + AudioCodec* loadCodec (std::string); + + /** + * Unload a codec + * @param CodecHandlePointer The map containing the pointer on the object and the pointer on the handle function + */ + void unloadCodec (CodecHandlePointer); + + /** + * Check if the files found in searched directories seems valid + * @param std::string The name of the file + * @return bool True if the file name begins with libcodec_ and ends with .so + * false otherwise + */ + bool seemsValid (std::string); + + /** + * Check if the codecs shared library has already been scanned during the session + * Useful not to load twice the same codec saved in the different directory + * @param std::string The complete name of the shared directory ( without the path ) + * @return bool True if the codecs has been scanned + * false otherwise + */ + bool alreadyInCache (std::string); + + /** + * Map the payload of a codec and the object associated ( AudioCodec * ) + */ + CodecsMap _CodecsMap; + + /** + * Vector containing a default order for the codecs + */ + CodecOrder _defaultCodecOrder; + + /** + * Vector containing the complete name of the codec shared library scanned + */ + std::vector<std::string> _Cache; + + /** + * Number of codecs loaded + */ + int _nbCodecs; + + /** + * Vector containing pairs + * Pair between pointer on function handle and pointer on audiocodec object + */ + std::vector< CodecHandlePointer > _CodecInMemory; }; #endif // __CODEC_DESCRIPTOR_H__ diff --git a/sflphone-common/src/audio/codecs/g722.h b/sflphone-common/src/audio/codecs/g722.h index e4dcba29f55566103b7f4a3f8c3f3e23246bb594..e5061071500516c33b13c56d0786a77649bdb1ff 100644 --- a/sflphone-common/src/audio/codecs/g722.h +++ b/sflphone-common/src/audio/codecs/g722.h @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -48,8 +48,7 @@ codec is considerably faster, and still fully compatible with wideband terminals #include <stdint.h> -enum -{ +enum { G722_SAMPLE_RATE_8000 = 0x0001, G722_PACKED = 0x0002 }; @@ -61,8 +60,7 @@ enum #define INT16_MIN (-32768) #endif -typedef struct -{ +typedef struct { /*! TRUE if the operating in the special ITU test mode, with the band split filters disabled. */ int itu_test_mode; @@ -76,8 +74,7 @@ typedef struct /*! Signal history for the QMF */ int x[24]; - struct - { + struct { int s; int sp; int sz; @@ -99,8 +96,7 @@ typedef struct int out_bits; } g722_encode_state_t; -typedef struct -{ +typedef struct { /*! TRUE if the operating in the special ITU test mode, with the band split filters disabled. */ int itu_test_mode; @@ -114,8 +110,7 @@ typedef struct /*! Signal history for the QMF */ int x[24]; - struct - { + struct { int s; int sp; int sz; @@ -130,7 +125,7 @@ typedef struct int nb; int det; } band[2]; - + unsigned int in_buffer; int in_bits; unsigned int out_buffer; @@ -141,13 +136,13 @@ typedef struct extern "C" { #endif -void g722_encode_init (void); -int g722_encode_release(); -int g722_encode(uint8_t g722_data[], const int16_t amp[], int len); + void g722_encode_init (void); + int g722_encode_release(); + int g722_encode (uint8_t g722_data[], const int16_t amp[], int len); -void g722_decode_init (void); -int g722_decode_release(); -int g722_decode(int16_t amp[], const uint8_t g722_data[], int len); + void g722_decode_init (void); + int g722_decode_release(); + int g722_decode (int16_t amp[], const uint8_t g722_data[], int len); #ifdef __cplusplus } diff --git a/sflphone-common/src/audio/common.h b/sflphone-common/src/audio/common.h index 6f24a65bd53a50bbede077e18354d2ecbb548b88..058d611c3209a92560e0aaaaffa711936ebdc6af 100644 --- a/sflphone-common/src/audio/common.h +++ b/sflphone-common/src/audio/common.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: + * Author: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/sflphone-common/src/audio/dcblocker.cpp b/sflphone-common/src/audio/dcblocker.cpp index 7ff24a2678db35e68d243b22fa9100489f380f78..bb373f1b012d3c25fd6cc84c953b63e3d57f8739 100644 --- a/sflphone-common/src/audio/dcblocker.cpp +++ b/sflphone-common/src/audio/dcblocker.cpp @@ -42,9 +42,9 @@ void DcBlocker::reset() _ym1 = 0; } -void DcBlocker::putData (SFLDataFormat *inputData, int nbBytes) {} +void DcBlocker::putData (SFLDataFormat *inputData UNUSED, int nbBytes UNUSED) {} -int DcBlocker::getData (SFLDataFormat *outputData) +int DcBlocker::getData (SFLDataFormat *outputData UNUSED) { return 0; } @@ -87,4 +87,4 @@ int DcBlocker::process (SFLDataFormat *inputData, SFLDataFormat *outputData, int } -void DcBlocker::process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {} +void DcBlocker::process (SFLDataFormat *micData UNUSED, SFLDataFormat *spkrData UNUSED, SFLDataFormat *outputData UNUSED, int nbBytes UNUSED) {} diff --git a/sflphone-common/src/audio/dcblocker.h b/sflphone-common/src/audio/dcblocker.h index 8d53688c19ef15a03f49761ff3b3a315914f5bd3..021369139ac287551603ea133b981c9c31400a5a 100644 --- a/sflphone-common/src/audio/dcblocker.h +++ b/sflphone-common/src/audio/dcblocker.h @@ -36,49 +36,50 @@ #include <vector> -class DcBlocker : public Algorithm { +class DcBlocker : public Algorithm +{ -public: + public: - DcBlocker(); + DcBlocker(); - ~DcBlocker(); + ~DcBlocker(); - virtual void reset(void); + virtual void reset (void); - /** - * Unused - */ - virtual void putData(SFLDataFormat *inputData, int nbBytes); + /** + * Unused + */ + virtual void putData (SFLDataFormat *inputData, int nbBytes); - /** - * Unused - */ - virtual int getData(SFLDataFormat *outputData); + /** + * Unused + */ + virtual int getData (SFLDataFormat *outputData); - /** - * Perform dc blocking given the input data - */ - virtual void process(SFLDataFormat *data, int nbBytes); + /** + * Perform dc blocking given the input data + */ + virtual void process (SFLDataFormat *data, int nbBytes); - /** - * Perform echo cancellation using internal buffers - * \param inputData containing mixed echo and voice data - * \param outputData containing - */ - virtual int process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); + /** + * Perform echo cancellation using internal buffers + * \param inputData containing mixed echo and voice data + * \param outputData containing + */ + virtual int process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); - /** - * Perform echo cancellation, application must provide its own buffer - * \param micData containing mixed echo and voice data - * \param spkrData containing far-end voice data to be sent to speakers - * \param outputData containing the processed data - */ - virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); + /** + * Perform echo cancellation, application must provide its own buffer + * \param micData containing mixed echo and voice data + * \param spkrData containing far-end voice data to be sent to speakers + * \param outputData containing the processed data + */ + virtual void process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); -private: + private: - SFLDataFormat _y, _x, _xm1, _ym1; + SFLDataFormat _y, _x, _xm1, _ym1; }; #endif diff --git a/sflphone-common/src/audio/delaydetection.cpp b/sflphone-common/src/audio/delaydetection.cpp index 4d7e459c43ec259a231ab3c0867122224d210e59..e05739ce17cabde5500d464e826094d8f3115b77 100644 --- a/sflphone-common/src/audio/delaydetection.cpp +++ b/sflphone-common/src/audio/delaydetection.cpp @@ -32,7 +32,6 @@ #include "delaydetection.h" #include "math.h" -// #include <stdio.h> #include <string.h> #include <samplerate.h> @@ -169,7 +168,7 @@ void DelayDetection::putData (SFLDataFormat *inputData, int nbBytes) } -int DelayDetection::getData (SFLDataFormat *outputData) +int DelayDetection::getData (SFLDataFormat *outputData UNUSED) { return 0; } @@ -194,19 +193,6 @@ void DelayDetection::process (SFLDataFormat *inputData, int nbBytes) downsampleData (tmp, down, nbSamples, _downsamplingFactor); - /* - for(int i = 0; i < 10; i++) - _debug("up: %.10f", tmp[i]); - - for(int i = 0; i < 10; i++) - _debug("down: %.10f", down[i]); - - bandpassFilter(down, nbSamples/_downsamplingFactor); - - for(int i = 0; i < 10; i++) - _debug("band: %.10f", down[i]); - */ - memcpy (_captureDataDown+ (_nbMicSampleStored/_downsamplingFactor), down, (nbSamples/_downsamplingFactor) *sizeof (float)); _nbMicSampleStored += nbSamples; @@ -218,54 +204,33 @@ void DelayDetection::process (SFLDataFormat *inputData, int nbBytes) else return; - /* - for(int i = 0; i < 10; i++) - _debug("spkrRef: %.10f", _spkrReferenceDown[i]); - - for(int i = 0; i < 10; i++) - _debug("micSeg: %.10f", _captureDataDown[i]); - */ - _debug ("_spkrDownSize: %d, _micDownSize: %d", _spkrDownSize, _micDownSize); crossCorrelate (_spkrReferenceDown, _captureDataDown, _correlationResult, _micDownSize, _spkrDownSize); int maxIndex = getMaxIndex (_correlationResult, _spkrDownSize); _debug ("MaxIndex: %d", maxIndex); - - // reset(); } -int DelayDetection::process (SFLDataFormat *intputData, SFLDataFormat *outputData, int nbBytes) +int DelayDetection::process (SFLDataFormat *intputData UNUSED, SFLDataFormat *outputData UNUSED, int nbBytes UNUSED) { return 0; } -void DelayDetection::process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {} +void DelayDetection::process (SFLDataFormat *micData UNUSED, SFLDataFormat *spkrData UNUSED, SFLDataFormat *outputData UNUSED, int nbBytes UNUSED) {} void DelayDetection::crossCorrelate (float *ref, float *seg, float *res, int refSize, int segSize) { _debug ("CrossCorrelate"); - int counter = 0; - // Output has same size as the int rsize = refSize; int ssize = segSize; int tmpsize = segSize-refSize+1; - /* - for(int i = 0; i < 32; i++) - _debug("ref: %.10f", ref[i]); - - for(int i = 0; i < 150; i++) - _debug("seg: %.10f", seg[i]); - */ - // perform autocorrelation on reference signal float acref = correlate (ref, ref, rsize); - // _debug("acref: %f", acref); // perform crossrelation on signal float acseg = 0.0; @@ -274,7 +239,6 @@ void DelayDetection::crossCorrelate (float *ref, float *seg, float *res, int ref while (--tmpsize) { --ssize; acseg = correlate (seg+tmpsize, seg+tmpsize, rsize); - // _debug("acseg: %f", acseg); res[ssize] = correlate (ref, seg+tmpsize, rsize); r = sqrt (acref*acseg); @@ -289,7 +253,6 @@ void DelayDetection::crossCorrelate (float *ref, float *seg, float *res, int ref while (rsize) { acseg = correlate (seg, seg, rsize); - // _debug("acseg: %f", acseg); res[ssize-1] = correlate (ref+i, seg, rsize); r = sqrt (acref*acseg); @@ -321,8 +284,6 @@ double DelayDetection::correlate (float *sig1, float *sig2, short size) void DelayDetection::convertInt16ToFloat32 (SFLDataFormat *input, float *output, int nbSamples) { - // factor is 1/(2^15), used to rescale the short int range to the - // [-1.0 - 1.0] float range. #define S2F_FACTOR .000030517578125f; int len = nbSamples; @@ -336,26 +297,6 @@ void DelayDetection::convertInt16ToFloat32 (SFLDataFormat *input, float *output, void DelayDetection::downsampleData (float *input, float *output, int nbSamples, int factor) { - /* - float tmp[nbSamples]; - - for(int i = 0; i < nbSamples; i++) { - tmp[i] = _decimationFilter.getOutputSample(input[i]); - } - - int j; - for(j=_remainingIndex; j<nbSamples; j+=factor) { - output[j] = tmp[j]; - } - _remainingIndex = j - nbSamples; - */ - - /* - double downsampleFactor = (double) samplerate1 / samplerate2; - - int nbSamplesMax = (int) (samplerate1 * getFramesize() / 1000); - */ - int _src_err; SRC_STATE *_src_state = src_new (SRC_LINEAR, 1, &_src_err); @@ -371,13 +312,7 @@ void DelayDetection::downsampleData (float *input, float *output, int nbSamples, src_data.src_ratio = downfactor; src_data.end_of_input = 0; // More data will come - //src_short_to_float_array (dataIn, _floatBufferUpMic, nbSamples); - //_debug("downsample %d %f %d" , src_data.output_frames, src_data.src_ratio , nbSamples); src_process (_src_state, &src_data); - //_debug("downsample %d %f %d" , src_data.output_frames, src_data.src_ratio , nbSamples); - // nbSamples = (src_data.output_frames_gen > nbSamplesMax) ? nbSamplesMax : src_data.output_frames_gen; - //_debug("downsample %d %f %d" , src_data.output_frames, src_data.src_ratio , nbSamples); - // src_float_to_short_array (_floatBufferDownMic , dataOut , nbSamples); } } diff --git a/sflphone-common/src/audio/delaydetection.h b/sflphone-common/src/audio/delaydetection.h index a7567b6c2e8ccdfb82301724c5f151548517a8f2..4e0891084237386fb0cfb04e8de947dab0cd93b0 100644 --- a/sflphone-common/src/audio/delaydetection.h +++ b/sflphone-common/src/audio/delaydetection.h @@ -41,151 +41,153 @@ #define MAX_DELAY 150 // Size of internal buffers in samples -#define DELAY_BUFF_SIZE MAX_DELAY*8000/1000 +#define DELAY_BUFF_SIZE MAX_DELAY*8000/1000 #define MAXFILTERSIZE 100 -class FirFilter { +class FirFilter +{ - public: + public: - /** - * Constructor for this class - */ - FirFilter(std::vector<double> ir); + /** + * Constructor for this class + */ + FirFilter (std::vector<double> ir); - /** - * SDestructor for this class - */ - ~FirFilter(); - - /** - * Perform filtering on one sample - */ - float getOutputSample(float inputSample); + /** + * SDestructor for this class + */ + ~FirFilter(); - void reset(void); + /** + * Perform filtering on one sample + */ + float getOutputSample (float inputSample); + void reset (void); - private: - /** - * Length of the filter - */ - int _length; + private: - /** - * Coefficient of the filter - */ - std::vector<double> _impulseResponse; + /** + * Length of the filter + */ + int _length; - /** - * Circular buffer - */ - double _taps[MAXFILTERSIZE]; + /** + * Coefficient of the filter + */ + std::vector<double> _impulseResponse; + + /** + * Circular buffer + */ + double _taps[MAXFILTERSIZE]; + + /** + * Counter + */ + int _count; - /** - * Counter - */ - int _count; - }; -class DelayDetection : public Algorithm { +class DelayDetection : public Algorithm +{ - public: + public: - DelayDetection(); + DelayDetection(); - ~DelayDetection(); + ~DelayDetection(); - virtual void reset(void); + virtual void reset (void); - virtual void putData(SFLDataFormat *inputData, int nbBytes); + virtual void putData (SFLDataFormat *inputData, int nbBytes); - virtual int getData(SFLDataFormat *getData); + virtual int getData (SFLDataFormat *getData); - virtual void process(SFLDataFormat *inputData, int nbBytes); + virtual void process (SFLDataFormat *inputData, int nbBytes); - virtual int process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); + virtual int process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); - virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); + virtual void process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); - private: + private: - enum State { - WaitForSpeaker, - WaitForMic, - ComputeCorrelation - }; + enum State { + WaitForSpeaker, + WaitForMic, + ComputeCorrelation + }; - /** - * Perform a normalized crosscorrelation between template and segment - */ - void crossCorrelate(float *ref, float *seg, float *res, int refSize, int segSize); + /** + * Perform a normalized crosscorrelation between template and segment + */ + void crossCorrelate (float *ref, float *seg, float *res, int refSize, int segSize); - /** - * Perform a correlation on specified signals (mac) - */ - double correlate(float *sig1, float *sig2, short size); + /** + * Perform a correlation on specified signals (mac) + */ + double correlate (float *sig1, float *sig2, short size); - void convertInt16ToFloat32(SFLDataFormat *input, float *ouput, int nbSamples); + void convertInt16ToFloat32 (SFLDataFormat *input, float *ouput, int nbSamples); - void downsampleData(float *input, float *output, int nbSamples, int factor); + void downsampleData (float *input, float *output, int nbSamples, int factor); - void bandpassFilter(float *input, int nbSamples); + void bandpassFilter (float *input, int nbSamples); - int getMaxIndex(float *data, int size); + int getMaxIndex (float *data, int size); - State _internalState; + State _internalState; - FirFilter _decimationFilter; + FirFilter _decimationFilter; - FirFilter _bandpassFilter; + FirFilter _bandpassFilter; - /** - * Segment size in samples for correlation - */ - short _segmentSize; + /** + * Segment size in samples for correlation + */ + short _segmentSize; - int _downsamplingFactor; + int _downsamplingFactor; - /** - * Resulting correlation size (s + w -1) - */ - short _correlationSize; + /** + * Resulting correlation size (s + w -1) + */ + short _correlationSize; - float _spkrReference[WINDOW_SIZE*2]; + float _spkrReference[WINDOW_SIZE*2]; - float _capturedData[DELAY_BUFF_SIZE*2]; + float _capturedData[DELAY_BUFF_SIZE*2]; - float _spkrReferenceDown[WINDOW_SIZE*2]; + float _spkrReferenceDown[WINDOW_SIZE*2]; - float _captureDataDown[DELAY_BUFF_SIZE*2]; + float _captureDataDown[DELAY_BUFF_SIZE*2]; - float _spkrReferenceFilter[WINDOW_SIZE*2]; + float _spkrReferenceFilter[WINDOW_SIZE*2]; - float _captureDataFilter[DELAY_BUFF_SIZE*2]; + float _captureDataFilter[DELAY_BUFF_SIZE*2]; - float _correlationResult[DELAY_BUFF_SIZE*2]; + float _correlationResult[DELAY_BUFF_SIZE*2]; - int _remainingIndex; + int _remainingIndex; - int _spkrDownSize; + int _spkrDownSize; - int _micDownSize; + int _micDownSize; - int _nbMicSampleStored; + int _nbMicSampleStored; - int _nbSpkrSampleStored; + int _nbSpkrSampleStored; - public: + public: - friend class DelayDetectionTest; + friend class DelayDetectionTest; }; #endif diff --git a/sflphone-common/src/audio/echocancel.cpp b/sflphone-common/src/audio/echocancel.cpp index cc9df19de75181114956d41d9c0995b4e0a1804d..e6e2a3c92fbec4e3d7c6002da27466eaee400b3f 100644 --- a/sflphone-common/src/audio/echocancel.cpp +++ b/sflphone-common/src/audio/echocancel.cpp @@ -241,7 +241,7 @@ int EchoCancel::getData (SFLDataFormat *outputData) return copied; } -void EchoCancel::process (SFLDataFormat *data, int nbBytes) {} +void EchoCancel::process (SFLDataFormat *data UNUSED, int nbBytes UNUSED) {} int EchoCancel::process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) @@ -330,7 +330,7 @@ int EchoCancel::process (SFLDataFormat *inputData, SFLDataFormat *outputData, in return nbFrame * _smplPerFrame; } -void EchoCancel::process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) +void EchoCancel::process (SFLDataFormat *micData UNUSED, SFLDataFormat *spkrData UNUSED, SFLDataFormat *outputData UNUSED, int nbBytes UNUSED) { } diff --git a/sflphone-common/src/audio/echocancel.h b/sflphone-common/src/audio/echocancel.h index e0ceda0445a67dc636a89df8874b21367b6a0c54..95cd987bac99250bf14347ab8608cddb71d06894 100644 --- a/sflphone-common/src/audio/echocancel.h +++ b/sflphone-common/src/audio/echocancel.h @@ -49,7 +49,7 @@ #define SPKR_LENGTH 80 #define MIC_LENGTH 80 -// Voice level threashold +// Voice level threashold #define MIN_SIG_LEVEL 250 // Delay between mic and speaker @@ -68,320 +68,329 @@ #define MIC_ADAPT_SIZE 100 // 1 sec #define SPKR_ADAPT_SIZE 20 // 200 ms -class EchoCancel : public Algorithm { - - public: - - EchoCancel(int smplRate = DEFAULT_SAMPLRATE, int frameLength = DEFAULT_FRAME_LENGTH); - - ~EchoCancel(); - - /** - * Reset echocanceller internal state at runtime. Usefull when making a new call - */ - virtual void reset(void); - - /** - * Add speaker data into internal buffer - * \param inputData containing far-end voice data to be sent to speakers - */ - virtual void putData(SFLDataFormat *inputData, int nbBytes); - - /** - * Get data ready to be played by speakers - */ - virtual int getData(SFLDataFormat *outputData); - - /** - * Unused - */ - virtual void process(SFLDataFormat *data, int nbBytes); - - /** - * Perform echo cancellation using internal buffers - * \param inputData containing mixed echo and voice data - * \param outputData containing - */ - virtual int process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); - - /** - * Perform echo cancellation, application must provide its own buffer - * \param micData containing mixed echo and voice data - * \param spkrData containing far-end voice data to be sent to speakers - * \param outputData containing the processed data - */ - virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); - - /** - * Set echo canceller internal sampling rate, reset if sampling rate changed - */ - void setSamplingRate(int smplRate); - - /** - * Set echo canceller state to active/deactive - */ - void setEchoCancelState(bool state) { _echoActive = state; } - - /** - * Return the echo canceller state - */ - bool getEchoCancelState(void) { return _echoActive; } - - /** - * Set the noise suppression state to active/deactive - */ - void setNoiseSuppressState(bool state) { _noiseActive = state; } - - /** - * Return the noise suppression state - */ - bool getNoiseSuppressState(void) { return _noiseActive; } - - private: - - /** - * Actual method calld to supress echo from mic, micData and spkrData must be synchronized - */ - void performEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData); - - /** - * This is the fall back method in case there is no spkr data available - */ - void performEchoCancelNoSpkr(SFLDataFormat *micData, SFLDataFormat *outputData); - - /** - * Compute current instantaneous microphone signal power and store it in internal array - */ - void updateMicLevel(SFLDataFormat *micData); - - /** - * Compute current instantaneous spkeaker signal power and store uit in internal array - */ - void updateSpkrLevel(SFLDataFormat *spkrData); - - /** - * Update speaker level array for both micData and spkrData - */ - void updateEchoCancel(SFLDataFormat *micData, SFLDataFormat *spkrData); - - /** - * Compute the average amplitude of the signal. - * \param data must be of SEGMENT_LENGTH long. - */ - int computeAmplitudeLevel(SFLDataFormat *data, int size); - - /** - * Compute amplitude signal - */ - SFLDataFormat estimatePower(SFLDataFormat *data, SFLDataFormat *ampl, int size, SFLDataFormat mem); - - /** - * Return the max amplitude provided any of _avgSpkrLevelHist or _avgMicLevelHist - */ - int getMaxAmplitude(int *data, int size); - - /** - * Apply gain factor on input buffer and copy result in output buffer. - * Buffers must be of SEGMENT_LENGTH long. - * \param input buffer - * \param output buffer - */ - void amplifySignal(SFLDataFormat *micData, SFLDataFormat *outputData, float amplify); - - /** - * Increase microphone gain by the provided factor. Sanity check are done internally. - */ - void increaseFactor(float factor); - - /** - * Decrease microphone gain. - */ - void decreaseFactor(); - - /** - * Perform simple correlation between data1 and data2 - */ - int performCorrelation(int *data1, int *data2, int size); - - /** - * Return maximum in data index - */ - int getMaximumIndex(int *data, int size); - - /** - * Internal buffer for mic data synchronization - */ - RingBuffer *_micData; - - /** - * Internal buffer for speaker data synchronization - */ - RingBuffer *_spkrData; - - RingBuffer *_spkrDataOut; - - /** - * Boolean value - */ - bool _spkrStoped; - - /** - * Internal buffer for audio processing - */ - SFLDataFormat _tmpSpkr[BUFF_SIZE]; - SFLDataFormat _tmpMic[BUFF_SIZE]; - SFLDataFormat _tmpOut[BUFF_SIZE]; - - /** - * Audio stream sampling rate - */ - int _samplingRate; - - /** - * Audio frame size in ms - */ - int _frameLength; - - /** - * Number of sample per frame - */ - int _smplPerFrame; - - /** - * Number of samples per segment - */ - int _smplPerSeg; - - /** - * Number of segment per frame - */ - int _nbSegmentPerFrame; - - /** - * Number of segment considered in history - * Mainly used to compute signal level - */ - int _micHistoryLength; - - int _spkrHistoryLength; - - /** - * Current playback level - */ - int _spkrLevel; - - /** - * Current capture level - */ - int _micLevel; - - /** - * Current index to store level in speaker history - */ - int _spkrHistCnt; - - /** - * Current index to store level in microphone history - */ - int _micHistCnt; - - /** - * Average speaker/microphone level history. Each value corespond to - * the averaged amplitude value over a segment (SEGMENT_LENGTH long) - */ - int _avgSpkrLevelHist[BUFF_SIZE]; - int _avgMicLevelHist[BUFF_SIZE]; - - /** - * Current linear gain factor to be applied on microphone - */ - float _amplFactor; - - /** - * Stored linea gain factor for lowpass filtering - */ - float _lastAmplFactor; - - /** - * Linear gain factor buffer to adjust to system's latency - */ - float _delayLineAmplify[MAX_DELAY_LINE_AMPL]; - - /** - * read/write for mic gain delay - */ - int _amplDelayIndexIn; - int _amplDelayIndexOut; - - /** - * State variable to determine if adaptation must be performed - */ - bool _adaptDone; - - /** - * State variable to specify if adaptation is started - */ - bool _adaptStarted; - - /** - * Adaptation index - */ - int _adaptCnt; - - /** - * Factor for power estimation - */ - float _alpha; - - /** - * Termporary spkr level memories - */ - SFLDataFormat _spkrLevelMem; - SFLDataFormat _micLevelMem; - - int _spkrAdaptCnt; - - int _micAdaptCnt; - - int _spkrAdaptSize; - - int _micAdaptSize; - - int _spkrAdaptArray[BUFF_SIZE]; - - int _micAdaptArray[BUFF_SIZE]; - - int _correlationSize; - - int _correlationArray[BUFF_SIZE]; - - int _processedByte; - - ofstream *micFile; - ofstream *spkrFile; - ofstream *echoFile; - - ofstream *micLevelData; - ofstream *spkrLevelData; - - // #ifdef HAVE_SPEEXDSP_LIB - /** - * Noise reduction processing state - */ - SpeexPreprocessState *_noiseState; - // #endif - - /** - * true if noise suppressor is active, false elsewhere - */ - bool _echoActive; - - /** - * true if noise suppressor is active, false elsewhere - */ - bool _noiseActive; - - DelayDetection _delayDetector; +class EchoCancel : public Algorithm +{ + + public: + + EchoCancel (int smplRate = DEFAULT_SAMPLRATE, int frameLength = DEFAULT_FRAME_LENGTH); + + ~EchoCancel(); + + /** + * Reset echocanceller internal state at runtime. Usefull when making a new call + */ + virtual void reset (void); + + /** + * Add speaker data into internal buffer + * \param inputData containing far-end voice data to be sent to speakers + */ + virtual void putData (SFLDataFormat *inputData, int nbBytes); + + /** + * Get data ready to be played by speakers + */ + virtual int getData (SFLDataFormat *outputData); + + /** + * Unused + */ + virtual void process (SFLDataFormat *data, int nbBytes); + + /** + * Perform echo cancellation using internal buffers + * \param inputData containing mixed echo and voice data + * \param outputData containing + */ + virtual int process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); + + /** + * Perform echo cancellation, application must provide its own buffer + * \param micData containing mixed echo and voice data + * \param spkrData containing far-end voice data to be sent to speakers + * \param outputData containing the processed data + */ + virtual void process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); + + /** + * Set echo canceller internal sampling rate, reset if sampling rate changed + */ + void setSamplingRate (int smplRate); + + /** + * Set echo canceller state to active/deactive + */ + void setEchoCancelState (bool state) { + _echoActive = state; + } + + /** + * Return the echo canceller state + */ + bool getEchoCancelState (void) { + return _echoActive; + } + + /** + * Set the noise suppression state to active/deactive + */ + void setNoiseSuppressState (bool state) { + _noiseActive = state; + } + + /** + * Return the noise suppression state + */ + bool getNoiseSuppressState (void) { + return _noiseActive; + } + + private: + + /** + * Actual method calld to supress echo from mic, micData and spkrData must be synchronized + */ + void performEchoCancel (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData); + + /** + * This is the fall back method in case there is no spkr data available + */ + void performEchoCancelNoSpkr (SFLDataFormat *micData, SFLDataFormat *outputData); + + /** + * Compute current instantaneous microphone signal power and store it in internal array + */ + void updateMicLevel (SFLDataFormat *micData); + + /** + * Compute current instantaneous spkeaker signal power and store uit in internal array + */ + void updateSpkrLevel (SFLDataFormat *spkrData); + + /** + * Update speaker level array for both micData and spkrData + */ + void updateEchoCancel (SFLDataFormat *micData, SFLDataFormat *spkrData); + + /** + * Compute the average amplitude of the signal. + * \param data must be of SEGMENT_LENGTH long. + */ + int computeAmplitudeLevel (SFLDataFormat *data, int size); + + /** + * Compute amplitude signal + */ + SFLDataFormat estimatePower (SFLDataFormat *data, SFLDataFormat *ampl, int size, SFLDataFormat mem); + + /** + * Return the max amplitude provided any of _avgSpkrLevelHist or _avgMicLevelHist + */ + int getMaxAmplitude (int *data, int size); + + /** + * Apply gain factor on input buffer and copy result in output buffer. + * Buffers must be of SEGMENT_LENGTH long. + * \param input buffer + * \param output buffer + */ + void amplifySignal (SFLDataFormat *micData, SFLDataFormat *outputData, float amplify); + + /** + * Increase microphone gain by the provided factor. Sanity check are done internally. + */ + void increaseFactor (float factor); + + /** + * Decrease microphone gain. + */ + void decreaseFactor(); + + /** + * Perform simple correlation between data1 and data2 + */ + int performCorrelation (int *data1, int *data2, int size); + + /** + * Return maximum in data index + */ + int getMaximumIndex (int *data, int size); + + /** + * Internal buffer for mic data synchronization + */ + RingBuffer *_micData; + + /** + * Internal buffer for speaker data synchronization + */ + RingBuffer *_spkrData; + + RingBuffer *_spkrDataOut; + + /** + * Boolean value + */ + bool _spkrStoped; + + /** + * Internal buffer for audio processing + */ + SFLDataFormat _tmpSpkr[BUFF_SIZE]; + SFLDataFormat _tmpMic[BUFF_SIZE]; + SFLDataFormat _tmpOut[BUFF_SIZE]; + + /** + * Audio stream sampling rate + */ + int _samplingRate; + + /** + * Audio frame size in ms + */ + int _frameLength; + + /** + * Number of sample per frame + */ + int _smplPerFrame; + + /** + * Number of samples per segment + */ + int _smplPerSeg; + + /** + * Number of segment per frame + */ + int _nbSegmentPerFrame; + + /** + * Number of segment considered in history + * Mainly used to compute signal level + */ + int _micHistoryLength; + + int _spkrHistoryLength; + + /** + * Factor for power estimation + */ + float _alpha; + + /** + * Termporary spkr level memories + */ + SFLDataFormat _spkrLevelMem; + SFLDataFormat _micLevelMem; + + /** + * Current playback level + */ + int _spkrLevel; + + /** + * Current capture level + */ + int _micLevel; + + /** + * Current index to store level in speaker history + */ + int _spkrHistCnt; + + /** + * Current index to store level in microphone history + */ + int _micHistCnt; + + /** + * Current linear gain factor to be applied on microphone + */ + float _amplFactor; + + /** + * Stored linea gain factor for lowpass filtering + */ + float _lastAmplFactor; + + /** + * read/write for mic gain delay + */ + int _amplDelayIndexIn; + int _amplDelayIndexOut; + + /** + * State variable to determine if adaptation must be performed + */ + bool _adaptDone; + + /** + * State variable to specify if adaptation is started + */ + bool _adaptStarted; + + /** + * Adaptation index + */ + int _adaptCnt; + + int _spkrAdaptCnt; + + int _micAdaptCnt; + + int _spkrAdaptSize; + + int _micAdaptSize; + + int _correlationSize; + + int _processedByte; + + /** + * true if noise suppressor is active, false elsewhere + */ + bool _echoActive; + + /** + * true if noise suppressor is active, false elsewhere + */ + bool _noiseActive; + + /** + * Average speaker/microphone level history. Each value corespond to + * the averaged amplitude value over a segment (SEGMENT_LENGTH long) + */ + int _avgSpkrLevelHist[BUFF_SIZE]; + int _avgMicLevelHist[BUFF_SIZE]; + + /** + * Linear gain factor buffer to adjust to system's latency + */ + float _delayLineAmplify[MAX_DELAY_LINE_AMPL]; + + int _spkrAdaptArray[BUFF_SIZE]; + + int _micAdaptArray[BUFF_SIZE]; + + int _correlationArray[BUFF_SIZE]; + + ofstream *micFile; + ofstream *spkrFile; + ofstream *echoFile; + + ofstream *micLevelData; + ofstream *spkrLevelData; + + // #ifdef HAVE_SPEEXDSP_LIB + /** + * Noise reduction processing state + */ + SpeexPreprocessState *_noiseState; + // #endif + + DelayDetection _delayDetector; }; diff --git a/sflphone-common/src/audio/jitterbuf.cpp b/sflphone-common/src/audio/jitterbuf.cpp index ac9335ee303748f4acd729f2900b270abd086792..4881498853e1ca7604e16d3bd6eee865b85d4dbc 100644 --- a/sflphone-common/src/audio/jitterbuf.cpp +++ b/sflphone-common/src/audio/jitterbuf.cpp @@ -124,7 +124,7 @@ static int longcmp (const void *a, const void *b) \note maybe later we can make the history buckets variable size, or something? */ /* drop parameter determines whether we will drop outliers to minimize * delay */ -static int history_put (jitterbuf *jb, long ts, long now, long ms) +static int history_put (jitterbuf *jb, long ts, long now) { long delay = now - (ts - jb->info.resync_offset); long threshold = 2 * jb->info.jitter + jb->info.conf.resync_threshold; @@ -539,7 +539,7 @@ jb_return_code jb_put (jitterbuf *jb, void *data, const enum jb_frame_type type, if (type == JB_TYPE_VOICE) { /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ - if (history_put (jb,ts,now,ms)) { + if (history_put (jb,ts,now)) { jb->info.frames_dropped++; return JB_DROP; } diff --git a/sflphone-common/src/audio/jitterbuf.h b/sflphone-common/src/audio/jitterbuf.h old mode 100755 new mode 100644 index 8de8bf0885d87f476550bc27c5201065d677b51d..2332968e5fe223567e032fea4c181e728c39f28c --- a/sflphone-common/src/audio/jitterbuf.h +++ b/sflphone-common/src/audio/jitterbuf.h @@ -14,7 +14,7 @@ */ /*! \file - * \brief + * \brief * jitterbuf: an application-independent jitterbuffer * \ref jitterbuf.c */ @@ -27,147 +27,147 @@ extern "C" { #endif -/*! \name configuration constants */ -/*@{ */ - /*! Number of historical timestamps to use in calculating jitter and drift */ -#define JB_HISTORY_SZ 500 - /*! what percentage of timestamps should we drop from the history when we examine it; - * this might eventually be something made configurable */ + /*! \name configuration constants */ + /*@{ */ + /*! Number of historical timestamps to use in calculating jitter and drift */ +#define JB_HISTORY_SZ 500 + /*! what percentage of timestamps should we drop from the history when we examine it; + * this might eventually be something made configurable */ #define JB_HISTORY_DROPPCT 3 - /*! the maximum droppct we can handle (say it was configurable). */ + /*! the maximum droppct we can handle (say it was configurable). */ #define JB_HISTORY_DROPPCT_MAX 4 - /*! the size of the buffer we use to keep the top and botton timestamps for dropping */ -#define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100 - /*! amount of additional jitterbuffer adjustment */ + /*! the size of the buffer we use to keep the top and botton timestamps for dropping */ +#define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100 + /*! amount of additional jitterbuffer adjustment */ #define JB_TARGET_EXTRA 40 - /*! ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */ + /*! ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */ #define JB_ADJUST_DELAY 40 -/*@} */ - -enum jb_return_code { - /* return codes */ - JB_OK, /* 0 */ - JB_EMPTY, /* 1 */ - JB_NOFRAME, /* 2 */ - JB_INTERP, /* 3 */ - JB_DROP, /* 4 */ - JB_SCHED /* 5 */ -}; - -enum jb_frame_type { - /* frame types */ - JB_TYPE_CONTROL, /*!< 0 */ - JB_TYPE_VOICE, /*!< 1 */ - JB_TYPE_VIDEO, /*!< 2 - reserved */ - JB_TYPE_SILENCE /*!< 3 */ -}; - -typedef struct jb_conf { - /* settings */ - long max_jitterbuf; /*!< defines a hard clamp to use in setting the jitter buffer delay */ - long resync_threshold; /*!< the jb will resync when delay increases to (2 * jitter) + this param */ - long max_contig_interp; /*!< the max interp frames to return in a row */ - long target_extra ; /*!< amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */ -} jb_conf; - -typedef struct jb_info { - jb_conf conf; - - /* statistics */ - long frames_in; /*!< number of frames input to the jitterbuffer.*/ - long frames_out; /*!< number of frames output from the jitterbuffer.*/ - long frames_late; /*!< number of frames which were too late, and dropped.*/ - long frames_lost; /*!< number of missing frames.*/ - long frames_dropped; /*!< number of frames dropped (shrinkage) */ - long frames_ooo; /*!< number of frames received out-of-order */ - long frames_cur; /*!< number of frames presently in jb, awaiting delivery.*/ - long jitter; /*!< jitter measured within current history interval*/ - long min; /*!< minimum lateness within current history interval */ - long current; /*!< the present jitterbuffer adjustment */ - long target; /*!< the target jitterbuffer adjustment */ - long losspct; /*!< recent lost frame percentage (* 1000) */ - long next_voice_ts; /*!< the ts of the next frame to be read from the jb - in receiver's time */ - long last_voice_ms; /*!< the duration of the last voice frame */ - long silence_begin_ts; /*!< the time of the last CNG frame, when in silence */ - long last_adjustment; /*!< the time of the last adjustment */ - long last_delay; /*!< the last now added to history */ - long cnt_delay_discont; /*!< the count of discontinuous delays */ - long resync_offset; /*!< the amount to offset ts to support resyncs */ - long cnt_contig_interp; /*!< the number of contiguous interp frames returned */ -} jb_info; - -typedef struct jb_frame { - void *data; /* the frame data */ - long ts; /* the relative delivery time expected */ - long ms; /* the time covered by this frame, in sec/8000 */ - enum jb_frame_type type; /* the type of frame */ - struct jb_frame *next, *prev; -} jb_frame; - -typedef struct jitterbuf { - jb_info info; - - /* history */ - long history[JB_HISTORY_SZ]; /*!< history */ - int hist_ptr; /*!< points to index in history for next entry */ - long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the max delays (highest first) */ - long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the min delays (lowest first) */ - int hist_maxbuf_valid; /*!< are the "maxbuf"/minbuf valid? */ - unsigned int dropem:1; /*!< flag to indicate dropping frames (overload) */ - - jb_frame *frames; /*!< queued frames */ - jb_frame *free; /*!< free frames (avoid malloc?) */ -} jitterbuf; - - -/*! \brief new jitterbuf */ -jitterbuf * jb_new(void); - -/*! \brief destroy jitterbuf */ -void jb_destroy(jitterbuf *jb); - -/*! \brief reset jitterbuf - * \note The jitterbuffer should be empty before you call this, otherwise - * you will leak queued frames, and some internal structures */ -void jb_reset(jitterbuf *jb); - -/*!\brief queue a frame - * - * data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time) - * now=now (in receiver's time) return value is one of - * JB_OK: Frame added. Last call to jb_next() still valid - * JB_DROP: Drop this frame immediately - * JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame - */ -enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now); - -/*! \brief get a frame for time now (receiver's time) return value is one of - * JB_OK: You've got frame! - * JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. - * JB_NOFRAME: There's no frame scheduled for this time. - * JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame) - * JB_EMPTY: The jb is empty. - */ -enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl); - -/*! \brief unconditionally get frames from jitterbuf until empty */ -enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout); - -/*! \brief when is the next frame due out, in receiver's time (0=EMPTY) - * This value may change as frames are added (esp non-audio frames) */ -long jb_next(jitterbuf *jb); - -/*! \brief get jitterbuf info: only "statistics" may be valid */ -enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats); - -/* some diagnostics */ -void jb_dbginfo(jitterbuf *jb); - -/*! \brief set jitterbuf conf */ -enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf); - -typedef void __attribute__((format(printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...); -void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); + /*@} */ + + enum jb_return_code { + /* return codes */ + JB_OK, /* 0 */ + JB_EMPTY, /* 1 */ + JB_NOFRAME, /* 2 */ + JB_INTERP, /* 3 */ + JB_DROP, /* 4 */ + JB_SCHED /* 5 */ + }; + + enum jb_frame_type { + /* frame types */ + JB_TYPE_CONTROL, /*!< 0 */ + JB_TYPE_VOICE, /*!< 1 */ + JB_TYPE_VIDEO, /*!< 2 - reserved */ + JB_TYPE_SILENCE /*!< 3 */ + }; + + typedef struct jb_conf { + /* settings */ + long max_jitterbuf; /*!< defines a hard clamp to use in setting the jitter buffer delay */ + long resync_threshold; /*!< the jb will resync when delay increases to (2 * jitter) + this param */ + long max_contig_interp; /*!< the max interp frames to return in a row */ + long target_extra ; /*!< amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */ + } jb_conf; + + typedef struct jb_info { + jb_conf conf; + + /* statistics */ + long frames_in; /*!< number of frames input to the jitterbuffer.*/ + long frames_out; /*!< number of frames output from the jitterbuffer.*/ + long frames_late; /*!< number of frames which were too late, and dropped.*/ + long frames_lost; /*!< number of missing frames.*/ + long frames_dropped; /*!< number of frames dropped (shrinkage) */ + long frames_ooo; /*!< number of frames received out-of-order */ + long frames_cur; /*!< number of frames presently in jb, awaiting delivery.*/ + long jitter; /*!< jitter measured within current history interval*/ + long min; /*!< minimum lateness within current history interval */ + long current; /*!< the present jitterbuffer adjustment */ + long target; /*!< the target jitterbuffer adjustment */ + long losspct; /*!< recent lost frame percentage (* 1000) */ + long next_voice_ts; /*!< the ts of the next frame to be read from the jb - in receiver's time */ + long last_voice_ms; /*!< the duration of the last voice frame */ + long silence_begin_ts; /*!< the time of the last CNG frame, when in silence */ + long last_adjustment; /*!< the time of the last adjustment */ + long last_delay; /*!< the last now added to history */ + long cnt_delay_discont; /*!< the count of discontinuous delays */ + long resync_offset; /*!< the amount to offset ts to support resyncs */ + long cnt_contig_interp; /*!< the number of contiguous interp frames returned */ + } jb_info; + + typedef struct jb_frame { + void *data; /* the frame data */ + long ts; /* the relative delivery time expected */ + long ms; /* the time covered by this frame, in sec/8000 */ + enum jb_frame_type type; /* the type of frame */ + struct jb_frame *next, *prev; + } jb_frame; + + typedef struct jitterbuf { + jb_info info; + + /* history */ + long history[JB_HISTORY_SZ]; /*!< history */ + int hist_ptr; /*!< points to index in history for next entry */ + long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the max delays (highest first) */ + long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the min delays (lowest first) */ + int hist_maxbuf_valid; /*!< are the "maxbuf"/minbuf valid? */ + unsigned int dropem:1; /*!< flag to indicate dropping frames (overload) */ + + jb_frame *frames; /*!< queued frames */ + jb_frame *free; /*!< free frames (avoid malloc?) */ + } jitterbuf; + + + /*! \brief new jitterbuf */ + jitterbuf * jb_new (void); + + /*! \brief destroy jitterbuf */ + void jb_destroy (jitterbuf *jb); + + /*! \brief reset jitterbuf + * \note The jitterbuffer should be empty before you call this, otherwise + * you will leak queued frames, and some internal structures */ + void jb_reset (jitterbuf *jb); + + /*!\brief queue a frame + * + * data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time) + * now=now (in receiver's time) return value is one of + * JB_OK: Frame added. Last call to jb_next() still valid + * JB_DROP: Drop this frame immediately + * JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame + */ + enum jb_return_code jb_put (jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now); + + /*! \brief get a frame for time now (receiver's time) return value is one of + * JB_OK: You've got frame! + * JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. + * JB_NOFRAME: There's no frame scheduled for this time. + * JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame) + * JB_EMPTY: The jb is empty. + */ + enum jb_return_code jb_get (jitterbuf *jb, jb_frame *frame, long now, long interpl); + + /*! \brief unconditionally get frames from jitterbuf until empty */ + enum jb_return_code jb_getall (jitterbuf *jb, jb_frame *frameout); + + /*! \brief when is the next frame due out, in receiver's time (0=EMPTY) + * This value may change as frames are added (esp non-audio frames) */ + long jb_next (jitterbuf *jb); + + /*! \brief get jitterbuf info: only "statistics" may be valid */ + enum jb_return_code jb_getinfo (jitterbuf *jb, jb_info *stats); + + /* some diagnostics */ + void jb_dbginfo (jitterbuf *jb); + + /*! \brief set jitterbuf conf */ + enum jb_return_code jb_setconf (jitterbuf *jb, jb_conf *conf); + + typedef void __attribute__ ( (format (printf, 1, 2))) (*jb_output_function_t) (const char *fmt, ...); + void jb_setoutput (jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); #ifdef __cplusplus } diff --git a/sflphone-common/src/audio/mainbuffer.h b/sflphone-common/src/audio/mainbuffer.h index 9b97a88fc000c9ad9c4628581d285da43222d84d..12a47c4c1801b9cf1691979e632d206ec2e09613 100644 --- a/sflphone-common/src/audio/mainbuffer.h +++ b/sflphone-common/src/audio/mainbuffer.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author : Alexandre Savard <alexandre.savard@savoirfairelinux.com> - * - * + * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -47,103 +47,106 @@ typedef std::set<CallID> CallIDSet; typedef std::map<CallID, CallIDSet*> CallIDMap; -class MainBuffer { +class MainBuffer +{ - public: + public: MainBuffer(); ~MainBuffer(); - void setInternalSamplingRate(int sr); + void setInternalSamplingRate (int sr); + + int getInternalSamplingRate() { + return _internalSamplingRate; + } - int getInternalSamplingRate() {return _internalSamplingRate;} + CallIDSet* getCallIDSet (CallID call_id); - CallIDSet* getCallIDSet(CallID call_id); + bool createCallIDSet (CallID set_id); - bool createCallIDSet(CallID set_id); + bool removeCallIDSet (CallID set_id); - bool removeCallIDSet(CallID set_id); + /** + * Add a new call id to this set + */ + void addCallIDtoSet (CallID set_id, CallID call_id); - /** - * Add a new call id to this set - */ - void addCallIDtoSet(CallID set_id, CallID call_id); + void removeCallIDfromSet (CallID set_id, CallID call_id); - void removeCallIDfromSet(CallID set_id, CallID call_id); + /** + * Create a new ringbuffer with default readpointer + */ + RingBuffer* createRingBuffer (CallID call_id); - /** - * Create a new ringbuffer with default readpointer - */ - RingBuffer* createRingBuffer(CallID call_id); + bool removeRingBuffer (CallID call_id); - bool removeRingBuffer(CallID call_id); + void bindCallID (CallID call_id1, CallID call_id2 = default_id); - void bindCallID(CallID call_id1, CallID call_id2 = default_id); + /** + * Add a new call_id to unidirectional outgoing stream + * \param call_id New call id to be added for this stream + * \param process_id Process that require this stream + */ + void bindHalfDuplexOut (CallID process_id, CallID call_id = default_id); - /** - * Add a new call_id to unidirectional outgoing stream - * \param call_id New call id to be added for this stream - * \param process_id Process that require this stream - */ - void bindHalfDuplexOut(CallID process_id, CallID call_id = default_id); + /** + * Unbind two calls + */ + void unBindCallID (CallID call_id1, CallID call_id2 = default_id); - /** - * Unbind two calls - */ - void unBindCallID(CallID call_id1, CallID call_id2 = default_id); + void unBindHalfDuplexOut (CallID process_id, CallID call_id = default_id); - void unBindHalfDuplexOut(CallID process_id, CallID call_id = default_id); + void unBindAll (CallID call_id); - void unBindAll(CallID call_id); + void unBindAllHalfDuplexOut (CallID process_id); - void unBindAllHalfDuplexOut(CallID process_id); + int putData (void *buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); - int putData(void *buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); + int getData (void *buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); - int getData(void *buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); + int availForPut (CallID call_id = default_id); - int availForPut(CallID call_id = default_id); + int availForGet (CallID call_id = default_id); - int availForGet(CallID call_id = default_id); + int discard (int toDiscard, CallID call_id = default_id); - int discard(int toDiscard, CallID call_id = default_id); + void flush (CallID call_id = default_id); - void flush(CallID call_id = default_id); + void flushAllBuffers(); - void flushAllBuffers(); + void flushDefault(); - void flushDefault(); - - void syncBuffers(CallID call_id); + void syncBuffers (CallID call_id); - void stateInfo(); + void stateInfo(); private: - RingBuffer* getRingBuffer(CallID call_id); + RingBuffer* getRingBuffer (CallID call_id); - int getDataByID(void *buffer, int toCopy, unsigned short volume, CallID call_id, CallID reader_id); + int getDataByID (void *buffer, int toCopy, unsigned short volume, CallID call_id, CallID reader_id); - int availForGetByID(CallID call_id, CallID reader_id); + int availForGetByID (CallID call_id, CallID reader_id); - int discardByID(int toDiscard, CallID call_id, CallID reader_id); + int discardByID (int toDiscard, CallID call_id, CallID reader_id); - void flushByID(CallID call_id, CallID reader_id); + void flushByID (CallID call_id, CallID reader_id); - RingBufferMap _ringBufferMap; + RingBufferMap _ringBufferMap; - CallIDMap _callIDMap; + CallIDMap _callIDMap; - SFLDataFormat* mixBuffer; + SFLDataFormat* mixBuffer; - // ost::Mutex _mutex; + // ost::Mutex _mutex; - int _internalSamplingRate; + int _internalSamplingRate; public: - friend class MainBufferTest; + friend class MainBufferTest; }; #endif diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index dd53993b772db89d459cc6ae779701cf9b78c185..23729214652aaf485b5805b20a238d28db077857 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -68,7 +68,7 @@ AudioStream::connectStream (std::string* deviceName) return true; } -static void success_cb (pa_stream *s, int success, void *userdata) +static void success_cb (pa_stream *s, int success UNUSED, void *userdata) { assert (s); @@ -78,7 +78,6 @@ static void success_cb (pa_stream *s, int success, void *userdata) pa_threaded_mainloop_signal (mainloop, 0); } - bool AudioStream::drainStream (void) { diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.h b/sflphone-common/src/audio/pulseaudio/audiostream.h index 20e199bf293134a18402189e22c9c1de013d4313..e4c48b94072d9e254f1705aa1ccf1e1265b62f77 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.h +++ b/sflphone-common/src/audio/pulseaudio/audiostream.h @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -44,157 +44,168 @@ * This data structure contains the different king of audio streams available */ enum STREAM_TYPE { - PLAYBACK_STREAM, - CAPTURE_STREAM, - RINGTONE_STREAM, - UPLOAD_STREAM + PLAYBACK_STREAM, + CAPTURE_STREAM, + RINGTONE_STREAM, + UPLOAD_STREAM }; struct PulseLayerType { pa_context * context; pa_threaded_mainloop * mainloop; - + std::string description; - + int type; double volume; }; -class AudioStream { - public: - /** - * Constructor - * @param context The PulseLayerType structure containing various information. - */ - AudioStream(PulseLayerType * driver, int smplrate); - - /** - * Destructor - */ - ~AudioStream(); - - /** - * Write data to the main abstraction ring buffer. - * @param buffer The buffer containing the data to be played - * @param toCopy The number of samples, in bytes - * @return int The number of bytes played - */ - int putMain( void* buffer , int toCopy ); - - /** - * Write data to the urgent abstraction ring buffer. ( dtmf , double calls ) - * @param buffer The buffer containing the data to be played - * @param toCopy The number of samples, in bytes - * @return int The number of bytes played - */ - int putUrgent( void* buffer , int toCopy ); - - /** - * Connect the pulse audio stream - */ - bool connectStream(std::string* deviceName); - - /** - * Drain the given stream. - */ - bool drainStream(void); - - /** - * Disconnect the pulseaudio stream - */ - bool disconnectStream(); - - /** - * Accessor: Get the pulseaudio stream object - * @return pa_stream* The stream - */ - pa_stream* pulseStream(){ return _audiostream; } - - /** - * Accessor - * @return std::string The stream name - */ - std::string getStreamName( void ) { return _streamDescription; } - - /** - * Accessor - * @param name The stream name - */ - void setStreamName( std::string name ) { _streamDescription = name; } - - void setVolume( double pc ) { _volume.values[0] *= pc/100; } - pa_cvolume getVolume( void ) { return _volume; } - - /** - * Accessor - * @return stream state - */ - pa_stream_state_t getStreamState(void); - - - - private: - - // Copy Constructor - AudioStream(const AudioStream& rh); - - // Assignment Operator - AudioStream& operator=( const AudioStream& rh); - - /** - * Create the audio stream into the given context - * @param c The pulseaudio context - * @return pa_stream* The newly created audio stream - */ - pa_stream* createStream( pa_context* c, std::string* deviceName); - - /** - * Mandatory asynchronous callback on the audio stream state - */ - static void stream_state_callback( pa_stream* s, void* user_data ); - - /** - * Asynchronous callback on data processing ( write and read ) - */ - static void audioCallback ( pa_stream* s, size_t bytes, void* userdata ); - - /** - * Write data to the sound device - */ - void write( void ); - - /** - * The pulse audio object - */ - pa_stream* _audiostream; - - /** - * The pulse audio context - */ - pa_context* _context; - - /** - * The type of the stream - */ - int _streamType; - - /** - * The name of the stream - */ - std::string _streamDescription; - - /** - * Streams parameters - */ - pa_cvolume _volume; - pa_stream_flags_t _flag; - pa_sample_spec _sample_spec ; - - pa_threaded_mainloop * _mainloop; - - ost::Mutex _mutex; - - bool _stream_is_ready; +class AudioStream +{ + public: + /** + * Constructor + * @param context The PulseLayerType structure containing various information. + */ + AudioStream (PulseLayerType * driver, int smplrate); + + /** + * Destructor + */ + ~AudioStream(); + + /** + * Write data to the main abstraction ring buffer. + * @param buffer The buffer containing the data to be played + * @param toCopy The number of samples, in bytes + * @return int The number of bytes played + */ + int putMain (void* buffer , int toCopy); + + /** + * Write data to the urgent abstraction ring buffer. ( dtmf , double calls ) + * @param buffer The buffer containing the data to be played + * @param toCopy The number of samples, in bytes + * @return int The number of bytes played + */ + int putUrgent (void* buffer , int toCopy); + + /** + * Connect the pulse audio stream + */ + bool connectStream (std::string* deviceName); + + /** + * Drain the given stream. + */ + bool drainStream (void); + + /** + * Disconnect the pulseaudio stream + */ + bool disconnectStream(); + + /** + * Accessor: Get the pulseaudio stream object + * @return pa_stream* The stream + */ + pa_stream* pulseStream() { + return _audiostream; + } + + /** + * Accessor + * @return std::string The stream name + */ + std::string getStreamName (void) { + return _streamDescription; + } + + /** + * Accessor + * @param name The stream name + */ + void setStreamName (std::string name) { + _streamDescription = name; + } + + void setVolume (double pc) { + _volume.values[0] *= pc/100; + } + pa_cvolume getVolume (void) { + return _volume; + } + + /** + * Accessor + * @return stream state + */ + pa_stream_state_t getStreamState (void); + + + + private: + + // Copy Constructor + AudioStream (const AudioStream& rh); + + // Assignment Operator + AudioStream& operator= (const AudioStream& rh); + + /** + * Create the audio stream into the given context + * @param c The pulseaudio context + * @return pa_stream* The newly created audio stream + */ + pa_stream* createStream (pa_context* c, std::string* deviceName); + + /** + * Mandatory asynchronous callback on the audio stream state + */ + static void stream_state_callback (pa_stream* s, void* user_data); + + /** + * Asynchronous callback on data processing ( write and read ) + */ + static void audioCallback (pa_stream* s, size_t bytes, void* userdata); + + /** + * Write data to the sound device + */ + void write (void); + + /** + * The pulse audio object + */ + pa_stream* _audiostream; + + /** + * The pulse audio context + */ + pa_context* _context; + + /** + * The type of the stream + */ + int _streamType; + + /** + * The name of the stream + */ + std::string _streamDescription; + + /** + * Streams parameters + */ + pa_cvolume _volume; + pa_stream_flags_t _flag; + pa_sample_spec _sample_spec ; + + pa_threaded_mainloop * _mainloop; + + ost::Mutex _mutex; + + bool _stream_is_ready; }; diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index ca936d37634b59af3ff96713a295d3094fcd490b..a4638126a4b60a416e8e60da7da0c4d2befb4988 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -63,24 +63,13 @@ static void ringtone_callback (pa_stream* s, size_t bytes, void* userdata) } - -static void stream_moved_callback (pa_stream *s, void *userdata) +static void stream_moved_callback (pa_stream *s, void *userdata UNUSED) { - int streamIndex = pa_stream_get_index (s); - int deviceIndex = pa_stream_get_device_index (s); - _debug ("stream_moved_callback: stream %d to %d", pa_stream_get_index (s), pa_stream_get_device_index (s)); - -} - -static void pa_success_callback (pa_context *c, int success, void *userdata) -{ - - _debug ("Audio: Success callback"); } -static void latency_update_callback (pa_stream *p, void *userdata) +static void latency_update_callback (pa_stream *p, void *userdata UNUSED) { pa_usec_t r_usec; @@ -96,7 +85,7 @@ static void latency_update_callback (pa_stream *p, void *userdata) } -static void sink_input_info_callback (pa_context *c, const pa_sink_info *i, int eol, void *userdata) +static void sink_input_info_callback (pa_context *c UNUSED, const pa_sink_info *i, int eol, void *userdata) { char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; @@ -131,10 +120,9 @@ static void sink_input_info_callback (pa_context *c, const pa_sink_info *i, int ( (PulseLayer *) userdata)->getSinkList()->push_back (deviceName); } - } -static void source_input_info_callback (pa_context *c, const pa_source_info *i, int eol, void *userdata) +static void source_input_info_callback (pa_context *c UNUSED, const pa_source_info *i, int eol, void *userdata) { char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; @@ -171,8 +159,7 @@ static void source_input_info_callback (pa_context *c, const pa_source_info *i, } } - -static void context_changed_callback (pa_context* c, pa_subscription_event_type_t t, uint32_t idx, void* userdata) +static void context_changed_callback (pa_context* c, pa_subscription_event_type_t t, uint32_t idx UNUSED, void* userdata UNUSED) { switch (t) { @@ -228,28 +215,15 @@ static void context_changed_callback (pa_context* c, pa_subscription_event_type_ _debug ("Audio: Unknown event type"); } - -} - -/* -static void stream_suspended_callback (pa_stream *s UNUSED, void *userdata UNUSED) -{ - _debug("Audio: Stream Suspended"); } -*/ - -static void playback_underflow_callback (pa_stream* s, void* userdata UNUSED) +static void playback_underflow_callback (pa_stream* s UNUSED, void* userdata UNUSED) { - // _debug ("Audio: Buffer Underflow"); - // pa_stream_trigger (s, NULL, NULL); } static void playback_overflow_callback (pa_stream* s UNUSED, void* userdata UNUSED) { - // _debug ("Audio: Buffer OverFlow"); - } @@ -671,15 +645,6 @@ int PulseLayer::canGetMic() } -int PulseLayer::getMic (void *buffer, int toCopy) -{ - if (record) { - return 0; - } else - return 0; -} - - void PulseLayer::startStream (void) { if (_audiofilter) @@ -1029,8 +994,6 @@ void PulseLayer::readFromMic (void) void PulseLayer::ringtoneToSpeaker (void) { - int availBytes; - AudioLoop* file_tone = _manager->getTelephoneFile(); SFLDataFormat* out; diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.h b/sflphone-common/src/audio/pulseaudio/pulselayer.h index 047fe84093f133c5ee4a29ae9b676d993944d774..2cfb2595d17e473c2b4fa9b8e9aafd166c94e061 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.h +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.h @@ -7,12 +7,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -54,244 +54,261 @@ class ManagerImpl; typedef std::list<std::string> DeviceList; -class PulseLayer : public AudioLayer { - public: - PulseLayer(ManagerImpl* manager); - ~PulseLayer(void); - - void openLayer( void ); - - bool closeLayer( void ); - - /** - * Check if no devices are opened, otherwise close them. - * Then open the specified devices by calling the private functions open_device - * @param indexIn The number of the card chosen for capture - * @param indexOut The number of the card chosen for playback - * @param sampleRate The sample rate - * @param frameSize The frame size - * @param stream To indicate which kind of stream you want to open - * SFL_PCM_CAPTURE - * SFL_PCM_PLAYBACK - * SFL_PCM_BOTH - * @param plugin The alsa plugin ( dmix , default , front , surround , ...) - */ - bool openDevice(int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, std::string plugin) ; - - DeviceList* getSinkList(void) { return &_sinkList; } - - DeviceList* getSourceList(void) { return &_sourceList; } - - void updateSinkList(void); - - void updateSourceList(void); - - bool inSinkList(std::string deviceName); - - bool inSourceList(std::string deviceName); - - void startStream(void); - - void stopStream(void); - - /** - * Query the capture device for number of bytes available in the hardware ring buffer - * @return int The number of bytes available - */ - int canGetMic(); - - /** - * Get data from the capture device - * @param buffer The buffer for data - * @param toCopy The number of bytes to get - * @return int The number of bytes acquired ( 0 if an error occured) - */ - int getMic(void *, int); - - static void overflow ( pa_stream* s, void* userdata ); - static void underflow ( pa_stream* s, void* userdata ); - static void stream_state_callback( pa_stream* s, void* user_data ); - static void context_state_callback( pa_context* c, void* user_data ); - // static void stream_suspended_callback ( pa_stream* s, void* userdata ); - - bool isCaptureActive (void){return true;} - - /** - * UNUSED in pulseaudio layer - */ - //std::vector<std::string> getSoundCardsInfo( int stream UNUSED ) { - //std::vector<std::string> tmp; - //return tmp; - //} - - /** - * Reduce volume of every audio applications connected to the same sink - */ - void reducePulseAppsVolume( void ); - - /** - * Restore the volume of every audio applications connected to the same sink to PA_VOLUME_NORM - */ - void restorePulseAppsVolume( void ); - - /** - * Set the volume of a sink. - * @param index The index of the stream - * @param channels The stream's number of channels - * @param volume The new volume (between 0 and 100) - */ - void setSinkVolume( int index, int channels, int volume ); - void setSourceVolume( int index, int channels, int volume ); - - void setPlaybackVolume( int volume ); - void setCaptureVolume( int volume ); - - /** - * Accessor - * @return AudioStream* The pointer on the playback AudioStream object - */ - AudioStream* getPlaybackStream(){ return playback;} - - /** - * Accessor - * @return AudioStream* The pointer on the record AudioStream object - */ - AudioStream* getRecordStream(){ return record;} - - /** - * Accessor - * @return AudioStream* The pointer on the ringtone AudioStream object - */ - AudioStream* getRingtoneStream(){ return ringtone;} - - int getSpkrVolume( void ) { return spkrVolume; } - void setSpkrVolume( int value ) { spkrVolume = value; } - - int getMicVolume( void ) { return micVolume; } - void setMicVolume( int value ) { micVolume = value; } - - void processPlaybackData( void ); - - void processCaptureData( void ); - - void processRingtoneData( void ); - - void processData(void); - - /** - * Get the echo canceller state - * @return true if echo cancel activated - */ - bool getEchoCancelState(void) { return AudioLayer::_echocancelstate; } - - /** - * Set the echo canceller state - * @param state true if echocancel active, false elsewhere - */ - void setEchoCancelState(bool state); - - /** - * Get the noise suppressor state - * @return true if noise suppressor activated - */ - bool getNoiseSuppressState(void) { return AudioLayer::_noisesuppressstate; } - - /** - * Set the noise suppressor state - * @param state true if noise suppressor active, false elsewhere - */ - void setNoiseSuppressState(bool state); - - private: - // Copy Constructor - PulseLayer(const PulseLayer& rh); - - // Assignment Operator - PulseLayer& operator=( const PulseLayer& rh); - - - /** - * Drop the pending frames and close the capture device - */ - void closeCaptureStream( void ); - - /** - * Write data from the ring buffer to the harware and read data from the hardware - */ - void readFromMic( void ); - void writeToSpeaker( void ); - void ringtoneToSpeaker( void ); - - /** - * Create the audio streams into the given context - * @param c The pulseaudio context - */ - bool createStreams( pa_context* c ); - - /** - * Drop the pending frames and close the playback device - */ - void closePlaybackStream( void ); - - /** - * Establishes the connection with the local pulseaudio server - */ - void connectPulseAudioServer( void ); - - /** - * Close the connection with the local pulseaudio server - */ - bool disconnectAudioStream( void ); - - /** - * Get some information about the pulseaudio server - */ - void serverinfo( void ); - - /** PulseAudio context and asynchronous loop */ - pa_context* context; - pa_threaded_mainloop* m; - - /** - * A stream object to handle the pulseaudio playback stream - */ - AudioStream* playback; - - /** - * A stream object to handle the pulseaudio capture stream - */ - AudioStream* record; - - /** - * A special stream object to handle specific playback stream for ringtone - */ - AudioStream* ringtone; - - /** Sample rate converter object */ - SamplerateConverter * _converter; - - bool is_started; - - int spkrVolume; - int micVolume; - - /* - ofstream *captureFile; - ofstream *captureRsmplFile; - ofstream *captureFilterFile; - */ - - DeviceList _sinkList; - - DeviceList _sourceList; - - // private: - - int byteCounter; - -public: - - friend class AudioLayerTest; +class PulseLayer : public AudioLayer +{ + public: + PulseLayer (ManagerImpl* manager); + ~PulseLayer (void); + + void openLayer (void); + + bool closeLayer (void); + + /** + * Check if no devices are opened, otherwise close them. + * Then open the specified devices by calling the private functions open_device + * @param indexIn The number of the card chosen for capture + * @param indexOut The number of the card chosen for playback + * @param sampleRate The sample rate + * @param frameSize The frame size + * @param stream To indicate which kind of stream you want to open + * SFL_PCM_CAPTURE + * SFL_PCM_PLAYBACK + * SFL_PCM_BOTH + * @param plugin The alsa plugin ( dmix , default , front , surround , ...) + */ + bool openDevice (int indexIn, int indexOut, int indexRing, int sampleRate, int frameSize , int stream, std::string plugin) ; + + DeviceList* getSinkList (void) { + return &_sinkList; + } + + DeviceList* getSourceList (void) { + return &_sourceList; + } + + void updateSinkList (void); + + void updateSourceList (void); + + bool inSinkList (std::string deviceName); + + bool inSourceList (std::string deviceName); + + void startStream (void); + + void stopStream (void); + + /** + * Query the capture device for number of bytes available in the hardware ring buffer + * @return int The number of bytes available + */ + int canGetMic(); + + static void overflow (pa_stream* s, void* userdata); + static void underflow (pa_stream* s, void* userdata); + static void stream_state_callback (pa_stream* s, void* user_data); + static void context_state_callback (pa_context* c, void* user_data); + // static void stream_suspended_callback ( pa_stream* s, void* userdata ); + + bool isCaptureActive (void) { + return true; + } + + /** + * UNUSED in pulseaudio layer + */ + //std::vector<std::string> getSoundCardsInfo( int stream UNUSED ) { + //std::vector<std::string> tmp; + //return tmp; + //} + + /** + * Reduce volume of every audio applications connected to the same sink + */ + void reducePulseAppsVolume (void); + + /** + * Restore the volume of every audio applications connected to the same sink to PA_VOLUME_NORM + */ + void restorePulseAppsVolume (void); + + /** + * Set the volume of a sink. + * @param index The index of the stream + * @param channels The stream's number of channels + * @param volume The new volume (between 0 and 100) + */ + void setSinkVolume (int index, int channels, int volume); + void setSourceVolume (int index, int channels, int volume); + + void setPlaybackVolume (int volume); + void setCaptureVolume (int volume); + + /** + * Accessor + * @return AudioStream* The pointer on the playback AudioStream object + */ + AudioStream* getPlaybackStream() { + return playback; + } + + /** + * Accessor + * @return AudioStream* The pointer on the record AudioStream object + */ + AudioStream* getRecordStream() { + return record; + } + + /** + * Accessor + * @return AudioStream* The pointer on the ringtone AudioStream object + */ + AudioStream* getRingtoneStream() { + return ringtone; + } + + int getSpkrVolume (void) { + return spkrVolume; + } + void setSpkrVolume (int value) { + spkrVolume = value; + } + + int getMicVolume (void) { + return micVolume; + } + void setMicVolume (int value) { + micVolume = value; + } + + void processPlaybackData (void); + + void processCaptureData (void); + + void processRingtoneData (void); + + void processData (void); + + /** + * Get the echo canceller state + * @return true if echo cancel activated + */ + bool getEchoCancelState (void) { + return AudioLayer::_echocancelstate; + } + + /** + * Set the echo canceller state + * @param state true if echocancel active, false elsewhere + */ + void setEchoCancelState (bool state); + + /** + * Get the noise suppressor state + * @return true if noise suppressor activated + */ + bool getNoiseSuppressState (void) { + return AudioLayer::_noisesuppressstate; + } + + /** + * Set the noise suppressor state + * @param state true if noise suppressor active, false elsewhere + */ + void setNoiseSuppressState (bool state); + + private: + // Copy Constructor + PulseLayer (const PulseLayer& rh); + + // Assignment Operator + PulseLayer& operator= (const PulseLayer& rh); + + + /** + * Drop the pending frames and close the capture device + */ + void closeCaptureStream (void); + + /** + * Write data from the ring buffer to the harware and read data from the hardware + */ + void readFromMic (void); + void writeToSpeaker (void); + void ringtoneToSpeaker (void); + + /** + * Create the audio streams into the given context + * @param c The pulseaudio context + */ + bool createStreams (pa_context* c); + + /** + * Drop the pending frames and close the playback device + */ + void closePlaybackStream (void); + + /** + * Establishes the connection with the local pulseaudio server + */ + void connectPulseAudioServer (void); + + /** + * Close the connection with the local pulseaudio server + */ + bool disconnectAudioStream (void); + + /** + * Get some information about the pulseaudio server + */ + void serverinfo (void); + + /** PulseAudio context and asynchronous loop */ + pa_context* context; + pa_threaded_mainloop* m; + + /** + * A stream object to handle the pulseaudio playback stream + */ + AudioStream* playback; + + /** + * A stream object to handle the pulseaudio capture stream + */ + AudioStream* record; + + /** + * A special stream object to handle specific playback stream for ringtone + */ + AudioStream* ringtone; + + /** Sample rate converter object */ + SamplerateConverter * _converter; + + bool is_started; + + int spkrVolume; + int micVolume; + + /* + ofstream *captureFile; + ofstream *captureRsmplFile; + ofstream *captureFilterFile; + */ + + DeviceList _sinkList; + + DeviceList _sourceList; + + // private: + + int byteCounter; + + public: + + friend class AudioLayerTest; }; #endif // _PULSE_LAYER_H_ diff --git a/sflphone-common/src/audio/recordable.h b/sflphone-common/src/audio/recordable.h index 6b08db919674c1529653c343c367c08a3b0f2201..4ec7362afe78e39d127700d6632b423e43b9da03 100644 --- a/sflphone-common/src/audio/recordable.h +++ b/sflphone-common/src/audio/recordable.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -33,52 +33,57 @@ #include "audiorecord.h" #include "audiorecorder.h" -class Recordable { +class Recordable +{ public: Recordable(); - ~Recordable(); + ~Recordable(); - /** - * Return recording state (true/false) - */ - bool isRecording(){ return recAudio.isRecording(); } + /** + * Return recording state (true/false) + */ + bool isRecording() { + return recAudio.isRecording(); + } - /** - * This method must be implemented for this interface as calls and conferences - * have different behavior. - */ - virtual bool setRecording() = 0; + /** + * This method must be implemented for this interface as calls and conferences + * have different behavior. + */ + virtual bool setRecording() = 0; - /** - * Stop recording - */ - void stopRecording(){ recAudio.stopRecording(); } + /** + * Stop recording + */ + void stopRecording() { + recAudio.stopRecording(); + } - /** - * Init the recording file name according to path specified in configuration - */ - void initRecFileName(); + /** + * Init the recording file name according to path specified in configuration + */ + void initRecFileName(); - /** - * Set recording sampling rate. - */ - void setRecordingSmplRate(int smplRate); + /** + * Set recording sampling rate. + */ + void setRecordingSmplRate (int smplRate); - virtual std::string getRecFileId() = 0; + virtual std::string getRecFileId() = 0; - // virtual std::string getFileName() = 0; + // virtual std::string getFileName() = 0; - // std::string getFileName() { return _filename; } + // std::string getFileName() { return _filename; } - /** - * An instance of audio recorder - */ - AudioRecord recAudio; + /** + * An instance of audio recorder + */ + AudioRecord recAudio; - AudioRecorder recorder; + AudioRecorder recorder; }; diff --git a/sflphone-common/src/audio/ringbuffer.h b/sflphone-common/src/audio/ringbuffer.h index 6d5ad7d29e12a7d73a45cc0aaf0f54be486c8475..b52cd3417c21f953cd85aeb47ca936547a89f484 100644 --- a/sflphone-common/src/audio/ringbuffer.h +++ b/sflphone-common/src/audio/ringbuffer.h @@ -33,144 +33,149 @@ typedef map<CallID, int> ReadPointer; static CallID default_id = "audiolayer_id"; -class RingBuffer { - public: - /** - * Constructor - * @param size Size of the buffer to create - */ - RingBuffer(int size, CallID call_id = default_id); - - /** - * Destructor - */ - ~RingBuffer(); - - CallID getBufferId(){ return buffer_id; } - - /** - * Reset the counters to 0 for this read pointer - */ - void flush (CallID call_id = default_id); - - void flushAll(); - - /** - * Get read pointer coresponding to this call - */ - int getReadPointer(CallID call_id = default_id); - - /** - * Get the whole readpointer list for this ringbuffer - */ - ReadPointer* getReadPointerList() { return &_readpointer; } - - /** - * Return the smalest readpointer. Usefull to evaluate if ringbuffer is full - */ - int getSmallestReadPointer(); - - /** - * Move readpointer forward by pointer_value - */ - void storeReadPointer(int pointer_value, CallID call_id = default_id); - - /** - * Add a new readpointer for this ringbuffer - */ - void createReadPointer(CallID call_id = default_id); - - /** - * Remove a readpointer for this ringbuffer - */ - void removeReadPointer(CallID call_id = default_id); - - /** - * Test if readpointer coresponding to this call is still active - */ - bool hasThisReadPointer(CallID call_id); - - int getNbReadPointer(); - - /** - * To get how much space is available in the buffer to write in - * @return int The available size - */ - int AvailForPut (void); - - /** - * Write data in the ring buffer - * @param buffer Data to copied - * @param toCopy Number of bytes to copy - * @param volume The volume - * @return int Number of bytes copied - */ - int Put (void* buffer, int toCopy, unsigned short volume = 100); - - /** - * To get how much space is available in the buffer to read in - * @return int The available size - */ - int AvailForGet (CallID call_id = default_id); - - /** - * Get data in the ring buffer - * @param buffer Data to copied - * @param toCopy Number of bytes to copy - * @param volume The volume - * @return int Number of bytes copied - */ - int Get (void* buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); - - /** - * Discard data from the buffer - * @param toDiscard Number of bytes to discard - * @return int Number of bytes discarded - */ - int Discard(int toDiscard, CallID call_id = default_id); - - /** - * Total length of the ring buffer - * @return int - */ - int putLen(); - - int getLen(CallID call_id = default_id); - - /** - * Debug function print mEnd, mStart, mBufferSize - */ - void debug(); - - private: - // Copy Constructor - RingBuffer(const RingBuffer& rh); - - // Assignment operator - RingBuffer& operator=(const RingBuffer& rh); - - /** Pointer on the first data */ - // int mStart; - /** Pointer on the last data */ - int mEnd; - /** Buffer size */ - int mBufferSize; - /** Data */ - samplePtr mBuffer; - - ReadPointer _readpointer; - - CallID buffer_id; - - public: - - friend class MainBufferTest; - - std::fstream *buffer_input_rec; - std::fstream *buffer_output_rec; - - static int count_rb; - +class RingBuffer +{ + public: + /** + * Constructor + * @param size Size of the buffer to create + */ + RingBuffer (int size, CallID call_id = default_id); + + /** + * Destructor + */ + ~RingBuffer(); + + CallID getBufferId() { + return buffer_id; + } + + /** + * Reset the counters to 0 for this read pointer + */ + void flush (CallID call_id = default_id); + + void flushAll(); + + /** + * Get read pointer coresponding to this call + */ + int getReadPointer (CallID call_id = default_id); + + /** + * Get the whole readpointer list for this ringbuffer + */ + ReadPointer* getReadPointerList() { + return &_readpointer; + } + + /** + * Return the smalest readpointer. Usefull to evaluate if ringbuffer is full + */ + int getSmallestReadPointer(); + + /** + * Move readpointer forward by pointer_value + */ + void storeReadPointer (int pointer_value, CallID call_id = default_id); + + /** + * Add a new readpointer for this ringbuffer + */ + void createReadPointer (CallID call_id = default_id); + + /** + * Remove a readpointer for this ringbuffer + */ + void removeReadPointer (CallID call_id = default_id); + + /** + * Test if readpointer coresponding to this call is still active + */ + bool hasThisReadPointer (CallID call_id); + + int getNbReadPointer(); + + /** + * To get how much space is available in the buffer to write in + * @return int The available size + */ + int AvailForPut (void); + + /** + * Write data in the ring buffer + * @param buffer Data to copied + * @param toCopy Number of bytes to copy + * @param volume The volume + * @return int Number of bytes copied + */ + int Put (void* buffer, int toCopy, unsigned short volume = 100); + + /** + * To get how much space is available in the buffer to read in + * @return int The available size + */ + int AvailForGet (CallID call_id = default_id); + + /** + * Get data in the ring buffer + * @param buffer Data to copied + * @param toCopy Number of bytes to copy + * @param volume The volume + * @return int Number of bytes copied + */ + int Get (void* buffer, int toCopy, unsigned short volume = 100, CallID call_id = default_id); + + /** + * Discard data from the buffer + * @param toDiscard Number of bytes to discard + * @return int Number of bytes discarded + */ + int Discard (int toDiscard, CallID call_id = default_id); + + /** + * Total length of the ring buffer + * @return int + */ + int putLen(); + + int getLen (CallID call_id = default_id); + + /** + * Debug function print mEnd, mStart, mBufferSize + */ + void debug(); + + private: + // Copy Constructor + RingBuffer (const RingBuffer& rh); + + // Assignment operator + RingBuffer& operator= (const RingBuffer& rh); + + /** Pointer on the first data */ + // int mStart; + /** Pointer on the last data */ + int mEnd; + /** Buffer size */ + int mBufferSize; + /** Data */ + samplePtr mBuffer; + + ReadPointer _readpointer; + + CallID buffer_id; + + public: + + friend class MainBufferTest; + + std::fstream *buffer_input_rec; + std::fstream *buffer_output_rec; + + static int count_rb; + }; diff --git a/sflphone-common/src/audio/samplerateconverter.h b/sflphone-common/src/audio/samplerateconverter.h index 3a20105fae5f5303bc940ae19a5c1e8dbb72a8e0..5645a64a4bc8d9a93a7123aa37c4764113e43515 100644 --- a/sflphone-common/src/audio/samplerateconverter.h +++ b/sflphone-common/src/audio/samplerateconverter.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -36,75 +36,80 @@ #include "global.h" -class SamplerateConverter { - public: - /** Constructor */ - SamplerateConverter( void ); - SamplerateConverter( int freq , int fs ); - /** Destructor */ - ~SamplerateConverter( void ); - - /** - * Upsample from the samplerate1 to the samplerate2 - * @param data The data buffer - * @param SamplerateConverter1 The lower sample rate - * @param SamplerateConverter2 The higher sample rate - * @param nbSamples The number of samples to process - * @return int The number of samples after the operation - */ - int upsampleData( SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples ); - - /** - * Downsample from the samplerate1 to the samplerate2 - * @param data The data buffer - * @param SamplerateConverter1 The lower sample rate - * @param SamplerateConverter2 The higher sample rate - * @param nbSamples The number of samples to process - * @return int The number of samples after the operation - */ - int downsampleData( SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples ); - - int getFrequence( void ) { return _frequence; } - - int getFramesize( void ) { return _framesize; } - - /** - * Convert short table to floats for audio processing - * @param in the input (short) array - * @param out The resulting (float) array - * @param len The number of elements in both tables - */ - void Short2FloatArray (const short *in, float *out, int len); - - - private: - // Copy Constructor - SamplerateConverter(const SamplerateConverter& rh); - - // Assignment Operator - SamplerateConverter& operator=( const SamplerateConverter& rh); - - void init( void ); - - /** Audio layer caracteristics */ - int _frequence; - int _framesize; - - /** Downsampled/Upsampled float buffers for the mic data processing */ - float32* _floatBufferDownMic; - float32* _floatBufferUpMic; - /** libSamplerateConverter converter for outgoing voice */ - SRC_STATE* _src_state_mic; - - /** Downsampled/Upsampled float buffers for the speaker data processing */ - float32* _floatBufferDownSpkr; - float32* _floatBufferUpSpkr; - /** libSamplerateConverter converter for incoming voice */ - SRC_STATE* _src_state_spkr; - /** libSamplerateConverter error */ - int _src_err; - - +class SamplerateConverter +{ + public: + /** Constructor */ + SamplerateConverter (void); + SamplerateConverter (int freq , int fs); + /** Destructor */ + ~SamplerateConverter (void); + + /** + * Upsample from the samplerate1 to the samplerate2 + * @param data The data buffer + * @param SamplerateConverter1 The lower sample rate + * @param SamplerateConverter2 The higher sample rate + * @param nbSamples The number of samples to process + * @return int The number of samples after the operation + */ + int upsampleData (SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples); + + /** + * Downsample from the samplerate1 to the samplerate2 + * @param data The data buffer + * @param SamplerateConverter1 The lower sample rate + * @param SamplerateConverter2 The higher sample rate + * @param nbSamples The number of samples to process + * @return int The number of samples after the operation + */ + int downsampleData (SFLDataFormat* dataIn , SFLDataFormat* dataOut , int samplerate1 , int samplerate2 , int nbSamples); + + int getFrequence (void) { + return _frequence; + } + + int getFramesize (void) { + return _framesize; + } + + /** + * Convert short table to floats for audio processing + * @param in the input (short) array + * @param out The resulting (float) array + * @param len The number of elements in both tables + */ + void Short2FloatArray (const short *in, float *out, int len); + + + private: + // Copy Constructor + SamplerateConverter (const SamplerateConverter& rh); + + // Assignment Operator + SamplerateConverter& operator= (const SamplerateConverter& rh); + + void init (void); + + /** Audio layer caracteristics */ + int _frequence; + int _framesize; + + /** Downsampled/Upsampled float buffers for the mic data processing */ + float32* _floatBufferDownMic; + float32* _floatBufferUpMic; + /** libSamplerateConverter converter for outgoing voice */ + SRC_STATE* _src_state_mic; + + /** Downsampled/Upsampled float buffers for the speaker data processing */ + float32* _floatBufferDownSpkr; + float32* _floatBufferUpSpkr; + /** libSamplerateConverter converter for incoming voice */ + SRC_STATE* _src_state_spkr; + /** libSamplerateConverter error */ + int _src_err; + + }; #endif //_SAMPLE_RATE_H diff --git a/sflphone-common/src/audio/sound/audiofile.cpp b/sflphone-common/src/audio/sound/audiofile.cpp index a97ccfdcde58fe9e9479579019b56389e00857b6..04be6d1d6cd78b1984236f1c7286bd8cfd03acc2 100644 --- a/sflphone-common/src/audio/sound/audiofile.cpp +++ b/sflphone-common/src/audio/sound/audiofile.cpp @@ -174,158 +174,3 @@ AudioFile::loadFile (const std::string& filename, AudioCodec* codec , unsigned i return true; } - - - -WavFile::WavFile() - : AudioLoop(), - _filename(), - _codec (NULL), - _start (false) - -{ -} - -WavFile::~WavFile() -{ -} - - -bool WavFile::isFileExist (const std::string& filename) -{ - - std::fstream fs (filename.c_str(), std::ios_base::in); - - if (!fs) { - _debug ("WavFile: File \"%s\" doesn't exist", filename.c_str()); - return false; - } - - return true; - -} - -bool WavFile::loadFile (const std::string& filename, AudioCodec* codec , unsigned int sampleRate) -{ - if (!isFileExist (filename)) - return false; - - std::fstream file; - - printf ("WavFile: Open %s", filename.c_str()); - - file.open (filename.c_str(), std::ios::in | std::ios::binary); - - char riff[4] = {}; - - file.read (riff, 4); - - if (strncmp ("RIFF", riff, 4) != 0) { - _error ("WavFile: File is not of RIFF format"); - return false; - } - - // Find the "fmt " chunk - char fmt[4] = {}; - - while (strncmp ("fmt ", fmt, 4) != 0) { - file.read (fmt, 4); - _debug ("WavFile: Searching... %s", fmt); - } - - SINT32 chunkSize; // fmt chunk size - unsigned short formatTag; // data compression tag - - file.read ( (char*) &chunkSize, 4); // Read fmt chunk size. - file.read ( (char*) &formatTag, 2); - - _debug ("Chunk size: %d\n", chunkSize); - _debug ("Format tag: %d\n", formatTag); - - - if (formatTag != 1) { // PCM = 1, FLOAT = 3 { - _error ("WaveFile: File contains an unsupported data format type"); - return false; - } - - // Get number of channels from the header. - SINT16 chan; - file.read ( (char*) &chan, 2); - - _channels = chan; - - _debug ("WavFile: channel %d", _channels); - - - // Get file sample rate from the header. - SINT32 srate; - file.read ( (char*) &srate, 4); - - _fileRate = (double) srate; - - printf ("WavFile: srate %d", srate); - - SINT32 avgb; - file.read ( (char*) &avgb, 4); - - _debug ("WavFile: Average byte %i\n", avgb); - - SINT16 blockal; - file.read ( (char*) &blockal, 2); - - _debug ("WaveFile: block alignment %d", blockal); - - // Determine the data type - _dataType = 0; - - SINT16 dt; - file.read ( (char*) &dt, 2); - - _debug ("WaveFile: dt %d", dt); - - if (formatTag == 1) { - if (dt == 8) - _dataType = 1; // SINT8; - else if (dt == 16) - _dataType = 2; // SINT16; - else if (dt == 32) - _dataType = 3; // SINT32; - } - - /* - else if ( formatTag == 3 ) - { - if (temp == 32) - dataType_ = FLOAT32; - else if (temp == 64) - dataType_ = FLOAT64; - } - */ - else { - _debug ("WavFile: File's bits per sample is not supported"); - return false; - } - - // Find the "data" chunk - char data[4] = {}; - - while (strncmp ("data", data, 4)) { - file.read (data, 4); - _debug ("WavFile: Searching data"); - } - - // Get length of data from the header. - SINT32 bytes; - file.read ( (char*) &bytes, 4); - - _debug ("WavFile: Data size in byte %ld", bytes); - - _fileSize = 8 * bytes / dt / _channels; // sample frames - - _debug ("WavFile: Data size in frames %ld", _fileSize); - - _debug ("WavFile: File successfully opened"); - - return true; - -} diff --git a/sflphone-common/src/audio/sound/audiofile.h b/sflphone-common/src/audio/sound/audiofile.h index cb96561ff2b6f3a748d830442ffa72de9cedfc64..7a7e9f59cb7b3c0446443d0eedaf2284771007c1 100644 --- a/sflphone-common/src/audio/sound/audiofile.h +++ b/sflphone-common/src/audio/sound/audiofile.h @@ -2,10 +2,10 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * - * Inspired by tonegenerator of + * Inspired by tonegenerator of * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004) * Inspired by ringbuffer of Audacity Project - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -45,131 +45,66 @@ class AudioFile : public AudioLoop { -public: - /** - * Constructor - */ - AudioFile(); - - /** - * Destructor - */ - ~AudioFile(); - - - /** - * Load a sound file in memory - * @param filename The absolute path to the file - * @param codec The codec to decode and encode it - * @param sampleRate The sample rate to read it - * @return bool True on success - */ - bool loadFile(const std::string& filename, AudioCodec *codec , unsigned int sampleRate); - - /** - * Start the sound file - */ - void start() { _start = true; } - - /** - * Stop the sound file - */ - void stop() { _start = false; } - - /** - * Tells whether or not the file is playing - * @return bool True if yes - * false otherwise - */ - bool isStarted() { return _start; } - -private: - // Copy Constructor - AudioFile(const AudioFile& rh); - - // Assignment Operator - AudioFile& operator=( const AudioFile& rh); - - /** The absolute path to the sound file */ - std::string _filename; - - /** Your preferred codec */ - AudioCodec* _codec; - - /** Start or not */ - bool _start; + public: + /** + * Constructor + */ + AudioFile(); + + /** + * Destructor + */ + ~AudioFile(); + + + /** + * Load a sound file in memory + * @param filename The absolute path to the file + * @param codec The codec to decode and encode it + * @param sampleRate The sample rate to read it + * @return bool True on success + */ + bool loadFile (const std::string& filename, AudioCodec *codec , unsigned int sampleRate); + + /** + * Start the sound file + */ + void start() { + _start = true; + } + + /** + * Stop the sound file + */ + void stop() { + _start = false; + } + + /** + * Tells whether or not the file is playing + * @return bool True if yes + * false otherwise + */ + bool isStarted() { + return _start; + } + + private: + // Copy Constructor + AudioFile (const AudioFile& rh); + + // Assignment Operator + AudioFile& operator= (const AudioFile& rh); + + /** The absolute path to the sound file */ + std::string _filename; + + /** Your preferred codec */ + AudioCodec* _codec; + + /** Start or not */ + bool _start; }; +#endif - - -/** - * @file audiofile.h - * @brief A class to manage wave files - */ - -class WavFile : public AudioLoop -{ -public: - /** - * Constructor - */ - WavFile(); - - /** - * Destructor - */ - ~WavFile(); - - - /** - * Load a sound file in memory - * @param filename The absolute path to the file - * @param codec The codec to decode and encode it - * @param sampleRate The sample rate to read it - * @return bool True on success - */ - bool loadFile(const std::string& filename, AudioCodec *codec , unsigned int sampleRate = 44100); - - /** - * Start the sound file - */ - void start() { _start = true; } - - /** - * Stop the sound file - */ - void stop() { _start = false; } - - /** - * Tells whether or not the file is playing - * @return bool True if yes - * false otherwise - */ - bool isStarted() { return _start; } - -private: - // Copy Constructor - WavFile(const AudioFile& rh); - - // Assignment Operator - WavFile& operator=( const AudioFile& rh); - - bool isFileExist(const std::string& filename); - - /** The absolute path to the sound file */ - std::string _filename; - - /** Your preferred codec */ - AudioCodec* _codec; - - /** Start or not */ - bool _start; - - int _channels; - int _fileRate; - int _dataType; - int _fileSize; -}; - -#endif // __AUDIOFILE_H__ diff --git a/sflphone-common/src/audio/sound/dtmf.h b/sflphone-common/src/audio/sound/dtmf.h index 155eca3a412d02457810ebf050a80644468378dd..41609cec66765b62c462750962ac93ba298b03b2 100644 --- a/sflphone-common/src/audio/sound/dtmf.h +++ b/sflphone-common/src/audio/sound/dtmf.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author : Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> + * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * * Portions Copyright (c) 2000 Billy Biggs <bbiggs@div8.net> * Portions Copyright (c) 2004 Wirlab <kphone@wirlab.net> @@ -42,36 +42,37 @@ * @file dtmf.h * @brief DMTF library to generate a dtmf sample */ -class DTMF { - public: - /** - * Create a new DTMF. - * @param sampleRate frequency of the sample (ex: 8000 hz) - */ - DTMF (unsigned int sampleRate); - - /** - * Destructor - */ - ~DTMF (void); +class DTMF +{ + public: + /** + * Create a new DTMF. + * @param sampleRate frequency of the sample (ex: 8000 hz) + */ + DTMF (unsigned int sampleRate); - /** - * Start the done for th given dtmf - * @param code The DTMF code - */ - void startTone(char code); - - /** - * Copy the sound inside the sampling* buffer - * @param buffer : a SFLDataFormat* buffer - * @param n : The size to generate - */ - bool generateDTMF (SFLDataFormat* buffer, size_t n); + /** + * Destructor + */ + ~DTMF (void); - char currentTone; - char newTone; + /** + * Start the done for th given dtmf + * @param code The DTMF code + */ + void startTone (char code); - DTMFGenerator dtmfgenerator; + /** + * Copy the sound inside the sampling* buffer + * @param buffer : a SFLDataFormat* buffer + * @param n : The size to generate + */ + bool generateDTMF (SFLDataFormat* buffer, size_t n); + + char currentTone; + char newTone; + + DTMFGenerator dtmfgenerator; }; #endif // __KEY_DTMF_H_ diff --git a/sflphone-common/src/audio/sound/dtmfgenerator.h b/sflphone-common/src/audio/sound/dtmfgenerator.h index 5fa095f0fc0edff600a5171f8300e4624575cd3e..84423b7853f0245f1f56ad9a336d66f872d74917 100644 --- a/sflphone-common/src/audio/sound/dtmfgenerator.h +++ b/sflphone-common/src/audio/sound/dtmfgenerator.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> + * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * * Portions (c) 2003 iptel.org * @@ -9,12 +9,12 @@ * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 3 of the License, or (at your * option) any later version. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public * License for more details. - * + * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -49,113 +49,113 @@ */ class DTMFException : public std::exception { - private: - - /** Message */ - const char* reason; - public: - /** - * Constructor - * @param _reason An error message - */ - DTMFException(const char* _reason) throw(); - - /** - * Destructor - */ - virtual ~DTMFException() throw(); -/* - // Copy Constructor - DTMFException(const DTMFException& rh) throw(); - - // Assignment Operator - DTMFException& operator=( const DTMFException& rh) throw(); -*/ - /** - * @return const char* The error - */ - virtual const char* what() const throw(); + private: + + /** Message */ + const char* reason; + public: + /** + * Constructor + * @param _reason An error message + */ + DTMFException (const char* _reason) throw(); + + /** + * Destructor + */ + virtual ~DTMFException() throw(); + /* + // Copy Constructor + DTMFException(const DTMFException& rh) throw(); + + // Assignment Operator + DTMFException& operator=( const DTMFException& rh) throw(); + */ + /** + * @return const char* The error + */ + virtual const char* what() const throw(); }; /* * @file dtmfgenerator.h * @brief DTMF Tone Generator */ -class DTMFGenerator +class DTMFGenerator { - private: - /** Struct to handle a DTMF */ - struct DTMFTone { - unsigned char code; /** Code of the tone */ - int lower; /** Lower frequency */ - int higher; /** Higher frequency */ - }; - - /** State of the DTMF generator */ - struct DTMFState { - unsigned int offset; /** Offset in the sample currently being played */ - SFLDataFormat* sample; /** Currently generated code */ - }; - - /** State of the DTMF generator */ - DTMFState state; - - /** The different kind of tones */ - static const DTMFTone tones[NUM_TONES]; - - /** Generated samples */ - SFLDataFormat* samples[NUM_TONES]; - - /** Sampling rate of generated dtmf */ - int _sampleRate; - - /** A tone object */ - Tone tone; - - public: - /** - * DTMF Generator contains frequency of each keys - * and can build one DTMF. - * @param sampleRate frequency of the sample (ex: 8000 hz) - */ - DTMFGenerator(unsigned int sampleRate); - - /** - * Destructor - */ - ~DTMFGenerator(); - - - // Copy Constructor - DTMFGenerator(const DTMFGenerator& rh); - - // Assignment Operator - DTMFGenerator& operator=( const DTMFGenerator& rh); - - /* - * Get n samples of the signal of code code - * @param buffer a SFLDataFormat pointer to an allocated buffer - * @param n number of sampling to get, should be lower or equal to buffer size - * @param code dtmf code to get sound - */ - void getSamples(SFLDataFormat* buffer, size_t n, unsigned char code) throw (DTMFException); - - /* - * Get next n samples (continues where previous call to - * genSample or genNextSamples stopped - * @param buffer a SFLDataFormat pointer to an allocated buffer - * @param n number of sampling to get, should be lower or equal to buffer size - */ - void getNextSamples(SFLDataFormat* buffer, size_t n) throw (DTMFException); - - private: - - /** - * Generate samples for a specific dtmf code - * @param code The code - * @return SFLDataFormat* The generated data - */ - SFLDataFormat* generateSample(unsigned char code) throw (DTMFException); + private: + /** Struct to handle a DTMF */ + struct DTMFTone { + unsigned char code; /** Code of the tone */ + int lower; /** Lower frequency */ + int higher; /** Higher frequency */ + }; + + /** State of the DTMF generator */ + struct DTMFState { + unsigned int offset; /** Offset in the sample currently being played */ + SFLDataFormat* sample; /** Currently generated code */ + }; + + /** State of the DTMF generator */ + DTMFState state; + + /** The different kind of tones */ + static const DTMFTone tones[NUM_TONES]; + + /** Generated samples */ + SFLDataFormat* samples[NUM_TONES]; + + /** Sampling rate of generated dtmf */ + int _sampleRate; + + /** A tone object */ + Tone tone; + + public: + /** + * DTMF Generator contains frequency of each keys + * and can build one DTMF. + * @param sampleRate frequency of the sample (ex: 8000 hz) + */ + DTMFGenerator (unsigned int sampleRate); + + /** + * Destructor + */ + ~DTMFGenerator(); + + + // Copy Constructor + DTMFGenerator (const DTMFGenerator& rh); + + // Assignment Operator + DTMFGenerator& operator= (const DTMFGenerator& rh); + + /* + * Get n samples of the signal of code code + * @param buffer a SFLDataFormat pointer to an allocated buffer + * @param n number of sampling to get, should be lower or equal to buffer size + * @param code dtmf code to get sound + */ + void getSamples (SFLDataFormat* buffer, size_t n, unsigned char code) throw (DTMFException); + + /* + * Get next n samples (continues where previous call to + * genSample or genNextSamples stopped + * @param buffer a SFLDataFormat pointer to an allocated buffer + * @param n number of sampling to get, should be lower or equal to buffer size + */ + void getNextSamples (SFLDataFormat* buffer, size_t n) throw (DTMFException); + + private: + + /** + * Generate samples for a specific dtmf code + * @param code The code + * @return SFLDataFormat* The generated data + */ + SFLDataFormat* generateSample (unsigned char code) throw (DTMFException); }; #endif // DTMFGENERATOR_H diff --git a/sflphone-common/src/audio/sound/tone.h b/sflphone-common/src/audio/sound/tone.h index cc813603c7df5f8eba10a2203137e6d86bc40e4e..8ce8359774a36477412ae218d2eb7d959139ea3f 100644 --- a/sflphone-common/src/audio/sound/tone.h +++ b/sflphone-common/src/audio/sound/tone.h @@ -2,9 +2,9 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * - * Inspired by tonegenerator of + * Inspired by tonegenerator of * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -45,65 +45,66 @@ * @file tone.h * @brief Tone sample (dial, busy, ring, congestion) */ -class Tone : public AudioLoop { -public: - /** - * Constructor - * @param definition String that contain frequency/time of the tone - * @param sampleRate SampleRating of audio tone - */ - Tone(const std::string& definition, unsigned int sampleRate); - - /** - * Destructor - */ - ~Tone(); - - /** The different kind of tones */ - enum TONEID { - TONE_DIALTONE = 0, - TONE_BUSY, - TONE_RINGTONE, - TONE_CONGESTION, - TONE_NULL - }; - - /** - * Add a simple or double sin to the buffer, it double the sin in stereo - * @param buffer The data - * @param frequency1 The first frequency - * @param frequency2 The second frequency - * @param nb are the number of int16 (mono) to generate - * by example nb=5 generate 10 int16, 5 for the left, 5 for the right - */ - void genSin(SFLDataFormat* buffer, int frequency1, int frequency2, int nb); - - /** - * - */ - void fillWavetable(void); - - /** - * - */ - double interpolate(double x); - - -private: - - /** - * allocate the memory with the definition - * @param definition String that contain frequency/time of the tone. - */ - void genBuffer(const std::string& definition); - - /** Sample rate */ - unsigned int _sampleRate; - - double _wavetable[TABLE_LENGTH]; - - double _xhigher; - double _xlower; +class Tone : public AudioLoop +{ + public: + /** + * Constructor + * @param definition String that contain frequency/time of the tone + * @param sampleRate SampleRating of audio tone + */ + Tone (const std::string& definition, unsigned int sampleRate); + + /** + * Destructor + */ + ~Tone(); + + /** The different kind of tones */ + enum TONEID { + TONE_DIALTONE = 0, + TONE_BUSY, + TONE_RINGTONE, + TONE_CONGESTION, + TONE_NULL + }; + + /** + * Add a simple or double sin to the buffer, it double the sin in stereo + * @param buffer The data + * @param frequency1 The first frequency + * @param frequency2 The second frequency + * @param nb are the number of int16 (mono) to generate + * by example nb=5 generate 10 int16, 5 for the left, 5 for the right + */ + void genSin (SFLDataFormat* buffer, int frequency1, int frequency2, int nb); + + /** + * + */ + void fillWavetable (void); + + /** + * + */ + double interpolate (double x); + + + private: + + /** + * allocate the memory with the definition + * @param definition String that contain frequency/time of the tone. + */ + void genBuffer (const std::string& definition); + + /** Sample rate */ + unsigned int _sampleRate; + + double _wavetable[TABLE_LENGTH]; + + double _xhigher; + double _xlower; }; #endif // __TONE_H__ diff --git a/sflphone-common/src/audio/sound/tonelist.h b/sflphone-common/src/audio/sound/tonelist.h index 41c9e5f48c38c26995b701f3f84d2642e3d6dfbc..210a74c7938e821bd5cbc99ddaf5966d3a646814 100644 --- a/sflphone-common/src/audio/sound/tonelist.h +++ b/sflphone-common/src/audio/sound/tonelist.h @@ -2,9 +2,9 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * - * Inspired by tonegenerator of + * Inspired by tonegenerator of * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -40,98 +40,102 @@ * @file tonelist.h * @brief Manages the different kind of tones according to the country */ -class ToneList { -public: - /** - * Constructor - */ - ToneList(); - - /** - * Destructor - */ - ~ToneList(); - - - /** Countries */ - enum COUNTRYID { - ZID_NORTH_AMERICA = 0, - ZID_FRANCE, - ZID_AUSTRALIA, - ZID_UNITED_KINGDOM, - ZID_SPAIN, - ZID_ITALY, - ZID_JAPAN - }; - - /** - * Get the string definition of a tone - * return the default country or default tone if id are invalid - * @param countryId The country Id, see ToneList constructor for the list - * @param toneId The toneId - * @return std::string A string definition of the tone - */ - std::string getDefinition(COUNTRYID countryId, Tone::TONEID toneId); - - /** - * Get the country id associate to a country name - * return the default country id if not found - * The default tone/country are set inside the ToneList constructor - * @param countryName countryName, see the ToneList constructor list - * @return COUNTRYID Country Id or default Id - */ - COUNTRYID getCountryId(const std::string& countryName); - - /** @return int The number of tones */ - int getNbTone() { return _nbTone; } - -private: - - // Copy Constructor - ToneList(const ToneList& rh); - - // Assignment Operator - ToneList& operator=( const ToneList& rh); - - void initToneDefinition(); - std::string _toneZone[TONE_NBCOUNTRY][TONE_NBTONE]; - int _nbTone; - int _nbCountry; - COUNTRYID _defaultCountryId; +class ToneList +{ + public: + /** + * Constructor + */ + ToneList(); + + /** + * Destructor + */ + ~ToneList(); + + + /** Countries */ + enum COUNTRYID { + ZID_NORTH_AMERICA = 0, + ZID_FRANCE, + ZID_AUSTRALIA, + ZID_UNITED_KINGDOM, + ZID_SPAIN, + ZID_ITALY, + ZID_JAPAN + }; + + /** + * Get the string definition of a tone + * return the default country or default tone if id are invalid + * @param countryId The country Id, see ToneList constructor for the list + * @param toneId The toneId + * @return std::string A string definition of the tone + */ + std::string getDefinition (COUNTRYID countryId, Tone::TONEID toneId); + + /** + * Get the country id associate to a country name + * return the default country id if not found + * The default tone/country are set inside the ToneList constructor + * @param countryName countryName, see the ToneList constructor list + * @return COUNTRYID Country Id or default Id + */ + COUNTRYID getCountryId (const std::string& countryName); + + /** @return int The number of tones */ + int getNbTone() { + return _nbTone; + } + + private: + + // Copy Constructor + ToneList (const ToneList& rh); + + // Assignment Operator + ToneList& operator= (const ToneList& rh); + + void initToneDefinition(); + std::string _toneZone[TONE_NBCOUNTRY][TONE_NBTONE]; + int _nbTone; + int _nbCountry; + COUNTRYID _defaultCountryId; }; /** * @author Yan Morin <yan.morin@savoirfairelinux.com> */ -class TelephoneTone { -public: - /** Initialize the toneList and set the current tone to null */ - TelephoneTone(const std::string& countryName, unsigned int sampleRate); - ~TelephoneTone(); - - - /** send TONE::ZT_TONE_NULL to stop the playing */ - void setCurrentTone(Tone::TONEID toneId); - - /** - * @return the currentTone after setting it with setCurrentTone - * 0 if the current tone is null - */ - Tone* getCurrentTone(); - - /** @return true if you should play the tone (CurrentTone is not NULL) */ - bool shouldPlay(); - -private: - // Copy Constructor - TelephoneTone(const TelephoneTone& rh); - - // Assignment Operator - TelephoneTone& operator=( const TelephoneTone& rh); - - Tone* _tone[TONE_NBTONE]; - Tone::TONEID _currentTone; - ToneList _toneList; +class TelephoneTone +{ + public: + /** Initialize the toneList and set the current tone to null */ + TelephoneTone (const std::string& countryName, unsigned int sampleRate); + ~TelephoneTone(); + + + /** send TONE::ZT_TONE_NULL to stop the playing */ + void setCurrentTone (Tone::TONEID toneId); + + /** + * @return the currentTone after setting it with setCurrentTone + * 0 if the current tone is null + */ + Tone* getCurrentTone(); + + /** @return true if you should play the tone (CurrentTone is not NULL) */ + bool shouldPlay(); + + private: + // Copy Constructor + TelephoneTone (const TelephoneTone& rh); + + // Assignment Operator + TelephoneTone& operator= (const TelephoneTone& rh); + + Tone* _tone[TONE_NBTONE]; + Tone::TONEID _currentTone; + ToneList _toneList; }; #endif diff --git a/sflphone-common/src/audio/speexechocancel.cpp b/sflphone-common/src/audio/speexechocancel.cpp index 40017ed7bc728ab6a8664ebb81191fe903bebd2d..a85a4caccbefae407483d480746b72202beef973 100644 --- a/sflphone-common/src/audio/speexechocancel.cpp +++ b/sflphone-common/src/audio/speexechocancel.cpp @@ -100,7 +100,7 @@ void SpeexEchoCancel::putData (SFLDataFormat *inputData, int nbBytes) // speex_echo_playback(_echoState, inputData); } -void SpeexEchoCancel::process (SFLDataFormat *data, int nbBytes) {} +void SpeexEchoCancel::process (SFLDataFormat *data UNUSED, int nbBytes UNUSED) {} int SpeexEchoCancel::process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) { @@ -158,10 +158,7 @@ int SpeexEchoCancel::process (SFLDataFormat *inputData, SFLDataFormat *outputDat return nbFrame * FRAME_SIZE; } -void SpeexEchoCancel::process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) +void SpeexEchoCancel::process (SFLDataFormat *micData UNUSED, SFLDataFormat *spkrData UNUSED, SFLDataFormat *outputData UNUSED, int nbBytes UNUSED) { - - // speex_echo_cancellation(_echoState, micData, spkrData, outputData); - } diff --git a/sflphone-common/src/audio/speexechocancel.h b/sflphone-common/src/audio/speexechocancel.h index 45628e14af81c7eecf9fb8b66f92bbf03f897060..fd37cf2ae177360443d8bafafc3f6e5669ab4bb1 100644 --- a/sflphone-common/src/audio/speexechocancel.h +++ b/sflphone-common/src/audio/speexechocancel.h @@ -26,60 +26,61 @@ #include "ringbuffer.h" -class SpeexEchoCancel : public Algorithm { +class SpeexEchoCancel : public Algorithm +{ - public: + public: - SpeexEchoCancel(); + SpeexEchoCancel(); - ~SpeexEchoCancel(); + ~SpeexEchoCancel(); - virtual void reset(void); + virtual void reset (void); - /** - * Add speaker data into internal buffer - * \param inputData containing far-end voice data to be sent to speakers - */ - virtual void putData(SFLDataFormat *inputData, int nbBytes); + /** + * Add speaker data into internal buffer + * \param inputData containing far-end voice data to be sent to speakers + */ + virtual void putData (SFLDataFormat *inputData, int nbBytes); - /** - * Unused - */ - virtual void process(SFLDataFormat *data, int nbBytes); + /** + * Unused + */ + virtual void process (SFLDataFormat *data, int nbBytes); - /** - * Perform echo cancellation using internal buffers - * \param inputData containing mixed echo and voice data - * \param outputData containing - */ - virtual int process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); + /** + * Perform echo cancellation using internal buffers + * \param inputData containing mixed echo and voice data + * \param outputData containing + */ + virtual int process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes); - /** - * Perform echo cancellation, application must provide its own buffer - * \param micData containing mixed echo and voice data - * \param spkrData containing far-end voice data to be sent to speakers - * \param outputData containing the processed data - */ - virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); + /** + * Perform echo cancellation, application must provide its own buffer + * \param micData containing mixed echo and voice data + * \param spkrData containing far-end voice data to be sent to speakers + * \param outputData containing the processed data + */ + virtual void process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes); - private: + private: - SpeexEchoState *_echoState; + SpeexEchoState *_echoState; - SpeexPreprocessState *_preState; + SpeexPreprocessState *_preState; - RingBuffer *_micData; - RingBuffer *_spkrData; + RingBuffer *_micData; + RingBuffer *_spkrData; - bool _spkrStoped; + bool _spkrStoped; - SFLDataFormat _tmpSpkr[5000]; - SFLDataFormat _tmpMic[5000]; - SFLDataFormat _tmpOut[5000]; + SFLDataFormat _tmpSpkr[5000]; + SFLDataFormat _tmpMic[5000]; + SFLDataFormat _tmpOut[5000]; - ofstream *micFile; - ofstream *spkrFile; - ofstream *echoFile; + ofstream *micFile; + ofstream *spkrFile; + ofstream *echoFile; }; #endif diff --git a/sflphone-common/src/call.h b/sflphone-common/src/call.h index 713f23e5609637c9c292c84e7a6d7c453dea1da7..f7fb935f167d4320fdc703c729bd3fcb67bc3a52 100644 --- a/sflphone-common/src/call.h +++ b/sflphone-common/src/call.h @@ -42,14 +42,15 @@ #define CallConfigNULL NULL -/* - * @file call.h +/* + * @file call.h * @brief A call is the base class for protocol-based calls */ typedef std::string CallID; -class Call: public Recordable{ +class Call: public Recordable +{ public: /** @@ -83,84 +84,103 @@ class Call: public Recordable{ * @param id Unique identifier of the call * @param type set definitely this call as incoming/outgoing */ - Call(const CallID& id, Call::CallType type); + Call (const CallID& id, Call::CallType type); virtual ~Call(); - /** + /** * Return a reference on the call id * @return call id */ - CallID& getCallId() {return _id; } + CallID& getCallId() { + return _id; + } - /** - * Return a reference on the conference id - * @return call id - */ - CallID& getConfId() {return _confID; } + /** + * Return a reference on the conference id + * @return call id + */ + CallID& getConfId() { + return _confID; + } - void setConfId(CallID id) {_confID = id; } + void setConfId (CallID id) { + _confID = id; + } - inline CallType getCallType (void) - { + inline CallType getCallType (void) { return _type; } - /** + /** * Set the peer number (destination on outgoing) * not protected by mutex (when created) * @param number peer number */ - void setPeerNumber(const std::string& number) { _peerNumber = number; } + void setPeerNumber (const std::string& number) { + _peerNumber = number; + } - /** + /** * Get the peer number (destination on outgoing) * not protected by mutex (when created) * @return std::string The peer number */ - const std::string& getPeerNumber() { return _peerNumber; } + const std::string& getPeerNumber() { + return _peerNumber; + } - /** + /** * Set the peer name (caller in ingoing) * not protected by mutex (when created) * @param name The peer name */ - void setPeerName(const std::string& name) { _peerName = name; } + void setPeerName (const std::string& name) { + _peerName = name; + } - /** + /** * Get the peer name (caller in ingoing) * not protected by mutex (when created) * @return std::string The peer name */ - const std::string& getPeerName() { return _peerName; } + const std::string& getPeerName() { + return _peerName; + } - /** - * Set the display name (caller in ingoing) - * not protected by mutex (when created) - * @return std::string The peer display name - */ - void setDisplayName(const std::string& name) { _displayName = name; } + /** + * Set the display name (caller in ingoing) + * not protected by mutex (when created) + * @return std::string The peer display name + */ + void setDisplayName (const std::string& name) { + _displayName = name; + } - /** - * Get the peer display name (caller in ingoing) - * not protected by mutex (when created) - * @return std::string The peer name - */ - const std::string& getDisplayName() { return _displayName; } + /** + * Get the peer display name (caller in ingoing) + * not protected by mutex (when created) + * @return std::string The peer name + */ + const std::string& getDisplayName() { + return _displayName; + } /** * Tell if the call is incoming * @return true if yes * false otherwise */ - bool isIncoming() { return (_type == Incoming) ? true : false; } + bool isIncoming() { + return (_type == Incoming) ? true : false; + } - /** + /** * Set the connection state of the call (protected by mutex) * @param state The connection state */ - void setConnectionState(ConnectionState state); + void setConnectionState (ConnectionState state); - /** + /** * Get the connection state of the call (protected by mutex) * @return ConnectionState The connection state */ @@ -170,26 +190,30 @@ class Call: public Recordable{ * Set the state of the call (protected by mutex) * @param state The call state */ - void setState(CallState state); + void setState (CallState state); - /** + /** * Get the call state of the call (protected by mutex) * @return CallState The call state */ CallState getState(); - + std::string getStateStr (); - void setCallConfiguration (Call::CallConfiguration callConfig) { _callConfig = callConfig; } - - Call::CallConfiguration getCallConfiguration (void) { return _callConfig; } - + void setCallConfiguration (Call::CallConfiguration callConfig) { + _callConfig = callConfig; + } + + Call::CallConfiguration getCallConfiguration (void) { + return _callConfig; + } + /** * Set the audio start boolean (protected by mutex) * @param start true if we start the audio * false otherwise */ - void setAudioStart(bool start); + void setAudioStart (bool start); /** * Tell if the audio is started (protected by mutex) @@ -198,47 +222,59 @@ class Call: public Recordable{ */ bool isAudioStarted(); - /** - * Set my IP [not protected] + /** + * Set my IP [not protected] * @param ip The local IP address */ - void setLocalIp(const std::string& ip) { _localIPAddress = ip; } + void setLocalIp (const std::string& ip) { + _localIPAddress = ip; + } - /** + /** * Set local audio port, as seen by me [not protected] * @param port The local audio port */ - void setLocalAudioPort(unsigned int port) { _localAudioPort = port;} + void setLocalAudioPort (unsigned int port) { + _localAudioPort = port; + } - /** + /** * Set the audio port that remote will see. * @param port The external audio port */ - void setLocalExternAudioPort(unsigned int port) { _localExternalAudioPort = port; } + void setLocalExternAudioPort (unsigned int port) { + _localExternalAudioPort = port; + } - /** - * Return the audio port seen by the remote side. + /** + * Return the audio port seen by the remote side. * @return unsigned int The external audio port */ - unsigned int getLocalExternAudioPort() { return _localExternalAudioPort; } + unsigned int getLocalExternAudioPort() { + return _localExternalAudioPort; + } - /** - * Return my IP [mutex protected] + /** + * Return my IP [mutex protected] * @return std::string The local IP */ const std::string& getLocalIp(); - /** - * Return port used locally (for my machine) [mutex protected] + /** + * Return port used locally (for my machine) [mutex protected] * @return unsigned int The local audio port */ unsigned int getLocalAudioPort(); - std::string getRecFileId(void){ return getPeerName(); } + std::string getRecFileId (void) { + return getPeerName(); + } - std::string getFileName(void) { return _filename; } + std::string getFileName (void) { + return _filename; + } - virtual bool setRecording(void); + virtual bool setRecording (void); protected: /** Protect every attribute that can be changed by two threads */ @@ -258,13 +294,13 @@ class Call: public Recordable{ unsigned int _localExternalAudioPort; - private: + private: /** Unique ID of the call */ CallID _id; - /** Unique conference ID, used exclusively in case of a conferece */ - CallID _confID; + /** Unique conference ID, used exclusively in case of a conferece */ + CallID _confID; /** Type of the call */ CallType _type; @@ -284,13 +320,13 @@ class Call: public Recordable{ /** Number of the peer */ std::string _peerNumber; - /** Display Name */ - std::string _displayName; + /** Display Name */ + std::string _displayName; - /** File name for his call : time YY-MM-DD */ + /** File name for his call : time YY-MM-DD */ std::string _filename; - + }; #endif diff --git a/sflphone-common/src/conference.h b/sflphone-common/src/conference.h index 77952531d1a7b979e6bcfb9c1d7e1a99c59d21b2..532c0abfcdb476b715819495b955d48c06729b0f 100644 --- a/sflphone-common/src/conference.h +++ b/sflphone-common/src/conference.h @@ -43,46 +43,53 @@ typedef std::string ConfID; typedef std::set<CallID> ParticipantSet; -class Conference: public Recordable{ +class Conference: public Recordable +{ public: enum ConferenceState {Active_Atached, Active_Detached, Hold}; - static int count; + static int count; Conference(); ~Conference(); - std::string getConfID() { return _id; } + std::string getConfID() { + return _id; + } - int getState(); + int getState(); - void setState(ConferenceState state); + void setState (ConferenceState state); - std::string getStateStr(); + std::string getStateStr(); - int getNbParticipants() { return _nbParticipant; } + int getNbParticipants() { + return _nbParticipant; + } - void add(CallID participant_id); + void add (CallID participant_id); - void remove(CallID participant_id); + void remove (CallID participant_id); - void bindParticipant(CallID participant_id); + void bindParticipant (CallID participant_id); - ParticipantSet getParticipantList(); + ParticipantSet getParticipantList(); - std::string getRecFileId(){ return getConfID(); } + std::string getRecFileId() { + return getConfID(); + } - virtual bool setRecording(); + virtual bool setRecording(); - private: + private: /** Unique ID of the conference */ CallID _id; - ConferenceState _confState; + ConferenceState _confState; ParticipantSet _participants; diff --git a/sflphone-common/src/config/engine.h b/sflphone-common/src/config/engine.h old mode 100755 new mode 100644 index c2345b656e73cca9c4af7258fbd6779d2a185dce..c9c140a46e65e6efb37a5caa280d8b251f9f225e --- a/sflphone-common/src/config/engine.h +++ b/sflphone-common/src/config/engine.h @@ -33,17 +33,18 @@ #include <yaml.h> -class Engine { +class Engine +{ - public: + public: - virtual void open() = 0; + virtual void open() = 0; - virtual void close() = 0; + virtual void close() = 0; - virtual void write() = 0; + virtual void write() = 0; - virtual void read() = 0; + virtual void read() = 0; }; diff --git a/sflphone-common/src/config/serializable.h b/sflphone-common/src/config/serializable.h old mode 100755 new mode 100644 index e9b88cc84c1059c1a917b0f86b971a6bcc401ab9..bc37cb24c3a705f21afcc881168bb8926f036e9b --- a/sflphone-common/src/config/serializable.h +++ b/sflphone-common/src/config/serializable.h @@ -39,15 +39,16 @@ class Engine; // class MappingNode; -class Serializable { +class Serializable +{ - public: + public: - virtual void serialize(Conf::YamlEmitter *emitter) = 0; + virtual void serialize (Conf::YamlEmitter *emitter) = 0; - virtual void unserialize(Conf::MappingNode *map) = 0; + virtual void unserialize (Conf::MappingNode *map) = 0; - private: + private: }; diff --git a/sflphone-common/src/config/yamlemitter.h b/sflphone-common/src/config/yamlemitter.h old mode 100755 new mode 100644 index e490b5fadfb649226ff3a285a80b4a55ee6746f1..e2e25a072444e1149303a0802069bced68f92ed7 --- a/sflphone-common/src/config/yamlemitter.h +++ b/sflphone-common/src/config/yamlemitter.h @@ -36,112 +36,114 @@ #include <string> #include "yamlnode.h" -namespace Conf { +namespace Conf +{ #define EMITTER_BUFFERSIZE 65536 #define EMITTER_MAXEVENT 1024 -class YamlEmitterException : public std::exception +class YamlEmitterException : public std::exception { - public: - YamlEmitterException(const std::string& str="") throw() : errstr(str) {} + public: + YamlEmitterException (const std::string& str="") throw() : errstr (str) {} + + virtual ~YamlEmitterException() throw() {} - virtual ~YamlEmitterException() throw() {} + virtual const char *what() const throw() { + std::string expt ("YamlParserException occured: "); + expt.append (errstr); - virtual const char *what() const throw() { - std::string expt("YamlParserException occured: "); - expt.append(errstr); - - return expt.c_str(); - } - private: - std::string errstr; + return expt.c_str(); + } + private: + std::string errstr; }; -class YamlEmitter { +class YamlEmitter +{ - public: + public: - YamlEmitter(const char *file); + YamlEmitter (const char *file); - ~YamlEmitter(); + ~YamlEmitter(); - void open(); + void open(); - void close(); + void close(); - void read(); + void read(); - void write(); + void write(); - void serializeAccount(MappingNode *map); + void serializeAccount (MappingNode *map); - void serializePreference(MappingNode *map); + void serializePreference (MappingNode *map); - void serializeVoipPreference(MappingNode *map); + void serializeVoipPreference (MappingNode *map); - void serializeAddressbookPreference(MappingNode *map); + void serializeAddressbookPreference (MappingNode *map); - void serializeHooksPreference(MappingNode *map); + void serializeHooksPreference (MappingNode *map); - void serializeAudioPreference(MappingNode *map); + void serializeAudioPreference (MappingNode *map); - void serializeShortcutPreference(MappingNode *map); + void serializeShortcutPreference (MappingNode *map); - void writeAudio(); + void writeAudio(); - void writeHooks(); + void writeHooks(); - void writeVoiplink(); + void writeVoiplink(); - void serializeData(); + void serializeData(); - private: + private: - void addMappingItem(int mappingid, Key key, YamlNode *node); + void addMappingItem (int mappingid, Key key, YamlNode *node); - std::string filename; + std::string filename; - FILE *fd; + FILE *fd; - /** - * The parser structure. - */ - yaml_emitter_t emitter; + /** + * The parser structure. + */ + yaml_emitter_t emitter; - /** - * The event structure array. - */ - yaml_event_t events[EMITTER_MAXEVENT]; + /** + * The event structure array. + */ + yaml_event_t events[EMITTER_MAXEVENT]; - /** - * - */ - unsigned char buffer[EMITTER_BUFFERSIZE]; + /** + * + */ + unsigned char buffer[EMITTER_BUFFERSIZE]; - /** - * Main document for this serialization - */ - yaml_document_t document; + /** + * Main document for this serialization + */ + yaml_document_t document; - /** - * Reference id to the top levell mapping when creating - */ - int topLevelMapping; + /** + * Reference id to the top levell mapping when creating + */ + int topLevelMapping; - /** - * We need to add the account sequence if this is the first account to be - */ - bool isFirstAccount; + /** + * We need to add the account sequence if this is the first account to be + */ + bool isFirstAccount; - /** - * Reference to the account sequence - */ - int accountSequence; + /** + * Reference to the account sequence + */ + int accountSequence; - friend class ConfigurationTest; + friend class ConfigurationTest; }; diff --git a/sflphone-common/src/config/yamlengine.cpp b/sflphone-common/src/config/yamlengine.cpp index e38c64c378f0cef24a72f0acf6dc0a83a483e436..9e2aa30dafb21e370c9179012f994eb555875a07 100644 --- a/sflphone-common/src/config/yamlengine.cpp +++ b/sflphone-common/src/config/yamlengine.cpp @@ -42,7 +42,7 @@ YamlEngine::~YamlEngine() {} void YamlEngine::openConfigFile() { - Conf::YamlParser *parser; + Conf::YamlParser *parser = NULL; try { parser = new Conf::YamlParser ("sequence.yml"); diff --git a/sflphone-common/src/config/yamlengine.h b/sflphone-common/src/config/yamlengine.h old mode 100755 new mode 100644 index 2997760bc2d96da4066c71e491e05f15ea083751..fcf9cd849b37e11bfe6334c7a61fd6d86728efbc --- a/sflphone-common/src/config/yamlengine.h +++ b/sflphone-common/src/config/yamlengine.h @@ -37,38 +37,41 @@ #include "yamlemitter.h" #include <exception> -namespace Conf { +namespace Conf +{ -class YamlEngineException : public std::exception { +class YamlEngineException : public std::exception +{ - virtual const char *what() const throw() { - return "YamlEngineException occured"; - } -}; + virtual const char *what() const throw() { + return "YamlEngineException occured"; + } +}; -class YamlEngine : public Engine { +class YamlEngine : public Engine +{ - public: + public: - YamlEngine(); + YamlEngine(); - ~YamlEngine(); + ~YamlEngine(); - virtual void openConfigFile(); + virtual void openConfigFile(); - virtual void closeConfigFile(); + virtual void closeConfigFile(); - virtual void write(); + virtual void write(); - virtual void read(); + virtual void read(); - private: + private: - YamlParser *parser; + YamlParser *parser; - YamlEmitter *emitter; + YamlEmitter *emitter; - YamlDocument *document; + YamlDocument *document; }; diff --git a/sflphone-common/src/config/yamlnode.h b/sflphone-common/src/config/yamlnode.h old mode 100755 new mode 100644 index e341b355038910426e5a47d1c9569582178d3563..ec2de80237669560dcafa065f658d2aa91b82400 --- a/sflphone-common/src/config/yamlnode.h +++ b/sflphone-common/src/config/yamlnode.h @@ -36,7 +36,8 @@ #include <map> #include <exception> -namespace Conf { +namespace Conf +{ class YamlNode; @@ -49,128 +50,149 @@ typedef std::map<Key, YamlNode *> Mapping; class YamlNodeException : public std::exception { - public: - YamlNodeException(const std::string& str="") throw() : errstr(str) {} + public: + YamlNodeException (const std::string& str="") throw() : errstr (str) {} - virtual ~YamlNodeException() throw() {} + virtual ~YamlNodeException() throw() {} - virtual const char *what() const throw() { - std::string expt("YamlNodeException occured: "); - expt.append(errstr); + virtual const char *what() const throw() { + std::string expt ("YamlNodeException occured: "); + expt.append (errstr); - return expt.c_str(); - } - private: - std::string errstr; + return expt.c_str(); + } + private: + std::string errstr; }; enum NodeType { DOCUMENT, SCALAR, MAPPING, SEQUENCE }; -class YamlNode { - - public: +class YamlNode +{ + + public: - YamlNode(NodeType t, YamlNode *top=NULL) : type(t), topNode(top) {} + YamlNode (NodeType t, YamlNode *top=NULL) : type (t), topNode (top) {} - ~YamlNode() {} + ~YamlNode() {} - NodeType getType() { return type; } + NodeType getType() { + return type; + } - YamlNode *getTopNode() { return topNode; } + YamlNode *getTopNode() { + return topNode; + } - private: + private: - NodeType type; + NodeType type; - YamlNode *topNode; + YamlNode *topNode; }; -class YamlDocument : YamlNode { +class YamlDocument : YamlNode +{ - public: + public: - YamlDocument(YamlNode* top=NULL) : YamlNode(DOCUMENT, top) {} + YamlDocument (YamlNode* top=NULL) : YamlNode (DOCUMENT, top) {} - ~YamlDocument() {} + ~YamlDocument() {} - void addNode(YamlNode *node); + void addNode (YamlNode *node); - YamlNode *popNode(void); + YamlNode *popNode (void); - Sequence *getSequence(void) { return &doc; } + Sequence *getSequence (void) { + return &doc; + } - private: + private: - Sequence doc; + Sequence doc; - }; +}; -class SequenceNode : public YamlNode { +class SequenceNode : public YamlNode +{ - public: + public: - SequenceNode(YamlNode *top) : YamlNode(SEQUENCE, top) {} + SequenceNode (YamlNode *top) : YamlNode (SEQUENCE, top) {} - ~SequenceNode() {} + ~SequenceNode() {} - Sequence *getSequence() { return &seq; } + Sequence *getSequence() { + return &seq; + } - void addNode(YamlNode *node); + void addNode (YamlNode *node); - private: + private: - Sequence seq; + Sequence seq; }; -class MappingNode : public YamlNode { +class MappingNode : public YamlNode +{ - public: + public: - MappingNode(YamlNode *top) : YamlNode(MAPPING, top) {} + MappingNode (YamlNode *top) : YamlNode (MAPPING, top) {} - ~MappingNode() {} + ~MappingNode() {} - Mapping *getMapping() { return ↦ } + Mapping *getMapping() { + return ↦ + } - void addNode(YamlNode *node); + void addNode (YamlNode *node); - void setTmpKey(Key key) { tmpKey = key; } + void setTmpKey (Key key) { + tmpKey = key; + } - void setKeyValue(Key key, YamlNode *value); + void setKeyValue (Key key, YamlNode *value); - void removeKeyValue(Key key); + void removeKeyValue (Key key); - YamlNode *getValue(Key key); + YamlNode *getValue (Key key); - private: + private: - Mapping map; + Mapping map; - Key tmpKey; + Key tmpKey; }; -class ScalarNode : public YamlNode { +class ScalarNode : public YamlNode +{ - public: + public: - ScalarNode(Value v="", YamlNode *top=NULL) : YamlNode(SCALAR, top), val(v) {} + ScalarNode (Value v="", YamlNode *top=NULL) : YamlNode (SCALAR, top), val (v) {} - ~ScalarNode() {} + ~ScalarNode() {} - Value getValue() { return val; } + Value getValue() { + return val; + } - void setValue(Value v) { val = v; } + void setValue (Value v) { + val = v; + } - private: + private: - Value val; + Value val; }; diff --git a/sflphone-common/src/config/yamlparser.h b/sflphone-common/src/config/yamlparser.h index 54ef7a9e86b3b47ed100d6dcb81e6fe3835a86fa..58c92826b926e903a8ffa5fd2ce9811fba229b73 100644 --- a/sflphone-common/src/config/yamlparser.h +++ b/sflphone-common/src/config/yamlparser.h @@ -37,123 +37,139 @@ #include <exception> #include <string> -namespace Conf { +namespace Conf +{ #define PARSER_BUFFERSIZE 65536 #define PARSER_MAXEVENT 1024 class YamlParserException : public std::exception { - public: - YamlParserException(const std::string& str="") throw() : errstr(str) {} - - virtual ~YamlParserException() throw() {} - - virtual const char *what() const throw() { - std::string expt("YamlParserException occured: "); - expt.append(errstr); - - return expt.c_str(); - } - private: - std::string errstr; + public: + YamlParserException (const std::string& str="") throw() : errstr (str) {} + + virtual ~YamlParserException() throw() {} + + virtual const char *what() const throw() { + std::string expt ("YamlParserException occured: "); + expt.append (errstr); + + return expt.c_str(); + } + private: + std::string errstr; }; -class YamlParser { +class YamlParser +{ - public: + public: - YamlParser(const char *file); + YamlParser (const char *file); - ~YamlParser(); + ~YamlParser(); - void open(); + void open(); - void close(); + void close(); - void serializeEvents(); + void serializeEvents(); - YamlDocument *composeEvents(); + YamlDocument *composeEvents(); - void constructNativeData(); + void constructNativeData(); - SequenceNode *getAccountSequence(void) { return accountSequence; }; + SequenceNode *getAccountSequence (void) { + return accountSequence; + }; - SequenceNode *getPreferenceSequence(void) { return preferenceSequence; } + SequenceNode *getPreferenceSequence (void) { + return preferenceSequence; + } - SequenceNode *getAddressbookSequence(void) { return addressbookSequence; } + SequenceNode *getAddressbookSequence (void) { + return addressbookSequence; + } - SequenceNode *getAudioSequence(void) { return audioSequence; } + SequenceNode *getAudioSequence (void) { + return audioSequence; + } - SequenceNode *getHookSequence(void) { return hooksSequence; } + SequenceNode *getHookSequence (void) { + return hooksSequence; + } - SequenceNode *getVoipPreferenceSequence(void) { return voiplinkSequence; } + SequenceNode *getVoipPreferenceSequence (void) { + return voiplinkSequence; + } - SequenceNode *getShortcutSequence(void) { return shortcutSequence; } + SequenceNode *getShortcutSequence (void) { + return shortcutSequence; + } - private: + private: - /** - * Copy yaml parser event in event_to according to their type. - */ - int copyEvent(yaml_event_t *event_to, yaml_event_t *event_from); + /** + * Copy yaml parser event in event_to according to their type. + */ + int copyEvent (yaml_event_t *event_to, yaml_event_t *event_from); - void processStream(void); + void processStream (void); - void processDocument(void); + void processDocument (void); - void processScalar(YamlNode *topNode); + void processScalar (YamlNode *topNode); - void processSequence(YamlNode *topNode); + void processSequence (YamlNode *topNode); - void processMapping(YamlNode *topNode); + void processMapping (YamlNode *topNode); - void mainNativeDataMapping(MappingNode *map); + void mainNativeDataMapping (MappingNode *map); - // void buildAccounts(SequenceNode *map); + // void buildAccounts(SequenceNode *map); - std::string filename; + std::string filename; - FILE *fd; + FILE *fd; - /** - * The parser structure. - */ - yaml_parser_t parser; + /** + * The parser structure. + */ + yaml_parser_t parser; - /** - * The event structure array. - */ - yaml_event_t events[PARSER_MAXEVENT]; + /** + * The event structure array. + */ + yaml_event_t events[PARSER_MAXEVENT]; - /** - * - */ - unsigned char buffer[PARSER_BUFFERSIZE]; + /** + * + */ + unsigned char buffer[PARSER_BUFFERSIZE]; - /** - * Number of event actually parsed - */ - int eventNumber; + /** + * Number of event actually parsed + */ + int eventNumber; - YamlDocument *doc; + YamlDocument *doc; - int eventIndex; + int eventIndex; - SequenceNode *accountSequence; + SequenceNode *accountSequence; - SequenceNode *preferenceSequence; + SequenceNode *preferenceSequence; - SequenceNode *addressbookSequence; + SequenceNode *addressbookSequence; - SequenceNode *audioSequence; + SequenceNode *audioSequence; - SequenceNode *hooksSequence; + SequenceNode *hooksSequence; - SequenceNode *voiplinkSequence; + SequenceNode *voiplinkSequence; - SequenceNode *shortcutSequence; + SequenceNode *shortcutSequence; }; diff --git a/sflphone-common/src/dbus/callmanager.h b/sflphone-common/src/dbus/callmanager.h index 950d12a98a2ae67f6b16bf401dcf4f38ee0494ee..89b84b8eb4848dd58af4b38351dd1c88f0ec24ae 100644 --- a/sflphone-common/src/dbus/callmanager.h +++ b/sflphone-common/src/dbus/callmanager.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,35 +27,39 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef __SFL_CALLMANAGER_H__ #define __SFL_CALLMANAGER_H__ +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "callmanager-glue.h" +#pragma GCC diagnostic warning "-Wignored-qualifiers" +#pragma GCC diagnostic warning "-Wunused-parameter" #include <dbus-c++/dbus.h> #include <exception> class CallManagerException: public std::exception { - virtual const char* what() const throw() - { - return "A CallManagerException occured"; - } + virtual const char* what() const throw() { + return "A CallManagerException occured"; + } }; -namespace sfl { - class AudioZrtpSession; +namespace sfl +{ +class AudioZrtpSession; } class CallManager -: public org::sflphone::SFLphone::CallManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor + : public org::sflphone::SFLphone::CallManager_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor { public: - CallManager(DBus::Connection& connection); + CallManager (DBus::Connection& connection); static const char* SERVER_PATH; /* methods exported by this interface, @@ -63,52 +67,52 @@ class CallManager */ /* Call related methods */ - void placeCall( const std::string& accountID, const std::string& callID, const std::string& to ); - void placeCallFirstAccount( const std::string& callID, const std::string& to ); - - void refuse( const std::string& callID ); - void accept( const std::string& callID ); - void hangUp( const std::string& callID ); - void hold( const std::string& callID ); - void unhold( const std::string& callID ); - void transfert( const std::string& callID, const std::string& to ); - std::map< std::string, std::string > getCallDetails( const std::string& callID ); + void placeCall (const std::string& accountID, const std::string& callID, const std::string& to); + void placeCallFirstAccount (const std::string& callID, const std::string& to); + + void refuse (const std::string& callID); + void accept (const std::string& callID); + void hangUp (const std::string& callID); + void hold (const std::string& callID); + void unhold (const std::string& callID); + void transfert (const std::string& callID, const std::string& to); + std::map< std::string, std::string > getCallDetails (const std::string& callID); std::vector< std::string > getCallList (void); - std::string getCurrentCallID( ); + std::string getCurrentCallID(); /* Conference related methods */ - void joinParticipant( const std::string& sel_callID, const std::string& drag_callID ); - void addParticipant( const std::string& callID, const std::string& confID ); - void addMainParticipant( const std::string& confID ); - void detachParticipant( const std::string& callID ); - void joinConference( const std::string& sel_confID, const std::string& drag_confID ); - void hangUpConference( const std::string& confID ); - void holdConference( const std::string& confID ); - void unholdConference( const std::string& confID ); - std::vector< std::string > getConferenceList (void); - std::vector< std::string > getParticipantList (const std::string& confID); - std::map< std::string, std::string > getConferenceDetails ( const std::string& callID ); - - /* General audio methods */ - void setVolume( const std::string& device, const double& value ); - double getVolume( const std::string& device ); - void setRecording( const std::string& callID ); - bool getIsRecording(const std::string& callID); - std::string getCurrentCodecName(const std::string& callID); - void playDTMF( const std::string& key ); - void startTone( const int32_t& start, const int32_t& type ); - - /* Security related methods */ - void setSASVerified(const std::string& callID); - void resetSASVerified(const std::string& callID); - void setConfirmGoClear(const std::string& callID); - void requestGoClear(const std::string& callID); - void acceptEnrollment(const std::string& callID, const bool& accepted); - void setPBXEnrollment(const std::string& callID, const bool& yesNo); - + void joinParticipant (const std::string& sel_callID, const std::string& drag_callID); + void addParticipant (const std::string& callID, const std::string& confID); + void addMainParticipant (const std::string& confID); + void detachParticipant (const std::string& callID); + void joinConference (const std::string& sel_confID, const std::string& drag_confID); + void hangUpConference (const std::string& confID); + void holdConference (const std::string& confID); + void unholdConference (const std::string& confID); + std::vector< std::string > getConferenceList (void); + std::vector< std::string > getParticipantList (const std::string& confID); + std::map< std::string, std::string > getConferenceDetails (const std::string& callID); + + /* General audio methods */ + void setVolume (const std::string& device, const double& value); + double getVolume (const std::string& device); + void setRecording (const std::string& callID); + bool getIsRecording (const std::string& callID); + std::string getCurrentCodecName (const std::string& callID); + void playDTMF (const std::string& key); + void startTone (const int32_t& start, const int32_t& type); + + /* Security related methods */ + void setSASVerified (const std::string& callID); + void resetSASVerified (const std::string& callID); + void setConfirmGoClear (const std::string& callID); + void requestGoClear (const std::string& callID); + void acceptEnrollment (const std::string& callID, const bool& accepted); + void setPBXEnrollment (const std::string& callID, const bool& yesNo); + private: - sfl::AudioZrtpSession * getAudioZrtpSession(const std::string& callID); + sfl::AudioZrtpSession * getAudioZrtpSession (const std::string& callID); }; diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index f76826b008e9edd621a7eaa5f02f333a6ee725dd..8ca26faf75d5e62086486a83848be75a0955b180 100755 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -101,19 +101,6 @@ </arg> </method> - <method name="setNumberOfCredential" tp:name-for-bindings="setNumberOfCredential"> - <tp:docstring> - </tp:docstring> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - </tp:docstring> - </arg> - <arg type="i" name="number" direction="in"> - <tp:docstring> - </tp:docstring> - </arg> - </method> - <method name="deleteAllCredential" tp:name-for-bindings="deleteAllCredential"> <tp:docstring> </tp:docstring> @@ -776,10 +763,6 @@ <method name="getTlsSettings" tp:name-for-bindings="getTlsSettings"> <tp:docstring> </tp:docstring> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - </tp:docstring> - </arg> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/> <arg type="a{ss}" name="details" direction="out"> <tp:docstring> @@ -791,10 +774,6 @@ <tp:docstring> </tp:docstring> <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="MapStringString"/> - <arg type="s" name="accountID" direction="in"> - <tp:docstring> - </tp:docstring> - </arg> <arg type="a{ss}" name="details" direction="in"> <tp:docstring> </tp:docstring> diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index aaf668089e69f9e5cbc6370e08dd01c084852cc3..68d659ff958c0a040ab316358a7f0f00976b6a2d 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -120,7 +120,7 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails (void) ip2ipAccountDetails.insert (std::pair<std::string, std::string> (LOCAL_PORT, portstr.str())); std::map<std::string, std::string> tlsSettings; - tlsSettings = getTlsSettings (IP2IP_PROFILE); + tlsSettings = getTlsSettings(); std::copy (tlsSettings.begin(), tlsSettings.end(), std::inserter ( ip2ipAccountDetails, ip2ipAccountDetails.end())); @@ -177,7 +177,7 @@ void ConfigurationManager::setIp2IpDetails (const std::map<std::string, if (it != details.end()) sipaccount->setZrtpDiaplaySasOnce ( (it->second == "true")); - setTlsSettings (IP2IP_PROFILE, details); + setTlsSettings (details); Manager::instance().saveConfig(); @@ -189,8 +189,7 @@ void ConfigurationManager::setIp2IpDetails (const std::map<std::string, } -std::map<std::string, std::string> ConfigurationManager::getTlsSettings ( - const std::string& section) +std::map<std::string, std::string> ConfigurationManager::getTlsSettings() { std::map<std::string, std::string> tlsSettings; @@ -220,8 +219,7 @@ std::map<std::string, std::string> ConfigurationManager::getTlsSettings ( return tlsSettings; } -void ConfigurationManager::setTlsSettings (const std::string& section, - const std::map<std::string, std::string>& details) +void ConfigurationManager::setTlsSettings (const std::map<std::string, std::string>& details) { std::map<std::string, std::string> map_cpy = details; @@ -338,17 +336,6 @@ int32_t ConfigurationManager::getNumberOfCredential ( return sipaccount->getCredentialCount(); } -void ConfigurationManager::setNumberOfCredential (const std::string& accountID, - const int32_t& number) -{ - /* - if (accountID != AccountNULL || !accountID.empty()) { - SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(accountID); - sipaccount->setCredentialCount(number); - } - */ -} - void ConfigurationManager::setCredential (const std::string& accountID, const int32_t& index, const std::map<std::string, std::string>& details) { diff --git a/sflphone-common/src/dbus/configurationmanager.h b/sflphone-common/src/dbus/configurationmanager.h old mode 100755 new mode 100644 index 6c6083fad430a80a9468597ec29adeb2f192f55c..0423ee3ea7fac0819c83c38dd694ae4cc9dcb891 --- a/sflphone-common/src/dbus/configurationmanager.h +++ b/sflphone-common/src/dbus/configurationmanager.h @@ -34,113 +34,117 @@ #ifndef CONFIGURATIONMANAGER_H #define CONFIGURATIONMANAGER_H +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "configurationmanager-glue.h" +#pragma GCC diagnostic warning "-Wignored-qualifiers" +#pragma GCC diagnostic warning "-Wunused-parameter" + #include <dbus-c++/dbus.h> class ConfigurationManager -: public org::sflphone::SFLphone::ConfigurationManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor + : public org::sflphone::SFLphone::ConfigurationManager_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor { -public: - - ConfigurationManager(DBus::Connection& connection); - static const char* SERVER_PATH; - -private: - std::vector<std::string> shortcutsKeys; - -public: - - std::map< std::string, std::string > getAccountDetails( const std::string& accountID ); - void setAccountDetails( const std::string& accountID, const std::map< std::string, std::string >& details ); - std::string addAccount( const std::map< std::string, std::string >& details ); - void removeAccount( const std::string& accoundID ); - void deleteAllCredential (const std::string& accountID); - std::vector< std::string > getAccountList( ); - void sendRegister( const std::string& accoundID , const int32_t& expire ); - - std::map< std::string, std::string > getTlsSettingsDefault (void); - void setIp2IpDetails(const std::map< std::string, std::string >& details); - std::map< std::string, std::string > getIp2IpDetails(void); - std::map< std::string, std::string > getCredential (const std::string& accountID, const int32_t& index); - int32_t getNumberOfCredential (const std::string& accountID); - void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details); - void setNumberOfCredential (const std::string& accountID, const int32_t& number); - - std::vector< std::string > getCodecList(void); - std::vector< std::string > getSupportedTlsMethod(void); - std::vector< std::string > getCodecDetails( const int32_t& payload ); - std::vector< std::string > getActiveCodecList (const std::string& accountID); - void setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID); - - std::vector< std::string > getAudioPluginList(); - void setInputAudioPlugin(const std::string& audioPlugin); - void setOutputAudioPlugin(const std::string& audioPlugin); - std::vector< std::string > getAudioOutputDeviceList(); - void setAudioOutputDevice(const int32_t& index); - void setAudioInputDevice(const int32_t& index); - void setAudioRingtoneDevice(const int32_t& index); - std::vector< std::string > getAudioInputDeviceList(); - std::vector< std::string > getCurrentAudioDevicesIndex(); - int32_t getAudioDeviceIndex(const std::string& name); - std::string getCurrentAudioOutputPlugin( void ); - std::string getEchoCancelState(void); - void setEchoCancelState(const std::string& state); - std::string getNoiseSuppressState(void); - void setNoiseSuppressState(const std::string& state); - - - std::vector< std::string > getToneLocaleList( ); - std::vector< std::string > getPlaybackDeviceList( ); - std::vector< std::string > getRecordDeviceList( ); - std::string getVersion( ); - std::vector< std::string > getRingtoneList( ); - int32_t getAudioManager( void ); - void setAudioManager( const int32_t& api ); - - bool isMd5CredentialHashing (void); - void setMd5CredentialHashing (const bool& enabled); - int32_t isIax2Enabled( void ); - int32_t isRingtoneEnabled( const std::string& accountID ); - void ringtoneEnabled( const std::string& accountID ); - std::string getRingtoneChoice( const std::string& accountID ); - void setRingtoneChoice( const std::string& accountID, const std::string& tone ); - std::string getRecordPath( void ); - void setRecordPath(const std::string& recPath ); - - - void setHistoryLimit( const int32_t& days); - int32_t getHistoryLimit (void); - - int32_t getMailNotify( void ); - void setMailNotify( void ); - - - std::map<std::string, int32_t> getAddressbookSettings (void); - void setAddressbookSettings (const std::map<std::string, int32_t>& settings); - std::vector< std::string > getAddressbookList ( void ); - void setAddressbookList( const std::vector< std::string >& list ); - - void setAccountsOrder (const std::string& order); - - std::map<std::string, std::string> getHookSettings (void); - void setHookSettings (const std::map<std::string, std::string>& settings); - - std::map <std::string, std::string> getHistory (void); - void setHistory (const std::map <std::string, std::string>& entries); - - std::map<std::string, std::string> getTlsSettings(const std::string& accountID); - void setTlsSettings(const std::string& accountID, const std::map< std::string, std::string >& details); - - std::string getAddrFromInterfaceName(const std::string& interface); - - std::vector<std::string> getAllIpInterface(void); - std::vector<std::string> getAllIpInterfaceByName(void); - - std::map< std::string, std::string > getShortcuts (); - void setShortcuts (const std::map< std::string, std::string >& shortcutsMap); + public: + + ConfigurationManager (DBus::Connection& connection); + static const char* SERVER_PATH; + + private: + std::vector<std::string> shortcutsKeys; + + public: + + std::map< std::string, std::string > getAccountDetails (const std::string& accountID); + void setAccountDetails (const std::string& accountID, const std::map< std::string, std::string >& details); + std::string addAccount (const std::map< std::string, std::string >& details); + void removeAccount (const std::string& accoundID); + void deleteAllCredential (const std::string& accountID); + std::vector< std::string > getAccountList(); + void sendRegister (const std::string& accoundID , const int32_t& expire); + + std::map< std::string, std::string > getTlsSettingsDefault (void); + void setIp2IpDetails (const std::map< std::string, std::string >& details); + std::map< std::string, std::string > getIp2IpDetails (void); + std::map< std::string, std::string > getCredential (const std::string& accountID, const int32_t& index); + int32_t getNumberOfCredential (const std::string& accountID); + void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details); + + std::vector< std::string > getCodecList (void); + std::vector< std::string > getSupportedTlsMethod (void); + std::vector< std::string > getCodecDetails (const int32_t& payload); + std::vector< std::string > getActiveCodecList (const std::string& accountID); + void setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID); + + std::vector< std::string > getAudioPluginList(); + void setInputAudioPlugin (const std::string& audioPlugin); + void setOutputAudioPlugin (const std::string& audioPlugin); + std::vector< std::string > getAudioOutputDeviceList(); + void setAudioOutputDevice (const int32_t& index); + void setAudioInputDevice (const int32_t& index); + void setAudioRingtoneDevice (const int32_t& index); + std::vector< std::string > getAudioInputDeviceList(); + std::vector< std::string > getCurrentAudioDevicesIndex(); + int32_t getAudioDeviceIndex (const std::string& name); + std::string getCurrentAudioOutputPlugin (void); + std::string getEchoCancelState (void); + void setEchoCancelState (const std::string& state); + std::string getNoiseSuppressState (void); + void setNoiseSuppressState (const std::string& state); + + + std::vector< std::string > getToneLocaleList(); + std::vector< std::string > getPlaybackDeviceList(); + std::vector< std::string > getRecordDeviceList(); + std::string getVersion(); + std::vector< std::string > getRingtoneList(); + int32_t getAudioManager (void); + void setAudioManager (const int32_t& api); + + bool isMd5CredentialHashing (void); + void setMd5CredentialHashing (const bool& enabled); + int32_t isIax2Enabled (void); + int32_t isRingtoneEnabled (const std::string& accountID); + void ringtoneEnabled (const std::string& accountID); + std::string getRingtoneChoice (const std::string& accountID); + void setRingtoneChoice (const std::string& accountID, const std::string& tone); + std::string getRecordPath (void); + void setRecordPath (const std::string& recPath); + + + void setHistoryLimit (const int32_t& days); + int32_t getHistoryLimit (void); + + int32_t getMailNotify (void); + void setMailNotify (void); + + + std::map<std::string, int32_t> getAddressbookSettings (void); + void setAddressbookSettings (const std::map<std::string, int32_t>& settings); + std::vector< std::string > getAddressbookList (void); + void setAddressbookList (const std::vector< std::string >& list); + + void setAccountsOrder (const std::string& order); + + std::map<std::string, std::string> getHookSettings (void); + void setHookSettings (const std::map<std::string, std::string>& settings); + + std::map <std::string, std::string> getHistory (void); + void setHistory (const std::map <std::string, std::string>& entries); + + std::map<std::string, std::string> getTlsSettings (void); + void setTlsSettings (const std::map< std::string, std::string >& details); + + std::string getAddrFromInterfaceName (const std::string& interface); + + std::vector<std::string> getAllIpInterface (void); + std::vector<std::string> getAllIpInterfaceByName (void); + + std::map< std::string, std::string > getShortcuts (); + void setShortcuts (const std::map< std::string, std::string >& shortcutsMap); }; diff --git a/sflphone-common/src/dbus/contactmanager.h b/sflphone-common/src/dbus/contactmanager.h index 5611b41f9b8b0b90438955a0e332edcf3fa64574..a7a06b1bf73d061c1a7de27fcdec6b1a9adc4427 100644 --- a/sflphone-common/src/dbus/contactmanager.h +++ b/sflphone-common/src/dbus/contactmanager.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,29 +27,29 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef CONTACTMANAGER_H #define CONTACTMANAGER_H #include "contactmanager-glue.h" #include <dbus-c++/dbus.h> - + class ContactManager -: public org::sflphone::SFLphone::ContactManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor + : public org::sflphone::SFLphone::ContactManager_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor { -public: + public: - ContactManager(DBus::Connection& connection); - static const char* SERVER_PATH; + ContactManager (DBus::Connection& connection); + static const char* SERVER_PATH; -public: - std::map< std::string, std::string > getContacts( const std::string& accountID ); - void setContacts( const std::string& accountID, const std::map< std::string, std::string >& details ); - void setPresence( const std::string& accountID, const std::string& presence, const std::string& additionalInfo ); - void setContactPresence( const std::string& accountID, const std::string& presence, const std::string& additionalInfo ); + public: + std::map< std::string, std::string > getContacts (const std::string& accountID); + void setContacts (const std::string& accountID, const std::map< std::string, std::string >& details); + void setPresence (const std::string& accountID, const std::string& presence, const std::string& additionalInfo); + void setContactPresence (const std::string& accountID, const std::string& presence, const std::string& additionalInfo); }; diff --git a/sflphone-common/src/dbus/dbusmanager.h b/sflphone-common/src/dbus/dbusmanager.h index 47a36d304fd5d1f7af3b0493f301c36913708811..acd97c95fc267c9fce807bc0d438bf2d0be0b24e 100644 --- a/sflphone-common/src/dbus/dbusmanager.h +++ b/sflphone-common/src/dbus/dbusmanager.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/sflphone-common/src/dbus/dbusmanagerimpl.h b/sflphone-common/src/dbus/dbusmanagerimpl.h index 916ae5a407aabd158bb5a92345a9e47a23313f0b..94a1cfc9d9908d4328bd10fa54ed3cc7c7e45e10 100644 --- a/sflphone-common/src/dbus/dbusmanagerimpl.h +++ b/sflphone-common/src/dbus/dbusmanagerimpl.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -37,20 +37,25 @@ class ConfigurationManager; class CallManager; class NetworkManager; -class DBusManagerImpl { +class DBusManagerImpl +{ public: - CallManager * getCallManager(){ return _callManager; }; - ConfigurationManager * getConfigurationManager(){ return _configurationManager; }; + CallManager * getCallManager() { + return _callManager; + }; + ConfigurationManager * getConfigurationManager() { + return _configurationManager; + }; int exec(); void exit(); static const char* SERVER_NAME; - + private: CallManager* _callManager; ConfigurationManager* _configurationManager; Instance* _instanceManager; DBus::BusDispatcher _dispatcher; - NetworkManager* _networkManager; + NetworkManager* _networkManager; }; #endif diff --git a/sflphone-common/src/dbus/instance.h b/sflphone-common/src/dbus/instance.h index d963e5d1319860a7d137edba0c4081dc9dcc9eac..edccb09d9f662f6fb8040fc5eebb5fd03a053958 100644 --- a/sflphone-common/src/dbus/instance.h +++ b/sflphone-common/src/dbus/instance.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,30 +27,34 @@ * shall include the source code for the parts of OpenSSL used as well * as that of the covered work. */ - + #ifndef INSTANCE_H #define INSTANCE_H +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "instance-glue.h" +#pragma GCC diagnostic warning "-Wignored-qualifiers" +#pragma GCC diagnostic warning "-Wunused-parameter" #include <dbus-c++/dbus.h> - + class Instance -: public org::sflphone::SFLphone::Instance_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor + : public org::sflphone::SFLphone::Instance_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor { -private: - int count; - -public: - Instance(DBus::Connection& connection); - static const char* SERVER_PATH; - - void Register( const int32_t& pid, const std::string& name ); - void Unregister( const int32_t& pid ); - int32_t getRegistrationCount( void ); - + private: + int count; + + public: + Instance (DBus::Connection& connection); + static const char* SERVER_PATH; + + void Register (const int32_t& pid, const std::string& name); + void Unregister (const int32_t& pid); + int32_t getRegistrationCount (void); + }; diff --git a/sflphone-common/src/dbus/networkmanager.h b/sflphone-common/src/dbus/networkmanager.h index 3754669751e101a6038130cb7d4d93c29b7219d7..78ee117f9324509a98d4c6e2e5360986ecaf8b8f 100644 --- a/sflphone-common/src/dbus/networkmanager.h +++ b/sflphone-common/src/dbus/networkmanager.h @@ -31,32 +31,35 @@ #ifndef NETWORKMANAGER_H #define NETWORKMANAGER_H +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "networkmanager_proxy.h" +#pragma GCC diagnostic warning "-Wignored-qualifiers" +#pragma GCC diagnostic warning "-Wunused-parameter" using namespace std; class NetworkManager -: public org::freedesktop::NetworkManager_proxy, - public DBus::IntrospectableProxy, - public DBus::ObjectProxy + : public org::freedesktop::NetworkManager_proxy, + public DBus::IntrospectableProxy, + public DBus::ObjectProxy { -public: - - NetworkManager(DBus::Connection&, const DBus::Path&, const char*); - void StateChanged(const uint32_t& state); - void PropertiesChanged(const std::map< std::string, ::DBus::Variant >& argin0); - string stateAsString(const uint32_t& state); - - enum NMState - { - NM_STATE_UNKNOWN = 0, - NM_STATE_ASLEEP, - NM_STATE_CONNECTING, - NM_STATE_CONNECTED, - NM_STATE_DISCONNECTED - }; - - static const string statesString[5]; + public: + + NetworkManager (DBus::Connection&, const DBus::Path&, const char*); + void StateChanged (const uint32_t& state); + void PropertiesChanged (const std::map< std::string, ::DBus::Variant >& argin0); + string stateAsString (const uint32_t& state); + + enum NMState { + NM_STATE_UNKNOWN = 0, + NM_STATE_ASLEEP, + NM_STATE_CONNECTING, + NM_STATE_CONNECTED, + NM_STATE_DISCONNECTED + }; + + static const string statesString[5]; }; #endif diff --git a/sflphone-common/src/dbus/networkmanager_proxy.h b/sflphone-common/src/dbus/networkmanager_proxy.h index 078925ceff22c9e0ebd0e21cf90868ab4b2da370..364b0e7bbb7952b24b5b7ab3505625387cfd3fb3 100644 --- a/sflphone-common/src/dbus/networkmanager_proxy.h +++ b/sflphone-common/src/dbus/networkmanager_proxy.h @@ -9,70 +9,69 @@ #include <dbus-c++/dbus.h> #include <cassert> -namespace org { -namespace freedesktop { +namespace org +{ +namespace freedesktop +{ class NetworkManager_proxy -: public ::DBus::InterfaceProxy + : public ::DBus::InterfaceProxy { -public: - - NetworkManager_proxy() - : ::DBus::InterfaceProxy("org.freedesktop.NetworkManager") - { - connect_signal(NetworkManager_proxy, StateChanged, _StateChanged_stub); - connect_signal(NetworkManager_proxy, PropertiesChanged, _PropertiesChanged_stub); - } - -public: - - /* properties exported by this interface */ -public: - - /* methods exported by this interface, - * this functions will invoke the corresponding methods on the remote objects - */ - std::vector< ::DBus::Path > GetDevices() - { - ::DBus::CallMessage call; - call.member("GetDevices"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< ::DBus::Path > argout; - ri >> argout; - return argout; - } - - -public: - - /* signal handlers for this interface - */ - virtual void StateChanged(const uint32_t& argin0) = 0; - virtual void PropertiesChanged(const std::map< std::string, ::DBus::Variant >& argin0) = 0; - -private: - - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _StateChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t arg0; - ri >> arg0; - StateChanged(arg0); - } - void _PropertiesChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::map< std::string, ::DBus::Variant > arg0; - ri >> arg0; - PropertiesChanged(arg0); - } + public: + + NetworkManager_proxy() + : ::DBus::InterfaceProxy ("org.freedesktop.NetworkManager") { + connect_signal (NetworkManager_proxy, StateChanged, _StateChanged_stub); + connect_signal (NetworkManager_proxy, PropertiesChanged, _PropertiesChanged_stub); + } + + public: + + /* properties exported by this interface */ + public: + + /* methods exported by this interface, + * this functions will invoke the corresponding methods on the remote objects + */ + std::vector< ::DBus::Path > GetDevices() { + ::DBus::CallMessage call; + call.member ("GetDevices"); + ::DBus::Message ret = invoke_method (call); + ::DBus::MessageIter ri = ret.reader(); + + std::vector< ::DBus::Path > argout; + ri >> argout; + return argout; + } + + + public: + + /* signal handlers for this interface + */ + virtual void StateChanged (const uint32_t& argin0) = 0; + virtual void PropertiesChanged (const std::map< std::string, ::DBus::Variant >& argin0) = 0; + + private: + + /* unmarshalers (to unpack the DBus message before calling the actual signal handler) + */ + void _StateChanged_stub (const ::DBus::SignalMessage &sig) { + ::DBus::MessageIter ri = sig.reader(); + + uint32_t arg0; + ri >> arg0; + StateChanged (arg0); + } + void _PropertiesChanged_stub (const ::DBus::SignalMessage &sig) { + ::DBus::MessageIter ri = sig.reader(); + + std::map< std::string, ::DBus::Variant > arg0; + ri >> arg0; + PropertiesChanged (arg0); + } }; -} } +} +} #endif //__dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H diff --git a/sflphone-common/src/eventthread.h b/sflphone-common/src/eventthread.h index eca20c22dc8c40ec39135eaf2539943f85373876..0285deec51f4af54641a5741746d87c7615294be 100644 --- a/sflphone-common/src/eventthread.h +++ b/sflphone-common/src/eventthread.h @@ -1,17 +1,17 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -42,34 +42,36 @@ class AlsaLayer; * @brief General thread to listen events continuously */ -class EventThread : public ost::Thread { +class EventThread : public ost::Thread +{ public: /** - * Thread constructor + * Thread constructor */ - EventThread (VoIPLink* link); - - ~EventThread (void){ + EventThread (VoIPLink* link); + + ~EventThread (void) { terminate(); } - + virtual void run () ; - + private: - EventThread(const EventThread& rh); // copy constructor - EventThread& operator=(const EventThread& rh); // assignment operator + EventThread (const EventThread& rh); // copy constructor + EventThread& operator= (const EventThread& rh); // assignment operator /** VoIPLink is the object being called by getEvents() method */ VoIPLink* _linkthread; }; -class AudioThread : public ost::Thread { +class AudioThread : public ost::Thread +{ public: AudioThread (AlsaLayer *alsa); - ~AudioThread (void){ + ~AudioThread (void) { terminate(); } @@ -77,7 +79,7 @@ class AudioThread : public ost::Thread { private: AudioThread (const AudioThread& at); - AudioThread& operator=(const AudioThread& at); + AudioThread& operator= (const AudioThread& at); AlsaLayer* _alsa; }; diff --git a/sflphone-common/src/global.h b/sflphone-common/src/global.h index 552616d7851be88197c105e84c062d3c0b2710fc..980f7081aea2e540c073609b1036b5bd8312cf52 100644 --- a/sflphone-common/src/global.h +++ b/sflphone-common/src/global.h @@ -3,17 +3,17 @@ * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -71,7 +71,7 @@ static const SOUND_FORMAT INT32 = 0x8; #define SUCCESS 0 #define ASSERT( expected , value) if( value == expected ) return SUCCESS; \ - else return 1; + else return 1; #define PIDFILE "sfl.pid" #ifdef DATAFORMAT_IS_FLOAT @@ -94,18 +94,18 @@ static const SOUND_FORMAT INT32 = 0x8; #define ALSA_DFT_CARD_ID 0 /** Index of the default soundcard */ -#define PCM_PLUGHW "plughw" /** Alsa plugin */ +#define PCM_PLUGHW "plughw" /** Alsa plugin */ #define PCM_DEFAULT "default" /** Default ALSA plugin */ #define PCM_DMIX "plug:dmix" /** Alsa plugin for software mixing */ #define PCM_DSNOOP "plug:dsnoop" /** Alsa plugin for microphone sharing */ #define PCM_DMIX_DSNOOP "dmix/dsnoop" /** Audio profile using Alsa dmix/dsnoop */ -#define SFL_CODEC_VALID_PREFIX "libcodec_" /** Valid prefix for codecs shared library */ +#define SFL_CODEC_VALID_PREFIX "libcodec_" /** Valid prefix for codecs shared library */ #define SFL_CODEC_VALID_EXTEN ".so" /** Valid extension for codecs shared library */ #define CURRENT_DIR "." /** Current directory */ #define PARENT_DIR ".." /** Parent directory */ -#define SFL_PCM_BOTH 0x0021 /** To open both playback and capture devices */ +#define SFL_PCM_BOTH 0x0021 /** To open both playback and capture devices */ #define SFL_PCM_PLAYBACK 0x0022 /** To open playback device only */ #define SFL_PCM_CAPTURE 0x0023 /** To open capture device only */ #define SFL_PCM_RINGTONE 0x0024 @@ -133,11 +133,11 @@ static const SOUND_FORMAT INT32 = 0x8; #define NETWORK_UNREACHABLE 0x0011 /** Network unreachable */ #define PULSEAUDIO_NOT_RUNNING 0x0100 /** Pulseaudio is not running */ -#define ALSA 0 +#define ALSA 0 #define PULSEAUDIO 1 -#define CHECK_INTERFACE( layer , api ) (layer == api) +#define CHECK_INTERFACE( layer , api ) (layer == api) -#define UNUSED __attribute__((__unused__)) +#define UNUSED __attribute__((__unused__)) #define DEFAULT_SIP_PORT "5060" #define DEFAULT_SIP_TLS_PORT "5061" @@ -147,27 +147,27 @@ static const SOUND_FORMAT INT32 = 0x8; /** Enumeration that contains known audio payloads */ typedef enum { - // http://www.iana.org/assignments/rtp-parameters - // http://www.gnu.org/software/ccrtp/doc/refman/html/formats_8h.html#a0 - // 0 PCMU A 8000 1 [RFC3551] - PAYLOAD_CODEC_ULAW = 0, - // 3 GSM A 8000 1 [RFC3551] - PAYLOAD_CODEC_GSM = 3, - // 8 PCMA A 8000 1 [RFC3551] - PAYLOAD_CODEC_ALAW = 8, - // 9 G722 A 8000 1 [RFC3551] - PAYLOAD_CODEC_G722 = 9, - // http://www.ietf.org/rfc/rfc3952.txt - // 97 iLBC/8000 - PAYLOAD_CODEC_ILBC_20 = 97, - PAYLOAD_CODEC_ILBC_30 = 98, - // http://www.speex.org/drafts/draft-herlein-speex-rtp-profile-00.txt - // 97 speex/8000 - // http://support.xten.com/viewtopic.php?p=8684&sid=3367a83d01fdcad16c7459a79859b08e - // 100 speex/16000 - PAYLOAD_CODEC_SPEEX_8000 = 110, - PAYLOAD_CODEC_SPEEX_16000 = 111, - PAYLOAD_CODEC_SPEEX_32000 = 112 + // http://www.iana.org/assignments/rtp-parameters + // http://www.gnu.org/software/ccrtp/doc/refman/html/formats_8h.html#a0 + // 0 PCMU A 8000 1 [RFC3551] + PAYLOAD_CODEC_ULAW = 0, + // 3 GSM A 8000 1 [RFC3551] + PAYLOAD_CODEC_GSM = 3, + // 8 PCMA A 8000 1 [RFC3551] + PAYLOAD_CODEC_ALAW = 8, + // 9 G722 A 8000 1 [RFC3551] + PAYLOAD_CODEC_G722 = 9, + // http://www.ietf.org/rfc/rfc3952.txt + // 97 iLBC/8000 + PAYLOAD_CODEC_ILBC_20 = 97, + PAYLOAD_CODEC_ILBC_30 = 98, + // http://www.speex.org/drafts/draft-herlein-speex-rtp-profile-00.txt + // 97 speex/8000 + // http://support.xten.com/viewtopic.php?p=8684&sid=3367a83d01fdcad16c7459a79859b08e + // 100 speex/16000 + PAYLOAD_CODEC_SPEEX_8000 = 110, + PAYLOAD_CODEC_SPEEX_16000 = 111, + PAYLOAD_CODEC_SPEEX_32000 = 112 } AudioCodecType; /** The struct to reflect the order the user wants to use the codecs */ diff --git a/sflphone-common/src/history/historyitem.h b/sflphone-common/src/history/historyitem.h index 55b12cb5b8785516cbb77f46b43570018a037ff2..52721d8522939a1fd0514893a565b17eb0e20626 100644 --- a/sflphone-common/src/history/historyitem.h +++ b/sflphone-common/src/history/historyitem.h @@ -40,10 +40,11 @@ typedef enum CallType { CALL_MISSED, CALL_INCOMING, CALL_OUTGOING -}CallType; +} CallType; -class HistoryItem { +class HistoryItem +{ public: /* @@ -55,7 +56,7 @@ class HistoryItem { * Constructor from a serialized form */ HistoryItem (std::string, std::string=""); - + /* * Destructor */ @@ -82,7 +83,7 @@ class HistoryItem { std::string _timestamp_start; std::string _timestamp_stop; - /* + /* * Represents the type of call * Has be either CALL_MISSED, CALL_INCOMING or CALL_OUTGOING */ @@ -96,7 +97,7 @@ class HistoryItem { /* * The account the call was made with - */ + */ std::string _account_id; }; diff --git a/sflphone-common/src/history/historymanager.h b/sflphone-common/src/history/historymanager.h index e8966dfeb200e832dd3819df842843925155a879..2796315aeaaf641ae24be164afa2546a8ea3c260 100644 --- a/sflphone-common/src/history/historymanager.h +++ b/sflphone-common/src/history/historymanager.h @@ -32,15 +32,16 @@ #ifndef _HISTORY_MANAGER #define _HISTORY_MANAGER -#include "historyitem.h" +#include "historyitem.h" #include <global.h> #include <user_cfg.h> #define DAY_UNIX_TIMESTAMP 86400 // Number of seconds in one day: 60 x 60 x 24 -typedef std::map <std::string, HistoryItem*> HistoryItemMap; +typedef std::map <std::string, HistoryItem*> HistoryItemMap; -class HistoryManager { +class HistoryManager +{ public: /* @@ -95,7 +96,7 @@ class HistoryManager { inline void set_history_path (std::string filename) { _history_path = filename; } - + /* *@return int The number of items found in the history file */ @@ -108,13 +109,12 @@ class HistoryManager { int set_serialized_history (std::map <std::string, std::string> history, int limit); private: - inline int get_unix_timestamp_equivalent (int days) - { + inline int get_unix_timestamp_equivalent (int days) { return days * DAY_UNIX_TIMESTAMP; } - - int getConfigInt(const std::string& section, const std::string& name, Conf::ConfigTree *history_list); - std::string getConfigString(const std::string& section, const std::string& name, Conf::ConfigTree *history_list); + + int getConfigInt (const std::string& section, const std::string& name, Conf::ConfigTree *history_list); + std::string getConfigString (const std::string& section, const std::string& name, Conf::ConfigTree *history_list); /* * Set the path to the history file @@ -139,7 +139,7 @@ class HistoryManager { /* * The path to the history file - */ + */ std::string _history_path; diff --git a/sflphone-common/src/hooks/urlhook.h b/sflphone-common/src/hooks/urlhook.h index 49208656063665caf781c681d8247c368e9e5e3b..90a463771f7edd8d499440c63835b6a087130401 100644 --- a/sflphone-common/src/hooks/urlhook.h +++ b/sflphone-common/src/hooks/urlhook.h @@ -36,7 +36,8 @@ #define RUN_COMMAND(command) system(command); -class UrlHook { +class UrlHook +{ public: /** diff --git a/sflphone-common/src/iax/iaxaccount.h b/sflphone-common/src/iax/iaxaccount.h index 1075dd70aba2b2eebfbc7a0ed453d17cd98875a7..d9596abb9b60d548d5fd32f8cb5bce5e2c6d4e90 100644 --- a/sflphone-common/src/iax/iaxaccount.h +++ b/sflphone-common/src/iax/iaxaccount.h @@ -2,17 +2,17 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -40,22 +40,22 @@ class IAXAccount : public Account { public: - IAXAccount(const AccountID& accountID); + IAXAccount (const AccountID& accountID); ~IAXAccount(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - void setAccountDetails(const std::map<std::string, std::string>& details); + void setAccountDetails (const std::map<std::string, std::string>& details); - std::map<std::string, std::string> getAccountDetails(); + std::map<std::string, std::string> getAccountDetails(); - void setVoIPLink (); + void setVoIPLink (); - /** - * Actually useless, since config loading is done in init() + /** + * Actually useless, since config loading is done in init() */ void loadConfig(); diff --git a/sflphone-common/src/iax/iaxcall.h b/sflphone-common/src/iax/iaxcall.h index 7ecb1558cacf79ab3e79f6c56276726fd4d24503..fae514039eefac9d4b3f33017ad2a6f48871eddd 100644 --- a/sflphone-common/src/iax/iaxcall.h +++ b/sflphone-common/src/iax/iaxcall.h @@ -39,110 +39,120 @@ /** * @file: iaxcall.h - * @brief IAXCall are IAX implementation of a normal Call + * @brief IAXCall are IAX implementation of a normal Call */ class IAXCall : public Call { -public: - /** - * Constructor - * @param id The unique ID of the call - * @param type The type of the call - */ - IAXCall(const CallID& id, Call::CallType type); - - /** - * Destructor - */ - ~IAXCall(); - - /** - * @return iax_session* The session pointer or NULL - */ - struct iax_session* getSession() { return _session; } - - /** - * Set the session pointer - * @param session the session pointer to assign - */ - void setSession(struct iax_session* session) { _session = session; } - - /** - * Set format (one single bit) - * This function sets the _audioCodec variable with the correct - * codec. - * @param format The format representing the codec - */ - void setFormat(int format); - - /** - * Get format for the voice codec used - * @return int Bitmask for codecs defined in iax/frame.h - */ - int getFormat() { return _format; } - - - /** - * @return int The bitwise list of supported formats - */ - int getSupportedFormat (std::string accountID); - - /** - * Return a format (int) with the first matching codec selected. - * - * This considers the order of the appearance in the CodecMap, - * thus, the order of preference. - * - * NOTE: Everything returned is bound to the content of the local - * CodecMap, so it won't return format values that aren't valid - * in this call context. - * - * @param needles The format(s) (bitwise) you are looking for to match - * @return int The matching format, thus 0 if none matches - */ - int getFirstMatchingFormat(int needles, std::string accountID); - - // AUDIO - /** - * Set internal codec Map: initialization only, not protected - * @param map The codec map - */ - void setCodecMap(const CodecDescriptor& map) { _codecMap = map; } - - /** - * Get internal codec Map: initialization only, not protected - * @return CodecDescriptor The codec map - */ - CodecDescriptor& getCodecMap(); - - /** - * Return audio codec [mutex protected] - * @return AudioCodecType The payload of the codec - */ - AudioCodecType getAudioCodec(); - -private: - /** Each call is associated with an iax_session */ - struct iax_session* _session; - - /** - * Set the audio codec used. [not protected] - * @param audioCodec The payload of the codec - */ - void setAudioCodec(AudioCodecType audioCodec) { _audioCodec = audioCodec; } - - /** Codec Map */ - CodecDescriptor _codecMap; - - /** Codec pointer */ - AudioCodecType _audioCodec; - - /** - * Format currently in use in the conversation, - * sent in each outgoing voice packet. - */ - int _format; + public: + /** + * Constructor + * @param id The unique ID of the call + * @param type The type of the call + */ + IAXCall (const CallID& id, Call::CallType type); + + /** + * Destructor + */ + ~IAXCall(); + + /** + * @return iax_session* The session pointer or NULL + */ + struct iax_session* getSession() { + return _session; + } + + /** + * Set the session pointer + * @param session the session pointer to assign + */ + void setSession (struct iax_session* session) { + _session = session; + } + + /** + * Set format (one single bit) + * This function sets the _audioCodec variable with the correct + * codec. + * @param format The format representing the codec + */ + void setFormat (int format); + + /** + * Get format for the voice codec used + * @return int Bitmask for codecs defined in iax/frame.h + */ + int getFormat() { + return _format; + } + + + /** + * @return int The bitwise list of supported formats + */ + int getSupportedFormat (std::string accountID); + + /** + * Return a format (int) with the first matching codec selected. + * + * This considers the order of the appearance in the CodecMap, + * thus, the order of preference. + * + * NOTE: Everything returned is bound to the content of the local + * CodecMap, so it won't return format values that aren't valid + * in this call context. + * + * @param needles The format(s) (bitwise) you are looking for to match + * @return int The matching format, thus 0 if none matches + */ + int getFirstMatchingFormat (int needles, std::string accountID); + + // AUDIO + /** + * Set internal codec Map: initialization only, not protected + * @param map The codec map + */ + void setCodecMap (const CodecDescriptor& map) { + _codecMap = map; + } + + /** + * Get internal codec Map: initialization only, not protected + * @return CodecDescriptor The codec map + */ + CodecDescriptor& getCodecMap(); + + /** + * Return audio codec [mutex protected] + * @return AudioCodecType The payload of the codec + */ + AudioCodecType getAudioCodec(); + + private: + /** Each call is associated with an iax_session */ + struct iax_session* _session; + + /** + * Set the audio codec used. [not protected] + * @param audioCodec The payload of the codec + */ + void setAudioCodec (AudioCodecType audioCodec) { + _audioCodec = audioCodec; + } + + /** Codec Map */ + CodecDescriptor _codecMap; + + /** Codec pointer */ + AudioCodecType _audioCodec; + + /** + * Format currently in use in the conversation, + * sent in each outgoing voice packet. + */ + int _format; }; #endif diff --git a/sflphone-common/src/iax/iaxvoiplink.cpp b/sflphone-common/src/iax/iaxvoiplink.cpp index 1d4068fe325a51874efc300ca1232654b02e712c..a9d4f117ea361c1fdba5731c715dcc57b9b2c77e 100644 --- a/sflphone-common/src/iax/iaxvoiplink.cpp +++ b/sflphone-common/src/iax/iaxvoiplink.cpp @@ -408,7 +408,7 @@ IAXVoIPLink::getIAXCall (const CallID& id) int -IAXVoIPLink::sendRegister (AccountID id) +IAXVoIPLink::sendRegister (AccountID id UNUSED) { IAXAccount *account; bool result; @@ -459,7 +459,7 @@ IAXVoIPLink::sendRegister (AccountID id) } int -IAXVoIPLink::sendUnregister (AccountID id) +IAXVoIPLink::sendUnregister (AccountID id UNUSED) { IAXAccount *account; diff --git a/sflphone-common/src/iax/iaxvoiplink.h b/sflphone-common/src/iax/iaxvoiplink.h index 0f61f5958823b218193d838a2c89df133654805b..4fe101b4d07029b51947dd8cda6c9273fbaf3e5c 100644 --- a/sflphone-common/src/iax/iaxvoiplink.h +++ b/sflphone-common/src/iax/iaxvoiplink.h @@ -3,17 +3,17 @@ * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -48,270 +48,276 @@ class AudioLayer; /** * @file iaxvoiplink.h - * @brief VoIPLink contains a thread that listen to external events + * @brief VoIPLink contains a thread that listen to external events * and contains IAX Call related functions */ class IAXVoIPLink : public VoIPLink { - public: - - /** - * Constructor - * @param accountID The account containing the voip link - */ - IAXVoIPLink(const AccountID& accountID); - - /** - * Destructor - */ - ~IAXVoIPLink(); - - /** - * Listen to events sent by the call manager ( asterisk, etc .. ) - */ - void getEvent(void); - - /** - * Init the voip link - * @return true if successful - * false otherwise - */ - bool init (void); - - /** - * Terminate a voip link by clearing the call list - */ - void terminate (void); - - /** - * Terminate on call - */ - void terminateOneCall(const CallID& id); - - /** - * Send out registration - * @return bool The new registration state (are we registered ?) - */ - int sendRegister (AccountID id); - - /** - * Destroy registration session - * @todo Send an IAX_COMMAND_REGREL to force unregistration upstream. - * Urgency: low - * @return bool true if we're registered upstream - * false otherwise - */ - int sendUnregister (AccountID id); - - /** - * Create a new outgoing call - * @param id The ID of the call - * @param toUrl The address to call - * @return Call* A pointer on the call - */ - Call* newOutgoingCall(const CallID& id, const std::string& toUrl); - - /** - * Answer a call - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool answer(const CallID& id); - - /** - * Hangup a call - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool hangup(const CallID& id); - - /** - * Peer Hungup a call - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool peerHungup(const CallID& id); - - /** - * Cancel a call - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool cancel(const CallID& id UNUSED ) { return false; } - - /** - * Put a call on hold - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool onhold(const CallID& id); - - /** - * Put a call off hold - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool offhold(const CallID& id); - - /** - * Transfer a call - * @param id The ID of the call - * @param to The recipient of the transfer - * @return bool true on success - * false otherwise - */ - bool transfer(const CallID& id, const std::string& to); - - /** - * Refuse a call - * @param id The ID of the call - * @return bool true on success - * false otherwise - */ - bool refuse (const CallID& id); - - /** - * Send DTMF - * @param id The ID of the call - * @param code The code of the DTMF - * @return bool true on success - * false otherwise - */ - bool carryingDTMFdigits(const CallID& id, char code); - - bool sendMessage(const std::string& to UNUSED, const std::string& body UNUSED) { return false; } - - bool isContactPresenceSupported() { return false; } - - /** - * Return the codec protocol used for this call - * @param id The call identifier - */ - std::string getCurrentCodecName(); - - - public: // iaxvoiplink only - - void updateAudiolayer( void ); - - private: - - /* - * Decode the message count IAX send. - * Returns only the new messages number - * - * @param msgcount The value sent by IAX in the REGACK message - * @return int The number of new messages waiting for the current registered user - */ - int processIAXMsgCount( int msgcount ); - - - /** - * Get IAX Call from an id - * @param id CallId - * @return IAXCall pointer or 0 - */ - IAXCall* getIAXCall(const CallID& id); - - /** - * Delete every call - */ - void terminateIAXCall(); - - /** - * Find a iaxcall by iax session number - * @param session an iax_session valid pointer - * @return iaxcall or 0 if not found - */ - IAXCall* iaxFindCallBySession(struct iax_session* session); - - /** - * Handle IAX Event for a call - * @param event An iax_event pointer - * @param call An IAXCall pointer - */ - void iaxHandleCallEvent(iax_event* event, IAXCall* call); - - /** - * Handle the VOICE events specifically - * @param event The iax_event containing the IAX_EVENT_VOICE - * @param call The associated IAXCall - */ - void iaxHandleVoiceEvent(iax_event* event, IAXCall* call); - - /** - * Handle IAX Registration Reply event - * @param event An iax_event pointer - */ - void iaxHandleRegReply(iax_event* event); - - /** - * Handle IAX pre-call setup-related events - * @param event An iax_event pointer - */ - void iaxHandlePrecallEvent(iax_event* event); - - /** - * Work out the audio data from Microphone to IAX2 channel - */ - void sendAudioFromMic(void); - - /** - * Send an outgoing call invite to iax - * @param call An IAXCall pointer - */ - bool iaxOutgoingInvite(IAXCall* call); - - /** Threading object */ - EventThread* _evThread; - - /** registration session : 0 if not register */ - struct iax_session* _regSession; - - /** Timestamp of when we should refresh the registration up with - * the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1 - * to force a registration. */ - int _nextRefreshStamp; - - /** Mutex for iax_ calls, since we're the only one dealing with the incorporated - * iax_stuff inside this class. */ - ost::Mutex _mutexIAX; - - /** Connection to audio card/device */ - AudioLayer* audiolayer; - - /** Mic-data related buffers */ - SFLDataFormat* micData; - SFLDataFormat* micDataConverted; - unsigned char* micDataEncoded; - - /** Speaker-data related buffers */ - SFLDataFormat* spkrDataDecoded; - SFLDataFormat* spkrDataConverted; - - /** Sample rate converter object */ - SamplerateConverter* converter; - - int converterSamplingRate; - - /** number of sample */ - int nbSample_; - - /** number of sample before conversion (recording) */ - int nbSampleForRec_; - - /* URL hook */ - UrlHook *urlhook; - - /** Counter for IncomingCallNotification */ - int countTime; + public: + + /** + * Constructor + * @param accountID The account containing the voip link + */ + IAXVoIPLink (const AccountID& accountID); + + /** + * Destructor + */ + ~IAXVoIPLink(); + + /** + * Listen to events sent by the call manager ( asterisk, etc .. ) + */ + void getEvent (void); + + /** + * Init the voip link + * @return true if successful + * false otherwise + */ + bool init (void); + + /** + * Terminate a voip link by clearing the call list + */ + void terminate (void); + + /** + * Terminate on call + */ + void terminateOneCall (const CallID& id); + + /** + * Send out registration + * @return bool The new registration state (are we registered ?) + */ + int sendRegister (AccountID id); + + /** + * Destroy registration session + * @todo Send an IAX_COMMAND_REGREL to force unregistration upstream. + * Urgency: low + * @return bool true if we're registered upstream + * false otherwise + */ + int sendUnregister (AccountID id); + + /** + * Create a new outgoing call + * @param id The ID of the call + * @param toUrl The address to call + * @return Call* A pointer on the call + */ + Call* newOutgoingCall (const CallID& id, const std::string& toUrl); + + /** + * Answer a call + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool answer (const CallID& id); + + /** + * Hangup a call + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool hangup (const CallID& id); + + /** + * Peer Hungup a call + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool peerHungup (const CallID& id); + + /** + * Cancel a call + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool cancel (const CallID& id UNUSED) { + return false; + } + + /** + * Put a call on hold + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool onhold (const CallID& id); + + /** + * Put a call off hold + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool offhold (const CallID& id); + + /** + * Transfer a call + * @param id The ID of the call + * @param to The recipient of the transfer + * @return bool true on success + * false otherwise + */ + bool transfer (const CallID& id, const std::string& to); + + /** + * Refuse a call + * @param id The ID of the call + * @return bool true on success + * false otherwise + */ + bool refuse (const CallID& id); + + /** + * Send DTMF + * @param id The ID of the call + * @param code The code of the DTMF + * @return bool true on success + * false otherwise + */ + bool carryingDTMFdigits (const CallID& id, char code); + + bool sendMessage (const std::string& to UNUSED, const std::string& body UNUSED) { + return false; + } + + bool isContactPresenceSupported() { + return false; + } + + /** + * Return the codec protocol used for this call + * @param id The call identifier + */ + std::string getCurrentCodecName(); + + + public: // iaxvoiplink only + + void updateAudiolayer (void); + + private: + + /* + * Decode the message count IAX send. + * Returns only the new messages number + * + * @param msgcount The value sent by IAX in the REGACK message + * @return int The number of new messages waiting for the current registered user + */ + int processIAXMsgCount (int msgcount); + + + /** + * Get IAX Call from an id + * @param id CallId + * @return IAXCall pointer or 0 + */ + IAXCall* getIAXCall (const CallID& id); + + /** + * Delete every call + */ + void terminateIAXCall(); + + /** + * Find a iaxcall by iax session number + * @param session an iax_session valid pointer + * @return iaxcall or 0 if not found + */ + IAXCall* iaxFindCallBySession (struct iax_session* session); + + /** + * Handle IAX Event for a call + * @param event An iax_event pointer + * @param call An IAXCall pointer + */ + void iaxHandleCallEvent (iax_event* event, IAXCall* call); + + /** + * Handle the VOICE events specifically + * @param event The iax_event containing the IAX_EVENT_VOICE + * @param call The associated IAXCall + */ + void iaxHandleVoiceEvent (iax_event* event, IAXCall* call); + + /** + * Handle IAX Registration Reply event + * @param event An iax_event pointer + */ + void iaxHandleRegReply (iax_event* event); + + /** + * Handle IAX pre-call setup-related events + * @param event An iax_event pointer + */ + void iaxHandlePrecallEvent (iax_event* event); + + /** + * Work out the audio data from Microphone to IAX2 channel + */ + void sendAudioFromMic (void); + + /** + * Send an outgoing call invite to iax + * @param call An IAXCall pointer + */ + bool iaxOutgoingInvite (IAXCall* call); + + /** Threading object */ + EventThread* _evThread; + + /** registration session : 0 if not register */ + struct iax_session* _regSession; + + /** Timestamp of when we should refresh the registration up with + * the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1 + * to force a registration. */ + int _nextRefreshStamp; + + /** Mutex for iax_ calls, since we're the only one dealing with the incorporated + * iax_stuff inside this class. */ + ost::Mutex _mutexIAX; + + /** Connection to audio card/device */ + AudioLayer* audiolayer; + + /** Mic-data related buffers */ + SFLDataFormat* micData; + SFLDataFormat* micDataConverted; + unsigned char* micDataEncoded; + + /** Speaker-data related buffers */ + SFLDataFormat* spkrDataDecoded; + SFLDataFormat* spkrDataConverted; + + /** Sample rate converter object */ + SamplerateConverter* converter; + + int converterSamplingRate; + + /** number of sample */ + int nbSample_; + + /** number of sample before conversion (recording) */ + int nbSampleForRec_; + + /* URL hook */ + UrlHook *urlhook; + + /** Counter for IncomingCallNotification */ + int countTime; }; #endif diff --git a/sflphone-common/src/logger.cpp b/sflphone-common/src/logger.cpp index efcfc8b5c762826685168541812295779e6cc6cb..958842bcc6e86115349617b31a0189f69d73e3f7 100644 --- a/sflphone-common/src/logger.cpp +++ b/sflphone-common/src/logger.cpp @@ -82,11 +82,11 @@ void log (const int level, const char* format, ...) message = buffer; message = prefix + message; - syslog (level, message.c_str()); + syslog (level, "%s", message.c_str()); if (consoleLog) { message = color_prefix + message + END_COLOR + "\n"; - fprintf (stderr, message.c_str()); + fprintf (stderr, "%s", message.c_str()); } } diff --git a/sflphone-common/src/logger.h b/sflphone-common/src/logger.h index 7bf8ec75d60e7a0607d6abfbeeda9a17921f92ad..58c15c4d94cbd9ac8256fd47cf446fc906c75696 100644 --- a/sflphone-common/src/logger.h +++ b/sflphone-common/src/logger.h @@ -35,10 +35,10 @@ namespace Logger { - void log(const int, const char*, ...); +void log (const int, const char*, ...); - void setConsoleLog(bool); - void setDebugMode(bool); +void setConsoleLog (bool); +void setDebugMode (bool); }; #define _error(...) Logger::log(LOG_ERR, __VA_ARGS__) diff --git a/sflphone-common/src/manager.h b/sflphone-common/src/manager.h index e9324055911b07075cc5ff6420b79b64a5a2c643..df04243699c2ff41a0eab0e0f140f98cb5963ade 100644 --- a/sflphone-common/src/manager.h +++ b/sflphone-common/src/manager.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author : Jean-Philippe Barrette-LaPierre + * Author : Jean-Philippe Barrette-LaPierre * <jean-philippe.barrette-lapierre@savoirfairelinux.com> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -37,5 +37,5 @@ typedef utilspp::SingletonHolder<ManagerImpl> Manager; -#endif +#endif diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index d0b3ac38aefbbf19730bddb18bf25480587f3623..15a34d79929da9cc6ee64a70e01387a0a058b7fe 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -3348,73 +3348,11 @@ std::string ManagerImpl::computeMd5HashFromCredential ( return hashedDigest; } -void ManagerImpl::setCredential (const std::string& accountID, - const int32_t& index, const std::map<std::string, std::string>& details) +void ManagerImpl::setCredential (const std::string& accountID UNUSED, + const int32_t& index UNUSED, const std::map<std::string, std::string>& details UNUSED) { _debug ("Manager: set credential"); - /* - std::map<std::string, std::string>::iterator it; - std::map<std::string, std::string> credentialInformation = details; - - std::string credentialIndex; - std::stringstream streamOut; - streamOut << index; - credentialIndex = streamOut.str(); - - std::string section = "Credential" + std::string(":") + accountID - + std::string(":") + credentialIndex; - - _debug ("Setting credential in section %s", section.c_str()); - - it = credentialInformation.find(USERNAME); - std::string username; - - if (it == credentialInformation.end()) { - username = EMPTY_FIELD; - } else { - username = it->second; - } - - Manager::instance().setConfig(section, USERNAME, username); - - it = credentialInformation.find(REALM); - std::string realm; - - if (it == credentialInformation.end()) { - realm = EMPTY_FIELD; - } else { - realm = it->second; - } - - Manager::instance().setConfig(section, REALM, realm); - - it = credentialInformation.find(PASSWORD); - std::string password; - - if (it == credentialInformation.end()) { - password = EMPTY_FIELD; - } else { - password = it->second; - } - - if (getMd5CredentialHashing()) { - // TODO: Fix this. - // This is an extremly weak test in order to check - // if the password is a hashed value. This is done - // because deleteCredential() is called before this - // method. Therefore, we cannot check if the value - // is different from the one previously stored in - // the configuration file. This is to avoid to - // re-hash a hashed password. - - if (password.length() != 32) { - password = computeMd5HashFromCredential(username, password, realm); - } - } - - Manager::instance().setConfig(section, PASSWORD, password); - */ } // method to reduce the if/else mess. diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h old mode 100755 new mode 100644 index 5a0b33dbf1e7303a0fb8125d590f77b3af167c10..9bea655902250ca97f97f1377c700f8f1f70e87c --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -87,14 +87,14 @@ typedef std::set<CallID> CallIDSet; /** To send multiple string */ typedef std::list<std::string> TokenList; -/** To store conference objects by call ids +/** To store conference objects by call ids used to retreive the conference according to a call */ typedef std::map<CallID, Conference*> ConferenceCallMap; /** To store conference objects by conference ids */ typedef std::map<CallID, Conference*> ConferenceMap; -static CallID default_conf = "conf"; +static CallID default_conf = "conf"; static char * mapStateToChar[] = { (char*) "UNREGISTERED", @@ -104,1292 +104,1312 @@ static char * mapStateToChar[] = { (char*) "ERRORAUTH", (char*) "ERRORNETWORK", (char*) "ERRORHOST", - (char*) "ERROREXISTSTUN", - (char*) "ERRORCONFSTUN" + (char*) "ERROREXISTSTUN", + (char*) "ERRORCONFSTUN" }; /** Manager (controller) of sflphone daemon */ -class ManagerImpl { - public: - ManagerImpl (void); - ~ManagerImpl (void); - - - /** - * General preferences configuration - */ - Preferences preferences; - - /** - * Voip related preferences - */ - VoipPreference voipPreferences; - - /** - * Addressbook related preferences - */ - AddressbookPreference addressbookPreference; - - /** - * Hook preferences - */ - HookPreference hookPreference; - - /** - * Audio preferences - */ - AudioPreference audioPreference; - - /** - * Shortcut preferences - */ - ShortcutPreferences shortcutPreferences; - - /** - * Method to build preferences from configuration - */ - short buildConfiguration(); - - /** - * Initialisation of thread (sound) and map. - * Init a new VoIPLink, audio codec and audio driver - */ - void init (void); - - /** - * Terminate all thread (sound, link) and unload AccountMap - */ - void terminate (void); - - /** - * Set user interface manager. - * @param man The DBUS interface implementation - */ - void setDBusManager (DBusManagerImpl* man) { _dbus = man; } - - /** - * Accessor to audiodriver. - * it's multi-thread and use mutex internally - * @return AudioLayer* The audio layer object - */ - AudioLayer* getAudioDriver(void) const { return _audiodriver; } - - /** - * Get a descriptor map of codec available - * @return CodecDescriptor The internal codec map - */ - CodecDescriptor& getCodecDescriptorMap(void) {return _codecDescriptorMap;} - - /** - * Functions which occur with a user's action - * Place a new call - * @param accountId The account to make tha call with - * @param id The call identifier - * @param to The recipient of the call - * @return bool true on success - * false otherwise - */ - bool outgoingCall(const AccountID& accountId, const CallID& id, const std::string& to); - - /** - * Functions which occur with a user's action - * Answer the call - * @param id The call identifier - */ - bool answerCall(const CallID& id); - - /** - * Functions which occur with a user's action - * Hangup the call - * @param id The call identifier - */ - bool hangupCall(const CallID& id); - - - /** - * Functions which occur with a user's action - * Hangup the conference (hangup every participants) - * @param id The call identifier - */ - bool hangupConference(const ConfID& id); - - /** - * Functions which occur with a user's action - * Cancel the call - * @param id The call identifier - */ - bool cancelCall(const CallID& id); - - /** - * Functions which occur with a user's action - * Put the call on hold - * @param id The call identifier - */ - bool onHoldCall(const CallID& id); - - /** - * Functions which occur with a user's action - * Put the call off hold - * @param id The call identifier - */ - bool offHoldCall(const CallID& id); - - /** - * Functions which occur with a user's action - * Transfer the call - * @param id The call identifier - * @param to The recipient of the transfer - */ - bool transferCall(const CallID& id, const std::string& to); - - /** - * Notify the client the transfer is successful - */ - void transferSucceded(); - - /** - * Notify the client that the transfer failed - */ - void transferFailed(); - - /** - * Functions which occur with a user's action - * Refuse the call - * @param id The call identifier - */ - bool refuseCall(const CallID& id); - - /** - * Create a new conference given two participant - * @param the first participant ID - * @param the second participant ID - */ - Conference* createConference(const CallID& id1, const CallID& id2); - - /** - * Delete this conference - * @param the conference ID - */ - void removeConference(const CallID& conference_id); - - /** - * Return the conference id for which this call is attached - * @ param the call id - */ - Conference* getConferenceFromCallID(const CallID& call_id); - - /** - * Hold every participant to a conference - * @param the conference id - */ - void holdConference(const CallID& conferece_id); - - /** - * Unhold all conference participants - * @param the conference id - */ - void unHoldConference(const CallID& conference_id); - - /** - * Test if this id is a conference (usefull to test current call) - * @param the call id - */ - bool isConference(const CallID& call_id); - - /** - * Test if a call id particips to this conference - * @param the call id - */ - bool participToConference(const CallID& call_id); - - /** - * Add a participant to a conference - * @param the call id - * @param the conference id - */ - void addParticipant(const CallID& call_id, const CallID& conference_id); - - /** - * Bind the main participant to a conference (mainly called on a double click action) - * @param the conference id - */ - void addMainParticipant(const CallID& conference_id); - - /** - * Join two participants to create a conference - * @param the fist call id - * @param the second call id - */ - void joinParticipant(const CallID& call_id1, const CallID& call_id2); - - /** - * Detach a participant from a conference, put the call on hold, do not hangup it - * @param call id - * @param the current call id - */ - void detachParticipant(const CallID& call_id, const CallID& current_call_id); - - /** - * Remove the conference participant from a conference - * @param call id - */ - void removeParticipant(const CallID& call_id); - - /** - * Process remaining participant given a conference and the current call id. - * Mainly called when a participant is detached or hagned up - * @param current call id - * @param conference pointer - */ - void processRemainingParticipant(CallID current_call_id, Conference *conf); - - /** - * Join two conference together into one unique conference - */ - void joinConference(const CallID& conf_id1, const CallID& conf_id2); - - void addStream(const CallID& call_id); - - void removeStream(const CallID& call_id); - - /** - * Save config to file - * @return true on success - * false otherwise - */ - bool saveConfig (void); - - /** - * Send registration to all enabled accounts - * @return 0 on registration success - * 1 otherelse - */ - int initRegisterAccounts(); - - /** - * @return true if we tried to register once - */ - bool _hasTriedToRegister; - - /** - * Handle choice of the DTMF-send-way - * @param id: callid of the line. - * @param code: pressed key. - */ - bool sendDtmf(const CallID& id, char code); - - /** - * Play the dtmf-associated sound - * @param code The pressed key - */ - bool playDtmf (char code); - - /** - * Play a ringtone - * @return bool True on success - * false otherwise - */ - bool playTone (); - - /** - * Play a special ringtone ( BUSY ) if there's at least one message on the voice mail - * @return bool True on success - * false otherwise - */ - bool playToneWithMessage (); - - /** - * Acts on the audio streams and audio files - */ - void stopTone (void); - - /** - * When receiving a new incoming call, add it to the callaccount map - * and notify user - * @param call A call pointer - * @param accountId an account id - * @return bool True if the call was added correctly - */ - bool incomingCall(Call* call, const AccountID& accountId); - - /** - * Notify the user that the recipient of the call has answered and the put the - * call in Current state - * @param id The call identifier - */ - void peerAnsweredCall(const CallID& id); - - /** - * Rings back because the outgoing call is ringing and the put the - * call in Ringing state - * @param id The call identifier - */ - void peerRingingCall(const CallID& id); - - /** - * Put the call in Hungup state, remove the call from the list - * @param id The call identifier - */ - void peerHungupCall(const CallID& id); - - /** - * Notify the client with an incoming message - * @param accountId The account identifier - * @param message The content of the message - */ - void incomingMessage(const AccountID& accountId, const std::string& message); - - /** - * Notify the client he has voice mails - * @param accountId The account identifier - * @param nb_msg The number of messages - */ - void startVoiceMessageNotification(const AccountID& accountId, int nb_msg); - - /** - * Notify the client through DBus that registration state has been updated - */ - void connectionStatusNotification(void); - - /** - * ConfigurationManager - Send registration request - * @param accountId The account to register/unregister - * @param enable The flag for the type of registration - * 0 for unregistration request - * 1 for registration request - */ - void sendRegister( const ::std::string& accountId , const int32_t& enable); - - bool getCallStatus(const std::string& sequenceId); - - /** - * Get account list - * @return std::vector<std::string> A list of accoundIDs - */ - std::vector< std::string > getAccountList(); - - /** - * Set the account order in the config file - */ - void setAccountsOrder (const std::string& order); - - /** - * Load the accounts order set by the user from the sflphonedrc config file - * @return std::vector<std::string> A vector containing the account ID's - */ - std::vector<std::string> loadAccountOrder (); - - /** - * Retrieve details about a given account - * @param accountID The account identifier - * @return std::map< std::string, std::string > The account details - */ - std::map< std::string, std::string > getAccountDetails(const AccountID& accountID); - - /** - * Retrieve details about a given call - * @param callID The account identifier - * @return std::map< std::string, std::string > The call details - */ - std::map< std::string, std::string > getCallDetails(const CallID& callID); - - /** - * Get call list - * @return std::vector<std::string> A list of call IDs - */ - std::vector< std::string > getCallList (void); - - /** - * Retrieve details about a given call - * @param callID The account identifier - * @return std::map< std::string, std::string > The call details - */ - std::map< std::string, std::string > getConferenceDetails(const CallID& callID); - - /** - * Get call list - * @return std::vector<std::string> A list of call IDs - */ - std::vector< std::string > getConferenceList (void); - - - /** - * Get a list of participant to a conference - * @return std::vector<std::string> A list of call IDs - */ - std::vector< std::string > getParticipantList (const std::string& confID); - - /** - * Save the details of an existing account, given the account ID - * This will load the configuration map with the given data. - * It will also register/unregister links where the 'Enabled' switched. - * @param accountID The account identifier - * @param details The account parameters - */ - void setAccountDetails( const ::std::string& accountID, - const std::map< ::std::string, ::std::string >& details ); - - /** - * Add a new account, and give it a new account ID automatically - * @param details The new account parameters - * @return The account Id given to the new account - */ - std::string addAccount(const std::map< ::std::string, ::std::string >& details); - - /** - * Delete an existing account, unregister VoIPLink associated, and - * purge from configuration. - * @param accountID The account unique ID - */ - void removeAccount(const AccountID& accountID); - - - /** - * Deletes all credentials defined for an account - * @param accountID The account unique ID - */ - void deleteAllCredential(const AccountID& accountID); - - /** - * Get current codec name - * @param call id - * @return std::string The codec name - */ - std::string getCurrentCodecName(const CallID& id); - - /** - * Set input audio plugin - * @param audioPlugin The audio plugin - */ - void setInputAudioPlugin(const std::string& audioPlugin); - - /** - * Set output audio plugin - * @param audioPlugin The audio plugin - */ - void setOutputAudioPlugin(const std::string& audioPlugin); - - /** - * Get list of supported audio output device - * @return std::vector<std::string> A list of the audio devices supporting playback - */ - std::vector<std::string> getAudioOutputDeviceList(void); - - /** - * Set audio device - * @param index The index of the soundcard - * @param the type of stream, either SFL_PCM_PLAYBACK, SFL_PCM_CAPTURE, SFL_PCM_RINGTONE - */ - void setAudioDevice(const int index, const int streamType); - - /** - * Get list of supported audio input device - * @return std::vector<std::string> A list of the audio devices supporting capture - */ - std::vector<std::string> getAudioInputDeviceList(void); - - /** - * Get string array representing integer indexes of output and input device - * @return std::vector<std::string> A list of the current audio devices - */ - std::vector<std::string> getCurrentAudioDevicesIndex(); - - /** - * Get index of an audio device - * @param name The string description of an audio device - * @return int His index - */ - int getAudioDeviceIndex( const std::string name ); - - /** - * Get current alsa plugin - * @return std::string The Alsa plugin - */ - std::string getCurrentAudioOutputPlugin( void ); - - std::string getEchoCancelState(void); - - void setEchoCancelState(std::string state); - - std::string getNoiseSuppressState(void); - - void setNoiseSuppressState(std::string state); - - /** - * Convert a list of payload in a special format, readable by the server. - * Required format: payloads separated with one slash. - * @return std::string The serializabled string - */ - std::string serialize(std::vector<std::string> v); - - std::vector<std::string> unserialize(std::string v); - - /** - * Tells if IAX2 support is enabled - * @return int 1 if IAX2 is enabled - * 0 otherwise - */ - int isIax2Enabled( void ); - - /** - * Ringtone option. - * If ringtone is enabled, ringtone on incoming call use custom choice. If not, only standart tone. - * @return int 1 if enabled - * 0 otherwise - */ - int isRingtoneEnabled( const AccountID& id ); - - /** - * Set the ringtone option - * Inverse current value - */ - void ringtoneEnabled( const AccountID& id ); - - /** - * Get the ringtone - * @return gchar* The file name selected as a ringtone - */ - std::string getRingtoneChoice( const AccountID& id); - - /** - * Set a ringtone - * @param tone The file name of the ringtone - */ - void setRingtoneChoice( const std::string&, const AccountID& id); - - /** - * Get the recording path from configuration tree - * @return the string correspoding to the path - */ - std::string getRecordPath( void ); - - /** - * Set the recoding path in the configuration tree - * @param a string reresenting the path - */ - void setRecordPath( const std::string& recPath); - - /** - * Set a credential for a given account. If it - * does not exist yet, it will be created. - */ - void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details); - - /** - * Retreive the value set in the configuration file. - * @return True if credentials hashing is enabled. - */ - bool getMd5CredentialHashing(void); - - /** - * Tells if the user wants to display the dialpad or not - * @return int 1 if dialpad has to be displayed - * 0 otherwise - */ - // int getDialpad( void ); - - /** - * Set the dialpad visible or not - */ - // void setDialpad (bool display); - - /** - * Tells if the user wants to display the volume controls or not - * @return int 1 if the controls have to be displayed - * 0 otherwise - */ - // int getVolumeControls( void ); - - /** - * Set the volume controls ( mic and speaker ) visible or not - */ - // void setVolumeControls (bool display); - - /** - * Set recording on / off - * Start recording - * @param id The call identifier - */ - void setRecordingCall(const CallID& id); - - /** - * Return true if the call is currently recorded - */ - bool isRecording(const CallID& id); - - /** - * Set the maximum number of days to keep in the history - * @param calls The number of days - */ - void setHistoryLimit (const int& days); - - /** - * Get the maximum number of days to keep in the history - * @return double The number of days - */ - int getHistoryLimit (void); - - // void setHistoryEnabled (void); - - // std::string getHistoryEnabled (void); - - - /** - * Configure the start-up option - * @return int 1 if SFLphone should start in the system tray - * 0 otherwise - */ - int isStartHidden( void ); - - /** - * Configure the start-up option - * At startup, SFLphone can be displayed or start hidden in the system tray - */ - void startHidden( void ); - - /** - * Configure the popup behaviour - * @return int 1 if it should popup on incoming calls - * 0 if it should never popups - */ - // int popupMode( void ); - - /** - * Configure the popup behaviour - * When SFLphone is in the system tray, you can configure when it popups - * Never or only on incoming calls - */ - // void switchPopupMode( void ); - - /** - * Determine whether or not the search bar (history) should be displayed - */ - // int getSearchbar( void ); - - /** - * Configure the search bar behaviour - */ - // void setSearchbar( void ); - - /** - * Set the desktop notification level - */ - // void setNotify( void ); - - /** - * Get the desktop notification level - * @return int The notification level - */ - // int32_t getNotify( void ); - - /** - * Set the desktop mail notification level - */ - void setMailNotify( void ); - - - /** - * Addressbook configuration - */ - std::map<std::string, int32_t> getAddressbookSettings (void); - - /** - * Addressbook configuration - */ - void setAddressbookSettings (const std::map<std::string, int32_t>& settings); - - /** - * Addressbook list - */ - void setAddressbookList(const std::vector< std::string >& list); - - /** - * Addressbook list - */ - std::vector <std::string> getAddressbookList( void ); - - /** - * Hook configuration - */ - std::map<std::string, std::string> getHookSettings (void); - - /** - * Hook configuration - */ - void setHookSettings (const std::map<std::string, std::string>& settings); - - - /** - * Get the audio manager - * @return int The audio manager - * 0 ALSA - * 1 PULSEAUDIO - */ - int32_t getAudioManager( void ); - - /** - * Set the audio manager - */ - void setAudioManager( const int32_t& api ); - - void switchAudioManager( void ); - - void audioSamplingRateChanged( void ); - - /** - * Get the desktop mail notification level - * @return int The mail notification level - */ - int32_t getMailNotify( void ); - - /** - * Retrieve the formatted list of codecs payload in the user config file and - * load in the active list of codecs - * @return std::vector<std::string> The vector containing the active codecs - */ - std::vector<std::string> retrieveActiveCodecs( void ); - - /** - * Get the list of the active codecs - * @return std::vector< ::std::string > The list of active codecs - */ - std::vector< ::std::string > getActiveCodecList( void ); - - /* - * Notify the client that an error occured - * @param errCode The error code. Could be: ALSA_CAPTURE_ERROR - * ALSA_PLAYBACK_ERROR - */ - void notifyErrClient( const int32_t& errCode ); - - /** - * Retrieve in the configuration tree the value of a parameter in a specific section - * @param section The section to look in - * @param name The name of the parameter you want to get - * @param arg Undocumented - * @return bool true on success - * false otherwise - */ - bool getConfig(const std::string& section, const std::string& name, TokenList& arg); - - /** - * Change a specific value in the configuration tree. - * This value will then be saved in the user config file sflphonedrc - * @param section The section name - * @param name The parameter name - * @param value The new string value - * @return bool true on success - * false otherwise - */ - bool setConfig(const std::string& section, const std::string& name, const std::string& value); - - /** - * Change a specific value in the configuration tree. - * This value will then be saved in the user config file sflphonedrc - * @param section The section name - * @param name The parameter name - * @param value The new int value - * @return bool true on success - * false otherwise - */ - bool setConfig(const std::string& section, const std::string& name, int value); - - inline std::string mapStateNumberToString(RegistrationState state) { - std::string stringRepresentation; - if (state > NumberOfState) { - stringRepresentation = "ERROR"; +class ManagerImpl +{ + public: + ManagerImpl (void); + ~ManagerImpl (void); + + + /** + * General preferences configuration + */ + Preferences preferences; + + /** + * Voip related preferences + */ + VoipPreference voipPreferences; + + /** + * Addressbook related preferences + */ + AddressbookPreference addressbookPreference; + + /** + * Hook preferences + */ + HookPreference hookPreference; + + /** + * Audio preferences + */ + AudioPreference audioPreference; + + /** + * Shortcut preferences + */ + ShortcutPreferences shortcutPreferences; + + /** + * Method to build preferences from configuration + */ + short buildConfiguration(); + + /** + * Initialisation of thread (sound) and map. + * Init a new VoIPLink, audio codec and audio driver + */ + void init (void); + + /** + * Terminate all thread (sound, link) and unload AccountMap + */ + void terminate (void); + + /** + * Set user interface manager. + * @param man The DBUS interface implementation + */ + void setDBusManager (DBusManagerImpl* man) { + _dbus = man; + } + + /** + * Accessor to audiodriver. + * it's multi-thread and use mutex internally + * @return AudioLayer* The audio layer object + */ + AudioLayer* getAudioDriver (void) const { + return _audiodriver; + } + + /** + * Get a descriptor map of codec available + * @return CodecDescriptor The internal codec map + */ + CodecDescriptor& getCodecDescriptorMap (void) { + return _codecDescriptorMap; + } + + /** + * Functions which occur with a user's action + * Place a new call + * @param accountId The account to make tha call with + * @param id The call identifier + * @param to The recipient of the call + * @return bool true on success + * false otherwise + */ + bool outgoingCall (const AccountID& accountId, const CallID& id, const std::string& to); + + /** + * Functions which occur with a user's action + * Answer the call + * @param id The call identifier + */ + bool answerCall (const CallID& id); + + /** + * Functions which occur with a user's action + * Hangup the call + * @param id The call identifier + */ + bool hangupCall (const CallID& id); + + + /** + * Functions which occur with a user's action + * Hangup the conference (hangup every participants) + * @param id The call identifier + */ + bool hangupConference (const ConfID& id); + + /** + * Functions which occur with a user's action + * Cancel the call + * @param id The call identifier + */ + bool cancelCall (const CallID& id); + + /** + * Functions which occur with a user's action + * Put the call on hold + * @param id The call identifier + */ + bool onHoldCall (const CallID& id); + + /** + * Functions which occur with a user's action + * Put the call off hold + * @param id The call identifier + */ + bool offHoldCall (const CallID& id); + + /** + * Functions which occur with a user's action + * Transfer the call + * @param id The call identifier + * @param to The recipient of the transfer + */ + bool transferCall (const CallID& id, const std::string& to); + + /** + * Notify the client the transfer is successful + */ + void transferSucceded(); + + /** + * Notify the client that the transfer failed + */ + void transferFailed(); + + /** + * Functions which occur with a user's action + * Refuse the call + * @param id The call identifier + */ + bool refuseCall (const CallID& id); + + /** + * Create a new conference given two participant + * @param the first participant ID + * @param the second participant ID + */ + Conference* createConference (const CallID& id1, const CallID& id2); + + /** + * Delete this conference + * @param the conference ID + */ + void removeConference (const CallID& conference_id); + + /** + * Return the conference id for which this call is attached + * @ param the call id + */ + Conference* getConferenceFromCallID (const CallID& call_id); + + /** + * Hold every participant to a conference + * @param the conference id + */ + void holdConference (const CallID& conferece_id); + + /** + * Unhold all conference participants + * @param the conference id + */ + void unHoldConference (const CallID& conference_id); + + /** + * Test if this id is a conference (usefull to test current call) + * @param the call id + */ + bool isConference (const CallID& call_id); + + /** + * Test if a call id particips to this conference + * @param the call id + */ + bool participToConference (const CallID& call_id); + + /** + * Add a participant to a conference + * @param the call id + * @param the conference id + */ + void addParticipant (const CallID& call_id, const CallID& conference_id); + + /** + * Bind the main participant to a conference (mainly called on a double click action) + * @param the conference id + */ + void addMainParticipant (const CallID& conference_id); + + /** + * Join two participants to create a conference + * @param the fist call id + * @param the second call id + */ + void joinParticipant (const CallID& call_id1, const CallID& call_id2); + + /** + * Detach a participant from a conference, put the call on hold, do not hangup it + * @param call id + * @param the current call id + */ + void detachParticipant (const CallID& call_id, const CallID& current_call_id); + + /** + * Remove the conference participant from a conference + * @param call id + */ + void removeParticipant (const CallID& call_id); + + /** + * Process remaining participant given a conference and the current call id. + * Mainly called when a participant is detached or hagned up + * @param current call id + * @param conference pointer + */ + void processRemainingParticipant (CallID current_call_id, Conference *conf); + + /** + * Join two conference together into one unique conference + */ + void joinConference (const CallID& conf_id1, const CallID& conf_id2); + + void addStream (const CallID& call_id); + + void removeStream (const CallID& call_id); + + /** + * Save config to file + * @return true on success + * false otherwise + */ + bool saveConfig (void); + + /** + * Send registration to all enabled accounts + * @return 0 on registration success + * 1 otherelse + */ + int initRegisterAccounts(); + + /** + * @return true if we tried to register once + */ + bool _hasTriedToRegister; + + /** + * Handle choice of the DTMF-send-way + * @param id: callid of the line. + * @param code: pressed key. + */ + bool sendDtmf (const CallID& id, char code); + + /** + * Play the dtmf-associated sound + * @param code The pressed key + */ + bool playDtmf (char code); + + /** + * Play a ringtone + * @return bool True on success + * false otherwise + */ + bool playTone (); + + /** + * Play a special ringtone ( BUSY ) if there's at least one message on the voice mail + * @return bool True on success + * false otherwise + */ + bool playToneWithMessage (); + + /** + * Acts on the audio streams and audio files + */ + void stopTone (void); + + /** + * When receiving a new incoming call, add it to the callaccount map + * and notify user + * @param call A call pointer + * @param accountId an account id + * @return bool True if the call was added correctly + */ + bool incomingCall (Call* call, const AccountID& accountId); + + /** + * Notify the user that the recipient of the call has answered and the put the + * call in Current state + * @param id The call identifier + */ + void peerAnsweredCall (const CallID& id); + + /** + * Rings back because the outgoing call is ringing and the put the + * call in Ringing state + * @param id The call identifier + */ + void peerRingingCall (const CallID& id); + + /** + * Put the call in Hungup state, remove the call from the list + * @param id The call identifier + */ + void peerHungupCall (const CallID& id); + + /** + * Notify the client with an incoming message + * @param accountId The account identifier + * @param message The content of the message + */ + void incomingMessage (const AccountID& accountId, const std::string& message); + + /** + * Notify the client he has voice mails + * @param accountId The account identifier + * @param nb_msg The number of messages + */ + void startVoiceMessageNotification (const AccountID& accountId, int nb_msg); + + /** + * Notify the client through DBus that registration state has been updated + */ + void connectionStatusNotification (void); + + /** + * ConfigurationManager - Send registration request + * @param accountId The account to register/unregister + * @param enable The flag for the type of registration + * 0 for unregistration request + * 1 for registration request + */ + void sendRegister (const ::std::string& accountId , const int32_t& enable); + + bool getCallStatus (const std::string& sequenceId); + + /** + * Get account list + * @return std::vector<std::string> A list of accoundIDs + */ + std::vector< std::string > getAccountList(); + + /** + * Set the account order in the config file + */ + void setAccountsOrder (const std::string& order); + + /** + * Load the accounts order set by the user from the sflphonedrc config file + * @return std::vector<std::string> A vector containing the account ID's + */ + std::vector<std::string> loadAccountOrder (); + + /** + * Retrieve details about a given account + * @param accountID The account identifier + * @return std::map< std::string, std::string > The account details + */ + std::map< std::string, std::string > getAccountDetails (const AccountID& accountID); + + /** + * Retrieve details about a given call + * @param callID The account identifier + * @return std::map< std::string, std::string > The call details + */ + std::map< std::string, std::string > getCallDetails (const CallID& callID); + + /** + * Get call list + * @return std::vector<std::string> A list of call IDs + */ + std::vector< std::string > getCallList (void); + + /** + * Retrieve details about a given call + * @param callID The account identifier + * @return std::map< std::string, std::string > The call details + */ + std::map< std::string, std::string > getConferenceDetails (const CallID& callID); + + /** + * Get call list + * @return std::vector<std::string> A list of call IDs + */ + std::vector< std::string > getConferenceList (void); + + + /** + * Get a list of participant to a conference + * @return std::vector<std::string> A list of call IDs + */ + std::vector< std::string > getParticipantList (const std::string& confID); + + /** + * Save the details of an existing account, given the account ID + * This will load the configuration map with the given data. + * It will also register/unregister links where the 'Enabled' switched. + * @param accountID The account identifier + * @param details The account parameters + */ + void setAccountDetails (const ::std::string& accountID, + const std::map< ::std::string, ::std::string >& details); + + /** + * Add a new account, and give it a new account ID automatically + * @param details The new account parameters + * @return The account Id given to the new account + */ + std::string addAccount (const std::map< ::std::string, ::std::string >& details); + + /** + * Delete an existing account, unregister VoIPLink associated, and + * purge from configuration. + * @param accountID The account unique ID + */ + void removeAccount (const AccountID& accountID); + + + /** + * Deletes all credentials defined for an account + * @param accountID The account unique ID + */ + void deleteAllCredential (const AccountID& accountID); + + /** + * Get current codec name + * @param call id + * @return std::string The codec name + */ + std::string getCurrentCodecName (const CallID& id); + + /** + * Set input audio plugin + * @param audioPlugin The audio plugin + */ + void setInputAudioPlugin (const std::string& audioPlugin); + + /** + * Set output audio plugin + * @param audioPlugin The audio plugin + */ + void setOutputAudioPlugin (const std::string& audioPlugin); + + /** + * Get list of supported audio output device + * @return std::vector<std::string> A list of the audio devices supporting playback + */ + std::vector<std::string> getAudioOutputDeviceList (void); + + /** + * Set audio device + * @param index The index of the soundcard + * @param the type of stream, either SFL_PCM_PLAYBACK, SFL_PCM_CAPTURE, SFL_PCM_RINGTONE + */ + void setAudioDevice (const int index, const int streamType); + + /** + * Get list of supported audio input device + * @return std::vector<std::string> A list of the audio devices supporting capture + */ + std::vector<std::string> getAudioInputDeviceList (void); + + /** + * Get string array representing integer indexes of output and input device + * @return std::vector<std::string> A list of the current audio devices + */ + std::vector<std::string> getCurrentAudioDevicesIndex(); + + /** + * Get index of an audio device + * @param name The string description of an audio device + * @return int His index + */ + int getAudioDeviceIndex (const std::string name); + + /** + * Get current alsa plugin + * @return std::string The Alsa plugin + */ + std::string getCurrentAudioOutputPlugin (void); + + std::string getEchoCancelState (void); + + void setEchoCancelState (std::string state); + + std::string getNoiseSuppressState (void); + + void setNoiseSuppressState (std::string state); + + /** + * Convert a list of payload in a special format, readable by the server. + * Required format: payloads separated with one slash. + * @return std::string The serializabled string + */ + std::string serialize (std::vector<std::string> v); + + std::vector<std::string> unserialize (std::string v); + + /** + * Tells if IAX2 support is enabled + * @return int 1 if IAX2 is enabled + * 0 otherwise + */ + int isIax2Enabled (void); + + /** + * Ringtone option. + * If ringtone is enabled, ringtone on incoming call use custom choice. If not, only standart tone. + * @return int 1 if enabled + * 0 otherwise + */ + int isRingtoneEnabled (const AccountID& id); + + /** + * Set the ringtone option + * Inverse current value + */ + void ringtoneEnabled (const AccountID& id); + + /** + * Get the ringtone + * @return gchar* The file name selected as a ringtone + */ + std::string getRingtoneChoice (const AccountID& id); + + /** + * Set a ringtone + * @param tone The file name of the ringtone + */ + void setRingtoneChoice (const std::string&, const AccountID& id); + + /** + * Get the recording path from configuration tree + * @return the string correspoding to the path + */ + std::string getRecordPath (void); + + /** + * Set the recoding path in the configuration tree + * @param a string reresenting the path + */ + void setRecordPath (const std::string& recPath); + + /** + * Set a credential for a given account. If it + * does not exist yet, it will be created. + */ + void setCredential (const std::string& accountID, const int32_t& index, const std::map< std::string, std::string >& details); + + /** + * Retreive the value set in the configuration file. + * @return True if credentials hashing is enabled. + */ + bool getMd5CredentialHashing (void); + + /** + * Tells if the user wants to display the dialpad or not + * @return int 1 if dialpad has to be displayed + * 0 otherwise + */ + // int getDialpad( void ); + + /** + * Set the dialpad visible or not + */ + // void setDialpad (bool display); + + /** + * Tells if the user wants to display the volume controls or not + * @return int 1 if the controls have to be displayed + * 0 otherwise + */ + // int getVolumeControls( void ); + + /** + * Set the volume controls ( mic and speaker ) visible or not + */ + // void setVolumeControls (bool display); + + /** + * Set recording on / off + * Start recording + * @param id The call identifier + */ + void setRecordingCall (const CallID& id); + + /** + * Return true if the call is currently recorded + */ + bool isRecording (const CallID& id); + + /** + * Set the maximum number of days to keep in the history + * @param calls The number of days + */ + void setHistoryLimit (const int& days); + + /** + * Get the maximum number of days to keep in the history + * @return double The number of days + */ + int getHistoryLimit (void); + + // void setHistoryEnabled (void); + + // std::string getHistoryEnabled (void); + + + /** + * Configure the start-up option + * @return int 1 if SFLphone should start in the system tray + * 0 otherwise + */ + int isStartHidden (void); + + /** + * Configure the start-up option + * At startup, SFLphone can be displayed or start hidden in the system tray + */ + void startHidden (void); + + /** + * Configure the popup behaviour + * @return int 1 if it should popup on incoming calls + * 0 if it should never popups + */ + // int popupMode( void ); + + /** + * Configure the popup behaviour + * When SFLphone is in the system tray, you can configure when it popups + * Never or only on incoming calls + */ + // void switchPopupMode( void ); + + /** + * Determine whether or not the search bar (history) should be displayed + */ + // int getSearchbar( void ); + + /** + * Configure the search bar behaviour + */ + // void setSearchbar( void ); + + /** + * Set the desktop notification level + */ + // void setNotify( void ); + + /** + * Get the desktop notification level + * @return int The notification level + */ + // int32_t getNotify( void ); + + /** + * Set the desktop mail notification level + */ + void setMailNotify (void); + + + /** + * Addressbook configuration + */ + std::map<std::string, int32_t> getAddressbookSettings (void); + + /** + * Addressbook configuration + */ + void setAddressbookSettings (const std::map<std::string, int32_t>& settings); + + /** + * Addressbook list + */ + void setAddressbookList (const std::vector< std::string >& list); + + /** + * Addressbook list + */ + std::vector <std::string> getAddressbookList (void); + + /** + * Hook configuration + */ + std::map<std::string, std::string> getHookSettings (void); + + /** + * Hook configuration + */ + void setHookSettings (const std::map<std::string, std::string>& settings); + + + /** + * Get the audio manager + * @return int The audio manager + * 0 ALSA + * 1 PULSEAUDIO + */ + int32_t getAudioManager (void); + + /** + * Set the audio manager + */ + void setAudioManager (const int32_t& api); + + void switchAudioManager (void); + + void audioSamplingRateChanged (void); + + /** + * Get the desktop mail notification level + * @return int The mail notification level + */ + int32_t getMailNotify (void); + + /** + * Retrieve the formatted list of codecs payload in the user config file and + * load in the active list of codecs + * @return std::vector<std::string> The vector containing the active codecs + */ + std::vector<std::string> retrieveActiveCodecs (void); + + /** + * Get the list of the active codecs + * @return std::vector< ::std::string > The list of active codecs + */ + std::vector< ::std::string > getActiveCodecList (void); + + /* + * Notify the client that an error occured + * @param errCode The error code. Could be: ALSA_CAPTURE_ERROR + * ALSA_PLAYBACK_ERROR + */ + void notifyErrClient (const int32_t& errCode); + + /** + * Retrieve in the configuration tree the value of a parameter in a specific section + * @param section The section to look in + * @param name The name of the parameter you want to get + * @param arg Undocumented + * @return bool true on success + * false otherwise + */ + bool getConfig (const std::string& section, const std::string& name, TokenList& arg); + + /** + * Change a specific value in the configuration tree. + * This value will then be saved in the user config file sflphonedrc + * @param section The section name + * @param name The parameter name + * @param value The new string value + * @return bool true on success + * false otherwise + */ + bool setConfig (const std::string& section, const std::string& name, const std::string& value); + + /** + * Change a specific value in the configuration tree. + * This value will then be saved in the user config file sflphonedrc + * @param section The section name + * @param name The parameter name + * @param value The new int value + * @return bool true on success + * false otherwise + */ + bool setConfig (const std::string& section, const std::string& name, int value); + + inline std::string mapStateNumberToString (RegistrationState state) { + std::string stringRepresentation; + + if (state > NumberOfState) { + stringRepresentation = "ERROR"; + return stringRepresentation; + } + + stringRepresentation = mapStateToChar[state]; return stringRepresentation; } - - stringRepresentation = mapStateToChar[state]; - return stringRepresentation; - } - - /** - * Get a int from the configuration tree - * Throw an Conf::ConfigTreeItemException if not found - * @param section The section name to look in - * @param name The parameter name - * @return int The int value - */ - - int getConfigInt(const std::string& section, const std::string& name); - - /** - * Get a bool from the configuration tree - * Throw an Conf::ConfigTreeItemException if not found - * @param section The section name to look in - * @param name The parameter name - * @return bool The bool value - */ - - bool getConfigBool(const std::string& section, const std::string& name); - - /** - * Get a string from the configuration tree - * Throw an Conf::ConfigTreeItemException if not found - * @param section The section name to look in - * @param name The parameter name - * @return sdt::string The string value - */ - std::string getConfigString(const std::string& section, const std::string& name); - - /** - * Retrieve the soundcards index in the user config file and try to open audio devices - * with a specific alsa plugin. - * Set the audio layer sample rate - */ - void selectAudioDriver(void); - - /** - * Handle audio sounds heard by a caller while they wait for their - * connection to a called party to be completed. - */ - void ringback (); - - /** - * Handle played music when an incoming call occurs - */ - void ringtone (const AccountID& accountID); - - /** - * Handle played music when a congestion occurs - */ - void congestion (); - - /** - * Handle played sound when a call can not be conpleted because of a busy recipient - */ - void callBusy(const CallID& id); - - /** - * Handle played sound when a failure occurs - */ - void callFailure(const CallID& id); - - /** - * Retrieve the current telephone tone - * @return AudioLoop* The audio tone or 0 if no tone (init before calling this function) - */ - AudioLoop* getTelephoneTone(); - - /** - * Retrieve the current telephone file - * @return AudioLoop* The audio file or 0 if the wav is stopped - */ - AudioLoop* getTelephoneFile(); - - /** - * @return true is there is one or many incoming call waiting - * new call, not anwsered or refused - */ - bool incomingCallWaiting(void); - - /** - * Notification of incoming call when you are already busy - */ - void notificationIncomingCall(void); - - /* - * Inline functions to manage speaker volume control - * Read by main thread and AudioLayer thread - * Write by main thread only - * @return unsigned short The volume value - */ - unsigned short getSpkrVolume(void) { return _spkr_volume; } - - /* - * Inline functions to manage speaker volume control - * Read by main thread and AudioLayer thread - * Write by main thread only - * @param spkr_vol The volume value - */ - void setSpkrVolume(unsigned short spkr_vol); - - /* - * Inline functions to manage mic volume control - * Read by main thread and AudioLayer thread - * Write by main thread only - * @return unsigned short The volume value - */ - unsigned short getMicVolume(void) { return _mic_volume; } - - /* - * Inline functions to manage mic volume control - * Read by main thread and AudioLayer thread - * Write by main thread only - * @param mic_vol The volume value - */ - void setMicVolume(unsigned short mic_vol); - - /** - * Init default values for the different fields in the config file. - * Fills the local _config (Conf::ConfigTree) with the default contents. - * Called in main.cpp, just before Manager::init(). - */ - void initConfigFile ( bool load_user_value=true, std::string alternate=""); - - /** - * Tell if the setup was already loaded - * @return bool True if yes - * false otherwise - */ - bool hasLoadedSetup() { return _setupLoaded; } - - /** - * Return a new random callid that is not present in the list - * @return CallID A brand new callid - */ - CallID getNewCallID(); - - /** - * Get the current call id - * @return CallID The call id or "" - */ - const CallID& getCurrentCallId(); - - /** - * Check if a call is the current one - * @param callId the new callid - * @return bool True if the id is the current call - */ - bool isCurrentCall(const CallID& callId); - - - /** - * Send registration to all enabled accounts - * @return 0 on registration success - * 1 otherelse - */ - int registerAccounts(); - - /** - * Restart PJSIP - * @param void - * @return void - */ - void restartPJSIP( ); - - void unregisterCurSIPAccounts (void); - - void registerCurSIPAccounts (void); - - /* - * Initialize audiodriver - */ - bool initAudioDriver(void); - - ost::Mutex* getAudioLayerMutex() { return &_audiolayer_mutex; } - - /** - * Helper function that creates an MD5 Hash from the credential - * information provided as parameters. The hash is computed as - * MD5(username ":" realm ":" password). - * - */ - std::string computeMd5HashFromCredential(const std::string& username, const std::string& password, const std::string& realm); - - private: - /* Transform digest to string. - * output must be at least PJSIP_MD5STRLEN+1 bytes. - * Helper function taken from sip_auth_client.c in - * pjproject-1.0.3. - * - * NOTE: THE OUTPUT STRING IS NOT NULL TERMINATED! - */ - void digest2str(const unsigned char digest[], char *output); - - /** - * Check if a process is running with the system command - * - * @return 0 on success - * 1 otherelse - */ - int app_is_running(std::string process); - - /** - * Create .PROGNAME directory in home user and create - * configuration tree from the settings file if this file exists. - * - * @return 0 if creating file failed - * 1 if config-file exists - * 2 if file doesn't exist yet. - */ - int createSettingsPath (void); - - /* - * Initialize audiocodec with config setting - */ - void initAudioCodec(void); - - - /* - * Initialize zeroconf module and scanning - */ - void initZeroconf(void); - - /* - * Init the volume for speakers/micro from 0 to 100 value - */ - void initVolume(); - - /** - * Switch of current call id - * @param id The new callid - */ - void switchCall(const CallID& id); - - /* - * Play one tone - * @return false if the driver is uninitialize - */ - bool playATone(Tone::TONEID toneId); - - /** The configuration tree. It contains accounts parameters, general user settings ,audio settings, ... */ - Conf::ConfigTree _config; - - /** Current Call ID */ - CallID _currentCallId2; - - /** Protected current call access */ - ost::Mutex _currentCallMutex; - - /** Vector of CodecDescriptor */ - CodecDescriptor* _codecBuilder; - - /** Audio layer */ - AudioLayer* _audiodriver; - - // Main thread - - DTMF* _dtmfKey; - - // map of codec (for configlist request) - CodecDescriptor _codecDescriptorMap; - - ///////////////////// - // Protected by Mutex - ///////////////////// - ost::Mutex _toneMutex; - TelephoneTone* _telephoneTone; - AudioFile _audiofile; - - // To handle volume control - short _spkr_volume; - short _mic_volume; - // End of sound variable - - - // Multithread variable (protected by _mutex) - // - /** Mutex to protect access to code section */ - ost::Mutex _mutex; - - ost::Mutex _audiolayer_mutex; - - // Multithread variable (non protected) - DBusManagerImpl * _dbus; - - /** Waiting Call Vectors */ - CallIDSet _waitingCall; - - /** Protect waiting call list, access by many voip/audio threads */ - ost::Mutex _waitingCallMutex; - - /** Number of waiting call, synchronize with waitingcall callidvector */ - unsigned int _nbIncomingWaitingCall; - - /** - * Add incoming callid to the waiting list - * @param id CallID to add - */ - void addWaitingCall(const CallID& id); - - /** - * Remove incoming callid to the waiting list - * @param id CallID to remove - */ - void removeWaitingCall(const CallID& id); - - /** - * Tell if a call is waiting and should be remove - * @param id CallID to test - * @return bool True if the call is waiting - */ - bool isWaitingCall(const CallID& id); - - /** - * Path of the ConfigFile - */ - std::string _path; - int _exist; - int _setupLoaded; + + /** + * Get a int from the configuration tree + * Throw an Conf::ConfigTreeItemException if not found + * @param section The section name to look in + * @param name The parameter name + * @return int The int value + */ + + int getConfigInt (const std::string& section, const std::string& name); + + /** + * Get a bool from the configuration tree + * Throw an Conf::ConfigTreeItemException if not found + * @param section The section name to look in + * @param name The parameter name + * @return bool The bool value + */ + + bool getConfigBool (const std::string& section, const std::string& name); + + /** + * Get a string from the configuration tree + * Throw an Conf::ConfigTreeItemException if not found + * @param section The section name to look in + * @param name The parameter name + * @return sdt::string The string value + */ + std::string getConfigString (const std::string& section, const std::string& name); + + /** + * Retrieve the soundcards index in the user config file and try to open audio devices + * with a specific alsa plugin. + * Set the audio layer sample rate + */ + void selectAudioDriver (void); + + /** + * Handle audio sounds heard by a caller while they wait for their + * connection to a called party to be completed. + */ + void ringback (); + + /** + * Handle played music when an incoming call occurs + */ + void ringtone (const AccountID& accountID); + + /** + * Handle played music when a congestion occurs + */ + void congestion (); + + /** + * Handle played sound when a call can not be conpleted because of a busy recipient + */ + void callBusy (const CallID& id); + + /** + * Handle played sound when a failure occurs + */ + void callFailure (const CallID& id); + + /** + * Retrieve the current telephone tone + * @return AudioLoop* The audio tone or 0 if no tone (init before calling this function) + */ + AudioLoop* getTelephoneTone(); + + /** + * Retrieve the current telephone file + * @return AudioLoop* The audio file or 0 if the wav is stopped + */ + AudioLoop* getTelephoneFile(); + + /** + * @return true is there is one or many incoming call waiting + * new call, not anwsered or refused + */ + bool incomingCallWaiting (void); + + /** + * Notification of incoming call when you are already busy + */ + void notificationIncomingCall (void); + + /* + * Inline functions to manage speaker volume control + * Read by main thread and AudioLayer thread + * Write by main thread only + * @return unsigned short The volume value + */ + unsigned short getSpkrVolume (void) { + return _spkr_volume; + } + + /* + * Inline functions to manage speaker volume control + * Read by main thread and AudioLayer thread + * Write by main thread only + * @param spkr_vol The volume value + */ + void setSpkrVolume (unsigned short spkr_vol); + + /* + * Inline functions to manage mic volume control + * Read by main thread and AudioLayer thread + * Write by main thread only + * @return unsigned short The volume value + */ + unsigned short getMicVolume (void) { + return _mic_volume; + } + + /* + * Inline functions to manage mic volume control + * Read by main thread and AudioLayer thread + * Write by main thread only + * @param mic_vol The volume value + */ + void setMicVolume (unsigned short mic_vol); + + /** + * Init default values for the different fields in the config file. + * Fills the local _config (Conf::ConfigTree) with the default contents. + * Called in main.cpp, just before Manager::init(). + */ + void initConfigFile (bool load_user_value=true, std::string alternate=""); + + /** + * Tell if the setup was already loaded + * @return bool True if yes + * false otherwise + */ + bool hasLoadedSetup() { + return _setupLoaded; + } + + /** + * Return a new random callid that is not present in the list + * @return CallID A brand new callid + */ + CallID getNewCallID(); + + /** + * Get the current call id + * @return CallID The call id or "" + */ + const CallID& getCurrentCallId(); + + /** + * Check if a call is the current one + * @param callId the new callid + * @return bool True if the id is the current call + */ + bool isCurrentCall (const CallID& callId); + + + /** + * Send registration to all enabled accounts + * @return 0 on registration success + * 1 otherelse + */ + int registerAccounts(); + + /** + * Restart PJSIP + * @param void + * @return void + */ + void restartPJSIP(); + + void unregisterCurSIPAccounts (void); + + void registerCurSIPAccounts (void); + + /* + * Initialize audiodriver + */ + bool initAudioDriver (void); + + ost::Mutex* getAudioLayerMutex() { + return &_audiolayer_mutex; + } + + /** + * Helper function that creates an MD5 Hash from the credential + * information provided as parameters. The hash is computed as + * MD5(username ":" realm ":" password). + * + */ + std::string computeMd5HashFromCredential (const std::string& username, const std::string& password, const std::string& realm); + + private: + /* Transform digest to string. + * output must be at least PJSIP_MD5STRLEN+1 bytes. + * Helper function taken from sip_auth_client.c in + * pjproject-1.0.3. + * + * NOTE: THE OUTPUT STRING IS NOT NULL TERMINATED! + */ + void digest2str (const unsigned char digest[], char *output); + + /** + * Check if a process is running with the system command + * + * @return 0 on success + * 1 otherelse + */ + int app_is_running (std::string process); + + /** + * Create .PROGNAME directory in home user and create + * configuration tree from the settings file if this file exists. + * + * @return 0 if creating file failed + * 1 if config-file exists + * 2 if file doesn't exist yet. + */ + int createSettingsPath (void); + + /* + * Initialize audiocodec with config setting + */ + void initAudioCodec (void); + + + /* + * Initialize zeroconf module and scanning + */ + void initZeroconf (void); + + /* + * Init the volume for speakers/micro from 0 to 100 value + */ + void initVolume(); + + /** + * Switch of current call id + * @param id The new callid + */ + void switchCall (const CallID& id); + + /* + * Play one tone + * @return false if the driver is uninitialize + */ + bool playATone (Tone::TONEID toneId); + + /** The configuration tree. It contains accounts parameters, general user settings ,audio settings, ... */ + Conf::ConfigTree _config; + + /** Current Call ID */ + CallID _currentCallId2; + + /** Protected current call access */ + ost::Mutex _currentCallMutex; + + /** Vector of CodecDescriptor */ + CodecDescriptor* _codecBuilder; + + /** Audio layer */ + AudioLayer* _audiodriver; + + // Main thread + + DTMF* _dtmfKey; + + // map of codec (for configlist request) + CodecDescriptor _codecDescriptorMap; + + ///////////////////// + // Protected by Mutex + ///////////////////// + ost::Mutex _toneMutex; + TelephoneTone* _telephoneTone; + AudioFile _audiofile; + + // To handle volume control + short _spkr_volume; + short _mic_volume; + // End of sound variable + + + // Multithread variable (protected by _mutex) + // + /** Mutex to protect access to code section */ + ost::Mutex _mutex; + + ost::Mutex _audiolayer_mutex; + + // Multithread variable (non protected) + DBusManagerImpl * _dbus; + + /** Waiting Call Vectors */ + CallIDSet _waitingCall; + + /** Protect waiting call list, access by many voip/audio threads */ + ost::Mutex _waitingCallMutex; + + /** Number of waiting call, synchronize with waitingcall callidvector */ + unsigned int _nbIncomingWaitingCall; + + /** + * Add incoming callid to the waiting list + * @param id CallID to add + */ + void addWaitingCall (const CallID& id); + + /** + * Remove incoming callid to the waiting list + * @param id CallID to remove + */ + void removeWaitingCall (const CallID& id); + + /** + * Tell if a call is waiting and should be remove + * @param id CallID to test + * @return bool True if the call is waiting + */ + bool isWaitingCall (const CallID& id); + + /** + * Path of the ConfigFile + */ + std::string _path; + int _exist; + int _setupLoaded; #ifdef USE_ZEROCONF - // DNSService contain every zeroconf services - // configuration detected on the network - DNSService *_DNSService; + // DNSService contain every zeroconf services + // configuration detected on the network + DNSService *_DNSService; #endif - /** Map to associate a CallID to the good account */ - CallAccountMap _callAccountMap; - - /** Mutex to lock the call account map (main thread + voiplink thread) */ - ost::Mutex _callAccountMapMutex; - - CallConfigMap _callConfigMap; - - bool associateConfigToCall (const CallID& callID, Call::CallConfiguration config); - - Call::CallConfiguration getConfigFromCall(const CallID& callID); - - bool removeCallConfig(const CallID& callID); - - /** Associate a new CallID to a AccountID - * Protected by mutex - * @param callID the new CallID not in the list yet - * @param accountID the known accountID present in accountMap - * @return bool True if the new association is create - */ - bool associateCallToAccount(const CallID& callID, const AccountID& accountID); - - /** Remove a CallID/AccountID association - * Protected by mutex - * @param callID the CallID to remove - * @return bool True if association is removed - */ - bool removeCallAccount(const CallID& callID); - - /** - *Contains a list of account (sip, aix, etc) and their respective voiplink/calls */ - AccountMap _accountMap; - - Account * _directIpAccount; - - void loadIptoipProfile(); - - /** - * Load the account from configuration - * @return short Number of account - */ - short loadAccountMap(); - - /** - * Unload the account (delete them) - */ - void unloadAccountMap(); + /** Map to associate a CallID to the good account */ + CallAccountMap _callAccountMap; + + /** Mutex to lock the call account map (main thread + voiplink thread) */ + ost::Mutex _callAccountMapMutex; + + CallConfigMap _callConfigMap; + + bool associateConfigToCall (const CallID& callID, Call::CallConfiguration config); + + Call::CallConfiguration getConfigFromCall (const CallID& callID); + + bool removeCallConfig (const CallID& callID); + + /** Associate a new CallID to a AccountID + * Protected by mutex + * @param callID the new CallID not in the list yet + * @param accountID the known accountID present in accountMap + * @return bool True if the new association is create + */ + bool associateCallToAccount (const CallID& callID, const AccountID& accountID); + + /** Remove a CallID/AccountID association + * Protected by mutex + * @param callID the CallID to remove + * @return bool True if association is removed + */ + bool removeCallAccount (const CallID& callID); + + /** + *Contains a list of account (sip, aix, etc) and their respective voiplink/calls */ + AccountMap _accountMap; + + Account * _directIpAccount; + + void loadIptoipProfile(); + + /** + * Load the account from configuration + * @return short Number of account + */ + short loadAccountMap(); + + /** + * Unload the account (delete them) + */ + void unloadAccountMap(); + + + /** + * Instance of the MainBuffer for the whole application + * + * In order to send signal to other parts of the application, one must pass through the mainbuffer. + * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. + * + */ + MainBuffer _mainBuffer; + + + public: + + /** + * Return a pointer to the instance of the mainbuffer + */ + MainBuffer *getMainBuffer (void) { + return &_mainBuffer; + } + + + /** + * Tell if there is a current call processed + * @return bool True if there is a current call + */ + bool hasCurrentCall(); + + /** + * Return the current DBusManagerImpl + * @return A pointer to the DBusManagerImpl instance + */ + DBusManagerImpl * getDbusManager() { + return _dbus; + } + + /** + * Tell if an account exists + * @param accountID account ID check + * @return bool True if the account exists + * false otherwise + */ + bool accountExists (const AccountID& accountID); + + std::map<std::string, std::string> send_history_to_client (void); + + void receive_history_from_client (std::map<std::string, std::string> history); + /** + * Get an account pointer + * @param accountID account ID to get + * @return Account* The account pointer or 0 + */ + Account* getAccount (const AccountID& accountID); + + /** Return the AccountID from a CallID + * Protected by mutex + * @param callID the CallID in the list + * @return AccountID The accountID associated or "" if the callID is not found + */ + AccountID getAccountFromCall (const CallID& callID); + + /** + * Get the voip link from the account pointer + * @param accountID Account ID to get + * @return VoIPLink* The voip link from the account pointer or 0 + */ + VoIPLink* getAccountLink (const AccountID& accountID=AccountNULL); + + VoIPLink* getSIPAccountLink (void); + + AccountID getAccountIdFromNameAndServer (const std::string& userName, const std::string& server); + + int getLocalIp2IpPort(); + std::string getStunServer (void); + void setStunServer (const std::string &server); - /** - * Instance of the MainBuffer for the whole application - * - * In order to send signal to other parts of the application, one must pass through the mainbuffer. - * Audio instances must be registered into the MainBuffer and bound together via the ManagerImpl. - * - */ - MainBuffer _mainBuffer; + int isStunEnabled (void); + void enableStun (void); + // Map containing reference between conferences and calls + ConferenceCallMap _conferencecall; - public: + // Map containing conference pointers + ConferenceMap _conferencemap; - /** - * Return a pointer to the instance of the mainbuffer - */ - MainBuffer *getMainBuffer(void) { return &_mainBuffer; } + private: + // Copy Constructor + ManagerImpl (const ManagerImpl& rh); - /** - * Tell if there is a current call processed - * @return bool True if there is a current call - */ - bool hasCurrentCall(); - - /** - * Return the current DBusManagerImpl - * @return A pointer to the DBusManagerImpl instance - */ - DBusManagerImpl * getDbusManager() { return _dbus; } - - /** - * Tell if an account exists - * @param accountID account ID check - * @return bool True if the account exists - * false otherwise - */ - bool accountExists(const AccountID& accountID); + // Assignment Operator + ManagerImpl& operator= (const ManagerImpl& rh); - std::map<std::string, std::string> send_history_to_client (void); + NumberCleaner *_cleaner; - void receive_history_from_client (std::map<std::string, std::string> history); - /** - * Get an account pointer - * @param accountID account ID to get - * @return Account* The account pointer or 0 - */ - Account* getAccount(const AccountID& accountID); + /** + * To handle the persistent history + */ + HistoryManager * _history; - /** Return the AccountID from a CallID - * Protected by mutex - * @param callID the CallID in the list - * @return AccountID The accountID associated or "" if the callID is not found - */ - AccountID getAccountFromCall(const CallID& callID); - - /** - * Get the voip link from the account pointer - * @param accountID Account ID to get - * @return VoIPLink* The voip link from the account pointer or 0 - */ - VoIPLink* getAccountLink(const AccountID& accountID=AccountNULL); - - VoIPLink* getSIPAccountLink (void); - - AccountID getAccountIdFromNameAndServer(const std::string& userName, const std::string& server); - - int getLocalIp2IpPort(); - - std::string getStunServer (void); - void setStunServer (const std::string &server); - - int isStunEnabled (void); - void enableStun (void); - - // Map containing reference between conferences and calls - ConferenceCallMap _conferencecall; - - // Map containing conference pointers - ConferenceMap _conferencemap; - -private: - - // Copy Constructor - ManagerImpl(const ManagerImpl& rh); + /** + * Check if the call is a classic call or a direct IP-to-IP call + */ + void check_call_configuration (const CallID& id, const std::string& to, Call::CallConfiguration *callConfig); - // Assignment Operator - ManagerImpl& operator=( const ManagerImpl& rh); - - NumberCleaner *_cleaner; - - /** - * To handle the persistent history - */ - HistoryManager * _history; - - /** - * Check if the call is a classic call or a direct IP-to-IP call - */ - void check_call_configuration (const CallID& id, const std::string& to, Call::CallConfiguration *callConfig); - - Conf::YamlParser *parser; - Conf::YamlEmitter *emitter; + Conf::YamlParser *parser; + Conf::YamlEmitter *emitter; #ifdef TEST - bool testCallAccountMap(); - bool testAccountMap(); + bool testCallAccountMap(); + bool testAccountMap(); #endif - friend class ConfigurationTest; - friend class HistoryTest; + friend class ConfigurationTest; + friend class HistoryTest; }; #endif // __MANAGER_H__ diff --git a/sflphone-common/src/numbercleaner.h b/sflphone-common/src/numbercleaner.h index a45192e258841175031339e77fba1b5c43ae0cee..6a4c2198d9de9b5440f270fd31d192557e439a6b 100644 --- a/sflphone-common/src/numbercleaner.h +++ b/sflphone-common/src/numbercleaner.h @@ -35,7 +35,8 @@ #include "logger.h" #include <string> -class NumberCleaner { +class NumberCleaner +{ public: NumberCleaner (void); @@ -43,16 +44,20 @@ class NumberCleaner { std::string clean (std::string to_clean); - inline void set_phone_number_prefix (std::string prefix) { - _debug("Number: Set phone number prefix %s", _prefix.c_str()); _prefix = prefix; } + inline void set_phone_number_prefix (std::string prefix) { + _debug ("Number: Set phone number prefix %s", _prefix.c_str()); + _prefix = prefix; + } - inline std::string get_phone_number_prefix (void) { return _prefix; } + inline std::string get_phone_number_prefix (void) { + return _prefix; + } private: std::string _prefix; - void strip_char(std::string to_strip, std::string *num); + void strip_char (std::string to_strip, std::string *num); }; diff --git a/sflphone-common/src/observer.h b/sflphone-common/src/observer.h index 5e778800598a1cbce1815a2ae544589171a0ba7a..ec3f8243841338747d34e55253a41a91a93c5b7e 100644 --- a/sflphone-common/src/observer.h +++ b/sflphone-common/src/observer.h @@ -36,26 +36,29 @@ /** * Observer design pattern interface */ -namespace Pattern { +namespace Pattern +{ /** * Observer interface */ -class Observer { -public: - virtual ~Observer() {}; - virtual void update() = 0; +class Observer +{ + public: + virtual ~Observer() {}; + virtual void update() = 0; }; -class Subject { -public: - virtual ~Subject() {}; - void attach(Observer& observer); - void detach(Observer& observer); - void notify(); +class Subject +{ + public: + virtual ~Subject() {}; + void attach (Observer& observer); + void detach (Observer& observer); + void notify(); -private: - std::list<Observer*> _observers; + private: + std::list<Observer*> _observers; }; } // end namespace diff --git a/sflphone-common/src/plug-in/librarymanager.h b/sflphone-common/src/plug-in/librarymanager.h index 2e94cd5681c3c8dcf7124703ec795ed275eb36e2..eba2ffd2858c267184083e23fc175a314b94acb3 100644 --- a/sflphone-common/src/plug-in/librarymanager.h +++ b/sflphone-common/src/plug-in/librarymanager.h @@ -32,11 +32,12 @@ #define LIBRARY_MANAGER_H #include "dlfcn.h" -#include <stdexcept> +#include <stdexcept> #include "global.h" -class LibraryManager { +class LibraryManager +{ public: typedef void* LibraryHandle; @@ -57,19 +58,22 @@ class LibraryManager { LibraryHandle _handlePtr; }; -class LibraryManagerException : public std::runtime_error { +class LibraryManagerException : public std::runtime_error +{ public: typedef enum Reason { loadingFailed = 0, symbolNotFound - }Reason; + } Reason; LibraryManagerException (const std::string &libraryName, const std::string &details, Reason reason); ~LibraryManagerException (void) throw() {} - inline Reason getReason (void) { return _reason; } + inline Reason getReason (void) { + return _reason; + } const char* what () const throw(); diff --git a/sflphone-common/src/plug-in/plugin.h b/sflphone-common/src/plug-in/plugin.h index 95a9adcb89027954c968a81b75e1b8b88974c368..f3c2afdc9d55e18690977bb99787f88d2d2e583f 100644 --- a/sflphone-common/src/plug-in/plugin.h +++ b/sflphone-common/src/plug-in/plugin.h @@ -32,25 +32,28 @@ #ifndef PLUGIN_H #define PLUGIN_H -#include "global.h" +#include "global.h" -#include "pluginmanager.h" +#include "pluginmanager.h" /* * @file plugin.h - * @brief Define a plugin object + * @brief Define a plugin object */ -class Plugin { +class Plugin +{ public: - Plugin( const std::string &name ){ + Plugin (const std::string &name) { _name = name; } virtual ~Plugin() {} - inline std::string getPluginName (void) { return _name; } + inline std::string getPluginName (void) { + return _name; + } /** * Return the minimal core version required so that the plugin could work @@ -59,7 +62,7 @@ class Plugin { virtual int initFunc (PluginInfo **info) = 0; private: - Plugin &operator =(const Plugin &plugin); + Plugin &operator = (const Plugin &plugin); std::string _name; }; diff --git a/sflphone-common/src/plug-in/pluginmanager.h b/sflphone-common/src/plug-in/pluginmanager.h index a60ee02b3ba86fcb889f1d252ddf709a9437d606..8d322b0b488f6efaee144e3820b6d661a5a690bb 100644 --- a/sflphone-common/src/plug-in/pluginmanager.h +++ b/sflphone-common/src/plug-in/pluginmanager.h @@ -39,9 +39,9 @@ #include "librarymanager.h" #include "global.h" -#include <map> -#include <string> -#include <vector> +#include <map> +#include <string> +#include <vector> class Plugin; @@ -55,7 +55,8 @@ typedef struct PluginInfo { #include "plugin.h" -class PluginManager { +class PluginManager +{ public: /** * Destructor @@ -86,20 +87,20 @@ class PluginManager { bool isPluginLoaded (const std::string &name); int registerPlugin (Plugin *plugin, LibraryManager *library); - + int unregisterPlugin (PluginInfo *plugin); - int deletePlugin (PluginInfo *plugin); + int deletePlugin (PluginInfo *plugin); /** - * Load a unix dynamic/shared library + * Load a unix dynamic/shared library * @param filename The path to the dynamic/shared library * @return LibraryManager* A pointer on the library */ LibraryManager* loadDynamicLibrary (const std::string &filename); /** - * Unload a unix dynamic/shared library + * Unload a unix dynamic/shared library * @param LibraryManager* The pointer on the loaded library */ int unloadDynamicLibrary (LibraryManager* libraryPtr); diff --git a/sflphone-common/src/preferences.cpp b/sflphone-common/src/preferences.cpp index 1e439fa308759caa851d06343697adec9253e14f..1750246406388bd869405d0e162c1b08f34205c4 100644 --- a/sflphone-common/src/preferences.cpp +++ b/sflphone-common/src/preferences.cpp @@ -192,7 +192,7 @@ VoipPreference::VoipPreference() : _playDtmf (true) , _pulseLength (atoi (DFT_PULSE_LENGTH_STR)) // DFT_PULSE_LENGTH_STR , _sendDtmfAs (0) , _symmetricRtp (true) - , _zidFile (ZRTP_ZIDFILE) // ZRTP_ZID_FILENAME + , _zidFile (ZRTP_ZIDFILE) // ZRTP_ZID_FILENAME { } @@ -487,7 +487,7 @@ AudioPreference::AudioPreference() : _cardin (atoi (ALSA_DFT_CARD)) // ALSA_DFT_ , _deviceRingtone ("") , _recordpath ("") // DFT_RECORD_PATH , _volumemic (atoi (DFT_VOL_SPKR_STR)) // DFT_VOL_SPKR_STR - , _volumespkr (atoi (DFT_VOL_MICRO_STR)) // DFT_VOL_MICRO_STR + , _volumespkr (atoi (DFT_VOL_MICRO_STR)) // DFT_VOL_MICRO_STR { } diff --git a/sflphone-common/src/preferences.h b/sflphone-common/src/preferences.h old mode 100755 new mode 100644 index cc3d8e380414c390b081e58731fd99ebbdeb0145..f57608daa98813fa3a786141c317b828a5f34af3 --- a/sflphone-common/src/preferences.h +++ b/sflphone-common/src/preferences.h @@ -34,372 +34,566 @@ #include "config/serializable.h" // general preferences -const Conf::Key orderKey("order"); // : 1234/2345/ -const Conf::Key audioApiKey("audioApi"); // : 0 -const Conf::Key historyLimitKey("historyLimit"); // : 30 -const Conf::Key historyMaxCallsKey("historyMaxCalls"); // : 20 -const Conf::Key notifyMailsKey("notifyMails"); // : false -const Conf::Key zoneToneChoiceKey("zoneToneChoice"); // : North America -const Conf::Key registrationExpireKey("registrationExpire");// : 180 -const Conf::Key portNumKey("portNum"); // : 5060 -const Conf::Key searchBarDisplayKey("searchBarDisplay"); // : true -const Conf::Key zeroConfenableKey("zeroConfenable"); // : false -const Conf::Key md5HashKey("md5Hash"); // : false +const Conf::Key orderKey ("order"); // : 1234/2345/ +const Conf::Key audioApiKey ("audioApi"); // : 0 +const Conf::Key historyLimitKey ("historyLimit"); // : 30 +const Conf::Key historyMaxCallsKey ("historyMaxCalls"); // : 20 +const Conf::Key notifyMailsKey ("notifyMails"); // : false +const Conf::Key zoneToneChoiceKey ("zoneToneChoice"); // : North America +const Conf::Key registrationExpireKey ("registrationExpire");// : 180 +const Conf::Key portNumKey ("portNum"); // : 5060 +const Conf::Key searchBarDisplayKey ("searchBarDisplay"); // : true +const Conf::Key zeroConfenableKey ("zeroConfenable"); // : false +const Conf::Key md5HashKey ("md5Hash"); // : false // voip preferences -const Conf::Key playDtmfKey("playDtmf"); // true true -const Conf::Key playTonesKey("playTones"); // true -const Conf::Key pulseLengthKey("pulseLength"); //=250 -const Conf::Key sendDtmfAsKey("sendDtmfAs");// =0 -const Conf::Key symmetricRtpKey("symmetric");// =true -const Conf::Key zidFileKey("zidFile");// =sfl.zid +const Conf::Key playDtmfKey ("playDtmf"); // true true +const Conf::Key playTonesKey ("playTones"); // true +const Conf::Key pulseLengthKey ("pulseLength"); //=250 +const Conf::Key sendDtmfAsKey ("sendDtmfAs");// =0 +const Conf::Key symmetricRtpKey ("symmetric");// =true +const Conf::Key zidFileKey ("zidFile");// =sfl.zid // addressbook preferences -const Conf::Key photoKey("photo");// false -const Conf::Key enabledKey("enabled");// true -const Conf::Key listKey("list");// 1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/ -const Conf::Key maxResultsKey("maxResults");// 25 -const Conf::Key businessKey("business");// true -const Conf::Key homeKey("home");// false -const Conf::Key mobileKey("mobile");// false +const Conf::Key photoKey ("photo");// false +const Conf::Key enabledKey ("enabled");// true +const Conf::Key listKey ("list");// 1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/ +const Conf::Key maxResultsKey ("maxResults");// 25 +const Conf::Key businessKey ("business");// true +const Conf::Key homeKey ("home");// false +const Conf::Key mobileKey ("mobile");// false // hooks preferences -const Conf::Key iax2EnabledKey("iax2Enabled");// : false -const Conf::Key numberAddPrefixKey("numberAddPrefix");//: false -const Conf::Key numberEnabledKey("numberEnabled"); //: false -const Conf::Key sipEnabledKey("sipEnabled"); //: false -const Conf::Key urlCommandKey("urlCommand"); //: x-www-browser -const Conf::Key urlSipFieldKey("urlSipField"); //: X-sflphone-url +const Conf::Key iax2EnabledKey ("iax2Enabled");// : false +const Conf::Key numberAddPrefixKey ("numberAddPrefix");//: false +const Conf::Key numberEnabledKey ("numberEnabled"); //: false +const Conf::Key sipEnabledKey ("sipEnabled"); //: false +const Conf::Key urlCommandKey ("urlCommand"); //: x-www-browser +const Conf::Key urlSipFieldKey ("urlSipField"); //: X-sflphone-url // audio preferences -const Conf::Key alsamapKey("alsa"); -const Conf::Key pulsemapKey("pulse"); -const Conf::Key cardinKey("cardin");// : 0 -const Conf::Key cardoutKey("cardout");// 0 -const Conf::Key cardringKey("cardring");// : 0 -const Conf::Key framesizeKey("framesize");// : 20 -const Conf::Key pluginKey("plugin"); //: default -const Conf::Key smplrateKey("smplrate");//: 44100 -const Conf::Key devicePlaybackKey("devicePlayback");//: -const Conf::Key deviceRecordKey("deviceRecord");// : -const Conf::Key deviceRingtoneKey("deviceRingtone");// : -const Conf::Key recordpathKey("recordpath");//: /home/msavard/Bureau -const Conf::Key volumemicKey("volumemic");//: 100 -const Conf::Key volumespkrKey("volumespkr");//: 100 +const Conf::Key alsamapKey ("alsa"); +const Conf::Key pulsemapKey ("pulse"); +const Conf::Key cardinKey ("cardin");// : 0 +const Conf::Key cardoutKey ("cardout");// 0 +const Conf::Key cardringKey ("cardring");// : 0 +const Conf::Key framesizeKey ("framesize");// : 20 +const Conf::Key pluginKey ("plugin"); //: default +const Conf::Key smplrateKey ("smplrate");//: 44100 +const Conf::Key devicePlaybackKey ("devicePlayback");//: +const Conf::Key deviceRecordKey ("deviceRecord");// : +const Conf::Key deviceRingtoneKey ("deviceRingtone");// : +const Conf::Key recordpathKey ("recordpath");//: /home/msavard/Bureau +const Conf::Key volumemicKey ("volumemic");//: 100 +const Conf::Key volumespkrKey ("volumespkr");//: 100 // shortcut preferences -const Conf::Key hangupShortKey("hangUp"); -const Conf::Key pickupShortKey("pickUp"); -const Conf::Key popupShortKey("popupWindow"); -const Conf::Key toggleHoldShortKey("toggleHold"); -const Conf::Key togglePickupHangupShortKey("togglePickupHangup"); - - -class Preferences : public Serializable { - - public: - - Preferences(); - - ~Preferences(); - - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(Conf::MappingNode *map); - - - std::string getAccountOrder(void) { return _accountOrder; } - void setAccountOrder(std::string ord) { _accountOrder = ord; } - - int getAudioApi(void) { return _audioApi; } - void setAudioApi(int api) { _audioApi = api; } - - int getHistoryLimit(void) { return _historyLimit; } - void setHistoryLimit(int lim) { _historyLimit = lim; } - - int getHistoryMaxCalls(void) { return _historyMaxCalls; } - void setHistoryMaxCalls(int max) { _historyMaxCalls = max; } - - bool getNotifyMails(void) { return _notifyMails; } - void setNotifyMails(bool mails) { _notifyMails = mails; } - - std::string getZoneToneChoice(void) { return _zoneToneChoice; } - void setZoneToneChoice(std::string str) { _zoneToneChoice = str; } - - int getRegistrationExpire(void) { return _registrationExpire; } - void setRegistrationExpire(int exp) { _registrationExpire = exp; } - - int getPortNum(void) { return _portNum; } - void setPortNum(int port) { _portNum = port; } - - bool getSearchBarDisplay(void) { return _searchBarDisplay; } - void setSearchBarDisplay(bool search) { _searchBarDisplay = search; } - - bool getZeroConfenable(void) { return _zeroConfenable; } - void setZeroConfenable(bool enable) { _zeroConfenable = enable; } - - bool getMd5Hash(void) { return _md5Hash; } - void setMd5Hash(bool md5) { _md5Hash = md5; } - - private: - - // account order - std::string _accountOrder; - - int _audioApi; - int _historyLimit; - int _historyMaxCalls; - bool _notifyMails; - std::string _zoneToneChoice; - int _registrationExpire; - int _portNum; - bool _searchBarDisplay; - bool _zeroConfenable; - bool _md5Hash; +const Conf::Key hangupShortKey ("hangUp"); +const Conf::Key pickupShortKey ("pickUp"); +const Conf::Key popupShortKey ("popupWindow"); +const Conf::Key toggleHoldShortKey ("toggleHold"); +const Conf::Key togglePickupHangupShortKey ("togglePickupHangup"); + + +class Preferences : public Serializable +{ + + public: + + Preferences(); + + ~Preferences(); + + virtual void serialize (Conf::YamlEmitter *emitter); + + virtual void unserialize (Conf::MappingNode *map); + + + std::string getAccountOrder (void) { + return _accountOrder; + } + void setAccountOrder (std::string ord) { + _accountOrder = ord; + } + + int getAudioApi (void) { + return _audioApi; + } + void setAudioApi (int api) { + _audioApi = api; + } + + int getHistoryLimit (void) { + return _historyLimit; + } + void setHistoryLimit (int lim) { + _historyLimit = lim; + } + + int getHistoryMaxCalls (void) { + return _historyMaxCalls; + } + void setHistoryMaxCalls (int max) { + _historyMaxCalls = max; + } + + bool getNotifyMails (void) { + return _notifyMails; + } + void setNotifyMails (bool mails) { + _notifyMails = mails; + } + + std::string getZoneToneChoice (void) { + return _zoneToneChoice; + } + void setZoneToneChoice (std::string str) { + _zoneToneChoice = str; + } + + int getRegistrationExpire (void) { + return _registrationExpire; + } + void setRegistrationExpire (int exp) { + _registrationExpire = exp; + } + + int getPortNum (void) { + return _portNum; + } + void setPortNum (int port) { + _portNum = port; + } + + bool getSearchBarDisplay (void) { + return _searchBarDisplay; + } + void setSearchBarDisplay (bool search) { + _searchBarDisplay = search; + } + + bool getZeroConfenable (void) { + return _zeroConfenable; + } + void setZeroConfenable (bool enable) { + _zeroConfenable = enable; + } + + bool getMd5Hash (void) { + return _md5Hash; + } + void setMd5Hash (bool md5) { + _md5Hash = md5; + } + + private: + + // account order + std::string _accountOrder; + + int _audioApi; + int _historyLimit; + int _historyMaxCalls; + bool _notifyMails; + std::string _zoneToneChoice; + int _registrationExpire; + int _portNum; + bool _searchBarDisplay; + bool _zeroConfenable; + bool _md5Hash; }; -class VoipPreference : public Serializable { +class VoipPreference : public Serializable +{ - public: + public: - VoipPreference(); + VoipPreference(); - ~VoipPreference(); + ~VoipPreference(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - bool getPlayDtmf(void) { return _playDtmf; } - void setPlayDtmf(bool dtmf) { _playDtmf = dtmf; } + bool getPlayDtmf (void) { + return _playDtmf; + } + void setPlayDtmf (bool dtmf) { + _playDtmf = dtmf; + } - bool getPlayTones(void) { return _playTones; } - void setPlayTones(bool tone) { _playTones = tone; } + bool getPlayTones (void) { + return _playTones; + } + void setPlayTones (bool tone) { + _playTones = tone; + } - int getPulseLength(void) { return _pulseLength; } - void setPulseLength(int length) { _pulseLength = length; } + int getPulseLength (void) { + return _pulseLength; + } + void setPulseLength (int length) { + _pulseLength = length; + } - int getSendDtmfAs(void) { return _sendDtmfAs; } - void setSendDtmfAs(int dtmf) { _sendDtmfAs = dtmf; } + int getSendDtmfAs (void) { + return _sendDtmfAs; + } + void setSendDtmfAs (int dtmf) { + _sendDtmfAs = dtmf; + } - bool getSymmetricRtp(void) { return _symmetricRtp; } - void setSymmetricRtp(bool sym) { _symmetricRtp = sym; } + bool getSymmetricRtp (void) { + return _symmetricRtp; + } + void setSymmetricRtp (bool sym) { + _symmetricRtp = sym; + } - std::string getZidFile(void) { return _zidFile; } - void setZidFile(std::string file) { _zidFile = file; } + std::string getZidFile (void) { + return _zidFile; + } + void setZidFile (std::string file) { + _zidFile = file; + } - private: + private: - bool _playDtmf; - bool _playTones; - int _pulseLength; - int _sendDtmfAs; - bool _symmetricRtp; - std::string _zidFile; + bool _playDtmf; + bool _playTones; + int _pulseLength; + int _sendDtmfAs; + bool _symmetricRtp; + std::string _zidFile; }; -class AddressbookPreference : public Serializable { - - public: - - AddressbookPreference(); - - ~AddressbookPreference(); - - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(Conf::MappingNode *map); - - bool getPhoto(void) { return _photo;} - void setPhoto(bool p) { _photo = p; } - - bool getEnabled(void) { return _enabled; } - void setEnabled(bool e) { _enabled = e; } - - std::string getList(void) { return _list; } - void setList(std::string l) { _list = l; } - - int getMaxResults(void) { return _maxResults; } - void setMaxResults(int r) { _maxResults = r; } - - bool getBusiness(void) { return _business; } - void setBusiness(bool b) { _business = b; } - - bool getHome(void) { return _home; } - void setHone(bool h) { _home = h; } - - bool getMobile(void) { return _mobile; } - void setMobile(bool m) { _mobile = m; } - - private: - - bool _photo; - bool _enabled; - std::string _list; - int _maxResults; - bool _business; - bool _home; - bool _mobile; +class AddressbookPreference : public Serializable +{ + + public: + + AddressbookPreference(); + + ~AddressbookPreference(); + + virtual void serialize (Conf::YamlEmitter *emitter); + + virtual void unserialize (Conf::MappingNode *map); + + bool getPhoto (void) { + return _photo; + } + void setPhoto (bool p) { + _photo = p; + } + + bool getEnabled (void) { + return _enabled; + } + void setEnabled (bool e) { + _enabled = e; + } + + std::string getList (void) { + return _list; + } + void setList (std::string l) { + _list = l; + } + + int getMaxResults (void) { + return _maxResults; + } + void setMaxResults (int r) { + _maxResults = r; + } + + bool getBusiness (void) { + return _business; + } + void setBusiness (bool b) { + _business = b; + } + + bool getHome (void) { + return _home; + } + void setHone (bool h) { + _home = h; + } + + bool getMobile (void) { + return _mobile; + } + void setMobile (bool m) { + _mobile = m; + } + + private: + + bool _photo; + bool _enabled; + std::string _list; + int _maxResults; + bool _business; + bool _home; + bool _mobile; }; -class HookPreference : public Serializable { +class HookPreference : public Serializable +{ - public: + public: - HookPreference(); + HookPreference(); - ~HookPreference(); + ~HookPreference(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - bool getIax2Enabled(void) { return _iax2Enabled; } - void setIax2Enabled( bool i) { _iax2Enabled = i; } + bool getIax2Enabled (void) { + return _iax2Enabled; + } + void setIax2Enabled (bool i) { + _iax2Enabled = i; + } - std::string getNumberAddPrefix(void) { return _numberAddPrefix; } - void setNumberAddPrefix(std::string n) { _numberAddPrefix = n; } + std::string getNumberAddPrefix (void) { + return _numberAddPrefix; + } + void setNumberAddPrefix (std::string n) { + _numberAddPrefix = n; + } - bool getNumberEnabled(void) { return _numberEnabled; } - void setNumberEnabled(bool n) { _numberEnabled = n; } + bool getNumberEnabled (void) { + return _numberEnabled; + } + void setNumberEnabled (bool n) { + _numberEnabled = n; + } - bool getSipEnabled(void) { return _sipEnabled; } - void setSipEnabled(bool s) { _sipEnabled = s; } + bool getSipEnabled (void) { + return _sipEnabled; + } + void setSipEnabled (bool s) { + _sipEnabled = s; + } - std::string getUrlCommand(void) { return _urlCommand; } - void setUrlCommand(std::string u) { _urlCommand = u; } + std::string getUrlCommand (void) { + return _urlCommand; + } + void setUrlCommand (std::string u) { + _urlCommand = u; + } - std::string getUrlSipField(void) { return _urlSipField; } - void setUrlSipField(std::string u) { _urlSipField = u; } + std::string getUrlSipField (void) { + return _urlSipField; + } + void setUrlSipField (std::string u) { + _urlSipField = u; + } - private: + private: - bool _iax2Enabled;// : false - std::string _numberAddPrefix;//: false - bool _numberEnabled; //: false - bool _sipEnabled; //: false - std::string _urlCommand; //: x-www-browser - std::string _urlSipField; //: X-sflphone-url + bool _iax2Enabled;// : false + std::string _numberAddPrefix;//: false + bool _numberEnabled; //: false + bool _sipEnabled; //: false + std::string _urlCommand; //: x-www-browser + std::string _urlSipField; //: X-sflphone-url }; -class AudioPreference : public Serializable { - - public: - - AudioPreference(); - - ~AudioPreference(); - - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(Conf::MappingNode *map); - - // alsa preference - int getCardin(void) { return _cardin; } - void setCardin(int c) { _cardin = c; } - - int getCardout(void) { return _cardout; } - void setCardout(int c) { _cardout = c; } - - int getCardring(void) { return _cardring; } - void setCardring(int c) { _cardring = c; } - - int getFramesize(void) { return _framesize; } - void setFramesize(int f) { _framesize = f; } - - std::string getPlugin(void) { return _plugin; } - void setPlugin(std::string p) { _plugin = p; } - - int getSmplrate(void) { return _smplrate; } - void setSmplrate(int r) { _smplrate = r; } - - //pulseaudio preference - std::string getDevicePlayback(void) { return _devicePlayback; } - void setDevicePlayback(std::string p) { _devicePlayback = p; } - - std::string getDeviceRecord(void) { return _deviceRecord; } - void setDeviceRecord(std::string r) { _deviceRecord = r; } - - std::string getDeviceRingtone(void) { return _deviceRingtone; } - void setDeviceRingtone(std::string r) { _deviceRingtone = r; } - - // general preference - std::string getRecordpath(void) { return _recordpath; } - void setRecordpath(std::string r) { _recordpath = r; } - - int getVolumemic(void) { return _volumemic; } - void setVolumemic(int m) { _volumemic = m; } - - int getVolumespkr(void) { return _volumespkr; } - void setVolumespkr(int s) { _volumespkr = s; } - - private: - - // alsa preference - int _cardin; // 0 - int _cardout; // 0 - int _cardring;// 0 - int _framesize; // 20 - std::string _plugin; // default - int _smplrate;// 44100 - - //pulseaudio preference - std::string _devicePlayback;//: - std::string _deviceRecord; //: - std::string _deviceRingtone; //: - - // general preference - std::string _recordpath; //: /home/msavard/Bureau - int _volumemic; //: 100 - int _volumespkr; //: 100 - +class AudioPreference : public Serializable +{ + + public: + + AudioPreference(); + + ~AudioPreference(); + + virtual void serialize (Conf::YamlEmitter *emitter); + + virtual void unserialize (Conf::MappingNode *map); + + // alsa preference + int getCardin (void) { + return _cardin; + } + void setCardin (int c) { + _cardin = c; + } + + int getCardout (void) { + return _cardout; + } + void setCardout (int c) { + _cardout = c; + } + + int getCardring (void) { + return _cardring; + } + void setCardring (int c) { + _cardring = c; + } + + int getFramesize (void) { + return _framesize; + } + void setFramesize (int f) { + _framesize = f; + } + + std::string getPlugin (void) { + return _plugin; + } + void setPlugin (std::string p) { + _plugin = p; + } + + int getSmplrate (void) { + return _smplrate; + } + void setSmplrate (int r) { + _smplrate = r; + } + + //pulseaudio preference + std::string getDevicePlayback (void) { + return _devicePlayback; + } + void setDevicePlayback (std::string p) { + _devicePlayback = p; + } + + std::string getDeviceRecord (void) { + return _deviceRecord; + } + void setDeviceRecord (std::string r) { + _deviceRecord = r; + } + + std::string getDeviceRingtone (void) { + return _deviceRingtone; + } + void setDeviceRingtone (std::string r) { + _deviceRingtone = r; + } + + // general preference + std::string getRecordpath (void) { + return _recordpath; + } + void setRecordpath (std::string r) { + _recordpath = r; + } + + int getVolumemic (void) { + return _volumemic; + } + void setVolumemic (int m) { + _volumemic = m; + } + + int getVolumespkr (void) { + return _volumespkr; + } + void setVolumespkr (int s) { + _volumespkr = s; + } + + private: + + // alsa preference + int _cardin; // 0 + int _cardout; // 0 + int _cardring;// 0 + int _framesize; // 20 + std::string _plugin; // default + int _smplrate;// 44100 + + //pulseaudio preference + std::string _devicePlayback;//: + std::string _deviceRecord; //: + std::string _deviceRingtone; //: + + // general preference + std::string _recordpath; //: /home/msavard/Bureau + int _volumemic; //: 100 + int _volumespkr; //: 100 + }; -class ShortcutPreferences : public Serializable { +class ShortcutPreferences : public Serializable +{ - public: + public: - ShortcutPreferences(); + ShortcutPreferences(); - ~ShortcutPreferences(); + ~ShortcutPreferences(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - void setShortcuts(std::map<std::string, std::string> shortcut); - std::map<std::string, std::string> getShortcuts(void); + void setShortcuts (std::map<std::string, std::string> shortcut); + std::map<std::string, std::string> getShortcuts (void); - std::string getHangup(void) { return _hangup; } - void setHangup(std::string hangup) { _hangup = hangup; } + std::string getHangup (void) { + return _hangup; + } + void setHangup (std::string hangup) { + _hangup = hangup; + } - std::string getPickup(void) { return _pickup; } - void setPickup(std::string pickup) { _pickup = pickup; } + std::string getPickup (void) { + return _pickup; + } + void setPickup (std::string pickup) { + _pickup = pickup; + } - std::string getPopup(void) { return _popup; } - void setPopup(std::string popup) { _popup = popup; } + std::string getPopup (void) { + return _popup; + } + void setPopup (std::string popup) { + _popup = popup; + } - std::string getToggleHold(void) { return _toggleHold; } - void setToggleHold(std::string hold) { _toggleHold = hold; } + std::string getToggleHold (void) { + return _toggleHold; + } + void setToggleHold (std::string hold) { + _toggleHold = hold; + } - std::string getTogglePickupHangup(void) { return _togglePickupHangup; } - void setTogglePickupHangup(std::string toggle) { _togglePickupHangup = toggle; } + std::string getTogglePickupHangup (void) { + return _togglePickupHangup; + } + void setTogglePickupHangup (std::string toggle) { + _togglePickupHangup = toggle; + } - private: + private: - std::string _hangup; - std::string _pickup; - std::string _popup; - std::string _toggleHold; - std::string _togglePickupHangup; + std::string _hangup; + std::string _pickup; + std::string _popup; + std::string _toggleHold; + std::string _togglePickupHangup; }; diff --git a/sflphone-common/src/sip/Pattern.h b/sflphone-common/src/sip/Pattern.h index a929c655218825eecc3a9f22634731d6712c6cbe..8d515a64589bf8a0a0bf6cb413d1800275736fab 100644 --- a/sflphone-common/src/sip/Pattern.h +++ b/sflphone-common/src/sip/Pattern.h @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,314 +34,318 @@ #include <vector> #include <pcre.h> -namespace sfl { - - /** - * Exception object that is thrown when - * an error occured while compiling the - * regular expression. - */ - class compile_error : public std::invalid_argument - { - public: - explicit compile_error(const std::string& error) : - std::invalid_argument(error) {} - }; - - /** - * Exception object that is thrown when - * an error occured while mathing a - * pattern to an expression. - */ - class match_error : public std::invalid_argument - { - public: - match_error(const std::string& error) : - std::invalid_argument(error) {} - }; - - /** - * This class implements in its way - * some of the libpcre library. - */ - - class Pattern { - - public: - +namespace sfl +{ + +/** + * Exception object that is thrown when + * an error occured while compiling the + * regular expression. + */ +class compile_error : public std::invalid_argument +{ + public: + explicit compile_error (const std::string& error) : + std::invalid_argument (error) {} +}; + +/** + * Exception object that is thrown when + * an error occured while mathing a + * pattern to an expression. + */ +class match_error : public std::invalid_argument +{ + public: + match_error (const std::string& error) : + std::invalid_argument (error) {} +}; + +/** +* This class implements in its way +* some of the libpcre library. +*/ + +class Pattern +{ + + public: + + /** + * Constructor for a regular expression + * pattern evaluator/matcher. + * + * @param pattern + * The regular expression to + * be used for this instance. + */ + + Pattern (const std::string& pattern, + const std::string& options = ""); + + /** + * Destructor. Pcre pattern gets freed + * here. + */ + ~Pattern(); + + /** + * Assignment operator overloading. + * Set the regular expression + * to be used on subject strings + * and compile the regular expression + * from that string. + * + * @param pattern The new pattern + */ + void operator= (const std::string& pattern) { + _pattern = pattern; + compile(); + } + + void operator= (const char * pattern) { + _pattern = pattern; + compile(); + } + + /** + * Compile the regular expression + * from the pattern that was set for + * this object. + */ + void compile (void); + + /** + * Get the currently set regular expression + * that is used on subject strings + * + * @return The currently set pattern + */ + inline std::string getPattern (void) { + return _pattern; + } + + /** + * << operator overload. Sets the the subject + * for latter use on the >> operator. + * + * @param subject + * The expression to be evaluated + * by the pattern. + * + */ + void operator<< (const std::string& subject) { + _subject = subject; + } + + /** + * Get the start position of the overall match. + * + * @return the start position of the overall match. + */ + size_t start (void) const; + + /** + * Get the start position of the specified match. + * + * @param groupNumber The capturing group number. + * + * @return the start position of the specified match. + */ + size_t start (unsigned int groupNumber) const; + + /** + * Get the start position of the specified match. + * + * @param groupName The capturing group name. + */ + void start (const std::string& groupName) const; + + /** + * Get the end position of the overall match. + * + * @return the end position of the overall match. + */ + size_t end (void) const; + + /** + * Get the end position of the specified match. + * + * @param groupNumber The capturing group number. + * + * @return the end position of the specified match. + */ + size_t end (unsigned int groupNumber) const; + + /** + * Get the end position of the specified match. + * + * @param groupName The capturing group name. + * + * @return the end position of the specified match. + */ + void end (const std::string& groupName) const; + + /** + * Get the number of capturing groups in the + * compiled regex. + * + * @return The number of capture groups. + * + * @pre The regular expression should have been + * compiled prior to the execution of this method. + */ + unsigned int getCaptureGroupCount (void); + + /** + * Get the substring matched in a capturing + * group (named or unnamed). + * + * This methods only performs a basic lookup + * inside its internal substring table. Thus, + * matches() should have been called prior to + * this method in order to obtain the desired + * output. + * + * @param groupName The name of the group + * + * @return the substring matched by the + * regular expression designated + * the group name. + */ + std::string group (const std::string& groupName); + + /** + * Get the substring matched in a named group. + * + * This methods only performs a basic lookup + * inside its internal substring table. Thus, + * matches() should have been called prior to + * this method in order to obtain the desired + * output. + * + * @param groupNumber The number of the group. + * + * @return the substring matched by the + * regular expression designated + * the group number. + */ + std::string group (int groupNumber); + + /** + * Similar to python's MatchObject.groups. Get all + * the substrings matched by the capture groups defined + * in the pattern. The complete (implicit) capture group + * is not returned : ie only groups from 1 up to the number + * of groups in the pattern are returned. + * + * @return A vector of stings that were matched by some + * capturing group in the pattern. + * + * @pre The regular expression should have been + * compiled prior to the execution of this method. + */ + std::vector<std::string> groups (void); + + /** + * Try to match the compiled pattern with a + * subject. + * + * @param subject Subject to be matched + * by the pattern. + * + * @return true If the subject matches the pattern, + * false otherwise. + * + * @pre The regular expression should have been + * compiled prior to the execution of this method. + * + * @post The internal substring table will be updated + * with the new matches. Therefore, subsequent + * calls to group may return different results. + */ + bool matches (const std::string& subject) throw (match_error); + + /** + * Try to match the compiled pattern with the implicit + * subject. + * + * @return true If the subject matches the pattern, + * false otherwise. + * + * @pre The regular expression should have been + * compiled prior to the execution of this method. + * + * @post The internal substring table will be updated + * with the new matches. Therefore, subsequent + * calls to group may return different results. + */ + bool matches (void) throw (match_error); + + /** + * Split the subject into a list of substrings. + * + * @return A vector of substrings. + * + * @pre The regular expression should have been + * compiled prior to the execution of this method. + * + * @post The internal subject won't be affected by this + * by this operation. In other words: subject_before = + * subject_after. + */ + std::vector<std::string> split (void); // throw(match_error); + + private: + /** + * The regular expression that represents that pattern. + */ + std::string _pattern; + + /** + * The optional subject string. + */ + std::string _subject; + + /** + * PCRE struct that + * contains the compiled regular + * expression + */ + pcre * _re; + + /** + * The internal output vector used by PCRE. + */ + int * _ovector; + + /** + * The size of the _ovector + */ + int _ovectorSize; + + /** + * Current offset in the _ovector; + */ + + int _offset[2]; + + /** + * The number of substrings matched after calling + * pcre_exec. + */ + int _count; + + /** + * PCRE options for this pattern. + */ + int _options; + /** - * Constructor for a regular expression - * pattern evaluator/matcher. - * - * @param pattern - * The regular expression to - * be used for this instance. - */ - - Pattern(const std::string& pattern, - const std::string& options = ""); - - /** - * Destructor. Pcre pattern gets freed - * here. - */ - ~Pattern(); - - /** - * Assignment operator overloading. - * Set the regular expression - * to be used on subject strings - * and compile the regular expression - * from that string. - * - * @param pattern The new pattern - */ - void operator=(const std::string& pattern) { - _pattern = pattern; - compile(); - } - - void operator=(const char * pattern) { - _pattern = pattern; - compile(); - } - - /** - * Compile the regular expression - * from the pattern that was set for - * this object. - */ - void compile(void); - - /** - * Get the currently set regular expression - * that is used on subject strings - * - * @return The currently set pattern - */ - inline std::string getPattern(void) { return _pattern; } - - /** - * << operator overload. Sets the the subject - * for latter use on the >> operator. - * - * @param subject - * The expression to be evaluated - * by the pattern. - * - */ - void operator<<(const std::string& subject) { - _subject = subject; - } - - /** - * Get the start position of the overall match. - * - * @return the start position of the overall match. - */ - size_t start(void) const; - - /** - * Get the start position of the specified match. - * - * @param groupNumber The capturing group number. - * - * @return the start position of the specified match. - */ - size_t start(unsigned int groupNumber) const; - - /** - * Get the start position of the specified match. - * - * @param groupName The capturing group name. - */ - void start(const std::string& groupName) const; - - /** - * Get the end position of the overall match. - * - * @return the end position of the overall match. - */ - size_t end(void) const; - - /** - * Get the end position of the specified match. - * - * @param groupNumber The capturing group number. - * - * @return the end position of the specified match. - */ - size_t end(unsigned int groupNumber) const; - - /** - * Get the end position of the specified match. - * - * @param groupName The capturing group name. - * - * @return the end position of the specified match. - */ - void end(const std::string& groupName) const; - - /** - * Get the number of capturing groups in the - * compiled regex. - * - * @return The number of capture groups. - * - * @pre The regular expression should have been - * compiled prior to the execution of this method. - */ - unsigned int getCaptureGroupCount(void); - - /** - * Get the substring matched in a capturing - * group (named or unnamed). - * - * This methods only performs a basic lookup - * inside its internal substring table. Thus, - * matches() should have been called prior to - * this method in order to obtain the desired - * output. - * - * @param groupName The name of the group - * - * @return the substring matched by the - * regular expression designated - * the group name. - */ - std::string group(const std::string& groupName); - - /** - * Get the substring matched in a named group. - * - * This methods only performs a basic lookup - * inside its internal substring table. Thus, - * matches() should have been called prior to - * this method in order to obtain the desired - * output. - * - * @param groupNumber The number of the group. - * - * @return the substring matched by the - * regular expression designated - * the group number. - */ - std::string group(int groupNumber); - - /** - * Similar to python's MatchObject.groups. Get all - * the substrings matched by the capture groups defined - * in the pattern. The complete (implicit) capture group - * is not returned : ie only groups from 1 up to the number - * of groups in the pattern are returned. - * - * @return A vector of stings that were matched by some - * capturing group in the pattern. - * - * @pre The regular expression should have been - * compiled prior to the execution of this method. - */ - std::vector<std::string> groups(void); - - /** - * Try to match the compiled pattern with a - * subject. - * - * @param subject Subject to be matched - * by the pattern. - * - * @return true If the subject matches the pattern, - * false otherwise. - * - * @pre The regular expression should have been - * compiled prior to the execution of this method. - * - * @post The internal substring table will be updated - * with the new matches. Therefore, subsequent - * calls to group may return different results. - */ - bool matches(const std::string& subject) throw(match_error); - - /** - * Try to match the compiled pattern with the implicit - * subject. - * - * @return true If the subject matches the pattern, - * false otherwise. - * - * @pre The regular expression should have been - * compiled prior to the execution of this method. - * - * @post The internal substring table will be updated - * with the new matches. Therefore, subsequent - * calls to group may return different results. - */ - bool matches(void) throw(match_error); - - /** - * Split the subject into a list of substrings. - * - * @return A vector of substrings. - * - * @pre The regular expression should have been - * compiled prior to the execution of this method. - * - * @post The internal subject won't be affected by this - * by this operation. In other words: subject_before = - * subject_after. - */ - std::vector<std::string> split(void); // throw(match_error); - - private: - /** - * The regular expression that represents that pattern. - */ - std::string _pattern; - - /** - * The optional subject string. - */ - std::string _subject; - - /** - * PCRE struct that - * contains the compiled regular - * expression - */ - pcre * _re; - - /** - * The internal output vector used by PCRE. - */ - int * _ovector; - - /** - * The size of the _ovector - */ - int _ovectorSize; - - /** - * Current offset in the _ovector; - */ - - int _offset[2]; - - /** - * The number of substrings matched after calling - * pcre_exec. - */ - int _count; - - /** - * PCRE options for this pattern. - */ - int _options; - - /** - * String representation of the options. - */ - std::string _optionsDescription; - }; + * String representation of the options. + */ + std::string _optionsDescription; +}; } diff --git a/sflphone-common/src/sip/SdesNegotiator.h b/sflphone-common/src/sip/SdesNegotiator.h index b57b46a16354e2582cdd60f32e23f9298414f676..1f11324be039ad70e9485d4c2487c74741af5c6a 100644 --- a/sflphone-common/src/sip/SdesNegotiator.h +++ b/sflphone-common/src/sip/SdesNegotiator.h @@ -11,7 +11,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -31,189 +31,218 @@ #define __SFL_SDES_NEGOTIATOR_H__ #include <stdexcept> -#include <string> +#include <string> #include <vector> -namespace sfl { - - /** - * General exception object that is thrown when - * an error occured with a regular expression - * operation. - */ - class parse_error : public std::invalid_argument - { - public: - explicit parse_error(const std::string& error) : - std::invalid_argument(error) {} - }; - - enum CipherMode { - AESCounterMode, - AESF8Mode - }; - - enum MACMode { - HMACSHA1 - }; - - enum KeyMethod { - Inline - // url, maybe at some point - }; - - struct CryptoSuiteDefinition { - char * name; - int masterKeyLength; - int masterSaltLength; - int srtpLifetime; - int srtcpLifetime; - CipherMode cipher; - int encryptionKeyLength; - MACMode mac; - int srtpAuthTagLength; - int srtcpAuthTagLength; - int srtpAuthKeyLength; - int srtcpAuthKeyLen; - }; - - /** - * List of accepted Crypto-Suites - * as defined in RFC4568 (6.2) - */ - const CryptoSuiteDefinition CryptoSuites[3] = { - {(char*)"AES_CM_128_HMAC_SHA1_80", 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 80, 80, 160, 160 }, - {(char*)"AES_CM_128_HMAC_SHA1_32", 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 32, 80, 160, 160 }, - {(char*)"F8_128_HMAC_SHA1_80", 128, 112, 48, 31, AESF8Mode, 128, HMACSHA1, 80, 80, 160, 160 } }; - - - class CryptoAttribute { - +namespace sfl +{ + +/** + * General exception object that is thrown when + * an error occured with a regular expression + * operation. + */ +class parse_error : public std::invalid_argument +{ public: - CryptoAttribute(std::string tag, - std::string cryptoSuite, - std::string srtpKeyMethod, - std::string srtpKeyInfo, - std::string lifetime, - std::string mkiValue, - std::string mkiLength) : - tag(tag), - cryptoSuite(cryptoSuite), - srtpKeyMethod(srtpKeyMethod), - srtpKeyInfo(srtpKeyInfo), - lifetime(lifetime), - mkiValue(mkiValue), - mkiLength(mkiLength) {}; - - - inline std::string getTag() { return tag; }; - inline std::string getCryptoSuite() { return cryptoSuite; }; - inline std::string getSrtpKeyMethod() { return srtpKeyMethod; }; - inline std::string getSrtpKeyInfo() { return srtpKeyInfo; }; - inline std::string getLifetime() { return lifetime; }; - inline std::string getMkiValue() { return mkiValue; }; - inline std::string getMkiLength() { return mkiLength; }; - - private: - std::string tag; - std::string cryptoSuite; - std::string srtpKeyMethod; - std::string srtpKeyInfo; - std::string lifetime; - std::string mkiValue; - std::string mkiLength; - }; - - class SdesNegotiator - { + explicit parse_error (const std::string& error) : + std::invalid_argument (error) {} +}; + +enum CipherMode { + AESCounterMode, + AESF8Mode +}; + +enum MACMode { + HMACSHA1 +}; + +enum KeyMethod { + Inline + // url, maybe at some point +}; + +struct CryptoSuiteDefinition { + char * name; + int masterKeyLength; + int masterSaltLength; + int srtpLifetime; + int srtcpLifetime; + CipherMode cipher; + int encryptionKeyLength; + MACMode mac; + int srtpAuthTagLength; + int srtcpAuthTagLength; + int srtpAuthKeyLength; + int srtcpAuthKeyLen; +}; + +/** +* List of accepted Crypto-Suites +* as defined in RFC4568 (6.2) +*/ +const CryptoSuiteDefinition CryptoSuites[3] = { + { (char*) "AES_CM_128_HMAC_SHA1_80", 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 80, 80, 160, 160 }, + { (char*) "AES_CM_128_HMAC_SHA1_32", 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 32, 80, 160, 160 }, + { (char*) "F8_128_HMAC_SHA1_80", 128, 112, 48, 31, AESF8Mode, 128, HMACSHA1, 80, 80, 160, 160 } +}; + + +class CryptoAttribute +{ + + public: + CryptoAttribute (std::string tag, + std::string cryptoSuite, + std::string srtpKeyMethod, + std::string srtpKeyInfo, + std::string lifetime, + std::string mkiValue, + std::string mkiLength) : + tag (tag), + cryptoSuite (cryptoSuite), + srtpKeyMethod (srtpKeyMethod), + srtpKeyInfo (srtpKeyInfo), + lifetime (lifetime), + mkiValue (mkiValue), + mkiLength (mkiLength) {}; + + + inline std::string getTag() { + return tag; + }; + inline std::string getCryptoSuite() { + return cryptoSuite; + }; + inline std::string getSrtpKeyMethod() { + return srtpKeyMethod; + }; + inline std::string getSrtpKeyInfo() { + return srtpKeyInfo; + }; + inline std::string getLifetime() { + return lifetime; + }; + inline std::string getMkiValue() { + return mkiValue; + }; + inline std::string getMkiLength() { + return mkiLength; + }; + + private: + std::string tag; + std::string cryptoSuite; + std::string srtpKeyMethod; + std::string srtpKeyInfo; + std::string lifetime; + std::string mkiValue; + std::string mkiLength; +}; + +class SdesNegotiator +{ /** * Constructor for an SDES crypto attributes - * negotiator. + * negotiator. * - * @param attribute - * A vector of crypto attributes as defined in + * @param attribute + * A vector of crypto attributes as defined in * RFC4568. This string will be parsed * and a crypto context will be created - * from it. + * from it. + */ + + public: + SdesNegotiator (const std::vector<CryptoSuiteDefinition>& localCapabilites, const std::vector<std::string>& remoteAttribute); + ~SdesNegotiator() { }; + + bool negotiate (void); + + /** + * Return crypto suite after negotiation + */ + std::string getCryptoSuite (void) { + return _cryptoSuite; + } + + /** + * Return key method after negotiation (most likely inline:) + */ + std::string getKeyMethod (void) { + return _srtpKeyMethod; + } + + /** + * Return crypto suite after negotiation + */ + std::string getKeyInfo (void) { + return _srtpKeyInfo; + } + + /** + * Return key lifetime after negotiation + */ + std::string getLifeTime (void) { + return _lifetime; + } + + /** + * Return mki value after negotiation + */ + std::string getMkiValue (void) { + return _mkiValue; + } + + /** + * Return mki length after negotiation + */ + std::string getMkiLength (void) { + return _mkiLength; + } + + private: + /** + * A vector list containing the remote attributes. + * Multiple crypto lines can be sent, and the + * prefered method is then chosen from that list. + */ + std::vector<std::string> _remoteAttribute; + + std::vector<CryptoSuiteDefinition> _localCapabilities; + + /** + * Selected crypto suite after negotiation + */ + std::string _cryptoSuite; + + /** + * Selected key method after negotiation (most likely inline:) + */ + std::string _srtpKeyMethod; + + /** + * Selected crypto suite after negotiation + */ + std::string _srtpKeyInfo; + + /** + * Selected key lifetime after negotiation */ - - public: - SdesNegotiator(const std::vector<CryptoSuiteDefinition>& localCapabilites, const std::vector<std::string>& remoteAttribute); - ~SdesNegotiator() { }; - - bool negotiate(void); - - /** - * Return crypto suite after negotiation - */ - std::string getCryptoSuite(void) { return _cryptoSuite; } - - /** - * Return key method after negotiation (most likely inline:) - */ - std::string getKeyMethod(void) { return _srtpKeyMethod; } - - /** - * Return crypto suite after negotiation - */ - std::string getKeyInfo(void) { return _srtpKeyInfo; } - - /** - * Return key lifetime after negotiation - */ - std::string getLifeTime(void) { return _lifetime; } - - /** - * Return mki value after negotiation - */ - std::string getMkiValue(void) { return _mkiValue; } - - /** - * Return mki length after negotiation - */ - std::string getMkiLength(void) { return _mkiLength; } - - private: - /** - * A vector list containing the remote attributes. - * Multiple crypto lines can be sent, and the - * prefered method is then chosen from that list. - */ - std::vector<std::string> _remoteAttribute; - - std::vector<CryptoSuiteDefinition> _localCapabilities; - - /** - * Selected crypto suite after negotiation - */ - std::string _cryptoSuite; - - /** - * Selected key method after negotiation (most likely inline:) - */ - std::string _srtpKeyMethod; - - /** - * Selected crypto suite after negotiation - */ - std::string _srtpKeyInfo; - - /** - * Selected key lifetime after negotiation - */ - std::string _lifetime; - - /** - * Selected mki value after negotiation - */ - std::string _mkiValue; - - /** - * Selected mki length after negotiation - */ - std::string _mkiLength; - - std::vector<CryptoAttribute *> parse(void); - }; + std::string _lifetime; + + /** + * Selected mki value after negotiation + */ + std::string _mkiValue; + + /** + * Selected mki length after negotiation + */ + std::string _mkiLength; + + std::vector<CryptoAttribute *> parse (void); +}; } #endif diff --git a/sflphone-common/src/sip/sdp.h b/sflphone-common/src/sip/sdp.h index 07c1ecfce7a51a309ffbf693c39b194e6777f084..19336befd5f881ee6a7466ea48d2490ca01aa377 100644 --- a/sflphone-common/src/sip/sdp.h +++ b/sflphone-common/src/sip/sdp.h @@ -49,52 +49,60 @@ class sdpException: public std::exception { - virtual const char* what() const throw() - { - return "An sdpException Occured"; - } + virtual const char* what() const throw() { + return "An sdpException Occured"; + } }; typedef std::vector<std::string> CryptoOffer; -class Sdp { +class Sdp +{ public: - + /* * Class Constructor. * * @param ip_addr */ - Sdp(pj_pool_t *pool); + Sdp (pj_pool_t *pool); /* Class destructor */ ~Sdp(); /* - * Read accessor. Get the list of the local media capabilities. + * Read accessor. Get the list of the local media capabilities. * * @return std::vector<sdpMedia*> the vector containing the different media */ - std::vector<sdpMedia*> get_local_media_cap( void ) { return _local_media_cap; } + std::vector<sdpMedia*> get_local_media_cap (void) { + return _local_media_cap; + } - /* - * Read accessor. Get the sdp session information - * - * @return pjmedia_sdp_session The structure that describes a SDP session - */ - pjmedia_sdp_session* get_local_sdp_session( void ) { return _local_offer; } + /* + * Read accessor. Get the sdp session information + * + * @return pjmedia_sdp_session The structure that describes a SDP session + */ + pjmedia_sdp_session* get_local_sdp_session (void) { + return _local_offer; + } /* * Write accessor. Set the local IP address that will be used in the sdp session */ - void set_ip_address( std::string ip_addr ) { _ip_addr = ip_addr; } + void set_ip_address (std::string ip_addr) { + _ip_addr = ip_addr; + } /* * Read accessor. Get the local IP address */ - std::string get_ip_address( void ) { return _ip_addr; } - + std::string get_ip_address (void) { + return _ip_addr; + } + /* * Build the local SDP offer */ @@ -107,34 +115,39 @@ class Sdp { * @param media The media to add to SDP * @param med The structure to receive the media section */ - void set_media_descriptor_line( sdpMedia* media, pjmedia_sdp_media** p_med ); + void set_media_descriptor_line (sdpMedia* media, pjmedia_sdp_media** p_med); /* Set the zrtp hash that was previously calculated from the hello message in the zrtp layer. * This hash value is unique at the media level. Therefore, if video support is added, one would * have to set the correct zrtp-hash value in the corresponding media section. * @param hash The hello hash of a rtp session. (Only audio at the moment) */ - inline void set_zrtp_hash(const std::string& hash) { _zrtp_hello_hash = hash; _debug("Zrtp hash set with %s\n", hash.c_str()); } + inline void set_zrtp_hash (const std::string& hash) { + _zrtp_hello_hash = hash; + _debug ("Zrtp hash set with %s\n", hash.c_str()); + } + + /* Set the srtp _master_key + * @param mk The Master Key of a srtp session. + */ + inline void set_srtp_crypto (const std::vector<std::string> lc) { + _srtp_crypto = lc; + } - /* Set the srtp _master_key - * @param mk The Master Key of a srtp session. - */ - inline void set_srtp_crypto(const std::vector<std::string> lc) { _srtp_crypto = lc; } - /* * On building an invite outside a dialog, build the local offer and create the * SDP negociator instance with it. */ int create_initial_offer (CodecOrder selectedCodecs); - /* - * On receiving an invite outside a dialog, build the local offer and create the - * SDP negociator instance with the remote offer. - * - * @param remote The remote offer - */ + /* + * On receiving an invite outside a dialog, build the local offer and create the + * SDP negociator instance with the remote offer. + * + * @param remote The remote offer + */ int receiving_initial_offer (pjmedia_sdp_session* remote, CodecOrder selectedCodecs); - + /* * On receiving a message, check if it contains SDP and negotiate. Should be used for * SDP answer and offer but currently is only used for answer. @@ -143,53 +156,53 @@ class Sdp { * @param inv The the invitation * @param rdata The remote data */ - - pj_status_t check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata); - + + pj_status_t check_sdp_answer (pjsip_inv_session *inv, pjsip_rx_data *rdata); + /** * Remove all media in the session media vector. */ - void clean_session_media(void); + void clean_session_media (void); /** * Remove all media in local media capability vector */ - void clean_local_media_capabilities(void); + void clean_local_media_capabilities (void); /* * Return a string description of the media added to the session, * ie the local media capabilities */ - std::string media_to_string( void ); + std::string media_to_string (void); /* * Return the codec of the first media after negociation */ - AudioCodec* get_session_media( void ); + AudioCodec* get_session_media (void); /* * read accessor. Return the negociated offer * * @return pjmedia_sdp_session The negociated offer */ - pjmedia_sdp_session* get_negociated_offer( void ){ + pjmedia_sdp_session* get_negociated_offer (void) { return _negociated_offer; } - /* - * Start the sdp negociation. - * - * @return pj_status_t 0 on success - * 1 otherwise - */ - pj_status_t start_negociation( void ); + /* + * Start the sdp negociation. + * + * @return pj_status_t 0 on success + * 1 otherwise + */ + pj_status_t start_negociation (void); - /* - * Retrieve the negociated sdp offer from the sip payload. - * - * @param sdp the negociated offer - */ - void set_negotiated_sdp ( const pjmedia_sdp_session *sdp ); + /* + * Retrieve the negociated sdp offer from the sip payload. + * + * @param sdp the negociated offer + */ + void set_negotiated_sdp (const pjmedia_sdp_session *sdp); /* * Attribute the specified port to every medias provided @@ -200,39 +213,53 @@ class Sdp { */ void attribute_port_to_all_media (int port); - void set_local_extern_audio_port(int port){ _local_extern_audio_port = port; } + void set_local_extern_audio_port (int port) { + _local_extern_audio_port = port; + } - int get_local_extern_audio_port (void){ return _local_extern_audio_port; } + int get_local_extern_audio_port (void) { + return _local_extern_audio_port; + } void toString (void); - /** + /** * Set remote's IP addr. [not protected] * @param ip The remote IP address */ - void set_remote_ip(const std::string& ip) { _remote_ip_addr = ip; } - - /** + void set_remote_ip (const std::string& ip) { + _remote_ip_addr = ip; + } + + /** * Return IP of destination [mutex protected] * @return const std:string The remote IP address */ - const std::string& get_remote_ip() { return _remote_ip_addr; } + const std::string& get_remote_ip() { + return _remote_ip_addr; + } - /** + /** * Set remote's audio port. [not protected] * @param port The remote audio port */ - void set_remote_audio_port(unsigned int port) { _remote_audio_port = port; } + void set_remote_audio_port (unsigned int port) { + _remote_audio_port = port; + } - /** - * Return audio port at destination [mutex protected] + /** + * Return audio port at destination [mutex protected] * @return unsigned int The remote audio port */ - unsigned int get_remote_audio_port() { return _remote_audio_port; } + unsigned int get_remote_audio_port() { + return _remote_audio_port; + } void set_media_transport_info_from_remote_sdp (const pjmedia_sdp_session *remote_sdp); - std::vector<sdpMedia*> get_session_media_list (void) { return _session_media; } + std::vector<sdpMedia*> get_session_media_list (void) { + return _session_media; + } void get_remote_sdp_crypto_from_offer (const pjmedia_sdp_session* remote_sdp, CryptoOffer& crypto_offer); @@ -251,13 +278,13 @@ class Sdp { /** Remote's IP address */ std::string _remote_ip_addr; - + /** Local SDP */ pjmedia_sdp_session *_local_offer; /* The negociated SDP offer */ // Explanation: each endpoint's offer is negociated, and a new sdp offer results from this - // negociation, with the compatible media from each part + // negociation, with the compatible media from each part pjmedia_sdp_session *_negociated_offer; // The pool to allocate memory @@ -273,9 +300,9 @@ class Sdp { /** "a=crypto" sdes local attributes obtained from AudioSrtpSession */ std::vector<std::string> _srtp_crypto; - - Sdp(const Sdp&); //No Copy Constructor - Sdp& operator=(const Sdp&); //No Assignment Operator + + Sdp (const Sdp&); //No Copy Constructor + Sdp& operator= (const Sdp&); //No Assignment Operator void set_local_media_capabilities (CodecOrder selectedCodecs); @@ -284,70 +311,70 @@ class Sdp { * Gives the originator of the session. * Serves as a globally unique identifier for this version of this session description. */ - void sdp_add_origin( void ); + void sdp_add_origin (void); /* * Mandatory field: Protocol version ("v=") * Add the protocol version in the SDP session description */ - void sdp_add_protocol( void ); + void sdp_add_protocol (void); /* * Optional field: Connection data ("c=") * Contains connection data. */ - void sdp_add_connection_info( void ); - + void sdp_add_connection_info (void); + /* * Mandatory field: Session name ("s=") * Add a textual session name. */ - void sdp_add_session_name( void ); + void sdp_add_session_name (void); /* * Optional field: Session information ("s=") * Provides textual information about the session. */ - void sdp_add_session_info( void ){} + void sdp_add_session_info (void) {} /* * Optional field: Uri ("u=") * Add a pointer to additional information about the session. */ - void sdp_add_uri( void ) {} + void sdp_add_uri (void) {} /* * Optional fields: Email address and phone number ("e=" and "p=") * Add contact information for the person responsible for the conference. */ - void sdp_add_email( void ) {} + void sdp_add_email (void) {} /* * Optional field: Bandwidth ("b=") * Denotes the proposed bandwidth to be used by the session or the media . */ - void sdp_add_bandwidth( void ) {} + void sdp_add_bandwidth (void) {} /* * Mandatory field: Timing ("t=") * Specify the start and the stop time for a session. */ - void sdp_add_timing( void ); + void sdp_add_timing (void); /* * Optional field: Time zones ("z=") */ - void sdp_add_time_zone( void ) {} + void sdp_add_time_zone (void) {} /* * Optional field: Encryption keys ("k=") */ - void sdp_add_encryption_key( void ) {} + void sdp_add_encryption_key (void) {} /* * Optional field: Attributes ("a=") */ - void sdp_add_attributes( ); + void sdp_add_attributes(); /* * Mandatory field: Media descriptions ("m=") @@ -357,30 +384,30 @@ class Sdp { std::string convert_int_to_string (int value); void set_remote_ip_from_sdp (const pjmedia_sdp_session *r_sdp); - + void set_remote_audio_port_from_sdp (pjmedia_sdp_media *r_media); void get_remote_sdp_media_from_offer (const pjmedia_sdp_session* r_sdp, pjmedia_sdp_media** r_media); - + /* * Adds a sdes attribute to the given media section. * - * @param media The media to add the srtp attribute to + * @param media The media to add the srtp attribute to */ - void sdp_add_sdes_attribute(std::vector<std::string>& crypto); + void sdp_add_sdes_attribute (std::vector<std::string>& crypto); - /* - * Adds a zrtp-hash attribute to + /* + * Adds a zrtp-hash attribute to * the given media section. The hello hash is * available only after is has been computed - * in the AudioZrtpSession constructor. + * in the AudioZrtpSession constructor. * - * @param media The media to add the zrtp-hash attribute to + * @param media The media to add the zrtp-hash attribute to * @param hash The hash to which the attribute should be set to - */ - void sdp_add_zrtp_attribute(pjmedia_sdp_media* media, std::string hash); - + */ + void sdp_add_zrtp_attribute (pjmedia_sdp_media* media, std::string hash); + }; diff --git a/sflphone-common/src/sip/sdpmedia.h b/sflphone-common/src/sip/sdpmedia.h index 96d47e326b424ebb1c75c9298342aec9559b8187..54a9a27d1d2b3d4cb459d670a938c5cbae36551a 100644 --- a/sflphone-common/src/sip/sdpmedia.h +++ b/sflphone-common/src/sip/sdpmedia.h @@ -83,19 +83,23 @@ typedef enum mediaType mediaType; class sdpMedia { public: - sdpMedia( int type ); - sdpMedia( std::string type, int port, std::string dir = DEFAULT_STREAM_DIRECTION); + sdpMedia (int type); + sdpMedia (std::string type, int port, std::string dir = DEFAULT_STREAM_DIRECTION); ~sdpMedia(); /* * Read accessor. Return the list of codecs */ - std::vector<AudioCodec*> get_media_codec_list() { return _codec_list; } + std::vector<AudioCodec*> get_media_codec_list() { + return _codec_list; + } /* * Read accessor. Return the type of media */ - mediaType get_media_type() { return _media_type; } + mediaType get_media_type() { + return _media_type; + } /* * Read accessor. Return the type of media @@ -105,59 +109,69 @@ class sdpMedia /* * Set the media type */ - void set_media_type( int type ) { _media_type = (mediaType)type; } + void set_media_type (int type) { + _media_type = (mediaType) type; + } /* * Read accessor. Return the transport port */ - int get_port() { return _port; } + int get_port() { + return _port; + } /* * Write accessor. Set the transport port */ - void set_port( int port ) { _port = port; } + void set_port (int port) { + _port = port; + } /* * Add a codec in the current media codecs vector * * @param payload The payload type */ - void add_codec( AudioCodec *codec ); + void add_codec (AudioCodec *codec); /* * Remove a codec from the current media codecs vector * * @param codec_name The codec encoding name */ - void remove_codec( std::string codec_name ); + void remove_codec (std::string codec_name); /* * Remove all the codecs from the list */ - void clear_codec_list( void ); + void clear_codec_list (void); /* * Return a string description of the current media - */ - std::string to_string( void ); + */ + std::string to_string (void); /* * Set the stream direction of the current media * ie: sendrecv, sendonly,... */ - void set_stream_direction( int direction ) { _stream_type = (streamDirection)direction; } + void set_stream_direction (int direction) { + _stream_type = (streamDirection) direction; + } /* * Get the stream direction of the current media * ie: sendrecv, sendonly,... */ - streamDirection get_stream_direction( void ) { return _stream_type; } + streamDirection get_stream_direction (void) { + return _stream_type; + } /* * Get the stream direction string description of the current media * ie: sendrecv, sendonly,... */ - std::string get_stream_direction_str( void ); + std::string get_stream_direction_str (void); private: /* The type of media */ diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index d6fb4785869f32213055b66d3e8cd361fb3626d9..39e201cdeaba161f48ff2feb89134ca7934f6cb5 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -36,10 +36,6 @@ #include <pwd.h> #include <sstream> -// CredentialItem::CredentialItem() {} - -// CredentialItem::~CredentialItem() {} - Credentials::Credentials() : credentialCount (0) {} Credentials::~Credentials() {} @@ -60,7 +56,7 @@ CredentialItem *Credentials::getCredential (int index) return NULL; } -void Credentials::serialize (Conf::YamlEmitter *emitter) +void Credentials::serialize (Conf::YamlEmitter *emitter UNUSED) { } diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h old mode 100755 new mode 100644 index 0285f695cba60f7dae9f616e1d6ff1db3288a52b..84f49b5ef2e651e5bdcfd3b39a85640e72658ac3 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -10,12 +10,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -52,50 +52,50 @@ enum DtmfType { OVERRTP, SIPINFO}; // SIP specific configuration keys -const Conf::Key expireKey("expire"); -const Conf::Key interfaceKey("interface"); -const Conf::Key portKey("port"); -const Conf::Key publishAddrKey("publishAddr"); -const Conf::Key publishPortKey("publishPort"); -const Conf::Key sameasLocalKey("sameasLocal"); -const Conf::Key resolveOnceKey("resolveOnce"); -const Conf::Key dtmfTypeKey("dtmfType"); -const Conf::Key serviceRouteKey("serviceRoute"); +const Conf::Key expireKey ("expire"); +const Conf::Key interfaceKey ("interface"); +const Conf::Key portKey ("port"); +const Conf::Key publishAddrKey ("publishAddr"); +const Conf::Key publishPortKey ("publishPort"); +const Conf::Key sameasLocalKey ("sameasLocal"); +const Conf::Key resolveOnceKey ("resolveOnce"); +const Conf::Key dtmfTypeKey ("dtmfType"); +const Conf::Key serviceRouteKey ("serviceRoute"); // TODO: write an object to store credential which implement serializable -const Conf::Key srtpKey("srtp"); -const Conf::Key srtpEnableKey("enable"); -const Conf::Key keyExchangeKey("keyExchange"); -const Conf::Key rtpFallbackKey("rtpFallback"); +const Conf::Key srtpKey ("srtp"); +const Conf::Key srtpEnableKey ("enable"); +const Conf::Key keyExchangeKey ("keyExchange"); +const Conf::Key rtpFallbackKey ("rtpFallback"); // TODO: wirte an object to store zrtp params wich implement serializable -const Conf::Key zrtpKey("zrtp"); -const Conf::Key displaySasKey("displaySas"); -const Conf::Key displaySasOnceKey("displaySasOnce"); -const Conf::Key helloHashEnabledKey("helloHashEnabled"); -const Conf::Key notSuppWarningKey("notSuppWarning"); +const Conf::Key zrtpKey ("zrtp"); +const Conf::Key displaySasKey ("displaySas"); +const Conf::Key displaySasOnceKey ("displaySasOnce"); +const Conf::Key helloHashEnabledKey ("helloHashEnabled"); +const Conf::Key notSuppWarningKey ("notSuppWarning"); // TODO: write an object to store tls params which implement serializable -const Conf::Key tlsKey("tls"); -const Conf::Key tlsPortKey("tlsPort"); -const Conf::Key certificateKey("certificate"); -const Conf::Key calistKey("calist"); -const Conf::Key ciphersKey("ciphers"); -const Conf::Key tlsEnableKey("enable"); -const Conf::Key methodKey("method"); -const Conf::Key timeoutKey("timeout"); -const Conf::Key tlsPasswordKey("password"); -const Conf::Key privateKeyKey("privateKey"); -const Conf::Key requireCertifKey("requireCertif"); -const Conf::Key serverKey("server"); -const Conf::Key verifyClientKey("verifyClient"); -const Conf::Key verifyServerKey("verifyServer"); - -const Conf::Key stunEnabledKey("stunEnabled"); -const Conf::Key stunServerKey("stunServer"); - -const Conf::Key credKey("credential"); -const Conf::Key credentialCountKey("count"); +const Conf::Key tlsKey ("tls"); +const Conf::Key tlsPortKey ("tlsPort"); +const Conf::Key certificateKey ("certificate"); +const Conf::Key calistKey ("calist"); +const Conf::Key ciphersKey ("ciphers"); +const Conf::Key tlsEnableKey ("enable"); +const Conf::Key methodKey ("method"); +const Conf::Key timeoutKey ("timeout"); +const Conf::Key tlsPasswordKey ("password"); +const Conf::Key privateKeyKey ("privateKey"); +const Conf::Key requireCertifKey ("requireCertif"); +const Conf::Key serverKey ("server"); +const Conf::Key verifyClientKey ("verifyClient"); +const Conf::Key verifyServerKey ("verifyServer"); + +const Conf::Key stunEnabledKey ("stunEnabled"); +const Conf::Key stunServerKey ("stunServer"); + +const Conf::Key credKey ("credential"); +const Conf::Key credentialCountKey ("count"); class SIPVoIPLink; @@ -106,55 +106,59 @@ class SIPVoIPLink; class SipAccountException : public std::exception { - public: - SipAccountException(const std::string& str="") throw() : errstr(str) {} + public: + SipAccountException (const std::string& str="") throw() : errstr (str) {} - virtual ~SipAccountException() throw() {} + virtual ~SipAccountException() throw() {} - virtual const char *what() const throw() { - std::string expt("SipAccountException occured: "); - expt.append(errstr); + virtual const char *what() const throw() { + std::string expt ("SipAccountException occured: "); + expt.append (errstr); - return expt.c_str(); - } - private: - std::string errstr; + return expt.c_str(); + } + private: + std::string errstr; }; class CredentialItem { - public: + public: - std::string username; - std::string password; - std::string realm; + std::string username; + std::string password; + std::string realm; }; class Credentials : public Serializable { - public: + public: - Credentials(); + Credentials(); - ~Credentials(); + ~Credentials(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - int getCredentialCount(void) { return credentialCount; } - void setCredentialCount(int count) { credentialCount = count; } + int getCredentialCount (void) { + return credentialCount; + } + void setCredentialCount (int count) { + credentialCount = count; + } - void setNewCredential(std::string username, std::string password, std::string realm); - CredentialItem *getCredential(int index); + void setNewCredential (std::string username, std::string password, std::string realm); + CredentialItem *getCredential (int index); - private: + private: - int credentialCount; + int credentialCount; - CredentialItem credentialArray[10]; + CredentialItem credentialArray[10]; }; @@ -166,51 +170,55 @@ class SIPAccount : public Account * Constructor * @param accountID The account identifier */ - SIPAccount(const AccountID& accountID); + SIPAccount (const AccountID& accountID); /* Copy Constructor */ - SIPAccount(const SIPAccount& rh); + SIPAccount (const SIPAccount& rh); /* Assignment Operator */ - SIPAccount& operator=( const SIPAccount& rh); + SIPAccount& operator= (const SIPAccount& rh); /** * Virtual destructor */ virtual ~SIPAccount(); - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize (Conf::YamlEmitter *emitter); - virtual void unserialize(Conf::MappingNode *map); + virtual void unserialize (Conf::MappingNode *map); - virtual void setAccountDetails(const std::map<std::string, std::string>& details); + virtual void setAccountDetails (const std::map<std::string, std::string>& details); - virtual std::map<std::string, std::string> getAccountDetails(); + virtual std::map<std::string, std::string> getAccountDetails(); - /** - * Set route header to appears in sip messages for this account - */ - void setRouteSet(std::string route) { _routeSet = route; } + /** + * Set route header to appears in sip messages for this account + */ + void setRouteSet (std::string route) { + _routeSet = route; + } - /** - * Get route header to appear in sip messages for this account - */ - std::string getRouteSet(void) { return _routeSet; } + /** + * Get route header to appear in sip messages for this account + */ + std::string getRouteSet (void) { + return _routeSet; + } - /** - * Special setVoIPLink which increment SipVoIPLink's number of client. - */ - // void setVoIPLink(VoIPLink *link); - void setVoIPLink(); + /** + * Special setVoIPLink which increment SipVoIPLink's number of client. + */ + // void setVoIPLink(VoIPLink *link); + void setVoIPLink(); - /** - * Actually useless, since config loading is done in init() + /** + * Actually useless, since config loading is done in init() */ void loadConfig(); /** * Initialize the SIP voip link with the account parameters and send registration - */ + */ int registerVoIPLink(); /** @@ -218,104 +226,150 @@ class SIPAccount : public Account */ int unregisterVoIPLink(); - inline void setCredInfo(pjsip_cred_info *cred) {_cred = cred;} - inline pjsip_cred_info *getCredInfo() {return _cred;} - - inline std::string& getAuthenticationUsername(void) { return _authenticationUsername; } - inline void setAuthenticationUsername(const std::string& username) { _authenticationUsername = username; } - - inline bool isResolveOnce(void) { return _resolveOnce; } - void setResolveOnce(bool reslv) { _resolveOnce = reslv; } - - - /** - * A client sendings a REGISTER request MAY suggest an expiration - * interval that indicates how long the client would like the - * registration to be valid. - * - * @return A string describing the expiration value. - */ - inline std::string& getRegistrationExpire(void) { return _registrationExpire; } - - /** - * Setting the Expiration Interval of Contact Addresses. - * - * @param A string describing the expiration value. - */ - inline void setRegistrationExpire(std::string expr) { _registrationExpire = expr; } - - bool fullMatch(const std::string& username, const std::string& hostname); - bool userMatch(const std::string& username); - bool hostnameMatch(const std::string& hostname); - + inline void setCredInfo (pjsip_cred_info *cred) { + _cred = cred; + } + inline pjsip_cred_info *getCredInfo() { + return _cred; + } + + inline std::string& getAuthenticationUsername (void) { + return _authenticationUsername; + } + inline void setAuthenticationUsername (const std::string& username) { + _authenticationUsername = username; + } + + inline bool isResolveOnce (void) { + return _resolveOnce; + } + void setResolveOnce (bool reslv) { + _resolveOnce = reslv; + } + + + /** + * A client sendings a REGISTER request MAY suggest an expiration + * interval that indicates how long the client would like the + * registration to be valid. + * + * @return A string describing the expiration value. + */ + inline std::string& getRegistrationExpire (void) { + return _registrationExpire; + } + + /** + * Setting the Expiration Interval of Contact Addresses. + * + * @param A string describing the expiration value. + */ + inline void setRegistrationExpire (std::string expr) { + _registrationExpire = expr; + } + + bool fullMatch (const std::string& username, const std::string& hostname); + bool userMatch (const std::string& username); + bool hostnameMatch (const std::string& hostname); + /* Registration flag */ - bool isRegister() {return _bRegister;} - void setRegister(bool result) {_bRegister = result;} - + bool isRegister() { + return _bRegister; + } + void setRegister (bool result) { + _bRegister = result; + } + /** - * Get the registration stucture that is used + * Get the registration stucture that is used * for PJSIP in the registration process. * Settings are loaded from configuration file. * @param void * @return pjsip_regc* A pointer to the registration structure */ - pjsip_regc* getRegistrationInfo( void ) { return _regc; } - - /** + pjsip_regc* getRegistrationInfo (void) { + return _regc; + } + + /** * Set the registration structure that is used * for PJSIP in the registration process; * @pram A pointer to the new registration structure * @return void */ - void setRegistrationInfo( pjsip_regc *regc ) { _regc = regc; } + void setRegistrationInfo (pjsip_regc *regc) { + _regc = regc; + } /** - * Get the number of credentials defined for + * Get the number of credentials defined for * this account. * @param none * @return int The number of credentials set for this account. */ - inline int getCredentialCount(void) { return credentials.getCredentialCount() + 1; } - inline void setCredentialCount(int count) { return credentials.setCredentialCount(count); } - + inline int getCredentialCount (void) { + return credentials.getCredentialCount() + 1; + } + inline void setCredentialCount (int count) { + return credentials.setCredentialCount (count); + } + /** * @return pjsip_tls_setting structure, filled from the configuration - * file, that can be used directly by PJSIP to initialize + * file, that can be used directly by PJSIP to initialize * TLS transport. */ - inline pjsip_tls_setting * getTlsSetting(void) { return _tlsSetting; } - - /** + inline pjsip_tls_setting * getTlsSetting (void) { + return _tlsSetting; + } + + /** * @return pj_str_t , filled from the configuration - * file, that can be used directly by PJSIP to initialize + * file, that can be used directly by PJSIP to initialize * an alternate UDP transport. */ - inline std::string getStunServer(void) { return _stunServer; } - inline void setStunServer (std::string srv) { _stunServer = srv; } + inline std::string getStunServer (void) { + return _stunServer; + } + inline void setStunServer (std::string srv) { + _stunServer = srv; + } - inline pj_str_t getStunServerName(void) { return _stunServerName; } + inline pj_str_t getStunServerName (void) { + return _stunServerName; + } - /** + /** * @return pj_uint8_t structure, filled from the configuration - * file, that can be used directly by PJSIP to initialize + * file, that can be used directly by PJSIP to initialize * an alternate UDP transport. */ - inline pj_uint16_t getStunPort (void) { return _stunPort; } - inline void setStunPort (pj_uint16_t port) { _stunPort = port; } - + inline pj_uint16_t getStunPort (void) { + return _stunPort; + } + inline void setStunPort (pj_uint16_t port) { + _stunPort = port; + } + /** - * @return bool Tells if current transport for that + * @return bool Tells if current transport for that * account is set to TLS. */ - inline bool isTlsEnabled(void) { return (_transportType == PJSIP_TRANSPORT_TLS) ? true: false; } - - /** - * @return bool Tells if current transport for that - * account is set to OTHER. - */ - inline bool isStunEnabled(void) { return (_transportType == PJSIP_TRANSPORT_START_OTHER) ? true: false; } - inline void setStunEnabled(bool enabl) { _stunEnabled = enabl; } - + inline bool isTlsEnabled (void) { + return (_transportType == PJSIP_TRANSPORT_TLS) ? true: false; + } + + /** + * @return bool Tells if current transport for that + * account is set to OTHER. + */ + inline bool isStunEnabled (void) { + return (_transportType == PJSIP_TRANSPORT_START_OTHER) ? true: false; + } + inline void setStunEnabled (bool enabl) { + _stunEnabled = enabl; + } + /* * @return pj_str_t "From" uri based on account information. * From RFC3261: "The To header field first and foremost specifies the desired @@ -325,8 +379,8 @@ class SIPAccount : public Account * of the host on which the UA is running, since these are not logical * names." */ - std::string getFromUri(void); - + std::string getFromUri (void); + /* * This method adds the correct scheme, hostname and append * the ;transport= parameter at the end of the uri, in accordance with RFC3261. @@ -335,236 +389,358 @@ class SIPAccount : public Account * @return pj_str_t "To" uri based on @param username * @param username A string formatted as : "username" */ - std::string getToUri(const std::string& username); + std::string getToUri (const std::string& username); /* - * In the current version of SFLPhone, "srv" uri is obtained in the preformated + * In the current version of SFLPhone, "srv" uri is obtained in the preformated * way: hostname:port. This method adds the correct scheme and append * the ;transport= parameter at the end of the uri, in accordance with RFC3261. * * @return pj_str_t "server" uri based on @param hostPort * @param hostPort A string formatted as : "hostname:port" */ - std::string getServerUri(void); - + std::string getServerUri (void); + /** * @param port Optional port. Otherwise set to the port defined for that account. * @param hostname Optional local address. Otherwise set to the hostname defined for that account. * @return pj_str_t The contact header based on account information */ - std::string getContactHeader(const std::string& address, const std::string& port); + std::string getContactHeader (const std::string& address, const std::string& port); - /** - * Set the interface name on which this account is bound, "default" means - * that the account is bound to the ANY interafec (0.0.0.0). This method should be - * when binding the account to a new sip transport only. - */ - inline void setLocalInterface(const std::string& interface) {_interface = interface;} + /** + * Set the interface name on which this account is bound, "default" means + * that the account is bound to the ANY interafec (0.0.0.0). This method should be + * when binding the account to a new sip transport only. + */ + inline void setLocalInterface (const std::string& interface) { + _interface = interface; + } - /** - * Get the local interface name on which this account is bound. - */ - inline std::string getLocalInterface(void) { return _interface; } + /** + * Get the local interface name on which this account is bound. + */ + inline std::string getLocalInterface (void) { + return _interface; + } - /** - * Get a flag which determine the usage in sip headers of either the local - * IP address and port (_localAddress and _localPort) or to an address set - * manually (_publishedAddress and _publishedPort). - */ - bool getPublishedSameasLocal(){ return _publishedSameasLocal; } + /** + * Get a flag which determine the usage in sip headers of either the local + * IP address and port (_localAddress and _localPort) or to an address set + * manually (_publishedAddress and _publishedPort). + */ + bool getPublishedSameasLocal() { + return _publishedSameasLocal; + } - /** - * Set a flag which determine the usage in sip headers of either the local - * IP address and port (_localAddress and _localPort) or to an address set - * manually (_publishedAddress and _publishedPort). - */ - void setPublishedSameasLocal(bool published){ _publishedSameasLocal = published; } + /** + * Set a flag which determine the usage in sip headers of either the local + * IP address and port (_localAddress and _localPort) or to an address set + * manually (_publishedAddress and _publishedPort). + */ + void setPublishedSameasLocal (bool published) { + _publishedSameasLocal = published; + } /** * Get the port on which the transport/listener should use, or is * actually using. * @return pj_uint16 The port used for that account - */ - inline pj_uint16_t getLocalPort(void) { return (pj_uint16_t) _localPort; } - - /** + */ + inline pj_uint16_t getLocalPort (void) { + return (pj_uint16_t) _localPort; + } + + /** * Set the new port on which this account is running over. * @pram port The port used by this account. */ - inline void setLocalPort(pj_uint16_t port) { _localPort = port; } - + inline void setLocalPort (pj_uint16_t port) { + _localPort = port; + } + /** * Get the published port, which is the port to be advertised as the port * for the chosen SIP transport. * @return pj_uint16 The port used for that account - */ - inline pj_uint16_t getPublishedPort(void) { return (pj_uint16_t) _publishedPort; } - - /** + */ + inline pj_uint16_t getPublishedPort (void) { + return (pj_uint16_t) _publishedPort; + } + + /** * Set the published port, which is the port to be advertised as the port * for the chosen SIP transport. * @pram port The port used by this account. */ - inline void setPublishedPort(pj_uint16_t port) { _publishedPort = port; } + inline void setPublishedPort (pj_uint16_t port) { + _publishedPort = port; + } - /** - * Get the local port for TLS listener. - * @return pj_uint16 The port used for that account - */ - inline pj_uint16_t getTlsListenerPort(void) { return (pj_uint16_t) _tlsListenerPort; } - - /** + /** + * Get the local port for TLS listener. + * @return pj_uint16 The port used for that account + */ + inline pj_uint16_t getTlsListenerPort (void) { + return (pj_uint16_t) _tlsListenerPort; + } + + /** * Set the local port for TLS listener. * @pram port The port used for TLS listener. */ - inline void setTlsListenerPort(pj_uint16_t port) { _tlsListenerPort = port; } - + inline void setTlsListenerPort (pj_uint16_t port) { + _tlsListenerPort = port; + } + /** * Get the public IP address set by the user for this account. * If this setting is not provided, the local bound adddress * will be used. * @return std::string The public IPV4 address formatted in the standard dot notation. */ - inline std::string getPublishedAddress(void) { return _publishedIpAddress; } - + inline std::string getPublishedAddress (void) { + return _publishedIpAddress; + } + /** * Set the public IP address to be used in Contact header. * @param The public IPV4 address in the standard dot notation. * @return void */ - inline void setPublishedAddress(const std::string& publishedIpAddress) { _publishedIpAddress = publishedIpAddress; } + inline void setPublishedAddress (const std::string& publishedIpAddress) { + _publishedIpAddress = publishedIpAddress; + } + + inline std::string getServiceRoute (void) { + return _serviceRoute; + } - inline std::string getServiceRoute(void) { return _serviceRoute; } + inline void setServiceRoute (std::string route) { + _serviceRoute = route; + } - inline void setServiceRoute(std::string route) { _serviceRoute = route; } - /** * Get the chosen transport type. * @return pjsip_transport_type_e Transport type chosen by the user for this account. */ - inline pjsip_transport_type_e getTransportType(void) { return _transportType; } - - inline pjsip_transport* getAccountTransport (void) { return _transport; } - - inline void setAccountTransport (pjsip_transport *transport) { _transport = transport; } - - std::string getTransportMapKey(void); - - DtmfType getDtmfType(void) { return _dtmfType; } - void setDtmfType(DtmfType type) { _dtmfType = type; } - - bool getSrtpEnable(void) { return _srtpEnabled; } - void setSrtpEnable(bool enabl) { _srtpEnabled = enabl; } - - std::string getSrtpKeyExchange(void) { return _srtpKeyExchange; } - void setSrtpKeyExchange(std::string key) { _srtpKeyExchange = key; } - - bool getSrtpFallback(void) { return _srtpFallback; } - void setSrtpFallback(bool fallback) { _srtpFallback = fallback; } - - bool getZrtpDisplaySas(void) { return _zrtpDisplaySas; } - void setZrtpDisplaySas(bool sas) { _zrtpDisplaySas = sas; } - - bool getZrtpDiaplaySasOnce(void) { return _zrtpDisplaySasOnce; } - void setZrtpDiaplaySasOnce(bool sasonce) { _zrtpDisplaySasOnce = sasonce; } - - bool getZrtpNotSuppWarning(void) { return _zrtpNotSuppWarning; } - void setZrtpNotSuppWarning(bool warning) { _zrtpNotSuppWarning = warning; } - - bool getZrtpHelloHash(void) { return _zrtpHelloHash; } - void setZrtpHelloHash(bool hellohash) { _zrtpHelloHash = hellohash; } - // void setSrtpKeyExchange - - std::string getRealm(void) { return _realm; } - void setRealm(std::string r) { _realm = r; } - - std::string getTlsEnable(void) {return _tlsEnable; } - void setTlsEnable(std::string enabl) { _tlsEnable = enabl; } - - std::string getTlsCaListFile(void) { return _tlsCaListFile; } - void setTlsCaListFile(std::string calist) { _tlsCaListFile = calist; } - - std::string getTlsCertificateFile(void) { return _tlsCertificateFile; } - void setTlsCertificateFile(std::string cert) { _tlsCertificateFile = cert; } - - std::string getTlsPrivateKeyFile(void) { return _tlsPrivateKeyFile; } - void setTlsPrivateKeyFile(std::string priv) { _tlsPrivateKeyFile = priv; } - - std::string getTlsPassword(void) { return _tlsPassword; } - void setTlsPassword(std::string pass) { _tlsPassword = pass; } - - std::string getTlsMethod(void) { return _tlsMethod; } - void setTlsMethod(std::string meth) { _tlsMethod = meth; } - - std::string getTlsCiphers(void) { return _tlsCiphers; } - void setTlsCiphers(std::string cipher) { _tlsCiphers = cipher; } - - std::string getTlsServerName(void) { return _tlsServerName; } - void setTlsServerName(std::string name) { _tlsServerName = name; } - - bool getTlsVerifyServer(void) { return _tlsVerifyServer; } - void setTlsVerifyServer(bool verif) { _tlsVerifyServer = verif; } - - bool getTlsVerifyClient(void) { return _tlsVerifyClient; } - void setTlsVerifyClient(bool verif) { _tlsVerifyClient = verif; } - - bool getTlsRequireClientCertificate(void) { return _tlsRequireClientCertificate; } - void setTlsRequireClientCertificate(bool require) { _tlsRequireClientCertificate = require; } - - std::string getTlsNegotiationTimeoutSec(void) { return _tlsNegotiationTimeoutSec; } - void setTlsNegotiationTimeoutSec(std::string timeout) { _tlsNegotiationTimeoutSec = timeout; } - - std::string getTlsNegotiationTimeoutMsec(void) { return _tlsNegotiationTimeoutMsec; } - void setTlsNegotiationTimeoutMsec(std::string timeout) { _tlsNegotiationTimeoutMsec = timeout; } - - private: - - /* Maps a string description of the SSL method + inline pjsip_transport_type_e getTransportType (void) { + return _transportType; + } + + inline pjsip_transport* getAccountTransport (void) { + return _transport; + } + + inline void setAccountTransport (pjsip_transport *transport) { + _transport = transport; + } + + std::string getTransportMapKey (void); + + DtmfType getDtmfType (void) { + return _dtmfType; + } + void setDtmfType (DtmfType type) { + _dtmfType = type; + } + + bool getSrtpEnable (void) { + return _srtpEnabled; + } + void setSrtpEnable (bool enabl) { + _srtpEnabled = enabl; + } + + std::string getSrtpKeyExchange (void) { + return _srtpKeyExchange; + } + void setSrtpKeyExchange (std::string key) { + _srtpKeyExchange = key; + } + + bool getSrtpFallback (void) { + return _srtpFallback; + } + void setSrtpFallback (bool fallback) { + _srtpFallback = fallback; + } + + bool getZrtpDisplaySas (void) { + return _zrtpDisplaySas; + } + void setZrtpDisplaySas (bool sas) { + _zrtpDisplaySas = sas; + } + + bool getZrtpDiaplaySasOnce (void) { + return _zrtpDisplaySasOnce; + } + void setZrtpDiaplaySasOnce (bool sasonce) { + _zrtpDisplaySasOnce = sasonce; + } + + bool getZrtpNotSuppWarning (void) { + return _zrtpNotSuppWarning; + } + void setZrtpNotSuppWarning (bool warning) { + _zrtpNotSuppWarning = warning; + } + + bool getZrtpHelloHash (void) { + return _zrtpHelloHash; + } + void setZrtpHelloHash (bool hellohash) { + _zrtpHelloHash = hellohash; + } + // void setSrtpKeyExchange + + std::string getRealm (void) { + return _realm; + } + void setRealm (std::string r) { + _realm = r; + } + + std::string getTlsEnable (void) { + return _tlsEnable; + } + void setTlsEnable (std::string enabl) { + _tlsEnable = enabl; + } + + std::string getTlsCaListFile (void) { + return _tlsCaListFile; + } + void setTlsCaListFile (std::string calist) { + _tlsCaListFile = calist; + } + + std::string getTlsCertificateFile (void) { + return _tlsCertificateFile; + } + void setTlsCertificateFile (std::string cert) { + _tlsCertificateFile = cert; + } + + std::string getTlsPrivateKeyFile (void) { + return _tlsPrivateKeyFile; + } + void setTlsPrivateKeyFile (std::string priv) { + _tlsPrivateKeyFile = priv; + } + + std::string getTlsPassword (void) { + return _tlsPassword; + } + void setTlsPassword (std::string pass) { + _tlsPassword = pass; + } + + std::string getTlsMethod (void) { + return _tlsMethod; + } + void setTlsMethod (std::string meth) { + _tlsMethod = meth; + } + + std::string getTlsCiphers (void) { + return _tlsCiphers; + } + void setTlsCiphers (std::string cipher) { + _tlsCiphers = cipher; + } + + std::string getTlsServerName (void) { + return _tlsServerName; + } + void setTlsServerName (std::string name) { + _tlsServerName = name; + } + + bool getTlsVerifyServer (void) { + return _tlsVerifyServer; + } + void setTlsVerifyServer (bool verif) { + _tlsVerifyServer = verif; + } + + bool getTlsVerifyClient (void) { + return _tlsVerifyClient; + } + void setTlsVerifyClient (bool verif) { + _tlsVerifyClient = verif; + } + + bool getTlsRequireClientCertificate (void) { + return _tlsRequireClientCertificate; + } + void setTlsRequireClientCertificate (bool require) { + _tlsRequireClientCertificate = require; + } + + std::string getTlsNegotiationTimeoutSec (void) { + return _tlsNegotiationTimeoutSec; + } + void setTlsNegotiationTimeoutSec (std::string timeout) { + _tlsNegotiationTimeoutSec = timeout; + } + + std::string getTlsNegotiationTimeoutMsec (void) { + return _tlsNegotiationTimeoutMsec; + } + void setTlsNegotiationTimeoutMsec (std::string timeout) { + _tlsNegotiationTimeoutMsec = timeout; + } + + private: + + /* Maps a string description of the SSL method * to the corresponding enum value in pjsip_ssl_method. - * @param method The string representation + * @param method The string representation * @return pjsip_ssl_method The corresponding value in the enum */ - pjsip_ssl_method sslMethodStringToPjEnum(const std::string& method); - + pjsip_ssl_method sslMethodStringToPjEnum (const std::string& method); + /* * Initializes tls settings from configuration file. * - */ - void initTlsConfiguration(void); - - /* - * Initializes STUN config from the config file - */ - void initStunConfiguration (void); - + */ + void initTlsConfiguration (void); + + /* + * Initializes STUN config from the config file + */ + void initStunConfiguration (void); + /* * Initializes set of additional credentials, if supplied by the user. */ - int initCredential(void); - + int initCredential (void); + /** - * If username is not provided, as it happens for Direct ip calls, + * If username is not provided, as it happens for Direct ip calls, * fetch the hostname of the machine on which the program is running * onto. * @return std::string The machine hostname as returned by pj_gethostname() */ - std::string getMachineName(void); - + std::string getMachineName (void); + /** - * If username is not provided, as it happens for Direct ip calls, - * fetch the Real Name field of the user that is currently - * running this program. + * If username is not provided, as it happens for Direct ip calls, + * fetch the Real Name field of the user that is currently + * running this program. * @return std::string The login name under which SFLPhone is running. - */ - std::string getLoginName(void); + */ + std::string getLoginName (void); + + std::string _routeSet; - std::string _routeSet; - // The pjsip client registration information pjsip_regc *_regc; // To check if the account is registered - bool _bRegister; + bool _bRegister; // Network settings std::string _registrationExpire; @@ -575,81 +751,81 @@ class SIPAccount : public Account // Flag which determine if _localIpAddress or _publishedIpAddress is used in // sip headers bool _publishedSameasLocal; - + std::string _publishedIpAddress; - + pj_uint16_t _localPort; pj_uint16_t _publishedPort; - std::string _serviceRoute; + std::string _serviceRoute; /** * The global TLS listener port which can be configured through the IP2IP_PROFILE */ pj_uint16_t _tlsListenerPort; - + pjsip_transport_type_e _transportType; - pjsip_transport* _transport; + pjsip_transport* _transport; // Special hack that is not here to stay // See #1852 bool _resolveOnce; - + //Credential information - pjsip_cred_info *_cred; - std::string _realm; + pjsip_cred_info *_cred; + std::string _realm; std::string _authenticationUsername; - Credentials credentials; + Credentials credentials; - // The TLS settings, if tls is chosen as - // a sip transport. - pjsip_tls_setting * _tlsSetting; + // The TLS settings, if tls is chosen as + // a sip transport. + pjsip_tls_setting * _tlsSetting; // The STUN server name, if applicable for internal use only - pj_str_t _stunServerName; + pj_str_t _stunServerName; // The STUN server port, if applicable pj_uint16_t _stunPort; DtmfType _dtmfType; - std::string _tlsEnable; - std::string _tlsPortStr; - std::string _tlsCaListFile; - std::string _tlsCertificateFile; - std::string _tlsPrivateKeyFile; - std::string _tlsPassword; - std::string _tlsMethod; - std::string _tlsCiphers; - std::string _tlsServerName; - bool _tlsVerifyServer; - bool _tlsVerifyClient; - bool _tlsRequireClientCertificate; - std::string _tlsNegotiationTimeoutSec; - std::string _tlsNegotiationTimeoutMsec; - - std::string _stunServer; - - bool _tlsEnabled; - bool _stunEnabled; - - // std::string _routeset; - - // std::string _realm; - // std::string _tlsListenerPort; - // std::string _routeSet; - // std::string _dtmfType; - - - bool _srtpEnabled; - std::string _srtpKeyExchange; - bool _srtpFallback; - - bool _zrtpDisplaySas; - bool _zrtpDisplaySasOnce; - bool _zrtpHelloHash; - bool _zrtpNotSuppWarning; + std::string _tlsEnable; + std::string _tlsPortStr; + std::string _tlsCaListFile; + std::string _tlsCertificateFile; + std::string _tlsPrivateKeyFile; + std::string _tlsPassword; + std::string _tlsMethod; + std::string _tlsCiphers; + std::string _tlsServerName; + bool _tlsVerifyServer; + bool _tlsVerifyClient; + bool _tlsRequireClientCertificate; + std::string _tlsNegotiationTimeoutSec; + std::string _tlsNegotiationTimeoutMsec; + + std::string _stunServer; + + bool _tlsEnabled; + bool _stunEnabled; + + // std::string _routeset; + + // std::string _realm; + // std::string _tlsListenerPort; + // std::string _routeSet; + // std::string _dtmfType; + + + bool _srtpEnabled; + std::string _srtpKeyExchange; + bool _srtpFallback; + + bool _zrtpDisplaySas; + bool _zrtpDisplaySasOnce; + bool _zrtpHelloHash; + bool _zrtpNotSuppWarning; }; diff --git a/sflphone-common/src/sip/sipcall.h b/sflphone-common/src/sip/sipcall.h index 46af03ad2d046c2338d4f8fd404b90103b249c5a..5c4eb4cf5f153184f52934e3c830c6c80f290ade 100644 --- a/sflphone-common/src/sip/sipcall.h +++ b/sflphone-common/src/sip/sipcall.h @@ -43,105 +43,132 @@ class AudioCodec; class Sdp; class AudioRtp; -namespace sfl { - class AudioRtpFactory; +namespace sfl +{ +class AudioRtpFactory; } /** * @file sipcall.h - * @brief SIPCall are SIP implementation of a normal Call + * @brief SIPCall are SIP implementation of a normal Call */ class SIPCall : public Call { - public: - - /** - * Constructor - * @param id The call identifier - * @param type The type of the call. Could be Incoming - * Outgoing - */ - SIPCall(const CallID& id, Call::CallType type, pj_pool_t *pool ); - - /** - * Destructor - */ - ~SIPCall(); - - /** - * Call Identifier - * @return int SIP call id - */ - int getCid() { return _cid; } - - /** - * Call Identifier - * @param cid SIP call id - */ - void setCid(int cid) { _cid = cid ; } - - /** - * Domain identifier - * @return int SIP domain id - */ - int getDid() { return _did; } - - /** - * Domain identifier - * @param did SIP domain id - */ - void setDid(int did) { _did = did; } - - /** - * Transaction identifier - * @return int SIP transaction id - */ - int getTid() { return _tid; } - - - - - /** - * Transaction identifier - * @param tid SIP transaction id - */ - void setTid(int tid) { _tid = tid; } - - void setXferSub(pjsip_evsub* sub) {_xferSub = sub;} - - pjsip_evsub *getXferSub() {return _xferSub;} - - void setInvSession(pjsip_inv_session* inv) {_invSession = inv;} - - pjsip_inv_session *getInvSession() {return _invSession;} - - Sdp* getLocalSDP (void) { return _local_sdp; } - - void setLocalSDP (Sdp *local_sdp) { _local_sdp = local_sdp; } - - /** Returns a pointer to the AudioRtp object */ - inline sfl::AudioRtpFactory * getAudioRtp(void) { return _audiortp; } - - private: - - int _cid; - int _did; - int _tid; - - // Copy Constructor - SIPCall(const SIPCall& rh); - - // Assignment Operator - SIPCall& operator=( const SIPCall& rh); - - /** Starting sound */ - sfl::AudioRtpFactory * _audiortp; - - pjsip_evsub *_xferSub; - - pjsip_inv_session *_invSession; - - Sdp *_local_sdp; + public: + + /** + * Constructor + * @param id The call identifier + * @param type The type of the call. Could be Incoming + * Outgoing + */ + SIPCall (const CallID& id, Call::CallType type, pj_pool_t *pool); + + /** + * Destructor + */ + ~SIPCall(); + + /** + * Call Identifier + * @return int SIP call id + */ + int getCid() { + return _cid; + } + + /** + * Call Identifier + * @param cid SIP call id + */ + void setCid (int cid) { + _cid = cid ; + } + + /** + * Domain identifier + * @return int SIP domain id + */ + int getDid() { + return _did; + } + + /** + * Domain identifier + * @param did SIP domain id + */ + void setDid (int did) { + _did = did; + } + + /** + * Transaction identifier + * @return int SIP transaction id + */ + int getTid() { + return _tid; + } + + + + + /** + * Transaction identifier + * @param tid SIP transaction id + */ + void setTid (int tid) { + _tid = tid; + } + + void setXferSub (pjsip_evsub* sub) { + _xferSub = sub; + } + + pjsip_evsub *getXferSub() { + return _xferSub; + } + + void setInvSession (pjsip_inv_session* inv) { + _invSession = inv; + } + + pjsip_inv_session *getInvSession() { + return _invSession; + } + + Sdp* getLocalSDP (void) { + return _local_sdp; + } + + void setLocalSDP (Sdp *local_sdp) { + _local_sdp = local_sdp; + } + + /** Returns a pointer to the AudioRtp object */ + inline sfl::AudioRtpFactory * getAudioRtp (void) { + return _audiortp; + } + + private: + + int _cid; + int _did; + int _tid; + + // Copy Constructor + SIPCall (const SIPCall& rh); + + // Assignment Operator + SIPCall& operator= (const SIPCall& rh); + + /** Starting sound */ + sfl::AudioRtpFactory * _audiortp; + + pjsip_evsub *_xferSub; + + pjsip_inv_session *_invSession; + + Sdp *_local_sdp; }; diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index c09f67e8c289006da47ed187a02cf102268cff6b..29de8360b2adac0c6356238ec36606a6ccf4857c 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -1597,7 +1597,7 @@ SIPVoIPLink::SIPCallReleased (SIPCall *call) void -SIPVoIPLink::SIPCallAnswered (SIPCall *call, pjsip_rx_data *rdata) +SIPVoIPLink::SIPCallAnswered (SIPCall *call, pjsip_rx_data *rdata UNUSED) { _info ("UserAgent: SIP call answered"); @@ -3023,27 +3023,9 @@ void set_voicemail_info (AccountID account, pjsip_msg_body *body) Manager::instance().startVoiceMessageNotification (account, voicemail); } -void SIPVoIPLink::handle_reinvite (SIPCall *call) +void SIPVoIPLink::handle_reinvite (SIPCall *call UNUSED) { - _debug ("UserAgent: Handle reinvite"); - /* - // Close the previous RTP session - call->getAudioRtp()->stop (); - call->setAudioStart (false); - - _debug ("Create new rtp session from handle_reinvite : %s:%i", call->getLocalIp().c_str(), call->getLocalAudioPort()); - _debug ("UserAgent: handle_reinvite"); - - try { - call->getAudioRtp()->initAudioRtpSession (call); - } catch (...) { - _debug ("! SIP Failure: Unable to create RTP Session (%s:%d)", __FILE__, __LINE__); - } - - - _debug("Handle reINVITE"); - */ } // This callback is called when the invite session state has changed @@ -3061,8 +3043,6 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e) _error ("UserAgent: Error: Call is NULL in call state changed callback"); return; } else { - // _debug(" call_on_state_changed: call id %s", call->getCallId().c_str()); - // _debug(" call_on_state_changed: call state %s", invitationStateMap[call->getInvSession()->state]); } //Retrieve the body message @@ -3370,11 +3350,11 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status) } -void call_on_forked (pjsip_inv_session *inv, pjsip_event *e) +void call_on_forked (pjsip_inv_session *inv UNUSED, pjsip_event *e UNUSED) { } -void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e) +void call_on_tsx_changed (pjsip_inv_session *inv UNUSED, pjsip_transaction *tsx, pjsip_event *e) { assert (tsx); @@ -4281,7 +4261,7 @@ void xfer_svr_cb (pjsip_evsub *sub, pjsip_event *event) } } -void on_rx_offer (pjsip_inv_session *inv, const pjmedia_sdp_session *offer) +void on_rx_offer (pjsip_inv_session *inv, const pjmedia_sdp_session *offer UNUSED) { _info ("UserAgent: Received SDP offer"); @@ -4559,7 +4539,7 @@ std::vector<std::string> SIPVoIPLink::getAllIpInterfaceByName (void) } -pj_bool_t stun_sock_on_status (pj_stun_sock *stun_sock, pj_stun_sock_op op, pj_status_t status) +pj_bool_t stun_sock_on_status (pj_stun_sock *stun_sock UNUSED, pj_stun_sock_op op UNUSED, pj_status_t status) { if (status == PJ_SUCCESS) return PJ_TRUE; @@ -4567,7 +4547,7 @@ pj_bool_t stun_sock_on_status (pj_stun_sock *stun_sock, pj_stun_sock_op op, pj_s return PJ_FALSE; } -pj_bool_t stun_sock_on_rx_data (pj_stun_sock *stun_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *src_addr, unsigned addr_len) +pj_bool_t stun_sock_on_rx_data (pj_stun_sock *stun_sock UNUSED, void *pkt UNUSED, unsigned pkt_len UNUSED, const pj_sockaddr_t *src_addr UNUSED, unsigned addr_len UNUSED) { return PJ_TRUE; } diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h index 20da9443255c77f55bd5016321acb2aa29cc1f16..eab4f13a393efbf1363376bd047845dada41609c 100644 --- a/sflphone-common/src/sip/sipvoiplink.h +++ b/sflphone-common/src/sip/sipvoiplink.h @@ -77,7 +77,7 @@ class SIPVoIPLink : public VoIPLink * Singleton method. Enable to retrieve the unique static instance * @return SIPVoIPLink* A pointer on the object */ - static SIPVoIPLink* instance( const AccountID& id ); + static SIPVoIPLink* instance (const AccountID& id); /** * Destructor @@ -85,40 +85,40 @@ class SIPVoIPLink : public VoIPLink ~SIPVoIPLink(); /* Copy Constructor */ - SIPVoIPLink(const SIPVoIPLink& rh); + SIPVoIPLink (const SIPVoIPLink& rh); /* Assignment Operator */ - SIPVoIPLink& operator=( const SIPVoIPLink& rh); + SIPVoIPLink& operator= (const SIPVoIPLink& rh); - /** - * Try to initiate the pjsip engine/thread and set config + /** + * Try to initiate the pjsip engine/thread and set config * @return bool True if OK */ - bool init(void); + bool init (void); /** * Shut the library and clean up */ - void terminate( void ); + void terminate (void); /** * Event listener. Each event send by the call manager is received and handled from here */ - void getEvent(void); + void getEvent (void); /** * Build and send SIP registration request * @return bool True on success * false otherwise */ - int sendRegister(AccountID id); + int sendRegister (AccountID id); /** * Build and send SIP unregistration request * @return bool True on success * false otherwise */ - int sendUnregister(AccountID id); + int sendUnregister (AccountID id); /** * Place a new call @@ -126,49 +126,49 @@ class SIPVoIPLink : public VoIPLink * @param toUrl The Sip address of the recipient of the call * @return Call* The current call */ - Call* newOutgoingCall(const CallID& id, const std::string& toUrl); + Call* newOutgoingCall (const CallID& id, const std::string& toUrl); /** * Answer the call * @param id The call identifier * @return int True on success */ - bool answer(const CallID& id); + bool answer (const CallID& id); /** * Hang up the call * @param id The call identifier * @return bool True on success */ - bool hangup(const CallID& id); + bool hangup (const CallID& id); /** * Hang up the call * @param id The call identifier * @return bool True on success */ - bool peerHungup(const CallID& id); + bool peerHungup (const CallID& id); /** * Cancel the call * @param id The call identifier * @return bool True on success */ - bool cancel(const CallID& id); + bool cancel (const CallID& id); /** * Put the call on hold * @param id The call identifier * @return bool True on success */ - bool onhold(const CallID& id); + bool onhold (const CallID& id); /** * Put the call off hold * @param id The call identifier * @return bool True on success */ - bool offhold(const CallID& id); + bool offhold (const CallID& id); /** * Transfer the call @@ -176,10 +176,10 @@ class SIPVoIPLink : public VoIPLink * @param to The recipient of the transfer * @return bool True on success */ - bool transfer(const CallID& id, const std::string& to); + bool transfer (const CallID& id, const std::string& to); /** Handle the incoming refer msg, not finished yet */ - bool transferStep2(SIPCall* call); + bool transferStep2 (SIPCall* call); /** * Refuse the call @@ -194,34 +194,34 @@ class SIPVoIPLink : public VoIPLink * @param code The char code * @return bool True on success */ - bool carryingDTMFdigits(const CallID& id, char code); + bool carryingDTMFdigits (const CallID& id, char code); /** * Send Dtmf using SIP INFO message */ - bool dtmfSipInfo(SIPCall *call, char code); + bool dtmfSipInfo (SIPCall *call, char code); /** * Send Dtmf over RTP */ - bool dtmfOverRtp(SIPCall* call, char code); + bool dtmfOverRtp (SIPCall* call, char code); - /** - * Terminate every call not hangup | brutal | Protected by mutex + /** + * Terminate every call not hangup | brutal | Protected by mutex */ - void terminateSIPCall(); - + void terminateSIPCall(); + /** * Terminate only one call */ - void terminateOneCall(const CallID& id); + void terminateOneCall (const CallID& id); /** * Send an outgoing call invite * @param call The current call * @return bool True if all is correct */ - bool SIPOutgoingInvite(SIPCall* call); + bool SIPOutgoingInvite (SIPCall* call); /** * Start a SIP Call @@ -229,32 +229,32 @@ class SIPVoIPLink : public VoIPLink * @param subject Undocumented * @return true if all is correct */ - bool SIPStartCall(SIPCall* call, const std::string& subject); + bool SIPStartCall (SIPCall* call, const std::string& subject); /** * Tell the user that the call was answered * @param */ - void SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata); + void SIPCallAnswered (SIPCall *call, pjsip_rx_data *rdata); /** * Handling 5XX/6XX error - * @param + * @param */ - void SIPCallServerFailure(SIPCall *call); + void SIPCallServerFailure (SIPCall *call); /** * Peer close the connection * @param */ - void SIPCallClosed(SIPCall *call); + void SIPCallClosed (SIPCall *call); /** * The call pointer was released * If the call was not cleared before, report an error * @param */ - void SIPCallReleased(SIPCall *call); + void SIPCallReleased (SIPCall *call); /** * Handle a re-invite request by the remote peer. @@ -268,106 +268,108 @@ class SIPVoIPLink : public VoIPLink * @param id The call identifier * @return SIPCall* A pointer on SIPCall object */ - SIPCall* getSIPCall(const CallID& id); + SIPCall* getSIPCall (const CallID& id); /** when we init the listener, how many times we try to bind a port? */ int _nbTryListenAddr; /** Increment the number of SIP account connected to this link */ - void incrementClients (void) { _clients++; } + void incrementClients (void) { + _clients++; + } /** Decrement the number of SIP account connected to this link */ void decrementClients (void); - /** - * Set Recording - * @param id The call identifier - */ - void setRecording(const CallID& id); - /** - * Returning state (true recording) - * @param id The call identifier - */ - bool isRecording(const CallID& id); + * Set Recording + * @param id The call identifier + */ + void setRecording (const CallID& id); /** - * Return the codec protocol used for this call + * Returning state (true recording) * @param id The call identifier */ - std::string getCurrentCodecName(); - + bool isRecording (const CallID& id); + + /** + * Return the codec protocol used for this call + * @param id The call identifier + */ + std::string getCurrentCodecName(); + int inv_session_reinvite (SIPCall *call, std::string direction=""); - + bool new_ip_to_ip_call (const CallID& id, const std::string& to); std::string get_useragent_name (const AccountID& id); - /** - * List all the interfaces on the system and return + /** + * List all the interfaces on the system and return * a vector list containing their IPV4 address. * @param void * @return std::vector<std::string> A std::string vector * of IPV4 address available on all of the interfaces on * the system. */ - std::vector<std::string> getAllIpInterface(void); + std::vector<std::string> getAllIpInterface (void); - /** - * List all the interfaces on the system and return - * a vector list containing their name (eth0, eth0:1 ...). - * @param void - * @return std::vector<std::string> A std::string vector - * of interface name available on all of the interfaces on - * the system. - */ - std::vector<std::string> getAllIpInterfaceByName(void); + /** + * List all the interfaces on the system and return + * a vector list containing their name (eth0, eth0:1 ...). + * @param void + * @return std::vector<std::string> A std::string vector + * of interface name available on all of the interfaces on + * the system. + */ + std::vector<std::string> getAllIpInterfaceByName (void); - /** - * List all the interfaces on the system and return - * a vector list containing their name (eth0, eth0:1 ...). - * @param void - * @return std::vector<std::string> A std::string vector - * of interface name available on all of the interfaces on - * the system. - */ - std::string getInterfaceAddrFromName(std::string ifaceName); + /** + * List all the interfaces on the system and return + * a vector list containing their name (eth0, eth0:1 ...). + * @param void + * @return std::vector<std::string> A std::string vector + * of interface name available on all of the interfaces on + * the system. + */ + std::string getInterfaceAddrFromName (std::string ifaceName); - /** - * Initialize the transport selector - * @param transport A transport associated with an account - * @param tp_sel A pointer to receive the transport selector structure - * - * @return pj_status_t PJ_SUCCESS if the structure was successfully initialized - */ - pj_status_t init_transport_selector (pjsip_transport *transport, pjsip_tpselector **tp_sel); + /** + * Initialize the transport selector + * @param transport A transport associated with an account + * @param tp_sel A pointer to receive the transport selector structure + * + * @return pj_status_t PJ_SUCCESS if the structure was successfully initialized + */ + pj_status_t init_transport_selector (pjsip_transport *transport, pjsip_tpselector **tp_sel); - /** - * Requests PJSIP library for local IP address, using pj_gethostbyname() - * @param addr* A string to be initialized - * - * @return bool True if addr successfully initialized - */ + /** + * Requests PJSIP library for local IP address, using pj_gethostbyname() + * @param addr* A string to be initialized + * + * @return bool True if addr successfully initialized + */ bool loadSIPLocalIP (std::string *addr); - /** - * This function unset the transport for a given account. It tests wether the - * associated transport is used by other accounts. If not, it shutdown the transport - * putting its reference counter to zero. PJSIP assumes transport destruction since - * this action can be delayed by ongoing SIP transactions. - */ - void shutdownSipTransport(const AccountID& accountID); + /** + * This function unset the transport for a given account. It tests wether the + * associated transport is used by other accounts. If not, it shutdown the transport + * putting its reference counter to zero. PJSIP assumes transport destruction since + * this action can be delayed by ongoing SIP transactions. + */ + void shutdownSipTransport (const AccountID& accountID); private: /** * Constructor * @param accountID The account identifier */ - SIPVoIPLink(const AccountID& accountID); + SIPVoIPLink (const AccountID& accountID); /* The singleton instance */ static SIPVoIPLink* _instance; @@ -381,9 +383,9 @@ class SIPVoIPLink : public VoIPLink */ pj_status_t enable_dns_srv_resolver (pjsip_endpoint *endpt, pj_dns_resolver ** p_resv); - void busy_sleep(unsigned msec); + void busy_sleep (unsigned msec); - /** + /** * Initialize the PJSIP library * Must be called before any other calls to the SIP layer * @@ -394,118 +396,118 @@ class SIPVoIPLink : public VoIPLink /** * Delete link-related stuff like calls */ - bool pjsip_shutdown(void); + bool pjsip_shutdown (void); pj_status_t stunServerResolve (AccountID id); - /** - * Function used to create a new sip transport or get an existing one from the map. - * The SIP transport is "acquired" according to account's current settings. - * This function should be called before registering an account - * @param accountID An account id for which transport is to be set - * - * @return bool True if the account is successfully created or successfully obtained - * from the transport map - */ - bool acquireTransport(const AccountID& accountID); - - - /** - * Create the default UDP transport according ot Ip2Ip profile settings - */ - bool createDefaultSipUdpTransport(); - - - /** - * Create the default TLS litener using IP2IP_PROFILE settings - */ - void createDefaultSipTlsListener(); - - - /** - * Create the default TLS litener according to account settings. - */ - void createTlsListener(const AccountID& accountID); - - - /** - * General Sip transport creation method according to the - * transport type specified in account settings - * @param id The account id for which a transport must - * be created. - */ - bool createSipTransport(AccountID id); - - - /** - * Method to store newly created UDP transport in internal transport map. - * Transports are stored in order to retreive them in case - * several accounts would share the same port number for UDP transprt. - * @param key The transport's port number - * @param transport A pointer to the UDP transport - */ - bool addTransportToMap(std::string key, pjsip_transport* transport); - - /** - * Create SIP UDP transport from account's setting - * @param id The account id for which a transport must - * be created. - * @return pj_status_t PJ_SUCCESS on success - */ + /** + * Function used to create a new sip transport or get an existing one from the map. + * The SIP transport is "acquired" according to account's current settings. + * This function should be called before registering an account + * @param accountID An account id for which transport is to be set + * + * @return bool True if the account is successfully created or successfully obtained + * from the transport map + */ + bool acquireTransport (const AccountID& accountID); + + + /** + * Create the default UDP transport according ot Ip2Ip profile settings + */ + bool createDefaultSipUdpTransport(); + + + /** + * Create the default TLS litener using IP2IP_PROFILE settings + */ + void createDefaultSipTlsListener(); + + + /** + * Create the default TLS litener according to account settings. + */ + void createTlsListener (const AccountID& accountID); + + + /** + * General Sip transport creation method according to the + * transport type specified in account settings + * @param id The account id for which a transport must + * be created. + */ + bool createSipTransport (AccountID id); + + + /** + * Method to store newly created UDP transport in internal transport map. + * Transports are stored in order to retreive them in case + * several accounts would share the same port number for UDP transprt. + * @param key The transport's port number + * @param transport A pointer to the UDP transport + */ + bool addTransportToMap (std::string key, pjsip_transport* transport); + + /** + * Create SIP UDP transport from account's setting + * @param id The account id for which a transport must + * be created. + * @return pj_status_t PJ_SUCCESS on success + */ int createUdpTransport (AccountID = ""); - /** - * Create a TLS transport from the default TLS listener from - * @param id The account id for which a transport must - * be created. - * @return pj_status_t PJ_SUCCESS on success - */ - pj_status_t createTlsTransport(const AccountID& id, std::string remoteAddr); - - /** - * Create a UDP transport using stun server to resove public address - * @param id The account id for which a transport must - * be created. - * @return pj_status_t PJ_SUCCESS on success - */ - pj_status_t createAlternateUdpTransport (AccountID id); - - - /** - * UDP Transports are stored in this map in order to retreive them in case - * several accounts would share the same port number. - */ - SipTransportMap _transportMap; - - /** For registration use only */ - int _regPort; - - /** Threading object */ - EventThread* _evThread; - ost::Mutex _mutexSIP; - - /* Number of SIP accounts connected to the link */ - int _clients; - - /* - * Get the correct address to use (ie advertised) from - * a uri. The corresponding transport that should be used - * with that uri will be discovered. - * - * @param uri The uri from which we want to discover the address to use - * @param transport The transport to use to discover the address - * @return pj_str_t The extern (public) address + /** + * Create a TLS transport from the default TLS listener from + * @param id The account id for which a transport must + * be created. + * @return pj_status_t PJ_SUCCESS on success */ - std::string findLocalAddressFromUri(const std::string& uri, pjsip_transport *transport); - - /* + pj_status_t createTlsTransport (const AccountID& id, std::string remoteAddr); + + /** + * Create a UDP transport using stun server to resove public address + * @param id The account id for which a transport must + * be created. + * @return pj_status_t PJ_SUCCESS on success + */ + pj_status_t createAlternateUdpTransport (AccountID id); + + + /** + * UDP Transports are stored in this map in order to retreive them in case + * several accounts would share the same port number. + */ + SipTransportMap _transportMap; + + /** For registration use only */ + int _regPort; + + /** Threading object */ + EventThread* _evThread; + ost::Mutex _mutexSIP; + + /* Number of SIP accounts connected to the link */ + int _clients; + + /* + * Get the correct address to use (ie advertised) from + * a uri. The corresponding transport that should be used + * with that uri will be discovered. + * + * @param uri The uri from which we want to discover the address to use + * @param transport The transport to use to discover the address + * @return pj_str_t The extern (public) address + */ + std::string findLocalAddressFromUri (const std::string& uri, pjsip_transport *transport); + + /* * Does the same as findLocalAddressFromUri but returns a port. * @param uri The uri from which we want to discover the port to use - * @param transport The transport to use to discover the port + * @param transport The transport to use to discover the port * @return int The extern (public) port */ - int findLocalPortFromUri(const std::string& uri, pjsip_transport *transport); + int findLocalPortFromUri (const std::string& uri, pjsip_transport *transport); }; diff --git a/sflphone-common/src/user_cfg.h b/sflphone-common/src/user_cfg.h index 3d950e71009b3ff37e27287f99d0697124a28c46..980881f889bbfa09f2ed8d2b4a7d77df59d4c486 100644 --- a/sflphone-common/src/user_cfg.h +++ b/sflphone-common/src/user_cfg.h @@ -81,7 +81,7 @@ #define WINDOW_POSITION_Y "Window.positionY" #define SHOW_STATUSICON "Statusicon.show" -#define IP2IP_PROFILE "IP2IP" +#define IP2IP_PROFILE "IP2IP" #define SIGNALISATION "VoIPLink" /** Section Signalisation */ #define ZRTP_ZIDFILE "zidFile" /** The filename used for storing ZIDs */ #define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */ @@ -104,11 +104,11 @@ #define URLHOOK_COMMAND "Hooks.url_command" #define URLHOOK_SIP_ENABLED "Hooks.sip_enabled" #define URLHOOK_IAX2_ENABLED "Hooks.iax2_enabled" -#define PHONE_NUMBER_HOOK_ENABLED "Hooks.phone_number_enabled" +#define PHONE_NUMBER_HOOK_ENABLED "Hooks.phone_number_enabled" #define PHONE_NUMBER_HOOK_ADD_PREFIX "Hooks.phone_number_add_prefix" #define EMPTY_FIELD "" /** Default value for empty field */ -#define DEFAULT_ACCOUNT_TYPE "SIP" +#define DEFAULT_ACCOUNT_TYPE "SIP" #define DFT_STUN_SERVER "stun.sflphone.org" /** Default STUN server address */ #define TRUE_STR "true" /** Default YES value */ #define FALSE_STR "false" /** Default NO value */ diff --git a/sflphone-common/src/voiplink.h b/sflphone-common/src/voiplink.h index e0d9bd6bdfc0de4f7ce4e780869479ba7736e8ff..f4bcecc2b7646da29cb8f8cc01d60a608c8d3efb 100644 --- a/sflphone-common/src/voiplink.h +++ b/sflphone-common/src/voiplink.h @@ -49,13 +49,14 @@ typedef std::map<CallID, Call*> CallMap; * @file voiplink.h * @brief Listener and manager interface for each VoIP protocol */ -class VoIPLink { +class VoIPLink +{ public: /** * Constructor * @param accountID The account identifier */ - VoIPLink(const AccountID& accountID); + VoIPLink (const AccountID& accountID); /** * Virtual destructor @@ -69,9 +70,9 @@ class VoIPLink { */ virtual void getEvent (void) = 0; - /** + /** * Virtual method - * Try to initiate the communication layer and set config + * Try to initiate the communication layer and set config * @return bool True if OK */ virtual bool init (void) = 0; @@ -88,7 +89,7 @@ class VoIPLink { * @return bool True on success * false otherwise */ - virtual int sendRegister ( AccountID id ) = 0; + virtual int sendRegister (AccountID id) = 0; /** * Virtual method @@ -96,7 +97,7 @@ class VoIPLink { * @return bool True on success * false otherwise */ - virtual int sendUnregister ( AccountID id ) = 0; + virtual int sendUnregister (AccountID id) = 0; /** * Place a new call @@ -104,49 +105,49 @@ class VoIPLink { * @param toUrl The address of the recipient of the call * @return Call* The current call */ - virtual Call* newOutgoingCall(const CallID& id, const std::string& toUrl) = 0; + virtual Call* newOutgoingCall (const CallID& id, const std::string& toUrl) = 0; /** * Answer the call * @param id The call identifier * @return bool True on success */ - virtual bool answer(const CallID& id) = 0; + virtual bool answer (const CallID& id) = 0; /** * Hang up a call * @param id The call identifier * @return bool True on success */ - virtual bool hangup(const CallID& id) = 0; + virtual bool hangup (const CallID& id) = 0; - /** - * Peer Hung up a call - * @param id The call identifier - * @return bool True on success - */ - virtual bool peerHungup(const CallID& id) = 0; + /** + * Peer Hung up a call + * @param id The call identifier + * @return bool True on success + */ + virtual bool peerHungup (const CallID& id) = 0; /** * Cancel the call dialing * @param id The call identifier * @return bool True on success */ - virtual bool cancel(const CallID& id) = 0; + virtual bool cancel (const CallID& id) = 0; /** * Put a call on hold * @param id The call identifier * @return bool True on success */ - virtual bool onhold(const CallID& id) = 0; + virtual bool onhold (const CallID& id) = 0; /** * Resume a call from hold state * @param id The call identifier * @return bool True on success */ - virtual bool offhold(const CallID& id) = 0; + virtual bool offhold (const CallID& id) = 0; /** * Transfer a call to specified URI @@ -154,14 +155,14 @@ class VoIPLink { * @param to The recipient of the call * @return bool True on success */ - virtual bool transfer(const CallID& id, const std::string& to) = 0; + virtual bool transfer (const CallID& id, const std::string& to) = 0; /** * Refuse incoming call * @param id The call identifier * @return bool True on success */ - virtual bool refuse(const CallID& id) = 0; + virtual bool refuse (const CallID& id) = 0; /** * Send DTMF @@ -169,40 +170,44 @@ class VoIPLink { * @param code The char code * @return bool True on success */ - virtual bool carryingDTMFdigits(const CallID& id, char code) = 0; + virtual bool carryingDTMFdigits (const CallID& id, char code) = 0; - /** - * Set Recording - * @param id The call identifier - */ - // virtual void setRecording(const CallID& id) = 0; + /** + * Set Recording + * @param id The call identifier + */ + // virtual void setRecording(const CallID& id) = 0; /** - * Return recording state - * @param id The call identifier - */ - // virtual bool isRecording(const CallID& id) = 0; + * Return recording state + * @param id The call identifier + */ + // virtual bool isRecording(const CallID& id) = 0; /** - * Return the codec protocol used for this call + * Return the codec protocol used for this call * @param id The call identifier */ virtual std::string getCurrentCodecName() = 0; - bool initDone (void) { return _initDone; } - void initDone (bool state) { _initDone = state; } + bool initDone (void) { + return _initDone; + } + void initDone (bool state) { + _initDone = state; + } /** Add a call to the call map (protected by mutex) * @param call A call pointer with a unique pointer * @return bool True if the call was unique and added */ - bool addCall(Call* call); + bool addCall (Call* call); /** Remove a call from the call map (protected by mutex) * @param id A Call ID * @return bool True if the call was correctly removed */ - bool removeCall(const CallID& id); + bool removeCall (const CallID& id); /** * Remove all the call from the map @@ -213,21 +218,25 @@ class VoIPLink { /** * @return AccountID parent Account's ID */ - inline AccountID& getAccountID(void) { return _accountID; } + inline AccountID& getAccountID (void) { + return _accountID; + } - Account* getAccountPtr(void); + Account* getAccountPtr (void); /** * @param accountID The account identifier */ - inline void setAccountID( const AccountID& accountID) { _accountID = accountID; } + inline void setAccountID (const AccountID& accountID) { + _accountID = accountID; + } - /** + /** * Get the call pointer from the call map (protected by mutex) * @param id A Call ID * @return Call* Call pointer or 0 */ - Call* getCall(const CallID& id); + Call* getCall (const CallID& id); private: /** diff --git a/sflphone-common/test/Makefile.am b/sflphone-common/test/Makefile.am index 41ab80fea2453830f84bd5d492b22f7165d03d5a..9da8e2f60349f9304800235277ac1158142b6d92 100644 --- a/sflphone-common/test/Makefile.am +++ b/sflphone-common/test/Makefile.am @@ -26,9 +26,7 @@ test_SOURCES = \ rtptest.h \ rtptest.cpp \ sdesnegotiatortest.h \ - sdesnegotiatortest.cpp \ - ringtonetest.h \ - ringtonetest.cpp + sdesnegotiatortest.cpp LLIBS=$(CPPUNIT_LIBS) \ ../src/sflphoned-logger.o \ diff --git a/sflphone-common/test/constants.h b/sflphone-common/test/constants.h index 5b3d0884f4c042d3b91b90325bab1f6d5aefb6aa..15bcd858601f5ff875c88ad956f8f234dc801cde 100644 --- a/sflphone-common/test/constants.h +++ b/sflphone-common/test/constants.h @@ -35,7 +35,7 @@ #define NO_STR "0" #define HISTORY_SAMPLE "history-sample" #define HISTORY_SAMPLE_SIZE 3 -#define CONFIG_SAMPLE "sflphonedrc-sample" +#define CONFIG_SAMPLE "sflphoned-sample.yml" #define HUGE_HISTORY_LIMIT 20000 #endif /* CONSTANTS_H_ */ diff --git a/sflphone-common/test/main.cpp b/sflphone-common/test/main.cpp index 0823891c597351b8208f094ddc0247c75e0550ee..1ce3b6b4e7b7d5ec7635a086ceaa0ca7261d9eec 100644 --- a/sflphone-common/test/main.cpp +++ b/sflphone-common/test/main.cpp @@ -30,8 +30,7 @@ #include <logger.h> #include <manager.h> - -#define CONFIG_SAMPLE "sflphonedrc-sample" +#include <constants.h> #include <cppunit/CompilerOutputter.h> #include <cppunit/extensions/TestFactoryRegistry.h>