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 | #include <errno.h> |
michael@0 | 6 | #include <string> |
michael@0 | 7 | #include <prcvar.h> |
michael@0 | 8 | #include <prlock.h> |
michael@0 | 9 | |
michael@0 | 10 | #include "CSFLog.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "CC_SIPCCDevice.h" |
michael@0 | 13 | #include "CC_SIPCCDeviceInfo.h" |
michael@0 | 14 | #include "CC_SIPCCFeatureInfo.h" |
michael@0 | 15 | #include "CC_SIPCCLine.h" |
michael@0 | 16 | #include "CC_SIPCCLineInfo.h" |
michael@0 | 17 | #include "CC_SIPCCCallInfo.h" |
michael@0 | 18 | #include "CallControlManagerImpl.h" |
michael@0 | 19 | #include "csf_common.h" |
michael@0 | 20 | |
michael@0 | 21 | extern "C" |
michael@0 | 22 | { |
michael@0 | 23 | #include "config_api.h" |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | |
michael@0 | 27 | static const char logTag[] = "CallControlManager"; |
michael@0 | 28 | |
michael@0 | 29 | using namespace std; |
michael@0 | 30 | using namespace CSFUnified; |
michael@0 | 31 | |
michael@0 | 32 | namespace CSF |
michael@0 | 33 | { |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | CallControlManagerImpl::CallControlManagerImpl() |
michael@0 | 37 | : m_lock("CallControlManagerImpl"), |
michael@0 | 38 | multiClusterMode(false), |
michael@0 | 39 | sipccLoggingMask(0xFFFFFFFF), |
michael@0 | 40 | authenticationStatus(AuthenticationStatusEnum::eNotAuthenticated), |
michael@0 | 41 | connectionState(ConnectionStatusEnum::eIdle) |
michael@0 | 42 | { |
michael@0 | 43 | CSFLogInfo(logTag, "CallControlManagerImpl()"); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | CallControlManagerImpl::~CallControlManagerImpl() |
michael@0 | 47 | { |
michael@0 | 48 | CSFLogInfo(logTag, "~CallControlManagerImpl()"); |
michael@0 | 49 | destroy(); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | bool CallControlManagerImpl::destroy() |
michael@0 | 53 | { |
michael@0 | 54 | CSFLogInfo(logTag, "destroy()"); |
michael@0 | 55 | bool retval = disconnect(); |
michael@0 | 56 | if(retval == false) |
michael@0 | 57 | { |
michael@0 | 58 | return retval; |
michael@0 | 59 | } |
michael@0 | 60 | return retval; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | // Observers |
michael@0 | 64 | void CallControlManagerImpl::addCCObserver ( CC_Observer * observer ) |
michael@0 | 65 | { |
michael@0 | 66 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 67 | if (observer == nullptr) |
michael@0 | 68 | { |
michael@0 | 69 | CSFLogError(logTag, "NULL value for \"observer\" passed to addCCObserver()."); |
michael@0 | 70 | return; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | ccObservers.insert(observer); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | void CallControlManagerImpl::removeCCObserver ( CC_Observer * observer ) |
michael@0 | 77 | { |
michael@0 | 78 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 79 | ccObservers.erase(observer); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | void CallControlManagerImpl::addECCObserver ( ECC_Observer * observer ) |
michael@0 | 83 | { |
michael@0 | 84 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 85 | if (observer == nullptr) |
michael@0 | 86 | { |
michael@0 | 87 | CSFLogError(logTag, "NULL value for \"observer\" passed to addECCObserver()."); |
michael@0 | 88 | return; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | eccObservers.insert(observer); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | void CallControlManagerImpl::removeECCObserver ( ECC_Observer * observer ) |
michael@0 | 95 | { |
michael@0 | 96 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 97 | eccObservers.erase(observer); |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | void CallControlManagerImpl::setMultiClusterMode(bool allowMultipleClusters) |
michael@0 | 101 | { |
michael@0 | 102 | CSFLogInfo(logTag, "setMultiClusterMode(%s)", |
michael@0 | 103 | allowMultipleClusters ? "TRUE" : "FALSE"); |
michael@0 | 104 | multiClusterMode = allowMultipleClusters; |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | void CallControlManagerImpl::setSIPCCLoggingMask(const cc_int32_t mask) |
michael@0 | 108 | { |
michael@0 | 109 | CSFLogInfo(logTag, "setSIPCCLoggingMask(%u)", mask); |
michael@0 | 110 | sipccLoggingMask = mask; |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | void CallControlManagerImpl::setAuthenticationString(const std::string &authString) |
michael@0 | 114 | { |
michael@0 | 115 | CSFLogInfo(logTag, "setAuthenticationString()"); |
michael@0 | 116 | this->authString = authString; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | void CallControlManagerImpl::setSecureCachePath(const std::string &secureCachePath) |
michael@0 | 120 | { |
michael@0 | 121 | CSFLogInfo(logTag, "setSecureCachePath(%s)", secureCachePath.c_str()); |
michael@0 | 122 | this->secureCachePath = secureCachePath; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | // Add local codecs |
michael@0 | 126 | void CallControlManagerImpl::setAudioCodecs(int codecMask) |
michael@0 | 127 | { |
michael@0 | 128 | CSFLogDebug(logTag, "setAudioCodecs %X", codecMask); |
michael@0 | 129 | |
michael@0 | 130 | VcmSIPCCBinding::setAudioCodecs(codecMask); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | void CallControlManagerImpl::setVideoCodecs(int codecMask) |
michael@0 | 134 | { |
michael@0 | 135 | CSFLogDebug(logTag, "setVideoCodecs %X", codecMask); |
michael@0 | 136 | |
michael@0 | 137 | VcmSIPCCBinding::setVideoCodecs(codecMask); |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | AuthenticationStatusEnum::AuthenticationStatus CallControlManagerImpl::getAuthenticationStatus() |
michael@0 | 141 | { |
michael@0 | 142 | return authenticationStatus; |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | bool CallControlManagerImpl::registerUser( const std::string& deviceName, const std::string& user, const std::string& password, const std::string& domain ) |
michael@0 | 146 | { |
michael@0 | 147 | setConnectionState(ConnectionStatusEnum::eRegistering); |
michael@0 | 148 | |
michael@0 | 149 | CSFLogInfo(logTag, "registerUser(%s, %s )", user.c_str(), domain.c_str()); |
michael@0 | 150 | if(phone != nullptr) |
michael@0 | 151 | { |
michael@0 | 152 | setConnectionState(ConnectionStatusEnum::eReady); |
michael@0 | 153 | |
michael@0 | 154 | CSFLogError(logTag, "registerUser() failed - already connected!"); |
michael@0 | 155 | return false; |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | softPhone = CC_SIPCCServicePtr(new CC_SIPCCService()); |
michael@0 | 159 | phone = softPhone; |
michael@0 | 160 | phone->init(user, password, domain, deviceName); |
michael@0 | 161 | softPhone->setLoggingMask(sipccLoggingMask); |
michael@0 | 162 | phone->addCCObserver(this); |
michael@0 | 163 | |
michael@0 | 164 | phone->setP2PMode(false); |
michael@0 | 165 | |
michael@0 | 166 | bool bStarted = phone->startService(); |
michael@0 | 167 | if (!bStarted) { |
michael@0 | 168 | setConnectionState(ConnectionStatusEnum::eFailed); |
michael@0 | 169 | } else { |
michael@0 | 170 | setConnectionState(ConnectionStatusEnum::eReady); |
michael@0 | 171 | } |
michael@0 | 172 | |
michael@0 | 173 | return bStarted; |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | bool CallControlManagerImpl::startP2PMode(const std::string& user) |
michael@0 | 177 | { |
michael@0 | 178 | setConnectionState(ConnectionStatusEnum::eRegistering); |
michael@0 | 179 | |
michael@0 | 180 | CSFLogInfo(logTag, "startP2PMode(%s)", user.c_str()); |
michael@0 | 181 | if(phone != nullptr) |
michael@0 | 182 | { |
michael@0 | 183 | setConnectionState(ConnectionStatusEnum::eReady); |
michael@0 | 184 | |
michael@0 | 185 | CSFLogError(logTag, "startP2PMode() failed - already started in p2p mode!"); |
michael@0 | 186 | return false; |
michael@0 | 187 | } |
michael@0 | 188 | |
michael@0 | 189 | softPhone = CC_SIPCCServicePtr(new CC_SIPCCService()); |
michael@0 | 190 | phone = softPhone; |
michael@0 | 191 | phone->init(user, "", "127.0.0.1", "sipdevice"); |
michael@0 | 192 | softPhone->setLoggingMask(sipccLoggingMask); |
michael@0 | 193 | phone->addCCObserver(this); |
michael@0 | 194 | |
michael@0 | 195 | phone->setP2PMode(true); |
michael@0 | 196 | |
michael@0 | 197 | bool bStarted = phone->startService(); |
michael@0 | 198 | if (!bStarted) { |
michael@0 | 199 | setConnectionState(ConnectionStatusEnum::eFailed); |
michael@0 | 200 | } else { |
michael@0 | 201 | setConnectionState(ConnectionStatusEnum::eReady); |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | return bStarted; |
michael@0 | 205 | } |
michael@0 | 206 | |
michael@0 | 207 | bool CallControlManagerImpl::startSDPMode() |
michael@0 | 208 | { |
michael@0 | 209 | CSFLogInfo(logTag, "startSDPMode"); |
michael@0 | 210 | if(phone != nullptr) |
michael@0 | 211 | { |
michael@0 | 212 | CSFLogError(logTag, "%s failed - already started in SDP mode!",__FUNCTION__); |
michael@0 | 213 | return false; |
michael@0 | 214 | } |
michael@0 | 215 | softPhone = CC_SIPCCServicePtr(new CC_SIPCCService()); |
michael@0 | 216 | phone = softPhone; |
michael@0 | 217 | phone->init("JSEP", "", "127.0.0.1", "sipdevice"); |
michael@0 | 218 | softPhone->setLoggingMask(sipccLoggingMask); |
michael@0 | 219 | phone->addCCObserver(this); |
michael@0 | 220 | phone->setSDPMode(true); |
michael@0 | 221 | |
michael@0 | 222 | return phone->startService(); |
michael@0 | 223 | } |
michael@0 | 224 | |
michael@0 | 225 | bool CallControlManagerImpl::disconnect() |
michael@0 | 226 | { |
michael@0 | 227 | CSFLogInfo(logTag, "disconnect()"); |
michael@0 | 228 | if(phone == nullptr) |
michael@0 | 229 | return true; |
michael@0 | 230 | |
michael@0 | 231 | connectionState = ConnectionStatusEnum::eIdle; |
michael@0 | 232 | phone->removeCCObserver(this); |
michael@0 | 233 | phone->stop(); |
michael@0 | 234 | phone->destroy(); |
michael@0 | 235 | phone = nullptr; |
michael@0 | 236 | softPhone = nullptr; |
michael@0 | 237 | |
michael@0 | 238 | return true; |
michael@0 | 239 | } |
michael@0 | 240 | |
michael@0 | 241 | std::string CallControlManagerImpl::getPreferredDeviceName() |
michael@0 | 242 | { |
michael@0 | 243 | return preferredDevice; |
michael@0 | 244 | } |
michael@0 | 245 | |
michael@0 | 246 | std::string CallControlManagerImpl::getPreferredLineDN() |
michael@0 | 247 | { |
michael@0 | 248 | return preferredLineDN; |
michael@0 | 249 | } |
michael@0 | 250 | |
michael@0 | 251 | ConnectionStatusEnum::ConnectionStatus CallControlManagerImpl::getConnectionStatus() |
michael@0 | 252 | { |
michael@0 | 253 | return connectionState; |
michael@0 | 254 | } |
michael@0 | 255 | |
michael@0 | 256 | std::string CallControlManagerImpl::getCurrentServer() |
michael@0 | 257 | { |
michael@0 | 258 | return ""; |
michael@0 | 259 | } |
michael@0 | 260 | |
michael@0 | 261 | // Currently controlled device |
michael@0 | 262 | CC_DevicePtr CallControlManagerImpl::getActiveDevice() |
michael@0 | 263 | { |
michael@0 | 264 | if(phone != nullptr) |
michael@0 | 265 | return phone->getActiveDevice(); |
michael@0 | 266 | |
michael@0 | 267 | return CC_DevicePtr(); |
michael@0 | 268 | } |
michael@0 | 269 | |
michael@0 | 270 | // All known devices |
michael@0 | 271 | PhoneDetailsVtrPtr CallControlManagerImpl::getAvailablePhoneDetails() |
michael@0 | 272 | { |
michael@0 | 273 | PhoneDetailsVtrPtr result = PhoneDetailsVtrPtr(new PhoneDetailsVtr()); |
michael@0 | 274 | for(PhoneDetailsMap::iterator it = phoneDetailsMap.begin(); it != phoneDetailsMap.end(); it++) |
michael@0 | 275 | { |
michael@0 | 276 | PhoneDetailsPtr details = it->second.get(); |
michael@0 | 277 | result->push_back(details); |
michael@0 | 278 | } |
michael@0 | 279 | return result; |
michael@0 | 280 | } |
michael@0 | 281 | |
michael@0 | 282 | PhoneDetailsPtr CallControlManagerImpl::getAvailablePhoneDetails(const std::string& deviceName) |
michael@0 | 283 | { |
michael@0 | 284 | PhoneDetailsMap::iterator it = phoneDetailsMap.find(deviceName); |
michael@0 | 285 | if(it != phoneDetailsMap.end()) |
michael@0 | 286 | { |
michael@0 | 287 | return it->second.get(); |
michael@0 | 288 | } |
michael@0 | 289 | return PhoneDetailsPtr(); |
michael@0 | 290 | } |
michael@0 | 291 | // Media setup |
michael@0 | 292 | VideoControlPtr CallControlManagerImpl::getVideoControl() |
michael@0 | 293 | { |
michael@0 | 294 | if(phone != nullptr) |
michael@0 | 295 | return phone->getVideoControl(); |
michael@0 | 296 | |
michael@0 | 297 | return VideoControlPtr(); |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | AudioControlPtr CallControlManagerImpl::getAudioControl() |
michael@0 | 301 | { |
michael@0 | 302 | if(phone != nullptr) |
michael@0 | 303 | return phone->getAudioControl(); |
michael@0 | 304 | |
michael@0 | 305 | return AudioControlPtr(); |
michael@0 | 306 | } |
michael@0 | 307 | |
michael@0 | 308 | bool CallControlManagerImpl::setProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key, std::string& value) |
michael@0 | 309 | { |
michael@0 | 310 | unsigned long strtoul_result; |
michael@0 | 311 | char *strtoul_end; |
michael@0 | 312 | |
michael@0 | 313 | CSFLogInfo(logTag, "setProperty( %s )", value.c_str()); |
michael@0 | 314 | |
michael@0 | 315 | if (key == ConfigPropertyKeysEnum::eLocalVoipPort) { |
michael@0 | 316 | errno = 0; |
michael@0 | 317 | strtoul_result = strtoul(value.c_str(), &strtoul_end, 10); |
michael@0 | 318 | |
michael@0 | 319 | if (errno || value.c_str() == strtoul_end || strtoul_result > USHRT_MAX) { |
michael@0 | 320 | return false; |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | CCAPI_Config_set_local_voip_port((int) strtoul_result); |
michael@0 | 324 | } else if (key == ConfigPropertyKeysEnum::eRemoteVoipPort) { |
michael@0 | 325 | errno = 0; |
michael@0 | 326 | strtoul_result = strtoul(value.c_str(), &strtoul_end, 10); |
michael@0 | 327 | |
michael@0 | 328 | if (errno || value.c_str() == strtoul_end || strtoul_result > USHRT_MAX) { |
michael@0 | 329 | return false; |
michael@0 | 330 | } |
michael@0 | 331 | |
michael@0 | 332 | CCAPI_Config_set_remote_voip_port((int) strtoul_result); |
michael@0 | 333 | } else if (key == ConfigPropertyKeysEnum::eTransport) { |
michael@0 | 334 | if (value == "tcp") |
michael@0 | 335 | CCAPI_Config_set_transport_udp(false); |
michael@0 | 336 | else |
michael@0 | 337 | CCAPI_Config_set_transport_udp(true); |
michael@0 | 338 | } |
michael@0 | 339 | |
michael@0 | 340 | return true; |
michael@0 | 341 | } |
michael@0 | 342 | |
michael@0 | 343 | std::string CallControlManagerImpl::getProperty(ConfigPropertyKeysEnum::ConfigPropertyKeys key) |
michael@0 | 344 | { |
michael@0 | 345 | std::string retValue = "NONESET"; |
michael@0 | 346 | char tmpString[11]; |
michael@0 | 347 | |
michael@0 | 348 | CSFLogInfo(logTag, "getProperty()"); |
michael@0 | 349 | |
michael@0 | 350 | if (key == ConfigPropertyKeysEnum::eLocalVoipPort) { |
michael@0 | 351 | csf_sprintf(tmpString, sizeof(tmpString), "%u", CCAPI_Config_get_local_voip_port()); |
michael@0 | 352 | retValue = tmpString; |
michael@0 | 353 | } else if (key == ConfigPropertyKeysEnum::eRemoteVoipPort) { |
michael@0 | 354 | csf_sprintf(tmpString, sizeof(tmpString), "%u", CCAPI_Config_get_remote_voip_port()); |
michael@0 | 355 | retValue = tmpString; |
michael@0 | 356 | } else if (key == ConfigPropertyKeysEnum::eVersion) { |
michael@0 | 357 | const char* version = CCAPI_Config_get_version(); |
michael@0 | 358 | retValue = version; |
michael@0 | 359 | } |
michael@0 | 360 | |
michael@0 | 361 | return retValue; |
michael@0 | 362 | } |
michael@0 | 363 | /* |
michael@0 | 364 | There are a number of factors that determine PhoneAvailabilityType::PhoneAvailability. The supported states for this enum are: |
michael@0 | 365 | { eUnknown, eAvailable, eUnAvailable, eNotAllowed }. eUnknown is the default value, which is set when there is no information |
michael@0 | 366 | available that would otherwise determine the availability value. The factors that can influence PhoneAvailability are: |
michael@0 | 367 | phone mode, and for a given device (described by DeviceInfo) the model, and the name of the device. For phone control mode, the |
michael@0 | 368 | device registration and whether CUCM says the device is CTI controllable (or not) is a factor. |
michael@0 | 369 | |
michael@0 | 370 | For Phone Control mode the state machine is: |
michael@0 | 371 | |
michael@0 | 372 | is blacklisted model name? -> Yes -> NOT_ALLOWED |
michael@0 | 373 | (see Note1 below) |
michael@0 | 374 | || |
michael@0 | 375 | \/ |
michael@0 | 376 | No |
michael@0 | 377 | || |
michael@0 | 378 | \/ |
michael@0 | 379 | is CTI Controllable? |
michael@0 | 380 | (determined from CUCM) -> No -> NOT_ALLOWED |
michael@0 | 381 | || |
michael@0 | 382 | \/ |
michael@0 | 383 | Yes |
michael@0 | 384 | || |
michael@0 | 385 | \/ |
michael@0 | 386 | Can we tell if it's registered? -> No -> ?????? TODO: Seems to depends on other factors (look at suggestedAvailability parameter |
michael@0 | 387 | || in DeviceSubProviderImpl.addOrUpdateDevice() in CSF1G Java code. |
michael@0 | 388 | \/ |
michael@0 | 389 | Yes |
michael@0 | 390 | || |
michael@0 | 391 | \/ |
michael@0 | 392 | is Registered? |
michael@0 | 393 | (determined from CUCM) -> No -> NOT_AVAILABLE |
michael@0 | 394 | || |
michael@0 | 395 | \/ |
michael@0 | 396 | Yes |
michael@0 | 397 | || |
michael@0 | 398 | \/ |
michael@0 | 399 | AVAILABLE |
michael@0 | 400 | |
michael@0 | 401 | ======== |
michael@0 | 402 | |
michael@0 | 403 | For Softphone mode the state machine is: |
michael@0 | 404 | |
michael@0 | 405 | is device excluded? |
michael@0 | 406 | (based on "ExcludedDevices" -> Yes -> NOT_ALLOWED |
michael@0 | 407 | config settings |
michael@0 | 408 | (see Note2 below)) |
michael@0 | 409 | || |
michael@0 | 410 | \/ |
michael@0 | 411 | No |
michael@0 | 412 | || |
michael@0 | 413 | \/ |
michael@0 | 414 | isSoftphone? |
michael@0 | 415 | |
michael@0 | 416 | |
michael@0 | 417 | |
michael@0 | 418 | Note1: model name has to match completely, ie it's not a sub-string match, but we are ignoring case. So, if the blacklist |
michael@0 | 419 | contains a string "Cisco Unified Personal Communicator" then the model has to match this completely (but can be a |
michael@0 | 420 | different case) to be a match. In CSF1G the blacklist is hard-wired to: |
michael@0 | 421 | { "Cisco Unified Personal Communicator", |
michael@0 | 422 | "Cisco Unified Client Services Framework", |
michael@0 | 423 | "Client Services Framework", |
michael@0 | 424 | "Client Services Core" } |
michael@0 | 425 | |
michael@0 | 426 | Note2: The "ExcludedDevices" is a comma-separated list of device name prefixes (not model name). Unlike the above, this is |
michael@0 | 427 | a sub-string match, but only a "starts with" sub-string match, not anywhere in the string. If the device name |
michael@0 | 428 | is a complete match then this is also excluded, ie doesn't have to be a sub-string. For example, if the |
michael@0 | 429 | ExcludeDevices list contains { "ECP", "UPC" } then assuming we're in softphone mode, then any device whose |
michael@0 | 430 | name starts with the strings ECP or UPC, or whose complete name is either of these will be deemed to be excluded |
michael@0 | 431 | and will be marked as NOT_ALLOWED straightaway. In Phone Control mode the "ExcludedDevices" list i not taken into |
michael@0 | 432 | account at all in the determination of availability. |
michael@0 | 433 | |
michael@0 | 434 | Note3: isSoftphone() function |
michael@0 | 435 | |
michael@0 | 436 | The config service provides a list of "blacklisted" device name prefixes, that is, if the name of the device starts with a |
michael@0 | 437 | sub-string that matches an entry in the blacklist, then it is straightaway removed from the list? marked as NOT_ALLOWED. |
michael@0 | 438 | */ |
michael@0 | 439 | |
michael@0 | 440 | // CC_Observers |
michael@0 | 441 | void CallControlManagerImpl::onDeviceEvent(ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info) |
michael@0 | 442 | { |
michael@0 | 443 | notifyDeviceEventObservers(deviceEvent, devicePtr, info); |
michael@0 | 444 | } |
michael@0 | 445 | void CallControlManagerImpl::onFeatureEvent(ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info) |
michael@0 | 446 | { |
michael@0 | 447 | notifyFeatureEventObservers(deviceEvent, devicePtr, info); |
michael@0 | 448 | } |
michael@0 | 449 | void CallControlManagerImpl::onLineEvent(ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info) |
michael@0 | 450 | { |
michael@0 | 451 | notifyLineEventObservers(lineEvent, linePtr, info); |
michael@0 | 452 | } |
michael@0 | 453 | void CallControlManagerImpl::onCallEvent(ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info) |
michael@0 | 454 | { |
michael@0 | 455 | notifyCallEventObservers(callEvent, callPtr, info); |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | |
michael@0 | 459 | void CallControlManagerImpl::notifyDeviceEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_DeviceInfoPtr info) |
michael@0 | 460 | { |
michael@0 | 461 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 462 | set<CC_Observer*>::const_iterator it = ccObservers.begin(); |
michael@0 | 463 | for ( ; it != ccObservers.end(); it++ ) |
michael@0 | 464 | { |
michael@0 | 465 | (*it)->onDeviceEvent(deviceEvent, devicePtr, info); |
michael@0 | 466 | } |
michael@0 | 467 | } |
michael@0 | 468 | |
michael@0 | 469 | void CallControlManagerImpl::notifyFeatureEventObservers (ccapi_device_event_e deviceEvent, CC_DevicePtr devicePtr, CC_FeatureInfoPtr info) |
michael@0 | 470 | { |
michael@0 | 471 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 472 | set<CC_Observer*>::const_iterator it = ccObservers.begin(); |
michael@0 | 473 | for ( ; it != ccObservers.end(); it++ ) |
michael@0 | 474 | { |
michael@0 | 475 | (*it)->onFeatureEvent(deviceEvent, devicePtr, info); |
michael@0 | 476 | } |
michael@0 | 477 | } |
michael@0 | 478 | |
michael@0 | 479 | void CallControlManagerImpl::notifyLineEventObservers (ccapi_line_event_e lineEvent, CC_LinePtr linePtr, CC_LineInfoPtr info) |
michael@0 | 480 | { |
michael@0 | 481 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 482 | set<CC_Observer*>::const_iterator it = ccObservers.begin(); |
michael@0 | 483 | for ( ; it != ccObservers.end(); it++ ) |
michael@0 | 484 | { |
michael@0 | 485 | (*it)->onLineEvent(lineEvent, linePtr, info); |
michael@0 | 486 | } |
michael@0 | 487 | } |
michael@0 | 488 | |
michael@0 | 489 | void CallControlManagerImpl::notifyCallEventObservers (ccapi_call_event_e callEvent, CC_CallPtr callPtr, CC_CallInfoPtr info) |
michael@0 | 490 | { |
michael@0 | 491 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 492 | set<CC_Observer*>::const_iterator it = ccObservers.begin(); |
michael@0 | 493 | for ( ; it != ccObservers.end(); it++ ) |
michael@0 | 494 | { |
michael@0 | 495 | (*it)->onCallEvent(callEvent, callPtr, info); |
michael@0 | 496 | } |
michael@0 | 497 | } |
michael@0 | 498 | |
michael@0 | 499 | void CallControlManagerImpl::notifyAvailablePhoneEvent (AvailablePhoneEventType::AvailablePhoneEvent event, |
michael@0 | 500 | const PhoneDetailsPtr availablePhoneDetails) |
michael@0 | 501 | { |
michael@0 | 502 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 503 | set<ECC_Observer*>::const_iterator it = eccObservers.begin(); |
michael@0 | 504 | for ( ; it != eccObservers.end(); it++ ) |
michael@0 | 505 | { |
michael@0 | 506 | (*it)->onAvailablePhoneEvent(event, availablePhoneDetails); |
michael@0 | 507 | } |
michael@0 | 508 | } |
michael@0 | 509 | |
michael@0 | 510 | void CallControlManagerImpl::notifyAuthenticationStatusChange (AuthenticationStatusEnum::AuthenticationStatus status) |
michael@0 | 511 | { |
michael@0 | 512 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 513 | set<ECC_Observer*>::const_iterator it = eccObservers.begin(); |
michael@0 | 514 | for ( ; it != eccObservers.end(); it++ ) |
michael@0 | 515 | { |
michael@0 | 516 | (*it)->onAuthenticationStatusChange(status); |
michael@0 | 517 | } |
michael@0 | 518 | } |
michael@0 | 519 | |
michael@0 | 520 | void CallControlManagerImpl::notifyConnectionStatusChange(ConnectionStatusEnum::ConnectionStatus status) |
michael@0 | 521 | { |
michael@0 | 522 | mozilla::MutexAutoLock lock(m_lock); |
michael@0 | 523 | set<ECC_Observer*>::const_iterator it = eccObservers.begin(); |
michael@0 | 524 | for ( ; it != eccObservers.end(); it++ ) |
michael@0 | 525 | { |
michael@0 | 526 | (*it)->onConnectionStatusChange(status); |
michael@0 | 527 | } |
michael@0 | 528 | } |
michael@0 | 529 | |
michael@0 | 530 | void CallControlManagerImpl::setConnectionState(ConnectionStatusEnum::ConnectionStatus status) |
michael@0 | 531 | { |
michael@0 | 532 | connectionState = status; |
michael@0 | 533 | notifyConnectionStatusChange(status); |
michael@0 | 534 | } |
michael@0 | 535 | } |