updated the protocol version check
This commit is contained in:
parent
b0887b2f97
commit
06bd5cd878
@ -77,6 +77,7 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
|
|
||||||
private function _check_protocol(&$input, &$reply) {
|
private function _check_protocol(&$input, &$reply) {
|
||||||
$version = trim($input->post('protocol_version'));
|
$version = trim($input->post('protocol_version'));
|
||||||
|
$reply->set('status_text', 'Minimum protocol version required: '.gallery_remote::GR_PROT_MAJ.'.'.gallery_remote::GR_PROT_MIN.' - your client\'s protocol version: '.$version);
|
||||||
if($version=='') {
|
if($version=='') {
|
||||||
$reply->send(gallery_remote::PROTO_VER_MISSING);
|
$reply->send(gallery_remote::PROTO_VER_MISSING);
|
||||||
return false;
|
return false;
|
||||||
@ -85,14 +86,21 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
$reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL);
|
$reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if($version<'2') {
|
else if($version<gallery_remote::GR_PROT_MAJ) {
|
||||||
$reply->send(gallery_remote::PROTO_MAJ_VER_INVAL);
|
$reply->send(gallery_remote::PROTO_MAJ_VER_INVAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if($version<'2.3') {
|
else if(strpos($version, '.')===false) {
|
||||||
$reply->send(gallery_remote::PROTO_MIN_VER_INVAL);
|
$reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$ver = explode('.', $version);
|
||||||
|
if($ver[0]==gallery_remote::GR_PROT_MAJ && $ver[1]<gallery_remote::GR_PROT_MIN) {
|
||||||
|
$reply->send(gallery_remote::PROTO_MIN_VER_INVAL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -357,7 +365,7 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
catch (ORM_Validation_Exception $e) {
|
catch (ORM_Validation_Exception $e) {
|
||||||
$validation = $e->validation;
|
$validation = $e->validation;
|
||||||
//print_r($validation->errors()); exit;
|
//print_r($validation->errors()); exit;
|
||||||
$reply->set('status_text', t('Failed to save item %item: %errors', array('item' => $filename, 'errors' => str_replace("\n", ' ', print_r($validation->errors(),true))) ));
|
$reply->set('status_text', t('Failed to validate item %item: %errors', array('item' => $filename, 'errors' => str_replace("\n", ' ', print_r($validation->errors(),true))) ));
|
||||||
$reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait
|
$reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
class gallery_remote_Core {
|
class gallery_remote_Core {
|
||||||
|
const GR_PROT_MAJ = 2;
|
||||||
|
const GR_PROT_MIN = 3;
|
||||||
|
|
||||||
const GR_STAT_SUCCESS = 0;
|
const GR_STAT_SUCCESS = 0;
|
||||||
const PROTO_MAJ_VER_INVAL = 101;
|
const PROTO_MAJ_VER_INVAL = 101;
|
||||||
const PROTO_MIN_VER_INVAL= 102;
|
const PROTO_MIN_VER_INVAL= 102;
|
||||||
@ -35,4 +38,4 @@ class gallery_remote_Core {
|
|||||||
const CREATE_ALBUM_FAILED = 502;
|
const CREATE_ALBUM_FAILED = 502;
|
||||||
const MOVE_ALBUM_FAILED = 503;
|
const MOVE_ALBUM_FAILED = 503;
|
||||||
const ROTATE_IMAGE_FAILED = 504;
|
const ROTATE_IMAGE_FAILED = 504;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user