* @revision 03 * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany * @homepage http://oss.tiggerswelt.net/oscar/ * @copyright Copyright © 2009 tiggersWelt.net */ require_once ("oscar/common.php"); require_once ("oscar/snac/helper/tlv.php"); require_once ("oscar/snac/helper/error.php"); require_once ("oscar/snac/icbm/message.php"); require_once ("oscar/snac/icbm/incoming_message.php"); require_once ("oscar/snac/icbm/retriveoffline.php"); require_once ("oscar/snac/icbm/notifycation.php"); /* General information about this family - used for autodetection */ class Oscar_SNAC_ICBM extends Oscar_SNAC { const SNAC_FAMILY = 0x0004; const SNAC_VERSION = 0x0001; const SNAC_TOOLID = 0x0110; const SNAC_TOOL_VERSION = 0x164F; } class Oscar_SNAC_ICBM_Error extends Oscar_SNAC_Helper_Error { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0001; // {{{ getSubcode /** * Retrive the description of an error-subcode * * @param int $Code * * @access protected * @return string */ protected function getSubcode ($Code) { switch ($Code) { case 1: return "Remote IM Offline"; case 2: return "Denied by parental controls"; case 3: return "Legal text required to send SMS"; case 4: return "Disclaimer required to send SMS"; case 5: return "SMS-Country not allowed"; case 8: return "Unknown SMS-Country"; case 9: return "Can't initiate IM"; case 10: return "IM-Usage limited"; case 11: return "IM-Usage limit reached"; case 12: return "IM-Usage limit reached for today"; case 13: return "IM-Usage limit reached for this month"; case 14: return "Offline-messages unsupported"; case 15: return "Storage-limit exceeded"; } } // }}} } class Oscar_SNAC_ICBM_Set extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0002; /* Channels */ const CHANNEL_DEFAULT = 0x0000; // Update all channels const CHANNEL_IM = 0x0001; const CHANNEL_RENDEZVOUS = 0x0002; /* Flags */ const CHANNEL_MSGS_ALLOWED = 0x00000001; const MISSED_CALLS_ENABLED = 0x00000002; const EVENTS_ALLOWED = 0x00000008; const SMS_SUPPORTED = 0x00000010; const OFFLINE_MSGS_ALLOWED = 0x00000100; /* Settings in this structure */ public $Channel = Oscar_SNAC_ICBM_Set::CHANNEL_IM; public $MessageFlags = 9; // CHANNEL_MSGS_ALLOWED | EVENTS_ALLOWED public $MessageSize = 8000; public $SenderWarningLevel = 999; public $ReceiverWarningLevel = 999; public $MinInterval = 0; // {{{ parse /** * Parse the response from server * * @access public * @return void */ public function parse () { $this->Channel = Oscar_Common::str2int16 ($this->Data, 0, true); $this->MessageFlags = Oscar_Common::str2int32 ($this->Data, 0, true); $this->MessageSize = Oscar_Common::str2int16 ($this->Data, 0, true); $this->SenderWarningLevel = Oscar_Common::str2int16 ($this->Data, 0, true); $this->ReceiverWarningLevel = Oscar_Common::str2int16 ($this->Data, 0, true); $this->MinInterval = Oscar_Common::str2int32 ($this->Data, 0, true); } // }}} // {{{ generate /** * Prepare packet for submission * * @access public * @return string */ public function generate () { $this->Data = Oscar_Common::int16tostr ($this->Channel) . Oscar_Common::int32tostr ($this->MessageFlags) . Oscar_Common::int16tostr ($this->MessageSize) . Oscar_Common::int16tostr ($this->SenderWarningLevel) . Oscar_Common::int16tostr ($this->ReceiverWarningLevel) . Oscar_Common::int32tostr ($this->MinInterval); for ($i = 0; $i < strlen ($this->Data); $i++) print dechex (ord ($this->Data [$i])) . " "; print "\n"; return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Reset extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0003; /* Which Channel to reset */ public $Channel = Oscar_SNAC_ICBM_Set::CHANNEL_DEFAULT; // {{{ parse /** * Parse the response from server * * @access public * @return void */ public function parse () { $this->Channel = Oscar_Common::str2int16 ($this->Data, 0, true); } // }}} // {{{ generate /** * Prepare packet for submission * * @access public * @return string */ public function gengerate () { if ($this->Channel == Oscar_SNAC_ICBM_Set::CHANEL_DEFAULT) $this->Data = ""; else $this->Data = Oscar_Common::int16tostr ($this->Channel); return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Request extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0004; } class Oscar_SNAC_ICBM_Response extends Oscar_SNAC_ICBM_Set { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0005; public $maxSlots = 0x0000; public $icbmFlags = 0x00000000; public $maxIncomingICBMLength = 0x0000; public $maxSourceEvil = 0x0000; public $maxDestinationEvil = 0x0000; public $minInterval = 0x000000; // {{{ parse /** * Parse the response from server * * @access public * @return void */ public function parse () { $this->maxSlots = Oscar_Common::str2int16 ($this->Data, 0, true); $this->icbmFlags = Oscar_Common::str2int32 ($this->Data, 0, true); $this->maxIncomingICBMLength = Oscar_Common::str2int16 ($this->Data, 0, true); $this->maxSourceEvil = Oscar_Common::str2int16 ($this->Data, 0, true); $this->maxDestinationEvil = Oscar_Common::str2int16 ($this->Data, 0, true); $this->minInterval = Oscar_Common::str2int32 ($this->Data, 0, true); } // }}} // {{{ generate /** * Prepare packet for submission * * @access public * @return string */ public function gengerate () { $this->Data = Oscar_Common::int16tostr ($this->maxSlots) . Oscar_Common::int32tostr ($this->icbmFlags) . Oscar_Common::int16tostr ($this->maxIncomingICBMLength) . Oscar_Common::int16tostr ($this->maxSourceEvil) . Oscar_Common::int16tostr ($this->maxDestinationEvil) . Oscar_Common::int32tostr ($this->minInterval); return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Warning extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0008; /* Warning-Types */ const ANONYMOUS = 0x0001; const NON_ANONYMOUS = 0x0000; public $SendAs = Oscar_SNAC_ICBM_Warning::ANONYMOUS; public $Username = ""; // {{{ parse /** * @access public * @return void */ public function parse () { $this->SendAs = Oscar_Common::str2int16 ($this->Data, 0, true); $this->Username = Oscar_Common::string08 ($this->Data, 0, true); } // }}} // {{{ generate /** * @access public * @return string */ public function generate () { $this->Data = Oscar_Common::int16tostr ($this->SendAs) . Oscar_Common::toString08 ($this->Username); return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Warning_ACK extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0009; public $LevelGain = 0; public $NewLevel = 0; // {{{ parse /** * @access public * @return void */ public function parse () { $this->LevelGain = Oscar_Common::str2int16 ($this->Data, 0, true); $this->NewLevel = Oscar_Common::str2int16 ($this->Data, 0, true); } // }}} // {{{ generate /** * @access public * @return string */ public function generate () { $this->Data = Oscar_Common::int16tostr ($this->LevelGain) . Oscar_Common::int16tostr ($this->NewLevel); return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Message_ACK extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x000B; const REASON_CHANNEL = 0x03; public $Cookie = ""; public $Channel = 0x00; public $Username = ""; public $Reason = 0x00; /* This is for Channel 1 Messages */ public $Charset_Major = 0x0; public $Charset_Minor = 0x0; public $Message = ""; /* Channel 2 Hack */ public $Channel2 = ""; # TODO: Add support for Channel 2 (RTF/Rendevouz) Messages // {{{ parse /** * @access public * @return void * @todo Handle other channel-types */ public function parse () { // Strip Cookie from data $this->Cookie = substr ($this->Data, 0, 8); $this->Data = substr ($this->Data, 8); // Get the channel $this->Channel = Oscar_Common::str2int16 ($this->Data, 0, true); // Get and trim username $this->Username = Oscar_Common::string08 ($this->Data, 0, true); // Get the reason $this->Reason = Oscar_Common::str2int16 ($this->Data, 0, true); // Handle additional Information for Channel 1 if ($this->Channel == 0x0001) { // Remove unused stuff # TODO: Maybe use this stuff?! $Length = Oscar_Common::str2int16 ($this->Data, 2); $this->Data = substr ($this->Data, $Length + 6); // Get length of usable content $Length = Oscar_Common::str2int16 ($this->Data, 2, true); $this->Charset_Major = OSCAR_Common::str2int16 ($this->Data, 0, true); $this->Charset_Minor = OSCAR_Common::str2int16 ($this->Data, 0, true); $this->Message = substr ($this->Data, 0, $Length - 4); } else $this->Channel2 = $this->Data; } // }}} // {{{ generate /** * @access public * @return string */ public function generate () { $this->Data = $this->Cookie . Oscar_Common::int16tostr ($this->Channel) . Oscar_Common::int8tostr (strlen ($this->Username)) . $this->Username . Oscar_Common::int16tostr ($this->Reason); // Append channel 1 information if ($this->Channel == 0x0001) $this->Data .= Oscar_Common::int8tostr (0x05) . // required capabilities Oscar_Common::int8tostr (0x01) . Oscar_Common::int16tostr (0x02) . Oscar_Common::int16tostr (0x0106) . Oscar_Common::int8tostr (0x01) . // Message itself Oscar_Common::int8tostr (0x01) . Oscar_Common::int16tostr (strlen ($this->Message) + 4) . Oscar_Common::int16tostr ($this->Charset_Major) . Oscar_Common::int16tostr ($this->Charset_Minor) . $this->Message; else $this->Data .= $this->Channel2; return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Message_Server_ACK extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x000C; public $Cookie = ""; public $Channel = 0x0001; public $Username = ""; // {{{ parse /** * @access public * @return void */ public function parse () { // Get and trim the cookie $this->Cookie = substr ($this->Data, 0, 8); $this->Data = substr ($this->Data, 8); // Get the channel $this->Channel = Oscar_Common::str2int16 ($this->Data, 0, true); // Get and trim username $this->Username = Oscar_Common::string08 ($this->Data, 0, true); // OSCAR defines an empty TLV-Set here that may be used in future parent::parse (); } // }}} // {{{ generate /** * @access public * @return string */ public function generate () { $this->Data = $this->Cookie . Oscar_Common::int16tostr ($this->Channel) . Oscar_Common::toString08 ($this->Username); return parent::generate (); } // }}} } class Oscar_SNAC_ICBM_Offline_Messages_ACK extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0017; } ?>