Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
eac99852
Commit
eac99852
authored
Apr 09, 2008
by
Emmanuel Milou
Browse files
Desktop notifications for accounts registration problems
parent
320ba789
Changes
4
Hide whitespace changes
Inline
Side-by-side
sflphone-gtk/src/SFLnotify.c
View file @
eac99852
...
...
@@ -42,7 +42,7 @@ notify_incoming_call( call_t* c )
callerid
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
NORM
AL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
CRITIC
AL
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
((
g_strcasecmp
(
__TIMEOUT_MODE
,
"default"
)
==
0
)
?
__TIMEOUT_TIME
:
NOTIFY_EXPIRES_NEVER
));
...
...
@@ -100,7 +100,7 @@ notify_voice_mails( guint count , account_t* acc )
body
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
NORMAL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
LOW
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
NOTIFY_EXPIRES_DEFAULT
);
...
...
@@ -112,7 +112,7 @@ notify_voice_mails( guint count , account_t* acc )
}
void
notify_
registered
_account
s
(
void
)
notify_
switch
_account
(
account_t
*
acc
)
{
// the account is different from NULL
GdkPixbuf
*
pixbuf
;
...
...
@@ -120,35 +120,90 @@ notify_registered_accounts( void )
gchar
*
body
=
""
;
notify_init
(
"sflphone"
);
guint
size
=
account_list_get_size
();
int
i
;
body
=
g_markup_printf_escaped
(
_
(
"Calling with %s account <i>%s</i>"
)
,
g_hash_table_lookup
(
acc
->
properties
,
ACCOUNT_TYPE
)
,
g_hash_table_lookup
(
acc
->
properties
,
ACCOUNT_ALIAS
));
title
=
g_markup_printf_escaped
(
_
(
"Switching account"
));
pixbuf
=
gdk_pixbuf_new_from_file
(
ICON_DIR
"/sflphone.png"
,
NULL
);
notification
=
notify_notification_new
(
title
,
body
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_NORMAL
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
NOTIFY_EXPIRES_DEFAULT
);
notify_notification_add_action
(
notification
,
"ignore"
,
_
(
"Ignore"
)
,
(
NotifyActionCallback
)
ignore_call_cb
,
NULL
,
NULL
);
if
(
!
notify_notification_show
(
notification
,
NULL
))
{
g_print
(
"notify(), failed to send notification
\n
"
);
}
}
void
notify_no_accounts
(
)
{
GdkPixbuf
*
pixbuf
;
gchar
*
title
;
gchar
*
body
=
""
;
notify_init
(
"sflphone"
);
body
=
g_markup_printf_escaped
(
_
(
"You haven't setup any accounts"
));
title
=
g_markup_printf_escaped
(
_
(
"Error"
));
pixbuf
=
gdk_pixbuf_new_from_file
(
ICON_DIR
"/sflphone.png"
,
NULL
);
notification
=
notify_notification_new
(
title
,
body
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_CRITICAL
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
NOTIFY_EXPIRES_DEFAULT
);
notify_notification_add_action
(
notification
,
"setup"
,
_
(
"Setup Accounts"
)
,
(
NotifyActionCallback
)
setup_accounts_cb
,
NULL
,
NULL
);
if
(
!
notify_notification_show
(
notification
,
NULL
))
{
g_print
(
"notify(), failed to send notification
\n
"
);
}
}
void
setup_accounts_cb
(
NotifyNotification
*
notification
,
gchar
*
action
,
gpointer
data
)
{
show_accounts_window
(
0
);
g_object_unref
(
notification
);
}
if
(
size
>
0
){
for
(
i
=
0
;
i
<
size
;
i
++
){
void
notify_no_registered_accounts
(
)
{
GdkPixbuf
*
pixbuf
;
gchar
*
title
;
gchar
*
body
=
""
;
notify_init
(
"sflphone"
);
body
=
g_markup_printf_escaped
(
_
(
"%s%s (%s) - State:<i>%s</i>"
)
,
body
,
g_hash_table_lookup
(
account_list_get_nth
(
i
)
->
properties
,
ACCOUNT_ALIAS
),
g_hash_table_lookup
(
account_list_get_nth
(
i
)
->
properties
,
ACCOUNT_TYPE
)
,
account_state_name
(
account_list_get_nth
(
i
)
->
state
))
;
}
body
=
g_markup_printf_escaped
(
_
(
"You have no registered accounts"
));
title
=
g_markup_printf_escaped
(
_
(
"
Accounts
"
));
title
=
g_markup_printf_escaped
(
_
(
"
Error
"
));
pixbuf
=
gdk_pixbuf_new_from_file
(
ICON_DIR
"/sflphone.png"
,
NULL
);
pixbuf
=
gdk_pixbuf_new_from_file
(
ICON_DIR
"/sflphone.png"
,
NULL
);
notification
=
notify_notification_new
(
title
,
body
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
NORM
AL
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
NOTIFY_EXPIRES_DEFAULT
);
notify_notification_add_action
(
notification
,
"
ignore
"
,
_
(
"
Ignore
"
)
,
(
NotifyActionCallback
)
ignore_call
_cb
,
NULL
,
NULL
);
notification
=
notify_notification_new
(
title
,
body
,
NULL
,
NULL
);
notify_notification_set_urgency
(
notification
,
NOTIFY_URGENCY_
CRITIC
AL
);
notify_notification_set_icon_from_pixbuf
(
notification
,
pixbuf
);
notify_notification_attach_to_status_icon
(
notification
,
get_status_icon
()
);
notify_notification_set_timeout
(
notification
,
NOTIFY_EXPIRES_DEFAULT
);
notify_notification_add_action
(
notification
,
"
setup
"
,
_
(
"
Setup Accounts
"
)
,
(
NotifyActionCallback
)
setup_accounts
_cb
,
NULL
,
NULL
);
if
(
!
notify_notification_show
(
notification
,
NULL
))
{
g_print
(
"notify(), failed to send notification
\n
"
);
}
if
(
!
notify_notification_show
(
notification
,
NULL
))
{
g_print
(
"notify(), failed to send notification
\n
"
);
}
}
sflphone-gtk/src/SFLnotify.h
View file @
eac99852
...
...
@@ -42,7 +42,9 @@ void notify_incoming_call( call_t* c);
void
notify_voice_mails
(
guint
count
,
account_t
*
acc
);
void
notify_registered_accounts
();
void
notify_switch_account
(
account_t
*
acc
);
void
notify_no_accounts
(
);
void
notify_no_registered_accounts
(
);
/*
* Callback when answer button is pressed.
* Action: Pick up the incoming call
...
...
@@ -67,4 +69,5 @@ void refuse_call_cb( NotifyNotification *notification, gchar *action, gpointer d
*/
void
ignore_call_cb
(
NotifyNotification
*
notification
,
gchar
*
action
,
gpointer
data
);
void
setup_accounts_cb
(
NotifyNotification
*
notification
,
gchar
*
action
,
gpointer
data
);
#endif
sflphone-gtk/src/accountlist.c
View file @
eac99852
...
...
@@ -23,7 +23,7 @@
#include <string.h>
GQueue
*
accountQueue
;
account_t
*
__CURRENT_ACCOUNT
=
NULL
;
gchar
*
__CURRENT_ACCOUNT
_ID
=
NULL
;
/* GCompareFunc to compare a accountID (gchar* and a account_t) */
gint
...
...
@@ -129,19 +129,19 @@ account_list_get_nth ( guint n )
account_t
*
account_list_get_current
(
)
{
return
__CURRENT_ACCOUNT
;
return
account_list_get_by_id
(
__CURRENT_ACCOUNT
_ID
)
;
}
void
account_list_set_current_id
(
const
gchar
*
accountID
)
{
__CURRENT_ACCOUNT
=
account_list_get_by_id
(
g_strdup
(
accountID
)
)
;
__CURRENT_ACCOUNT
_ID
=
g_strdup
(
accountID
);
}
void
account_list_set_current_pos
(
guint
n
)
{
__CURRENT_ACCOUNT
=
account_list_get_nth
(
n
);
__CURRENT_ACCOUNT
_ID
=
account_list_get_nth
(
n
)
->
accountID
;
}
const
gchar
*
account_state_name
(
account_state_t
s
)
...
...
sflphone-gtk/src/actions.c
View file @
eac99852
...
...
@@ -194,8 +194,8 @@ sflphone_init()
{
dbus_register
(
getpid
(),
"Gtk+ Client"
);
sflphone_fill_account_list
();
sflphone_set_current_account
();
sflphone_fill_codec_list
();
sflphone_set_current_account
();
return
TRUE
;
}
}
...
...
@@ -568,16 +568,16 @@ sflphone_keypad( guint keyval, gchar * key)
void
sflphone_place_call
(
call_t
*
c
)
{
//status_bar_display_account(c);
if
(
c
->
state
==
CALL_STATE_DIALING
)
{
account_t
*
current
=
account_list_get_current
();
if
(
current
)
{
if
(
strcmp
(
g_hash_table_lookup
(
current
->
properties
,
"Status"
),
"REGISTERED"
)
==
0
)
if
(
g_
strc
asec
mp
(
g_hash_table_lookup
(
current
->
properties
,
"Status"
),
"REGISTERED"
)
==
0
)
{
// OK, everything alright - the call is made with the current account
c
->
accountID
=
current
->
accountID
;
status_bar_display_account
(
c
);
dbus_place_call
(
c
);
}
else
...
...
@@ -588,19 +588,21 @@ sflphone_place_call ( call_t * c )
for
(
pos
=
1
;
pos
<
account_list_get_size
()
;
pos
++
){
current
=
account_list_get_nth
(
pos
);
if
(
current
){
if
(
strcmp
(
g_hash_table_lookup
(
current
->
properties
,
"Status"
),
"REGISTERED"
)
==
0
){
//
notify_switch_account();
if
(
g_
strc
asec
mp
(
g_hash_table_lookup
(
current
->
properties
,
"Status"
),
"REGISTERED"
)
==
0
){
notify_switch_account
(
current
);
//main_warning_error_message(_("Switch account."));
c
->
accountID
=
current
->
accountID
;
status_bar_display_account
(
c
);
dbus_place_call
(
c
);
break
;
}
}
}
notify_no_registered_accounts
();
}
}
else
{
//
notify_no_accounts();
notify_no_accounts
();
main_window_error_message
(
_
(
"There is no accounts to make this call with."
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment