"Fossies" - the Fresh Open Source Software Archive

Member "tvnserver-2.0.4/tvnserver-app/TvnServerApplication.cpp" (3 Aug 2011, 2523 Bytes) of archive /windows/misc/tvnserver-2.0.4-src.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "TvnServerApplication.cpp" see the Fossies "Dox" file reference documentation.

    1 // Copyright (C) 2008, 2009, 2010 GlavSoft LLC.
    2 // All rights reserved.
    3 //
    4 //-------------------------------------------------------------------------
    5 // This file is part of the TightVNC software.  Please visit our Web site:
    6 //
    7 //                       http://www.tightvnc.com/
    8 //
    9 // This program is free software; you can redistribute it and/or modify
   10 // it under the terms of the GNU General Public License as published by
   11 // the Free Software Foundation; either version 2 of the License, or
   12 // (at your option) any later version.
   13 //
   14 // This program is distributed in the hope that it will be useful,
   15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17 // GNU General Public License for more details.
   18 //
   19 // You should have received a copy of the GNU General Public License along
   20 // with this program; if not, write to the Free Software Foundation, Inc.,
   21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   22 //-------------------------------------------------------------------------
   23 //
   24 
   25 #include "TvnServerApplication.h"
   26 #include "ServerCommandLine.h"
   27 #include "TvnServerHelp.h"
   28 
   29 #include "thread/GlobalMutex.h"
   30 
   31 #include "util/ResourceLoader.h"
   32 #include "util/StringTable.h"
   33 
   34 #include "tvnserver/resource.h"
   35 
   36 TvnServerApplication::TvnServerApplication(HINSTANCE hInstance, const TCHAR *commandLine)
   37 : WindowsApplication(hInstance), m_tvnServer(0), m_commandLine(commandLine)
   38 {
   39 }
   40 
   41 TvnServerApplication::~TvnServerApplication()
   42 {
   43 }
   44 
   45 int TvnServerApplication::run()
   46 {
   47 
   48   ServerCommandLine parser;
   49 
   50   if (!parser.parse(m_commandLine.getString()) || parser.showHelp()) {
   51     TvnServerHelp::showUsage();
   52     return 0;
   53   }
   54 
   55   GlobalMutex *appInstanceMutex;
   56 
   57   try {
   58     appInstanceMutex = new GlobalMutex(_T("tvnserverApplication"), false, true);
   59   } catch (...) {
   60     MessageBox(0,
   61                StringTable::getString(IDS_SERVER_ALREADY_RUNNING),
   62                StringTable::getString(IDS_MBC_TVNSERVER), MB_OK | MB_ICONEXCLAMATION);
   63     return 1;
   64   }
   65 
   66   m_tvnServer = new TvnServer(false);
   67 
   68   m_tvnServer->addListener(this);
   69 
   70   m_tvnControlRunner = new WsConfigRunner();
   71 
   72   int exitCode = WindowsApplication::run();
   73 
   74   delete m_tvnControlRunner;
   75 
   76   m_tvnServer->removeListener(this);
   77 
   78   delete m_tvnServer;
   79 
   80   delete appInstanceMutex;
   81 
   82   return exitCode;
   83 }
   84 
   85 void TvnServerApplication::onTvnServerShutdown()
   86 {
   87   WindowsApplication::shutdown();
   88 }