/*ProfiPacket - packet radio terminal program
  Copyright (C) 1999  Alexander Feigl

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Author:

  Alexander Feigl
  Burachstraße 51

  D-88250 Weingarten

  Mail : Alexander.Feigl@gmx.de
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "QSO.h"
#include "Server.h"
#include "GUIMain.h"
#include "Main.h"
#include "global.h"


void SVO_Cleanup(void *Server);
void SVO_AbortServer(void *Server);
int  SVO_AskAudio(void *Server,int effect);
int  SVO_GetServerType(void *Server);

int SERV_AbortFileTransfer(unsigned long channel)
 {
  struct QSO *qso;

  if ( (channel<1) && (channel>MaxChannel) ) return (ERR_SERVER_NOTCONNECTED);

  qso=QSOs+(channel-1);

  if (qso->Server==NULL) return (ERR_SERVER_NOTCONNECTED);
  if (qso->TransferMode==0) return (ERR_SERVER_NOTRANSFER);
  if (qso->OnlyPrepared)
   {
    MAIN_ResetFileTransfer(channel);
    GUI_RedisplayFileTransfer(channel);
    return(0);
   }
  SERV_AbortServer(qso);
  return(0);
 }

void SERV_AbortServer(struct QSO *qso)
 {
  if (qso->Server!=NULL)
   {
    SVO_AbortServer(qso->Server);
   }
 }

void SERV_CleanupServer(struct QSO *qso)
 {
  if (qso->Server!=NULL)
   {
    SVO_Cleanup(qso->Server);
   }
 }

int SERV_AskAudio(struct QSO *qso,int effect)
 {
  int eff;
  eff=effect;
  
  if (qso->Server!=NULL)
   {
    eff=SVO_AskAudio(qso->Server,eff);
   }
  return(eff);
 }



int SERV_GetServerType(struct QSO *qso)
 {
  int st=0;
  if (qso->Server!=NULL)
   {
    st=SVO_GetServerType(qso->Server);
   }
  return(st);
 }

int SERV_IsTopServer(struct QSO *qso)
 {
  if (qso->Server==NULL) return(0);
  if (qso->Server->OldServer==NULL) return(1);
  return(0);
 }