Matrix Science header

ms_http_client_session.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_http_client_session.hpp                                                #
00004 # 'msparser' toolkit                                                         #
00005 # Represents a session on a Mascot server                                    #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2013 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011  * @(#)$Source: /vol/cvsroot/parser/inc/ms_http_client_session.hpp,v $
00012  * @(#)$Revision: 1.8 $
00013  * @(#)$Date: 2016/05/19 16:07:07 $
00014 ##############################################################################
00015  */
00016 
00017 #ifndef MS_HTTP_CLIENT_SESSION_HPP
00018 #define MS_HTTP_CLIENT_SESSION_HPP
00019 
00020 #ifdef _WIN32
00021 #pragma warning(disable:4251)   // Don't want all classes to be exported
00022 #pragma warning(disable:4786)   // Debug symbols too long
00023 #   ifndef _MATRIX_USE_STATIC_LIB
00024 #       ifdef MS_MASCOTRESFILE_EXPORTS
00025 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00026 #       else
00027 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00028 #       endif
00029 #   else
00030 #       define MS_MASCOTRESFILE_API
00031 #   endif
00032 #else
00033 #   define MS_MASCOTRESFILE_API
00034 #endif
00035 
00036 #include <string>
00037 #include <vector>
00038 
00039 namespace matrix_science
00040 {
00046     class ms_http_client;
00047     class ms_http_client_search;
00048 
00050 
00061     class MS_MASCOTRESFILE_API ms_http_client_session :
00062         public ms_errors
00063     {
00064         public:
00066 
00072             enum SequenceShowOptions
00073             {
00074                 SHOW_PI = 0x0001, 
00075                 SHOW_TITLE = 0x0002, 
00076                 SHOW_LENGTH = 0x0004, 
00077                 SHOW_SEQUENCE = 0x0008, 
00078                 SHOW_REFERENCE = 0x0010, 
00079 
00080                 SHOW_NONE = 0, 
00081                 SHOW_ALL = 0xFFFF 
00082             };
00083 
00084 
00086             ms_http_client_session();
00087 
00089             ms_http_client_session(const ms_http_helper connection, const std::string sessionId);
00090 
00092             virtual ~ms_http_client_session();
00093 
00094             ms_http_client_session(const ms_http_client_session & src);
00095 #ifndef SWIG
00096             ms_http_client_session& operator=(const ms_http_client_session & right);
00097 #endif
00098             void copyFrom(const ms_http_client_session * right);
00099 
00101             std::string getSessionID() const;
00102             std::string sessionId() const { return getSessionID(); }   // Deprecated. Released with 2.5.2
00103 
00105             bool getIsPermitted(
00106                     ms_security_tasks::TASKID taskType,
00107                     bool & returnIsPermitted);
00108 
00110             bool submitSearch(
00111                     ms_http_client_search & returnTask,
00112                     const std::string & httpHeader,
00113                     const std::string & prologue,
00114                     const std::string & filename,
00115                     const std::string & epilogue,
00116                     ms_http_helper_progress & progress);
00117 
00119             bool getSequenceFile(
00120                     const std::string & database,
00121                     const std::vector<std::string> & accessionNames,
00122                     const std::vector<int> & accessionFrames,
00123                     const std::string & filename,
00124                     const SequenceShowOptions options = SHOW_ALL
00125                     );
00126 
00128             bool logout();
00129 
00131             bool getIsXmlUploadedList(const std::vector<std::string> & taskIds, std::vector<int> & xmlUploaded);
00132 
00133         private:
00134 
00135             // type of login for the session to allow re-login if session has expired
00136             enum SessionSecurityType {
00137                 SECURITY_NONE,
00138                 SECURITY_DISABLED,
00139                 SECURITY_GUEST,
00140                 SECURITY_WEB,
00141                 SECURITY_USER
00142             };
00143 
00144             ms_http_client_session(
00145                     ms_http_helper connection,
00146                     std::string sessionId,
00147                     SessionSecurityType security,
00148                     const std::string & username = "",
00149                     const std::string & password = "");
00150 
00151             // Create a new Mascot task attached to this Mascot session.
00152             bool createTask(
00153                     ms_http_client_search & returnTask);
00154 
00155             // http functions to be used by the task class to re-try is Mascot session has expired
00156             bool httpGetString(const std::string & action, std::string & result);
00157             bool httpGetResponseUsingSessionId(const std::string & action, ms_http_helper_response & response);
00158             bool httpGetFileUsingSessionId(
00159                     const std::string & action,
00160                     const std::string & filename,
00161                     ms_http_helper_progress & progress,
00162                     ms_http_helper::FileMode fileMode = ms_http_helper::FM_binary);
00163             bool httpPostFileAppendingSessionId(
00164                     const std::string & action,
00165                     const std::string & httpHeader,
00166                     const std::string & prologue,
00167                     const std::string & filename,
00168                     const std::string & epilogue,
00169                     ms_http_helper_handles & handles,
00170                     ms_http_helper_progress & progress);
00171             bool relogin();
00172 
00173             ms_http_helper connection_;
00174             std::string sessionId_;
00175 
00176             SessionSecurityType security_;
00177             std::string username_;
00178             std::string password_;
00179 
00180             bool isLoggedIn_;
00181 
00182         friend class ms_http_client; // access to private constructor used when logging in
00183         friend class ms_http_client_search; // access to useful getString and getFile functions
00184     };
00185  // end of http_client_group
00187 } // namespace matrix_science
00188 
00189 #endif // MS_HTTP_CLIENT_SESSION_HPP
00190 
00191 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51