<?php
/*
 *
 * Copyright 2009 France Telecom SA Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 */

/**
 *  @desc Object containing all the necessary data for service connectivity
 *  @name  M2M_ServiceConfigurator
 *  @package M2M API
 *  @param M2M_ServiceConfigurator
 */
class M2M_ServiceConfigurator {
	
	/**
	 * @var $_oProxy
	 */
  protected $_oProxy;
  
	/**
	 * @var $_oSoapClient
	 * @desc The http proxy address
	 */
	protected $_oSoapClient;
		
	/**
	 * @var $_oCredentials
	 * @desc Contains the credentials for service connexion
	 */
	protected $_oCredentials;
	
	/**
	 * @var $_sSubscriptionStatusServiceUrl
	 * @desc Contains the path to the actual service endpoint
	 */
	protected $_sSubscriptionStatusServiceUrl;

	/**
	 * @var $_sSimLifecycleManagementServiceUrl
	 */
	protected  $_sSimLifecycleManagementServiceUrl;	

	/**
	 * @var $sConnectivityDirectoryUrl
	 */
	protected $sConnectivityDirectoryUrl;
	
 
	/**
	 * @var $sSessionHistoryUrlV2
	 */
	protected $sSessionHistoryUrlV2;

	
	
	/**
	 * @var $sServiceCustomerAlarmUrlV2
	 */
	protected $sServiceCustomerAlarmUrlV2;
	
	/**
	 * @var $sTrafficTrackingUrl
	 */
	protected $sTrafficTrackingUrl;
	
	/**
	 * @var $sDeviceInfoUrl
	 */
	protected $sDeviceInfoUrl;
	
  	/**
	 * @var $sCertificate
	 */
	protected $sCertificate;
  
		
	/**
	 * Contructor
	 * @param string $propertyFile Path to the configuration file
	 * 
	 */
	public function __construct (M2M_IniParser $oIniM2m) {
	  
	// Proxy
	$this->_oProxy = new M2M_Proxy(
	$oIniM2m->getProperty("proxyHost"),
	$oIniM2m->getProperty("proxyPort"),
    $oIniM2m->getProperty("proxyUsername"),
    $oIniM2m->getProperty("proxyPassword")		  
	);
		
	// Credentials
	$this->_oCredentials = new M2M_Credentials();
	$this->_oCredentials->login    = $oIniM2m->getProperty("login");
	$this->_oCredentials->password = $oIniM2m->getProperty("password");
	
	//Certificate
    //$this->_sCertificate = $oIniM2m->getProperty ( "useCertificate" );

    // Service Urls
    $this->_sConnectivityDirectoryUrl   = $oIniM2m->getProperty ( "connectivityDirectoryUrl" );
    $this->_sSimLifecycleManagementUrl  = $oIniM2m->getProperty ( "simLifecycleManagementUrl" );
    $this->_sSubscriptionStatusUrl      = $oIniM2m->getProperty ( "subscriptionStatusUrl" );
	$this->_sSessionHistoryUrlV2		= $oIniM2m->getProperty ( "sessionHistoryUrl2" );
	//New Service Urls
	$this->_sServiceCustomerAlarmUrlV2    = $oIniM2m->getProperty ( "ServiceCustomerAlarmUrl2" );	
	$this->_sTrafficTrackingUrl 		= $oIniM2m->getProperty ( "TrafficTrackingUrl" );
	$this->_sDeviceInfoUrl 		= $oIniM2m->getProperty ( "deviceInfoUrl" );

	}
	

 /**
   * Callback for unknown methods
   * @param $method
   * @param $args
   * @return unknown_type
   */
  public function __call($method, $args) {
    if ( property_exists ( $this, $attr = substr ( $method, 3 ) ) ) {
      if ( substr ( $method, 0, 3 ) == 'set' ) {
        return $this->$attr = $args [0];
      }
      if ( substr ( $method, 0, 3 ) == 'get' ) {
        return $this->$attr;
      }
    }
    throw new M2M_ProxyException ( "Method $method not found in " . __FILE__ . "." );
  }	
}

