Freya  0.0.1
A Gtk3 MPD Client
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
src/MPD/BaseClient.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_BASECLIENT_GUARD
00032 #define FREYA_BASECLIENT_GUARD
00033 
00034 #include "Listener.hh"
00035 #include "Connection.hh"
00036 #include "Query.hh"
00037 
00038 namespace MPD
00039 {
00052     class BaseClient
00053     {
00054     public:
00058         void go_idle();
00062         void go_busy();
00063 
00073         Connection& get_connection();
00074 
00080         bool is_connected();
00081 
00085         void begin();
00089         void commit();
00090 
00101         Status * get_status();
00102 
00111         EventNotifier& signal_client_update();
00112 
00118         ConnectionNotifier& signal_connection_change();
00119 
00127         void force_update();
00128 
00136         Query * create_db_songs_query(bool exact = false);
00137 
00145         Query * create_db_tag_query(mpd_tag_type tag);
00146 
00147     protected:
00148 
00152         BaseClient();
00153 
00159         bool __connect();
00165         bool __disconnect();
00166 
00170         MPD::Connection m_Conn;
00174         MPD::Listener * mp_Listener;
00175 
00179         bool m_ListBegun;
00180 
00181     private:
00182 
00191         gboolean timeout_reconnect();
00192 
00199         void handle_errors(bool is_fatal, mpd_error err);
00200 
00204         EventNotifier m_Notifier;
00205     };
00206 }
00207 
00208 #endif /* end of include guard: FREYA_BASECLIENT_GUARD */