Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
norstbox
gajim
Commits
e9672422
Commit
e9672422
authored
18 years ago
by
jimpp
Browse files
Options
Downloads
Patches
Plain Diff
#1005 preparation : move popups and sound code for incomming new messages to notify.py
parent
1a7fbe72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gajim.py
+12
-50
12 additions, 50 deletions
src/gajim.py
src/notify.py
+52
-4
52 additions, 4 deletions
src/notify.py
with
64 additions
and
54 deletions
src/gajim.py
+
12
−
50
View file @
e9672422
...
...
@@ -511,63 +511,25 @@ class Interface:
not
gajim
.
contacts
.
get_contact
(
account
,
jid
)
and
not
pm
:
return
# Is it a first or next message received ?
first
=
False
if
not
chat_control
and
not
gajim
.
awaiting_events
[
account
].
has_key
(
jid_of_control
):
# It's a first message and not a Private Message
first
=
True
if
gajim
.
config
.
get_per
(
'
soundevents
'
,
'
first_message_received
'
,
'
enabled
'
)
and
first
:
helpers
.
play_sound
(
'
first_message_received
'
)
elif
gajim
.
config
.
get_per
(
'
soundevents
'
,
'
next_message_received
'
,
'
enabled
'
):
helpers
.
play_sound
(
'
next_message_received
'
)
if
pm
:
room_jid
=
jid
nick
=
resource
if
first
:
if
gajim
.
config
.
get
(
'
notify_on_new_message
'
)
and
\
helpers
.
allow_showing_notification
(
account
):
room_name
,
t
=
gajim
.
get_room_name_and_server_from_room_jid
(
room_jid
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
priv_msg_recv.png
'
)
path
=
gtkgui_helpers
.
get_path_to_generic_or_avatar
(
img
)
title
=
_
(
'
New Private Message from room %s
'
)
%
room_name
text
=
_
(
'
%(nickname)s: %(message)s
'
)
%
{
'
nickname
'
:
nick
,
'
message
'
:
message
}
notify
.
popup
(
_
(
'
New Private Message
'
),
full_jid_with_resource
,
account
,
'
pm
'
,
path_to_image
=
path
,
title
=
title
,
text
=
text
)
groupchat_control
.
on_private_message
(
nick
,
message
,
array
[
2
])
return
if
first
:
if
gajim
.
config
.
get
(
'
notify_on_new_message
'
)
and
\
helpers
.
allow_showing_notification
(
account
):
text
=
message
if
msg_type
==
'
normal
'
:
# single message
event_type
=
_
(
'
New Single Message
'
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
single_msg_recv.png
'
)
title
=
_
(
'
New Single Message from %(nickname)s
'
)
%
\
{
'
nickname
'
:
gajim
.
get_name_from_jid
(
account
,
jid
)}
else
:
# chat message
event_type
=
_
(
'
New Message
'
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
chat_msg_recv.png
'
)
title
=
_
(
'
New Message from %(nickname)s
'
)
%
\
{
'
nickname
'
:
gajim
.
get_name_from_jid
(
account
,
jid
)}
path
=
gtkgui_helpers
.
get_path_to_generic_or_avatar
(
img
)
notify
.
popup
(
event_type
,
jid_of_control
,
account
,
msg_type
,
path_to_image
=
path
,
title
=
title
,
text
=
text
)
# array: (jid, msg, time, encrypted, msg_type, subject)
self
.
roster
.
on_message
(
jid
,
message
,
array
[
2
],
account
,
array
[
3
],
msg_type
,
array
[
5
],
resource
,
msg_id
)
nickname
=
resource
msg_type
=
'
pm
'
groupchat_control
.
on_private_message
(
nickname
,
message
,
array
[
2
])
else
:
# array: (jid, msg, time, encrypted, msg_type, subject)
self
.
roster
.
on_message
(
jid
,
message
,
array
[
2
],
account
,
array
[
3
],
msg_type
,
array
[
5
],
resource
,
msg_id
)
nickname
=
gajim
.
get_name_from_jid
(
account
,
jid
)
# Check and do wanted notifications
notify
.
notify
(
'
new_message
'
,
jid
,
account
,
[
msg_type
,
first
,
nickname
,
message
])
if
self
.
remote_ctrl
:
self
.
remote_ctrl
.
raise_signal
(
'
NewMessage
'
,
(
account
,
array
))
...
...
This diff is collapsed.
Click to expand it.
src/notify.py
+
52
−
4
View file @
e9672422
...
...
@@ -62,7 +62,23 @@ def notify(event, jid, account, parameters):
if
gajim
.
config
.
get_per
(
'
soundevents
'
,
'
contact_disconnected
'
,
'
enabled
'
):
do_sound
=
True
elif
(
event
==
'
new_message
'
):
message_type
=
parameters
[
0
]
first
=
parameters
[
1
]
nickname
=
parameters
[
2
]
message
=
parameters
[
3
]
if
gajim
.
config
.
get
(
'
notify_on_new_message
'
)
and
\
helpers
.
allow_showing_notification
(
account
)
and
first
:
do_popup
=
True
if
first
and
gajim
.
config
.
get_per
(
'
soundevents
'
,
'
first_message_received
'
,
'
enabled
'
):
do_sound
=
True
elif
not
first
and
gajim
.
config
.
get_per
(
'
soundevents
'
,
'
next_message_received
'
,
'
enabled
'
):
do_sound
=
True
else
:
print
'
*Event not implemeted yet*
'
# Do the wanted notifications
if
(
do_popup
):
if
(
event
==
'
contact_connected
'
or
event
==
'
contact_disconnected
'
or
\
...
...
@@ -112,10 +128,42 @@ def notify(event, jid, account, parameters):
text
=
status_message
popup
(
_
(
'
Contact Signed Out
'
),
jid
,
account
,
path_to_image
=
path
,
title
=
title
,
text
=
text
)
else
:
print
'
Event not implemeted yet
'
elif
(
event
==
'
new_message
'
):
if
message_type
==
'
normal
'
:
# single message
event_type
=
_
(
'
New Single Message
'
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
single_msg_recv.png
'
)
title
=
_
(
'
New Single Message from %(nickname)s
'
)
%
\
{
'
nickname
'
:
nickname
}
text
=
message
elif
message_type
==
'
pm
'
:
# private message
event_type
=
_
(
'
New Private Message
'
)
room_name
,
t
=
gajim
.
get_room_name_and_server_from_room_jid
(
jid
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
priv_msg_recv.png
'
)
title
=
_
(
'
New Private Message from room %s
'
)
%
room_name
text
=
_
(
'
%(nickname)s: %(message)s
'
)
%
{
'
nickname
'
:
nickname
,
'
message
'
:
message
}
else
:
# chat message
event_type
=
_
(
'
New Message
'
)
img
=
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
chat_msg_recv.png
'
)
title
=
_
(
'
New Message from %(nickname)s
'
)
%
\
{
'
nickname
'
:
nickname
}
text
=
message
path
=
gtkgui_helpers
.
get_path_to_generic_or_avatar
(
img
)
popup
(
event_type
,
jid
,
account
,
message_type
,
path_to_image
=
path
,
title
=
title
,
text
=
text
)
if
(
do_sound
):
helpers
.
play_sound
(
event
)
if
(
event
==
'
new_message
'
):
if
first
:
helpers
.
play_sound
(
'
first_message_received
'
)
else
:
helpers
.
play_sound
(
'
next_message_received
'
)
elif
(
event
==
'
contact_connected
'
or
event
==
'
contact_disconnected
'
):
helpers
.
play_sound
(
event
)
def
popup
(
event_type
,
jid
,
account
,
msg_type
=
''
,
path_to_image
=
None
,
...
...
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