basic_action.cc

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 
00021 #include <astxx/manager/connection.h>
00022 #include <astxx/manager/basic_action.h>
00023 #include <astxx/manager/message.h>
00024 #include <astxx/manager/error.h>
00025 
00026 namespace astxx {
00027    namespace manager {
00048       message::response basic_action::handle_response(message::response response) {
00049          if (response == "Error") {
00050             if (response["Message"] == permission_error_string) {
00051                throw manager::permission_denied();
00052             }
00053             else if (response["Message"] == authentication_error_string) {
00054                throw manager::authentication_required();
00055             }
00056             else if (response["Message"] == "No timeout specified") {
00057                throw action::missing_data(response["Message"], action());
00058             }
00059             else if (response["Message"] == "No channel specified") {
00060                throw action::missing_data(response["Message"], action());
00061             }
00062             else if (response["Message"] == "Channel not specified") {
00063                throw action::missing_data(response["Message"], action());
00064             }
00065             else if (response["Message"] == "Extension not specified") {
00066                throw action::missing_data(response["Message"], action());
00067             }
00068             else if (response["Message"] == "No variable specified") {
00069                throw action::missing_data(response["Message"], action());
00070             }
00071             else if (response["Message"] == "No value specified") {
00072                throw action::missing_data(response["Message"], action());
00073             }
00074             else if (response["Message"] == "Mailbox not specified") {
00075                throw action::missing_data(response["Message"], action());
00076             }
00077             else if (response["Message"] == "Invalid priority") {
00078                throw action::bad_data(response["Message"], action());
00079             }
00080             else if (response["Message"] == "Invalid channel") {
00081                throw action::bad_data(response["Message"], action());
00082             }
00083             else if (response["Message"] == "Invalid timeout") {
00084                throw action::bad_data(response["Message"], action());
00085             }
00086             else if (response["Message"] == "No such channel") {
00087                throw action::channel_not_found(response["Message"], action());
00088             }
00089          }
00090          return response;
00091       }
00092 
00103       message::response basic_action::operator()(connection& c) {
00104          return handle_response(c(*this));
00105       }
00106    }
00107 }
00108 

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