~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/src/dbus/callmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
const char* CallManager::SERVER_PATH = "/org/sflphone/SFLphone/CallManager";
43
43
 
44
44
CallManager::CallManager (DBus::Connection& connection)
45
 
        : DBus::ObjectAdaptor (connection, SERVER_PATH)
 
45
    : DBus::ObjectAdaptor (connection, SERVER_PATH)
46
46
{
47
47
}
48
48
 
49
49
void
50
50
CallManager::placeCall (const std::string& accountID,
51
51
                        const std::string& callID,
52
 
                        const std::string& to)
53
 
{    // Check if a destination number is available
 
52
                        const std::string& to)     // Check if a destination number is available
 
53
{
54
54
 
55
55
    if (to == "")   _debug ("No number entered - Call stopped");
56
56
    else            Manager::instance().outgoingCall (accountID, callID, to);
58
58
 
59
59
void
60
60
CallManager::placeCallFirstAccount (const std::string& callID,
61
 
                                    const std::string& to)
 
61
                                    const std::string& to)
62
62
{
63
63
 
64
64
    if (to == "") {
65
 
        _warn("CallManager: Warning: No number entered, call stopped");
66
 
        return;
 
65
        _warn ("CallManager: Warning: No number entered, call stopped");
 
66
        return;
67
67
    }
68
68
 
69
69
    std::vector< std::string > accountOrder = Manager::instance().loadAccountOrder();
71
71
 
72
72
    Account *account;
73
73
 
74
 
    _debug("AccountOrder size: %d", accountOrder.size());
75
 
 
76
 
    if(accountOrder.size() > 0) {
77
 
 
78
 
      iter = accountOrder.begin();
79
 
 
80
 
      while(iter != accountOrder.end()) {
81
 
        account = Manager::instance().getAccount(*iter);
82
 
        if((*iter != IP2IP_PROFILE) && account->isEnabled()) {
83
 
            Manager::instance().outgoingCall (*iter, callID, to);
84
 
            return;
85
 
        }
86
 
 
87
 
        iter++;
88
 
      }
89
 
    }
90
 
    else {
91
 
      _error("AccountOrder is empty");
92
 
      // If accountOrder is empty fallback on accountList (which has no preference order)
93
 
      std::vector< std::string > accountList = Manager::instance().getAccountList();
94
 
      iter = accountList.begin();
95
 
      
96
 
 
97
 
      _error("AccountList size: %d", accountList.size());
98
 
      if(accountList.size() > 0) {
99
 
        while(iter != accountList.end()) {
100
 
          _error("iter");
101
 
          account = Manager::instance().getAccount(*iter);
102
 
          if((*iter != IP2IP_PROFILE) && account->isEnabled()) {
103
 
            _error("makecall");
104
 
            Manager::instance().outgoingCall(*iter, callID, to);
105
 
            return;
106
 
          }
107
 
          iter++;
108
 
        }
109
 
        
110
 
      }
111
 
    }
112
 
    
113
 
    _warn("CallManager: Warning: No enabled account found, call stopped");
114
 
    
 
74
    _debug ("AccountOrder size: %d", accountOrder.size());
 
75
 
 
76
    if (accountOrder.size() > 0) {
 
77
 
 
78
        iter = accountOrder.begin();
 
79
 
 
80
        while (iter != accountOrder.end()) {
 
81
            account = Manager::instance().getAccount (*iter);
 
82
 
 
83
            if ( (*iter != IP2IP_PROFILE) && account->isEnabled()) {
 
84
                Manager::instance().outgoingCall (*iter, callID, to);
 
85
                return;
 
86
            }
 
87
 
 
88
            iter++;
 
89
        }
 
90
    } else {
 
91
        _error ("AccountOrder is empty");
 
92
        // If accountOrder is empty fallback on accountList (which has no preference order)
 
93
        std::vector< std::string > accountList = Manager::instance().getAccountList();
 
94
        iter = accountList.begin();
 
95
 
 
96
 
 
97
        _error ("AccountList size: %d", accountList.size());
 
98
 
 
99
        if (accountList.size() > 0) {
 
100
            while (iter != accountList.end()) {
 
101
                _error ("iter");
 
102
                account = Manager::instance().getAccount (*iter);
 
103
 
 
104
                if ( (*iter != IP2IP_PROFILE) && account->isEnabled()) {
 
105
                    _error ("makecall");
 
106
                    Manager::instance().outgoingCall (*iter, callID, to);
 
107
                    return;
 
108
                }
 
109
 
 
110
                iter++;
 
111
            }
 
112
 
 
113
        }
 
114
    }
 
115
 
 
116
    _warn ("CallManager: Warning: No enabled account found, call stopped");
 
117
 
115
118
}
116
119
 
117
120
void
261
264
std::vector< std::string >
262
265
CallManager::getParticipantList (const std::string& confID)
263
266
{
264
 
    _debug("CallManager: Get Participant list for conference %s", confID.c_str());
 
267
    _debug ("CallManager: Get Participant list for conference %s", confID.c_str());
265
268
    return Manager::instance().getParticipantList (confID);
266
269
}
267
270
 
330
333
    SIPVoIPLink * link = NULL;
331
334
    link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (AccountNULL));
332
335
 
333
 
    if (link == NULL) {
334
 
        _debug ("Failed to get sip link");
 
336
    if (!link) {
 
337
        _debug ("CallManager: Failed to get sip link");
335
338
        throw CallManagerException();
336
339
    }
337
340
 
338
341
    SIPCall *call = link->getSIPCall (callID);
339
342
 
 
343
    if (!call) {
 
344
        _debug ("CallManager: Call id %d is not valid", callID.c_str());
 
345
        throw CallManagerException();
 
346
    }
 
347
 
340
348
    sfl::AudioRtpFactory * audioRtp = NULL;
341
349
    audioRtp = call->getAudioRtp();
342
350
 
343
 
    if (audioRtp == NULL) {
344
 
        _debug ("Failed to get AudioRtpFactory");
 
351
    if (!audioRtp) {
 
352
        _debug ("CallManager: Failed to get AudioRtpFactory");
345
353
        throw CallManagerException();
346
354
    }
347
355
 
349
357
 
350
358
    zSession = audioRtp->getAudioZrtpSession();
351
359
 
352
 
    if (zSession == NULL) {
353
 
        _debug ("Failed to get AudioZrtpSession");
 
360
    if (!zSession) {
 
361
        _debug ("CallManager: Failed to get AudioZrtpSession");
354
362
        throw CallManagerException();
355
363
    }
356
364
 
366
374
        zSession = getAudioZrtpSession (callID);
367
375
        zSession->SASVerified();
368
376
    } catch (...) {
369
 
        throw;
 
377
        return;
 
378
        // throw;
370
379
    }
371
380
 
372
381
}
380
389
        zSession = getAudioZrtpSession (callID);
381
390
        zSession->resetSASVerified();
382
391
    } catch (...) {
383
 
        throw;
 
392
        return;
 
393
        // throw;
384
394
    }
385
395
 
386
396
}
395
405
        zSession = getAudioZrtpSession (callID);
396
406
        zSession->goClearOk();
397
407
    } catch (...) {
398
 
        throw;
 
408
        return;
 
409
        // throw;
399
410
    }
400
411
 
401
412
}
410
421
        zSession = getAudioZrtpSession (callID);
411
422
        zSession->requestGoClear();
412
423
    } catch (...) {
413
 
        throw;
 
424
        return;
 
425
        /// throw;
414
426
    }
415
427
 
416
428
}
426
438
        zSession = getAudioZrtpSession (callID);
427
439
        zSession->acceptEnrollment (accepted);
428
440
    } catch (...) {
429
 
        throw;
 
441
        return;
 
442
        // throw;
430
443
    }
431
444
 
432
445
}
442
455
        zSession = getAudioZrtpSession (callID);
443
456
        zSession->setPBXEnrollment (yesNo);
444
457
    } catch (...) {
445
 
        throw;
 
458
        return;
 
459
        // throw;
446
460
    }
447
461
 
448
462
}
 
463
 
 
464
void
 
465
CallManager::sendTextMessage (const std::string& callID, const std::string& message)
 
466
{
 
467
    if (!Manager::instance().sendTextMessage (callID, message, "Me"))
 
468
        throw CallManagerException();
 
469
}