Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
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
Evert Mouw
gajim-plugins
Commits
b41ce172
Commit
b41ce172
authored
13 years ago
by
Dicson
Browse files
Options
Downloads
Patches
Plain Diff
Hamster plugin added
parent
585a4fde
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hamster/__init__.py
+1
-0
1 addition, 0 deletions
hamster/__init__.py
hamster/hamster.py
+112
-0
112 additions, 0 deletions
hamster/hamster.py
hamster/manifest.ini
+9
-0
9 additions, 0 deletions
hamster/manifest.ini
with
122 additions
and
0 deletions
hamster/__init__.py
0 → 100644
+
1
−
0
View file @
b41ce172
from
hamster
import
HamsterIntegrationPlugin
This diff is collapsed.
Click to expand it.
hamster/hamster.py
0 → 100644
+
112
−
0
View file @
b41ce172
# -*- coding: utf-8 -*-
import
dbus
import
gobject
import
datetime
as
dt
from
common
import
gajim
from
common
import
ged
from
common
import
dbus_support
from
plugins
import
GajimPlugin
from
plugins.helpers
import
log_calls
,
log
from
common.pep
import
ACTIVITIES
HAMSTAER_INTERFACE
=
'
org.gnome.Hamster
'
SUBACTIVITIES
=
[]
subactivity_
=
[
ACTIVITIES
[
x
].
keys
()
for
x
in
ACTIVITIES
.
keys
()]
for
x
in
subactivity_
:
SUBACTIVITIES
=
SUBACTIVITIES
+
x
SUBACTIVITIES
=
set
(
SUBACTIVITIES
)
SUBACTIVITIES
.
remove
(
'
category
'
)
XMPP_ACTIVITIES
=
set
(
ACTIVITIES
.
keys
())
class
HamsterIntegrationPlugin
(
GajimPlugin
):
@log_calls
(
'
HamsterIntegrationPlugin
'
)
def
init
(
self
):
self
.
description
=
_
(
'
Integration with project hamster
\n
'
'
see https://trac.gajim.org/ticket/6993
\n
'
'
and http://projecthamster.wordpress.com/about/
'
)
self
.
config_dialog
=
None
self
.
events_handlers
=
{}
@log_calls
(
'
HamsterIntegrationPlugin
'
)
def
activate
(
self
):
if
not
dbus_support
.
supported
:
return
self
.
bus
=
dbus_support
.
session_bus
.
SessionBus
()
try
:
self
.
session_presence
=
self
.
bus
.
get_object
(
HAMSTAER_INTERFACE
,
'
/org/gnome/Hamster
'
)
except
:
gajim
.
log
.
debug
(
'
Hamster D-Bus service not found
'
)
return
self
.
active
=
True
self
.
bus
.
add_signal_receiver
(
self
.
hamster_facts_changed
,
'
FactsChanged
'
,
HAMSTAER_INTERFACE
)
gajim
.
ged
.
register_event_handler
(
'
our-show
'
,
ged
.
POSTGUI
,
self
.
on_our_status
)
self
.
pep_dict
=
{}
@log_calls
(
'
HamsterIntegrationPlugin
'
)
def
deactivate
(
self
):
if
not
dbus_support
.
supported
or
not
self
.
active
:
return
self
.
active
=
False
self
.
bus
.
remove_signal_receiver
(
self
.
hamster_facts_changed
,
"
FactsChanged
"
,
dbus_interface
=
HAMSTAER_INTERFACE
)
def
hamster_facts_changed
(
self
,
*
args
,
**
kw
):
# get hamster tags
facts
=
self
.
session_presence
.
GetTodaysFacts
(
dbus_interface
=
HAMSTAER_INTERFACE
)
if
self
.
from_dbus_fact
(
facts
[
-
1
])[
'
end_time
'
]:
accounts
=
gajim
.
connections
.
keys
()
for
account
in
accounts
:
if
gajim
.
account_is_connected
(
account
):
connection
=
gajim
.
connections
[
account
]
connection
.
retract_activity
()
return
last_fact
=
self
.
from_dbus_fact
(
facts
[
-
1
])
tags
=
set
(
last_fact
[
'
tags
'
])
activity
=
"
Other
"
activity_candidates
=
XMPP_ACTIVITIES
.
intersection
(
tags
)
if
len
(
activity_candidates
)
>=
1
:
activity
=
list
(
activity_candidates
)[
0
]
subactivity
=
'
other
'
subactivity_candidates
=
SUBACTIVITIES
.
intersection
(
tags
)
if
len
(
subactivity_candidates
)
>=
1
:
subactivity
=
list
(
subactivity_candidates
)[
0
]
# send activity
accounts
=
gajim
.
connections
.
keys
()
for
account
in
accounts
:
if
gajim
.
account_is_connected
(
account
):
connection
=
gajim
.
connections
[
account
]
connection
.
send_activity
(
activity
,
subactivity
,
last_fact
[
'
fact
'
])
def
from_dbus_fact
(
self
,
fact
):
'''
unpack the struct into a proper dict
'''
return
dict
(
fact
=
fact
[
4
],
start_time
=
dt
.
datetime
.
utcfromtimestamp
(
fact
[
1
]),
end_time
=
dt
.
datetime
.
utcfromtimestamp
(
fact
[
2
])
if
fact
[
2
]
else
None
,
description
=
fact
[
3
],
activity_id
=
fact
[
5
],
category
=
fact
[
6
],
tags
=
fact
[
7
],
date
=
dt
.
datetime
.
utcfromtimestamp
(
fact
[
8
]).
date
(),
delta
=
dt
.
timedelta
(
days
=
fact
[
9
]
//
(
24
*
60
*
60
),
seconds
=
fact
[
9
]
%
(
24
*
60
*
60
)),
id
=
fact
[
0
])
def
on_our_status
(
self
,
network_event
):
gajim
.
ged
.
remove_event_handler
(
'
our-show
'
,
ged
.
POSTGUI
,
self
.
on_our_status
)
gobject
.
timeout_add
(
10000
,
self
.
hamster_facts_changed
)
This diff is collapsed.
Click to expand it.
hamster/manifest.ini
0 → 100644
+
9
−
0
View file @
b41ce172
[info]
name:
Hamstar
integration
short_name:
hamstar_integration
version:
0.1
description:
Integration
with
project
hamster
see
https://trac.gajim.org/ticket/6993
and
http://projecthamster.wordpress.com/about/
authors:
Denis
Fomin
<fominde@gmail.com>
homepage:
http://trac-plugins.gajim.org/wiki/
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