File: TransferCall.py

package info (click to toggle)
skysentials 1.0.1-4
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze
  • size: 112 kB
  • ctags: 55
  • sloc: python: 758; makefile: 7
file content (134 lines) | stat: -rw-r--r-- 3,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import gtk
import gobject
import sys
import re
import string
import time

#Skype4Py
import Skype4Py

REV="$Rev: 69 $"

class TransferCall:
	def __init__(self, skype_obj, friends):
		# Initialize vars
		self.calllist = {}
		self.call_ls = gtk.ListStore(str, object)
		self.friends = friends

		self.skype = skype_obj
		self.skype.RegisterEventHandler('CallStatus', self.CallStatus)
		self.skype.RegisterEventHandler('CallTransferStatusChanged',
			self.CallTransfer)

		for call in self.skype.ActiveCalls:
			self.calllist[call] = self.call_ls.append([
				call.PartnerDisplayName,
				call])

	def CallStatus(self, call, value):
		gtk.gdk.threads_enter()
		if value == "INPROGRESS":
			if not call in self.calllist.keys():
				self.calllist[call] = self.call_ls.append([
					call.PartnerDisplayName,
					call])
		else:
			if call in self.calllist.keys():
				self.call_ls.remove(self.calllist[call])
				del self.calllist[call]

		gtk.gdk.threads_leave()

	def CallTransfer(self, call, value):
		self.l_status.set_text(value)
		
	def transfer(self, widget):
		calliter = self.calls.get_active_iter()
		if not calliter:
			return 

		iter = self.entry.get_active_iter()
		if iter:
			transferto = self.entry_ls.get_value(iter, 1)
		else:
			transferto = self.entry.child.get_text()
		if transferto == "":
			return

		call = self.call_ls.get_value(calliter, 1)
		if call.CanTransfer(transferto):
			call.Transfer(transferto)
		else:
			self.l_status.set_text("Call can't be transferred!")
			

	def window_show(self):
		vbox = gtk.VBox(False, 0)

		label = gtk.Label("Transfer Call")
		label.set_markup("<span size=\"large\" weight=\"bold\">Transfer Call</span>")
		vbox.pack_start(label, False, False, 0)
		label.show()

		frame = gtk.Frame('Call:')
		self.calls = gtk.ComboBox(self.call_ls)
		cell = gtk.CellRendererText()
		self.calls.pack_start(cell, True)
		self.calls.add_attribute(cell, 'text', 0)

		frame.add(self.calls)
		self.calls.show()

		vbox.pack_start(frame, False, False, 0)
		frame.show()

		frame = gtk.Frame('Transfer To:')

		self.entry_ls = gtk.ListStore(str, str)
		self.entry = gtk.ComboBoxEntry(self.entry_ls, 0)

		friends = self.friends.keys()
		friends.sort()
		for friend in friends:
			self.entry_ls.append([friend, self.friends[friend]])
		frame.add(self.entry)
		self.entry.show()
		self.entry.grab_focus()
		vbox.pack_start(frame, False, False, 0)
		frame.show()

		self.sendbutton = gtk.Button("Transfer")
		self.sendbutton_connect = self.sendbutton.connect("clicked",
			self.transfer)
		self.sendbutton.set_flags(gtk.CAN_DEFAULT)
		vbox.pack_start(self.sendbutton, False, False, 0)
		self.sendbutton.show()

		label = gtk.Label()
		vbox.pack_start(label, False, False, 0)
		label.show()

		table = gtk.Table(rows=1, columns=2)

		label = gtk.Label("Transfer Status:")
		table.attach(label, 0, 1, 0, 1)
		label.show()

		self.l_status = gtk.Label("")
		table.attach(self.l_status, 1, 2, 0, 1)
		self.l_status.show()

		vbox.pack_start(table, False, False, 0)
		table.show()

		# Set Number from CmdLine if anything given.
		if len(sys.argv) == 2:
			self.entry.set_active_iter(self.entry_ls.append([sys.argv[1], sys.argv[1]]))

		# Now show everything
		vbox.show()
		return vbox