Skip to content

Commit 4eef90b

Browse files
committed
Added decorators required by PyObjc4
1 parent 7d0a7ea commit 4eef90b

40 files changed

+1189
-83
lines changed

AccountSettings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
NSRunAlertPanel,
77
NSSavePanel,
88
NSWorkspace)
9+
910
from Foundation import (NSBundle,
1011
NSIndexSet,
1112
NSNotFound,
@@ -16,6 +17,7 @@
1617
NSURLCredentialPersistenceForSession,
1718
NSURLRequest,
1819
NSURLRequestReloadIgnoringLocalAndRemoteCacheData)
20+
1921
from WebKit import WebActionOriginalURLKey
2022
import objc
2123

@@ -69,6 +71,7 @@ def showSettingsForAccount_(self, account):
6971
request = NSURLRequest.requestWithURL_cachePolicy_timeoutInterval_(url, NSURLRequestReloadIgnoringLocalAndRemoteCacheData, 15)
7072
self.showAccountRequest(account, request)
7173

74+
@objc.python_method
7275
def showAccountRequest(self, account, request):
7376
self._account = account
7477
self._authRequestCount = 0
@@ -106,6 +109,7 @@ def showPSTNAccessforAccount_(self, account):
106109
self.webView.mainFrame().loadRequest_(request)
107110
self.window.makeKeyAndOrderFront_(self)
108111

112+
@objc.python_method
109113
def showIncomingCall(self, session, url):
110114
self._account = session.account
111115

AlertPanel.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def sessionControllersManager(self):
8989
return NSApp.delegate().contactsWindowController.sessionControllersManager
9090

9191
def init(self):
92-
self = super(AlertPanel, self).init()
92+
self = objc.super(AlertPanel, self).init()
9393
if self:
9494
NSBundle.loadNibNamed_owner_("AlertPanel", self)
9595
self.panel.setLevel_(3000)
@@ -103,6 +103,7 @@ def init(self):
103103

104104
return self
105105

106+
@objc.python_method
106107
def init_speech_recognition(self):
107108
settings = SIPSimpleSettings()
108109
if settings.sounds.use_speech_recognition:
@@ -112,13 +113,15 @@ def init_speech_recognition(self):
112113
commands = ("Accept", "Answer", "Busy", "Reject", "Voicemail", "Answering machine")
113114
self.speech_recognizer.setCommands_(commands)
114115

116+
@objc.python_method
115117
def startSpeechRecognition(self):
116118
if self.speech_recognizer is None:
117119
self.init_speech_recognition()
118120

119121
if self.speech_recognizer is not None and len(self.sessions):
120122
self.speech_recognizer.startListening()
121123

124+
@objc.python_method
122125
def stopSpeechRecognition(self):
123126
if self.speech_recognizer:
124127
self.speech_recognizer.stopListening()
@@ -144,19 +147,22 @@ def speechRecognizer_didRecognizeCommand_(self, recognizer, command):
144147
def speechSynthesizer_didFinishSpeaking_(self, sender, success):
145148
self.unMuteAfterSpeechDidEnd()
146149

150+
@objc.python_method
147151
def init_speech_synthesis(self):
148152
self.speech_synthesizer = NSSpeechSynthesizer.alloc().init() or Null
149153
self.speech_synthesizer.setDelegate_(self)
150154
self.speak_text = None
151155
self.speech_synthesizer_timer = None
152156

157+
@objc.python_method
153158
def stopSpeechSynthesizer(self):
154159
self.speech_synthesizer.stopSpeaking()
155160
if self.speech_synthesizer_timer and self.speech_synthesizer_timer.isValid():
156161
self.speech_synthesizer_timer.invalidate()
157162
self.speak_text = None
158163
self.unMuteAfterSpeechDidEnd()
159164

165+
@objc.python_method
160166
def startSpeechSynthesizerTimer(self):
161167
self.speech_synthesizer_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(2, self, "startSpeaking:", None, False)
162168
NSRunLoop.currentRunLoop().addTimer_forMode_(self.speech_synthesizer_timer, NSRunLoopCommonModes)
@@ -181,6 +187,7 @@ def startSpeaking_(self, timer):
181187
self.muteBeforeSpeechWillStart()
182188
self.speech_synthesizer.startSpeakingString_(self.speak_text)
183189

190+
@objc.python_method
184191
def show(self):
185192
self.panel.center()
186193
self.panel.orderFront_(self)
@@ -189,6 +196,7 @@ def show(self):
189196
def close(self):
190197
self.panel.close()
191198

199+
@objc.python_method
192200
def getItemView(self):
193201
array = NSMutableArray.array()
194202
context = NSMutableDictionary.dictionary()
@@ -203,6 +211,7 @@ def getItemView(self):
203211
else:
204212
raise RuntimeError("Internal Error. Could not find NSBox in AlertPanelView.nib")
205213

214+
@objc.python_method
206215
def getButtonImageForState(self, size, pushed):
207216
image = NSImage.alloc().initWithSize_(size)
208217
image.lockFocus()
@@ -223,13 +232,16 @@ def getButtonImageForState(self, size, pushed):
223232
image.unlockFocus()
224233
return image
225234

235+
@objc.python_method
226236
def addIncomingStreamProposal(self, session, streams):
227237
self.proposals[session] = streams
228238
self._addIncomingSession(session, streams, True)
229239

240+
@objc.python_method
230241
def addIncomingSession(self, session):
231242
self._addIncomingSession(session, session.blink_supported_streams, False)
232243

244+
@objc.python_method
233245
def _addIncomingSession(self, session, streams, is_update_proposal):
234246
view = self.getItemView()
235247
self.sessions[session] = view
@@ -485,6 +497,7 @@ def _addIncomingSession(self, session, streams, is_update_proposal):
485497
else:
486498
self.conferenceButton.setHidden_(False)
487499

500+
@objc.python_method
488501
def format_subject_for_incoming_reinvite(self, session, streams):
489502
alt_action = None
490503
alt_object = ONLY_CHAT
@@ -530,6 +543,7 @@ def format_subject_for_incoming_reinvite(self, session, streams):
530543
subject = NSLocalizedString("Addition of unknown stream to existing session requested by", "Label")
531544
return subject, alt_action, alt_object
532545

546+
@objc.python_method
533547
def format_subject_for_incoming_invite(self, session, streams):
534548
alt_action = None
535549
alt_object = ONLY_CHAT
@@ -575,6 +589,7 @@ def format_subject_for_incoming_invite(self, session, streams):
575589

576590
return subject, alt_action, alt_object
577591

592+
@objc.python_method
578593
def removeSession(self, session):
579594
if not self.sessions.has_key(session):
580595
return
@@ -618,6 +633,7 @@ def removeSession(self, session):
618633
if not self.sessions:
619634
self.unMuteAfterSpeechDidEnd()
620635

636+
@objc.python_method
621637
def disableAnsweringMachine(self, view, session):
622638
if session in self.answeringMachineTimers:
623639
amLabel = view.viewWithTag_(15)
@@ -627,6 +643,7 @@ def disableAnsweringMachine(self, view, session):
627643
timer.invalidate()
628644
del self.answeringMachineTimers[session]
629645

646+
@objc.python_method
630647
@run_in_gui_thread
631648
def enableAnsweringMachine(self, view, session, run_now=False):
632649
try:
@@ -646,6 +663,7 @@ def enableAnsweringMachine(self, view, session, run_now=False):
646663
if run_now:
647664
self.acceptAudioStreamAnsweringMachine(session)
648665

666+
@objc.python_method
649667
def disableAutoAnswer(self, view, session):
650668
if session in self.autoAnswerTimers:
651669
label = view.viewWithTag_(15)
@@ -655,6 +673,7 @@ def disableAutoAnswer(self, view, session):
655673
timer.invalidate()
656674
del self.autoAnswerTimers[session]
657675

676+
@objc.python_method
658677
def enableAutoAnswer(self, view, session, delay=30):
659678
if session not in self.autoAnswerTimers:
660679
label = view.viewWithTag_(15)
@@ -684,20 +703,25 @@ def timerTickAutoAnswer_(self, timer):
684703
text = NSLocalizedString("Automaticaly Accepting in %i s", "Label") % remaining
685704
info["label"].setStringValue_(text)
686705

706+
@objc.python_method
687707
@run_in_gui_thread
688708
def handle_notification(self, notification):
689709
handler = getattr(self, '_NH_%s' % notification.name, Null)
690710
handler(notification)
691711

712+
@objc.python_method
692713
def _NH_SIPSessionDidFail(self, notification):
693714
self.cancelSession(notification.sender, notification.data.reason)
694715

716+
@objc.python_method
695717
def _NH_SIPSessionProposalRejected(self, notification):
696718
self.cancelSession(notification.sender, notification.data.reason)
697719

720+
@objc.python_method
698721
def _NH_SIPSessionDidEnd(self, notification):
699722
self.cancelSession(notification.sender, notification.data.end_reason)
700723

724+
@objc.python_method
701725
def _NH_CFGSettingsObjectDidChange(self, notification):
702726
settings = SIPSimpleSettings()
703727
if notification.data.modified.has_key("sounds.use_speech_recognition"):
@@ -724,6 +748,7 @@ def _NH_CFGSettingsObjectDidChange(self, notification):
724748
else:
725749
self.disableAutoAnswer(view, session)
726750

751+
@objc.python_method
727752
def muteBeforeSpeechWillStart(self):
728753
if self.speech_synthesizer:
729754
hasAudio = any(sess.hasStreamOfType("audio") for sess in self.sessionControllersManager.sessionControllers)
@@ -734,6 +759,7 @@ def muteBeforeSpeechWillStart(self):
734759
if self.speech_recognizer:
735760
self.speech_recognizer.stopListening()
736761

762+
@objc.python_method
737763
def unMuteAfterSpeechDidEnd(self):
738764
if self.muted_by_synthesizer and SIPManager().is_muted():
739765
NSApp.delegate().contactsWindowController.muteClicked_(None)
@@ -766,6 +792,7 @@ def buttonClicked_(self, sender):
766792
else:
767793
self.decideForSessionRequest(action, session)
768794

795+
@objc.python_method
769796
def decideForProposalRequest(self, action, session, streams):
770797
sessionController = self.sessionControllersManager.sessionControllerForSession(session)
771798
if action == ACCEPT:
@@ -783,6 +810,7 @@ def decideForProposalRequest(self, action, session, streams):
783810
sessionController.log_info(u"Error rejecting proposal: %s" % exc)
784811
self.removeSession(session)
785812

813+
@objc.python_method
786814
def decideForSessionRequest(self, action, session):
787815
sessionController = self.sessionControllersManager.sessionControllerForSession(session)
788816
if action == ACCEPT:
@@ -824,6 +852,7 @@ def decideForSessionRequest(self, action, session):
824852
sessionController.log_info(u"Error rejecting session: %s" % exc)
825853
self.removeSession(session)
826854

855+
@objc.python_method
827856
def decideForAllSessionRequests(self, action):
828857
if self.attention is not None:
829858
NSApp.cancelUserAttentionRequest_(self.attention)
@@ -910,10 +939,12 @@ def decideForAllSessionRequests(self, action):
910939
sessionController.log_info(u"Error rejecting session: %s" % exc)
911940
self.removeSession(session)
912941

942+
@objc.python_method
913943
def acceptStreams(self, session, add_to_conference=False):
914944
self.sessionControllersManager.startIncomingSession(session, session.blink_supported_streams, add_to_conference=add_to_conference)
915945
self.removeSession(session)
916946

947+
@objc.python_method
917948
def acceptProposedStreams(self, session):
918949
sessionController = self.sessionControllersManager.sessionControllerForSession(session)
919950
if sessionController is not None:
@@ -924,17 +955,20 @@ def acceptProposedStreams(self, session):
924955

925956
self.removeSession(session)
926957

958+
@objc.python_method
927959
def acceptChatStream(self, session):
928960
streams = [s for s in session.proposed_streams if s.type== "chat"]
929961
self.sessionControllersManager.startIncomingSession(session, streams)
930962
self.removeSession(session)
931963

964+
@objc.python_method
932965
def acceptAudioStreamAnsweringMachine(self, session):
933966
# accept audio only
934967
streams = [s for s in session.proposed_streams if s.type == "audio"]
935968
self.sessionControllersManager.startIncomingSession(session, streams, answeringMachine=True)
936969
self.removeSession(session)
937970

971+
@objc.python_method
938972
def acceptAudioStream(self, session):
939973
# accept audio and chat only
940974
streams = [s for s in session.proposed_streams if s.type in ("audio", "chat")]
@@ -949,17 +983,20 @@ def acceptAudioStream(self, session):
949983
self.sessionControllersManager.startIncomingSession(session, streams)
950984
self.removeSession(session)
951985

986+
@objc.python_method
952987
def rejectProposal(self, session):
953988
session.reject_proposal()
954989
self.removeSession(session)
955990

991+
@objc.python_method
956992
def rejectSession(self, session, code=603, reason=None):
957993
try:
958994
session.reject(code, reason)
959995
except IllegalStateError, e:
960996
print e
961997
self.removeSession(session)
962998

999+
@objc.python_method
9631000
def cancelSession(self, session, reason):
9641001
"""Session cancelled by something other than the user"""
9651002

@@ -975,6 +1012,7 @@ def cancelSession(self, session, reason):
9751012
view.viewWithTag_(i).setEnabled_(False)
9761013
self.removeSession(session)
9771014

1015+
@objc.python_method
9781016
def rejectAllSessions(self):
9791017
for session in self.sessions.keys():
9801018
sessionController = self.sessionControllersManager.sessionControllerForSession(session)

0 commit comments

Comments
 (0)