00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MS_HTTP_CLIENT_SESSION_HPP
00018 #define MS_HTTP_CLIENT_SESSION_HPP
00019
00020
00021 #include <string>
00022 #include <vector>
00023
00024 namespace matrix_science
00025 {
00031 class ms_http_client;
00032 class ms_http_client_search;
00033
00035
00046 class MS_MASCOTRESFILE_API ms_http_client_session :
00047 public ms_errors
00048 {
00049 public:
00051
00057 enum SequenceShowOptions
00058 {
00059 SHOW_PI = 0x0001,
00060 SHOW_TITLE = 0x0002,
00061 SHOW_LENGTH = 0x0004,
00062 SHOW_SEQUENCE = 0x0008,
00063 SHOW_REFERENCE = 0x0010,
00064
00065 SHOW_NONE = 0,
00066 SHOW_ALL = 0xFFFF
00067 };
00068
00069
00071 ms_http_client_session();
00072
00074 ms_http_client_session(const ms_http_helper connection, const std::string sessionId);
00075
00077 virtual ~ms_http_client_session();
00078
00079 ms_http_client_session(const ms_http_client_session & src);
00080 #ifndef SWIG
00081 ms_http_client_session& operator=(const ms_http_client_session & right);
00082 #endif
00083 void copyFrom(const ms_http_client_session * right);
00084
00086 std::string getSessionID() const;
00087 std::string sessionId() const { return getSessionID(); }
00088 #ifndef SWIG
00089
00090 bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & returnIsPermitted);
00091 #else // SWIG Multiple return values
00092 bool getIsPermitted(ms_security_tasks::TASKID taskType, bool & OUTPUT);
00093 #endif
00094
00095 #ifndef SWIGCSHARP
00096
00097 bool submitSearch(
00098 ms_http_client_search & returnTask,
00099 const std::string & httpHeader,
00100 const std::string & prologue,
00101 const std::string & filename,
00102 const std::string & epilogue,
00103 ms_http_helper_progress & progress,
00104 bool batch = false);
00105 #else
00106 bool submitSearch(
00107 ms_http_client_search & returnTask,
00108 const std::wstring & httpHeader,
00109 const std::wstring & prologue,
00110 const std::wstring & filename,
00111 const std::wstring & epilogue,
00112 ms_http_helper_progress & progress,
00113 bool batch = false) {
00114 return submitSearchWide(returnTask, httpHeader, prologue, filename, epilogue, progress, batch);
00115 };
00116 #endif
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
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
00152 bool createTask(
00153 ms_http_client_search & returnTask);
00154
00155
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 bool submitSearchWide(
00174 ms_http_client_search & returnTask,
00175 const std::wstring & httpHeader,
00176 const std::wstring & prologue,
00177 const std::wstring & filename,
00178 const std::wstring & epilogue,
00179 ms_http_helper_progress & progress,
00180 bool batch = false
00181 );
00182
00183 ms_http_helper connection_;
00184 std::string sessionId_;
00185
00186 SessionSecurityType security_;
00187 std::string username_;
00188 std::string password_;
00189
00190 bool isLoggedIn_;
00191
00192 friend class ms_http_client;
00193 friend class ms_http_client_search;
00194 };
00195
00197 }
00198
00199 #endif // MS_HTTP_CLIENT_SESSION_HPP
00200
00201