| AnyConnect Secure Mobility Client 5.1.1.42

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# examples/CLI/CLIClientImpl.h

    00001 /******************************************************************************\
    00002  *  This sample is supplied as is with no implied warranty.
    00003  *  It is designed to assist you in using the Cisco AnyConnect VPN API.
    00004  *  It is assumed that you will build a production application and
    00005  *  refer to this sample as a reference only.
    00006  \*****************************************************************************/
    00007
    00008 #ifndef _CLICLIENTIMPL_
    00009 #define _CLICLIENTIMPL_
    00010
    00011 #include <mutex>
    00012 #include <stdio.h>
    00013 #include <stdlib.h>
    00014 #include "ClientIfc.h"
    00015
    00016 enum RequestType
    00017 {
    00018     REQ_CONNECT,
    00019     REQ_GROUPLIST,
    00020     REQ_STATE,
    00021     REQ_STATISTICS,
    00022     REQ_DISCONNECT,
    00023     REQ_END
    00024 };
    00025
    00026 /**
    00027  * This is an example application demonstrating the implementation of the
    00028  * AnyConnect API
    00029  */
    00030
    00031 class CLIClientImpl : public ClientIfc
    00032 {
    00033     public:
    00034
    00035         CLIClientImpl();
    00036         virtual ~CLIClientImpl();
    00037
    00038         // The following methods are for support and not considered part of
    00039         // the main API interface.
    00040
    00041         void printHostList();
    00042
    00043         void printDefaultHost();
    00044
    00045         void connect(std::string host, std::string user,
    00046                      std::string password, std::string group);
    00047
    00048         void disconnect();
    00049
    00050         void showGroups(std::string host);
    00051
    00052         /**
    00053          * This method demonstrates accessing the statistics data delivered
    00054          * via the ClientIfc::StatsCB method.
    00055          */
    00056         void getStats();
    00057
    00058         /**
    00059          * Method with example of parsing ConnectPromptInfo.
    00060          *
    00061          * This method is triggered by an API call on the method
    00062          * UserPromptCB(ConnectPromptInfo &).
    00063          */
    00064         void setUserData(ConnectPromptInfo &ConnectPrompt);
    00065
    00066         void printGroupList(ConnectPromptInfo &ConnectPrompt);
    00067
    00068         std::wstring convertMultiByteToWide(const std::string &sInputData);
    00069
    00070         void EventAvailable();
    00071         void ProcessEvents();
    00072
    00073         void SetRequestType(RequestType e_RequestType);
    00074
    00075     protected:
    00076
    00077         void StatsCB(VPNStats &stats);
    00078
    00079         void StateCB(const VPNState state,
    00080                      const VPNSubState subState,
    00081                      const tstring stateString);
    00082
    00083         void BannerCB(const tstring &banner);
    00084
    00085         void PreConnectReminderCB(const tstring &rtstrPreConnectReminder);
    00086
    00087         void NoticeCB(const tstring &notice,
    00088                       const MessageType type,
    00089                       const bool bSensitive = false);
    00090
    00091         void ExitNoticeCB(const tstring &notice,
    00092                           const int returnCode);
    00093
    00094         void ServiceReadyCB();
    00095
    00096         void UserPromptCB(ConnectPromptInfo &ConnectPrompt);
    00097
    00098         void CertBlockedCB(const tstring &rtstrUntrustedServer);
    00099         void CertWarningCB(const tstring &rtstrUntrustedServer,
    00100                            const std::list<tstring> &rltstrCertErrors,
    00101                            bool bAllowImport);
    00102
    00103
    00104     private:
    00105
    00106         RequestType me_RequestType;
    00107
    00108         tstring ms_user,
    00109                 ms_pswd,
    00110                 ms_group;
    00111
    00112         std::mutex mtx;
    00113         volatile bool mb_exit;
    00114         volatile bool mb_eventAvailable;
    00115         bool mb_ConnectingStateReceived;
    00116 };
    00117
    00118
    00119 #endif // _CLICLIENTIMPL_