login.h

Go to the documentation of this file.
00001 /* vim: set et sw=3 tw=0 fo=croqlaw cino=t0:
00002  *
00003  * Astxx, the Asterisk C++ API and Utility Library.
00004  * Copyright (C) 2005-2007  Matthew A. Nicholson
00005  * Copyright (C) 2005-2007  Digium, Inc.
00006  * 
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License version 2.1 as published by the Free Software Foundation.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00027 #ifndef ASTXX_MANAGER_ACTION_LOGIN_H
00028 #define ASTXX_MANAGER_ACTION_LOGIN_H
00029 
00030 #include <astxx/manager/basic_action.h>
00031 #include <astxx/manager/message.h>
00032 #include <astxx/manager/error.h>
00033 
00034 namespace astxx {
00035    namespace manager {
00036       namespace action {
00040          class login : public basic_action {
00041             public:
00043                class error : public manager::error {
00044                   public:
00045                      explicit error(const std::string& desc) throw() : manager::error(desc) { }
00046                };
00047 
00048             public:
00053                login(const std::string& username, const std::string& secret) : username(username), secret(secret) {
00054                }
00055          
00059                message::action action() const {
00060                   message::action action("Login");
00061                   action["Username"] = username;
00062                   action["Secret"] = secret;
00063                   return action;
00064                }
00065 
00070                message::response handle_response(message::response response) {
00071                   basic_action::handle_response(response);
00072 
00073                   if ("Success" != response) {
00074                      throw login::error(response["Message"]);
00075                   }
00076 
00077                   return response;
00078                }
00079 
00080             private:
00081                std::string username;
00082                std::string secret;
00083          };
00084       }
00085    }
00086 }
00087 
00088 #endif

Generated on Thu Jul 3 01:32:42 2008 for Astxx by  doxygen 1.5.6