summaryrefslogtreecommitdiffstats
path: root/lskat/lskat/KConnectEntry.cpp
blob: ed926d6d6e6409ece90e0374a202fd5d83fe565d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/***************************************************************************
                          KConnectEntry.cpp  -  description
                             -------------------
    begin                : Tue May 2 2000
    copyright            : (C) 2000 by Martin Heni
    email                : martin@heni-online.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
/***************************************************************************
                          FILENAME|  -  description
                             -------------------
    begin                : Tue Apr 4 2000
    copyright            : (C) |1995-2000 by Martin Heni
    email                : martin@heni-online.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "KConnectEntry.h"

KG_INPUTTYPE KConnectEntry::QueryType()
{
  return type;
}

KRemoteConnect *KConnectEntry::QueryRemoteConnect()
{
  return connect.r;
}

KProcessConnect *KConnectEntry::QueryProcessConnect()
{
  return connect.p;
}

KInteractiveConnect *KConnectEntry::QueryInteractiveConnect()
{
  return connect.i;
}

KR_STATUS KConnectEntry::QuerytqStatus()
{
  switch(type)
  {
      case KG_INPUTTYPE_INTERACTIVE:
        return connect.i->QuerytqStatus();
      break;
      case KG_INPUTTYPE_REMOTE:
        return connect.r->QuerytqStatus();
      break;
      case KG_INPUTTYPE_PROCESS:
        return connect.p->QuerytqStatus();
      break;
    default:  
        return KR_INVALID;
      break;
  }
}
bool KConnectEntry::SendMsg(KEMessage *msg)
{
  switch(type)
  {
      case KG_INPUTTYPE_INTERACTIVE:
        return connect.i->SendMsg(msg);
      break;
      case KG_INPUTTYPE_REMOTE:
        return connect.r->SendMsg(msg);
      break;
      case KG_INPUTTYPE_PROCESS:
        return connect.p->SendMsg(msg);
      break;
    default:  
        return false;
      break;
  }
}

bool KConnectEntry::Exit()
{
  bool result;
  result=FALSE;
  switch(type)
  {
      case KG_INPUTTYPE_INTERACTIVE:
      result=connect.i->Exit();
      delete connect.i;
      break;
      case KG_INPUTTYPE_REMOTE:
      result=connect.r->Exit();
      delete connect.r;
      break;
      case KG_INPUTTYPE_PROCESS:
      result=connect.p->Exit();
      delete connect.p;
      break;
    default:  result=FALSE;
      break;
  }
  return result;
}

bool KConnectEntry::Init(KG_INPUTTYPE stype,int id,KEMessage *msg)
{
  bool result;
  type=stype;
  ID=id;
  switch(stype)
  {
      case KG_INPUTTYPE_INTERACTIVE:
        connect.i=new KInteractiveConnect;
        result=connect.i->Init(id,msg);
      break;
      case KG_INPUTTYPE_REMOTE:
        connect.r=new KRemoteConnect;
        result=connect.r->Init(id,msg);
      break;
      case KG_INPUTTYPE_PROCESS:
        connect.p=new KProcessConnect;
        result=connect.p->Init(id,msg);
      break;
    default: result=FALSE;
      break;
  }
  return result;
}
KConnectEntry::KConnectEntry()
{
  type=(KG_INPUTTYPE)0;
  connect.r=0;
}

KConnectEntry::~KConnectEntry()
{
//  printf("DESTRUCTING KCONNECTENTRY\n");
  Exit(); 
}

KConnectEntry::KConnectEntry(KConnectEntry &msg)
{
  *this=msg;
}
KConnectEntry &KConnectEntry::operator=(KConnectEntry &entry)
{
  // printf("&KConnectEntry::operator=:: I am not sure whether this is really a good idea...\n");
  Init(entry.QueryType(),entry.ID);

  return *this;
}