diff --git a/app/assets/js/movim_rpc.js b/app/assets/js/movim_rpc.js index 950bb9545..26b9fbcd0 100644 --- a/app/assets/js/movim_rpc.js +++ b/app/assets/js/movim_rpc.js @@ -101,11 +101,13 @@ function MovimRPC() for(h = 0; h < funcalls.length; h++) { var funcall = funcalls[h]; - try { - window[funcall.func](funcall.params); - } - catch(err) { - console.log("Error caught: " + err.toString() + " - " +funcall.func); + if(funcall.func) { + try { + window[funcall.func](funcall.params); + } + catch(err) { + console.log("Error caught: " + err.toString() + " - " +funcall.func); + } } } } diff --git a/app/models/contact/Contact.php b/app/models/contact/Contact.php index ae313e817..e44efb7e9 100644 --- a/app/models/contact/Contact.php +++ b/app/models/contact/Contact.php @@ -177,14 +177,14 @@ class Contact extends ModlModel { if($size == 'email') { $str = BASE_URI.'cache/'.strtolower($this->jid).'_email.jpg'; } else { - $jid = strtolower($jid); - if($jid != false) { + $jid = strtolower($jid); + if($jid != false && file_exists(CACHE_PATH.$jid.'_'.$size.'.jpg')) { $str = BASE_URI.'cache/'.strtolower($jid).'_'.$size.'.jpg'; } elseif( isset($this->phototype) && isset($this->photobin) - && $this->phototype != '' - && $this->photobin != '' + && (string)$this->phototype != '' + && (string)$this->photobin != '' ) { $str = BASE_URI.'cache/'.strtolower($this->jid).'_'.$size.'.jpg'; } else { diff --git a/app/widgets/Connection/Connection.php b/app/widgets/Connection/Connection.php index 47e589801..6748da507 100644 --- a/app/widgets/Connection/Connection.php +++ b/app/widgets/Connection/Connection.php @@ -31,8 +31,6 @@ class Connection extends WidgetBase if($value >= 10) { $value = floor(($value-10)/10); - RPC::call('Session.rollback'); - if($value == 0) RPC::call('movim_fill', 'countdown', ''); else { diff --git a/app/widgets/Visio/visio.css b/app/widgets/Visio/visio.css index 53c0a3716..7a7bb98ba 100644 --- a/app/widgets/Visio/visio.css +++ b/app/widgets/Visio/visio.css @@ -26,9 +26,6 @@ body { } #visio #camera-stream { - /*display: block; - width: auto; - height: 100%;*/ width: 100%; } @@ -42,165 +39,3 @@ body { #visio #log div { margin-bottom: 1em; } -/*body { - margin: 0px; - background-color: #333; - font-family: sans-serif; -} - -#connection { - width: 100%; - height: 100%; - position: absolute; - top: 0px; - left: 0px; - background-color: rgba(0, 0, 0, 0.6); - display: none; - color: white; - font-size: 1.5em; - text-align: center; - line-height: 5em; -} - -#chatpop { - height: 100%; - width: 100%; - position: fixed; - top: 0px; - left: 0px; -} - -#chatpop #chatpoplist label { - display: block; -} - -#chatpop #chatpoplist li input[type=radio] { - display: none; -} - -#chatpop #chatpoplist li input[type=radio]:checked ~ .content { - display: block; -} - -#chatpop #chatpoplist input[type=radio]:checked ~ label { - background-color: #111; -} - -#chatpop #chatpoplist { - width: 25%; - height: 100%; - list-style-type: none; - margin: 0px; - overflow-y: auto; - display: block; - padding: 0px; -} - -#chatpop #chatpoplist li { - margin: 0px; - padding: 0px; -} - -#chatpop #chatpoplist li .tab { - white-space: nowrap; - width: auto; - overflow: hidden; - color: #BBB; - line-height: 30px; - font-size: 13px; - text-overflow: ellipsis; -} - -#chatpop #chatpoplist li:hover .tab { - background-color: #222; - cursor: pointer; -} - -#chatpop #chatpoplist li .tab img.avatar { - float: left; - margin-right: 5px; - width: 30px; -} - -#chatpop #chatpoplist li .content { - position: fixed; - top: 0px; - right: 0px; - height: 90%; - width: 75%; - display: none; - background-color: white; - overflow-y: auto; - box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); -} - -#chatpop #chatpoplist li .content .text { - position: fixed; - bottom: 0px; - right: 0px; - width: 75%; - background-color: red; - min-height: 10%; - border-top: 1px solid #333; - background-color: white; -} - -#chatpop #chatpoplist li .content .text textarea { - width: 100%; - margin: 0px; - padding: 0px; - border: 0px; - height: auto; - background-color: white; - resize: none; -} - -#chatpop #chatpoplist li .content .messages { - font-size: 13px; -} - -#chatpop #chatpoplist li .content .messages .message { - margin: 10px; - margin-right: 30px; - background-color: #FFE8CC; - padding: 5px; - min-height: 25px; -} - -#chatpop #chatpoplist li .content .messages .message.me { - margin-left: 30px; - margin-right: 10px; - background-color: #FFFFCC; -} - -#chatpop #chatpoplist li .content .messages .message .date { - float: right; - color: #888; - font-size: 11px; - padding-left: 10px; -} - -#chatpop #chatpoplist li .content .messages .message.presence { - background-color: transparent; - font-weight: bold; - min-height: 0px; -} - -#chatpop #chatpoplist span.chatbutton { - width: 28px; - height: 28px; - background-repeat: no-repeat; - background-position: center center; - position: fixed; - bottom: 0px; - left: 0px; -} - -#chatpop #chatpoplist span.chatbutton:hover { - cursor: pointer; -} - -#chatpop #chatpoplist li span.chatbutton.cross { - background-image: url(img/cross.png); -} -*/ diff --git a/app/widgets/Visio/visio.js b/app/widgets/Visio/visio.js index 73b72a04f..377b758fa 100644 --- a/app/widgets/Visio/visio.js +++ b/app/widgets/Visio/visio.js @@ -23,29 +23,6 @@ window.onunload = function() { //self.opener.Roster_ajaxToggleChat(); }; -/*function scrollAllTalks() { - var mes = document.querySelectorAll('.content'); - for (var i=0; i"]); + }, + + /* + * @brief Call a function in the main window + * @param Array, array[0] is the name of the function, then the params + */ + call: function(args) { + if( self.opener && !self.opener.closed ) { + // The popup is open so call it + var func = args[0]; + args.shift(); + var params = args; + self.opener[func].apply(null, params); + } } } diff --git a/app/widgets/Visio/webrtc.js b/app/widgets/Visio/webrtc.js index 2dc0f2eab..087d8a093 100644 --- a/app/widgets/Visio/webrtc.js +++ b/app/widgets/Visio/webrtc.js @@ -49,7 +49,9 @@ function onOfferCreated(description) { function sendMessage(offer) { var msgString = JSON.stringify(offer); - Visio.log('C->S: ' + msgString); + //Visio.log('C->S: ' + msgString); + Visio.log('Send the proposal.'); + Visio.call(['VisioExt_ajaxSendProposal', msgString]); } function onSetSessionDescriptionSuccess() { diff --git a/app/widgets/VisioExt/VisioExt.php b/app/widgets/VisioExt/VisioExt.php index e310be526..f3307a36f 100644 --- a/app/widgets/VisioExt/VisioExt.php +++ b/app/widgets/VisioExt/VisioExt.php @@ -26,6 +26,13 @@ class VisioExt extends WidgetBase $this->addjs('visioext.js'); } + function ajaxSendProposal($proposal) { + $p = json_decode($proposal); + $stj = new SDPtoJingle($p->sdp, $this->user->getLogin()); + \movim_log(\moxl\cleanXML($stj->generate())); + + } + function build() { } diff --git a/bootstrap.php b/bootstrap.php index f493c1a86..ca38a5e5f 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -177,6 +177,9 @@ class Bootstrap { private function loadCommonLibraries() { // XMPPtoForm lib require_once(LIB_PATH . "XMPPtoForm.php"); + + // SDPtoJingle lib + require_once(LIB_PATH . "SDPtoJingle.php"); // Markdown lib require_once(LIB_PATH . "Markdown.php"); diff --git a/lib/SDPtoJingle.php b/lib/SDPtoJingle.php new file mode 100644 index 000000000..73650fda5 --- /dev/null +++ b/lib/SDPtoJingle.php @@ -0,0 +1,102 @@ +sdp = $sdp; + $this->jingle = new SimpleXMLElement(''); + $this->jingle->addAttribute('xmlns', 'urn:xmpp:jingle:1'); + $this->jingle->addAttribute('action','session-initiate'); + $this->jingle->addAttribute('initiator',$jid); + } + + function generate() { + $arr = explode("\r", str_replace("\n", "", $this->sdp)); + + $m = false; + + foreach($arr as $l) { + list($key, $line) = explode('=', $l); + switch($key) { + case 'm': + $expl = explode(' ', $line); + $content = $this->jingle->addChild('content'); + $content->addAttribute('creator', 'initiator'); + $content->addAttribute('name', $expl[0]); + + // The description node + $description = $content->addChild('description'); + $description->addAttribute('xmlns', "urn:xmpp:jingle:apps:rtp:11"); + + // The transport node + $transport = $content->addChild('transport'); + $transport->addAttribute('xmlns', "xmlns='urn:xmpp:jingle:transports:ice-udp:1"); + $transport->addAttribute('pwd', $this->icepwd); + $transport->addAttribute('ufrag', $this->iceufrag); + $m = true; + break; + case 'a': + if($m) { + $expl = explode(' ', $line); + // We have a new candidate ! + if(count($expl) > 5) { + // We explode the candidate:0 or :1 + $candidexpl = explode(':', $expl[0]); + + $candidate = $transport->addChild('candidate'); + + $candidate->addAttribute('componenent', $candidexpl[1]); + $candidate->addAttribute('foundation', $expl[1]); + $candidate->addAttribute('generation', 0); + $candidate->addAttribute('protocol', $expl[2]); + $candidate->addAttribute('priority', $expl[3]); + $candidate->addAttribute('ip', $expl[4]); + $candidate->addAttribute('port', $expl[5]); + $candidate->addAttribute('type', $expl[7]); + $candidate->addAttribute('id', \generateKey(10)); + + if(isset($expl[9])) + $candidate->addAttribute('rel-addr', $expl[9]); + if(isset($expl[11])) + $candidate->addAttribute('rel-port', $expl[11]); + } + + $expl = explode(':', $exp[1]); + switch($expl[0]) { + // We have a new codec ! + case 'rtpmap': + $rtpmap = explode(' ', $expl[1]); + list($codec, $freq) = explode('/',$rtpmap[1]); + + $payloadtype = $description->addChild('payload-type'); + $payloadtype->addAttribute('id', $rtpmap[0]); + $payloadtype->addAttribute('name', $codec); + $payloadtype->addAttribute('clockrate', $freq); + break; + } + } else { + $expl = explode(':', $line); + // Some ICE ids + switch($expl[0]) { + case 'ice-pwd': + $this->icepwd = $expl[1]; + break; + case 'ice-ufrag': + $this->iceufrag = $expl[1]; + break; + + } + } + break; + } + + } + + return $this->jingle->asXML(); + } +} diff --git a/system/Sessionx.php b/system/Sessionx.php index aa4588ab0..fea54ad96 100644 --- a/system/Sessionx.php +++ b/system/Sessionx.php @@ -56,15 +56,7 @@ class Sessionx { protected function regenerate() { // Generating the session cookie's hash. - $hash_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $hash = ""; - - for($i = 0; $i < 64; $i++) { - $r = mt_rand(0, strlen($hash_chars) - 1); - $hash.= $hash_chars[$r]; - } - - self::$_sessionid = $hash; + self::$_sessionid = \generateKey(64); setcookie('MOVIM_SESSION_ID', self::$_sessionid, time() + $this->_max_age); } diff --git a/system/Utils.php b/system/Utils.php index 2c895e30d..dacbf36df 100644 --- a/system/Utils.php +++ b/system/Utils.php @@ -690,10 +690,10 @@ function generateUUID($string = false) { function movim_log($log) { \system\Logs\Logger::log($log); - /* openlog('movim', LOG_NDELAY, LOG_USER); - $errlines = explode("\n",$log); - foreach ($errlines as $txt) { syslog(LOG_DEBUG, $txt); } - closelog();*/ + openlog('movim', LOG_NDELAY, LOG_USER); + $errlines = explode("\n",$log); + foreach ($errlines as $txt) { syslog(LOG_DEBUG, $txt); } + closelog(); } /** @@ -727,4 +727,21 @@ function getFlagTitle($color){ } return $title; } + +/* + * @desc Generate a simple random key + * @params The size of the key + */ +function generateKey($size) { + // Generating the session cookie's hash. + $hash_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $hash = ""; + + for($i = 0; $i < $size; $i++) { + $r = mt_rand(0, strlen($hash_chars) - 1); + $hash.= $hash_chars[$r]; + } + + return $hash; +} ?> diff --git a/themes/movim/css/forms.css b/themes/movim/css/forms.css index 833909dab..2bedcdb9b 100644 --- a/themes/movim/css/forms.css +++ b/themes/movim/css/forms.css @@ -272,6 +272,7 @@ legend { font-weight: bold; font-size: 0.8em; line-height: 2.4em; + font-family: helvetica, sans-serif; text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.3); diff --git a/themes/movim/css/style.css b/themes/movim/css/style.css index fa09bc6f0..4a5376500 100644 --- a/themes/movim/css/style.css +++ b/themes/movim/css/style.css @@ -312,6 +312,7 @@ ul.clean li { #left a:link, #left a:visited { color: #94A6B0; + text-decoration: none; } #left ul { diff --git a/themes/movim/favicon.xcf b/themes/movim/favicon.xcf new file mode 100644 index 000000000..6c4c4779b Binary files /dev/null and b/themes/movim/favicon.xcf differ diff --git a/themes/movim/img/favicon.ico b/themes/movim/img/favicon.ico index 7477a66c4..01455f891 100644 Binary files a/themes/movim/img/favicon.ico and b/themes/movim/img/favicon.ico differ