1
0

updated the protocol version check

This commit is contained in:
Thomas E. Horner 2012-08-25 09:32:14 +02:00
parent b0887b2f97
commit 06bd5cd878
2 changed files with 16 additions and 5 deletions

View File

@ -77,6 +77,7 @@ class Gallery_Remote_Controller extends Controller {
private function _check_protocol(&$input, &$reply) {
$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=='') {
$reply->send(gallery_remote::PROTO_VER_MISSING);
return false;
@ -85,14 +86,21 @@ class Gallery_Remote_Controller extends Controller {
$reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL);
return false;
}
else if($version<'2') {
else if($version<gallery_remote::GR_PROT_MAJ) {
$reply->send(gallery_remote::PROTO_MAJ_VER_INVAL);
return false;
}
else if($version<'2.3') {
$reply->send(gallery_remote::PROTO_MIN_VER_INVAL);
else if(strpos($version, '.')===false) {
$reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL);
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;
}
@ -357,7 +365,7 @@ class Gallery_Remote_Controller extends Controller {
catch (ORM_Validation_Exception $e) {
$validation = $e->validation;
//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
}
catch (Exception $e) {

View File

@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_remote_Core {
const GR_PROT_MAJ = 2;
const GR_PROT_MIN = 3;
const GR_STAT_SUCCESS = 0;
const PROTO_MAJ_VER_INVAL = 101;
const PROTO_MIN_VER_INVAL= 102;
@ -35,4 +38,4 @@ class gallery_remote_Core {
const CREATE_ALBUM_FAILED = 502;
const MOVE_ALBUM_FAILED = 503;
const ROTATE_IMAGE_FAILED = 504;
}
}