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-client-gnome
Commits
068fb69b
Commit
068fb69b
authored
Mar 23, 2015
by
Stepan Salenikovich
Browse files
gnome: fix lrc not sending Unregister signal
Refs #69021 Change-Id: If5e254166887382a8c950dbac7c40140d1a1b926
parent
8bc51e5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ring_client.cpp
View file @
068fb69b
...
...
@@ -62,6 +62,8 @@ struct _RingClientPrivate {
GtkWidget
*
win
;
/* for libRingclient */
QCoreApplication
*
qtapp
;
/* UAM */
QMetaObject
::
Connection
uam_updated
;
};
G_DEFINE_TYPE_WITH_PRIVATE
(
RingClient
,
ring_client
,
GTK_TYPE_APPLICATION
);
...
...
@@ -83,25 +85,46 @@ init_exception_dialog(const char* msg)
gtk_widget_destroy
(
dialog
);
}
static
const
GActionEntry
ring_actions
[]
=
{
{
"accept"
,
NULL
,
NULL
,
NULL
,
NULL
,
{
0
}
},
{
"hangup"
,
NULL
,
NULL
,
NULL
,
NULL
,
{
0
}
},
{
"hold"
,
NULL
,
NULL
,
"false"
,
NULL
,
{
0
}
},
/* TODO implement the other actions */
// { "mute_audio", NULL, NULL, "false", NULL, {0} },
// { "mute_video", NULL, NULL, "false", NULL, {0} },
// { "transfer", NULL, NULL, "flase", NULL, {0} },
// { "record", NULL, NULL, "false", NULL, {0} }
};
/* this union is used to pass the int refering to the Action as a parameter to the GAction callback */
typedef
union
_int_ptr_t
{
int
value
;
gpointer
ptr
;
}
int_ptr_t
;
static
void
activate_action
(
GSimpleAction
*
action
,
G_GNUC_UNUSED
GVariant
*
parameter
,
gpointer
user_data
)
{
g_debug
(
"activating action: %s"
,
g_action_get_name
(
G_ACTION
(
action
)));
int_ptr_t
key
;
key
.
ptr
=
user_data
;
UserActionModel
::
Action
a
=
static_cast
<
UserActionModel
::
Action
>
(
key
.
value
);
UserActionModel
*
uam
=
CallModel
::
instance
()
->
userActionModel
();
uam
<<
a
;
}
static
int
ring_client_
command_line
(
GApplication
*
app
,
GApplicationCommandLine
*
cmdline
)
ring_client_
startup
(
GApplication
*
app
,
gint
argc
,
gchar
**
argv
)
{
G_APPLICATION_CLASS
(
ring_client_parent_class
)
->
startup
(
app
);
RingClient
*
client
=
RING_CLIENT
(
app
);
RingClientPrivate
*
priv
=
RING_CLIENT_GET_PRIVATE
(
client
);
gint
argc
;
gchar
**
argv
=
g_application_command_line_get_arguments
(
cmdline
,
&
argc
);
GOptionContext
*
context
=
ring_client_options_get_context
();
GError
*
error
=
NULL
;
if
(
g_option_context_parse
(
context
,
&
argc
,
&
argv
,
&
error
)
==
FALSE
)
{
g_print
(
_
(
"%s
\n
Run '%s --help' to see a full list of available command line options.
\n
"
),
error
->
message
,
argv
[
0
]);
g_error_free
(
error
);
g_option_context_free
(
context
);
return
1
;
}
g_option_context_free
(
context
);
/* init clutter */
int
clutter_error
;
if
((
clutter_error
=
gtk_clutter_init
(
&
argc
,
&
argv
))
!=
CLUTTER_INIT_SUCCESS
)
{
...
...
@@ -111,17 +134,18 @@ ring_client_command_line(GApplication *app, GApplicationCommandLine *cmdline)
/* init libRingClient and make sure its connected to the dbus */
try
{
/* TODO: do we care about passing the cmd line arguments here? */
priv
->
qtapp
=
new
QCoreApplication
(
argc
,
argv
);
/* the call model will try to connect to dring via dbus */
CallModel
::
instance
();
}
catch
(
const
char
*
msg
)
{
init_exception_dialog
(
msg
);
g_critical
(
"%s"
,
msg
);
return
1
;
}
catch
(
QString
&
msg
)
{
QByteArray
ba
=
msg
.
toLocal8Bit
();
const
char
*
c_str
=
ba
.
data
();
init_exception_dialog
(
c_str
);
g_critical
(
"%s"
,
c_str
);
return
1
;
}
...
...
@@ -136,55 +160,7 @@ ring_client_command_line(GApplication *app, GApplicationCommandLine *cmdline)
g_object_set
(
G_OBJECT
(
gtk_settings
),
"gtk-button-images"
,
TRUE
,
NULL
);
/* create an empty window */
if
(
priv
->
win
==
NULL
)
{
priv
->
win
=
ring_main_window_new
(
GTK_APPLICATION
(
app
));
}
gtk_window_present
(
GTK_WINDOW
(
priv
->
win
));
return
0
;
}
static
const
GActionEntry
ring_actions
[]
=
{
{
"accept"
,
NULL
,
NULL
,
NULL
,
NULL
,
{
0
}
},
{
"hangup"
,
NULL
,
NULL
,
NULL
,
NULL
,
{
0
}
},
{
"hold"
,
NULL
,
NULL
,
"false"
,
NULL
,
{
0
}
},
/* TODO implement the other actions */
// { "mute_audio", NULL, NULL, "false", NULL, {0} },
// { "mute_video", NULL, NULL, "false", NULL, {0} },
// { "transfer", NULL, NULL, "flase", NULL, {0} },
// { "record", NULL, NULL, "false", NULL, {0} }
};
/* this union is used to pass the int refering to the Action as a parameter to the GAction callback */
typedef
union
_int_ptr_t
{
int
value
;
gpointer
ptr
;
}
int_ptr_t
;
static
void
activate_action
(
GSimpleAction
*
action
,
G_GNUC_UNUSED
GVariant
*
parameter
,
gpointer
user_data
)
{
g_debug
(
"activating action: %s"
,
g_action_get_name
(
G_ACTION
(
action
)));
int_ptr_t
key
;
key
.
ptr
=
user_data
;
UserActionModel
::
Action
a
=
static_cast
<
UserActionModel
::
Action
>
(
key
.
value
);
UserActionModel
*
uam
=
CallModel
::
instance
()
->
userActionModel
();
uam
<<
a
;
}
static
void
ring_client_startup
(
GApplication
*
app
)
{
G_APPLICATION_CLASS
(
ring_client_parent_class
)
->
startup
(
app
);
RingClient
*
client
=
RING_CLIENT
(
app
);
/* add GActions */
g_action_map_add_action_entries
(
G_ACTION_MAP
(
app
),
ring_actions
,
G_N_ELEMENTS
(
ring_actions
),
client
);
...
...
@@ -207,7 +183,7 @@ ring_client_startup(GApplication *app)
}
/* change the state of the GActions based on the UserActionModel */
QObject
::
connect
(
uam
,
&
UserActionModel
::
dataChanged
,
[
actionHash
,
uam
](
const
QModelIndex
&
tl
,
const
QModelIndex
&
br
)
{
priv
->
uam_updated
=
QObject
::
connect
(
uam
,
&
UserActionModel
::
dataChanged
,
[
actionHash
,
uam
](
const
QModelIndex
&
tl
,
const
QModelIndex
&
br
)
{
const
int
first
(
tl
.
row
()),
last
(
br
.
row
());
for
(
int
i
=
first
;
i
<=
last
;
i
++
)
{
const
QModelIndex
&
idx
=
uam
->
index
(
i
,
0
);
...
...
@@ -221,6 +197,39 @@ ring_client_startup(GApplication *app)
}
}
});
return
0
;
}
static
int
ring_client_command_line
(
GApplication
*
app
,
GApplicationCommandLine
*
cmdline
)
{
RingClient
*
client
=
RING_CLIENT
(
app
);
RingClientPrivate
*
priv
=
RING_CLIENT_GET_PRIVATE
(
client
);
gint
argc
;
gchar
**
argv
=
g_application_command_line_get_arguments
(
cmdline
,
&
argc
);
GOptionContext
*
context
=
ring_client_options_get_context
();
GError
*
error
=
NULL
;
if
(
g_option_context_parse
(
context
,
&
argc
,
&
argv
,
&
error
)
==
FALSE
)
{
g_print
(
_
(
"%s
\n
Run '%s --help' to see a full list of available command line options.
\n
"
),
error
->
message
,
argv
[
0
]);
g_error_free
(
error
);
g_option_context_free
(
context
);
return
1
;
}
g_option_context_free
(
context
);
/* init libs and create main window only once */
if
(
priv
->
win
==
NULL
)
{
if
(
ring_client_startup
(
app
,
argc
,
argv
)
!=
0
)
return
1
;
priv
->
win
=
ring_main_window_new
(
GTK_APPLICATION
(
app
));
}
gtk_window_present
(
GTK_WINDOW
(
priv
->
win
));
return
0
;
}
static
void
...
...
@@ -229,6 +238,8 @@ ring_client_shutdown(GApplication *app)
RingClient
*
self
=
RING_CLIENT
(
app
);
RingClientPrivate
*
priv
=
RING_CLIENT_GET_PRIVATE
(
self
);
QObject
::
disconnect
(
priv
->
uam_updated
);
/* free the QCoreApplication, which will destroy all libRingClient models
* and thus send the Unregister signal over dbus to dring */
delete
priv
->
qtapp
;
...
...
@@ -250,7 +261,6 @@ ring_client_init(RingClient *self)
static
void
ring_client_class_init
(
RingClientClass
*
klass
)
{
G_APPLICATION_CLASS
(
klass
)
->
startup
=
ring_client_startup
;
G_APPLICATION_CLASS
(
klass
)
->
command_line
=
ring_client_command_line
;
G_APPLICATION_CLASS
(
klass
)
->
shutdown
=
ring_client_shutdown
;
}
...
...
Write
Preview
Supports
Markdown
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