// 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. ".
"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);
}
$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" />';
}
$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);
}
}
$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.'" />';
$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
// 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>";
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);
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