Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #pragma once |
michael@0 | 6 | |
michael@0 | 7 | #include "CallControlManager.h" |
michael@0 | 8 | #include "PhoneDetailsImpl.h" |
michael@0 | 9 | #include "CC_SIPCCService.h" |
michael@0 | 10 | #include "mozilla/Mutex.h" |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | #include <set> |
michael@0 | 14 | #include <map> |
michael@0 | 15 | |
michael@0 | 16 | namespace CSF |
michael@0 | 17 | { |
michael@0 | 18 | class CallControlManagerImpl: public CallControlManager, public CC_Observer |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | CallControlManagerImpl(); |
michael@0 | 22 | virtual bool destroy(); |
michael@0 | 23 | virtual ~CallControlManagerImpl(); |
michael@0 | 24 | |
michael@0 | 25 | // Observers |
michael@0 | 26 | virtual void addCCObserver ( CC_Observer * observer ); |
michael@0 | 27 | virtual void removeCCObserver ( CC_Observer * observer ); |
michael@0 | 28 | |
michael@0 | 29 | virtual void addECCObserver ( ECC_Observer * observer ); |
michael@0 | 30 | virtual void removeECCObserver ( ECC_Observer * observer ); |
michael@0 | 31 | |
michael@0 | 32 | // Config and global setup |
michael@0 | 33 | virtual void setMultiClusterMode(bool allowMultipleClusters); |
michael@0 | 34 | virtual void setSIPCCLoggingMask(const cc_int32_t mask); |
michael@0 | 35 | virtual void setAuthenticationString(const std::string &authString); |
michael@0 | 36 | virtual void setSecureCachePath(const std::string &secureCachePath); |
michael@0 | 37 | |
michael@0 | 38 | // Add local codecs |
michael@0 | 39 | virtual void setAudioCodecs(int codecMask); |
michael@0 | 40 | virtual void setVideoCodecs(int codecMask); |
michael@0 | 41 | |
michael@0 | 42 | virtual AuthenticationStatusEnum::AuthenticationStatus getAuthenticationStatus(); |
michael@0 | 43 | |
michael@0 | 44 | virtual bool registerUser( const std::string& deviceName, const std::string& user, const std::string& password, const std::string& domain ); |
michael@0 | 45 | |
michael@0 | 46 | virtual bool startP2PMode(const std::string& user); |
michael@0 | 47 | |
michael@0 | 48 | virtual bool startSDPMode(); |
michael@0 | 49 | |
michael@0 | 50 | virtual bool disconnect(); |
michael@0 | 51 | virtual std::string getPreferredDeviceName(); |
michael@0 | 52 | virtual std::string getPreferredLineDN(); |
michael@0 | 53 | virtual ConnectionStatusEnum::ConnectionStatus getConnectionStatus(); |
michael@0 | 54 | virtual std::string getCurrentServer(); |
michael@0 | 55 | |
michael@0 | 56 | // Currently controlled device |
michael@0 | 57 | virtual CC_DevicePtr getActiveDevice(); |
michael@0 | 58 | |
michael@0 | 59 | // All known devices |
michael@0 | 60 | virtual PhoneDetailsVtrPtr getAvailablePhoneDetails(); |
michael@0 | 61 | virtual PhoneDetailsPtr getAvailablePhoneDetails(const std::string& deviceName); |
michael@0 | 62 | |
michael@0 | 63 | // Media setup |
michael@0 | 64 | virtual VideoControlPtr getVideoControl(); |
michael@0 | 65 | virtual AudioControlPtr getAudioControl(); |
michael@0 | 66 | |
michael@0 | 67 | virtual bool setProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key, std::string& value); |
michael@0 | 68 | virtual std::string getProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key); |
michael@0 | 69 | |
michael@0 | 70 | private: // Data Storage |
michael@0 | 71 | |
michael@0 | 72 | // Observers |
michael@0 | 73 | mozilla::Mutex m_lock; |
michael@0 | 74 | std::set<CC_Observer *> ccObservers; |
michael@0 | 75 | std::set<ECC_Observer *> eccObservers; |
michael@0 | 76 | |
michael@0 | 77 | // Config and global setup |
michael@0 | 78 | std::string username; |
michael@0 | 79 | std::string password; |
michael@0 | 80 | std::string authString; |
michael@0 | 81 | std::string secureCachePath; |
michael@0 | 82 | bool multiClusterMode; |
michael@0 | 83 | cc_int32_t sipccLoggingMask; |
michael@0 | 84 | |
michael@0 | 85 | AuthenticationStatusEnum::AuthenticationStatus authenticationStatus; |
michael@0 | 86 | |
michael@0 | 87 | std::string preferredDevice; |
michael@0 | 88 | std::string preferredLineDN; |
michael@0 | 89 | CC_ServicePtr phone; // The generic handle, for simple operations. |
michael@0 | 90 | CC_SIPCCServicePtr softPhone; // For setup operations not available on the generic API. |
michael@0 | 91 | |
michael@0 | 92 | // All known devices |
michael@0 | 93 | typedef std::map<std::string, PhoneDetailsImplPtr> PhoneDetailsMap; |
michael@0 | 94 | PhoneDetailsMap phoneDetailsMap; |
michael@0 | 95 | |
michael@0 | 96 | // store connection state |
michael@0 | 97 | ConnectionStatusEnum::ConnectionStatus connectionState; |
michael@0 | 98 | |
michael@0 | 99 | public: // Listeners for stacks controlled by CallControlManager |
michael@0 | 100 | // CC_Observers |
michael@0 | 101 | void onDeviceEvent (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info); |
michael@0 | 102 | void onFeatureEvent (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info); |
michael@0 | 103 | void onLineEvent (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info); |
michael@0 | 104 | void onCallEvent (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info); |
michael@0 | 105 | |
michael@0 | 106 | private: //member functions |
michael@0 | 107 | |
michael@0 | 108 | // CC_Observers |
michael@0 | 109 | void notifyDeviceEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info); |
michael@0 | 110 | void notifyFeatureEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info); |
michael@0 | 111 | void notifyLineEventObservers (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info); |
michael@0 | 112 | void notifyCallEventObservers (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info); |
michael@0 | 113 | |
michael@0 | 114 | // ECC_Observers |
michael@0 | 115 | void notifyAvailablePhoneEvent (AvailablePhoneEventType::AvailablePhoneEvent event, |
michael@0 | 116 | const PhoneDetailsPtr phoneDetails); |
michael@0 | 117 | void notifyAuthenticationStatusChange (AuthenticationStatusEnum::AuthenticationStatus); |
michael@0 | 118 | void notifyConnectionStatusChange(ConnectionStatusEnum::ConnectionStatus status); |
michael@0 | 119 | void setConnectionState(ConnectionStatusEnum::ConnectionStatus status); |
michael@0 | 120 | }; |
michael@0 | 121 | |
michael@0 | 122 | } |