mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 11:03:41 +00:00
jappixmini: make BOSH proxy optional
This commit is contained in:
parent
a53167da1a
commit
b4aa673c5d
3 changed files with 38 additions and 23 deletions
|
@ -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 <bosh> 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.
|
||||
|
|
|
@ -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 .= "<p><strong>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.</strong></p>";
|
||||
|
||||
// bosh proxy
|
||||
$bosh_proxy = intval(get_config("jappixmini", "bosh_proxy"));
|
||||
$bosh_proxy = intval($bosh_proxy) ? ' checked="checked"' : '';
|
||||
$o .= '<label for="jappixmini-proxy">Activate BOSH proxy</label>';
|
||||
$o .= ' <input id="jappixmini-proxy" type="checkbox" name="jappixmini-proxy" value="1"'.$bosh_proxy.' /><br />';
|
||||
|
||||
// info text field
|
||||
$o .= '<label for="jappixmini-infotext">Info text to help users with configuration (important if you want to provide your own BOSH host!):</label><br />';
|
||||
$info_text = get_config("jappixmini", "infotext");
|
||||
$o .= '<textarea id="jappixmini-infotext" name="jappixmini-infotext" rows="5" cols="50">'.htmlentities($info_text).'</textarea><br />';
|
||||
$o .= '<p><label for="jappixmini-infotext">Info text to help users with configuration (important if you want to provide your own BOSH host!):</label><br />';
|
||||
$o .= '<textarea id="jappixmini-infotext" name="jappixmini-infotext" rows="5" cols="50">'.htmlentities($info_text).'</textarea></p>';
|
||||
|
||||
// submit button
|
||||
$o .= '<input type="submit" name="jappixmini-admin-settings" value="OK" />';
|
||||
}
|
||||
|
||||
|
@ -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 .= ' <input id="jappixmini-server" type="text" name="jappixmini-server" value="'.$server.'" />';
|
||||
$s .= '<br />';
|
||||
|
||||
$conf = file_get_contents("addon/jappixmini/jappix/store/conf/main.xml");
|
||||
preg_match("/<bosh_proxy>(.*)<\/bosh_proxy>/", $conf, $matches);
|
||||
if ($matches[1]=="on") {
|
||||
$s .= '<label for="jappixmini-bosh">Jabber BOSH host</label>';
|
||||
$s .= ' <input id="jappixmini-bosh" type="text" name="jappixmini-bosh" value="'.$bosh.'" />';
|
||||
$s .= '<br />';
|
||||
}
|
||||
$s .= '<label for="jappixmini-bosh">Jabber BOSH host</label>';
|
||||
$s .= ' <input id="jappixmini-bosh" type="text" name="jappixmini-bosh" value="'.$bosh.'" />';
|
||||
$s .= '<br />';
|
||||
|
||||
$s .= '<label for="jappixmini-password">Jabber password</label>';
|
||||
$s .= ' <input type="hidden" id="jappixmini-password" name="jappixmini-encrypted-password" value="'.$password.'" />';
|
||||
|
@ -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>(.*)<\/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'] .= "<script type=\"text/javascript\">
|
||||
jQuery(document).ready(function() {
|
||||
jappixmini_addon_start('$server', '$username', '$bosh', $encrypt, '$password', $nickname, $contacts_json, $autoapprove, $autosubscribe);
|
||||
jappixmini_addon_start('$server', '$username', '$proxy', '$bosh', $encrypt, '$password', $nickname, $contacts_json, $autoapprove, $autosubscribe);
|
||||
});
|
||||
</script>";
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue