@ -9,6 +9,7 @@
# (c) 2009 Stefan Sayer <sayer at iptel.org>
# License: GPLv3
#
import sys
import random
from PyQt4 import QtCore , QtGui
@ -18,7 +19,7 @@ from PyQt4.QtCore import *
from xmlrpclib import *
from threading import *
from conftable import *
from conftable import *
from participant import *
from callbox import *
from account import *
@ -36,10 +37,11 @@ HAS_ACCOUNT=False
try :
from accountconfig import *
HAS_ACCOUNT = True
except :
except Exception :
print ( " accountconfig.py not found - will ask for account to make calls " )
pass
class named_participant ( Ui_participant ) :
def __init__ ( self , parent , title , callid , id ) :
self . callid = callid
@ -48,12 +50,12 @@ class named_participant(Ui_participant):
self . parent = parent
self . tag = " "
parent . setWindowTitle ( title )
QtCore . QObject . connect ( self . bt_ciao , QtCore . SIGNAL ( " clicked() " ) , self . ciao_clicked )
QtCore . QObject . connect ( self . bt_ciao , QtCore . SIGNAL ( " clicked() " ) , self . ciao_clicked )
QtCore . QObject . connect ( self . cb_muted , QtCore . SIGNAL ( " stateChanged(int) " ) , self . muted_changed )
def ciao_clicked ( self ) :
self . bt_ciao . emit ( QtCore . SIGNAL ( " ciao(int) " ) , self . id )
def status2text ( self , s ) :
return { 0 : " Disconnected " ,
1 : " Connecting " ,
@ -61,7 +63,7 @@ class named_participant(Ui_participant):
3 : " Connected " ,
4 : " Disconnecting " ,
5 : " Finished " } [ s ]
def set_status ( self , status , hint , muted ) :
self . l_status . setText ( self . status2text ( status ) )
self . l_status . setToolTip ( hint )
@ -69,26 +71,26 @@ class named_participant(Ui_participant):
self . cb_muted . setCheckState ( Qt . Checked )
else :
self . cb_muted . setCheckState ( Qt . Unchecked )
def muted_changed ( self , i ) :
print ( " callid is " , self . callid )
self . cb_muted . emit ( QtCore . SIGNAL ( " mute(int,bool) " ) , self . id , self . cb_muted . isChecked ( ) )
class StartQT4 ( QtGui . QMainWindow ) :
participants = [ ]
roomname = " "
adminpin = " "
adminpin = " "
s = None
last_res = None
def __init__ ( self , parent = None ) :
QtGui . QWidget . __init__ ( self , parent )
self . ui = Ui_MainWindow ( )
self . ui . setupUi ( self )
self . show ( )
if HAS_ACCOUNT :
if HAS_ACCOUNT :
self . call_domain = DOMAIN
self . call_user = USER
self . call_pwd = PASSWORD
@ -99,12 +101,12 @@ class StartQT4(QtGui.QMainWindow):
dlg_cb . setupUi ( dlg )
if dlg . exec_ ( ) == QDialog . Rejected :
raise " well, I need a SIP account to make calls "
self . call_domain = str ( dlg_cb . e_domain . text ( ) )
self . call_pwd = str ( dlg_cb . e_pwd . text ( ) )
self . call_user = str ( dlg_cb . e_user . text ( ) )
self . call_auth_user = self . call_user
QtCore . QObject . connect ( self . ui . buttonNew , QtCore . SIGNAL ( " clicked() " ) , self . new_call )
self . s = ServerProxy ( CONTROL_URI )
print ( " server has %d running calls " % self . s . calls ( ) )
@ -119,28 +121,28 @@ class StartQT4(QtGui.QMainWindow):
break
if self . adminpin == " " :
raise " oh, could not get a free room :( "
print ( " roomname is %s , adminpin is %s " % ( self . roomname , self . adminpin ) )
self . ui . label . setText ( " iptel.org \n webconference \n https://webconference.iptel.org \n \n room: %s adminpin: %s \n \n "
self . ui . label . setText ( " iptel.org \n webconference \n https://webconference.iptel.org \n \n room: %s adminpin: %s \n \n "
" to dial in call sip:conference@iptel.org \n and type %s * "
% ( self . roomname , self . adminpin , self . roomname ) )
self . timer = QtCore . QTimer ( self )
self . connect ( self . timer , QtCore . SIGNAL ( " timeout() " ) , self . timer_hit )
self . timer . start ( REFRESH_INTERVAL )
def timer_hit ( self ) :
res = self . s . di ( ' webconference ' , ' roomInfo ' , self . roomname , self . adminpin )
if res [ 0 ] != 0 :
print ( " oh my god, can ' t see this room! " )
return
code , reason , participants , serverstatus = res
if participants == self . last_res :
return #optimize a bit
self . last_res = participants
for part in participants :
call_tag , number , status , reason , muted , participant_id = part
found = False
@ -152,7 +154,7 @@ class StartQT4(QtGui.QMainWindow):
if not found :
p = self . createparticipantWidget ( number , call_tag )
p . set_status ( status , reason , muted )
def createparticipantWidget ( self , name , callid ) :
w = QtGui . QDockWidget ( " someone " , self . ui . frame_main )
part = named_participant ( w , name , callid , len ( self . participants ) )
@ -163,7 +165,7 @@ class StartQT4(QtGui.QMainWindow):
w . show ( )
self . participants = self . participants + [ part ]
return part
def new_call ( self ) :
print ( " a new call. " )
dlg = QtGui . QDialog ( self )
@ -171,31 +173,29 @@ class StartQT4(QtGui.QMainWindow):
dlg_cb . setupUi ( dlg )
if dlg . exec_ ( ) == QDialog . Rejected :
return
print ( " now calling %s " % dlg_cb . num . text ( ) )
res = self . s . di ( ' webconference ' , ' dialout ' , self . roomname , self . adminpin , str ( dlg_cb . num . text ( ) ) ,
self . call_user , self . call_domain , self . call_auth_user , self . call_pwd )
if res [ 0 ] != 0 :
print ( " oh, my dear, calling failed with code %d " % res [ 0 ] )
return
code , result , callid , serverinfo = res
code , result , callid , serverinfo = res
print ( " code %d result %s " % ( code , result ) )
print ( " serverinfo is %s " % serverinfo )
self . createparticipantWidget ( dlg_cb . num . text ( ) , callid )
def part_ciao ( self , id ) :
print ( " ciao: " , id )
self . s . di ( ' webconference ' , ' kickout ' , self . roomname , self . adminpin , self . participants [ id ] . callid )
def part_muted ( self , id , s ) :
print ( " mute: " , id , " is " , s )
if s :
self . s . di ( ' webconference ' , ' mute ' , self . roomname , self . adminpin , self . participants [ id ] . callid )
else :
self . s . di ( ' webconference ' , ' unmute ' , self . roomname , self . adminpin , self . participants [ id ] . callid )
if __name__ == " __main__ " :
@ -203,4 +203,3 @@ if __name__ == "__main__":
myapp = StartQT4 ( )
myapp . show ( )
sys . exit ( app . exec_ ( ) )