// 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);
}
// display instructions and warnings on addon settings page for admin
if (!file_exists("addon/jappixmini/jappix")) {
- $o .= '<p><strong>You need to install the Jappix application, adapted for Friendica (see README).</strong></p>';
+ $o .= '<p><strong>You need to install the Jappix application (see README).</strong></p>';
+ }
+ else if (file_exists("addon/jappixmini/jappix/index.php")) {
+ // try to delete automatically
+ try {
+ unlink("addon/jappixmini/jappix/index.php");
+ }
+ catch (Exception $e) {}
+
+ // warn admin if this is not possible
+ if (file_exists("addon/jappixmini/jappix/index.php"))
+ $o .= '<p><strong style="color:#fff;background-color:#f00">You must delete addon/jappixmini/jappix/index.php (see README).</strong></p>';
+ else {
+ info("Deleted addon/jappixmini/jappix/index.php automatically.");
+ $o .= '<p>Jappix is installed.</p>';
+ }
}
else if (!file_exists("addon/jappixmini/jappix.zip")) {
$o .= '<p><strong style="color:#fff;background-color:#f00">The source archive jappix.zip does not exist. This is probably a violation of the Jappix License (see README).</strong></p>';
$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/proxy.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>";