Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
45f2b6a0
Commit
45f2b6a0
authored
Aug 31, 2010
by
Alexandre Savard
Browse files
[#2402] Code indent
parent
784d42f4
Changes
156
Expand all
Hide whitespace changes
Inline
Side-by-side
astylerc
View file @
45f2b6a0
...
...
@@ -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
...
...
sflphone-client-gnome/src/accountlist.c
View file @
45f2b6a0
...
...
@@ -36,357 +36,366 @@
GQueue
*
accountQueue
;
/* GCompareFunc to compare a accountID (gchar* and a account_t) */
gint
is_accountID_struct
(
gconstpointer
a
,
gconstpointer
b
)
{
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
)
{
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
(
" %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
(
" %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
()
;
current
=
account_list_get_current
();
if
(
current
)
return
current
->
accountID
;
else
return
""
;
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
;
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
),
"SIP"
)
==
0
)
n
++
;
}
if
(
strcmp
(
g_hash_table_lookup
(
current
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
n
++
;
}
return
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
)
{
if
(
g_strcasecmp
(
g_hash_table_lookup
(
current
->
properties
,
ACCOUNT_MAILBOX
),
""
)
!=
0
)
return
TRUE
;
}
return
FALSE
;
return
FALSE
;
}
void
current_account_set_message_number
(
guint
nb
)
{
account_t
*
current
;
account_t
*
current
;
current
=
account_list_get_current
();
if
(
current
)
{
current
->
_messages_number
=
nb
;
}
current
=
account_list_get_current
();
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
);
}