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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Peter Shkenev
gajim
Commits
b854555e
Commit
b854555e
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
fix strings to be more readable; add get_status (did not test yet); raise allover
parent
7d357dfe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gajim-remote.py
+60
-50
60 additions, 50 deletions
src/gajim-remote.py
src/remote_control.py
+21
-2
21 additions, 2 deletions
src/remote_control.py
with
81 additions
and
52 deletions
src/gajim-remote.py
+
60
−
50
View file @
b854555e
...
...
@@ -59,6 +59,14 @@ def __init__(self):
def
__str__
(
self
):
return
_
(
'
D-Bus is not present on this machine or python module is missing
'
)
class
SessionBusNotPresent
(
Exception
):
'''
This exception indicates that there is no session daemon
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
Session bus is not available
'
)
try
:
import
dbus
except
:
...
...
@@ -88,7 +96,7 @@ def __init__(self):
#
self
.
commands
=
{
'
help
'
:[
_
(
'
show a help on specific command
'
),
_
(
'
show
s
a help on specific command
'
),
[
#User gets help for the command, specified by this parameter
(
_
(
'
command
'
),
...
...
@@ -100,110 +108,112 @@ def __init__(self):
[]
],
'
show_next_unread
'
:
[
_
(
'
Popup a window with the next unread message
'
),
_
(
'
Popup
s
a window with the next unread message
'
),
[]
],
'
list_contacts
'
:
[
_
(
'
Print a list of all contacts in the roster.
\
Each contact appear on a separate line
'
),
_
(
'
Prints a list of all contacts in the roster. Each contact appear on a separate line
'
),
[
(
_
(
'
account
'
),
_
(
'
show only contacts of the
\
given account
'
),
False
)
(
_
(
'
account
'
),
_
(
'
show only contacts of the given account
'
),
False
)
]
],
'
list_accounts
'
:
[
_
(
'
Print a list of registered accounts
'
),
_
(
'
Print
s
a list of registered accounts
'
),
[]
],
'
change_status
'
:
[
_
(
'
Change the status of account or accounts
'
),
_
(
'
Change
s
the status of account or accounts
'
),
[
(
_
(
'
status
'
),
_
(
'
one of: offline, online, chat, away,
\
xa, dnd, invisible
'
),
True
),
(
_
(
'
status
'
),
_
(
'
one of: offline, online, chat, away, xa, dnd, invisible
'
),
True
),
(
_
(
'
message
'
),
_
(
'
status message
'
),
False
),
(
_
(
'
account
'
),
_
(
'
change status of account
"
account
"
.
\
If not specified, try to change status of all accounts that
\
have
"
sync with global status
"
option set
'
),
False
)
(
_
(
'
account
'
),
_
(
'
change status of account
"
account
"
.
'
'
If not specified, try to change status of all accounts that
have
'
'
"
sync with global status
"
option set
'
),
False
)
]
],
'
open_chat
'
:
[
_
(
'
Show the chat dialog so that you can send messages to a
\
contact
'
),
_
(
'
Shows the chat dialog so that you can send messages to a contact
'
),
[
(
'
jid
'
,
_
(
'
JID of the contact that you want to chat
\
with
'
),
(
'
jid
'
,
_
(
'
JID of the contact that you want to chat with
'
),
True
),
(
_
(
'
account
'
),
_
(
'
if specified, contact is taken from
\
the
contact list of this account
'
),
False
)
(
_
(
'
account
'
),
_
(
'
if specified, contact is taken from
the
'
'
contact list of this account
'
),
False
)
]
],
'
send_message
'
:[
_
(
'
Send new message to a contact in the roster. Both OpenPGP
\
key
and account are optional. If you want to set only
\'
account
\'
,
without
\
\'
OpenPGP key
\'
, just set
\'
OpenPGP key
\'
to
\'\'
.
'
),
_
(
'
Send
s
new message to a contact in the roster. Both OpenPGP
key
'
'
and account are optional. If you want to set only
\'
account
\'
,
'
'
without
\'
OpenPGP key
\'
, just set
\'
OpenPGP key
\'
to
\'\'
.
'
),
[
(
'
jid
'
,
_
(
'
JID of the contact that will receive the
\
message
'
),
True
),
(
'
jid
'
,
_
(
'
JID of the contact that will receive the message
'
),
True
),
(
_
(
'
message
'
),
_
(
'
message contents
'
),
True
),
(
_
(
'
pgp key
'
),
_
(
'
if specified, the message will be
\
encrypted
using this public key
'
),
False
),
(
_
(
'
account
'
),
_
(
'
if specified, the message will be
\
sent
using this account
'
),
False
),
(
_
(
'
pgp key
'
),
_
(
'
if specified, the message will be
encrypted
'
'
using this public key
'
),
False
),
(
_
(
'
account
'
),
_
(
'
if specified, the message will be
sent
'
'
using this account
'
),
False
),
]
],
'
contact_info
'
:
[
_
(
'
Get detailed info on a contact
'
),
_
(
'
Get
s
detailed info on a contact
'
),
[
(
'
jid
'
,
_
(
'
JID of the contact
'
),
True
)
]
],
'
send_file
'
:
[
_
(
'
Send file to a contact
'
),
_
(
'
Send
s
file to a contact
'
),
[
(
_
(
'
file
'
),
_
(
'
File path
'
),
True
),
(
'
jid
'
,
_
(
'
JID of the contact
'
),
True
),
(
_
(
'
account
'
),
_
(
'
if specified, file will be sent
\
using this
account
'
),
False
)
(
_
(
'
account
'
),
_
(
'
if specified, file will be sent
using this
'
'
account
'
),
False
)
]
],
'
prefs_list
'
:
[
_
(
'
List all preferences and their values
'
),
_
(
'
List
s
all preferences and their values
'
),
[
]
],
'
prefs_put
'
:
[
_
(
'
Set value of
\'
key
\'
to
\'
value
\'
.
'
),
_
(
'
Set
s
value of
\'
key
\'
to
\'
value
\'
.
'
),
[
(
_
(
'
key=value
'
),
_
(
'
\'
key
\'
is the name of the preference,
\
\'
value
\'
is the value to set it to
'
),
True
)
(
_
(
'
key=value
'
),
_
(
'
\'
key
\'
is the name of the preference,
'
'
\'
value
\'
is the value to set it to
'
),
True
)
]
],
'
prefs_del
'
:
[
_
(
'
Delete a preference item
'
),
_
(
'
Delete
s
a preference item
'
),
[
(
_
(
'
key
'
),
_
(
'
name of the preference to be deleted
'
),
True
)
]
],
'
prefs_store
'
:
[
_
(
'
Write the current state of Gajim preferences to the
\
.config
file
'
),
_
(
'
Write
s
the current state of Gajim preferences to the
.config
'
'
file
'
),
[
]
],
'
remove_contact
'
:
[
_
(
'
Remove contact from roster
'
),
_
(
'
Remove
s
contact from roster
'
),
[
(
'
jid
'
,
_
(
'
JID of the contact
'
),
True
),
(
_
(
'
account
'
),
_
(
'
if specified, contact is taken from
\
the
contact list of this account
'
),
False
)
(
_
(
'
account
'
),
_
(
'
if specified, contact is taken from
the
'
'
contact list of this account
'
),
False
)
]
],
'
add_contact
'
:
[
_
(
'
Add contact to roster
'
),
_
(
'
Add
s
contact to roster
'
),
[
(
_
(
'
account
'
),
_
(
'
Add new contact to this account.
'
),
True
)
(
_
(
'
account
'
),
_
(
'
Add
s
new contact to this account.
'
),
True
)
]
]
],
'
get_status
'
:
[
_
(
'
Returns current status
'
),
[
(
_
(
'
account
'
),
_
(
'
if specified, returns status for this account;
'
'
Else returns global status
'
),
False
)
]
],
}
if
self
.
argv_len
<
2
or
\
...
...
@@ -227,7 +237,7 @@ def __init__(self):
id
=
self
.
sbus
.
add_signal_receiver
(
self
.
show_vcard_info
,
'
VcardInfo
'
,
INTERFACE
,
SERVICE
,
OBJ_PATH
)
except
Exception
,
e
:
send_error
(
_
(
'
Service
not a
vailable
'
)
+
'
:
'
+
str
(
e
))
raise
Service
NotA
vailable
res
=
self
.
call_remote_method
()
self
.
print_result
(
res
)
...
...
@@ -245,8 +255,8 @@ def print_result(self, res):
if
res
is
False
:
if
self
.
argv_len
<
4
:
send_error
(
_
(
'
\'
%s
\'
is not in your roster.
\n
\
Please specify account for sending the message.
'
)
%
sys
.
argv
[
2
])
send_error
(
_
(
'
\'
%s
\'
is not in your roster.
\n
'
'
Please specify account for sending the message.
'
)
%
sys
.
argv
[
2
])
else
:
send_error
(
_
(
'
You have no active account
'
))
elif
self
.
command
==
'
list_accounts
'
:
...
...
@@ -273,7 +283,7 @@ def init_connection(self):
try
:
self
.
sbus
=
dbus
.
SessionBus
()
except
:
send_error
(
_
(
'
Session bus is not available.
'
)
+
'
:
'
+
str
(
e
))
raise
SessionBusNotPresent
if
_version
[
1
]
>=
30
:
obj
=
self
.
sbus
.
get_object
(
SERVICE
,
OBJ_PATH
)
...
...
@@ -555,7 +565,7 @@ def call_remote_method(self):
res
=
self
.
method
(
sys
.
argv
[
2
],
sys
.
argv
[
3
],
sys
.
argv
[
4
],
sys
.
argv
[
5
])
return
res
except
Exception
,
e
:
except
Exception
:
raise
ServiceNotAvailable
return
None
...
...
This diff is collapsed.
Click to expand it.
src/remote_control.py
+
21
−
2
View file @
b854555e
...
...
@@ -48,6 +48,9 @@
OBJ_PATH
=
'
/org/gajim/dbus/RemoteObject
'
SERVICE
=
'
org.gajim.dbus
'
STATUS_LIST
=
[
'
offline
'
,
'
connecting
'
,
'
online
'
,
'
chat
'
,
'
away
'
,
'
xa
'
,
'
dnd
'
,
'
invisible
'
]
class
Remote
:
def
__init__
(
self
):
self
.
signal_object
=
None
...
...
@@ -106,7 +109,8 @@ def __init__(self, service):
self
.
prefs_del
,
self
.
prefs_put
,
self
.
add_contact
,
self
.
remove_contact
self
.
remove_contact
,
self
.
get_status
,
])
def
raise_signal
(
self
,
signal
,
arg
):
...
...
@@ -127,14 +131,29 @@ def raise_signal(self, signal, arg):
def
VcardInfo
(
self
,
*
vcard
):
pass
def
get_status
(
self
,
*
args
):
'''
get_status(account = None)
returns status (show to be exact) which is the global one
unless account is given
'''
account
=
self
.
_get_real_arguments
(
args
,
1
)
accounts
=
gajim
.
contacts
.
keys
()
if
not
account
and
len
(
accounts
)
==
1
:
# if there is only one account in roster, take it as default
# if user did not ask for account
account
=
accounts
[
0
]
# FIXME: get global status, not the status from first (ask Yann)
if
account
:
# return show for this account (either first or the specified)
index
=
gajim
.
connections
[
account
].
connected
return
STATUS_LIST
[
index
]
def
send_file
(
self
,
*
args
):
'''
send_file(file_path, jid, account=None)
'''
send_file(file_path, jid, account=None)
send file, located at
'
file_path
'
to
'
jid
'
, using account
(optional)
'
account
'
'''
file_path
,
jid
,
account
=
self
.
_get_real_arguments
(
args
,
3
)
accounts
=
gajim
.
contacts
.
keys
()
# if there is only one account in roster, take it as default
# if user did not ask for account
if
not
account
and
len
(
accounts
)
==
1
:
account
=
accounts
[
0
]
if
account
:
...
...
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