1
# Copyright (C) 2008 Valmantas Paliksa <walmis at balticum-tv dot lt>
2
# Copyright (C) 2008 Tadas Dailyda <tadas at dailyda dot com>
4
# Licensed under the GNU General Public License Version 3
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
from gi.repository import GObject
20
from blueman.ods.OdsBase import OdsBase
22
class OdsSession(OdsBase):
24
'connected' : (GObject.SignalFlags.RUN_FIRST, None, ()),
25
'cancelled' : (GObject.SignalFlags.NO_HOOKS, None, ()),
26
'disconnected' : (GObject.SignalFlags.NO_HOOKS, None, ()),
27
'transfer-started' : (GObject.SignalFlags.NO_HOOKS, None, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,)),
28
'transfer-progress' : (GObject.SignalFlags.NO_HOOKS, None, (GObject.TYPE_PYOBJECT,)),
29
'transfer-completed' : (GObject.SignalFlags.NO_HOOKS, None, ()),
30
'error-occurred' : (GObject.SignalFlags.NO_HOOKS, None, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,)),
33
def __init__(self, obj_path):
34
OdsBase.__init__(self, "org.openobex.Session", obj_path)
35
self.Connected = False
36
self.Handle("Cancelled", self.on_cancelled)
37
self.Handle("Disconnected", self.on_disconnected)
38
self.Handle("TransferStarted", self.on_trans_started)
39
self.Handle("TransferProgress", self.on_trans_progress)
40
self.Handle("TransferCompleted", self.on_trans_complete)
41
self.Handle("ErrorOccurred", self.on_error)
44
dprint("deleting session")
46
#this is executed by gobject, before the connected signal is emitted
47
def do_connected(self):
50
def on_cancelled(self):
51
self.emit("cancelled")
54
def on_disconnected(self):
55
dprint("disconnected")
56
self.Connected = False
57
self.emit("disconnected")
60
def on_trans_started(self, filename, path, size):
61
self.emit("transfer-started", filename, path, size)
63
def on_trans_progress(self, bytes):
64
self.emit("transfer-progress", bytes)
66
def on_trans_complete(self):
67
self.emit("transfer-completed")
69
def on_error(self, name, msg):
70
self.emit("error-occurred", name, msg)