Commit 45f2b6a0 authored by Alexandre Savard's avatar Alexandre Savard

[#2402] Code indent

parent 784d42f4
......@@ -5,7 +5,7 @@
# Savoir-faire Linux Inc
# http://www.sflphone.org
style=kr # Kernighan & Ritchie style formatting/indenting uses linux bracket
style=k&r # Kernighan & Ritchie style formatting/indenting uses linux bracket
indent=spaces=4 # Use spaces instead of tabs for indentation
indent-classes # Indent 'class' and 'struct' blocks so that the blocks 'public:', 'protected:' and 'private:' are indented
indent-switches # Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block
......
This diff is collapsed.
......@@ -40,8 +40,7 @@
/** @enum account_state_t
* This enum have all the states an account can take.
*/
typedef enum
{
typedef enum {
/** Invalid state */
ACCOUNT_STATE_INVALID = 0,
/** The account is registered */
......@@ -123,31 +122,31 @@ void account_list_remove (const gchar * accountID);
* @param state The state
* @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
*/
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
*/
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
......@@ -160,47 +159,47 @@ void account_list_set_current (account_t *current);
* @param s 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
*/
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);
......
This diff is collapsed.
......@@ -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,19 +154,19 @@ 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.
*/
void sflphone_fill_ip2ip_profile(void);
void sflphone_fill_ip2ip_profile (void);
/**
* @return The internal hash table representing
......@@ -210,22 +210,22 @@ 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);
/**
......@@ -233,7 +233,7 @@ void sflphone_join_conference(const gchar* sel_confID, const gchar* drag_confID)
* 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
......@@ -245,14 +245,14 @@ void sflphone_srtp_sdes_on(callable_obj_t * c);
* 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
......@@ -261,31 +261,31 @@ void sflphone_srtp_zrtp_off( callable_obj_t * c );
* @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
......@@ -295,10 +295,10 @@ void sflphone_request_go_clear(void);
* @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);
#endif
......@@ -37,28 +37,24 @@
#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;
}
}
......@@ -67,7 +63,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, "<");
......@@ -75,21 +71,21 @@ 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;
}
......@@ -101,29 +97,30 @@ gchar* call_get_audio_codec (callable_obj_t *obj)
gchar *format ="";
int samplerate;
if (obj)
{
if (obj) {
audio_codec = dbus_get_current_codec_name (obj);
codec = codec_list_get_by_name (audio_codec, NULL);
if (codec){
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);
}
......@@ -150,13 +147,14 @@ 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_stop));
set_timestamp (& (obj->_time_start));
set_timestamp (& (obj->_time_stop));
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;
......@@ -194,7 +192,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;
}
......@@ -210,12 +208,11 @@ 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) {
switch (token)
{
switch (token) {
case 0:
history_state = get_history_state_from_id (*ptr);
break;
......@@ -241,6 +238,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details
}
}
if (g_strcasecmp (peer_name, "empty") == 0)
peer_name="";
......@@ -262,7 +260,8 @@ void free_callable_obj_t (callable_obj_t *c)
g_free (c);
}
void attach_thumbnail (callable_obj_t *call, GdkPixbuf *pixbuf) {
void attach_thumbnail (callable_obj_t *call, GdkPixbuf *pixbuf)
{
call->_contact_thumbnail = pixbuf;
}
......@@ -270,8 +269,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;
}
......@@ -279,11 +278,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;
......@@ -310,25 +310,23 @@ gchar* get_call_duration (callable_obj_t *obj)
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);
else
res = g_markup_printf_escaped("00:%i", duration);
}
if (duration / 60 == 0) {
if (duration < 10)
res = g_markup_printf_escaped ("00:0%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);
}
......@@ -358,8 +356,7 @@ gchar* serialize_history_entry (callable_obj_t *entry)
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:
......@@ -371,14 +368,14 @@ 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)
{
if (obj) {
// Fetch the current timestamp
(void) time (&now);
lt = obj->_time_start;
......@@ -387,21 +384,22 @@ gchar* get_formatted_start_timestamp (callable_obj_t *obj) {
if (now - lt < UNIX_WEEK) {
if (now-lt < UNIX_DAY) {
strftime((char *)str, 100, N_("today at %R"), (const struct tm *)ptr);
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);
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);
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);
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 "";
}
......@@ -410,13 +408,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)
......@@ -424,8 +422,9 @@ time_t convert_gchar_to_timestamp (gchar *timestamp)
return (time_t) atoi (timestamp);
}
gchar*
get_peer_information (callable_obj_t *c) {
gchar*
get_peer_information (callable_obj_t *c)
{
gchar *res;
......
......@@ -40,8 +40,7 @@
* @enum history_state
* This enum have all the state a call can take in the history
*/
typedef enum
{
typedef enum {
MISSED,
INCOMING,
OUTGOING
......@@ -51,8 +50,7 @@ typedef enum
* @enum contact_type
* This enum have all types of contacts: HOME phone, cell phone, etc...
*/
typedef enum
{
typedef enum {
CONTACT_PHONE_HOME,
CONTACT_PHONE_BUSINESS,
CONTACT_PHONE_MOBILE
......@@ -62,8 +60,7 @@ typedef enum
* @enum callable_obj_type
* This enum have all types of items
</