From 2606d1287ae09ef666063e3696d51666755d8618 Mon Sep 17 00:00:00 2001 From: anderson.peterle@previdencia.gov.br Date: Tue, 22 Dec 2009 14:56:08 +0000 Subject: [PATCH] ajuste de versoes de arquivos e produtos --- srcacic/RFB/rfbproto.h | 7 +++++++ srcacic/VNCViewer/ClientConnection.cpp | 20 ++++++++++++++++++-- srcacic/VNCViewer/Res/vncviewer.rc | 19 ++++++++++--------- srcacic/VNCViewer/SessionDialog.h | 2 +- srcacic/VNCViewer/VNCViewer.vcproj | 296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------- srcacic/WinVNC/WinVNC/CACIC_Auth.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ srcacic/WinVNC/WinVNC/CACIC_Auth.h | 45 +++++++++------------------------------------ srcacic/WinVNC/WinVNC/CACIC_Crypt.cpp | 50 ++++++++++++++++++++++++++++---------------------- srcacic/WinVNC/WinVNC/CACIC_Crypt.h | 12 ++++-------- srcacic/WinVNC/WinVNC/CACIC_Utils.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- srcacic/WinVNC/WinVNC/CACIC_Utils.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- srcacic/WinVNC/WinVNC/Res/on-line_logo.bmp | Bin 6854 -> 0 bytes srcacic/WinVNC/WinVNC/WinVNC.vcproj | 332 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------- srcacic/WinVNC/WinVNC/resource.h | 7 ++++++- srcacic/WinVNC/WinVNC/supInfoDlg.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- srcacic/WinVNC/WinVNC/supInfoDlg.h | 6 ++++++ srcacic/WinVNC/WinVNC/vncListDlg.cpp | 2 ++ srcacic/WinVNC/WinVNC/vncPassDlg.cpp | 38 ++++++++++++++++++++++++++++++++++---- srcacic/WinVNC/WinVNC/vncPassDlg.h | 14 +++----------- srcacic/WinVNC/WinVNC/vncacceptdialog.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ srcacic/WinVNC/WinVNC/vncclient.cpp | 22 +++++++++++++++------- srcacic/WinVNC/WinVNC/vnclog.cpp | 22 +++++++++++++++++----- srcacic/WinVNC/WinVNC/vnclog.h | 5 +++++ srcacic/WinVNC/WinVNC/vncserver.cpp | 3 +-- srcacic/WinVNC/WinVNC/winvnc.cpp | 8 +++++--- srcacic/WinVNC/WinVNC/winvnc.rc | 32 +++++++++++++++++--------------- 26 files changed, 841 insertions(+), 483 deletions(-) diff --git a/srcacic/RFB/rfbproto.h b/srcacic/RFB/rfbproto.h index 8f146ce..1fffa75 100644 --- a/srcacic/RFB/rfbproto.h +++ b/srcacic/RFB/rfbproto.h @@ -289,6 +289,7 @@ typedef struct { /* client -> server */ +#define rfbNoLogout 100 #define rfbSetPixelFormat 0 #define rfbFixColourMapEntries 1 /* not currently supported */ #define rfbSetEncodings 2 @@ -877,6 +878,11 @@ typedef struct { * *****************************************************************************/ +typedef struct { + CARD8 type; +} rfbNoLogoutMsg; + +#define sz_rfbNoLogoutMsg 3 /*----------------------------------------------------------------------------- * SetPixelFormat - tell the RFB server the format in which the client wants @@ -1091,6 +1097,7 @@ typedef struct _rfbSetSWMsg { typedef union { CARD8 type; + rfbNoLogoutMsg nl; rfbSetPixelFormatMsg spf; rfbFixColourMapEntriesMsg fcme; rfbSetEncodingsMsg se; diff --git a/srcacic/VNCViewer/ClientConnection.cpp b/srcacic/VNCViewer/ClientConnection.cpp index 33ece6a..752f919 100644 --- a/srcacic/VNCViewer/ClientConnection.cpp +++ b/srcacic/VNCViewer/ClientConnection.cpp @@ -69,7 +69,8 @@ extern "C" { #include // sf@2002 -#include "CACIC_Crypt.h" +#include "../WinVNC/WinVNC/CACIC_Crypt.h" +#include "../WinVNC/WinVNC/CACIC_Utils.h" // [v1.0.2-jp1 fix] #pragma comment(lib, "imm32.lib") @@ -1802,7 +1803,7 @@ void ClientConnection::NegotiateProtocolVersion() m_fServerKnowsFileTransfer = true; }*/ - else if ((m_majorVersion == 15) && (m_minorVersion < 17)) { + else if ((m_majorVersion == 3) && (m_minorVersion < 3)) { /* if server is 3.2 we can't use the new authentication */ vnclog.Print(0, _T("Can't use IDEA authentication\n")); @@ -5666,6 +5667,19 @@ LRESULT CALLBACK ClientConnection::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, // 8 April 2008 jdp hide window while shutting down ::ShowWindow(hwnd, SW_HIDE); + + // TODO: quando o cliente é removido pelo servidor ou cai, a janela sobre o logout aparece assim mesmo. + if (_this->m_running) { + int doLogout = MessageBox(hwnd, "Deseja efetuar logout na máquina remota?", "srCACICcli", MB_YESNO); + if (doLogout == IDNO) { + // CACIC: Envia mensagem dizendo que o servidor deve efetuar o logout. + rfbNoLogoutMsg nl; + nl.type = rfbNoLogout; + + _this->WriteExact((char *)&nl, sz_rfbNoLogoutMsg, rfbNoLogout); + } + } + // Close the worker thread _this->KillThread(); @@ -5690,6 +5704,7 @@ LRESULT CALLBACK ClientConnection::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, _this->SuspendThread(); _this->Reconnect(); } + return 0; } @@ -6379,6 +6394,7 @@ LRESULT CALLBACK ClientConnection::WndProchwnd(HWND hwnd, UINT iMsg, WPARAM wPar // 8 April 2008 jdp ::ShowWindow(hwnd, SW_HIDE); + // Close the worker thread as well _this->KillThread(); diff --git a/srcacic/VNCViewer/Res/vncviewer.rc b/srcacic/VNCViewer/Res/vncviewer.rc index 3100d3a..fa560c6 100644 --- a/srcacic/VNCViewer/Res/vncviewer.rc +++ b/srcacic/VNCViewer/Res/vncviewer.rc @@ -535,8 +535,8 @@ IDB_VNC32 BITMAP "vnc32.BMP" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,5,0,804 - PRODUCTVERSION 2,5,0,804 + FILEVERSION 2,5,9,0 + PRODUCTVERSION 2,6,0,0 FILEFLAGSMASK 0x37L #ifdef _DEBUG FILEFLAGS 0x25L @@ -549,20 +549,21 @@ VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "000004b0" + BLOCK "080004b0" BEGIN - VALUE "CompanyName", "Dataprev - Unidade Regional Espírito Santo" - VALUE "FileDescription", "Visualizador do Suporte Remoto Seguro do Sistema CACIC" - VALUE "FileVersion", "2, 5, 0, 804" + VALUE "Comments", "Licença: GNU/LGPL" + VALUE "CompanyName", "Dataprev-Emp. de TI da Prev Social - UDSL/SSLC" + VALUE "FileDescription", "Sistema CACIC - Módulo Cliente para Suporte Remoto Seguro" + VALUE "FileVersion", "2.5.9.0" VALUE "InternalName", "srCACICcli" VALUE "LegalCopyright", "Copyright © 2008 DATAPREV" - VALUE "LegalTrademarks", "srCACIC" - VALUE "ProductVersion", "2, 5, 0, 804" + VALUE "ProductName", "srCACIC" + VALUE "ProductVersion", "2.6.0.0" END END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x0, 1200 + VALUE "Translation", 0x800, 1200 END END diff --git a/srcacic/VNCViewer/SessionDialog.h b/srcacic/VNCViewer/SessionDialog.h index 63e543f..d3588ef 100644 --- a/srcacic/VNCViewer/SessionDialog.h +++ b/srcacic/VNCViewer/SessionDialog.h @@ -29,7 +29,7 @@ #include "MRU.h" #include -class SessionDialog +class SessionDialog { public: diff --git a/srcacic/VNCViewer/VNCViewer.vcproj b/srcacic/VNCViewer/VNCViewer.vcproj index 558ead3..100e353 100644 --- a/srcacic/VNCViewer/VNCViewer.vcproj +++ b/srcacic/VNCViewer/VNCViewer.vcproj @@ -117,9 +117,9 @@ /> + +#include "vncPassDlg.h" + +#include "CACIC_Con.h" +#include "CACIC_Crypt.h" +#include "CACIC_Exception.h" +#include "CACIC_Utils.h" + const string CACIC_Auth::GET_CONFIG_SCRIPT = "srcacic_get_config.php"; const string CACIC_Auth::SET_SESSION_SCRIPT = "srcacic_set_session.php"; const string CACIC_Auth::AUTH_CLIENT_SCRIPT = "srcacic_auth_client.php"; const unsigned int CACIC_Auth::TAMANHO_RESPOSTA = 1025; const string CACIC_Auth::AGUARDE_FILENAME = "aguarde_srCACIC.txt"; const string CACIC_Auth::COOKIE_FILENAME = "cacic_ck.txt"; -const UINT CACIC_Auth::TEMPO_IDLE = 5; +const UINT CACIC_Auth::TEMPO_IDLE = 15; bool CACIC_Auth::autentica() { @@ -93,7 +102,7 @@ bool CACIC_Auth::autenticaUsuario(vector &listaDominios) bool CACIC_Auth::validaTecnico(char nm_usuario_cli[], char te_senha_cli[], char te_node_address_cli[], char te_documento_referencial[], char te_motivo_conexao[], char te_so_cli[], - const vncClientId vncCID, const char peerName[]) + const short vncCID, const char peerName[]) { string post = getPostComum(); @@ -122,6 +131,7 @@ bool CACIC_Auth::validaTecnico(char nm_usuario_cli[], char te_senha_cli[], char if (!verificaAuthTecnico(resposta, te_node_address_cli, te_documento_referencial, te_motivo_conexao, te_so_cli, vncCID, peerName)) { + m_efetuarLogout = false; return false; } @@ -135,26 +145,20 @@ bool CACIC_Auth::verificaAuthChave(char resposta[], vector &listaDomini if (!verificaStatus(resposta)) throw SRCException("Falha na verificação da chave!"); string dominios; - dominios = CACIC_Utils::leTag(resposta, "SERVIDORES_AUTENTICACAO"); + CACIC_Utils::leTag(resposta, "SERVIDORES_AUTENTICACAO", dominios); string dominios_dec; dominios_dec = CACIC_Crypt::decodifica(dominios.c_str()); - char* dominios_dec_str = (char*)malloc(sizeof(char)*(dominios_dec.length() + 1)); - string::traits_type::copy(dominios_dec_str, dominios_dec.c_str(), dominios_dec.length() + 1); - char* id_dominio = strtok(dominios_dec_str, ";"); - char* nm_dominio = strtok(NULL, ";"); - - while (id_dominio != NULL) - { - listaDominios.push_back(Dominio(id_dominio, nm_dominio)); + stringstream dominiosStream(dominios_dec); + string id_dominio; + string nm_dominio; - id_dominio = strtok(NULL, ";"); - nm_dominio = strtok(NULL, ";"); + while (getline(dominiosStream, id_dominio, ';') && + getline(dominiosStream, nm_dominio, ';')) + { + listaDominios.push_back(Dominio(id_dominio, nm_dominio)); } - delete dominios_dec_str; - delete id_dominio; - delete nm_dominio; if (listaDominios.empty()) throw SRCException("A lista de domínios está vazia."); @@ -175,13 +179,13 @@ bool CACIC_Auth::verificaAuthDominio(char resposta[]) if (!verificaStatus(resposta)) return false;//throw SRCException("Falha na autenticação do usuário."); string nm_completo; - nm_completo = CACIC_Utils::leTag(resposta, "NM_COMPLETO"); + CACIC_Utils::leTag(resposta, "NM_COMPLETO", nm_completo); string nome_dec; nome_dec.append(CACIC_Crypt::decodifica(nm_completo.c_str())); string id_sessao; - id_sessao = CACIC_Utils::leTag(resposta, "ID_SESSAO"); + CACIC_Utils::leTag(resposta, "ID_SESSAO", id_sessao); m_usuario = nome_dec; m_idSessao = id_sessao; @@ -197,12 +201,12 @@ bool CACIC_Auth::verificaAuthDominio(char resposta[]) } bool CACIC_Auth::verificaAuthTecnico(char resposta[], char te_node_address_cli[], char te_documento_referencial[], - char te_motivo_conexao[], char te_so_cli[], const vncClientId vncCID, const char peerName[]) + char te_motivo_conexao[], char te_so_cli[], const short vncCID, const char peerName[]) { try { string status; - status = CACIC_Utils::leTag(resposta, "STATUS"); + CACIC_Utils::leTag(resposta, "STATUS", status); string status_dec; status_dec = CACIC_Crypt::decodifica(status.c_str()); @@ -212,16 +216,16 @@ bool CACIC_Auth::verificaAuthTecnico(char resposta[], char te_node_address_cli[] if (status_dec.compare("OK") != 0) throw SRCException(status_dec.c_str()); string id_usuario_cli; - id_usuario_cli = CACIC_Utils::leTag(resposta, "ID_USUARIO_CLI"); + CACIC_Utils::leTag(resposta, "ID_USUARIO_CLI", id_usuario_cli); string id_conexao; - id_conexao = CACIC_Utils::leTag(resposta, "ID_CONEXAO"); + CACIC_Utils::leTag(resposta, "ID_CONEXAO", id_conexao); string nm_usuario_completo; - nm_usuario_completo = CACIC_Utils::leTag(resposta, "NM_USUARIO_COMPLETO"); + CACIC_Utils::leTag(resposta, "NM_USUARIO_COMPLETO", nm_usuario_completo); string dt_hr_inicio_sessao; - dt_hr_inicio_sessao = CACIC_Utils::leTag(resposta, "DT_HR_INICIO_SESSAO"); + CACIC_Utils::leTag(resposta, "DT_HR_INICIO_SESSAO", dt_hr_inicio_sessao); string nm_usuario_completo_dec; nm_usuario_completo_dec.append(CACIC_Crypt::decodifica(nm_usuario_completo.c_str())); @@ -262,7 +266,7 @@ bool CACIC_Auth::verificaAuthTecnico(char resposta[], char te_node_address_cli[] } catch(SRCException ex) { - MessageBox(NULL, ex.getMessage().c_str(), "Erro!", MB_OK | MB_ICONERROR); + //MessageBox(NULL, ex.getMessage().c_str(), "Erro!", MB_OK | MB_ICONERROR); vnclog.Print(LL_SRLOG, VNCLOG(ex.getMessage().c_str())); return false; } @@ -313,10 +317,13 @@ void CACIC_Auth::atualizaSessao() { listaIDUsuario += m_listaClientes[i].id_usuario_visitante; if (i < m_listaClientes.size() - 1) listaIDUsuario += ""; + listaIDConexao += m_listaClientes[i].id_conexao; if (i < m_listaClientes.size() - 1) listaIDConexao += ""; + listaNodeAddress += m_listaClientes[i].te_node_address_visitante; if (i < m_listaClientes.size() - 1) listaNodeAddress += ""; + listaID_SO += m_listaClientes[i].te_so_visitante; if (i < m_listaClientes.size() - 1) listaID_SO += ""; } @@ -364,7 +371,7 @@ void CACIC_Auth::sendChatText(char te_mensagem[], char cs_origem[]) post += "id_sessao="; post += m_idSessao; post += "&id_conexao="; - post += m_novoCliente.id_conexao; + post += m_novoCliente.id_conexao; post += "&te_mensagem="; post += te_mensagem_enc; post += "&cs_origem="; @@ -377,24 +384,35 @@ void CACIC_Auth::sendChatText(char te_mensagem[], char cs_origem[]) CACIC_Con::sendHtppPost(m_servidorWeb, session_script, post, resposta, TAMANHO_RESPOSTA); } -void CACIC_Auth::removeCliente(vncClientId vncCID) +void CACIC_Auth::removeCliente(short vncCID) { // Atualiza a sessão antes de remover o cliente. atualizaSessao(); - m_infoDlg.closeInfoDialog(); for (int i = 0; i < m_listaClientes.size(); i++) { if (m_listaClientes[i].vncCID == vncCID) { m_listaClientes.erase(m_listaClientes.begin() + i); - return; + break; } } // Apagando os dados do último cliente conectado. ClienteSRC novoCliente = {0}; m_novoCliente = novoCliente; + + if (m_efetuarLogout == true) { + // Envia uma mensagem para o diáligo, dizendo para ele + // trocar o label que é mostrado. + PostMessage(m_infoDlg.hwInfoDlg, WM_LOGOUT_WARNING, 0, 0); + + Sleep(20000); + CACIC_Auth::getInstance()->finalizaServidor(); + ExitWindowsEx(EWX_LOGOFF | EWX_FORCE, 0); + } + m_infoDlg.closeInfoDialog(); + m_efetuarLogout = true; } string CACIC_Auth::getPostComum() @@ -413,7 +431,7 @@ string CACIC_Auth::getPostComum() bool CACIC_Auth::verificaStatus(char resposta[]) { string status; - status = CACIC_Utils::leTag(resposta, "STATUS"); + CACIC_Utils::leTag(resposta, "STATUS", status); string status_dec; status_dec = CACIC_Crypt::decodifica(status.c_str()); diff --git a/srcacic/WinVNC/WinVNC/CACIC_Auth.h b/srcacic/WinVNC/WinVNC/CACIC_Auth.h index a2c5b8f..1013d9a 100644 --- a/srcacic/WinVNC/WinVNC/CACIC_Auth.h +++ b/srcacic/WinVNC/WinVNC/CACIC_Auth.h @@ -7,45 +7,12 @@ #ifndef _CACIC_AUTH_ #define _CACIC_AUTH_ -#include "stdhdrs.h" - #include -using namespace std; -#include #include using namespace std; -#include - -#include "vncPassDlg.h" #include "supInfoDlg.h" -#include "CACIC_Con.h" -#include "CACIC_Crypt.h" -#include "CACIC_Exception.h" -#include "CACIC_Utils.h" - -#include "vncClient.h" - -/** - * Struct referente a um usuário cliente. - */ -struct ClienteSRC { - vncClientId vncCID; - string peerName; - string id_usuario_visitante; - string id_usuario_cli; - string id_conexao; - string nm_usuario_completo; - string te_node_address_visitante; - string te_node_address_cli; - string te_documento_referencial; - string te_motivo_conexao; - string te_so_visitante; - string te_so_cli; - string dt_hr_inicio_sessao; -}; - class CACIC_Auth { public: @@ -73,6 +40,11 @@ public: */ supInfoDlg m_infoDlg; + /** + * Variável de decisão sobre o logout do sistema após o suporte. + */ + bool m_efetuarLogout; + /** Singleton. */ static CACIC_Auth* getInstance() { @@ -107,7 +79,7 @@ public: * @param vncCID ID do cliente VNC, utilizado para * diferenciar os clientes, caso haja mais de um. */ - void removeCliente(vncClientId vncCID); + void removeCliente(short vncCID); /** * Faz a comunicação com o gerente web para validar a palavra chave @@ -130,7 +102,7 @@ public: */ bool validaTecnico(char nm_usuario_cli[], char te_senha_cli[], char te_node_address_cli[], char te_documento_referencial[], char te_motivo_conexao[], char te_so_cli[], - const vncClientId vncCID, const char peerName[]); + const short vncCID, const char peerName[]); /** * Se comunica com o gerente web para atualizar a sessão de suporte. @@ -154,6 +126,7 @@ private: CACIC_Auth() { m_idleTime = TEMPO_IDLE; + m_efetuarLogout = true; } virtual ~CACIC_Auth() {} @@ -229,7 +202,7 @@ private: */ bool verificaAuthTecnico(char resposta[], char te_node_address_cli[], char te_documento_referencial[], char te_motivo_conexao[], char te_so_cli[], - const vncClientId vncCID, const char peerName[]); + const short vncCID, const char peerName[]); /** * Verifica o valor de retorno STATUS que é enviado pelo gerente web diff --git a/srcacic/WinVNC/WinVNC/CACIC_Crypt.cpp b/srcacic/WinVNC/WinVNC/CACIC_Crypt.cpp index d95310b..0c9d13f 100644 --- a/srcacic/WinVNC/WinVNC/CACIC_Crypt.cpp +++ b/srcacic/WinVNC/WinVNC/CACIC_Crypt.cpp @@ -6,6 +6,13 @@ #include "CACIC_Crypt.h" +#include "CACIC_Utils.h" + +#include + +#include "Rijndael.h" +#include "base64.h" + const unsigned int CACIC_Crypt::SRCACIC_BLOCK_SIZE = 16; const unsigned int CACIC_Crypt::SRCACIC_KEY_SIZE = 16; const char CACIC_Crypt::SRCACIC_KEY[17] = "CacicBrasil"; @@ -20,41 +27,40 @@ string CACIC_Crypt::decodifica(const char* entrada) decode_base64 = base64_decode(entradaStr); - unsigned int saida_len = decode_base64.length(); + const unsigned int saidaLen = decode_base64.length(); - char* saida = new char[saida_len + 1]; - memset(saida, 0, saida_len + 1); + const unsigned int buffLen = saidaLen + 1; + char* saidaBuff = new char[buffLen]; + memset(saidaBuff, 0, buffLen); CRijndael oRijndael; oRijndael.MakeKey(SRCACIC_KEY, SRCACIC_IV, SRCACIC_KEY_SIZE, SRCACIC_BLOCK_SIZE); - oRijndael.Decrypt(decode_base64.c_str(), saida, saida_len, CRijndael::CBC); + oRijndael.Decrypt(decode_base64.c_str(), saidaBuff, saidaLen, CRijndael::CBC); - string out(saida); - - delete []saida; - return out; + string saida = string(saidaBuff); + delete []saidaBuff; + return saida; } string CACIC_Crypt::codifica(const char* entrada) { - unsigned int entrada_len = strlen(entrada); - unsigned int saida_len = (int)ceil((float)(entrada_len)/SRCACIC_BLOCK_SIZE)*SRCACIC_BLOCK_SIZE; + const unsigned int entradaLen = strlen(entrada); + const unsigned int saidaLen = (int)ceil((float)(entradaLen)/SRCACIC_BLOCK_SIZE)*SRCACIC_BLOCK_SIZE; - char* saida = new char[saida_len + 1]; - memset(saida, 0, saida_len + 1); - char* zerof_entrada = new char[saida_len + 1]; - memset(zerof_entrada, 0, saida_len + 1); + const unsigned int buffLen = saidaLen + 1; + char* saidaBuff = new char[buffLen]; + memset(saidaBuff, 0, buffLen); + char* zerofEntrada = new char[buffLen]; + memset(zerofEntrada, 0, buffLen); - strncpy(zerof_entrada, entrada, entrada_len); + strncpy(zerofEntrada, entrada, entradaLen); CRijndael oRijndael; oRijndael.MakeKey(SRCACIC_KEY, SRCACIC_IV, SRCACIC_KEY_SIZE, SRCACIC_BLOCK_SIZE); - oRijndael.Encrypt(zerof_entrada, saida, saida_len, CRijndael::CBC); - - string encode_base64; - encode_base64 = base64_encode(reinterpret_cast(saida), saida_len); + oRijndael.Encrypt(zerofEntrada, saidaBuff, saidaLen, CRijndael::CBC); - delete []saida; - delete []zerof_entrada; - return encode_base64; + string saida = base64_encode(reinterpret_cast(saidaBuff), saidaLen); + delete []saidaBuff; + delete []zerofEntrada; + return saida; } diff --git a/srcacic/WinVNC/WinVNC/CACIC_Crypt.h b/srcacic/WinVNC/WinVNC/CACIC_Crypt.h index c8f4cc7..4c39fd3 100644 --- a/srcacic/WinVNC/WinVNC/CACIC_Crypt.h +++ b/srcacic/WinVNC/WinVNC/CACIC_Crypt.h @@ -7,12 +7,8 @@ #ifndef _CACIC_CRYPT_ #define _CACIC_CRYPT_ -#include - -#include "CACIC_Utils.h" - -#include "Rijndael.h" -#include "base64.h" +#include +using namespace std; class CACIC_Crypt { @@ -22,14 +18,14 @@ public: * Remove da String de entrada os caracteres colocados pela URLEncode, * tira do Base64 e depois decodifica usando o Rijndael. * @param entrada String a ser decodificada. - * @return string String decodificada. + * @param saida String decodificada. */ static string decodifica(const char* entrada); /** * Codifica a String passada com o algoritmo Rijndael e coloca no Base64. * @param entrada String a ser codificada. - * @return string String codificada. + * @param saida String codificada. */ static string codifica(const char* entrada); diff --git a/srcacic/WinVNC/WinVNC/CACIC_Utils.cpp b/srcacic/WinVNC/WinVNC/CACIC_Utils.cpp index ed5c647..897ae94 100644 --- a/srcacic/WinVNC/WinVNC/CACIC_Utils.cpp +++ b/srcacic/WinVNC/WinVNC/CACIC_Utils.cpp @@ -6,13 +6,25 @@ #include "CACIC_Utils.h" +#include +#pragma comment(lib, "iphlpapi.lib") + +#include + +#include +#include + +#include "CACIC_Exception.h" + const string CACIC_Utils::F_SANS_SERIF = "Microsoft Sans Serif"; -string CACIC_Utils::leTag(char xml[], char tagname[]) +void CACIC_Utils::leTag(char xml[], char tagname[], string &conteudo) { - char* tag; - char* a_xml = new char[strlen(xml)]; + // 1 posição maior por causa do null character + const int xmlLen = strlen(xml) + 1; + char* a_xml = new char[xmlLen]; strcpy(a_xml, xml); + char* tag; // pega o conteudo da tag de resposta tagname tag = strtok(a_xml, "<>"); @@ -21,17 +33,16 @@ string CACIC_Utils::leTag(char xml[], char tagname[]) tag = strtok(NULL, "<>"); } - string errorMsg = "Falha ao ler arquivo xml."; + string errorMsg = "Falha na comunicação com o módulo Gerente WEB."; //string errorMsg = "Tag "; //errorMsg.append(tagname); //errorMsg.append(" não encontrada!"); if (tag == NULL) throw SRCException(errorMsg); tag = strtok(NULL, "<>"); - string content; - content = tag; - - return content; + + conteudo = string(tag); + delete a_xml; } void CACIC_Utils::replaceAll(string &str, string key, string newkey) @@ -162,3 +173,107 @@ void CACIC_Utils::changeFont(HWND dlgHandle, int dlgItem, int fontSize, string f SendMessage(GetDlgItem(dlgHandle, dlgItem), WM_SETFONT, (int)hFont, MAKELONG(TRUE, 0)); } + +//void tokenize(const string &str, vector &tokens, const string &delimiters) +//{ +// string::size_type lastPos = str.find_first_not_of(delimiters, 0); +// string::size_type pos = str.find_first_of(delimiters, lastPos); +// +// while (string::npos != pos || string::npos != lastPos) +// { +// tokens.push_back(str.substr(lastPos, pos - lastPos)); +// +// lastPos = str.find_first_not_of(delimiters, pos); +// pos = str.find_first_of(delimiters, lastPos); +// } +//} + +string CACIC_Utils::getMACAddress() { + + IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information for up to 16 NICs + DWORD dwBufLen = sizeof(AdapterInfo); // Save the memory size of buffer + + DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo + AdapterInfo, // [out] buffer to receive data + &dwBufLen); // [in] size of receive data buffer + //assert(dwStatus == ERROR_SUCCESS); // Verify return value is valid, no buffer overflow + + PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info + //do { + // PrintMACaddress(pAdapterInfo->Address); // Print MAC address + // pAdapterInfo = pAdapterInfo->Next; // Progress through linked list + //} while(pAdapterInfo); // Terminate if last adapter + + char mac[18]; + + sprintf(mac, "%02X-%02X-%02X-%02X-%02X-%02X", + pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2], + pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5]); + + string macstr = mac; + + return macstr; + +} + +string CACIC_Utils::getSOID() { + OSVERSIONINFO osver; + ZeroMemory(&osver, sizeof(OSVERSIONINFO)); + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osver); + + std::stringstream spid; + std::stringstream smajorv; + std::stringstream sminorv; + std::stringstream csd; + + std::string soIDStr; + + spid << osver.dwPlatformId; + soIDStr = spid.str(); + smajorv << osver.dwMajorVersion; + soIDStr += "."; + soIDStr += smajorv.str(); + sminorv << osver.dwMinorVersion; + soIDStr += "."; + soIDStr += sminorv.str(); + + int major; + smajorv >> major; + int minor; + sminorv >> minor; + if (major <= 4) + {// Win95 Win98 WinME + if (minor == 0 || minor == 10 || minor == 90) + { + if (osver.szCSDVersion != NULL) + { + csd << osver.szCSDVersion; + soIDStr += "."; + soIDStr += csd.str(); + } + } + } + else + {// Win2K acima + OSVERSIONINFOEX osverex; + ZeroMemory(&osverex, sizeof(OSVERSIONINFOEX)); + osverex.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + GetVersionEx((LPOSVERSIONINFOA) &osverex); + + soIDStr += "."; + switch (osverex.wProductType) + { + case VER_NT_WORKSTATION: soIDStr += "1"; break; + case VER_NT_DOMAIN_CONTROLLER: soIDStr += "2"; break; + case VER_NT_SERVER: soIDStr += "3"; break; + } + + std::stringstream scsd; + scsd << osverex.wSuiteMask; + soIDStr += "."; + soIDStr += scsd.str(); + } + + return soIDStr; +} diff --git a/srcacic/WinVNC/WinVNC/CACIC_Utils.h b/srcacic/WinVNC/WinVNC/CACIC_Utils.h index 26050ab..d70395d 100644 --- a/srcacic/WinVNC/WinVNC/CACIC_Utils.h +++ b/srcacic/WinVNC/WinVNC/CACIC_Utils.h @@ -9,10 +9,38 @@ #include using namespace std; -#include -#include -#include "CACIC_Exception.h" +#include "windows.h" + +/** + * Struct referente a um usuário cliente. + */ +struct ClienteSRC { + short vncCID; + string peerName; + string id_usuario_visitante; + string id_usuario_cli; + string id_conexao; + string nm_usuario_completo; + string te_node_address_visitante; + string te_node_address_cli; + string te_documento_referencial; + string te_motivo_conexao; + string te_so_visitante; + string te_so_cli; + string dt_hr_inicio_sessao; +}; + +/** + * Struct referente a um domínio de autenticação. + */ +struct Dominio { + Dominio(string p_id, string p_nome) : id(p_id), nome(p_nome) {} + Dominio() : id(""), nome("") {} + Dominio(const Dominio& d) : id(d.id), nome(d.nome) {} + string id; + string nome; +}; class CACIC_Utils { @@ -25,10 +53,10 @@ public: * Método bruto para ler uma tag específica de um arquivo xml. * @param xml String no formato de arquivo xml. * @param tagname String com o nome da tag a ser pesquisada. - * @return String com o conteúdo da tag pesquisada. + * @param conteudo String com o conteúdo da tag pesquisada. * @trows CACIC_Exception caso a tag não seja encontrada. */ - static string leTag(char xml[], char tagname[]); + static void leTag(char xml[], char tagname[], string &conteudo); /** * Troca caracteres específicos de uma string. @@ -90,6 +118,30 @@ public: int fontSize, string fontName, bool fontIsBold = false); + /** + * Método para separar a string em partes delimitadas por um, ou um conjunto, + * de caracteres. + * @param str String a ser tokenizada. + * @param tokens Vetor de saída dos tokens gerados. + * @param delimiters Delimitadores que serão usados para separar a string. + * @note http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-7.html + */ + //static void tokenize(const string &str, vector &tokens, const string &delimiters = " "); + + /** + * Obtém o MAC Address da placa de rede.
+ * TODO: Quando houver mais de uma placa de rede no pc, verificar qual + * está se comunicando com o servidor para enviar o MAC certo. + */ + static string getMACAddress(); + + /** + * Obtém a identificação do sistema operacional.
+ * Artigo sobre SOID:
+ * http://www.codeguru.com/cpp/w-p/system/systeminformation/article.php/c8973__2/ + */ + static string getSOID(); + private: /** diff --git a/srcacic/WinVNC/WinVNC/Res/on-line_logo.bmp b/srcacic/WinVNC/WinVNC/Res/on-line_logo.bmp index b5171af..fc3c73d 100644 Binary files a/srcacic/WinVNC/WinVNC/Res/on-line_logo.bmp and b/srcacic/WinVNC/WinVNC/Res/on-line_logo.bmp differ diff --git a/srcacic/WinVNC/WinVNC/WinVNC.vcproj b/srcacic/WinVNC/WinVNC/WinVNC.vcproj index fdd6fbd..8e4fb0e 100644 --- a/srcacic/WinVNC/WinVNC/WinVNC.vcproj +++ b/srcacic/WinVNC/WinVNC/WinVNC.vcproj @@ -116,9 +116,9 @@ />
+ + hwInfoDlg = hwnd; vrsBkColor = CreateSolidBrush(RGB(255, 255, 160)); + ShowWindow(GetDlgItem(hwnd, IDC_ATENCAO_STATIC), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_AVISO_SUPORTE), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_NOME_LBL), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_IP_LBL), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_INICIO_LBL), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_DOC_LBL), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_NOME), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_IP), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_INICIO), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_REFERENCIA), TRUE); + ShowWindow(GetDlgItem(hwnd, IDC_AVISO_LOGOUT), FALSE); + // Fazendo o diálogo ficar transparente. // Fonte: http://weseetips.com/2008/10/07/how-to-set-transparent-dialogs/ LONG ExtendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); @@ -100,6 +114,47 @@ BOOL CALLBACK supInfoDlg::supInfoDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP } break; + // Timer event + case WM_TIMER: + { + _this->m_timeoutCount--; + + // Update the displayed count + char temp[256]; + sprintf(temp, "ATENÇÃO: O sistema efetuará logout em %u segundos!", (_this->m_timeoutCount)); + SetDlgItemText(hwnd, IDC_AVISO_LOGOUT, temp); + } + break; + + case WM_LOGOUT_WARNING: + { + // Fazendo o diálogo ficar opaco novamente. + // Fonte: http://weseetips.com/2008/10/07/how-to-set-transparent-dialogs/ + LONG ExtendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLong(hwnd, GWL_EXSTYLE, ExtendedStyle | WS_EX_LAYERED); + double TransparencyPercentage = 100.0; + double fAlpha = TransparencyPercentage * (255.0 /100); + BYTE byAlpha = static_cast(fAlpha); + SetLayeredWindowAttributes(hwnd, 0, byAlpha, LWA_ALPHA); + + CACIC_Utils::changeFont(hwnd, IDC_AVISO_LOGOUT, 26, CACIC_Utils::F_SANS_SERIF, true); + + ShowWindow(GetDlgItem(hwnd, IDC_ATENCAO_STATIC), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_AVISO_SUPORTE), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_NOME_LBL), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_IP_LBL), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_INICIO_LBL), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_DOC_LBL), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_NOME), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_IP), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_INICIO), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_INFO_REFERENCIA), FALSE); + ShowWindow(GetDlgItem(hwnd, IDC_AVISO_LOGOUT), TRUE); + + SetTimer(hwnd, 1, 1000, NULL); + } + break; + case WM_COMMAND: { switch (LOWORD(wParam)) @@ -125,8 +180,12 @@ BOOL CALLBACK supInfoDlg::supInfoDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP HDC hdc = (HDC)wParam; HWND hwndStatic = (HWND)lParam; - SetBkMode(hdc, TRANSPARENT); - return (LRESULT)vrsBkColor; + if (hwndStatic == GetDlgItem(hwnd, IDC_AVISO_LOGOUT)) + { + SetTextColor(hdc, RGB(255, 0, 0)); + //SetBkMode(hdc, TRANSPARENT); + //return (BOOL)GetStockObject(NULL_BRUSH); + } /*if (hwndStatic == GetDlgItem(hwnd, IDC_AVISO_SUPORTE)) { @@ -138,6 +197,9 @@ BOOL CALLBACK supInfoDlg::supInfoDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP SetBkMode(hdc, TRANSPARENT); return (LRESULT)vrsBkColor; }*/ + + SetBkMode(hdc, TRANSPARENT); + return (LRESULT)vrsBkColor; } break; diff --git a/srcacic/WinVNC/WinVNC/supInfoDlg.h b/srcacic/WinVNC/WinVNC/supInfoDlg.h index 27e8899..319da18 100644 --- a/srcacic/WinVNC/WinVNC/supInfoDlg.h +++ b/srcacic/WinVNC/WinVNC/supInfoDlg.h @@ -12,6 +12,8 @@ using namespace std; #include "CACIC_Utils.h" +#define WM_LOGOUT_WARNING 1001 + #pragma once class supInfoDlg { @@ -28,6 +30,10 @@ public: string m_dataInicio; string m_documentoReferencia; + int m_timeoutCount; + + HWND hwInfoDlg; + private: HANDLE m_hInfoDlgThread; diff --git a/srcacic/WinVNC/WinVNC/vncListDlg.cpp b/srcacic/WinVNC/WinVNC/vncListDlg.cpp index 977c072..0721d88 100644 --- a/srcacic/WinVNC/WinVNC/vncListDlg.cpp +++ b/srcacic/WinVNC/WinVNC/vncListDlg.cpp @@ -135,6 +135,8 @@ BOOL CALLBACK vncListDlg::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM if (nSelected != LB_ERR) { char szClient[128]; + // CACIC: + CACIC_Auth::getInstance()->m_efetuarLogout = false; if (SendMessage(hList, LB_GETTEXT, nSelected, (LPARAM)szClient) > 0) _this->m_pServer->KillClient(szClient); } diff --git a/srcacic/WinVNC/WinVNC/vncPassDlg.cpp b/srcacic/WinVNC/WinVNC/vncPassDlg.cpp index aadcefa..238826e 100644 --- a/srcacic/WinVNC/WinVNC/vncPassDlg.cpp +++ b/srcacic/WinVNC/WinVNC/vncPassDlg.cpp @@ -54,7 +54,14 @@ BOOL CALLBACK vncPassDlg::vncAuthDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP switch (uMsg) { + /** Os cases desse switch se referem as mensagens de notificação lançadas + por processos de threads.*/ + case WM_INITDIALOG: + /** Case 1: Case de construção da janela de Autenticação. É um estado + estático. Aqui a primeira janela de dialogo do suporte remoto é + montada. De acordo com as respostas obtidas pela interação do usuario, + essa janela é tambem aqui, reformulada.*/ { // Save the lParam into our user data so that subsequent calls have // access to the parent C++ object @@ -91,7 +98,7 @@ BOOL CALLBACK vncPassDlg::vncAuthDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP } if (_this->m_authStat == vncPassDlg::FALHA_AUTENTICACAO) - { + { // Mensagem da faixa na cor vermelha, informando falha. msgBkColor = CreateSolidBrush(RGB(242, 0, 28)); SendMessage(hDominios, CB_SELECTSTRING, 0, (LPARAM) _this->m_listaDominios.at(_this->m_indiceDominio).nome.c_str()); @@ -101,7 +108,7 @@ BOOL CALLBACK vncPassDlg::vncAuthDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP SetDlgItemText(hwnd, IDC_MSG, (LPSTR) "Falha na Autenticação!"); } else if (_this->m_authStat == vncPassDlg::AUTENTICADO) - { + { // Mensagem da faixa na cor verde, validando o suporte. msgBkColor = CreateSolidBrush(RGB(102, 255, 0)); SendMessage(hDominios, CB_SELECTSTRING, 0, (LPARAM) _this->m_listaDominios.at(_this->m_indiceDominio).nome.c_str()); @@ -116,13 +123,18 @@ BOOL CALLBACK vncPassDlg::vncAuthDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP EnableWindow( hSenha, FALSE ); SetDlgItemText( hwnd, IDC_MSG, (LPSTR)_this->m_msgInfo.c_str() ); - } + //Lança um timeout sobre o botao de OK, confirmando a autenticação. + _this->m_timeoutPassDlg = (UINT)5; + SetTimer(hwnd,1,1000,NULL); + } return TRUE; } break; case WM_COMMAND: + /** Case 2: Estado dinâmico interativo, onde os comandos são captados e exibidos + em tempo de uso.*/ { switch (LOWORD(wParam)) { @@ -163,7 +175,25 @@ BOOL CALLBACK vncPassDlg::vncAuthDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP } } break; - + + case WM_TIMER: + /** Case 3: Estado de detecção de um timeout. Ele verifica que um timeout + ocorreu em algum momento e a partir dele, toma as devidas ações.*/ + { + //Atualiza a Mensagem no botão de OK da janela de Autenticação. + char temp[256]; + sprintf(temp, "OK [%u]", (_this->m_timeoutPassDlg)); + SetDlgItemText(hwnd, ID_POK, temp); + + /** Fecha a janela de autenticação "clicando automaticamente + no botao OK".*/ + if (!(_this->m_timeoutPassDlg)) EndDialog(hwnd, ID_POK); + _this->m_timeoutPassDlg--; + } + break; + + /** Case 4: Estado de atualização da janela. De acordo com a interação + com o menu, os campos mudam de layout, se tornando transparentes.*/ case WM_CTLCOLORSTATIC: { HDC hdc = (HDC)wParam; diff --git a/srcacic/WinVNC/WinVNC/vncPassDlg.h b/srcacic/WinVNC/WinVNC/vncPassDlg.h index 9ec865b..880ec51 100644 --- a/srcacic/WinVNC/WinVNC/vncPassDlg.h +++ b/srcacic/WinVNC/WinVNC/vncPassDlg.h @@ -23,17 +23,6 @@ using namespace std; #pragma once -/** - * Struct referente a um domínio de autenticação. - */ -struct Dominio { - Dominio(string p_id, string p_nome) : id(p_id), nome(p_nome) {} - Dominio() : id(""), nome("") {} - - string id; - string nome; -}; - class vncPassDlg { public: @@ -54,6 +43,9 @@ public: EAuthCode m_authStat; string m_msgInfo; + // Campo extra para fazer o timeout da janela! + UINT m_timeoutPassDlg; + BOOL DoDialog(); private: diff --git a/srcacic/WinVNC/WinVNC/vncacceptdialog.cpp b/srcacic/WinVNC/WinVNC/vncacceptdialog.cpp index 500e77b..6693503 100644 --- a/srcacic/WinVNC/WinVNC/vncacceptdialog.cpp +++ b/srcacic/WinVNC/WinVNC/vncacceptdialog.cpp @@ -37,6 +37,9 @@ // [v1.0.2-jp1 fix] Load resouce from dll extern HINSTANCE hInstResDLL; +DWORD WINAPI makeWndBlink(LPVOID lParam); +HANDLE isWindowActivated = 0; + // Constructor vncAcceptDialog::vncAcceptDialog(UINT timeoutSecs,BOOL acceptOnTimeout, const char *ipAddress) @@ -149,6 +152,18 @@ BOOL CALLBACK vncAcceptDialog::vncAcceptDlgProc(HWND hwnd, // Beep MessageBeep(MB_ICONEXCLAMATION); + + // Faz a janela piscar na barra de tarefas + PFLASHWINFO fhwInfo = new FLASHWINFO(); + fhwInfo->cbSize = sizeof (FLASHWINFO); + fhwInfo->dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG; + fhwInfo->dwTimeout = 1000; + fhwInfo->hwnd = hwnd; + fhwInfo->uCount = 60; + FlashWindowEx(fhwInfo); + + DWORD threadID; + CreateThread(NULL, 0, makeWndBlink, (LPVOID) hwnd, 0, &threadID); // Return success! return TRUE; @@ -207,6 +222,10 @@ BOOL CALLBACK vncAcceptDialog::vncAcceptDlgProc(HWND hwnd, break; + case WM_ACTIVATE: + case WM_MOUSEACTIVATE: + SetEvent(isWindowActivated); + break; // Window is being destroyed! (Should never happen) case WM_DESTROY: EndDialog(hwnd, IDREJECT); @@ -215,3 +234,29 @@ BOOL CALLBACK vncAcceptDialog::vncAcceptDlgProc(HWND hwnd, return 0; } +DWORD WINAPI makeWndBlink(LPVOID lParam) { + HWND hwnd = (HWND) lParam; + int percentage = 100; + int flip = -1; + isWindowActivated = CreateEvent(0, FALSE, FALSE, 0); + + while (WaitForSingleObject(isWindowActivated, 10)) { + if (percentage == 25) { + flip = 1; + } else if (percentage == 100) { + flip = -1; + Sleep(1000); + } + percentage += (1 * flip); + + LONG ExtendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLong(hwnd, GWL_EXSTYLE, ExtendedStyle | WS_EX_LAYERED); + double TransparencyPercentage = (double) percentage; + double fAlpha = TransparencyPercentage * (255.0 /100); + BYTE byAlpha = static_cast(fAlpha); + SetLayeredWindowAttributes(hwnd, 0, byAlpha, LWA_ALPHA); + } + SetLayeredWindowAttributes(hwnd, 0, static_cast(100 * (255.0 /100)), LWA_ALPHA); + + return 0; +} diff --git a/srcacic/WinVNC/WinVNC/vncclient.cpp b/srcacic/WinVNC/WinVNC/vncclient.cpp index 17f1ecf..2e7f5a5 100644 --- a/srcacic/WinVNC/WinVNC/vncclient.cpp +++ b/srcacic/WinVNC/WinVNC/vncclient.cpp @@ -609,8 +609,8 @@ vncClientThread::InitAuthenticate() // TODO: aqui é o local provável para o recebimento do usuario e senha do técnico. vnclog.Print(LL_INTINFO, "password authentication"); - // Tirando o timeout do socket para esperar o cliente enviar as informações do técnico. - if (!m_socket->SetTimeout(0)) + // Alterando o timeout para que o cliente tenha tempo de enviar as informações do técnico. + if (!m_socket->SetTimeout(60000)) vnclog.Print(LL_INTERR, VNCLOG("failed to set socket timeout(%d)\n"), GetLastError()); // Lê o username @@ -634,7 +634,7 @@ vncClientThread::InitAuthenticate() if (!m_socket->ReadExact(te_so_cli, sizeof(te_so_cli))) return FALSE; - // Colocando o timeout denovo. + // Voltando o timeout ao normal. if (!m_socket->SetTimeout(30000)) vnclog.Print(LL_INTERR, VNCLOG("failed to set socket timeout(%d)\n"), GetLastError()); @@ -1059,7 +1059,6 @@ vncClientThread::run(void *arg) if (!InitVersion()) { m_server->RemoveClient(m_client->GetClientId()); - CACIC_Auth::getInstance()->removeCliente(m_client->GetClientId()); // wa@2005 - AutoReconnection attempt if required if (m_server->AutoReconnect()) @@ -1073,7 +1072,6 @@ vncClientThread::run(void *arg) if (!InitAuthenticate()) { m_server->RemoveClient(m_client->GetClientId()); - CACIC_Auth::getInstance()->removeCliente(m_client->GetClientId()); return; } CACIC_Auth::getInstance()->m_infoDlg.showInfoDialog(); @@ -1153,13 +1151,11 @@ vncClientThread::run(void *arg) if (!m_socket->SendExact((char *)&server_ini, sizeof(server_ini))) { m_server->RemoveClient(m_client->GetClientId()); - CACIC_Auth::getInstance()->removeCliente(m_client->GetClientId()); return; } if (!m_socket->SendExact(desktopname, strlen(desktopname))) { m_server->RemoveClient(m_client->GetClientId()); - CACIC_Auth::getInstance()->removeCliente(m_client->GetClientId()); return; } vnclog.Print(LL_INTINFO, VNCLOG("sent pixel format to client\n")); @@ -1185,6 +1181,11 @@ vncClientThread::run(void *arg) // added jeff BOOL need_to_disable_input = m_server->LocalInputsDisabled(); bool need_to_clear_keyboard = true; + + // TODO CACIC tirando o timeout do socket. Quando o chat está aberto sem mensagens, + // não há fluxo no socket, fazendo com que ele de timeout, + if (!m_socket->SetTimeout(0)) + vnclog.Print(LL_INTERR, VNCLOG("failed to set socket timeout(%d)\n"), GetLastError()); while (connected) { rfbClientToServerMsg msg; @@ -1237,6 +1238,10 @@ vncClientThread::run(void *arg) switch(msg.type) { + case rfbNoLogout: + CACIC_Auth::getInstance()->m_efetuarLogout = false; + break; + case rfbSetPixelFormat: // Read the rest of the message: if (!m_socket->ReadExact(((char *) &msg)+nTO, sz_rfbSetPixelFormatMsg-nTO)) @@ -2674,6 +2679,9 @@ vncClientThread::run(void *arg) } } + // TODO CACIC voltando o timeout ao normal + if (!m_socket->SetTimeout(30000)) + vnclog.Print(LL_INTERR, VNCLOG("failed to set socket timeout(%d)\n"), GetLastError()); // Move into the thread's original desktop // TAG 14 diff --git a/srcacic/WinVNC/WinVNC/vnclog.cpp b/srcacic/WinVNC/WinVNC/vnclog.cpp index 68093f0..48d7734 100644 --- a/srcacic/WinVNC/WinVNC/vnclog.cpp +++ b/srcacic/WinVNC/WinVNC/vnclog.cpp @@ -185,10 +185,9 @@ inline void VNCLog::ReallyPrintLine(const char* line) struct tm ts; char data_buf[20]; - // Formata a data, "ddd yyyy-mm-dd hh:mm:ss zzz" ts = *localtime(&now); - strftime(data_buf, sizeof(data_buf), "%Y-%m-%d %H:%M:%S", &ts); - + strftime(data_buf, sizeof(data_buf), "%d/%m %X", &ts); + if (m_toscript) enviaLog(data_buf, (char*)line, SCRIPT); // ADICIONADO if (m_todebug) OutputDebugString(line); if (m_toconsole) { @@ -196,9 +195,21 @@ inline void VNCLog::ReallyPrintLine(const char* line) WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), line, strlen(line), &byteswritten, NULL); }; if (m_tofile && (hlogfile != NULL)) { + string strLine; + strLine.append(data_buf); + strLine.append(" : "); + strLine.append("[Suporte Remoto]"); + //if (/*Verificar modo DEBUG!*/){ + // strLine.append(" ("); + // strLine.append(/*Funcao de retorno da Versao: v.2.6.0.0*/); + // strLine.append(")"); + // strLine.append(" DEBUG -"); + //} + strLine.append(" "); + strLine.append(line); DWORD byteswritten; - WriteFile(hlogfile, line, strlen(line), &byteswritten, NULL); - } + WriteFile(hlogfile, strLine.c_str(), strLine.length(), &byteswritten, NULL); + } } void VNCLog::ReallyPrint(const char* format, va_list ap) @@ -226,6 +237,7 @@ void VNCLog::ReallyPrint(const char* format, va_list ap) ReallyPrintLine(line); } + VNCLog::~VNCLog() { if (m_filename != NULL) diff --git a/srcacic/WinVNC/WinVNC/vnclog.h b/srcacic/WinVNC/WinVNC/vnclog.h index ce7e907..c74d78d 100644 --- a/srcacic/WinVNC/WinVNC/vnclog.h +++ b/srcacic/WinVNC/WinVNC/vnclog.h @@ -84,6 +84,11 @@ public: // the log mode includes ToFile void SetFile(const char* filename, bool append = false); + /** + * Verifica a existencia do diretorio debugs. + */ + + virtual ~VNCLog(); private: diff --git a/srcacic/WinVNC/WinVNC/vncserver.cpp b/srcacic/WinVNC/WinVNC/vncserver.cpp index 1820d6d..25900f1 100644 --- a/srcacic/WinVNC/WinVNC/vncserver.cpp +++ b/srcacic/WinVNC/WinVNC/vncserver.cpp @@ -131,7 +131,7 @@ vncServer::vncServer() m_querysetting = 4; m_queryaccept = 0; - m_querytimeout = 30; + m_querytimeout = 60; m_retry_timeout = 0; // Autolock settings @@ -994,7 +994,6 @@ vncServer::RemoveClient(vncClientId clientid) // Notify anyone interested of the change DoNotify(WM_SRV_CLIENT_DISCONNECT, 0, 0); - vnclog.Print(LL_INTINFO, VNCLOG("RemoveClient() done\n")); } diff --git a/srcacic/WinVNC/WinVNC/winvnc.cpp b/srcacic/WinVNC/WinVNC/winvnc.cpp index b5cb93c..6ef9e13 100644 --- a/srcacic/WinVNC/WinVNC/winvnc.cpp +++ b/srcacic/WinVNC/WinVNC/winvnc.cpp @@ -47,6 +47,8 @@ #include "vncOSVersion.h" #include "videodriver.h" +#include "CACIC_Crypt.h" + FILE *pFile; MMRESULT mmCRes; // Allocating and initializing GlobalClass's @@ -195,8 +197,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, strcat(WORKDIR,"srCACIC.log"); vnclog.SetFile(WORKDIR, true); - vnclog.SetMode(VNCLog::ToScript); - vnclog.SetLevel(LL_SRLOG); + vnclog.SetMode(VNCLog::ToFile); + vnclog.SetLevel(LL_ALL); #ifdef _DEBUG { @@ -296,7 +298,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, CACIC_Auth::getInstance()->setTimeout(timeout); if (CACIC_Auth::getInstance()->autentica()) { - iniciaTimer(); + iniciaTimer(); // inicia o timer de atualização da sessão if (!Myinit(hInstance)) return 0; return WinVNCAppMain(); } diff --git a/srcacic/WinVNC/WinVNC/winvnc.rc b/srcacic/WinVNC/WinVNC/winvnc.rc index e671df9..6eb8b5c 100644 --- a/srcacic/WinVNC/WinVNC/winvnc.rc +++ b/srcacic/WinVNC/WinVNC/winvnc.rc @@ -117,15 +117,16 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN CTEXT "ESTAÇÃO DE TRABALHO EM SUPORTE REMOTO",IDC_AVISO_SUPORTE,54,12,205,11 CTEXT "ATENÇÃO",IDC_ATENCAO_STATIC,54,2,205,10 - LTEXT "Nome:",IDC_STATIC,54,22,24,8 - LTEXT "IP:",IDC_STATIC,54,32,10,8 - LTEXT "Início:",IDC_STATIC,54,42,20,8 + LTEXT "Nome:",IDC_NOME_LBL,54,22,24,8 + LTEXT "IP:",IDC_IP_LBL,54,32,10,8 + LTEXT "Início:",IDC_INICIO_LBL,54,42,20,8 LTEXT "",IDC_INFO_NOME,78,23,181,8,0,WS_EX_TRANSPARENT LTEXT "",IDC_INFO_IP,78,32,181,8,0,WS_EX_TRANSPARENT LTEXT "",IDC_INFO_INICIO,78,41,181,8,0,WS_EX_TRANSPARENT - LTEXT "Doc. Referência:",IDC_STATIC_INFO_REF,54,51,57,8 + LTEXT "Doc. Referência:",IDC_DOC_LBL,54,51,57,8 LTEXT "",IDC_INFO_REFERENCIA,111,51,148,8 CONTROL 163,IDC_SRCACIC_IMG,"Static",SS_BITMAP,0,0,54,62 + CTEXT "ATENÇÃO: O sistema efetuará logout em 20 segundos!",IDC_AVISO_LOGOUT,54,2,205,58,NOT WS_VISIBLE,WS_EX_TRANSPARENT END @@ -222,8 +223,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,5,0,804 - PRODUCTVERSION 2,5,0,804 + FILEVERSION 2,5,9,0 + PRODUCTVERSION 2,6,0,0 FILEFLAGSMASK 0x37L #ifdef _DEBUG FILEFLAGS 0x25L @@ -236,20 +237,21 @@ VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "000004b0" + BLOCK "080004b0" BEGIN - VALUE "CompanyName", "Dataprev - Unidade Regional Espírito Santo" - VALUE "FileDescription", "Módulo Suporte Remoto Seguro do Sistema CACIC" - VALUE "FileVersion", "2, 5, 0, 804" + VALUE "Comments", "Licença: GNU/LGPL" + VALUE "CompanyName", "Dataprev-Emp. de TI da Prev Social - UDSL/SSLC" + VALUE "FileDescription", "Sistema CACIC - Módulo Suporte Remoto Seguro" + VALUE "FileVersion", "2.5.9.0" VALUE "InternalName", "srCACICsrv" VALUE "LegalCopyright", "Copyright © 2008 DATAPREV" - VALUE "LegalTrademarks", "srCACIC" - VALUE "ProductVersion", "2, 5, 0, 804" + VALUE "ProductName", "srCACIC" + VALUE "ProductVersion", "2.6.0.0" END END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x0, 1200 + VALUE "Translation", 0x800, 1200 END END @@ -393,7 +395,7 @@ BEGIN DEFPUSHBUTTON "OK",ID_POK,55,130,50,13 PUSHBUTTON "Cancelar",ID_PCANCELAR,117,130,50,13 COMBOBOX IDC_DOMAIN_CB,84,59,83,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CTEXT "v2.5.0.804",IDC_AUTHDLG_VERSION,187,145,36,8,SS_CENTERIMAGE,WS_EX_STATICEDGE + CTEXT "v2.6.0.0",IDC_AUTHDLG_VERSION,187,145,36,8,SS_CENTERIMAGE,WS_EX_STATICEDGE CTEXT "Por favor, preencha as informações solicitadas abaixo, para a autenticação de seu usuário.",IDC_AUTH_INFO,3,38,216,18 EDITTEXT IDC_MSG,3,111,216,17,ES_CENTER | ES_MULTILINE | ES_READONLY | NOT WS_BORDER CTEXT "ATENÇÃO: Esta autenticação, que precede a abertura de sessão para suporte remoto, atribui ao usuário a total responsabilidade por todo e qualquer tipo de dano lógico à estação que porventura seja causado por acesso externo indevido.",IDC_ATT_MSG,3,3,216,33 @@ -409,7 +411,7 @@ BEGIN EDITTEXT IDC_USER_EDIT,69,58,83,12,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",ID_POK,45,76,45,13 PUSHBUTTON "Cancelar",ID_PCANCELAR,102,76,45,13 - CTEXT "v2.5.0.804",IDC_AUTHDLG_VERSION,159,90,36,8,SS_CENTERIMAGE,WS_EX_STATICEDGE + CTEXT "v2.6.0.0",IDC_AUTHDLG_VERSION,159,90,36,8,SS_CENTERIMAGE,WS_EX_STATICEDGE CTEXT "Por favor, digite seu nome no campo abaixo.",IDC_AUTH_INFO,3,46,188,10 CTEXT "ATENÇÃO: Esta autenticação, que precede a abertura de sessão para suporte remoto, atribui ao usuário a total responsabilidade por todo e qualquer tipo de dano lógico à estação que porventura seja causado por acesso externo indevido.",IDC_ATT_MSG,3,3,188,40 END -- libgit2 0.21.2