[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 include_once 'SyncML/Command.php'; 4 5 /** 6 * The SyncML_Command_Final class. 7 * 8 * $Horde: framework/SyncML/SyncML/Command/Final.php,v 1.10.10.5 2006/01/01 21:28:36 jan Exp $ 9 * 10 * Copyright 2003-2006 Anthony Mills <amills@pyramid6.com> 11 * 12 * See the enclosed file COPYING for license information (LGPL). If you 13 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 14 * 15 * @author Anthony Mills <amills@pyramid6.com> 16 * @since Horde 3.0 17 * @package SyncML 18 */ 19 class SyncML_Command_Final extends SyncML_Command { 20 21 /** 22 * Create the response for a final tag 23 */ 24 function output($currentCmdID, &$output) 25 { 26 $state = &$_SESSION['SyncML.state']; 27 $attrs = array(); 28 29 // If the client hasn't sent us device info, request it now. 30 $di = SyncML_Device::deviceInfo(); 31 if (empty($di->_Man)) { 32 $output->startElement($state->getURI(), 'Get', $attrs); 33 34 $output->startElement($state->getURI(), 'CmdID', $attrs); 35 $chars = $currentCmdID; 36 $output->characters($chars); 37 $output->endElement($state->getURI(), 'CmdID'); 38 39 $output->startElement($state->getURI(), 'Meta', $attrs); 40 $output->startElement($state->getURIMeta(), 'Type', $attrs); 41 $attrs = array(); 42 if (is_a($output, 'XML_WBXML_Encoder')) { 43 $chars = MIME_SYNCML_DEVICE_INFO_WBXML; 44 } else { 45 $chars = MIME_SYNCML_DEVICE_INFO_XML; 46 } 47 $output->characters($chars); 48 $output->endElement($state->getURI(), 'Type'); 49 $output->endElement($state->getURI(), 'Meta'); 50 51 $output->startElement($state->getURI(), 'Item', $attrs); 52 $output->startElement($state->getURI(), 'Target', $attrs); 53 $output->startElement($state->getURI(), 'LocURI', $attrs); 54 $chars = ($state->getVersion() == 0) ? './devinf10' : './devinf11'; 55 $output->characters($chars); 56 $output->endElement($state->getURI(), 'LocURI'); 57 $output->endElement($state->getURI(), 'Target'); 58 $output->endElement($state->getURI(), 'Item'); 59 60 $output->endElement($state->getURI(), 'Get'); 61 62 // Mark this id down as needing a results packet routed to 63 // the Put command. 64 $state->setExpectedResultType($currentCmdID, 'Put'); 65 66 $currentCmdID++; 67 } 68 return $currentCmdID; 69 } 70 /** 71 * Create a <Final> output. 72 * Before that continue a sync if there are pending entries. 73 * Static method 74 */ 75 function outputFinal($currentCmdID, &$output) 76 { 77 $state = &$_SESSION['SyncML.state']; 78 $attrs = array(); 79 80 global $messageFull; 81 /* If there's pending sync data and space left in the message: 82 * send data now. */ 83 if (!$messageFull && 84 count($p = $state->getPendingSyncs()) > 0) { 85 foreach ($p as $pendingSync) { 86 if (!$messageFull) { 87 $GLOBALS['backend']->logMessage('continue sync for syncType=' . $pendingSync, 88 __FILE__, __LINE__, PEAR_LOG_DEBUG); 89 $sync = & $state->getSync($pendingSync); 90 $currentCmdID = $sync->createSyncOutput($currentCmdID, $output); 91 } 92 } 93 } /* 94 * Don't send the final tag if we haven't sent all sync data yet. 95 */ 96 if (!$state->hasPendingElements()) { 97 $output->startElement($state->getURI(), 'Final', $attrs); 98 $output->endElement($state->getURI(), 'Final'); 99 } else { 100 $GLOBALS['backend']->logMessage('pending elements, not sending final tag', 101 __FILE__, __LINE__, PEAR_LOG_DEBUG); 102 } 103 return $currentCmdID; 104 } 105 106 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |