Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
b4d135bc
Commit
b4d135bc
authored
Mar 27, 2014
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified HistoryEntry to keep the name separate from the uri
parent
7c14a3b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
history.py
blink/history.py
+33
-34
mainwindow.py
blink/mainwindow.py
+3
-2
No files found.
blink/history.py
View file @
b4d135bc
...
...
@@ -32,7 +32,7 @@ class HistoryManager(object):
def
__init__
(
self
):
try
:
data
=
pickle
.
load
(
open
(
ApplicationData
.
get
(
'calls_history'
)))
if
not
isinstance
(
data
,
list
)
or
not
all
(
isinstance
(
item
,
HistoryEntry
)
for
item
in
data
):
if
not
isinstance
(
data
,
list
)
or
not
all
(
isinstance
(
item
,
HistoryEntry
)
and
item
.
text
for
item
in
data
):
raise
ValueError
(
"invalid save data"
)
except
Exception
:
self
.
calls
=
[]
...
...
@@ -103,15 +103,18 @@ class HistoryEntry(object):
incoming_failed_icon
=
IconDescriptor
(
Resources
.
get
(
'icons/arrow-inward-red.svg'
))
outgoing_failed_icon
=
IconDescriptor
(
Resources
.
get
(
'icons/arrow-outward-red.svg'
))
def
__init__
(
self
,
direction
,
remote_identity
,
target_uri
,
account_id
,
call_time
,
duration
,
reason
=
None
):
def
__init__
(
self
,
direction
,
name
,
uri
,
account_id
,
call_time
,
duration
,
failed
=
False
,
reason
=
None
):
self
.
direction
=
direction
self
.
remote_identity
=
remote_identity
self
.
target_uri
=
target_
uri
self
.
name
=
name
self
.
uri
=
uri
self
.
account_id
=
account_id
self
.
call_time
=
call_time
self
.
duration
=
duration
self
.
failed
=
failed
self
.
reason
=
reason
self
.
failed
=
False
def
__reduce__
(
self
):
return
(
self
.
__class__
,
(
self
.
direction
,
self
.
name
,
self
.
uri
,
self
.
account_id
,
self
.
call_time
,
self
.
duration
,
self
.
failed
,
self
.
reason
))
def
__eq__
(
self
,
other
):
return
self
is
other
...
...
@@ -138,35 +141,9 @@ class HistoryEntry(object):
else
:
return
self
.
incoming_normal_icon
if
self
.
direction
==
'incoming'
else
self
.
outgoing_normal_icon
@
classmethod
def
from_session
(
cls
,
session
):
if
session
.
start_time
is
None
and
session
.
end_time
is
not
None
:
# Session may have anded before it fully started
session
.
start_time
=
session
.
end_time
call_time
=
session
.
start_time
or
datetime
.
now
()
if
session
.
start_time
and
session
.
end_time
:
duration
=
session
.
end_time
-
session
.
start_time
else
:
duration
=
None
remote_identity
=
session
.
remote_identity
remote_uri
=
'
%
s@
%
s'
%
(
remote_identity
.
uri
.
user
,
remote_identity
.
uri
.
host
)
match
=
cls
.
phone_number_re
.
match
(
remote_uri
)
if
match
:
remote_uri
=
match
.
group
(
'number'
)
try
:
contact
=
next
(
contact
for
contact
in
AddressbookManager
()
.
get_contacts
()
if
remote_uri
in
(
addr
.
uri
for
addr
in
contact
.
uris
))
except
StopIteration
:
display_name
=
remote_identity
.
display_name
else
:
display_name
=
contact
.
name
if
display_name
and
display_name
!=
remote_uri
:
remote_identity
=
'
%
s <
%
s>'
%
(
display_name
,
remote_uri
)
else
:
remote_identity
=
remote_uri
return
cls
(
session
.
direction
,
remote_identity
,
remote_uri
,
unicode
(
session
.
account
.
id
),
call_time
,
duration
)
def
__unicode__
(
self
):
result
=
unicode
(
self
.
remote_identity
)
@
property
def
text
(
self
):
result
=
unicode
(
self
.
name
)
if
self
.
call_time
:
call_date
=
self
.
call_time
.
date
()
today
=
date
.
today
()
...
...
@@ -191,4 +168,26 @@ class HistoryEntry(object):
result
+=
' (
%
s)'
%
self
.
reason
.
title
()
return
result
@
classmethod
def
from_session
(
cls
,
session
):
if
session
.
start_time
is
None
and
session
.
end_time
is
not
None
:
# Session may have anded before it fully started
session
.
start_time
=
session
.
end_time
call_time
=
session
.
start_time
or
datetime
.
now
()
if
session
.
start_time
and
session
.
end_time
:
duration
=
session
.
end_time
-
session
.
start_time
else
:
duration
=
None
remote_uri
=
'
%
s@
%
s'
%
(
session
.
remote_identity
.
uri
.
user
,
session
.
remote_identity
.
uri
.
host
)
match
=
cls
.
phone_number_re
.
match
(
remote_uri
)
if
match
:
remote_uri
=
match
.
group
(
'number'
)
try
:
contact
=
next
(
contact
for
contact
in
AddressbookManager
()
.
get_contacts
()
if
remote_uri
in
(
addr
.
uri
for
addr
in
contact
.
uris
))
except
StopIteration
:
display_name
=
session
.
remote_identity
.
display_name
else
:
display_name
=
contact
.
name
return
cls
(
session
.
direction
,
display_name
,
remote_uri
,
unicode
(
session
.
account
.
id
),
call_time
,
duration
)
blink/mainwindow.py
View file @
b4d135bc
...
...
@@ -383,8 +383,9 @@ class MainWindow(base_class, ui_class):
self
.
history_menu
.
clear
()
if
self
.
history_manager
.
calls
:
for
entry
in
reversed
(
self
.
history_manager
.
calls
):
action
=
self
.
history_menu
.
addAction
(
entry
.
icon
,
unicode
(
entry
)
)
action
=
self
.
history_menu
.
addAction
(
entry
.
icon
,
entry
.
text
)
action
.
entry
=
entry
action
.
setToolTip
(
entry
.
uri
)
else
:
action
=
self
.
history_menu
.
addAction
(
"Call history is empty"
)
action
.
setEnabled
(
False
)
...
...
@@ -396,7 +397,7 @@ class MainWindow(base_class, ui_class):
account
=
account_manager
.
get_account
(
action
.
entry
.
account_id
)
except
KeyError
:
account
=
None
contact
,
contact_uri
=
URIUtils
.
find_contact
(
action
.
entry
.
target_
uri
)
contact
,
contact_uri
=
URIUtils
.
find_contact
(
action
.
entry
.
uri
)
session_manager
.
create_session
(
contact
,
contact_uri
,
[
StreamDescription
(
'audio'
)],
account
=
account
)
# TODO: memorize media type and use it? -Saul (not sure about history in/out -Dan)
def
_AH_SystemTrayShowWindow
(
self
,
checked
):
...
...
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