/**
  * the singleton pattern
  *
  * @return ActiveSync_Controller_Device
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new ActiveSync_Controller_Device();
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 /**
  * (non-PHPdoc)
  * @see ActiveSync/ActiveSync_TestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     $iphone = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_IPHONE);
     $iphone->owner_id = $this->_testUser->getId();
     $this->objects['deviceIPhone'] = ActiveSync_Controller_Device::getInstance()->create($iphone);
 }
Exemplo n.º 3
0
 /**
  * process the XML file and add, change, delete or fetches data 
  *
  * @return resource
  */
 public function handle()
 {
     $controller = ActiveSync_Controller::getInstance();
     $xml = simplexml_import_dom($this->_inputDom);
     $this->_policyType = isset($xml->Policies->Policy->PolicyType) ? (string) $xml->Policies->Policy->PolicyType : null;
     $this->_policyKey = isset($xml->Policies->Policy->PolicyKey) ? (int) $xml->Policies->Policy->PolicyKey : null;
     if ($this->_device->remotewipe == self::REMOTEWIPE_REQUESTED && isset($xml->RemoteWipe->Status) && (int) $xml->RemoteWipe->Status == self::STATUS_SUCCESS) {
         $this->_device->remotewipe = self::REMOTEWIPE_CONFIRMED;
         $this->_device = ActiveSync_Controller_Device::getInstance()->update($this->_device);
     }
 }
Exemplo n.º 4
0
 /**
  * (non-PHPdoc)
  * @see ActiveSync/ActiveSync_TestCase::setUp()
  */
 protected function setUp()
 {
     $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP);
     if (!$imapConfig || !isset($imapConfig->useSystemAccount) || $imapConfig->useSystemAccount != TRUE) {
         $this->markTestSkipped('IMAP backend not configured');
     }
     $this->_emailTestClass = new Felamimail_Controller_MessageTest();
     $this->_emailTestClass->setup();
     $this->_createdMessages = new Tinebase_Record_RecordSet('Felamimail_Model_Message');
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $testDevice = ActiveSync_Backend_DeviceTests::getTestDevice();
     $this->objects['device'] = ActiveSync_Controller_Device::getInstance()->create($testDevice);
 }
Exemplo n.º 5
0
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     // remove accounts for group member tests
     try {
         Tinebase_User::getInstance()->deleteUser($this->objects['user']->accountId);
     } catch (Exception $e) {
         // do nothing
     }
     Addressbook_Controller_Contact::getInstance()->delete(array($this->objects['contact']->getId(), $this->objects['unSyncableContact']->getId()));
     Tinebase_Container::getInstance()->deleteContainer($this->objects['containerWithSyncGrant']);
     Tinebase_Container::getInstance()->deleteContainer($this->objects['containerWithoutSyncGrant']);
     ActiveSync_Controller_Device::getInstance()->delete($this->objects['deviceWebOS']);
     ActiveSync_Controller_Device::getInstance()->delete($this->objects['deviceIPhone']);
     $filterBackend = new Tinebase_PersistentFilter_Backend_Sql();
     $filterBackend->delete($this->objects['filter']->getId());
     Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts($this->_setGeoData);
 }
Exemplo n.º 6
0
 /**
  * return active device
  * 
  * @param string $_deviceType
  * @return ActiveSync_Model_Device
  */
 protected function _getDevice($_deviceType)
 {
     if (isset($this->objects['devices'][$_deviceType])) {
         return $this->objects['devices'][$_deviceType];
     }
     $this->objects['devices'][$_deviceType] = ActiveSync_Controller_Device::getInstance()->create(ActiveSync_Backend_DeviceTests::getTestDevice($_deviceType));
     return $this->objects['devices'][$_deviceType];
 }
Exemplo n.º 7
0
 /**
  * test setting content filter
  */
 public function testSetDeviceContentFilter()
 {
     ActiveSync_Controller_Device::getInstance()->setDeviceContentFilter($this->objects['device']->getId(), ActiveSync_Controller::CLASS_CONTACTS, $this->objects['filter']->getId());
     $device = ActiveSync_Controller_Device::getInstance()->get($this->objects['device']->getId());
     $this->assertEquals($device->contactsfilter_id, $this->objects['filter']->getId());
 }
Exemplo n.º 8
0
 /**
  * Set sync filter
  * 
  * @param  string $deviceId
  * @param  string $class one of {Calendar, Contacts, Email, Tasks}
  * @param  string $filterId
  * @return array device data
  */
 public function setDeviceContentFilter($deviceId, $class, $filterId)
 {
     $device = ActiveSync_Controller_Device::getInstance()->setDeviceContentFilter($deviceId, $class, $filterId);
     return $device->toArray();
 }
Exemplo n.º 9
0
 /**
  * test xml generation for IPhone
  */
 public function testRemoteWipeStep2()
 {
     $this->testRemoteWipeStep1();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <Provision xmlns="uri:Provision"><RemoteWipe><Status>1</Status></RemoteWipe></Provision>');
     $provision = new Syncope_Command_Provision($doc, $this->objects['device'], $this->objects['device']->policykey);
     $provision->handle();
     $responseDoc = $provision->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $this->objects['device'] = ActiveSync_Controller_Device::getInstance()->get($this->objects['device']);
     $this->assertEquals(Syncope_Command_Provision::REMOTEWIPE_CONFIRMED, $this->objects['device']->remotewipe);
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('Provision', 'uri:Provision');
     $nodes = $xpath->query('//Provision:Provision/Provision:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_FolderSync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//Provision:Provision/Provision:RemoteWipe');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
 }
Exemplo n.º 10
0
 /**
  * (non-PHPdoc)
  * @see ActiveSync/ActiveSync_TestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     // replace email to make current user organizer and attendee
     $this->_testXMLInput = str_replace('*****@*****.**', Tinebase_Core::getUser()->accountEmailAddress, $this->_testXMLInput);
     $event = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->addMonth(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->addMonth(1)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true, 'attendee' => new Tinebase_Record_RecordSet('Calendar_Model_Attender', array(array('user_id' => Tinebase_Core::getUser()->contact_id, 'user_type' => Calendar_Model_Attender::USERTYPE_USER, 'status' => Calendar_Model_Attender::STATUS_ACCEPTED)))));
     $event = Calendar_Controller_Event::getInstance()->create($event);
     $this->objects['event'] = $event;
     $event2MonthsBack = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->subMonth(2)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->subMonth(2)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true));
     $event = Calendar_Controller_Event::getInstance()->create($event2MonthsBack);
     $this->objects['event2MonthsBack'] = $event;
     $eventDaily = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->addMonth(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->addMonth(1)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=' . Tinebase_DateTime::now()->addMonth(1)->addDay(6)->setHour(22)->setMinute(59)->setSecond(59)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true));
     $eventDaily = Calendar_Controller_Event::getInstance()->create($eventDaily);
     // compute recurset
     $recurSet = Calendar_Model_Rrule::computeRecurrenceSet($eventDaily, new Tinebase_Record_RecordSet('Calendar_Model_Event'), $eventDaily->dtstart, $eventDaily->rrule_until);
     // first deleted instance
     Calendar_Controller_Event::getInstance()->createRecurException($recurSet[0], true);
     // second deleted instance
     Calendar_Controller_Event::getInstance()->createRecurException($recurSet[1], true);
     // first exception instance
     $recurSet[2]->dtstart->addHour(2);
     $recurSet[2]->dtend->addHour(2);
     $recurSet[2]->summary = 'Test Exception 1';
     Calendar_Controller_Event::getInstance()->createRecurException($recurSet[2]);
     // first exception instance
     $recurSet[3]->dtstart->addHour(3);
     $recurSet[3]->dtend->addHour(3);
     $recurSet[3]->summary = 'Test Exception 2';
     Calendar_Controller_Event::getInstance()->createRecurException($recurSet[3]);
     // reread event from database again
     $eventDaily = Calendar_Controller_Event::getInstance()->get($eventDaily);
     #var_dump($eventDaily->toArray());
     $this->objects['eventDaily'] = $eventDaily;
     Tinebase_Core::getPreference('ActiveSync')->setValue(ActiveSync_Preference::DEFAULTCALENDAR, $this->_getContainerWithSyncGrant()->getId());
     ########### define test filter
     $filterBackend = new Tinebase_PersistentFilter_Backend_Sql();
     try {
         $filter = $filterBackend->getByProperty('Calendar Sync Test', 'name');
     } catch (Tinebase_Exception_NotFound $e) {
         $filter = new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Calendar_Model_EventFilter', 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getContainerWithSyncGrant()->getId())), 'name' => 'Calendar Sync Test', 'description' => 'Created by unit test'));
         $filter = $filterBackend->create($filter);
     }
     $this->objects['filter'] = $filter;
     ########### define test devices
     $palm = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_WEBOS);
     $palm->owner_id = $this->_testUser->getId();
     $palm->calendarfilter_id = $this->objects['filter']->getId();
     $this->objects['deviceWebOS'] = ActiveSync_Controller_Device::getInstance()->create($palm);
     $iphone = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_IPHONE);
     $iphone->owner_id = $this->_testUser->getId();
     $iphone->calendarfilter_id = $this->objects['filter']->getId();
     $this->objects['deviceIPhone'] = ActiveSync_Controller_Device::getInstance()->create($iphone);
 }