Freya  0.0.1
A Gtk3 MPD Client
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
src/MPD/AbstractClientExtension.hh
Go to the documentation of this file.
00001 /***********************************************************
00002 * This file is part of Freya
00003 * - A free MPD Gtk3 MPD Client -
00004 *
00005 * Authors: Christopher Pahl, Christoph Piechula,
00006 *          Eduard Schneider
00007 *
00008 * Copyright (C) [2011-2012]
00009 * Hosted at: https://github.com/studentkittens/Freya
00010 *
00011 *              __..--''``---....___   _..._    __
00012 *    /// //_.-'    .-/";  `        ``<._  ``.''_ `. / // /
00013 *   ///_.-' _..--.'_                        `( ) ) // //
00014 *   / (_..-' // (< _     ;_..__               ; `' / ///
00015 *    / // // //  `-._,_)' // / ``--...____..-' /// / //
00016 *  Ascii-Art by Felix Lee <flee@cse.psu.edu>
00017 *
00018 * Freya is free software: you can redistribute it and/or modify
00019 * it under the terms of the GNU General Public License as published by
00020 * the Free Software Foundation, either version 3 of the License, or
00021 * (at your option) any later version.
00022 *
00023 * Freya is distributed in the hope that it will be useful,
00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00026 * GNU General Public License for more details.
00027 *
00028 * You should have received a copy of the GNU General Public License
00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>.
00030 **************************************************************/
00031 #ifndef FREYA_ABSTRACTCLIENTEXTENSION_HH
00032 #define FREYA_ABSTRACTCLIENTEXTENSION_HH
00033 
00034 namespace MPD
00035 {
00036     class BaseClient;
00037 
00041     class AbstractClientExtension
00042     {
00043     public:
00044 
00050         AbstractClientExtension(BaseClient& base_client)
00051         {
00052             mp_BaseClient = &base_client;
00053         }
00054 
00055     protected:
00056 
00057         BaseClient * mp_BaseClient;
00058     };
00059 
00060 /* Get the mpd_connection */
00061 #define get_c_connection()                                 \
00062         (mp_BaseClient->is_connected()) ?                  \
00063         mp_BaseClient->get_connection().get_connection() : \
00064         NULL
00065 
00066 /* Go into active mode */
00067 #define EXTERNAL_GET_BUSY                     \
00068             if(mp_BaseClient->is_connected()) \
00069             {                                 \
00070                 mp_BaseClient->go_busy();     \
00071                 mpd_connection * conn =       \
00072                 get_c_connection();           \
00073                 if(conn != NULL) {
00074 
00075 /* Go back idling, *never* forget this */
00076 #define EXTERNAL_GET_LAID                 \
00077                 }                         \
00078                 mp_BaseClient->go_idle(); \
00079             }
00080 
00081 }
00082 
00083 #endif /* end of include guard: FREYA_ABSTRACTCLIENTEXTENSION_HH */