Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2005 Martin Koegler |
| 2 | * Copyright (C) 2010 TigerVNC Team |
| 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | |
| 20 | #include <rfb/CSecurityStack.h> |
| 21 | |
| 22 | using namespace rfb; |
| 23 | |
| 24 | CSecurityStack::CSecurityStack(int Type, const char*Name, CSecurity* s0, |
| 25 | CSecurity* s1) |
| 26 | :name(Name),type(Type) |
| 27 | { |
| 28 | state = 0; |
| 29 | state0 = s0; |
| 30 | state1 = s1; |
| 31 | } |
| 32 | |
| 33 | CSecurityStack::~CSecurityStack() |
| 34 | { |
| 35 | if (state0) |
| 36 | delete state0; |
| 37 | if (state1) |
| 38 | delete state1; |
| 39 | } |
| 40 | |
| 41 | bool CSecurityStack::processMsg(CConnection* cc) |
| 42 | { |
| 43 | bool res=true; |
| 44 | if (state == 0) { |
| 45 | if (state0) |
| 46 | res = state0->processMsg(cc); |
| 47 | |
| 48 | if (!res) |
| 49 | return res; |
| 50 | |
| 51 | state++; |
| 52 | } |
| 53 | |
| 54 | if (state == 1) { |
| 55 | if(state1) |
| 56 | res = state1->processMsg(cc); |
| 57 | |
| 58 | if(!res) |
| 59 | return res; |
| 60 | |
| 61 | state++; |
| 62 | } |
| 63 | |
| 64 | return res; |
| 65 | } |