#!/bin/sh
# Copyright 2004-2005 by İsmail Dönmez <ismail@kde.org.tr>

# A script for Konversation to call connectToServer for each instance of Konversation.

url=`echo $1 | sed -e "s,irc://,,"`
server_and_port=`echo $url | sed -e "s,\b/.*,,"`
server=`echo $server_and_port| awk -F":" '{print $1}'`
port=`echo $server_and_port| awk -F":" '{print $2}'`
channel_and_password=`echo $url | awk -F"/" '{print $2}'`
channel=`echo $channel_and_password | awk -F"?" '{print $1}'`
password=`echo $channel_and_password | awk -F"?" '{print $2}'`

if test -z "$port";then port=6667;fi;

if test ! ${channel:0:1} == '#' && test ! -z $channel ;then channel="#"$channel;fi 

if [ `pidof konversation` ]; then
    dcop konversation Konversation connectToServer $server $port "$channel" "$password"
else
    konversation --server $server --port $port --channel "$channel" --password "$password"
fi


