fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7428] sms: more on pswin


From: Sigurd Nes
Subject: [Fmsystem-commits] [7428] sms: more on pswin
Date: Fri, 24 Jun 2011 08:45:30 +0000

Revision: 7428
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7428
Author:   sigurdne
Date:     2011-06-24 08:45:29 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
sms: more on pswin

Modified Paths:
--------------
    trunk/sms/inc/plugin/gateway/pswin/get.php

Added Paths:
-----------
    trunk/sms/inc/plugin/gateway/pswin/SMSReceive.php

Added: trunk/sms/inc/plugin/gateway/pswin/SMSReceive.php
===================================================================
--- trunk/sms/inc/plugin/gateway/pswin/SMSReceive.php                           
(rev 0)
+++ trunk/sms/inc/plugin/gateway/pswin/SMSReceive.php   2011-06-24 08:45:29 UTC 
(rev 7428)
@@ -0,0 +1,419 @@
+<?php
+       /**
+       * phpGroupWare
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2011 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package phpgroupware
+       * @subpackage communication
+       * @category core
+       * @version $Id: SMSReceive.php 4237 2009-11-27 23:17:21Z sigurd $
+       */
+
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 2 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       /**
+        * soap client for pswin.com SMS service
+        * this code is generated by the 
http://code.google.com/p/wsdl2php-interpreter/ 
+        *
+        * @package phpgroupware
+        * @subpackage sms
+        */
+       
+       /**
+        * ReceiveSMSMessage
+        */
+       class ReceiveSMSMessage
+       {
+               /**
+                * @access public
+                * @var IncomingSMSMessage
+                */
+               public $m;
+       }
+       
+       /**
+        * IncomingSMSMessage
+        */
+       class IncomingSMSMessage
+       {
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $ReceiverNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $SenderNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Text;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Network;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Address;
+               /**
+                * @access public
+                * @var GSMPosition
+                */
+               public $Position;
+       }
+       
+       /**
+        * GSMPosition
+        */
+       class GSMPosition
+       {
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Longitude;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Lattitude;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Radius;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $County;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Council;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $CouncilNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Place;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $SubPlace;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $ZipCode;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $City;
+       }
+       
+       /**
+        * ReceiveSMSMessageResponse
+        */
+       class ReceiveSMSMessageResponse
+       {
+               /**
+                * @access public
+                * @var ReturnValue
+                */
+               public $ReceiveSMSMessageResult;
+       }
+       
+       /**
+        * ReturnValue
+        */
+       class ReturnValue
+       {
+               /**
+                * @access public
+                * @var sint
+                */
+               public $Code;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Description;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Reference;
+       }
+       
+       /**
+        * ReceiveDeliveryReport
+        */
+       class ReceiveDeliveryReport
+       {
+               /**
+                * @access public
+                * @var DeliveryReport
+                */
+               public $dr;
+       }
+       
+       /**
+        * DeliveryReport
+        */
+       class DeliveryReport
+       {
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $State;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $ReceiverNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $DeliveryTime;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Reference;
+       }
+       
+       /**
+        * ReceiveDeliveryReportResponse
+        */
+       class ReceiveDeliveryReportResponse
+       {
+               /**
+                * @access public
+                * @var ReturnValue
+                */
+               public $ReceiveDeliveryReportResult;
+       }
+       
+       /**
+        * ReceiveMMSMessage
+        */
+       class ReceiveMMSMessage
+       {
+               /**
+                * @access public
+                * @var IncomingMMSMessage
+                */
+               public $m;
+       }
+       
+       /**
+        * IncomingMMSMessage
+        */
+       class IncomingMMSMessage
+       {
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $ReceiverNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $SenderNumber;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Subject;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Network;
+               /**
+                * @access public
+                * @var sstring
+                */
+               public $Address;
+               /**
+                * @access public
+                * @var GSMPosition
+                */
+               public $Position;
+               /**
+                * @access public
+                * @var sbase64Binary
+                */
+               public $Data;
+       }
+       
+       /**
+        * ReceiveMMSMessageResponse
+        */
+       class ReceiveMMSMessageResponse
+       {
+               /**
+                * @access public
+                * @var ReturnValue
+                */
+               public $ReceiveMMSMessageResult;
+       }
+       
+       /**
+        * SMSReceive
+        * @author WSDLInterpreter
+        */
+       class SMSReceive extends SoapClient
+       {
+               /**
+                * Default class map for wsdl=>php
+                * @access private
+                * @var array
+                */
+               private static $classmap = array(
+                       "ReceiveSMSMessage" => "ReceiveSMSMessage",
+                       "IncomingSMSMessage" => "IncomingSMSMessage",
+                       "GSMPosition" => "GSMPosition",
+                       "ReceiveSMSMessageResponse" => 
"ReceiveSMSMessageResponse",
+                       "ReturnValue" => "ReturnValue",
+                       "ReceiveDeliveryReport" => "ReceiveDeliveryReport",
+                       "DeliveryReport" => "DeliveryReport",
+                       "ReceiveDeliveryReportResponse" => 
"ReceiveDeliveryReportResponse",
+                       "ReceiveMMSMessage" => "ReceiveMMSMessage",
+                       "IncomingMMSMessage" => "IncomingMMSMessage",
+                       "ReceiveMMSMessageResponse" => 
"ReceiveMMSMessageResponse",
+               );
+       
+               /**
+                * Constructor using wsdl location and options array
+                * @param string $wsdl WSDL location for this service
+                * @param array $options Options for the SoapClient
+                */
+               public function 
__construct($wsdl="http://sms.pswin.com/SOAP/Receive.asmx?wsdl";, 
$options=array())
+               {
+                       foreach(self::$classmap as $wsdlClassName => 
$phpClassName) {
+                           if(!isset($options['classmap'][$wsdlClassName])) {
+                               $options['classmap'][$wsdlClassName] = 
$phpClassName;
+                           }
+                       }
+                       parent::__construct($wsdl, $options);
+               }
+       
+               /**
+                * Checks if an argument list matches against a valid argument 
type list
+                * @param array $arguments The argument list to check
+                * @param array $validParameters A list of valid argument types
+                * @return boolean true if arguments match against 
validParameters
+                * @throws Exception invalid function signature message
+                */
+               public function _checkArguments($arguments, $validParameters)
+               {
+                       $variables = "";
+                       foreach ($arguments as $arg) {
+                           $type = gettype($arg);
+                           if ($type == "object") {
+                               $type = get_class($arg);
+                           }
+                           $variables .= "(".$type.")";
+                       }
+                       if (!in_array($variables, $validParameters)) {
+                           throw new Exception("Invalid parameter types: 
".str_replace(")(", ", ", $variables));
+                       }
+                       return true;
+               }
+       
+               /**
+                * Service Call: ReceiveSMSMessage
+                * Parameter options:
+                * (ReceiveSMSMessage) parameters
+                * (ReceiveSMSMessage) parameters
+                * @param mixed,... See function description for parameter 
options
+                * @return ReceiveSMSMessageResponse
+                * @throws Exception invalid function signature message
+                */
+               public function ReceiveSMSMessage($mixed = null)
+               {
+                       $validParameters = array(
+                               "(ReceiveSMSMessage)",
+                               "(ReceiveSMSMessage)",
+                       );
+                       $args = func_get_args();
+                       $this->_checkArguments($args, $validParameters);
+                       return $this->__soapCall("ReceiveSMSMessage", $args);
+               }
+       
+       
+               /**
+                * Service Call: ReceiveDeliveryReport
+                * Parameter options:
+                * (ReceiveDeliveryReport) parameters
+                * (ReceiveDeliveryReport) parameters
+                * @param mixed,... See function description for parameter 
options
+                * @return ReceiveDeliveryReportResponse
+                * @throws Exception invalid function signature message
+                */
+               public function ReceiveDeliveryReport($mixed = null)
+               {
+                       $validParameters = array(
+                               "(ReceiveDeliveryReport)",
+                               "(ReceiveDeliveryReport)",
+                       );
+                       $args = func_get_args();
+                       $this->_checkArguments($args, $validParameters);
+                       return $this->__soapCall("ReceiveDeliveryReport", 
$args);
+               }
+       
+       
+               /**
+                * Service Call: ReceiveMMSMessage
+                * Parameter options:
+                * (ReceiveMMSMessage) parameters
+                * (ReceiveMMSMessage) parameters
+                * @param mixed,... See function description for parameter 
options
+                * @return ReceiveMMSMessageResponse
+                * @throws Exception invalid function signature message
+                */
+               public function ReceiveMMSMessage($mixed = null)
+               {
+                       $validParameters = array(
+                               "(ReceiveMMSMessage)",
+                               "(ReceiveMMSMessage)",
+                       );
+                       $args = func_get_args();
+                       $this->_checkArguments($args, $validParameters);
+                       return $this->__soapCall("ReceiveMMSMessage", $args);
+               }
+       }

Modified: trunk/sms/inc/plugin/gateway/pswin/get.php
===================================================================
--- trunk/sms/inc/plugin/gateway/pswin/get.php  2011-06-23 14:32:02 UTC (rev 
7427)
+++ trunk/sms/inc/plugin/gateway/pswin/get.php  2011-06-24 08:45:29 UTC (rev 
7428)
@@ -34,50 +34,35 @@
                }
 
 
-               function check_for_new_mail()
+               function gw_set_incoming_action()
                {
                        if(!isset($this->pswin_param['email_user']) || ! 
$this->pswin_param['email_user'])
                        {
                            throw new Exception('Email user not defined');      
                
                        }
 
-                       $account_id = 
$GLOBALS['phpgw']->accounts->name2id($this->pswin_param['email_user']);
+                               require_once 'SMSReceive.php';
 
-                       $GLOBALS['phpgw_info']['user']['account_id'] = 
$account_id;
-                       $GLOBALS['phpgw']->preferences->account_id = 
$account_id;
-                       $pref = $GLOBALS['phpgw']->preferences->read();
-                       
$GLOBALS['phpgw_info']['user']['preferences']['felamimail'] = 
isset($pref['felamimail']) ? $pref['felamimail'] : '';
+                               $options=array();
+                               $options['soap_version'] = SOAP_1_1;
+                               $options['location'] = 
$this->pswin_param['receive_url'];
+                               $options['uri']         = 
"http://sms.pswin.com/SOAP/SMS.asmx";;
+                               $options['trace']               = 1;
+                               $options['proxy_host']  = 
$this->pswin_param['proxy_host'];
+                               $options['proxy_port']  = 
$this->pswin_param['proxy_port'];
+                               $options['encoding']    = 
'iso-8859-1';//'UTF-8';
 
-                       $boPreferences  = 
CreateObject('felamimail.bopreferences');
-                       $boPreferences->setProfileActive(true,2); //2 for 
selected user
-                       $bofelamimail   = 
CreateObject('felamimail.bofelamimail');
+                               $receive = new SMSReceive('', $options);
 
-                       $connectionStatus = $bofelamimail->openConnection();
-                       $headers = $bofelamimail->getHeaders('INBOX', 1, 
$maxMessages = 15, $sort = 0, $_reverse = 1, $_filter = array('string' => '', 
'type' => 'quick', 'status' => 'unseen'));
+                               $ReceiveSMSMessage = new ReceiveSMSMessage();
+                               
+                               $ReturnValue = 
$receive->ReceiveSMSMessage($ReceiveSMSMessage);
 
-                       $sms = array();
-                       $j = 0;
-                       if (isset($headers['header']) && 
is_array($headers['header']))
-                       {
-                               foreach ($headers['header'] as $header)
-                               {
-                                       if(!$header['seen'])
-                                       {
-                                               $sms[$j]['uid'] = 
$header['uid'];
-                                               $sms[$j]['message'] = 
utf8_encode($header['subject']);
-                                               $bodyParts = 
$bofelamimail->getMessageBody($header['uid']);
-                                               $sms[$j]['message'] .= "\n";
-                                               for($i=0; $i<count($bodyParts); 
$i++ )
-                                               {
-                                                       $sms[$j]['message'] .= 
utf8_encode($bodyParts[$i]['body']) . "\n";
-                                               }
+                               $result = $ReturnValue->ReceiveSMSMessageResult;
 
-                                               $sms[$j]['message'] = 
substr($sms[$j]['message'],0,160);
-                                               $j++;
-                                       }
-                               }
-                       }
 
+                       $sms = array();
+
                        foreach($sms as $entry)
                        {
                                $sms_datetime   = $entry[''];
@@ -96,42 +81,4 @@
                                $bofelamimail->closeConnection();
                        }
                }
-
-
-               function gw_set_incoming_action()
-               {
-                       $this->check_for_new_mail();
-                       
-return;
-                   $handle = @opendir($this->pswin_param[path] . 
"/cache/smsd");
-                   while ($sms_in_file = @readdir($handle))
-                   {
-                               if (preg_match("/^ERR.in/i",$sms_in_file) && 
!preg_match("/^[.]/",$sms_in_file))
-                               {
-                                   $fn = $this->pswin_param[path] . 
"/cache/smsd/$sms_in_file";
-                                   $tobe_deleted = $fn;
-                                   $lines = @file ($fn);
-                                   $sms_datetime = trim($lines[0]);
-                                   $sms_sender = trim($lines[1]);
-                                   $message = "";
-                                   for ($lc=2;$lc<count($lines);$lc++)
-                                   {
-                                       $message .= trim($lines[$lc]);
-                                   }
-                                   $array_target_code = explode(" ",$message);
-                                   $target_code = 
strtoupper(trim($array_target_code[0]));
-                                   $message = $array_target_code[1];
-                                   for ($i=2;$i<count($array_target_code);$i++)
-                                   {
-                                               $message .= " 
".$array_target_code[$i];
-                                   }
-                                   // collected:
-                                   // $sms_datetime, $sms_sender, 
$target_code, $message
-                                   if 
($this->setsmsincomingaction($sms_datetime,$sms_sender,$target_code,$message))
-                                   {
-                                               @unlink($tobe_deleted);
-                                   }
-                               }
-                   }
-               }
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]