These scripts prepare a clean licq directory from info form
centericq and kxicq

I wrote them to faciliate a transfer from those programs

-- 
regs MR E_T

_______________________
\                      \
  \   OOHH I hate TYPOS  \
    \                      \
      ~~~~~~~~~~~~~~~~~~~~~~~
#/bin/sh
#
#  written by conon <[EMAIL PROTECTED]>
#
#  This script is intended to be run before starting licq
#  It prepares the directory and users setups to that of a
#  current kxicq setup
#  just run the script and it will do it all
#

test "${1}" && test "${1}" == "-t" -o "${1}" == "-T" && TESTING="-b .licq"

if test "$TESTING"
  then
    LICQ_DIR=.licq
    KDE_DIR=.kde/share
  else
    LICQ_DIR=~/.licq
    KDE_DIR=~/.kde/share
  fi

LICQ_USER_DIR=${LICQ_DIR}/users
LICQ_HISTORY_DIR=${LICQ_DIR}/history
LICQ_CONF=${LICQ_DIR}/licq.conf
LICQ_OWNER=${LICQ_DIR}/owner.uin
LICQ_QT_GUI=${LICQ_DIR}/licq_qt-gui.conf
LICQ_USERS=${LICQ_DIR}/users.conf
OWNER_HISTORY=${LICQ_HISTORY_DIR}/owner.history

KXICQ_RC=${KDE_DIR}/config/kxicq2rc
KXICQ_CONTACTS=${KDE_DIR}/apps/kxicq2/contacts.kxicq
KXICQ_MESSAGES=${KDE_DIR}/apps/kxicq2/messages.kxicq2

DEFAULT_T_F=0

L_SERVER="ICQServer"
K_SERVER="Server"
SERVER=""
L_SERVER_PORT="ICQServerPort"
K_SERVER_PORT="Port"
SERVER_PORT=0
L_USE_PROXY="ProxyEnabled"
K_USE_PROXY="Use Proxy"
USE_PROXY=""
L_PROXY_SERVER="ProxyServer"
K_PROXY_SERVER="Proxy Server"
PROXY_SERVER=""
L_PROXY_PORT="ProxyServerPort"
K_PROXY_PORT="Proxy Port"
PROXY_PORT=0
L_DOCKING="UseDock"
K_DOCKING="KDE Dock"
DOCKING=0

L_NICK="Alias"
K_NICK="Nick"
NICK=""
L_PASSWORD="Password"
K_PASSWORD="Password"
PASSWORD=""
L_UIN="Uin"
K_UIN="UIN"
UIN=0
L_WEB_STATUS="WebPresence"
K_WEB_STATUS="Web Status"
WEB_STATUS=0
L_HIDE_IP="HideIp"
K_HIDE_IP="Hide IP"
HIDE_IP=0

K_USE_AUTO_AWAY="Auto Away"
USE_AWAY_TIME=false
L_AWAY_TIME="AutoAway"
K_AWAY_TIME="Away Time"
AWAY_TIME=5
L_N_A_TIME="AutoNA"
K_N_A_TIME="N/A Time"
N_A_TIME=10

function true_false ()
{
  case $1
   in
   "true"|"TRUE"|"True"|"1")    echo 1;;
   "false"|"FALSE"|"False"|"0") echo 0;;
   *)                           echo ${DEFAULT_T_F};;
   esac
}

function readkxicq2conf ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INREST=${INSTUFF##*'='}
      case ${INBASE}
        in
        ${K_SERVER})        SERVER="${INREST}";;
        ${K_SERVER_PORT})   SERVER_PORT="${INREST}";;
        ${K_USE_PROXY})     USE_PROXY=`true_false ${INREST}`;;
        ${K_PROXY_SERVER})  PROXY_SERVER="${INREST}";;
        ${K_PROXY_PORT})    PROXY_PORT="${INREST}";;
        ${K_NICK})          NICK="${INREST}";;
        ${K_PASSWORD})      PASSWORD="${INREST}";;
        ${K_UIN})           UIN="${INREST}";;
        ${K_WEB_STATUS})    WEB_STATUS=`true_false ${INREST}`;;
        ${K_HIDE_IP})       HIDE_IP=`true_false ${INREST}`;;
        ${K_DOCKING})       DOCKING=`true_false ${INREST}`;;
        ${K_USE_AUTO_AWAY}) USE_AUTO_AWAY="${INREST}";;
        ${K_AWAY_TIME})     AWAY_TIME="${INREST}";;
        ${K_N_A_TIME})      N_A_TIME="${INREST}";;
        esac
    done
}

function out_licq_conf ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INBASE=${INSTUFF%%' '*}
      INREST=${INSTUFF##*'='}
      INREST=${INSTUFF##*' '}
      case $INBASE
        in
        ${L_SERVER})       echo "${INBASE} = ${SERVER}";;
        ${L_SERVER_PORT})  echo "${INBASE} = ${SERVER_PORT}";;
        ${L_USE_PROXY})    echo "${INBASE} = ${USE_PROXY}";;
        ${L_PROXY_SERVER}) echo "${INBASE} = ${PROXY_SERVER}";;
        ${L_PROXY_PORT})   echo "${INBASE} = ${PROXY_PORT}";;
        *)                 echo "${INSTUFF}";;
        esac
    done
}

function out_owner_uin ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INBASE=${INSTUFF%%' '*}
      INREST=${INSTUFF##*'='}
      INREST=${INSTUFF##*' '}
      case $INBASE
        in
        "History")       echo "${INBASE} = ${OWNER_HISTORY}";;
        ${L_NICK})       echo "${INBASE} = ${NICK}";;
        ${L_PASSWORD})   echo "${INBASE} = ${PASSWORD}";;
        ${L_UIN})        echo "${INBASE} = ${UIN}";;
        ${L_WEB_STATUS}) echo "${INBASE} = ${WEB_STATUS}";;
        ${L_HIDE_IP})    echo "${INBASE} = ${HIDE_IP}";;
        *)               echo "${INSTUFF}";;
        esac
    done
}

function out_qt_gui ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INBASE=${INSTUFF%%' '*}
      INREST=${INSTUFF##*'='}
      INREST=${INSTUFF##*' '}
      case ${INBASE}
        in
        ${L_DOCKING})   echo "${INBASE} = ${DOCKING}";;
        *)              if ${USE_AWAY_TIME}
                          then
                            case $INBASE
                              in
                              ${L_AWAY_TIME}) echo "${INBASE} = ${AWAY_TIME}";;
                              ${L_N_A_TIME})  echo "${INBASE} = ${N_A_TIME}";;
                              *) echo ${INSTUFF};;
                              esac
                          else
                            echo ${INSTUFF}
                          fi
        esac
    done
}

function test_mv ()
{
  if test -e ${1}.new
    then
      test -e ${1} && mv ${1} ${1}.orig
      mv ${1}.new ${1}
    fi
}

declare -a CONTACTS
CONTACT_COUNT=0
NICKNAME=""
FNAME=""
LNAME=""
EMAIL=""
U_I_N=""
NOTIFY=0
IGNORE=0
VISIBLE=0
INVISIBLE=0
NEW_USERS=0
NEW_USER="0"

function cat_user_skel ()
{
  local SYSTEM_GROUPS=0
  let SYSTEM_GROUPS+=${NOTIFY}
  let SYSTEM_GROUPS+=${IGNORE}
  let SYSTEM_GROUPS+=${VISIBLE}
  let SYSTEM_GROUPS+=${INVISIBLE}
  let SYSTEM_GROUPS+=${NEW_USERS}
  cat <<-EOF
        [user]
        History = ${LICQ_HISTORY_DIR}/${U_I_N}.history
        Groups.System = ${SYSTEM_GROUPS}
        Groups.User = 
        Ip =
        Port =
        NewUser = ${NEW_USER}
        NewMessages =
        LastOnline =
        Alias = ${NICKNAME}
        FirstName = ${FNAME}
        LastName = ${LNAME}}
        Email1 = ${EMAIL}
        Email2 =
        City =
        State =
        PhoneNumber =
        FaxNumber =
        Address =
        CellularNumber =
        Zipcode =
        Country =
        Timezone =
        Authorization =
        HideEmail =
        Age =
        Gender =
        Homepage =
        BirthYear =
        BirthMonth =
        BirthDay =
        Language1 =
        Language2 =
        Language3 =
        CompanyCity =
        CompanyState =
        CompanyPhoneNumber =
        CompanyFaxNumber =
        CompanyAddress =
        CompanyName =
        CompanyDepartment =
        CompanyPosition =
        CompanyHomepage =
        EOF
}

function parse_contacts ()
{
  local INSTUFF
  local INBASE
  local INREST
  local INCONTACT="false"

  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INREST=${INSTUFF##*'='}
      if test "${INSTUFF:0:1}" == "["
        then
          if ${INCONTACT}
            then
              echo -n > ${LICQ_HISTORY_DIR}/${U_I_N}.history
              cat_user_skel > ${LICQ_USER_DIR}/${U_I_N}.uin
              CONTACTS[${CONTACT_COUNT}]="${U_I_N}"
              let CONTACT_COUNT+=1
              INCONTACT=false
              NICKNAME=""
              U_I_N=""
              NOTIFY=0
              IGNORE=0
              VISIBLE=0
              INVISIBLE=0
              NEW_USERS=0
              FNAME=""
              LNAME=""
              EMAIL=""
              NEW_USER="0"
            fi
          if test "${INSTUFF:0:8}" == "[Contact"
            then
              INCONTACT="true"
            else
              INCONTACT="false"
            fi 
        fi
      case ${INBASE}
        in
        "UIN")           U_I_N="${INREST}";;
        "Nick")          NICKNAME="${INREST}";;
        "Online Notify") test "${INREST}" == "1" -o "${INREST}" == "true" \
                           && NOTIFY="1";;
        "Visible")       test "${INREST}" == "1" -o "${INREST}" == "true" \
                           && VISIBLE="2";;
        "Invisible")       test "${INREST}" == "1" -o "${INREST}" == "true" \
                           && INVISIBLE="4";;
        "Ignore")        test "${INREST}" == "1" -o "${INREST}" == "true" \
                           && IGNORE="8";;
        esac
    done
}

function out_users_conf ()
{
  local TMPCOUNT=0
  local TEMPCOUNT=1
  echo -e "[users]\nNumOfUsers = ${CONTACT_COUNT}"
  while test ${TMPCOUNT} -lt ${CONTACT_COUNT}
    do
      echo "User${TEMPCOUNT} = ${CONTACTS[${TMPCOUNT}]}"
      let TMPCOUNT+=1
      let TEMPCOUNT+=1
    done
}

GLOBAL_MESSAGE=""
function parse_message ()
{
  local TMPIFS=${IFS}
  IFS=""
  local MESG="$@"
  local STRLEN=${#MESG}
  local TMPCNT=0
  GLOBAL_MESSAGE=":"
  while test ${TMPCNT} -lt ${STRLEN}
    do
      case "${MESG:${TMPCNT}:2}"
        in
        "\\r")   let TMPCNT+=1;;
        "\\n")   let TMPCNT+=1
                 GLOBAL_MESSAGE="${GLOBAL_MESSAGE}\n:";;
        *)       case '${MESG:${TMPCNT}:1}'
                   in
                   '\n') GLOBAL_MESSAGE="${GLOBAL_MESSAGE}:\n";;
                   ,\r,) GLOBAL_MESSAGE="${GLOBAL_MESSAGE}";;
                   *)    GLOBAL_MESSAGE="${GLOBAL_MESSAGE}${MESG:${TMPCNT}:1}";;
                   esac
        esac
      let TMPCNT+=1
    done
  GLOBAL_MESSAGE="${GLOBAL_MESSAGE}\n"
  IFS=${TMPIFS}
}

function convert_history ()
{
  local INSTUFF
  local INBASE
  local INREST
  local INMESSAGE="false"
  local OPT_READ=""
  local OPT_TYPE=""
  local OPT_SENT=""
  local DATE=""
  local MESSAGE=""
  local URL=""
  local TEMP=""

  while read -r INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INREST=${INSTUFF##*'='}
      if test "${INBASE:0:1}" == "["
        then
          if $INMESSAGE
            then
              if ! test -e ${LICQ_USER_DIR}/${U_I_N}.uin
                then
                  echo -n > ${LICQ_HISTORY_DIR}/${U_I_N}.history
                  NEW_USER="1"
                  NEW_USERS="16"
                  INVISIBLE="4"
                  cat_user_skel > ${LICQ_USER_DIR}/${U_I_N}.uin
                  CONTACTS[${CONTACT_COUNT}]="${U_I_N}"
                  let CONTACT_COUNT+=1
                  NICKNAME=""
                  U_I_N=""
                  NOTIFY=0
                  IGNORE=0
                  VISIBLE=0
                  INVISIBLE=0
                  NEW_USERS=0
                  FNAME=""
                  LNAME=""
                  EMAIL=""
                  NEW_USER="0"
                fi
#              echo "prep >> ${LICQ_HISTORY_DIR}/${U_I_N}.history"
#              test "$MESSAGE" || { test "${OPT_TYPE}" == "0012" && MESSAGE=":You have 
been added to my list\n" ; }
#              test "$MESSAGE" || MESSAGE=":\n"
              echo -en "[ ${OPT_SENT} | ${OPT_TYPE} | 2046 | 0001 | ${DATE} ]"\
                       "\n${MESSAGE}${URL}"  \
                         >> ${LICQ_HISTORY_DIR}/${U_I_N}.history
              INMESSAGE="false"
              OPT_READ=""
              OPT_TYPE=""
              OPT_SENT=""
              DATE=""
              U_I_N=""
              MESSAGE=""
              URL=""
              NICKNAME=""
            fi
          if test "${INBASE:0:8}" == "[Message"
            then
              INMESSAGE="true"
            fi
        fi
      case ${INBASE}
        in
        "DateTime")   TEMP=$INREST
                      DATE="${TEMP%%'-'*}"; TEMP=${TEMP#*'-'}
                      DATE="${TEMP%%'-'*}/${DATE}" ; TEMP=${TEMP#*'-'}
                      DATE=`date +"%s" -d "${DATE}/${TEMP:2}"`;;
         "Options")   OPT_READ="${INREST%%' '*}" ; TEMP="${INREST#*' '}"
                      OPT_TYPE="${TEMP%%' '*}" ; TEMP="${TEMP#*' '}"
                      OPT_SENT="${TEMP%%' '*}"
                      if test "${OPT_SENT}" == "1"
                        then
                          OPT_SENT="S"
                        else
                          OPT_SENT="R"
                        fi
                      case $OPT_TYPE
                        in
                        "01") OPT_TYPE=0001;;
                        "02") OPT_TYPE=0004;;
                        "03") OPT_TYPE=0012;;
                        "04") OPT_TYPE=0006;;
                        "05") OPT_TYPE=0008;;
                        "06") OPT_TYPE=0013;;
                        "07") OPT_TYPE=0014;;
                        "08") OPT_TYPE=0007;;
                        "09") OPT_TYPE=0003;;
                        "10") OPT_TYPE=0002;;
                        "11") OPT_TYPE=0019;;
                        "12") OPT_TYPE=0026;;
                        esac;;
        "Message")      parse_message "${INREST}"
                        MESSAGE="${MESSAGE}${GLOBAL_MESSAGE}";;
        "Url")          parse_message "${INREST}"
                        URL="${URL}${GLOBAL_MESSAGE}";;
        "Uin")          U_I_N="${INREST}";;
        "Nick")         Nickname="${INREST}";;
        "FirstName")    FNAME="${INREST}";;
        "LastName")     LNAME="${INREST}";;
        "Email")        EMAIL="${INREST}";;
        esac
    done
}

test -d ${LICQ_DIR} || licq ${TESTING} -I -h >/dev/null 2>&1 
#test -d ${LICQ_DIR} || mkdir ${LICQ_DIR}
#test -d ${LICQ_HISTORY_DIR} || mkdir ${LICQ_HISTORY_DIR}
#test -d ${LICQ_USER_DIR} || mkdir ${LICQ_USER_DIR}

if test -e ${KXICQ_RC} -a ! -e ${LICQ_OWNER}.orig
  then
    readkxicq2conf < ${KXICQ_RC}
    if test -e ${LICQ_CONF}
      then
        out_licq_conf < ${LICQ_CONF} >${LICQ_CONF}.new
      else
        out_licq_conf >${LICQ_CONF}.new <<-EOF
                [licq]
                Version = 1020
                
                [plugins]
                NumPlugins = 1
                Plugin1 = qt-gui
                
                [network]
                AllowNewUsers = 1
                NumOfICQServers = 1
                ICQServer = login.icq.com
                ICQServerPort = 5190
                TCPPortsLow = 0
                TCPPortsHigh = 0
                TCPEnabled = 1
                MaxUsersPerPacket = 100
                IgnoreTypes = 0
                ForegroundColor = 0
                BackgroundColor = 16777215
                Errors = log.errors
                ErrorTypes = 6
                Rejects = log.rejects
                Translation = none
                UrlViewer = viewurl-netscape.sh
                Terminal = xterm -T Licq -e
                ProxyEnabled = 0
                ProxyServerType = 1
                ProxyServer =
                ProxyServerPort = 0
                ProxyAuthEnabled = 0
                ProxyLogin =
                ProxyPassword =
                UseSS = 0
                
                [onevent]
                Enable = 1
                Command = play
                Message = /usr/share/licq/sounds/icq/Message.wav
                Chat = /usr/share/licq/sounds/icq/Chat.wav
                File = /usr/share/licq/sounds/icq/File.wav
                Url = /usr/share/licq/sounds/icq/URL.wav
                OnlineNotify = /usr/share/licq/sounds/icq/Notify.wav
                SysMsg = /usr/share/licq/sounds/icq/System.wav
                
                [groups]
                NumOfGroups = 3
                DefaultGroup = 0
                NewUserGroup = 1
                Group1.name = New Users
                Group2.name = Friends
                Group3.name = Family
                Group1.id = 0
                Group2.id = 0
                Group3.id = 0
                EOF
      fi
    echo -n > ${OWNER_HISTORY}
#    if test -e ${LICQ_OWNER}
#      then
#        out_owner_uin < ${LICQ_OWNER} >${LICQ_OWNER}.new
#      else
        out_owner_uin >${LICQ_OWNER}.new <<-EOF
                [user]
                Alias = None
                Password =
                Uin = 0
                WebPresence = 0
                HideIP = 0
                History = ${OWNER_HISTORY}
                Groups.System = 0
                Groups.User = 0
                Ip = 0.0.0.0
                IntIp = 0.0.0.0
                Port = 1800
                NewMessages = 0
                LastOnline = 0
                LastSent = 0
                LastRecv = 0
                LastCheckedAR = 0
                AutoAccept = 0
                StatusToUser = 65535
                CustomAutoRsp =
                SendIntIp = 0
                UserEncoding =
                SID = 0
                GSID = 0
                Authorization = 0
                RCG = 0
                SSTime = 0
                SSCount = 0
                AutoResponse =
                EOF
#      fi
    if test -e ${LICQ_QT_GUI}
      then
        out_qt_gui < ${LICQ_QT_GUI} >${LICQ_QT_GUI}.new
      else
        out_qt_gui >${LICQ_QT_GUI}.new <<-EOF
                [appearance]
                Skin = basic
                Icons = computer
                Font = default
                GridLines = 0
                ShowHeader = 1
                ShowOfflineUsers = 1
                ShowDividers = 1
                UseDock = 0
                FontStyles = 1
                NumColumns = 1
                Column1.Title = Alias
                Column1.Format = %a
                Column1.Width = 90
                Column1.Align = 0
                
                [startup]
                Logon = 0
                AutoAway = 5
                AutoNA = 10
                
                [functions]
                AutoClose = 1

                
                [floaties]
                Num = 0
                [locale]
                DefaultEncoding =
                ShowAllEncodings = 0
                EOF
      fi
    test -e ${KXICQ_CONTACTS} && parse_contacts <${KXICQ_CONTACTS}
    test -e ${KXICQ_MESSAGES} && convert_history <${KXICQ_MESSAGES}
    test -e ${KXICQ_CONTACTS} && out_users_conf >${LICQ_USERS}.new
  fi

test_mv ${LICQ_CONF}
test_mv ${LICQ_OWNER}
test_mv ${LICQ_QT_GUI}
test_mv ${LICQ_USERS}

chmod 700 ${LICQ_DIR}
chmod 600 ${LICQ_DIR}/*
chmod 700 ${LICQ_USER_DIR}
chmod 600 ${LICQ_USER_DIR}/*
chmod 700 ${LICQ_HISTORY_DIR}
chmod 600 ${LICQ_HISTORY_DIR}/*
#!/bin/sh
#
#  written by conon <[EMAIL PROTECTED]>
#
#  This script is intended to be run before starting licq
#  It prepares the directory and users setups to that of a
#  current centericq setup
#  just run the script and it will do it all
#

test "${1}" && test "${1}" == "-t" -o "${1}" == "-T" && TESTING="-b .licq"

if test "$TESTING"
  then
    LICQ_DIR=.licq
    CENTER_DIR=.centericq
  else
    LICQ_DIR=~/.licq
    CENTER_DIR=~/.centericq
  fi

LICQ_USER_DIR=${LICQ_DIR}/users
LICQ_HISTORY_DIR=${LICQ_DIR}/history
LICQ_CONF=${LICQ_DIR}/licq.conf
LICQ_OWNER=${LICQ_DIR}/owner.uin
LICQ_QT_GUI=${LICQ_DIR}/licq_qt-gui.conf
LICQ_USERS=${LICQ_DIR}/users.conf
OWNER_HISTORY=${LICQ_HISTORY_DIR}/owner.history

CENTER_RC=${CENTER_DIR}/config
CENTER_MODES=${CENTER_DIR}/modelist

C_UIN="icq_uin"
L_UIN="Uin"
UIN=""
C_PASSWORD="icq_pass"
L_PASSWORD="Password"
PASSWORD=""
C_SERVER="icq_server"
L_SERVER="ICQServer"
SERVER=""
C_SERVER_PORT=""
L_SERVER_PORT="Port"
SERVER_PORT=""

function read_centericq_conf ()
{
  local INBASE
  local INREST
  while read INBASE INREST
    do
      case ${INBASE}
        in
        $C_UIN)      UIN=${INREST};;
        $C_PASSWORD) PASSWORD=${INREST};;
        $C_SERVER)   SERVER=${INREST%%':'*}
                     SERVER_PORT=${INREST##*':'};;
        esac
     done
}

function out_licq_conf ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INBASE=${INSTUFF%%' '*}
      INREST=${INSTUFF##*'='}
      INREST=${INSTUFF##*' '}
      case $INBASE
        in
        L_SERVER) echo "${INBASE} = ${SERVER}";;
        L_PORT)   echo "${INBASE} = ${SERVER_PORT}";;
        *)        echo "${INSTUFF}";;
        esac
    done
}

function out_owner_uin ()
{
  local INSTUFF
  local INBASE
  local INREST
  while read INSTUFF
    do
      INBASE=${INSTUFF%%'='*}
      INBASE=${INSTUFF%%' '*}
      INREST=${INSTUFF##*'='}
      INREST=${INSTUFF##*' '}
      case $INBASE
        in
        "History")     echo "${INBASE} = ${OWNER_HISTORY}";;
        ${L_PASSWORD}) echo "${INBASE} = ${PASSWORD}";;
        ${L_UIN})      echo "${INBASE} = ${UIN}";;
        *)             echo "${INSTUFF}";;
        esac
    done
}

declare -a CONTACTS
CONTACT_COUNT=0

function test_mv ()
{
  if test -e ${1}.new
    then
      test -e ${1} && mv ${1} ${1}.orig
      mv ${1}.new ${1}
    fi
}

declare -a USER_DETAIL
USER_DETAILS=0

function parse_info ()
{
  USER_DETAILS=0
  while read USER_DETAIL[${USER_DETAILS}]
    do
      let USER_DETAILS+=1
    done
}

NEW_USER=0
function user_mode ()
{
  local mode=0
  local name=""
  local uin=""
  local IGNORE=0
  local VISIBLE=0
  local INVISIBLE=0
  while read mode name uin
    do
      if test "${name}" == "${1}" -o "${uin}" == "${1}"
        then
          case ${mode}
            in
            "1") IGNORE=8;;
            "2") VISIBLE=2;;
            "3") INVISIBLE=4;;
            esac
        fi
    done
  let mode=${IGNORE}
  let mode+=${VISIBLE}
  let mode+=${INVISIBLE}
  echo ${mode}
}

function out_user_uin ()
{
  local SYSTEM_GROUPS=0
  SYSTEM_GROUPS=`user_mode ${1} <${CENTER_MODES}`

  cat <<-EOF
        [user]
        History = ${LICQ_HISTORY_DIR}/${1}.history
        Groups.System = ${SYSTEM_GROUPS}
        Groups.User =
        Ip =
        Port =
        NewUser = ${NEW_USER}
        NewMessages =
        LastOnline = ${USER_DETAIL[46]}
        Alias = ${USER_DETAIL[0]}
        FirstName = ${USER_DETAIL[1]}
        LastName = ${USER_DETAIL[2]}
        Email1 = ${USER_DETAIL[5]}
        Email2 =
        City = ${USER_DETAIL[6]}
        State = ${USER_DETAIL[7]}
        PhoneNumber = ${USER_DETAIL[8]}
        FaxNumber = ${USER_DETAIL[9]}
        Address = ${USER_DETAIL[10]}
        CellularNumber = ${USER_DETAIL[11]}
        Zipcode = ${USER_DETAIL[12]}
        Country = ${USER_DETAIL[13]}
        Timezone =
        Authorization =
        HideEmail =
        Age = ${USER_DETAIL[26]}
        Gender = ${USER_DETAIL[27]}
        Homepage = ${USER_DETAIL[29]}
        BirthYear = ${USER_DETAIL[34]}
        BirthMonth = ${USER_DETAIL[33]}
        BirthDay = ${USER_DETAIL[32]}
        Language1 =
        Language2 =
        Language3 =
        CompanyCity = ${USER_DETAIL[14]}
        CompanyState = ${USER_DETAIL[15]}
        CompanyPhoneNumber = ${USER_DETAIL[16]}
        CompanyFaxNumber = ${USER_DETAIL[17]}
        CompanyAddress = ${USER_DETAIL[18]}
        CompanyName = ${USER_DETAIL[21]}
        CompanyDepartment = ${USER_DETAIL[22]}
        CompanyPosition = ${USER_DETAIL[23]}
        CompanyHomepage = ${USER_DETAIL[25]}
        EOF
}

function parse_history_0 ()
{
true
}

function parse_history ()
{
  local INSTUFF
  local LINE_COUNT=0
  local INMESG=false
  local MESSAGE=""
  local CDIR="R"
  local CMND=""
  local TIME=""
  local TESTY="\014"
  local URL=""

#read -r INSTUFF
  while read -r INSTUFF
    do
      INSTUFF=`echo ${INSTUFF} |tr -d "\f\r"`
      if ! test "${INSTUFF}" && ${INMESG}
        then
          echo -e "[ ${CDIR} | ${SUBCMD} | 2046 | 0001 | ${TIME} ]"
          echo -en "${MESSAGE}"
          test "${URL}" && echo -en "${URL}"
          INMESG=false
          LINE_COUNT=0
          MESSAGE=""
          URL=""
        fi
      test "${INSTUFF}" && INMESG=true
      case ${LINE_COUNT}
        in
         "0")    if test "${INSTUFF}" == "OUT" 
                 then
                   CDIR="S"
                 else
                   CDIR="R"
                 fi;;
         "1")     SUBCMD="${INSTUFF}";;
         "2")     TIME="${INSTUFF}";;
         "3")     true;;
         "4")     case "$SUBCMD"
                    in
                    "AUTH") if test "${INSTUFF}" == "1"
                              then
                                SUBCMD="0008"
                              else
                                SUBCMD="0007"
                              fi;;
                    "URL")  URL=":${INSTUFF}"
                                SUBCMD="0004";;
                    *)  MESSAGE="${MESSAGE}:${INSTUFF}\n"
                                SUBCMD="0001";;
                    esac;;
         *)     MESSAGE="${MESSAGE}:${INSTUFF}\n";;
        esac
      test "${INSTUFF}" && let LINE_COUNT+=1
    done 
}

function parse_contacts ()
{
  local UIN
  for DIR in ${CENTER_DIR}/*/
    do
      UIN=${DIR%*'/'}
      UIN=${UIN##${CENTER_DIR}/}
      test "$UIN" == "0" && continue
      CONTACTS[${CONTACT_COUNT}]="${UIN}"
      let CONTACT_COUNT+=1
      if test -e ${DIR}/history
        then
          parse_history <${DIR}/history  >${LICQ_HISTORY_DIR}/${UIN}.history
        else
          echo -n > ${LICQ_HISTORY_DIR}/${UIN}.history
        fi
      if test -e ${DIR}/info
        then
          parse_info <${DIR}/info
        fi
        out_user_uin ${UIN} >${LICQ_USER_DIR}/${UIN}.uin
    done
}

function out_users_conf ()
{
  local TMPCOUNT=0
  local TEMPCOUNT=1
  echo -e "[users]\nNumOfUsers = ${CONTACT_COUNT}"
  while test ${TMPCOUNT} -lt ${CONTACT_COUNT}
    do
      echo "User${TEMPCOUNT} = ${CONTACTS[${TMPCOUNT}]}"
      let TMPCOUNT+=1
      let TEMPCOUNT+=1
    done
}

test -d ${LICQ_DIR} || licq ${TESTING} -I -h >/dev/null 2>&1
if test -e ${CENTER_RC} -a ! -e ${LICQ_OWNER}.orig
  then
    read_centericq_conf < ${CENTER_RC}
    if test -e ${LICQ_CONF}
      then
        out_licq_conf < ${LICQ_CONF} >${LICQ_CONF}.new
      else
        out_licq_conf >${LICQ_CONF}.new <<-EOF
                [licq]
                Version = 1020
                
                [plugins]
                NumPlugins = 1
                Plugin1 = qt-gui
                
                [network]
                AllowNewUsers = 1
                NumOfICQServers = 1
                ICQServer = login.icq.com
                ICQServerPort = 5190
                TCPPortsLow = 0
                TCPPortsHigh = 0
                TCPEnabled = 1
                MaxUsersPerPacket = 100
                IgnoreTypes = 0
                ForegroundColor = 0
                BackgroundColor = 16777215
                Errors = log.errors
                ErrorTypes = 6
                Rejects = log.rejects
                Translation = none
                UrlViewer = viewurl-netscape.sh
                Terminal = xterm -T Licq -e
                ProxyEnabled = 0
                ProxyServerType = 1
                ProxyServer =
                ProxyServerPort = 0
                ProxyAuthEnabled = 0
                ProxyLogin =
                ProxyPassword =
                UseSS = 0
                
                [onevent]
                Enable = 1
                Command = play
                Message = /usr/share/licq/sounds/icq/Message.wav
                Chat = /usr/share/licq/sounds/icq/Chat.wav
                File = /usr/share/licq/sounds/icq/File.wav
                Url = /usr/share/licq/sounds/icq/URL.wav
                OnlineNotify = /usr/share/licq/sounds/icq/Notify.wav
                SysMsg = /usr/share/licq/sounds/icq/System.wav
                
                [groups]
                NumOfGroups = 3
                DefaultGroup = 0
                NewUserGroup = 1
                Group1.name = New Users
                Group2.name = Friends
                Group3.name = Family
                Group1.id = 0
                Group2.id = 0
                Group3.id = 0
                EOF
      fi
    echo -n > ${OWNER_HISTORY}
#    if test -e ${LICQ_OWNER}
#      then
#        out_owner_uin < ${LICQ_OWNER} >${LICQ_OWNER}.new
#      else
        out_owner_uin >${LICQ_OWNER}.new <<-EOF
                [user]
                Alias = None
                Password =
                Uin = 0
                WebPresence = 0
                HideIP = 0
                History = ${OWNER_HISTORY}
                Groups.System = 0
                Groups.User = 0
                Ip = 0.0.0.0
                IntIp = 0.0.0.0
                Port = 1800
                NewMessages = 0
                LastOnline = 0
                LastSent = 0
                LastRecv = 0
                LastCheckedAR = 0
                AutoAccept = 0
                StatusToUser = 65535
                CustomAutoRsp =
                SendIntIp = 0
                UserEncoding =
                SID = 0
                GSID = 0
                Authorization = 0
                RCG = 0
                SSTime = 0
                SSCount = 0
                AutoResponse =
                EOF
#      fi
    parse_contacts
    out_users_conf >${LICQ_USERS}.new
  fi

test_mv ${LICQ_CONF}
test_mv ${LICQ_OWNER}
test_mv ${LICQ_USERS}

chmod 700 ${LICQ_DIR}
chmod 600 ${LICQ_DIR}/*
chmod 700 ${LICQ_USER_DIR}
chmod 600 ${LICQ_USER_DIR}/*
chmod 700 ${LICQ_HISTORY_DIR}
chmod 600 ${LICQ_HISTORY_DIR}/*

Reply via email to