git.fiddlerwoaroof.com
conversation.h
7699d7ec
 #ifndef _CONVERSATION_H
 #define _CONVERSATION_H
 
0b6e39a6
 #include <string>
caf7db60
 #include <memory>
0b6e39a6
 
f46fb7b6
 #include "request.h"
2fade7af
 #include "pam.h"
7699d7ec
 
f46fb7b6
 struct conversation_result {
     std::string user_name;
     std::string token;
caf7db60
 };
 
f46fb7b6
 class conversation_ifc
cdf7fd74
 {
 public:
f46fb7b6
     virtual conversation_result initiate (const pam_request &request)
cdf7fd74
     {
f46fb7b6
         return { "", "" };
cdf7fd74
     }
caf7db60
 };
8a15acc6
 
f46fb7b6
 class conversation: public conversation_ifc
cdf7fd74
 {
 private:
f46fb7b6
     std::shared_ptr<conversation_ifc> delegate_;
cdf7fd74
 public:
f46fb7b6
     conversation (const std::shared_ptr<conversation_ifc> &delegate) :
b017a4d2
         delegate_ (delegate) {}
f46fb7b6
     conversation() : conversation (std::shared_ptr<conversation_ifc>
                                        (new conversation_ifc)) {}
     conversation_result initiate (const pam_request &request)
cdf7fd74
     {
f46fb7b6
         return delegate_->initiate (request);
cdf7fd74
     }
8a15acc6
 };
caf7db60
 
f46fb7b6
 inline conversation wrap (conversation_ifc *delegate)
 {
     return conversation (std::shared_ptr<conversation_ifc> (delegate));
 };
 
2fade7af
 conversation create_conversation(pam &pam);
 
7699d7ec
 #endif