depends glib2 &&

depends "$BITLBEE_SSL" "--ssl=$BITLBEE_SSL" &&
depends "$BITLBEE_EVENT" "--events=${BITLBEE_EVENT/glib2/glib}" &&

optional_depends libotr \
                 "--otr=1" \
                 "--otr=0" \
                 "for off-the-record (OTR) encryption support" &&

if is_depends_enabled $SPELL libotr && list_find "$BITLBEE_OPTS" "--plugins=1"; then
  config_query BITLBEE_OTRPLUGIN "Build OTR support as a plugin?" n &&

  if [[ $BITLBEE_OTRPLUGIN == y ]]; then
    list_remove "BITLBEE_OPTS" "--otr=1" &&
    list_add "BITLBEE_OPTS" "--otr=plugin"
  fi
fi &&

optional_depends pidgin \
                 "--purple=1" \
                 "--purple=0" \
                 "for enabling protocol support via libpurple" &&

if ! is_depends_enabled $SPELL pidgin; then
  config_query_option BITLBEE_OPTS "Enable Jabber (XMPP) protocol?" y \
                                   "--jabber=1" \
                                   "--jabber=0" &&

  config_query_option BITLBEE_OPTS "Enable Oscar protocol (for ICQ or AIM)?" y \
                                   "--oscar=1" \
                                   "--oscar=0" &&

  config_query_option BITLBEE_OPTS "Enable Yahoo protocol?" y \
                                   "--yahoo=1" \
                                   "--yahoo=0" &&

  config_query_option BITLBEE_OPTS "Enable MSN protocol?" y \
                                   "--msn=1" \
                                   "--msn=0"
else
  list_add "BITLBEE_OPTS" "--jabber=0" &&
  list_add "BITLBEE_OPTS" "--oscar=0" &&
  list_add "BITLBEE_OPTS" "--yahoo=0" &&
  list_add "BITLBEE_OPTS" "--msn=0"
fi &&

if ! list_find "$BITLBEE_OPTS" "--skype=0"; then
  depends asciidoc
fi
