Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
4d342d6f
Commit
4d342d6f
authored
10 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
gnome: add years to timer and reuse for call history display
Refs #47119 Change-Id: I9a7f0e5f6633feec4e9322ad9f38a2c6039b012a
parent
74a97294
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
gnome/src/callable_obj.c
+33
-4
33 additions, 4 deletions
gnome/src/callable_obj.c
gnome/src/callable_obj.h
+2
-0
2 additions, 0 deletions
gnome/src/callable_obj.h
gnome/src/contacts/calltree.c
+1
-27
1 addition, 27 deletions
gnome/src/contacts/calltree.c
with
36 additions
and
31 deletions
gnome/src/callable_obj.c
+
33
−
4
View file @
4d342d6f
...
...
@@ -41,6 +41,7 @@
#include
"contacts/calltree.h"
#include
"dbus.h"
#include
<unistd.h>
#include
<stdint.h>
gint
get_state_callstruct
(
gconstpointer
a
,
gconstpointer
b
)
{
...
...
@@ -193,12 +194,40 @@ gchar* get_peer_info(const gchar* const number, const gchar* const name)
gchar
*
get_call_duration
(
callable_obj_t
*
obj
)
{
long
duration
=
difftime
(
obj
->
_time_stop
,
obj
->
_time_start
);
char
time_str
[
32
];
format_duration
(
obj
,
obj
->
_time_stop
,
time_str
,
sizeof
time_str
);
if
(
duration
<
0
)
duration
=
0
;
return
g_strdup_printf
(
"<small>Duration:</small> %s"
,
time_str
);
}
return
g_strdup_printf
(
"<small>Duration:</small> %.2ld:%.2ld"
,
duration
/
60
,
duration
%
60
);
void
format_duration
(
callable_obj_t
*
obj
,
time_t
end
,
char
*
timestr
,
size_t
timestr_sz
)
{
const
gdouble
diff
=
difftime
(
end
,
obj
->
_time_start
);
guint32
seconds
=
CLAMP
(
diff
,
0
.
0
f
,
UINT32_MAX
);
enum
{
HOURS_PER_DAY
=
24
,
DAYS_PER_YEAR
=
365
,
SECONDS_PER_HOUR
=
3600
,
SECONDS_PER_DAY
=
SECONDS_PER_HOUR
*
HOURS_PER_DAY
,
SECONDS_PER_YEAR
=
DAYS_PER_YEAR
*
SECONDS_PER_DAY
};
const
guint32
years
=
seconds
/
SECONDS_PER_YEAR
;
const
guint32
days
=
(
seconds
/
SECONDS_PER_DAY
)
%
DAYS_PER_YEAR
;
const
guint32
hours
=
(
seconds
/
SECONDS_PER_HOUR
)
%
HOURS_PER_DAY
;
const
guint32
minutes
=
(
seconds
/
60
)
%
60
;
seconds
%=
60
;
if
(
years
)
g_snprintf
(
timestr
,
timestr_sz
,
_
(
"%uy %ud %02uh %02umn %02us"
),
years
,
days
,
hours
,
minutes
,
seconds
);
else
if
(
days
)
g_snprintf
(
timestr
,
timestr_sz
,
_
(
"%ud %02uh %02umn %02us"
),
days
,
hours
,
minutes
,
seconds
);
else
if
(
hours
)
g_snprintf
(
timestr
,
timestr_sz
,
"%u:%02u:%02u"
,
hours
,
minutes
,
seconds
);
else
g_snprintf
(
timestr
,
timestr_sz
,
"%02u:%02u"
,
minutes
,
seconds
);
}
static
...
...
This diff is collapsed.
Click to expand it.
gnome/src/callable_obj.h
+
2
−
0
View file @
4d342d6f
...
...
@@ -197,6 +197,8 @@ gchar* get_call_duration(callable_obj_t *obj);
gchar
*
get_formatted_start_timestamp
(
time_t
);
void
format_duration
(
callable_obj_t
*
obj
,
time_t
end
,
char
*
timestr
,
size_t
timestr_sz
);
gboolean
call_was_outgoing
(
callable_obj_t
*
obj
);
void
restore_call
(
const
gchar
*
id
);
...
...
This diff is collapsed.
Click to expand it.
gnome/src/contacts/calltree.c
+
1
−
27
View file @
4d342d6f
...
...
@@ -1170,29 +1170,6 @@ void calltree_display(calltab_t *tab, SFLPhoneClient *client)
update_actions
(
client
);
}
static
void
format_duration
(
guint32
seconds
,
char
*
timestr
,
size_t
timestr_sz
)
{
enum
{
HOURS_PER_DAY
=
24
,
SECONDS_PER_HOUR
=
3600
,
SECONDS_PER_DAY
=
SECONDS_PER_HOUR
*
HOURS_PER_DAY
};
const
guint32
days
=
seconds
/
SECONDS_PER_DAY
;
const
guint32
hours
=
(
seconds
/
SECONDS_PER_HOUR
)
%
HOURS_PER_DAY
;
const
guint32
minutes
=
(
seconds
/
60
)
%
60
;
seconds
%=
60
;
if
(
days
)
g_snprintf
(
timestr
,
timestr_sz
,
_
(
"%ud %02uh %02umn %02us"
),
days
,
hours
,
minutes
,
seconds
);
else
if
(
hours
)
g_snprintf
(
timestr
,
timestr_sz
,
"%u:%02u:%02u"
,
hours
,
minutes
,
seconds
);
else
g_snprintf
(
timestr
,
timestr_sz
,
"%02u:%02u"
,
minutes
,
seconds
);
}
gboolean
calltree_update_clock
(
G_GNUC_UNUSED
gpointer
data
)
{
if
(
calllist_empty
(
current_calls_tab
))
...
...
@@ -1200,7 +1177,6 @@ gboolean calltree_update_clock(G_GNUC_UNUSED gpointer data)
char
timestr
[
32
];
const
gchar
*
msg
=
""
;
double
duration
;
callable_obj_t
*
call
=
calltab_get_selected_call
(
current_calls_tab
);
if
(
call
)
{
...
...
@@ -1213,9 +1189,7 @@ gboolean calltree_update_clock(G_GNUC_UNUSED gpointer data)
case
CALL_STATE_BUSY
:
break
;
default:
duration
=
difftime
(
time
(
NULL
),
call
->
_time_start
);
format_duration
(
CLAMP
(
duration
,
0
.
0
f
,
UINT32_MAX
),
timestr
,
sizeof
(
timestr
));
format_duration
(
call
,
time
(
NULL
),
timestr
,
sizeof
(
timestr
));
msg
=
timestr
;
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment