Ejemplo n.º 1
0
 public function getFunctionsForCall($callinfo)
 {
     $contextList = '';
     if (isset($callinfo['state'])) {
         switch ($callinfo['state']) {
             case 'CS_NEW':
             case 'CS_INIT':
                 $contextList .= 'freeswitch.callstatus.setup;';
                 break;
             case 'CS_ROUTING':
             case 'CS_SOFT_EXECUTE':
             case 'CS_EXECUTE':
             case 'CS_EXCHANGE_MEDIA':
             case 'CS_PARK':
                 $contextList .= 'freeswitch.callstatus.active;';
                 break;
             case 'CS_CONSUME_MEDIA':
             case 'CS_HIBERNATE':
             case 'CS_RESET':
             case 'CS_HANGUP':
             case 'CS_REPORTING':
             case 'CS_DESTROY':
                 $contextList .= 'freeswitch.callstatus.teardown;';
                 break;
         }
     }
     if (isset($callinfo['callstate']) && $callinfo['callstate'] == 'ACTIVE') {
         $contextList .= 'freeswitch.callstatus.active;';
     }
     return callmanagerFunction::getFunctionsByContext($contextList);
 }
Ejemplo n.º 2
0
 public static function register($name, $package, $displayname, $context, $desc = null, $mode = 'SAFE')
 {
     // see if the package is already registered
     $funcobj = null;
     try {
         $funcobj =& self::getFunctionByName($name);
     } catch (Exception $e) {
         if (!$e->getCode() == 0) {
             throw $e;
         }
     }
     if ($funcobj && $mode == 'SAFE') {
         throw new callmanagerException('This feature is already registered and registration was attempted in safe mode.', 0);
     }
     // find the package attempting registration
     try {
         if (!($packageobj = Package_Catalog::getInstalledPackage($package))) {
             throw new callmanagerException('The package "' . $package . '" that attempted to register funnction "' . $name . '" was not found.', -1);
         }
     } catch (Package_Catalog_Exception $e) {
         throw new callmanagerException('The package "' . $package . '" that attempted to register function "' . $name . '" was not found.', -1);
     }
     $package = $packageobj['datastore_id'];
     // if we are reregging (e.g. to handle a package upgrade) then make sure that package matches what is on file
     if ($mode == 'REREG' && $funcobj && $funcobj->cmf_package_id !== $package) {
         // Make sure the package that is on file still exists, otherwise allow the rereg
         $cmf_package_obj = Doctrine::getTable('package')->findOne($funcobj->cmf_package_id);
         if ($cmf_package_obj && $cmf_package_obj->name !== $packageobj->name) {
             throw new callmanagerException('Rereg was attempted on the funnction named "' . $funcobj->cmf_name . '" but the package that tried to reregister named "' . $packageobj->name . '" does not match the currently registered package "' . $ftr_package_obj->name . '".', -2);
         }
     }
     if (!$funcobj) {
         $funcobj = new callmanagerFunction();
     }
     $funcobj->cmf_name = $name;
     $funcobj->cmf_display_name = $displayname;
     $funcobj->cmf_package_id = $package;
     $funcobj->cmf_context = $context;
     $funcobj->cmf_desc = $desc;
     $funcobj->save();
 }
Ejemplo n.º 3
0
 public static function installDefaultFunctions()
 {
     try {
         callmanagerFunction::reregister('hangup', 'callmanager', 'Hangup', 'freeswitch.callstatus.active;', 'Does this sound like a dial tone?', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
     try {
         callmanagerFunction::reregister('hold', 'callmanager', 'Hold', 'freeswitch.callstatus.active;', 'Bring on the elevator music!', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
     try {
         callmanagerFunction::reregister('monitor', 'callmanager', 'Monitor', 'freeswitch.callstatus.active;', 'Do you have a warrant?', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
     try {
         callmanagerFunction::reregister('valetpark', 'callmanager', 'Park', 'freeswitch.callstatus.active;', 'As long as it\'s not parallel parking!!!', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
     try {
         callmanagerFunction::reregister('record', 'callmanager', 'Record', 'freeswitch.callstatus.active;', 'For quality control purposes.', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
     try {
         callmanagerFunction::reregister('transfer', 'callmanager', 'Transfer', 'freeswitch.callstatus.active;', 'Someone is on the phone for you...', User::TYPE_SYSTEM_ADMIN);
     } catch (callmanagerException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
 }