function ajaxShowPosition($pos) { list($lat, $lon) = explode(',', $pos); $pos = json_decode(file_get_contents('http://nominatim.openstreetmap.org/reverse?format=json&lat=' . $lat . '&lon=' . $lon . '&zoom=27&addressdetails=1')); RPC::call('movim_fill', 'postpublishlocation', (string) $pos->display_name); RPC::commit(); }
function ajaxAddChatroom() { $r = new Rooms(); $r->ajaxChatroomAdd(array('jid' => '*****@*****.**', 'name' => 'Movim Chatroom', 'nick' => false, 'autojoin' => 0)); $r->ajaxJoin('*****@*****.**'); RPC::call('MovimUtils.redirect', $this->route('chat')); }
function onLocationPublishError($error) { Notification::append(null, $error); RPC::call('movim_delete', 'mapdiv'); RPC::call('movim_delete', 'mapdata'); RPC::commit(); }
function onConfigured($package) { $node = $package->content; switch ($node) { case 'storage:bookmarks': $notif = $this->__('init.bookmark'); break; case 'urn:xmpp:vcard4': $notif = $this->__('init.vcard4'); break; case 'urn:xmpp:avatar:data': $notif = $this->__('init.avatar'); break; case 'http://jabber.org/protocol/geoloc': $notif = $this->__('init.location'); break; case 'urn:xmpp:pubsub:subscription': $notif = $this->__('init.subscriptions'); break; case 'urn:xmpp:microblog:0': $notif = $this->__('init.microblog'); break; } RPC::call('Init.setNode', $node); Notification::append(null, $notif); }
public function __construct(MappedClassLoader $mappedClassLoader, SerializationPolicyProvider $serializationPolicyProvider) { $this->mappedClassLoader = $mappedClassLoader; $this->serializationPolicyProvider = $serializationPolicyProvider; $this->serializationPolicy = RPC::getDefaultSerializationPolicy(); $this->logger = LoggerManager::getLogger('gwtphp.rpc.impl.ServerSerializationStreamReader'); }
static function fill($html = '', $scroll = false) { RPC::call('movim_fill', 'dialog', $html); if ($scroll) { RPC::call('Dialog.addScroll'); } }
function onMyAvatarError() { $cd = new \modl\ContactDAO(); $me = $cd->get(); $html = $this->prepareForm($me); RPC::call('movim_fill', 'avatar_form', $html); Notification::append(null, $this->__('avatar.not_updated')); }
function ajaxUnregister() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $config->unregister = !$config->unregister; $cd->set($config); RPC::call('MovimUtils.reloadThis'); RPC::commit(); }
function onConfig($package) { $data = (array) $package->content; $this->user->setConfig($data); $html = $this->prepareConfigForm(); RPC::call('movim_fill', 'config_widget', $html); RPC::call('Config.load'); Notification::append(null, $this->__('config.updated')); }
function ajaxGet($type = 'all', $server = null, $node = null, $page = 0) { $html = $this->prepareList($type, $server, $node, $page); if ($page > 0) { RPC::call('movim_append', 'menu_wrapper', $html); } else { RPC::call('movim_fill', 'menu_widget', $html); RPC::call('movim_posts_unread', 0); } RPC::call('Menu.refresh'); }
function onNotifs($from = false) { $html = $this->prepareNotifs(); RPC::call('MovimTpl.fill', '#notifs_widget', $html); RPC::call('Notifs.refresh'); if (is_string($from)) { $cd = new \Modl\ContactDAO(); $contact = $cd->get($from); $avatar = $contact->getPhoto('s'); if ($avatar == false) { $avatar = null; } Notification::append('invite|' . $from, $contact->getTrueName(), $this->__('notifs.wants_to_talk', $contact->getTrueName()), $avatar, 4); } }
public static function exchange($amount, $from = 'NZD', $to = 'CNY') { $url = "http://www.google.com/finance/converter?a={$amount}&from={$from}&to={$to}"; if ($data = RPC::fetch($url)) { $dom = new \DOMDocument(); @$dom->loadHTML($data); $finder = new \DomXPath($dom); $classname = "bld"; $nodes = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' {$classname} ')]"); $node = $nodes->item(0)->nodeValue; $amount = str_replace(' CNY', '', $node); return number_format($amount, 2, '.', ','); } return false; }
function onSessionInitiate($jingle) { $jts = new \JingletoSDP($jingle); $sdp = $jts->generate(); $cd = new \Modl\ContactDAO(); $contact = $cd->get(cleanJid((string) $jingle->attributes()->initiator)); if (!isset($contact)) { $contact = new Modl\Contact(); } if ($sdp) { RPC::call('movim_desktop_notification', $contact->getTrueName(), $this->__('visio.calling'), $contact->getPhoto('m')); RPC::call('remoteSetJid', (string) $jingle->attributes()->initiator); RPC::call('remoteCall', 'onOffer', $sdp); RPC::commit(); } }
function ajaxChangePassword($form) { $validate = Validator::string()->length(6, 40); $p1 = $form->password->value; $p2 = $form->password_confirmation->value; if ($validate->validate($p1) && $validate->validate($p2)) { if ($p1 == $p2) { $arr = explodeJid($this->user->getLogin()); $cp = new ChangePassword(); $cp->setTo($arr['server'])->setUsername($arr['username'])->setPassword($p1)->request(); } else { RPC::call('Account.resetPassword'); Notification::append(null, $this->__('account.password_not_same')); } } else { RPC::call('Account.resetPassword'); Notification::append(null, $this->__('account.password_not_valid')); } }
public static function init() { self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS = new HashMap(); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Boolean::clazz(), Boolean::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Byte::clazz(), Byte::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Character::clazz(), Character::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Float::clazz(), Float::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Integer::clazz(), Integer::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Long::clazz(), Long::typeClass()); self::$PRIMITIVE_WRAPPER_CLASS_TO_PRIMITIVE_CLASS->put(Short::clazz(), Short::typeClass()); self::$TYPE_NAMES['Z'] = Boolean::typeClass(); self::$TYPE_NAMES['B'] = Byte::typeClass(); self::$TYPE_NAMES['C'] = Character::typeClass(); self::$TYPE_NAMES['D'] = Double::typeClass(); self::$TYPE_NAMES['F'] = Float::typeClass(); self::$TYPE_NAMES['I'] = Integer::typeClass(); self::$TYPE_NAMES['J'] = Long::typeClass(); self::$TYPE_NAMES['S'] = Short::typeClass(); self::$serviceToImplementedInterfacesMap = new HashMap(); }
function onCommand($package) { $command = $package->content; $view = $this->tpl(); if (isset($command->note)) { $view->assign('note', $command->note); Dialog::fill($view->draw('_adhoc_note', true)); } if (isset($command->x)) { $xml = new \XMPPtoForm(); $form = $xml->getHTML($command->x->asXML()); $view->assign('form', $form); $view->assign('attributes', $command->attributes()); $view->assign('actions', null); if (isset($command->actions)) { $view->assign('actions', $command->actions); } Dialog::fill($view->draw('_adhoc_form', true), true); } RPC::call('AdHoc.initForm'); }
function ajaxDisplay() { $tmp = []; foreach (scandir(USERS_PATH) as $f) { if (is_dir(USERS_PATH . '/' . $f)) { $time = filemtime(USERS_PATH . '/' . $f . '/index.html'); if ($time) { array_push($tmp, $time); } } } sort($tmp); $days = []; $pattern = "M Y"; foreach ($tmp as $k => $time) { $key = date($pattern, $time); if (isset($days[$key])) { $days[$key]++; } else { $days[$key] = 1; } } $data = new stdClass(); $data->labels = []; $data->datasets = []; $first = new StdClass(); $first->label = "Monthly Subscriptions"; $first->fillColor = "rgba(255,152,0,0.5)"; $first->strokeColor = "rgba(255,152,0,0.8)"; $first->highlightFill = "rgba(220,220,220,0.75)"; $first->highlightStroke = "rgba(220,220,220,1)"; $values = []; foreach ($days as $key => $value) { array_push($data->labels, $key); array_push($values, $value); } $first->data = $values; array_push($data->datasets, $first); RPC::call('Statistics.drawGraphs', $data); }
function ajaxLogin($username) { $validate_user = Validator::string()->length(4, 40); if (!$validate_user->validate($username)) { Notification::append(null, $this->__('login_anonymous.bad_username')); return; } // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $host = 'anonymous.jappix.com'; $password = '******'; // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We set the username in the session $s = Session::start(); $s->set('username', $username); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
function prepareMessages($jid) { if (!$this->validateJid($jid)) { return; } $md = new \Modl\MessageDAO(); $messages = $md->getContact(echapJid($jid), 0, 30); if (is_array($messages)) { $messages = array_reverse($messages); foreach ($messages as $message) { $this->prepareMessage($message); } } $view = $this->tpl(); $view->assign('jid', $jid); $cd = new \Modl\ContactDAO(); $contact = $cd->get($jid); $me = $cd->get(); if ($me == null) { $me = new \Modl\Contact(); } $view->assign('contact', $contact); $view->assign('me', false); $left = $view->draw('_chat_bubble', true); $view->assign('contact', $me); $view->assign('me', true); $right = $view->draw('_chat_bubble', true); $room = $view->draw('_chat_bubble_room', true); RPC::call('Chat.setBubbles', $left, $right, $room); RPC::call('Chat.appendMessages', $messages); }
private function displayServer($server) { if (!$this->validateServer($server)) { return; } $html = $this->prepareServer($server); RPC::call('movim_fill', 'groups_widget', $html); RPC::call('Groups.refresh'); }
if (isset($msg)) { if ($msg->func == 'message' && $msg->body != '') { $msg = $msg->body; } elseif ($msg->func == 'unregister') { \Moxl\Stanza\Stream::end(); } elseif ($msg->func == 'register') { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $domain = \Moxl\Utils::getDomain($msg->host); #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $connector->create($domain, 5222)->then($xmpp_behaviour); } } else { return; } $rpc = new \RPC(); $rpc->handle_json($msg); $msg = json_encode(\RPC::commit()); \RPC::clear(); if (!empty($msg)) { echo base64_encode(gzcompress($msg, 9)) . ""; #fwrite(STDERR, colorize($msg, 'yellow')." : ".colorize('sent to the browser', 'green')."\n"); } $xml = \Moxl\API::commit(); \Moxl\API::clear(); $loop->tick(); if (!empty($xml) && $conn) { $conn->write(trim($xml)); #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); } }
if (empty($payloadType)) { $out->writeObject($payload); } else { $clazz = Classes::classOf($payloadType); $out->writeValue($clazz, $payload); } $sink->accept($command); } public static function streamResponseForFailure(ClientOracle $clientOracle, OutputStream $out, Exception $payload) { $sink = $clientOracle->createCommandSink($out); self::streamResponse($clientOracle, $payload, $sink, true); $sink->finish(); } } RPC::init(); class RpcRequest { public $service; public $method; public $parameters; public function __construct($service, $method, $parameters) { $this->service = $service; $this->method = $method; $this->parameters = $parameters; } } /** @gwtname com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException */ class IncompatibleRemoteServiceException extends Exception {
/** * Process a call originating from the given request. Uses the * {@link RPC#invokeAndEncodeResponse(Object, java.lang.reflect.Method, Object[])} * method to do the actual work. * <p> * Subclasses may optionally override this method to handle the payload in any * way they desire (by routing the request to a framework component, for * instance). The {@link HttpServletRequest} and {@link HttpServletResponse} * can be accessed via the {@link #getThreadLocalRequest()} and * {@link #getThreadLocalResponse()} methods. * </p> * This is public so that it can be unit tested easily without HTTP. * * @param payload the UTF-8 request payload * @return a string which encodes either the method's return, a checked * exception thrown by the method, or an * {@link IncompatibleRemoteServiceException} * @throws SerializationException if we cannot serialize the response * @throws UnexpectedException if the invocation throws a checked exception * that is not declared in the service method's signature * @throws RuntimeException if the service method throws an unchecked * exception (the exception will be the one thrown by the service) */ public function processCall($payload) { try { $this->logger->debug('Processing Call start', $this); $rpcRequest = RPC::decodeRequest($payload, $this->getMappedClassLoader(), $this); //FOCUS: this method is used only in PHP implementation of GWT RemoteServiceServlet $this->onAfterRequestDecoded($rpcRequest); $target = $this->getRPCTargetResolverStrategy()->resolveRPCTarget($rpcRequest->getMethod()->getDeclaringMappedClass()); return RPC::invokeAndEncodeResponse($target, $rpcRequest->getMethod(), $rpcRequest->getParameters(), $rpcRequest->getSerializationPolicy(), $rpcRequest->getMappedClassLoader()); } catch (IncompatibleRemoteServiceException $ex) { $this->logger->log(LoggerLevel::getLevelError(), 'An IncompatibleRemoteServiceException was thrown while processing this call.', $ex); return RPC::encodeResponseForFailure(null, $ex, null, $this->getMappedClassLoader()); } }
function onGroupSubscribedList($list) { $html = $this->prepareList($list); RPC::call('movim_fill', 'groupsubscribedlistconfig', $html); }
public function processCall($payload) { $this->checkPermutationStrongName(); try { $rpcRequest = RPC::decodeRequest($payload, Classes::classOf($this->delegate), $this); $this->onAfterRequestDeserialized($rpcRequest); return RPC::invokeAndEncodeResponse($this->delegate, $rpcRequest->getMethod(), $rpcRequest->getParameters(), $rpcRequest->getSerializationPolicy(), $rpcRequest->getFlags()); } catch (IncompatibleRemoteServiceException $ex) { echo $ex; /*log( "An IncompatibleRemoteServiceException was thrown while processing this call.", ex); */ return RPC::encodeResponseForFailure(null, $ex); } catch (RpcTokenException $ex) { //log("An RpcTokenException was thrown while processing this call.", //tokenException); return RPC::encodeResponseForFailure(null, $ex); } }
public function processCall(ClientOracle $clientOracle, $payload, OutputStream $stream) { assert($payload != null); assert(mb_strlen($payload) != 0); try { $rpcRequest = RPC::decodeRequest($payload, $clientOracle); $this->onAfterRequestDeserialized($rpcRequest); RPC::invokeAndStreamResponse($rpcRequest, $clientOracle, $stream); } catch (RemoteException $e) { throw new SerializationException('An exception was sent from the client : ' . $e); } catch (IncompatibleRemoteServiceException $e) { error_log('A incompatibleRemoteServiceException was thrown while processing this call : ' . $e); RPC::streamResponseForFailure($clientOracle, $stream, $e); } }
function ajaxClear() { $html = $this->prepareEmpty(); RPC::call('movim_fill', 'group_widget', $html); }
function ajaxGetForm() { $cd = new \modl\ContactDAO(); $me = $cd->get(); RPC::call('MovimTpl.fill', '#avatar_form', $this->prepareForm($me)); }
public function ajaxUpdateDatabase() { $md = \modl\Modl::getInstance(); $md->check(true); RPC::call('movim_reload_this'); }
function preparePresence() { $cd = new \Modl\ContactDAO(); $pd = new \Modl\PresenceDAO(); $session = \Session::start(); // If the user is still on a logued-in page after a daemon restart if ($session->get('jid') == false) { RPC::call('MovimUtils.disconnect'); return false; } $presence = $pd->getPresence($session->get('jid'), $session->get('resource')); $presencetpl = $this->tpl(); $contact = $cd->get(); if ($contact == null) { $contact = new \Modl\Contact(); } if ($presence == null) { $presence = new \Modl\Presence(); } $presencetpl->assign('me', $contact); $presencetpl->assign('presence', $presence); $presencetpl->assign('presencetxt', getPresencesTxt()); $presencetpl->assign('dialog', $this->call('ajaxOpenDialog')); $html = $presencetpl->draw('_presence', true); return $html; }