#!/bin/sh

# : Locate the place where Qtopia is installed
if [ "$QPEDIR" = "" ]
then
    if [ -d "/opt/Qtopia" ]
    then
	QPEDIR="/opt/Qtopia"
    else
	if [ -d "/opt/QtPalmtop" ]
	then
	    QPEDIR="/opt/QtPalmtop"
	else
	    # err, better quit than doing some damage
	    exit
	fi
    fi
fi

# : Unpack icons
cd $QPEDIR
mkdir -p pics/tkc

if [ -e "tkcicons16x16.tar.gz" ]
then
  mv tkcicons16x16.tar.gz pics/tkc
  cd pics/tkc
  tar xzf tkcicons16x16.tar.gz
  rm tkcicons16x16.tar.gz
  cd $QPEDIR
fi

if [ -e "tkcicons32x32.tar.gz" ]
then
  mv tkcicons32x32.tar.gz pics/tkc
  cd pics/tkc
  tar xzf tkcicons32x32.tar.gz
  rm tkcicons32x32.tar.gz
  cd $QPEDIR
fi

# : Create "theKompany.com" tab if needed
if [ ! -e "$QPEDIR/apps/theKompany.com/.directory" ]
then
  mkdir -p "$QPEDIR/apps/theKompany.com"
  echo -n -e "[Desktop Entry]\nName=theKompany.com\nIcon=tkc\n" > "$QPEDIR/apps/theKompany.com/.directory"
  chmod -R a+rw "$QPEDIR/apps/theKompany.com"
fi
if [ ! -e "$QPEDIR/pics/tkc.png" ]
then
  cp "$QPEDIR/pics/tkc/theKompany.png" "$QPEDIR/pics/tkc.png"
  chmod a+r "$QPEDIR/pics/tkc.png"
fi

# : Add mimetimes
TKCEXP=`/bin/cat "$QPEDIR/etc/mime.types" | /bin/grep "^application/tkcexpense"`
if [ "$PDB" = "" ]
then
    echo -n -e "\napplication/tkcexpense			exp\n" >>"$QPEDIR/etc/mime.types"
fi
