@@ -89,7 +89,7 @@ def sessionControllersManager(self):
89
89
return NSApp .delegate ().contactsWindowController .sessionControllersManager
90
90
91
91
def init (self ):
92
- self = super (AlertPanel , self ).init ()
92
+ self = objc . super (AlertPanel , self ).init ()
93
93
if self :
94
94
NSBundle .loadNibNamed_owner_ ("AlertPanel" , self )
95
95
self .panel .setLevel_ (3000 )
@@ -103,6 +103,7 @@ def init(self):
103
103
104
104
return self
105
105
106
+ @objc .python_method
106
107
def init_speech_recognition (self ):
107
108
settings = SIPSimpleSettings ()
108
109
if settings .sounds .use_speech_recognition :
@@ -112,13 +113,15 @@ def init_speech_recognition(self):
112
113
commands = ("Accept" , "Answer" , "Busy" , "Reject" , "Voicemail" , "Answering machine" )
113
114
self .speech_recognizer .setCommands_ (commands )
114
115
116
+ @objc .python_method
115
117
def startSpeechRecognition (self ):
116
118
if self .speech_recognizer is None :
117
119
self .init_speech_recognition ()
118
120
119
121
if self .speech_recognizer is not None and len (self .sessions ):
120
122
self .speech_recognizer .startListening ()
121
123
124
+ @objc .python_method
122
125
def stopSpeechRecognition (self ):
123
126
if self .speech_recognizer :
124
127
self .speech_recognizer .stopListening ()
@@ -144,19 +147,22 @@ def speechRecognizer_didRecognizeCommand_(self, recognizer, command):
144
147
def speechSynthesizer_didFinishSpeaking_ (self , sender , success ):
145
148
self .unMuteAfterSpeechDidEnd ()
146
149
150
+ @objc .python_method
147
151
def init_speech_synthesis (self ):
148
152
self .speech_synthesizer = NSSpeechSynthesizer .alloc ().init () or Null
149
153
self .speech_synthesizer .setDelegate_ (self )
150
154
self .speak_text = None
151
155
self .speech_synthesizer_timer = None
152
156
157
+ @objc .python_method
153
158
def stopSpeechSynthesizer (self ):
154
159
self .speech_synthesizer .stopSpeaking ()
155
160
if self .speech_synthesizer_timer and self .speech_synthesizer_timer .isValid ():
156
161
self .speech_synthesizer_timer .invalidate ()
157
162
self .speak_text = None
158
163
self .unMuteAfterSpeechDidEnd ()
159
164
165
+ @objc .python_method
160
166
def startSpeechSynthesizerTimer (self ):
161
167
self .speech_synthesizer_timer = NSTimer .timerWithTimeInterval_target_selector_userInfo_repeats_ (2 , self , "startSpeaking:" , None , False )
162
168
NSRunLoop .currentRunLoop ().addTimer_forMode_ (self .speech_synthesizer_timer , NSRunLoopCommonModes )
@@ -181,6 +187,7 @@ def startSpeaking_(self, timer):
181
187
self .muteBeforeSpeechWillStart ()
182
188
self .speech_synthesizer .startSpeakingString_ (self .speak_text )
183
189
190
+ @objc .python_method
184
191
def show (self ):
185
192
self .panel .center ()
186
193
self .panel .orderFront_ (self )
@@ -189,6 +196,7 @@ def show(self):
189
196
def close (self ):
190
197
self .panel .close ()
191
198
199
+ @objc .python_method
192
200
def getItemView (self ):
193
201
array = NSMutableArray .array ()
194
202
context = NSMutableDictionary .dictionary ()
@@ -203,6 +211,7 @@ def getItemView(self):
203
211
else :
204
212
raise RuntimeError ("Internal Error. Could not find NSBox in AlertPanelView.nib" )
205
213
214
+ @objc .python_method
206
215
def getButtonImageForState (self , size , pushed ):
207
216
image = NSImage .alloc ().initWithSize_ (size )
208
217
image .lockFocus ()
@@ -223,13 +232,16 @@ def getButtonImageForState(self, size, pushed):
223
232
image .unlockFocus ()
224
233
return image
225
234
235
+ @objc .python_method
226
236
def addIncomingStreamProposal (self , session , streams ):
227
237
self .proposals [session ] = streams
228
238
self ._addIncomingSession (session , streams , True )
229
239
240
+ @objc .python_method
230
241
def addIncomingSession (self , session ):
231
242
self ._addIncomingSession (session , session .blink_supported_streams , False )
232
243
244
+ @objc .python_method
233
245
def _addIncomingSession (self , session , streams , is_update_proposal ):
234
246
view = self .getItemView ()
235
247
self .sessions [session ] = view
@@ -485,6 +497,7 @@ def _addIncomingSession(self, session, streams, is_update_proposal):
485
497
else :
486
498
self .conferenceButton .setHidden_ (False )
487
499
500
+ @objc .python_method
488
501
def format_subject_for_incoming_reinvite (self , session , streams ):
489
502
alt_action = None
490
503
alt_object = ONLY_CHAT
@@ -530,6 +543,7 @@ def format_subject_for_incoming_reinvite(self, session, streams):
530
543
subject = NSLocalizedString ("Addition of unknown stream to existing session requested by" , "Label" )
531
544
return subject , alt_action , alt_object
532
545
546
+ @objc .python_method
533
547
def format_subject_for_incoming_invite (self , session , streams ):
534
548
alt_action = None
535
549
alt_object = ONLY_CHAT
@@ -575,6 +589,7 @@ def format_subject_for_incoming_invite(self, session, streams):
575
589
576
590
return subject , alt_action , alt_object
577
591
592
+ @objc .python_method
578
593
def removeSession (self , session ):
579
594
if not self .sessions .has_key (session ):
580
595
return
@@ -618,6 +633,7 @@ def removeSession(self, session):
618
633
if not self .sessions :
619
634
self .unMuteAfterSpeechDidEnd ()
620
635
636
+ @objc .python_method
621
637
def disableAnsweringMachine (self , view , session ):
622
638
if session in self .answeringMachineTimers :
623
639
amLabel = view .viewWithTag_ (15 )
@@ -627,6 +643,7 @@ def disableAnsweringMachine(self, view, session):
627
643
timer .invalidate ()
628
644
del self .answeringMachineTimers [session ]
629
645
646
+ @objc .python_method
630
647
@run_in_gui_thread
631
648
def enableAnsweringMachine (self , view , session , run_now = False ):
632
649
try :
@@ -646,6 +663,7 @@ def enableAnsweringMachine(self, view, session, run_now=False):
646
663
if run_now :
647
664
self .acceptAudioStreamAnsweringMachine (session )
648
665
666
+ @objc .python_method
649
667
def disableAutoAnswer (self , view , session ):
650
668
if session in self .autoAnswerTimers :
651
669
label = view .viewWithTag_ (15 )
@@ -655,6 +673,7 @@ def disableAutoAnswer(self, view, session):
655
673
timer .invalidate ()
656
674
del self .autoAnswerTimers [session ]
657
675
676
+ @objc .python_method
658
677
def enableAutoAnswer (self , view , session , delay = 30 ):
659
678
if session not in self .autoAnswerTimers :
660
679
label = view .viewWithTag_ (15 )
@@ -684,20 +703,25 @@ def timerTickAutoAnswer_(self, timer):
684
703
text = NSLocalizedString ("Automaticaly Accepting in %i s" , "Label" ) % remaining
685
704
info ["label" ].setStringValue_ (text )
686
705
706
+ @objc .python_method
687
707
@run_in_gui_thread
688
708
def handle_notification (self , notification ):
689
709
handler = getattr (self , '_NH_%s' % notification .name , Null )
690
710
handler (notification )
691
711
712
+ @objc .python_method
692
713
def _NH_SIPSessionDidFail (self , notification ):
693
714
self .cancelSession (notification .sender , notification .data .reason )
694
715
716
+ @objc .python_method
695
717
def _NH_SIPSessionProposalRejected (self , notification ):
696
718
self .cancelSession (notification .sender , notification .data .reason )
697
719
720
+ @objc .python_method
698
721
def _NH_SIPSessionDidEnd (self , notification ):
699
722
self .cancelSession (notification .sender , notification .data .end_reason )
700
723
724
+ @objc .python_method
701
725
def _NH_CFGSettingsObjectDidChange (self , notification ):
702
726
settings = SIPSimpleSettings ()
703
727
if notification .data .modified .has_key ("sounds.use_speech_recognition" ):
@@ -724,6 +748,7 @@ def _NH_CFGSettingsObjectDidChange(self, notification):
724
748
else :
725
749
self .disableAutoAnswer (view , session )
726
750
751
+ @objc .python_method
727
752
def muteBeforeSpeechWillStart (self ):
728
753
if self .speech_synthesizer :
729
754
hasAudio = any (sess .hasStreamOfType ("audio" ) for sess in self .sessionControllersManager .sessionControllers )
@@ -734,6 +759,7 @@ def muteBeforeSpeechWillStart(self):
734
759
if self .speech_recognizer :
735
760
self .speech_recognizer .stopListening ()
736
761
762
+ @objc .python_method
737
763
def unMuteAfterSpeechDidEnd (self ):
738
764
if self .muted_by_synthesizer and SIPManager ().is_muted ():
739
765
NSApp .delegate ().contactsWindowController .muteClicked_ (None )
@@ -766,6 +792,7 @@ def buttonClicked_(self, sender):
766
792
else :
767
793
self .decideForSessionRequest (action , session )
768
794
795
+ @objc .python_method
769
796
def decideForProposalRequest (self , action , session , streams ):
770
797
sessionController = self .sessionControllersManager .sessionControllerForSession (session )
771
798
if action == ACCEPT :
@@ -783,6 +810,7 @@ def decideForProposalRequest(self, action, session, streams):
783
810
sessionController .log_info (u"Error rejecting proposal: %s" % exc )
784
811
self .removeSession (session )
785
812
813
+ @objc .python_method
786
814
def decideForSessionRequest (self , action , session ):
787
815
sessionController = self .sessionControllersManager .sessionControllerForSession (session )
788
816
if action == ACCEPT :
@@ -824,6 +852,7 @@ def decideForSessionRequest(self, action, session):
824
852
sessionController .log_info (u"Error rejecting session: %s" % exc )
825
853
self .removeSession (session )
826
854
855
+ @objc .python_method
827
856
def decideForAllSessionRequests (self , action ):
828
857
if self .attention is not None :
829
858
NSApp .cancelUserAttentionRequest_ (self .attention )
@@ -910,10 +939,12 @@ def decideForAllSessionRequests(self, action):
910
939
sessionController .log_info (u"Error rejecting session: %s" % exc )
911
940
self .removeSession (session )
912
941
942
+ @objc .python_method
913
943
def acceptStreams (self , session , add_to_conference = False ):
914
944
self .sessionControllersManager .startIncomingSession (session , session .blink_supported_streams , add_to_conference = add_to_conference )
915
945
self .removeSession (session )
916
946
947
+ @objc .python_method
917
948
def acceptProposedStreams (self , session ):
918
949
sessionController = self .sessionControllersManager .sessionControllerForSession (session )
919
950
if sessionController is not None :
@@ -924,17 +955,20 @@ def acceptProposedStreams(self, session):
924
955
925
956
self .removeSession (session )
926
957
958
+ @objc .python_method
927
959
def acceptChatStream (self , session ):
928
960
streams = [s for s in session .proposed_streams if s .type == "chat" ]
929
961
self .sessionControllersManager .startIncomingSession (session , streams )
930
962
self .removeSession (session )
931
963
964
+ @objc .python_method
932
965
def acceptAudioStreamAnsweringMachine (self , session ):
933
966
# accept audio only
934
967
streams = [s for s in session .proposed_streams if s .type == "audio" ]
935
968
self .sessionControllersManager .startIncomingSession (session , streams , answeringMachine = True )
936
969
self .removeSession (session )
937
970
971
+ @objc .python_method
938
972
def acceptAudioStream (self , session ):
939
973
# accept audio and chat only
940
974
streams = [s for s in session .proposed_streams if s .type in ("audio" , "chat" )]
@@ -949,17 +983,20 @@ def acceptAudioStream(self, session):
949
983
self .sessionControllersManager .startIncomingSession (session , streams )
950
984
self .removeSession (session )
951
985
986
+ @objc .python_method
952
987
def rejectProposal (self , session ):
953
988
session .reject_proposal ()
954
989
self .removeSession (session )
955
990
991
+ @objc .python_method
956
992
def rejectSession (self , session , code = 603 , reason = None ):
957
993
try :
958
994
session .reject (code , reason )
959
995
except IllegalStateError , e :
960
996
print e
961
997
self .removeSession (session )
962
998
999
+ @objc .python_method
963
1000
def cancelSession (self , session , reason ):
964
1001
"""Session cancelled by something other than the user"""
965
1002
@@ -975,6 +1012,7 @@ def cancelSession(self, session, reason):
975
1012
view .viewWithTag_ (i ).setEnabled_ (False )
976
1013
self .removeSession (session )
977
1014
1015
+ @objc .python_method
978
1016
def rejectAllSessions (self ):
979
1017
for session in self .sessions .keys ():
980
1018
sessionController = self .sessionControllersManager .sessionControllerForSession (session )
0 commit comments