Beispiel #1
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     MMapManager::startSession();
     //check if the session has expired
     MMapManager::checkSessionExpiration();
     $return = null;
     $dataManager = DataManager::getInstance();
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     $return = array();
     foreach ($params as $call) {
         $call[2] = json_encode($call[2]);
         $_POST['params'] = $call[2];
         $request->setPost('params', $call[2]);
         $_GET['message'] = $call[1];
         $request->setGET('message', $call[1]);
         $_GET['checknum'] = $call[0];
         $request->setGET('checknum', $call[0]);
         MMapMsg::getInstance()->processRequest($request, $response);
         MMapManager::getInstance()->doResponse($response);
         $response->clear();
         $content = ob_get_contents();
         ob_clean();
         $return[] = $content;
     }
     $response->setBodyRenderer(new DataManagerBodyRenderer($return));
 }
Beispiel #2
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     MMapManager::startSession();
     //check if the session has expired
     MMapManager::checkSessionExpiration();
     $return = null;
     $dataManager = DataManager::getInstance();
     // restore current process using checknum
     $myProcManager = ProcManager::getInstance();
     $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum'));
     $myProcManager->setCurrentProcess($myProcess);
     $appDesc = new EyeMobileApplicationDescriptor($myProcess->getName());
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     $methodName = $request->getGET('message');
     // calling an ExecModule
     if (strpos($methodName, '__') === 0) {
         $moduleName = explode('_', substr($methodName, 2));
         $methodName = $moduleName[1];
         //ex: "FileChooser"
         $moduleName = $moduleName[0];
         //ex: "browsePath"
         $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params));
     } else {
         if ($appDesc->isJavascriptOnlyApplication()) {
             $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params);
         } else {
             if (method_exists($appDesc->getApplicationClassName(), $methodName)) {
                 $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
             } else {
                 //If no function is present, call the NOT mobile function
                 MMapMsg::getInstance()->processRequest($request, $response);
                 return;
             }
             //				try {
             //					$return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
             //				} catch (Exception $e) {
             //					//If no function is present, call the NOT mobile function
             //					MMapMsg::getInstance()->processRequest($request, $response);
             //					return;
             //				}
         }
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
Beispiel #3
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     MMapManager::startSession();
     //check if the session has expired
     MMapManager::checkSessionExpiration();
     $return = null;
     $dataManager = DataManager::getInstance();
     // restore current process using checknum
     $myProcManager = ProcManager::getInstance();
     $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum'));
     $myProcManager->setCurrentProcess($myProcess);
     $appDesc = new EyeosApplicationDescriptor($myProcess->getName());
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     $methodName = $request->getGET('message');
     // calling an ExecModule
     if (strpos($methodName, '__') === 0) {
         $moduleName = explode('_', substr($methodName, 2));
         $methodName = $moduleName[1];
         //ex: "FileChooser"
         $moduleName = $moduleName[0];
         //ex: "browsePath"
         $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params));
     } else {
         if ($appDesc->isJavascriptOnlyApplication()) {
             $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params);
         } else {
             $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
         }
     }
     //try to force mime type. If there is a previous mime type defined at application level
     //this have no effect
     if (!headers_sent()) {
         $response->getHeaders()->append('Content-type:text/plain');
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
Beispiel #4
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     $return = null;
     $dataManager = DataManager::getInstance();
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     //login in the system and get a valid login context
     $subject = new Subject();
     $loginContext = new LoginContext('eyeos-login', $subject);
     $cred = new EyeosPasswordCredential();
     $cred->setUsername($_REQUEST['username']);
     $cred->setPassword($_REQUEST['password'], true);
     $subject->getPrivateCredentials()->append($cred);
     $loginContext->login();
     //now create fake process called api
     Kernel::enterSystemMode();
     $appProcess = new Process('api');
     $appProcess->setPid('31337');
     $mem = MemoryManager::getInstance();
     $processTable = $mem->get('processTable', array());
     $processTable[31337] = $appProcess;
     $mem->set('processTable', $processTable);
     $appProcess->setLoginContext($loginContext);
     ProcManager::getInstance()->setCurrentProcess($appProcess);
     kernel::exitSystemMode();
     $return = call_user_func_array(array('EyeosApplicationExecutable', '__callModule'), array($request->getPOST('module'), $request->getPOST('name'), $params));
     //try to force mime type. If there is a previous mime type defined at application level
     //this have no effect
     if (!headers_sent()) {
         $response->getHeaders()->append('Content-type:text/plain');
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
Beispiel #5
0
 public function getRenderedBody()
 {
     return DataManager::getInstance()->doOutput($this->getBodyData());
 }
Beispiel #6
0
 public function initFromRequest(MMapRequest $request)
 {
     $this->setRequest($request);
     $get = $request->getGET();
     $this->setApplicationDescriptor(new EyeMobileApplicationDescriptor($get['getApplication']));
     if (isset($get['includeBody'])) {
         $this->setIncludeBody($get['includeBody']);
     }
     if (isset($get['args'])) {
         $args = DataManager::getInstance()->doInput($get['args']);
         if (is_array($args)) {
             $this->setArgs(new ArrayList($args));
         } else {
             Logger::getLogger('system.services.MMap.AppDroidExecutionContext')->warn('Argument in URL is not an array, ignoring. (Given value: ' . $args . ')');
         }
     }
 }