diff --git a/jappixmini/README b/jappixmini/README index 822f4391..222b85a5 100644 --- a/jappixmini/README +++ b/jappixmini/README @@ -10,8 +10,9 @@ the Jappix project (https://bind.jappix.com/) is not locked to a specific XMPP provider, but keep in mind that only personal usage is approved according to http://codingteam.net/project/jappix/doc/BoshServer. If you have a larger server, it is recommended that you install your own BOSH -server, add it to the tag in jappix/store/conf/hosts.xml, and disable -the bosh proxy in jappix/store/conf/main.xml. +server and recommend it using the configuration help field. If it is on the +same server, you can also deactivate the BOSH proxy. This should improve the +performance. The addon has an experimental autosubscribe and autosuggest functionality which tries to add your Friendica contacts to your roster automatically. diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 88233063..b177507a 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -70,7 +70,7 @@ register_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron'); // Jappix source download as required by AGPL register_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source'); -// set standard info text +// set standard configuration $info_text = get_config("jappixmini", "infotext"); if (!$info_text) set_config("jappixmini", "infotext", "To get the chat working, you need to know a BOSH host which works with your Jabber account. ". @@ -78,6 +78,9 @@ if (!$info_text) set_config("jappixmini", "infotext", "in mind that the BOSH server can read along all chat messages. If you know that your Jabber ". "server also provides an own BOSH server, it is much better to use this one!" ); + +$bosh_proxy = get_config("jappixmini", "bosh_proxy"); +if ($bosh_proxy==="") set_config("jappixmini", "bosh_proxy", 1); } @@ -110,10 +113,18 @@ function jappixmini_plugin_admin(&$a, &$o) { $cron_run = get_config("jappixmini", "last_cron_execution"); if (!$cron_run) $o .= "

Warning: The cron job has not yet been executed. If this message is still there after some time (usually 10 minutes), this means that autosubscribe and autoaccept will not work.

"; + // bosh proxy + $bosh_proxy = intval(get_config("jappixmini", "bosh_proxy")); + $bosh_proxy = intval($bosh_proxy) ? ' checked="checked"' : ''; + $o .= ''; + $o .= '
'; + // info text field - $o .= '
'; $info_text = get_config("jappixmini", "infotext"); - $o .= '
'; + $o .= '


'; + $o .= '

'; + + // submit button $o .= ''; } @@ -122,7 +133,9 @@ function jappixmini_plugin_admin_post(&$a) { $submit = $_REQUEST['jappixmini-admin-settings']; if ($submit) { $info_text = $_REQUEST['jappixmini-infotext']; + $bosh_proxy = intval($_REQUEST['jappixmini-proxy']); set_config("jappixmini", "infotext", $info_text); + set_config("jappixmini", "bosh_proxy", $bosh_proxy); } } @@ -255,13 +268,9 @@ function jappixmini_settings(&$a, &$s) { $s .= ' '; $s .= '
'; - $conf = file_get_contents("addon/jappixmini/jappix/store/conf/main.xml"); - preg_match("/(.*)<\/bosh_proxy>/", $conf, $matches); - if ($matches[1]=="on") { - $s .= ''; - $s .= ' '; - $s .= '
'; - } + $s .= ''; + $s .= ' '; + $s .= '
'; $s .= ''; $s .= ' '; @@ -410,11 +419,13 @@ function jappixmini_script(&$a,&$s) { $autosubscribe = get_pconfig(local_user(),'jappixmini','autosubscribe'); $autosubscribe = intval($autosubscribe); - // deactivate bosh host if proxy is off - $conf = file_get_contents("addon/jappixmini/jappix/store/conf/main.xml"); - preg_match("/(.*)<\/bosh_proxy>/", $conf, $matches); - if ($matches[1]!="on") { - $bosh = ''; + // set proxy if necessary + $use_proxy = get_config('jappixmini','bosh_proxy'); + if ($use_proxy) { + $proxy = $a->get_baseurl().'/addon/jappixmini/jappix/php/bosh.php'; + } + else { + $proxy = ""; } // get a list of jabber accounts of the contacts @@ -448,7 +459,7 @@ function jappixmini_script(&$a,&$s) { // add javascript to start Jappix Mini $a->page['htmlhead'] .= ""; diff --git a/jappixmini/lib.js b/jappixmini/lib.js index d1858ff8..8f4a2669 100644 --- a/jappixmini/lib.js +++ b/jappixmini/lib.js @@ -170,7 +170,7 @@ function jappixmini_addon_subscribe() { sendSubscribe(xid, "subscribe"); } -function jappixmini_addon_start(server, username, bosh, encrypted, password, nickname, contacts, autoapprove, autosubscribe) { +function jappixmini_addon_start(server, username, proxy, bosh, encrypted, password, nickname, contacts, autoapprove, autosubscribe) { handler = function(password){ // check if settings have changed, reinitialize jappix mini if this is the case settings_identifier = str_sha1(server); @@ -183,15 +183,18 @@ function jappixmini_addon_start(server, username, bosh, encrypted, password, nic if (saved_identifier != settings_identifier) removeDB('jappix-mini', 'dom'); setDB("jappix-mini", "settings_identifier", settings_identifier); - // set bosh host - if (bosh) - HOST_BOSH = HOST_BOSH+"?host_bosh="+encodeURI(bosh); + // set HOST_BOSH + if (proxy) + HOST_BOSH = proxy+"?host_bosh="+encodeURI(bosh); + else + HOST_BOSH = bosh; // start jappix mini MINI_NICKNAME = nickname; + LOCK_HOST = "off"; console.log("launchMini"); launchMini(true, false, server, username, password); - jappixmini_manage_roster(contacts, autoapprove, autosubscribe) + jappixmini_manage_roster(contacts, autoapprove, autosubscribe) } // decrypt password if necessary